[chronojump] comboSelectJumpsRj done!
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] comboSelectJumpsRj done!
- Date: Sat, 8 Oct 2016 12:34:21 +0000 (UTC)
commit 33cc1a96b6b654509c7afd9bc23ebed753312dbf
Author: Xavier de Blas <xaviblas gmail com>
Date: Sat Oct 8 14:33:38 2016 +0200
comboSelectJumpsRj done!
src/gui/chronojump.cs | 64 ++++++++++++-----------------------------
src/gui/cjCombo.cs | 36 +++++++++++++++++++----
src/gui/jump.cs | 11 +++----
src/sqlite/jumpType.cs | 67 ++++++++++++++++++++++++++++++++++--------
src/sqlite/usefulObjects.cs | 28 ++++++++++++++++++
5 files changed, 136 insertions(+), 70 deletions(-)
---
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index a56c753..62cf701 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -128,9 +128,9 @@ public partial class ChronoJumpWindow
[Widget] Gtk.TreeView treeview_multi_chronopic;
[Widget] Gtk.HBox hbox_combo_select_jumps;
- [Widget] Gtk.Box hbox_combo_select_jumps_rj;
- [Widget] Gtk.Box hbox_combo_select_runs;
- [Widget] Gtk.Box hbox_combo_select_runs_interval;
+ [Widget] Gtk.HBox hbox_combo_select_jumps_rj;
+ [Widget] Gtk.HBox hbox_combo_select_runs;
+ [Widget] Gtk.HBox hbox_combo_select_runs_interval;
//auto mode
[Widget] Gtk.Box hbox_jump_types_options;
@@ -167,6 +167,7 @@ public partial class ChronoJumpWindow
[Widget] Gtk.ComboBox combo_select_runs_interval;
CjComboSelectJumps comboSelectJumps; //new since 1.6.3. Using gui/cjCombo.cs
+ CjComboSelectJumpsRj comboSelectJumpsRj; //new since 1.6.3. Using gui/cjCombo.cs
[Widget] Gtk.ComboBox combo_result_jumps;
[Widget] Gtk.ComboBox combo_result_jumps_rj;
@@ -1940,7 +1941,6 @@ public partial class ChronoJumpWindow
* --------------------------------------------------------
*/
- string [] selectJumpsRjString;
string [] selectRunsString;
string [] selectRunsIntervalString;
@@ -1959,33 +1959,16 @@ public partial class ChronoJumpWindow
}
}
- private void createComboSelectJumpsRj(bool create) {
+ private void createComboSelectJumpsRj(bool create)
+ {
if(create)
- combo_select_jumps_rj = ComboBox.NewText ();
-
- string [] jumpTypes = SqliteJumpType.SelectJumpRjTypes("", false); //without alljumpsname,
not only name
- selectJumpsRjString = new String [jumpTypes.Length];
- string [] jumpNamesToCombo = new String [jumpTypes.Length];
- int i =0;
- foreach(string jumpType in jumpTypes) {
- string [] j = jumpType.Split(new char[] {':'});
- string nameTranslated = Catalog.GetString(j[1]);
- selectJumpsRjString[i] =
- j[0] + ":" + j[1] + ":" + nameTranslated + ":" + //uniqueID, name,
nameTranslated
- j[2] + ":" + j[3] + ":" + j[4] + ":" + //startIn, weight,
jumpsLimited
- j[5] + ":" + j[6]; //fixedValue,
description
- jumpNamesToCombo[i] = nameTranslated;
- i++;
- }
-
- UtilGtk.ComboUpdate(combo_select_jumps_rj, jumpNamesToCombo, "");
- combo_select_jumps_rj.Active = 0;
- combo_select_jumps_rj.Changed += new EventHandler (on_combo_select_jumps_rj_changed);
-
- if(create) {
- hbox_combo_select_jumps_rj.PackStart(combo_select_jumps_rj, true, true, 0);
- hbox_combo_select_jumps_rj.ShowAll();
- combo_select_jumps_rj.Sensitive = false;
+ {
+ comboSelectJumpsRj = new CjComboSelectJumpsRj(combo_select_jumps_rj,
hbox_combo_select_jumps_rj);
+ combo_select_jumps_rj = comboSelectJumpsRj.Combo;
+ combo_select_jumps_rj.Changed += new EventHandler (on_combo_select_jumps_rj_changed);
+ } else {
+ comboSelectJumpsRj.Fill();
+ combo_select_jumps_rj = comboSelectJumpsRj.Combo;
}
}
@@ -4141,10 +4124,6 @@ public partial class ChronoJumpWindow
private void on_rj_activate (object o, EventArgs args)
{
- //currentJumpRjType is already defined in selecting name from combo or from jumpsMoreWin
- //string jumpEnglishName = Util.FindOnArray(':',2,1,
UtilGtk.ComboGetActive(combo_select_jumps_rj), selectJumpsRjString);
- //currentJumpRjType = new JumpType(jumpEnglishName);
-
double progressbarLimit = 0;
//if it's a unlimited interval run, put -1 as limit value
@@ -5936,7 +5915,7 @@ LogB.Debug("X");
SqliteJumpType.SelectJumpTypes(false, Constants.AllJumpsName, "",
true), ""); //without filter, only select name
new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Added simple
jump."));
} else {
- createComboSelectJumpsRj(false); //this will update also the selectJumpsRjString
+ createComboSelectJumpsRj(false);
UtilGtk.ComboUpdate(combo_result_jumps_rj,
SqliteJumpType.SelectJumpRjTypes(Constants.AllJumpsName, true), "");
//without filter, only select name
@@ -6033,17 +6012,12 @@ LogB.Debug("X");
extra_window_jumps_initialize(new JumpType("Free"));
}
- private void on_deleted_jump_rj_type (object o, EventArgs args) {
- //first delete if from combos
- string translatedName = Util.FindOnArray(':', 2, 1, jumpsRjMoreWin.SelectedEventName,
selectJumpsRjString);
- UtilGtk.ComboDelThisValue(combo_select_jumps_rj, translatedName);
- UtilGtk.ComboDelThisValue(combo_result_jumps_rj, translatedName);
-
- //2nd delete if from global string. -1 selects all row
- string row = Util.FindOnArray(':',1, -1, jumpsRjMoreWin.SelectedEventName,
selectJumpsRjString);
- selectJumpsRjString = Util.DeleteString(selectJumpsRjString, row);
+ private void on_deleted_jump_rj_type (object o, EventArgs args)
+ {
+ string translatedName =
comboSelectJumpsRj.GetNameTranslated(jumpsRjMoreWin.SelectedEventName);
+ combo_select_jumps_rj = comboSelectJumpsRj.DeleteValue(translatedName);
- combo_select_jumps_rj.Active = 0;
+ UtilGtk.ComboDelThisValue(combo_result_jumps_rj, translatedName);
combo_result_jumps_rj.Active = 0;
extra_window_jumps_rj_initialize(new JumpType("RJ(j)"));
diff --git a/src/gui/cjCombo.cs b/src/gui/cjCombo.cs
index e4e1e78..3a8c533 100644
--- a/src/gui/cjCombo.cs
+++ b/src/gui/cjCombo.cs
@@ -109,9 +109,7 @@ public class CjComboSelectJumps : CjCombo
this.hbox = hbox_combo_select_jumps;
create();
-
Fill();
-
package();
}
@@ -120,13 +118,39 @@ public class CjComboSelectJumps : CjCombo
{
l_types = (List<object>) SqliteJumpType.SelectJumpTypesNew(false, "", "", false); //without
alljumpsname, without filter, not only name
- string [] jumpNamesToCombo = new String [l_types.Count];
+ string [] namesToCombo = new String [l_types.Count];
int i =0;
- foreach(SelectJumpTypes jumpType in l_types)
- jumpNamesToCombo[i++] = jumpType.NameTranslated;
+ foreach(SelectJumpTypes type in l_types)
+ namesToCombo[i++] = type.NameTranslated;
- UtilGtk.ComboUpdate(combo, jumpNamesToCombo, "");
+ UtilGtk.ComboUpdate(combo, namesToCombo, "");
combo.Active = 0;
}
+}
+
+public class CjComboSelectJumpsRj : CjCombo
+{
+ public CjComboSelectJumpsRj(Gtk.ComboBox combo_select_jumps_rj, Gtk.HBox hbox_combo_select_jumps_rj)
+ {
+ this.combo = combo_select_jumps_rj;
+ this.hbox = hbox_combo_select_jumps_rj;
+
+ create();
+ Fill();
+ package();
+ }
+
+ //if we just need to update values, call only this method
+ public override void Fill()
+ {
+ l_types = (List<object>) SqliteJumpType.SelectJumpRjTypesNew("", false); //without
alljumpsname, not only name
+ string [] namesToCombo = new String [l_types.Count];
+ int i =0;
+ foreach(SelectJumpRjTypes type in l_types)
+ namesToCombo[i++] = type.NameTranslated;
+
+ UtilGtk.ComboUpdate(combo, namesToCombo, "");
+ combo.Active = 0;
+ }
}
diff --git a/src/gui/jump.cs b/src/gui/jump.cs
index 5f4f5a4..0ab8691 100644
--- a/src/gui/jump.cs
+++ b/src/gui/jump.cs
@@ -1100,7 +1100,7 @@ partial class ChronoJumpWindow
private void on_extra_window_jumps_rj_test_changed(object o, EventArgs args)
{
- string jumpEnglishName = Util.FindOnArray(':',2,1,
UtilGtk.ComboGetActive(combo_select_jumps_rj), selectJumpsRjString);
+ string jumpEnglishName = comboSelectJumpsRj.GetSelectedNameEnglish();
currentJumpRjType = createJumpType(jumpEnglishName, false);
extra_window_jumps_rj_initialize(currentJumpRjType);
@@ -1267,17 +1267,16 @@ partial class ChronoJumpWindow
SqlitePreferences.Update("allowFinishRjAfterTime",
checkbutton_allow_finish_rj_after_time.Active.ToString(), false);
}
- private void on_more_jumps_update_test (object o, EventArgs args)
+ private void on_more_jumps_update_test (object o, EventArgs args)
{
currentEventType = new JumpType(jumpsMoreWin.SelectedEventName);
comboSelectJumps.MakeActive(jumpsMoreWin.SelectedEventName);
}
- private void on_more_jumps_rj_update_test (object o, EventArgs args) {
+ private void on_more_jumps_rj_update_test (object o, EventArgs args)
+ {
currentEventType = new JumpType(jumpsRjMoreWin.SelectedEventName);
- string jumpTranslatedName = Util.FindOnArray(':',1,2, jumpsRjMoreWin.SelectedEventName,
selectJumpsRjString);
-
- combo_select_jumps_rj.Active = UtilGtk.ComboMakeActive(combo_select_jumps_rj,
jumpTranslatedName);
+ comboSelectJumpsRj.MakeActive(jumpsRjMoreWin.SelectedEventName);
}
//used from the dialogue "jumps more"
diff --git a/src/sqlite/jumpType.cs b/src/sqlite/jumpType.cs
index f04ddf9..ff8b547 100644
--- a/src/sqlite/jumpType.cs
+++ b/src/sqlite/jumpType.cs
@@ -267,38 +267,34 @@ class SqliteJumpType : Sqlite
SqliteDataReader reader;
reader = dbcmd.ExecuteReader();
- List<object> jumpTypes = new List<object>();
+ List<object> types = new List<object>();
- int count = new int();
- count = 0;
-
- SelectJumpTypes jumpType;
+ SelectJumpTypes type;
if(allJumpsName != "") {
- jumpType = new SelectJumpTypes(allJumpsName);
- jumpTypes.Add(jumpType);
+ type = new SelectJumpTypes(allJumpsName);
+ types.Add(type);
}
while(reader.Read()) {
if(onlyName) {
- jumpType = new SelectJumpTypes(reader[1].ToString());
+ type = new SelectJumpTypes(reader[1].ToString());
} else {
- jumpType = new SelectJumpTypes(
+ type = new SelectJumpTypes(
Convert.ToInt32(reader[0]), //uniqueID
reader[1].ToString(), //nameEnglish
Util.IntToBool(Convert.ToInt32(reader[2].ToString())),
//startIn
Util.IntToBool(Convert.ToInt32(reader[3].ToString())),
//hasWeight
reader[4].ToString()); //description
}
- jumpTypes.Add(jumpType);
+ types.Add(type);
}
reader.Close();
closeIfNeeded(dbconOpened);
- return jumpTypes;
+ return types;
}
-
-
+ //on newly cereated code use above method
public static string[] SelectJumpTypes(bool dbconOpened, string allJumpsName, string filter, bool
onlyName)
{
//allJumpsName: add and "allJumpsName" value
@@ -370,6 +366,51 @@ class SqliteJumpType : Sqlite
return myTypes;
}
+ //use SelectJumpTypes object. Since 1.6.3
+ public static List<object> SelectJumpRjTypesNew(string allJumpsName, bool onlyName)
+ {
+ Sqlite.Open();
+ dbcmd.CommandText = "SELECT * " +
+ " FROM " + Constants.JumpRjTypeTable + " " +
+ " ORDER BY uniqueID";
+
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ SqliteDataReader reader;
+ reader = dbcmd.ExecuteReader();
+
+ List<object> types = new List<object>();
+
+ SelectJumpRjTypes type;
+ if(allJumpsName != "") {
+ type = new SelectJumpRjTypes(allJumpsName);
+ types.Add(type);
+ }
+
+ while(reader.Read()) {
+ if(onlyName) {
+ type = new SelectJumpRjTypes(reader[1].ToString());
+ } else {
+ type = new SelectJumpRjTypes(
+ Convert.ToInt32(reader[0]), //uniqueID
+ reader[1].ToString(), //nameEnglish
+ Util.IntToBool(Convert.ToInt32(reader[2].ToString())),
//startIn
+ Util.IntToBool(Convert.ToInt32(reader[3].ToString())),
//hasWeight
+ Util.IntToBool(Convert.ToInt32(reader[4].ToString())),
//jumpsLimited
+
Convert.ToDouble(Util.ChangeDecimalSeparator(reader[5].ToString())), //fixedValue
+ reader[6].ToString() //description
+ );
+ }
+ types.Add(type);
+ }
+
+ reader.Close();
+ Sqlite.Close();
+
+ return types;
+ }
+ //on newly cereated code use above method
public static string[] SelectJumpRjTypes(string allJumpsName, bool onlyName)
{
Sqlite.Open();
diff --git a/src/sqlite/usefulObjects.cs b/src/sqlite/usefulObjects.cs
index dbaccb3..2a91113 100644
--- a/src/sqlite/usefulObjects.cs
+++ b/src/sqlite/usefulObjects.cs
@@ -38,6 +38,11 @@ public class SelectJumpTypes : SelectTypes
public bool HasWeight;
public string Description;
+ //needed for inheritance
+ public SelectJumpTypes()
+ {
+ }
+
public SelectJumpTypes(string nameEnglish)
{
this.NameEnglish = nameEnglish;
@@ -54,3 +59,26 @@ public class SelectJumpTypes : SelectTypes
}
}
+public class SelectJumpRjTypes : SelectJumpTypes
+{
+ public bool JumpsLimited;
+ public double FixedValue;
+
+ public SelectJumpRjTypes(string nameEnglish)
+ {
+ this.NameEnglish = nameEnglish;
+ }
+
+ public SelectJumpRjTypes(int id, string nameEnglish, bool startIn, bool hasWeight, bool jumpsLimited,
double fixedValue, string description)
+ {
+ this.Id = id;
+ this.NameEnglish = nameEnglish;
+ this.NameTranslated = Catalog.GetString(nameEnglish);
+ this.StartIn = startIn;
+ this.HasWeight = hasWeight;
+ this.JumpsLimited = jumpsLimited;
+ this.FixedValue = fixedValue;
+ this.Description = description;
+ }
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]