From f033f4f0fb66cac4a995e6a421135c514f039a77 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 7 May 2020 11:11:08 +0300 Subject: Add option for show/hide hidden gender By default hidden gender is hidden. --- src/gui/windows/charcreatedialog.cpp | 9 ++++++--- src/gui/windows/charcreatedialog.h | 2 ++ src/resources/db/chardb.cpp | 15 +++++++++++++++ src/resources/db/chardb.h | 4 ++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 17d993f1a..b2913ce68 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -139,7 +139,8 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, maxHairStyle(CharDB::getMaxHairStyle()), minHairStyle(CharDB::getMinHairStyle()), mAction(0), - mDirection(0) + mDirection(0), + mShowHiddenGender(CharDB::getShowHiddenGender()) { setStickyButtonLock(true); setSticky(true); @@ -285,7 +286,8 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, mGenderStrip->addButton(_("F"), "f", false); if (features.getIntValue("forceAccountGender") == -1) { - if (serverFeatures->haveCharHiddenGender()) + if (mShowHiddenGender && + serverFeatures->haveCharHiddenGender()) { // TRANSLATORS: one char size male character gender mGenderStrip->addButton(_("M"), "m", true); @@ -304,7 +306,8 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, { // TRANSLATORS: one char size male character gender mGenderStrip->addButton(_("M"), "m", true); - if (serverFeatures->haveCharHiddenGender()) + if (mShowHiddenGender && + serverFeatures->haveCharHiddenGender()) { // TRANSLATORS: one char size hidden character gender mGenderStrip->addButton(_("H"), "h", false); diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h index c3e79133b..1d93d998a 100644 --- a/src/gui/windows/charcreatedialog.h +++ b/src/gui/windows/charcreatedialog.h @@ -166,6 +166,8 @@ class CharCreateDialog final : public Window, unsigned int mAction; unsigned int mDirection; + + bool mShowHiddenGender; }; #endif // GUI_WINDOWS_CHARCREATEDIALOG_H diff --git a/src/resources/db/chardb.cpp b/src/resources/db/chardb.cpp index 3eddf1c27..ca256e4f3 100644 --- a/src/resources/db/chardb.cpp +++ b/src/resources/db/chardb.cpp @@ -29,6 +29,7 @@ namespace { bool mLoaded = false; + bool showHiddenGender = false; unsigned mMinHairColor = 0; unsigned mMaxHairColor = 0; unsigned mMinHairStyle = 0; @@ -104,6 +105,10 @@ void CharDB::load() { loadMinMax(node, &mMinRace, &mMaxRace); } + else if (xmlNameEqual(node, "flags")) + { + loadFlags(node); + } } delete doc; @@ -121,6 +126,11 @@ void CharDB::loadMinMax(XmlNodeConstPtr node, *max = XML::getProperty(node, "max", 10); } +void CharDB::loadFlags(XmlNodeConstPtr node) +{ + showHiddenGender = XML::getBoolProperty(node, "showHiddeGender", false); +} + void CharDB::unload() { logger->log1("Unloading char database..."); @@ -187,3 +197,8 @@ const STD_VECTOR &CharDB::getDefaultItems() { return mDefaultItems; } + +bool CharDB::getShowHiddenGender() +{ + return showHiddenGender; +} diff --git a/src/resources/db/chardb.h b/src/resources/db/chardb.h index 88cea5173..cc60bd954 100644 --- a/src/resources/db/chardb.h +++ b/src/resources/db/chardb.h @@ -47,6 +47,8 @@ namespace CharDB unsigned *restrict const min, unsigned *restrict const max); + void loadFlags(XmlNodeConstPtr node); + unsigned getMinHairColor() A_WARN_UNUSED; unsigned getMaxHairColor() A_WARN_UNUSED; @@ -70,6 +72,8 @@ namespace CharDB unsigned getMaxRace() A_WARN_UNUSED; const STD_VECTOR &getDefaultItems() A_WARN_UNUSED; + + bool getShowHiddenGender(); } // namespace CharDB #endif // RESOURCES_DB_CHARDB_H -- cgit v1.2.3-60-g2f50