Browse Source

RTA import mode.

Iñigo Valentin 4 năm trước cách đây
mục cha
commit
ebfd8f81e4

+ 1 - 1
src/cli/runeoptimizer/db/db.c

@@ -169,7 +169,7 @@ extern int db_execute(char query[], char *parameters[]){
           stmt, i + 1, parameters[i], strlen(parameters[i]), NULL
         );
     }
-    //printf("PREP QUERY: %s\n", sqlite3_expanded_sql(stmt));
+    //printf("\tPREP QUERY: %s\n", sqlite3_expanded_sql(stmt));
     if (SQLITE_DONE != sqlite3_step(stmt)){
         fprintf(
           stderr, "ERROR Executing statement '%s': %s\n",

+ 14 - 0
src/cli/runeoptimizer/error/error.h

@@ -343,6 +343,13 @@
  */
 #define ERROR_INPUT_UPDATE_NO_ARGUMENTS -125
 
+/**
+ * Update command user input error.
+ *
+ * Indicates that no a wrong mode has been passed.
+ */
+#define ERROR_INPUT_UPDATE_MODE -125
+
 /**
  * Update command user input error.
  *
@@ -503,6 +510,13 @@
  */
 #define ERROR_DB_UPDATE_TEAMS -224
 
+/**
+ * Database error.
+ *
+ * Error updating the table runes.
+ */
+#define ERROR_DB_UPDATE_RUNES -224
+
 /**
  * Database error.
  *

+ 11 - 5
src/cli/runeoptimizer/optimize/optimize.c

@@ -131,8 +131,8 @@ static int initialize_data(Optimizer_Data *data);
  * function of the program.
  * @param[in] argv Arguments passed to the optimizer. As a rule, they must be
  * the same than the argv received by the {@link main} function of the program
- * without the first three (program name, command and unit ID). Only two of them
- * are mandatory: --stats / -T and --sets / -N.
+ * without the first two (program name and command). Only two of them are
+ * mandatory: --stats / -T and --sets / -N.
  * @param[out] data Data where the options wil be stored.
  * @return {@link SUCCESS} if every argument could be parsed, or an error
  * defined in {@link error.h} if there were problems with any of them.
@@ -468,6 +468,12 @@ static int calculate_rune_count(Optimizer_Data *data){
 }
 
 extern int optimize(int argc, char *argv[]){
+
+    if (argc == 0){
+        fprintf(stderr, "No unit specified.\n");
+        return ERROR_INPUT_OPTIMIZE_NO_UNIT;
+    }
+
     Optimizer_Data opt_data;
     int status = SUCCESS;
     char query_even[RUNE_QUERY_LEN];
@@ -481,7 +487,7 @@ extern int optimize(int argc, char *argv[]){
     if ((status = initialize_data(&opt_data)) != SUCCESS) return status;
     // Parse command line arguments.
 
-    if ((status = parse_arguments(argc - 1, argv + 1, &opt_data)) != SUCCESS)
+    if ((status = parse_arguments(argc, argv, &opt_data)) != SUCCESS)
         return status;
     // Get the unit from the database.
     if ((status = read_unit(argv[0], opt_data.unit)) != SUCCESS) return status;
@@ -1448,9 +1454,9 @@ static thrd_start_t optimize_thread(void *data_ptr){
                 stats.hp +=
                   data->unit->base_hp * 0.08 * (set_count.enhance % 2);
             if (set_count.accuracy >= 2) // +10% ACC per set of 2
-                stats.acc += 20;
+                stats.acc += 10;
             if (set_count.tolerance >= 2) // +10% RES per set of 2
-                stats.res += 20;
+                stats.res += 10;
 
             // Cap cappable stats
             if (stats.crr > 100) stats.crr = 100;

+ 75 - 31
src/cli/runeoptimizer/update/update.c

@@ -25,6 +25,8 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <stdbool.h>
+#include <getopt.h>
 #include "../runeoptimizer.h"
 #include "../error/error.h"
 #include "update.h"
@@ -147,44 +149,46 @@ const int MAIN_STATS_VALUES[DIFFERENT_STATS][RUNE_MAX_STARS + 1][2] = {
   }
 };
 
-extern int update(int argc, char *argv[]){
+/**
+ * Parses the arguments for the update command.
+ *
+ * Processes the argument list, looking for recognized commands and sets up the
+ * options for the updates. Unrecognized arguments get ignored.
+ * If a command has been wrongly passed or couldn't be parsed, a message will be
+ * printed to stderr.
+ *
+ * @param[in] argc Number of argument passed to the optimizer command. As a
+ * rule, it must me three less than the argc received by the {@link main}
+ * function of the program.
+ * @param[in] argv Arguments passed to the optimizer. As a rule, they must be
+ * the same than the argv received by the {@link main} function of the program
+ * without the first three (program name, command and source).
+ * @param[out] options Structure where the options wil be stored.
+ * @return {@link SUCCESS} if every argument could be parsed, or an error
+ * defined in {@link error.h} if there were problems with any of them.
+ */
+static int parse_arguments(int argc, char *argv[], Update_Options *options);
 
-    // Options
-    unsigned char six_stars = FALSE;
-    unsigned char with_runes = FALSE;
-    unsigned char clear_teams = FALSE;
-    unsigned char gui = FALSE;
+extern int update(int argc, char *argv[]){
 
     // One argument mandatory
     if (argc == 0){
         fprintf(
           stderr,
-          "update command takes 1 or more arguments, %d supplied\n", argc - 3
+          "update command takes 1 or more arguments, %d supplied\n", argc - 1
         );
         return ERROR_INPUT_UPDATE_NO_ARGUMENTS;
     }
 
-    // Parse options, skip first arg
-    for (int i = 1; i < argc; i ++){
-        if (strcmp("--six-stars", argv[i]) == 0 || strcmp("-s", argv[i]) == 0){
-            six_stars = TRUE;
-        }
-        else if (
-          strcmp("--with-runes", argv[i]) == 0 || strcmp("-r", argv[i]) == 0
-        ){
-            with_runes = TRUE;
-        }
-        else if (
-          strcmp("--clear-teams", argv[i]) == 0 || strcmp("-t", argv[i]) == 0
-        ){
-            clear_teams = TRUE;
-        }
-        else if (
-          strcmp("--gui", argv[i]) == 0 || strcmp("-g", argv[i]) == 0
-        ){
-            gui = TRUE;
-        }
-    }
+    // Options
+    int status = SUCCESS;
+    Update_Options options;
+    options.rta = false;
+    options.lower = false;
+    options.runes = false;
+    options.quiet = false;
+    if ((status = parse_arguments(argc, argv, &options)) != SUCCESS)
+        return status;
 
     // First, test json
     if (strlen(argv[0]) > 5){
@@ -192,12 +196,52 @@ extern int update(int argc, char *argv[]){
         strncpy(extension, argv[0] + strlen(argv[0]) - 5, 5);
         extension[5] = '\0';
         if (strcmp(extension, ".json") == 0){
-            return update_json(
-              argv[0], six_stars, with_runes, clear_teams, gui
-            );
+            return update_json(argv[0], &options);
         }
     }
     // TODO: More ifs as more options are implemented...
     fprintf(stderr, "Unknwon source supplied: %s\n", argv[0]);
     return ERROR_INPUT_UPDATE_UNKNOWN_SOURCE;
 }
+
+static int parse_arguments(int argc, char *argv[], Update_Options *options){
+    int opt;
+    static struct option long_options[] = {
+      // Output options
+      {"quiet",       no_argument,       0, 'q'},
+      {"clear-teams", no_argument,       0, 't'},
+      {"lower-level", no_argument,       0, 'l'},
+      {"runes",       no_argument,       0, 'r'},
+      {"mode",        required_argument, 0, 'm'},
+      {0, 0, 0, 0}
+    };
+    while (1){
+        int option_index = 0;
+        opt = getopt_long(argc, argv, "qtlrm:", long_options, &option_index);
+        // Exit on end.
+        if (opt == -1) break;
+        switch (opt){
+            case 0:  break; // Not using flags
+            case 'q': options->quiet = true; break; // quiet
+            case 't': options->clear = true; break; // clear-teams
+            case 'l': options->lower = true; break; // lower-level
+            case 'r': options->runes = true; break; // runes
+            case 'm': // mode
+                if (0 == strcmp("normal", optarg))
+                    options->rta = false;
+                else if (0 == strcmp("rta", optarg))
+                    options->rta = true;
+                else{
+                    fprintf(
+                      stderr,
+                      "Unrecognized mode '%s'. Accepted values are 'normal' "
+                      "and 'rta'.\n", optarg
+                    );
+                    return ERROR_INPUT_UPDATE_MODE;
+                }
+                break;
+        }
+    }
+
+    return SUCCESS;
+}

+ 49 - 10
src/cli/runeoptimizer/update/update.h

@@ -26,6 +26,7 @@
 
 #pragma once
 
+#include <stdbool.h>
 #include "../runeoptimizer.h"
 
 /**
@@ -36,6 +37,48 @@
  */
 #define MAX_SUBSTATS 4
 
+/**
+ * Options for the updater.
+ */
+typedef struct Update_Options{
+
+    /**
+     * Indicator for RTA mode.
+     *
+     * If true, RTA runes will be used. If false, normal runes will be used.
+     */
+    bool rta;
+
+    /**
+     * Indicator to import monsters with lower level.
+     *
+     * If false, only monsters at level 40 will be imported. If true, every
+     * monsters
+     */
+    bool lower;
+
+    /**
+     * Indicator to import only monsters with runes.
+     *
+     * If true, monsters without runes will not be imported.
+     */
+    bool runes;
+
+    /**
+     * Indicator to clear teams.
+     *
+     * When true, data from tables teams and units_teams will be deleted.
+     */
+    bool clear;
+
+    /**
+     * Indicator to supress output.
+     *
+     * When true, nothing will be written to stdout.
+     */
+    bool quiet;
+} Update_Options;
+
 /**
  * Structure representing a rune stat
  *
@@ -702,10 +745,13 @@ extern void update_get_monster_name(int id, char name[UNIT_NAME_LEN]);
  * @param[in] id Player ID.
  * @param[in] name Player name.
  * @param[in] level Player level.
+ * @param[in] rta RTA mode indicator.
  * @return {@link SUCCESS} if the info is saved or {@link ERROR_DB_INSERT_INFO}
  * on error.
  */
-extern int update_info(const char *id, const char *name, const char *level);
+extern int update_info(
+  const char *id, const char *name, const char *level, bool rta
+);
 
 /**
  * Updates the database from a json file.
@@ -714,18 +760,11 @@ extern int update_info(const char *id, const char *name, const char *level);
  * files from other applications may work, but with no guarantees.
  *
  * @param[in] file Path to the file.
- * @param[in] six_stars Indicator to import only 6* units. Units with runes will
- * be saved anyway.
- * @param[in] with_runes Indicator to import only units with runes.
- * @param[in] clear_teams Indicator to recreate tables teams and units_teams.
- * @param[in] gui Indicator to format output for thr GUI.
+ * @param[in] options Options passed to the updater.
  * @return {@link SUCCESS} if the update were performed, or an error defined
  * in {@link error.h} if there were errors.
  */
-extern int update_json(
-  char file[], unsigned char six_stars,
-  unsigned char with_runes, unsigned char clear_teams, unsigned char gui
-);
+extern int update_json(char file[], Update_Options *options);
 
 /**
  * Calculates the total stat values for a rune.

+ 3 - 1
src/cli/runeoptimizer/update/update_db_tables.c

@@ -154,7 +154,8 @@ extern int update_db_tables(unsigned char clear_teams){
         "  current_crr INT,"
         "  current_crd INT,"
         "  current_res INT,"
-        "  current_acc INT"
+        "  current_acc INT,"
+        "  modified INT"
         ");",
         NULL
       )
@@ -174,6 +175,7 @@ extern int update_db_tables(unsigned char clear_teams){
         "  player_id CHAR(12),"
         "  player_name CHAR(64),"
         "  player_level INT,"
+        "  rta INT,"
         "  ts DATETIME,"
         "  modified INT"
         ");",

+ 9 - 5
src/cli/runeoptimizer/update/update_info.c

@@ -28,12 +28,15 @@
 #include <sqlite3.h>
 #include <string.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <time.h>
 #include "../error/error.h"
 #include "../db/db.h"
 #include "../runeoptimizer.h"
 
-extern int update_info(const char *id, const char *name, const char *level){
+extern int update_info(
+  const char *id, const char *name, const char *level, bool rta
+){
     time_t t = time(NULL);
     struct tm tm = *localtime(&t);
     char ts[130];
@@ -43,18 +46,19 @@ extern int update_info(const char *id, const char *name, const char *level){
       tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
       tm.tm_hour, tm.tm_min, tm.tm_sec
     );
-    char *query_parameters[5];
-    for (int i = 0; i < 5; i ++) query_parameters[i] = malloc(strlen(ts));
+    char *query_parameters[6];
+    for (int i = 0; i < 6; i ++) query_parameters[i] = malloc(strlen(ts));
     sprintf(query_parameters[0], "%s", id);
     sprintf(query_parameters[1], "%s", name);
     sprintf(query_parameters[2], "%s", level);
     query_parameters[3] = ts;
     query_parameters[4] = "0"; // Modified, always 0.
+    sprintf(query_parameters[5], "%d", rta);
     if (
       SUCCESS !=
       db_execute(
-        "INSERT INTO info ( player_id, player_name, player_level, ts, modified)"
-        "VALUES (?, ?, ?, ?, ?)",
+        "INSERT INTO info ( player_id, player_name, player_level, ts, modified, rta)"
+        "VALUES (?, ?, ?, ?, ?, ?)",
         query_parameters
       )
     ){

+ 76 - 24
src/cli/runeoptimizer/update/update_json.c

@@ -56,9 +56,7 @@ static int update_json_rune(json_object *rune_json, unsigned char *unit_id);
  * stderr.
  *
  * @param[in] unit_json Unit json fragment.
- * @param[in] six_stars Indicator to import only 6* units. Units with runes will
- * be saved anyway.
- * @param[in] with_runes Indicator to import only units with runes.
+ * @param[in] options Options passed to the updater.
  * @param[out] total_runes Cunter for runes. Will be increased for each saved
  * rune.
  * @param[out] total_stats Cunter for rune stats. Will be increased for each
@@ -67,20 +65,28 @@ static int update_json_rune(json_object *rune_json, unsigned char *unit_id);
  * the unit was not saved because it did not match the criteria. -1 on error.
  */
 static int update_json_unit(
-  json_object *unit_json, unsigned char six_stars,
-  unsigned char with_runes, unsigned int *total_runes, unsigned int *total_stats
+  json_object *unit_json, Update_Options *options,
+  unsigned int *total_runes, unsigned int *total_stats
 );
 
-extern int update_json(
-  char file[], unsigned char six_stars,
-  unsigned char with_runes, unsigned char clear_teams, unsigned char gui
-){
+/**
+ * Saves runes for RTA mode.
+ *
+ * Unassigns every rune in the database, and then updates them from the json
+ * file.
+ *
+ * @param[in] runes world_arena_rune_equip_list object of the json.
+ * @return number of runes assigned in rta mode.
+ */
+static int save_rta_runes(json_object *runes);
+
+extern int update_json(char file[], Update_Options *options){
     // Counters for objcts saved
     unsigned int total_units = 0;
     unsigned int total_runes = 0;
     unsigned int total_stats = 0;
 
-    if (gui == FALSE) printf("Updating from json file: %s\n", file);
+    if (!options->quiet) printf("Updating from json file: %s\n", file);
 
     // Read the JSON content
     json_object *root = json_object_from_file(file);
@@ -101,7 +107,7 @@ extern int update_json(
     fflush(stdout); // To refresh GUI output.
 
     // Recreate the database tables
-    int status = update_db_tables(clear_teams);
+    int status = update_db_tables(options->clear);
     if (SUCCESS != status) return(status);
 
     // Parse runes
@@ -122,7 +128,7 @@ extern int update_json(
         idx = json_object_array_get_idx(unit_list, i);
 
         status = update_json_unit(
-          idx, six_stars, with_runes, &total_runes, &total_stats
+          idx, options, &total_runes, &total_stats
         );
         if (status == 1) total_units ++;
     }
@@ -130,11 +136,19 @@ extern int update_json(
     status = update_current_stats();
     if (SUCCESS != status) return(status);
 
+    // If rta mode, update rta runes
+    if (options->rta){
+        json_object *rta_runes =
+          json_object_object_get(root, "world_arena_rune_equip_list");
+        save_rta_runes(rta_runes);
+    }
+
     // Insert into table info
     status = update_info(
       json_object_get_string(wizard_id),
       json_object_get_string(wizard_name),
-      json_object_get_string(wizard_level)
+      json_object_get_string(wizard_level),
+      options->rta
     );
     if (SUCCESS != status) return(status);
 
@@ -390,11 +404,11 @@ static int update_json_rune(json_object *rune_json, unsigned char *unit_id){
 }
 
 static int update_json_unit(
-  json_object *unit_json, unsigned char six_stars,
-  unsigned char with_runes, unsigned int *total_runes, unsigned int *total_stats
+  json_object *unit_json, Update_Options *options,
+  unsigned int *total_runes, unsigned int *total_stats
 ){
     int ret_val = 0;
-    unsigned char unit_has_runes = FALSE;
+    bool unit_has_runes = false;
     struct DB_Unit unit;
     char *query_parameters[23];
     for (int i = 1; i < 23; i ++) query_parameters[i] = malloc(5);
@@ -449,7 +463,7 @@ static int update_json_unit(
     json_object *unit_runes = json_object_object_get(unit_json, "runes");
     int rune_count = json_object_array_length(unit_runes);
     for (int i = 0; i < rune_count; i++){
-        unit_has_runes = TRUE;
+        unit_has_runes = true;
         // TODO: Test this: reference or value?
         total_runes ++;
         json_object *idx = json_object_array_get_idx(unit_runes, i);
@@ -459,9 +473,14 @@ static int update_json_unit(
 
     // Insert unit, depending on flags and status
     if (
-        unit_has_runes == TRUE ||
-        (six_stars == FALSE && with_runes == FALSE) ||
-        (six_stars == TRUE && unit.stars == TRUE)
+        unit_has_runes
+        || (
+          !options->runes // If no runes, and only runes flag, don't
+          && (
+            (unit.level < 40 && options->lower) // lv<40 only with lower flag
+            || (unit.level == 40)
+          )
+        )
     ){
         ret_val = 1;
         query_parameters[0] = (char *) unit.id;
@@ -498,16 +517,49 @@ static int update_json_unit(
             "  base_crr,    base_crd,    base_res,    base_acc,"
             "  current_hp,  current_atk, current_def, current_spd,"
             "  current_crr, current_crd, current_res, current_acc,"
-            "  storage, monster"
+            "  storage, monster, modified"
             ") VALUES ("
-            "  ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?"
+            "  ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "
+            "  ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0"
             ")",
           query_parameters
           )
         ){
             fprintf(stderr, "Unable to insert unit: %s\n", sqlite3_errmsg(db));
-            return(-1);
+            return ERROR_DB_INSERT_UNITS;
+        }
+    }
+    return ret_val;
+}
+
+static int save_rta_runes(json_object *runes){
+    // Unassigne every rune
+    if (SUCCESS != db_execute("UPDATE runes SET unit = '' ", NULL)){
+        fprintf(
+          stderr, "Unable to clear runes for RTA: %s\n", sqlite3_errmsg(db)
+        );
+        return ERROR_DB_UPDATE_RUNES;
+    }
+    // Loop the json object and save the runes
+    int count = json_object_array_length(runes);
+    char *parameters[2]; // RUNE_ID_LEN > UNIT_ID_LEN
+    parameters[0] = malloc(sizeof(char) * (RUNE_ID_LEN + 1));
+    parameters[1] = malloc(sizeof(char) * (RUNE_ID_LEN + 1));
+
+    json_object *idx;
+    int i;
+    for (i = 0; i < count; i++){
+        idx = json_object_array_get_idx(runes, i);
+        json_object *rune_id = json_object_object_get(idx, "rune_id");
+        json_object *unit_id = json_object_object_get(idx, "occupied_id");
+        strcpy(parameters[0], json_object_get_string(unit_id));
+        strcpy(parameters[1], json_object_get_string(rune_id));
+        if (SUCCESS != db_execute(
+          "UPDATE runes SET unit = ? WHERE id = ?", parameters)
+        ){
+            fprintf(stderr, "Error saving RTA rune: %s\n", sqlite3_errmsg(db));
+            return ERROR_DB_UPDATE_RUNES;
         }
     }
-    return(ret_val);
+    return i;
 }

+ 48 - 48
src/gui/runeoptimizer_gui/gui/DialogUpdateJson.py

@@ -41,7 +41,7 @@ class DialogUpdateJson(wx.Dialog):
     _message_sizer = None
     _button_sizer = None
     _file_selector = None
-    _stars_check = None
+    _level_check = None
     _runes_check = None
     _clear_teams_check = None
     update_done = False
@@ -66,72 +66,64 @@ class DialogUpdateJson(wx.Dialog):
 
         # Parent constructor
         wx.Dialog.__init__(
-          self, parent=parent, id=id, pos=(50, 50), size=(400, 290),
+          self, parent, id,
           title="Update from JSON file", style=wx.DEFAULT_DIALOG_STYLE
         )
-
+        dialog_sizer = wx.BoxSizer(wx.VERTICAL)
         self._form_sizer = wx.BoxSizer(wx.VERTICAL)
         self._progress_sizer = wx.BoxSizer(wx.VERTICAL)
         self._message_sizer = wx.BoxSizer(wx.VERTICAL)
-        self._button_sizer = wx.BoxSizer(wx.VERTICAL)
-
-        file_selector_label = wx.StaticText(
-            parent=self,  id=wx.ID_ANY, label="Select a JSON file",
-            pos=(30, 30), size=(130, 30)
-          )
-        self._form_sizer.Add(file_selector_label)
+        self._button_sizer = wx.BoxSizer(wx.HORIZONTAL)
+        dialog_sizer.Add(self._form_sizer, 1, wx.ALIGN_CENTER|wx.ALL, 10)
+        dialog_sizer.Add(self._progress_sizer, 1, wx.ALIGN_CENTER|wx.ALL, 10)
+        dialog_sizer.Add(self._message_sizer, 1, wx.ALIGN_CENTER|wx.ALL, 10)
+        dialog_sizer.Add(self._button_sizer, 1, wx.EXPAND|wx.ALIGN_CENTER|wx.ALL, 10)
+
+        self._form_sizer.Add(
+          wx.StaticText(self,label="Select a JSON file:"), 0
+        )
         self._file_selector = wx.FilePickerCtrl(parent=self,
-          id=wx.ID_ANY, path="",
-          message="Select JSON file", wildcard="JSON files (*.json)|*.json",
-          style=wx.FC_DEFAULT_STYLE, pos=(140, 20), size=(250, 40)
+          path="", message="Select JSON file",
+          wildcard="JSON files (*.json)|*.json", style=wx.FC_DEFAULT_STYLE
         )
-        self._form_sizer.Add(self._file_selector)
-        self._stars_check = wx.CheckBox(
-          parent=self, id=wx.ID_ANY, label="Only import units at with 6 stars.",
-          pos=(30, 80), size=(230, 20)
+        self._form_sizer.Add(self._file_selector, 0)
+        self._level_check = wx.CheckBox(
+          self, label="Include units at level less tan 40."
         )
-        self._form_sizer.Add(self._stars_check)
+        self._form_sizer.Add(self._level_check, 0)
         self._runes_check = wx.CheckBox(
-          parent=self, id=wx.ID_ANY, label="Only import units with runes.",
-          pos=(30, 110), size=(230, 20)
+          self, label="Only import units with runes."
         )
-        self._form_sizer.Add(self._runes_check)
+        self._form_sizer.Add(self._runes_check, 0)
         self._clear_teams_check = wx.CheckBox(
-          parent=self, id=wx.ID_ANY, label="Clear team data",
-          pos=(30, 140), size=(230, 20)
+          self, label="Clear team data"
         )
-        self._form_sizer.Add(self._clear_teams_check)
+        self._form_sizer.Add(self._clear_teams_check, 0)
+        self._rta_check = wx.CheckBox(self, label="RTA mode.")
+        self._form_sizer.Add(self._rta_check)
 
-        self._accept_button = wx.Button(
-          parent=self, id=wx.ID_ANY, pos=(100, 180),
-          size=(100, 40), style=wx.LC_REPORT, label="Accept"
-        )
-        wx.Button(
-          parent=self, id=wx.ID_OK, pos=(210, 180),
-          size=(100, 40), style=wx.LC_REPORT, label="Close"
-        )
-        self._button_sizer.Add(self._accept_button)
+        self._accept_button = wx.Button(self, label="Accept", size=(50, 80))
         self._accept_button.Bind(wx.EVT_BUTTON, self._accept)
+        self._button_sizer.Add(self._accept_button, 1)
+        self._button_sizer.Add(wx.Button(self, id=wx.ID_OK, label="Close"), 1)
 
         anim = wx.adv.Animation(
-          os.path.dirname(os.path.realpath(__file__)) + '/../res/icon/progress.gif'
-        )
-        progress_ctrl = wx.adv.AnimationCtrl(
-          parent=self, id=wx.ID_ANY, anim=anim, pos=(126, 176), size=(48, 48)
+          os.path.dirname(os.path.realpath(__file__))
+          + '/../res/icon/progress.gif'
         )
+        progress_ctrl = wx.adv.AnimationCtrl(self, anim=anim)
         progress_ctrl.Play()
-        self._progress_sizer.Add(progress_ctrl)
+        self._progress_sizer.Add(progress_ctrl, 1, wx.ALIGN_CENTER|wx.ALL, 15)
 
         # Progress message
-        self._message_label = wx.StaticText(
-          parent=self,  id=wx.ID_ANY, label="",
-          pos=(20, 20), size=(340, 460)
-        )
+        self._message_label = wx.StaticText(self)
         self._message_sizer.Add(self._message_label)
 
         # Hide progress bar and messages
         self._progress_sizer.ShowItems(False)
         self._message_sizer.ShowItems(False)
+        self.SetSizer(dialog_sizer)
+        self.Layout()
 
     def _check_process(self, event):
         """Checks the process output and updates the progress message.
@@ -142,13 +134,15 @@ class DialogUpdateJson(wx.Dialog):
             The event that triggered the call.
 
         """
-
+        printf("CHECK PROGRESS")
         if self._process is not None:
             stream = self._process.GetInputStream()
             if stream.CanRead():
+                printf("    CAN READ")
                 text = bytes.decode(stream.read())
                 #text = text[:-1] # Remove the last newline
                 self._message_label.SetLabel(text)
+                printf("     TEXT: " + text)
         else:
             self._timer.Stop()
 
@@ -166,7 +160,7 @@ class DialogUpdateJson(wx.Dialog):
         """
 
         self._timer.Stop()
-        self._progress_sizer.ShowItems(False)
+        
         errStream = bytes.decode(self._process.GetErrorStream().read())
         if errStream == "":
             self._message_label.SetLabel(
@@ -181,6 +175,8 @@ class DialogUpdateJson(wx.Dialog):
             )
             self.update_done = True
             self.update_error = True
+        self._progress_sizer.ShowItems(False)
+        self.Layout()
 
     def _accept(self, event):
         """Called when the accept button is clicked.
@@ -198,16 +194,20 @@ class DialogUpdateJson(wx.Dialog):
         self._progress_sizer.ShowItems(True)
         self._message_sizer.ShowItems(True)
         self._button_sizer.ShowItems(False)
+        self.Layout()
         # TODO: Executable name for windows
         command = "runeoptimizer update "
         command += pipes.quote(self._file_selector.GetPath())
-        if self._stars_check.GetValue():
-            command += " --six-stars"
+        if self._level_check.GetValue():
+            command += " --lower-level"
         if self._runes_check.GetValue():
-            command += " --with-runes"
+            command += " --runes"
         if self._clear_teams_check.GetValue():
             command += " --clear-teams"
-        command += " --gui"
+        if self._rta_check.GetValue():
+            command += " --mode rta"
+        else:
+            command += " --mode normal"
         print("Command: " + command)
 
         # Timer ot periodically check on the process

+ 1 - 1
src/gui/runeoptimizer_gui/gui/PanelUnits.py

@@ -400,7 +400,7 @@ class PanelUnits(wx.Panel):
         curr_stats = self._sel_unit.stats.values()
         for i in range(0, 10):
             b_stat = str(base_stats[i])
-            c_stat = str(base_stats[i])
+            c_stat = str(curr_stats[i])
             if i in [4, 5, 6, 7]:
                 b_stat += "%"
                 c_stat += "%"

+ 7 - 2
src/gui/runeoptimizer_gui/gui/RuneOptimizerFrame.py

@@ -48,7 +48,8 @@ class RuneOptimizerFrame(wx.Frame):
             player_name,
             player_level,
             ts,
-            modified
+            modified,
+            rta
           FROM info
         """)
         row = cursor.fetchone()
@@ -57,7 +58,11 @@ class RuneOptimizerFrame(wx.Frame):
         else:
             status = \
               row[1] + ", Lv" + str(row[2]) + " (ID #" +str(row[0]) + ")."
-            status += " Last updated " + str(row[3])
+            status += " Last updated " + str(row[3]) + " for "
+            if row[5] == 1:
+                status += "RTA mode"
+            else:
+                status += "normal mode"
             if row[4] == 1:
                 status += ". Modifications applied since."
             else: