Skip to content

Commit

Permalink
default and custom role updating
Browse files Browse the repository at this point in the history
- changed the custom role updating to actually save the changes so that
it doesn't have to perform them each time DT starts
- added a way to export changed default roles to a file. this should be
used to merge new changes from role.validate_pref into the defaults when
new versions/preferences are established
- removed junk from game_data default roles and updated them
  • Loading branch information
splintermind committed Dec 8, 2015
1 parent ee5061a commit 3a3cfbe
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 88 deletions.
8 changes: 8 additions & 0 deletions inc/gamedatareader.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ class GameDataReader : public QObject {
QString get_mood_name(MOOD_TYPE m_type,bool colored = false);
QString get_mood_desc(MOOD_TYPE m_type,bool colored = false);

bool custom_roles_updated() {return m_cust_roles_updated;}
void custom_roles_updated(bool val) {m_cust_roles_updated=val;}
bool default_roles_updated() {return m_def_roles_updated;}
void default_roles_updated(bool val) {m_def_roles_updated=val;}

static QStringList m_seasons;
static QStringList m_months;

Expand Down Expand Up @@ -178,6 +183,9 @@ class GameDataReader : public QObject {
QMap<int,QString> m_building_names;
QMap<int,QString> m_building_quality;

bool m_cust_roles_updated;
bool m_def_roles_updated;

void build_calendar();
};
#endif
2 changes: 1 addition & 1 deletion inc/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class MainWindow : public QMainWindow
//roles
void add_new_custom_role();
void add_new_opt();
void write_custom_roles();
void write_roles(bool custom = true);
void refresh_roles_data();

//optimizer
Expand Down
4 changes: 3 additions & 1 deletion inc/role.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Role : public QObject {
void script(QString script){m_script = script;}
bool is_custom(){return m_is_custom;}
void is_custom(bool val){m_is_custom = val;}
bool updated(){return m_updated;}

//unfortunately we need to keep all the keys as a string and cast them so we can use the same functions
//ie can't pass in a hash with <string, aspect> and <int, aspect>
Expand Down Expand Up @@ -89,7 +90,7 @@ class Role : public QObject {
protected:
void parseAspect(QSettings &s, QString node, weight_info &g_weight, QHash<QString, RoleAspect *> &list, float default_weight);
void parsePreferences(QSettings &s, QString node, weight_info &g_weight, float default_weight);
void check_pref_flags(Preference *p, int first_flag);
void validate_pref(Preference *p, int first_flag);
void write_aspect_group(QSettings &s, QString group_name, weight_info group_weight, float group_default_weight, QHash<QString, RoleAspect *> &list);
void write_pref_group(QSettings &s, float default_prefs_weight);

Expand All @@ -107,5 +108,6 @@ class Role : public QObject {
QList<int> m_labors; //labors associated via the skills in the role
QString m_pref_desc;
int m_cur_pref_len;
bool m_updated;
};
#endif // ROLE_H
Loading

0 comments on commit 3a3cfbe

Please sign in to comment.