Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add detailed commitment for sexual orientation #51

Merged
merged 3 commits into from
Jan 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 28 additions & 4 deletions resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,36 @@
<file alias="img/tables.png">resources/img/tables.png</file>
<file alias="img/table-insert-column.png">resources/img/table-insert-column.png</file>
<file alias="img/book-question.png">resources/img/book-question.png</file>
<file alias="img/male-male.png">resources/img/male-male.png</file>
<file alias="img/female-bi.png">resources/img/female-bi.png</file>
<file alias="img/female-female.png">resources/img/female-female.png</file>
<file alias="img/male-bi.png">resources/img/male-bi.png</file>
<file alias="img/female.png">resources/img/female.png</file>
<file alias="img/female-asexual.png">resources/img/female-asexual.png</file>
<file alias="img/female-asexual-bg.png">resources/img/female-asexual-bg.png</file>
<file alias="img/female-bi.png">resources/img/female-bi.png</file>
<file alias="img/female-bi-i-i.png">resources/img/female-bi-i-i.png</file>
<file alias="img/female-bi-i-c.png">resources/img/female-bi-i-c.png</file>
<file alias="img/female-bi-c-i.png">resources/img/female-bi-c-i.png</file>
<file alias="img/female-bi-c-c.png">resources/img/female-bi-c-c.png</file>
<file alias="img/female-hetero.png">resources/img/female-hetero.png</file>
<file alias="img/female-hetero-i.png">resources/img/female-hetero-i.png</file>
<file alias="img/female-hetero-c.png">resources/img/female-hetero-c.png</file>
<file alias="img/female-homo.png">resources/img/female-homo.png</file>
<file alias="img/female-homo-i.png">resources/img/female-homo-i.png</file>
<file alias="img/female-homo-c.png">resources/img/female-homo-c.png</file>
<file alias="img/male.png">resources/img/male.png</file>
<file alias="img/male-asexual.png">resources/img/male-asexual.png</file>
<file alias="img/male-asexual-bg.png">resources/img/male-asexual-bg.png</file>
<file alias="img/male-bi.png">resources/img/male-bi.png</file>
<file alias="img/male-bi-i-i.png">resources/img/male-bi-i-i.png</file>
<file alias="img/male-bi-i-c.png">resources/img/male-bi-i-c.png</file>
<file alias="img/male-bi-c-i.png">resources/img/male-bi-c-i.png</file>
<file alias="img/male-bi-c-c.png">resources/img/male-bi-c-c.png</file>
<file alias="img/male-hetero.png">resources/img/male-hetero.png</file>
<file alias="img/male-hetero-i.png">resources/img/male-hetero-i.png</file>
<file alias="img/male-hetero-c.png">resources/img/male-hetero-c.png</file>
<file alias="img/male-homo.png">resources/img/male-homo.png</file>
<file alias="img/male-homo-i.png">resources/img/male-homo-i.png</file>
<file alias="img/male-homo-c.png">resources/img/male-homo-c.png</file>
<file alias="img/sex-unknown.png">resources/img/sex-unknown.png</file>
<file alias="img/sex-unknown-bg.png">resources/img/sex-unknown-bg.png</file>
<file alias="img/heart.png">resources/img/heart.png</file>
<file alias="img/wrench-screwdriver.png">resources/img/wrench-screwdriver.png</file>
<file alias="img/question-white.png">resources/img/question-white.png</file>
Expand Down
Binary file added resources/img/female-asexual-bg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/img/female-asexual.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/female-bi-c-c.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/female-bi-c-i.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/female-bi-i-c.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/female-bi-i-i.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/img/female-bi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resources/img/female-female.png
Binary file not shown.
Binary file added resources/img/female-hetero-c.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/female-hetero-i.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/female-hetero.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/female-homo-c.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/female-homo-i.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/female-homo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/img/female.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/male-asexual-bg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/img/male-asexual.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/male-bi-c-c.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/male-bi-c-i.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/male-bi-i-c.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/male-bi-i-i.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/img/male-bi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/male-hetero-c.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/male-hetero-i.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/male-hetero.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/img/male-homo-c.png
Binary file added resources/img/male-homo-i.png
Binary file added resources/img/male-homo.png
Binary file removed resources/img/male-male.png
Diff not rendered.
Binary file modified resources/img/male.png
Binary file added resources/img/sex-unknown-bg.png
Binary file added resources/img/sex-unknown.png
110 changes: 79 additions & 31 deletions src/dwarf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,25 @@ void Dwarf::read_id() {
TRACE << "UNIT ID:" << m_id;
}

static const char *sex_interest_icon_suffix (Dwarf::SEX_COMMITMENT interest)
{
switch (interest) {
case Dwarf::COMMIT_LOVER:
return "i";
case Dwarf::COMMIT_MARRIAGE:
return "c";
default:
LOGE << "Invalid interest in suffix";
return "";
}
}

void Dwarf::read_gender_orientation() {
QSettings *s = DT->user_settings();
auto gender_info_option = s->value("options/gender_info", Option_ShowOrientation).toInt();
bool show_orientation = gender_info_option >= Option_ShowOrientation;
bool show_commitment = !m_is_animal && gender_info_option >= Option_ShowCommitment;

BYTE sex = m_df->read_byte(m_address + m_mem->dwarf_offset("sex"));
TRACE << "GENDER:" << sex;
m_gender_info.gender = static_cast<GENDER_TYPE>(sex);
Expand All @@ -456,7 +474,7 @@ void Dwarf::read_gender_orientation() {
QStringList icon_name;

if(m_gender_info.gender == SEX_UNK){
icon_name.append("question-white");
icon_name.append("sex-unknown");
}else if(m_gender_info.gender == SEX_M){
icon_name.append("male");
}else{
Expand All @@ -466,44 +484,74 @@ void Dwarf::read_gender_orientation() {
int orient_offset = m_mem->soul_detail("orientation");
if(m_gender_info.gender != SEX_UNK && m_first_soul && orient_offset != -1){
quint32 orientation = m_df->read_addr(m_first_soul + orient_offset);
m_gender_info.male_interest = orientation & (1 << 1);
m_gender_info.male_commit = orientation & (1 << 2);
m_gender_info.female_interest = orientation & (1 << 3);
m_gender_info.female_commit = orientation & (1 << 4);
m_gender_info.male = static_cast<SEX_COMMITMENT>((orientation & (3<<1))>>1);
m_gender_info.female = static_cast<SEX_COMMITMENT>((orientation & (3<<3))>>3);

//check the commitment/breed bits first. this determines animal breeding, and will override the interest bit, seemingly
//for example, a male dwarf, with interest in males and commitment to females will marry a female
icon_name.append(get_gender_icon_suffix(m_gender_info.male_commit,m_gender_info.female_commit));
SEX_COMMITMENT other, same;
if (m_gender_info.gender == SEX_M) {
other = m_gender_info.female;
same = m_gender_info.male;
}
else {
other = m_gender_info.male;
same = m_gender_info.female;
}


if (other && same) {
if (show_orientation)
icon_name.append("bi");
if (show_commitment) {
icon_name.append(sex_interest_icon_suffix(m_gender_info.male));
icon_name.append(sex_interest_icon_suffix(m_gender_info.female));
}
m_gender_info.orientation = ORIENT_BISEXUAL;
}
else if (other) {
if (show_orientation)
icon_name.append("hetero");
if (show_commitment)
icon_name.append(sex_interest_icon_suffix(other));
m_gender_info.orientation = ORIENT_HETERO;
}
else if (same) {
if (show_orientation)
icon_name.append("homo");
if (show_commitment)
icon_name.append(sex_interest_icon_suffix(same));
m_gender_info.orientation = ORIENT_HOMO;
}
else {
if (show_orientation)
icon_name.append("asexual");
if (show_commitment)
icon_name.append("bg");
m_gender_info.orientation = ORIENT_ASEXUAL;
}
}
icon_name.removeAll("");
m_icn_gender = QString(":img/%1.png").arg(icon_name.join("-"));

QStringList gender_desc;
gender_desc << get_gender_desc(m_gender_info.gender) << get_orientation_desc(m_gender_info.orientation);
gender_desc.removeAll("");
m_gender_info.full_desc = gender_desc.join(" - ");
}

QString Dwarf::get_gender_icon_suffix(bool male_flag, bool female_flag, bool checking_interest){
QString suffix = "";
if(male_flag && female_flag){
suffix ="bi";
m_gender_info.orientation = ORIENT_BISEXUAL;
}else if(male_flag && m_gender_info.gender == SEX_M){
suffix ="male";
m_gender_info.orientation = ORIENT_HOMO;
}else if(female_flag && m_gender_info.gender == SEX_F){
suffix ="female";
m_gender_info.orientation = ORIENT_HOMO;
}else if(!male_flag && !female_flag){
if(m_is_animal || checking_interest){
suffix ="asexual";
m_gender_info.orientation = ORIENT_ASEXUAL;
}else{
return get_gender_icon_suffix(m_gender_info.male_interest,m_gender_info.female_interest,true);
gender_desc << get_gender_desc(m_gender_info.gender);
if (show_orientation)
gender_desc << get_orientation_desc(m_gender_info.orientation);
if (show_commitment) {
static const QStringList preferences = { tr("Not interested in %1"), tr("Likes %1"), tr("Will marry %1") };
for (const auto &t: {
std::make_tuple(m_gender_info.male, tr("males")),
std::make_tuple(m_gender_info.female, tr("females")) }) {
auto pref = std::get<0>(t);
if (pref) {
if (pref < preferences.count())
gender_desc << preferences[std::get<0>(t)].arg(std::get<1>(t));
else
gender_desc << "Invalid orientation flag";
}
}
}
return suffix;
gender_desc.removeAll("");
m_gender_info.full_desc = gender_desc.join(" - ");
}

void Dwarf::read_mood(){
Expand Down
53 changes: 32 additions & 21 deletions src/dwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,37 @@ class Dwarf : public QObject

bool is_valid() {return m_is_valid;}

typedef enum {
enum GENDER_TYPE {
SEX_UNK = -1,
SEX_F = 0,
SEX_M = 1
} GENDER_TYPE;
};
Q_ENUMS(GENDER_TYPE)

typedef enum {
enum SEX_ORIENT_TYPE {
ORIENT_ASEXUAL,
ORIENT_BISEXUAL,
ORIENT_HOMO,
ORIENT_HETERO
} SEX_ORIENT_TYPE;
};
Q_ENUMS(SEX_ORIENT_TYPE)

typedef enum{
enum SEX_COMMITMENT {
COMMIT_UNINTERESTED = 0,
COMMIT_LOVER = 1,
COMMIT_MARRIAGE = 2,
};
Q_ENUMS(SEX_COMMITMENT)

enum MISC_STATES {
STATE_MIGRANT = 7,
STATE_OUTDOORS = 14,
STATE_HARDENED = 15,
STATE_ON_BREAK = 17,
STATE_CAVE_ADAPT = 19
} MISC_STATES;
};

typedef enum{
enum TRAINED_LEVEL {
none=-1, //custom
semi_wild=0,
trained=1,
Expand All @@ -104,18 +111,18 @@ class Dwarf : public QObject
unknown_trained=8,
wild_untamed=9,
hostile=10 //custom
} TRAINED_LEVEL;
};
Q_ENUMS(TRAINED_LEVEL)

typedef enum{
enum UNIT_OCCUPATION {
OCC_NONE = -1,
OCC_TAVERN,
OCC_PERFORMER,
OCC_SCHOLAR,
OCC_MERC,
OCC_MONSTER,
OCC_SCRIBE
} UNIT_OCCUPATION;
};

static inline QString get_animal_trained_descriptor(const TRAINED_LEVEL &type) {
switch (type) {
Expand Down Expand Up @@ -174,18 +181,24 @@ class Dwarf : public QObject
struct unit_gender{
GENDER_TYPE gender;
SEX_ORIENT_TYPE orientation;
bool male_commit;
bool female_commit;
bool male_interest;
bool female_interest;
SEX_COMMITMENT male, female;
QString full_desc;
};

Q_INVOKABLE GENDER_TYPE get_gender() {return m_gender_info.gender;}
Q_INVOKABLE SEX_ORIENT_TYPE get_orientation() {return m_gender_info.orientation;}
QString get_gender_orient_desc() {return m_gender_info.full_desc;}
Q_INVOKABLE bool is_male() {return (m_gender_info.gender == SEX_M);}
Q_INVOKABLE bool is_female() {return (m_gender_info.gender == SEX_F);}
enum GenderInfoOption
{
Option_SexOnly = 0,
Option_ShowOrientation,
Option_ShowCommitment,
};

Q_INVOKABLE GENDER_TYPE get_gender() const {return m_gender_info.gender;}
Q_INVOKABLE SEX_ORIENT_TYPE get_orientation() const {return m_gender_info.orientation;}
QString get_gender_orient_desc() const {return m_gender_info.full_desc;}
Q_INVOKABLE SEX_COMMITMENT same_sex_commitment() const { return m_gender_info.gender == SEX_M ? m_gender_info.male : m_gender_info.female; }
Q_INVOKABLE SEX_COMMITMENT other_sex_commitment() const { return m_gender_info.gender == SEX_M ? m_gender_info.female : m_gender_info.male; }
Q_INVOKABLE bool is_male() const {return (m_gender_info.gender == SEX_M);}
Q_INVOKABLE bool is_female() const {return (m_gender_info.gender == SEX_F);}

Q_INVOKABLE bool is_animal() {return m_is_animal;}
Q_INVOKABLE bool is_pet() {return m_is_pet;}
Expand Down Expand Up @@ -749,8 +762,6 @@ class Dwarf : public QObject
void check_availability();
void set_validation(QString reason, bool *valid_var = 0, bool valid = false, LOG_LEVEL l = LL_INFO);

QString get_gender_icon_suffix(bool male_flag, bool female_flag, bool checking_interest = false);

void add_inv_warn(Item *i, bool include_mat_name, Item::ITEM_STATE i_status);
void process_uncovered(ITEM_TYPE i_type, QString desc, int count, int req_count);
void process_inv_item(QString category, Item *item, bool is_contained_item=false);
Expand Down
12 changes: 11 additions & 1 deletion src/dwarfmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,12 @@ void DwarfModel::build_rows() {
}else if(m_group_by == GB_PROFESSION){
m_grouped_dwarves[d->profession()].append(d);
}else if(m_group_by == GB_SEX){
m_grouped_dwarves[d->get_gender_orient_desc()].append(d);
m_grouped_dwarves[Dwarf::get_gender_desc(d->get_gender())].append(d);
} else if (m_group_by == GB_SEX_ORIENT){
auto group = QString("%1 - %2")
.arg(Dwarf::get_gender_desc(d->get_gender()))
.arg(Dwarf::get_orientation_desc(d->get_orientation()));
m_grouped_dwarves[group].append(d);
}else if(m_group_by == GB_MIGRATION_WAVE){
m_grouped_dwarves[d->get_migration_desc()].append(d);
}else if(m_group_by == GB_AGE){
Expand Down Expand Up @@ -477,6 +482,8 @@ void DwarfModel::build_row(const QString &key) {
} else if (m_group_by == GB_AGE){
agg_first_col->setData(first_dwarf->get_age(), DR_SORT_VALUE);
} else if (m_group_by == GB_SEX){
agg_first_col->setData(Dwarf::get_gender_desc(first_dwarf->get_gender()), DR_SORT_VALUE);
} else if (m_group_by == GB_SEX_ORIENT){
agg_first_col->setData(first_dwarf->get_gender_orient_desc(), DR_SORT_VALUE);
} else if (m_group_by == GB_SQUAD){
int squad_id = first_dwarf->squad_id();
Expand Down Expand Up @@ -601,6 +608,9 @@ void DwarfModel::build_row(const QString &key) {
case GB_AGE:
sort_val = d->get_age();
break;
case GB_SEX_ORIENT:
sort_val = d->get_gender_orient_desc();
break;
case GB_NOTHING:
default:
sort_val = d->nice_name();
Expand Down
1 change: 1 addition & 0 deletions src/dwarfmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class DwarfModel : public QStandardItemModel {
GB_PROFESSION,
GB_RACE,
GB_SEX,
GB_SEX_ORIENT,
GB_SQUAD,
GB_ASSIGNED_LABORS,
GB_TOTAL_SKILL_LEVELS,
Expand Down
3 changes: 2 additions & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ MainWindow::MainWindow(QWidget *parent)
ui->cb_group_by->addItem(tr("Age"), DwarfModel::GB_AGE);
ui->cb_group_by->addItem(tr("Caste"), DwarfModel::GB_CASTE);
ui->cb_group_by->addItem(tr("Current Job"), DwarfModel::GB_CURRENT_JOB);
ui->cb_group_by->addItem(tr("Gender & Orientation"), DwarfModel::GB_SEX);
ui->cb_group_by->addItem(tr("Goals"), DwarfModel::GB_GOALS);
ui->cb_group_by->addItem(tr("Happiness"), DwarfModel::GB_HAPPINESS);
ui->cb_group_by->addItem(tr("Has Nickname"),DwarfModel::GB_HAS_NICKNAME);
Expand All @@ -240,6 +239,8 @@ MainWindow::MainWindow(QWidget *parent)
ui->cb_group_by->addItem(tr("Occupation"),DwarfModel::GB_OCCUPATION);
ui->cb_group_by->addItem(tr("Profession"), DwarfModel::GB_PROFESSION);
ui->cb_group_by->addItem(tr("Race"), DwarfModel::GB_RACE);
ui->cb_group_by->addItem(tr("Sex"), DwarfModel::GB_SEX);
ui->cb_group_by->addItem(tr("Sexual Orientation"), DwarfModel::GB_SEX_ORIENT);
ui->cb_group_by->addItem(tr("Skill Rust"), DwarfModel::GB_SKILL_RUST);
ui->cb_group_by->addItem(tr("Squad"), DwarfModel::GB_SQUAD);
ui->cb_group_by->addItem(tr("Total Assigned Labors"),DwarfModel::GB_ASSIGNED_LABORS);
Expand Down