Skip to content

Commit

Permalink
#41 script cleanup and gui modifications
Browse files Browse the repository at this point in the history
- moved relevant script methods into each tab if applicable in the
script gui
- added migration wave, goal and belief methods for scripts
- added the goals and belief reference tables to the script gui
- moved the traits with goals and beliefs into a new personality tab in
the script gui
- added other missing script methods to the script help
  • Loading branch information
splintermind committed Jul 31, 2014
1 parent 7c6892a commit 5af43c1
Show file tree
Hide file tree
Showing 7 changed files with 372 additions and 181 deletions.
72 changes: 38 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#############################################################################
# Makefile for building: DwarfTherapist
# Generated by qmake (3.0) (Qt 5.1.1) on: Mon Jul 28 11:48:38 2014
# Generated by qmake (3.0) (Qt 5.1.1) on: Thu Jul 31 09:13:17 2014
# Project: dwarftherapist.pro
# Template: app
# Command: Z:\Qt\5.1.1\mingw48_32\bin\qmake.exe -spec win32-g++ -o Makefile dwarftherapist.pro
# Command: Z:\Qt\5.1.1\mingw48_32\bin\qmake.exe -spec win32-g++ CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug -o Makefile dwarftherapist.pro
#############################################################################

MAKEFILE = Makefile

first: release
install: release-install
uninstall: release-uninstall
first: debug
install: debug-install
uninstall: debug-uninstall
QMAKE = Z:\Qt\5.1.1\mingw48_32\bin\qmake.exe
DEL_FILE = del
CHK_DIR_EXISTS= if not exist
Expand All @@ -26,24 +26,10 @@ SYMLINK = copy /y
DEL_DIR = rmdir
MOVE = move
SUBTARGETS = \
release \
debug
debug \
release


release: FORCE
$(MAKE) -f $(MAKEFILE).Release
release-make_first: FORCE
$(MAKE) -f $(MAKEFILE).Release
release-all: FORCE
$(MAKE) -f $(MAKEFILE).Release all
release-clean: FORCE
$(MAKE) -f $(MAKEFILE).Release clean
release-distclean: FORCE
$(MAKE) -f $(MAKEFILE).Release distclean
release-install: FORCE
$(MAKE) -f $(MAKEFILE).Release install
release-uninstall: FORCE
$(MAKE) -f $(MAKEFILE).Release uninstall
debug: FORCE
$(MAKE) -f $(MAKEFILE).Debug
debug-make_first: FORCE
Expand All @@ -58,6 +44,20 @@ debug-install: FORCE
$(MAKE) -f $(MAKEFILE).Debug install
debug-uninstall: FORCE
$(MAKE) -f $(MAKEFILE).Debug uninstall
release: FORCE
$(MAKE) -f $(MAKEFILE).Release
release-make_first: FORCE
$(MAKE) -f $(MAKEFILE).Release
release-all: FORCE
$(MAKE) -f $(MAKEFILE).Release all
release-clean: FORCE
$(MAKE) -f $(MAKEFILE).Release clean
release-distclean: FORCE
$(MAKE) -f $(MAKEFILE).Release distclean
release-install: FORCE
$(MAKE) -f $(MAKEFILE).Release install
release-uninstall: FORCE
$(MAKE) -f $(MAKEFILE).Release uninstall

Makefile: dwarftherapist.pro ../../Qt/5.1.1/mingw48_32/mkspecs/win32-g++/qmake.conf ../../Qt/5.1.1/mingw48_32/mkspecs/features/spec_pre.prf \
../../Qt/5.1.1/mingw48_32/mkspecs/qdevice.pri \
Expand Down Expand Up @@ -111,6 +111,8 @@ Makefile: dwarftherapist.pro ../../Qt/5.1.1/mingw48_32/mkspecs/win32-g++/qmake.c
../../Qt/5.1.1/mingw48_32/mkspecs/features/win32/default_pre.prf \
../../Qt/5.1.1/mingw48_32/mkspecs/features/resolve_config.prf \
../../Qt/5.1.1/mingw48_32/mkspecs/features/default_post.prf \
../../Qt/5.1.1/mingw48_32/mkspecs/features/qml_debug.prf \
../../Qt/5.1.1/mingw48_32/mkspecs/features/declarative_debug.prf \
../../Qt/5.1.1/mingw48_32/mkspecs/features/win32/rtti.prf \
../../Qt/5.1.1/mingw48_32/mkspecs/features/warn_on.prf \
../../Qt/5.1.1/mingw48_32/mkspecs/features/qt.prf \
Expand All @@ -129,7 +131,7 @@ Makefile: dwarftherapist.pro ../../Qt/5.1.1/mingw48_32/mkspecs/win32-g++/qmake.c
Z:/Qt/5.1.1/mingw48_32/lib/Qt5Network.prl \
Z:/Qt/5.1.1/mingw48_32/lib/Qt5Gui.prl \
Z:/Qt/5.1.1/mingw48_32/lib/Qt5Core.prl
$(QMAKE) -spec win32-g++ -o Makefile dwarftherapist.pro
$(QMAKE) -spec win32-g++ CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug -o Makefile dwarftherapist.pro
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\spec_pre.prf:
..\..\Qt\5.1.1\mingw48_32\mkspecs\qdevice.pri:
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\device_config.prf:
Expand Down Expand Up @@ -182,6 +184,8 @@ Makefile: dwarftherapist.pro ../../Qt/5.1.1/mingw48_32/mkspecs/win32-g++/qmake.c
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\win32\default_pre.prf:
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\resolve_config.prf:
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\default_post.prf:
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\qml_debug.prf:
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\declarative_debug.prf:
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\win32\rtti.prf:
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\warn_on.prf:
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\qt.prf:
Expand All @@ -201,30 +205,30 @@ Z:/Qt/5.1.1/mingw48_32/lib/Qt5Network.prl:
Z:/Qt/5.1.1/mingw48_32/lib/Qt5Gui.prl:
Z:/Qt/5.1.1/mingw48_32/lib/Qt5Core.prl:
qmake: FORCE
@$(QMAKE) -spec win32-g++ -o Makefile dwarftherapist.pro
@$(QMAKE) -spec win32-g++ CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug -o Makefile dwarftherapist.pro

qmake_all: FORCE

make_first: release-make_first debug-make_first FORCE
all: release-all debug-all FORCE
clean: release-clean debug-clean FORCE
distclean: release-distclean debug-distclean FORCE
make_first: debug-make_first release-make_first FORCE
all: debug-all release-all FORCE
clean: debug-clean release-clean FORCE
distclean: debug-distclean release-distclean FORCE
-$(DEL_FILE) Makefile

release-mocclean:
$(MAKE) -f $(MAKEFILE).Release mocclean
debug-mocclean:
$(MAKE) -f $(MAKEFILE).Debug mocclean
mocclean: release-mocclean debug-mocclean
release-mocclean:
$(MAKE) -f $(MAKEFILE).Release mocclean
mocclean: debug-mocclean release-mocclean

release-mocables:
$(MAKE) -f $(MAKEFILE).Release mocables
debug-mocables:
$(MAKE) -f $(MAKEFILE).Debug mocables
mocables: release-mocables debug-mocables
release-mocables:
$(MAKE) -f $(MAKEFILE).Release mocables
mocables: debug-mocables release-mocables

check: first
FORCE:

$(MAKEFILE).Release: Makefile
$(MAKEFILE).Debug: Makefile
$(MAKEFILE).Release: Makefile
1 change: 1 addition & 0 deletions inc/belief.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Belief : public QObject {
QString name;
int m_id;

int belief_id(){return m_id;}
bool is_active(const short &personal_val);
QString level_message(const short &val);
};
Expand Down
58 changes: 9 additions & 49 deletions inc/dwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class Dwarf : public QObject
//! return whether or not the dwarf is on break
bool is_on_break() {return m_is_on_break;}

//-1 = none, 0 = female, 1 = male
Q_INVOKABLE GENDER_TYPE get_gender() {return m_gender;}
Q_INVOKABLE bool is_male() {return (m_gender == SEX_M);}

Expand Down Expand Up @@ -119,63 +118,29 @@ class Dwarf : public QObject

//! return the raw happiness score for this dwarf
Q_INVOKABLE int get_raw_happiness() {return m_raw_happiness;}

//! return this dwarf's strength attribute score
//! return specific attribute values
Q_INVOKABLE int strength() {return attribute((int)AT_STRENGTH);}

//! return this dwarf's agility attribute score
Q_INVOKABLE int agility() {return attribute((int)AT_AGILITY);}

//! return this dwarf's toughness attribute score
Q_INVOKABLE int toughness() {return attribute((int)AT_TOUGHNESS);}

//! return this dwarf's endurance attribute score
Q_INVOKABLE int endurance() {return attribute((int)AT_ENDURANCE);}

//! return this dwarf's recuperation attribute score
Q_INVOKABLE int recuperation() {return attribute((int)AT_RECUPERATION);}

//! return this dwarf's disease resistance attribute score
Q_INVOKABLE int disease_resistance() {return attribute((int)AT_DISEASE_RESISTANCE);}

//! return this dwarf's willpower attribute score
Q_INVOKABLE int willpower() {return attribute((int)AT_WILLPOWER);}

//! return this dwarf's memory attribute score
Q_INVOKABLE int memory() {return attribute((int)AT_MEMORY);}

//! return this dwarf's focus attribute score
Q_INVOKABLE int focus() {return attribute((int)AT_FOCUS);}

//! return this dwarf's intuition attribute score
Q_INVOKABLE int intuition() {return attribute((int)AT_INTUITION);}

//! return this dwarf's patience attribute score
Q_INVOKABLE int patience() {return attribute((int)AT_PATIENCE);}

//! return this dwarf's empathy attribute score
Q_INVOKABLE int empathy() {return attribute((int)AT_EMPATHY);}

//! return this dwarf's social awareness attribute score
Q_INVOKABLE int social_awareness() {return attribute((int)AT_SOCIAL_AWARENESS);}

//! return this dwarf's creativity attribute score
Q_INVOKABLE int creativity() {return attribute((int)AT_CREATIVITY);}

//! return this dwarf's musicality attribute score
Q_INVOKABLE int musicality() {return attribute((int)AT_MUSICALITY);}

//! return this dwarf's analytical ability attribute score
Q_INVOKABLE int analytical_ability() {return attribute((int)AT_ANALYTICAL_ABILITY);}

//! return this dwarf's linguistic ability attribute score
Q_INVOKABLE int linguistic_ability() {return attribute((int)AT_LINGUISTIC_ABILITY);}

//! return this dwarf's spatial sense attribute score
Q_INVOKABLE int spatial_sense() {return attribute((int)AT_SPATIAL_SENSE);}

//! return this dwarf's kinesthetic sense attribute score
Q_INVOKABLE int kinesthetic_sense() {return attribute((int)AT_KINESTHETIC_SENSE);}
//! attribute value from id
Q_INVOKABLE int attribute(int attrib_id) {return get_attribute(attrib_id).get_value();}
Attribute get_attribute(int id);

//! return this dwarf's squad reference id
Q_INVOKABLE int squad_id(bool original = false) { return (original ? m_squad_id : m_pending_squad_id);}
Expand Down Expand Up @@ -233,7 +198,7 @@ class Dwarf : public QObject
int total_xp() {return m_total_xp;}

//! return the migration wave
int migration_wave() {return m_migration_wave;}
Q_INVOKABLE int migration_wave() {return m_migration_wave;}

//! returns a description of birth or migration
QString get_migration_desc();
Expand Down Expand Up @@ -280,9 +245,6 @@ class Dwarf : public QObject
bool trait_is_conflicted(const int &trait_id);
QList<UnitBelief> trait_conflicts(const int &trait_id){return m_conflicting_beliefs.values(trait_id);}

Q_INVOKABLE int attribute(int attrib_id) {return get_attribute(attrib_id).get_value();}
Attribute get_attribute(int id);

//! returns the numeric rating for the this dwarf in the skill specified by skill_id
Q_INVOKABLE float skill_level(int skill_id, bool raw = false, bool precise = false);

Expand All @@ -296,6 +258,7 @@ class Dwarf : public QObject
bool belief_is_active(const int &belief_id);
QHash<int, UnitBelief> &beliefs() {return m_beliefs;}
UnitBelief get_unit_belief(int belief_id);
Q_INVOKABLE int belief_value(int belief_id){return get_unit_belief(belief_id).belief_value();}

//! return a hashmap of roles and ratings for this dwarf
const QHash<QString, float> &role_ratings() {return m_role_ratings;}
Expand Down Expand Up @@ -324,7 +287,7 @@ class Dwarf : public QObject
void refresh_data();

//! set the pending nickname for this dwarf (does not auto-commit)
Q_INVOKABLE void set_nickname(const QString &nick);
void set_nickname(const QString &nick);

//! set the migration wave this dwarf (DwarfModel currently calls this with its best guess)
void set_migration_wave(const int &wave_number) {m_migration_wave = wave_number;}
Expand Down Expand Up @@ -377,9 +340,7 @@ class Dwarf : public QObject

//! method for mapping a caste id to a meaningful text name string
Q_INVOKABLE QString caste_name(bool plural_name = false);

Q_INVOKABLE QString caste_tag();

//! static method for mapping a caste id to a meaningful text description string
Q_INVOKABLE QString caste_desc();

Expand Down Expand Up @@ -409,9 +370,6 @@ class Dwarf : public QObject
return m_first_name;
}

// QString squad_name() const {
// return m_squad_name;
// }
QString squad_name();

uint turn_count() const {
Expand Down Expand Up @@ -458,6 +416,8 @@ class Dwarf : public QObject

UnitHealth get_unit_health() {return m_unit_health;}

Q_INVOKABLE bool has_goal(int goal_id){return m_goals.contains(goal_id);}
//! number of goals realized
Q_INVOKABLE int goals_realized(){return m_goals_realized;}

//! returns a list of items, grouped by body part name
Expand Down
10 changes: 7 additions & 3 deletions inc/gamedatareader.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ class GameDataReader : public QObject {
QList<QPair<QString, Role*> > get_ordered_roles() {return m_ordered_roles;}
QVector<QString> get_default_roles() {return m_default_roles;}
QHash<int,QVector<Role*> > get_skill_roles() {return m_skill_roles;}
QHash<int,QString> get_skills(){return m_skills;}
QHash<int,QString> get_skills(){return m_skills;}
QList<QPair<int,QString> > get_ordered_beliefs(){return m_ordered_beliefs;}
QList<QPair<int,QString> > get_ordered_goals(){return m_ordered_goals;}

QList<QPair<QString, laborOptimizerPlan*> > get_ordered_opt_plans() {return m_ordered_opts;}
QHash<QString, laborOptimizerPlan*>& get_opt_plans(){return m_opt_plans;}
Expand Down Expand Up @@ -163,6 +165,10 @@ class GameDataReader : public QObject {
QList<QPair<int, Trait*> > m_ordered_traits;

QHash<int, Belief*> m_beliefs;
QList<QPair<int,QString> > m_ordered_beliefs;

QHash<int,QPair<QString,QString> > m_goals; //id key with pair name and desc
QList<QPair<int,QString> > m_ordered_goals;

QHash<int, QString> m_skills;
QList<QPair<int, QString> > m_ordered_skills;
Expand Down Expand Up @@ -198,8 +204,6 @@ class GameDataReader : public QObject {

QMap<short, Thought*> m_unit_thoughts;

QHash<int,QPair<QString,QString> > m_goals; //id key with pair name and desc

void load_race_names();
void load_caste_names();
void build_calendar();
Expand Down
20 changes: 20 additions & 0 deletions src/gamedatareader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ GameDataReader::GameDataReader(QObject *parent)
}
m_data_settings->endArray();

qSort(goal_names);
foreach(QString name, goal_names) {
foreach(int goal_id, m_goals.uniqueKeys()) {
if (m_goals.value(goal_id).first == name) {
m_ordered_goals << qMakePair(goal_id,name);
break;
}
}
}


//beliefs
int beliefs = m_data_settings->beginReadArray("beliefs");
QStringList belief_names;
Expand All @@ -191,6 +202,15 @@ GameDataReader::GameDataReader(QObject *parent)
belief_names << b->name;
}
m_data_settings->endArray();
qSort(belief_names);
foreach(QString name, belief_names) {
foreach(Belief *b, m_beliefs) {
if (b->name == name) {
m_ordered_beliefs << qMakePair(b->belief_id(),get_belief_name(b->belief_id()));
break;
}
}
}

int job_count = m_data_settings->beginReadArray("dwarf_jobs");
qDeleteAll(m_dwarf_jobs);
Expand Down

0 comments on commit 5af43c1

Please sign in to comment.