瀏覽代碼

Optional and broken sets options in the GUI.

Iñigo Valentin 4 年之前
父節點
當前提交
de30ce1d48

+ 78 - 28
RuneOptimizerGUI/classes/PanelOptimizer.py

@@ -51,10 +51,14 @@ class PanelOptimizer(wx.Panel):
         Tho selctors to choose stats allowed in optimization.
     setChoiceList : wx.Choice[3]
         List of selector to pik rune sets.
+    optSetCheckListList : wx.CheckListBox
+        Selectors to choose optional rune sets.
     levelChoice : wx.Choice
         Selector to pick the level for the rune optimization.
     inventoryCheck : wx.Checkbox
-        Checkbox to use only runes in the inventory
+        Checkbox to use only runes in the inventory.
+    brokenCheck : wx.Checkbox
+        Checkbox to enable broken sets.
     teamCheckList : wx.CheckboxList :
         List of selectable teams to exclude from the optimization.
     progressGauge : wx.Gauge
@@ -479,26 +483,13 @@ class PanelOptimizer(wx.Panel):
 
         optSetBox = wx.StaticBox(
           self, label="Other Rune Sets:", id=wx.ID_ANY,
-          pos=(290, 300), size=(190, 190)
+          pos=(290, 300), size=(110, 190)
         )
         self.optionsSizer.Add(optSetBox)
-        self.optSetCheckListList = [
-          wx.CheckListBox(
-            parent=optSetBox, id=wx.ID_ANY, pos=(5, 5),
-            size=(70, 160), choices=names[1:7]
-          ),
-          wx.CheckListBox(
-            parent=optSetBox, id=wx.ID_ANY, pos=(75, 5),
-            size=(70, 160), choices=names[8:14]
-          ),
-          wx.CheckListBox(
-            parent=optSetBox, id=wx.ID_ANY, pos=(145, 5),
-            size=(70, 160), choices=names[9:24]
-          )
-        ]
-        for i in range(0, 3):
-            self.optSetCheckListList[i].SetFont(smallFont)
-
+        self.optSetCheckList = wx.CheckListBox(
+          parent=optSetBox, id=wx.ID_ANY, pos=(5, 5),
+          size=(100, 160), choices=names[1:]
+        )
         # Team list
         teams = []
         cursor = conn.execute("""
@@ -512,16 +503,9 @@ class PanelOptimizer(wx.Panel):
             teams.append(str(row[1]) + " (" + str(row[2]) + ")")
         teamsBox = wx.StaticBox(
           parent=self, label="Exclude runes from units in teams",
-          id=wx.ID_ANY, pos=(560, 300), size=(260, 170)
+          id=wx.ID_ANY, pos=(410, 300), size=(260, 170)
         )
-
-        # Inventory only option
         self.optionsSizer.Add(teamsBox)
-        self.inventoryCheck = wx.CheckBox(
-          parent=self, id=wx.ID_ANY, label="Only runes in storage",
-          pos=(560, 470), size=(180, 20)
-        )
-        self.optionsSizer.Add(self.inventoryCheck)
         self.teamCheckList = wx.CheckListBox(
           parent=teamsBox, id=wx.ID_ANY,
           pos=(5, 5), size=(250, 110), choices=teams
@@ -537,6 +521,20 @@ class PanelOptimizer(wx.Panel):
         self.Bind(wx.EVT_BUTTON, self.selectAllTeams, btAllTeams)
         self.Bind(wx.EVT_BUTTON, self.deselectAllTeams, btNoTeams)
 
+        # Broken sets option
+        self.brokenCheck = wx.CheckBox(
+          parent=self, id=wx.ID_ANY, label="Allow broken sets",
+          pos=(400, 470), size=(180, 20)
+        )
+        self.optionsSizer.Add(self.brokenCheck)
+
+        # Inventory only option
+        self.inventoryCheck = wx.CheckBox(
+          parent=self, id=wx.ID_ANY, label="Only runes in storage",
+          pos=(560, 470), size=(180, 20)
+        )
+        self.optionsSizer.Add(self.inventoryCheck)
+
         # Button to start
         btOptimize = wx.Button(
           parent=self, id=wx.ID_ANY, pos=(600, 500),
@@ -805,7 +803,8 @@ class PanelOptimizer(wx.Panel):
             if (actualId > 11):
                 actualId -= 1
             self.setChoiceList[i].SetSelection(actualId)
-
+        # Clear all optional sets
+        self.optSetCheckList.SetCheckedItems(())
 
 
         self.optionsSizer.ShowItems(True)
@@ -883,6 +882,55 @@ class PanelOptimizer(wx.Panel):
         if len(stats) > 0:
             stats = stats[:-1]
             # TODO: ELSE ERROR
+        # Optional sets
+        optSets = ""
+        for s in self.optSetCheckList.GetCheckedItems():
+            if s == 0:
+                optSets += "energy,"
+            elif s == 1:
+                optSets += "guard,"
+            elif s == 2:
+                optSets += "swift,"
+            elif s == 3:
+                optSets += "blade,"
+            elif s == 4:
+                optSets += "rage,"
+            elif s == 5:
+                optSets += "focus,"
+            elif s == 6:
+                optSets += "endure,"
+            elif s == 7:
+                optSets += "fatal,"
+            elif s == 8:
+                optSets += "despair,"
+            elif s == 9:
+                optSets += "vampire,"
+            elif s == 10:
+                optSets += "violent,"
+            elif s == 11:
+                optSets += "nemesis,"
+            elif s == 12:
+                optSets += "will,"
+            elif s == 13:
+                optSets += "shield,"
+            elif s == 14:
+                optSets += "revenge,"
+            elif s == 15:
+                optSets += "destroy,"
+            elif s == 16:
+                optSets += "fight,"
+            elif s == 17:
+                optSets += "determination,"
+            elif s == 18:
+                optSets += "enhance,"
+            elif s == 19:
+                optSets += "accuracy,"
+            elif s == 20:
+                optSets += "tolerance,"
+        if len(optSets) > 0:
+            optSets = optSets[:-1]
+            command += (" --opt-sets " + optSets)
+
         command += (" --stats " + stats)
         command += (" --min-hp " + str(self.minStatSlidList[0].GetValue()))
         command += (" --min-atk " + str(self.minStatSlidList[1].GetValue()))
@@ -897,6 +945,8 @@ class PanelOptimizer(wx.Panel):
 
         if self.inventoryCheck.GetValue():
             command += " --storage"
+        if self.brokenCheck.GetValue():
+            command += " --broken"
         if len(self.teamCheckList.GetCheckedItems()) > 0:
             command += " --no-teams "
             for team in self.teamCheckList.GetCheckedItems():

+ 6 - 6
src/RuneOptimizer/optimize/optimize.c

@@ -187,12 +187,12 @@ int cmd_optimize(int argc, char *argv[]){
 
     // Precalculate how many combinations will have to be tested.
     unsigned long long max_combinations =
-      rune_count[1] *
-      rune_count[2] *
-      rune_count[3] *
-      rune_count[4] *
-      rune_count[5] *
-      rune_count[6];
+      (unsigned long long) rune_count[1] *
+      (unsigned long long) rune_count[2] *
+      (unsigned long long) rune_count[3] *
+      (unsigned long long) rune_count[4] *
+      (unsigned long long) rune_count[5] *
+      (unsigned long long) rune_count[6];
 
     // Print summary with data collected so far. Skip for GUI.
     if (options.gui == FALSE){

+ 1 - 1
src/RuneOptimizer/optimize/optimize_parse_arguments.c

@@ -505,7 +505,7 @@ int optimize_parse_arguments(
         }
         // GUI invoked?
         else if (strcmp("--gui", argv[i]) == 0 || strcmp("-g", argv[i]) == 0){
-            options->gui = FALSE;
+            options->gui = TRUE;
         }
 
     }