summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-10-29 16:19:55 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-10-29 17:16:37 +0100
commit6cd8881f1b11c99f8e72735017e743c50094e922 (patch)
tree7f6726d2ed01fe39b78c4e2eb6cc4561c6e0db80 /src/gui
parent93ad5ec32de124dfa0c054acfd1f2a378cb9ca75 (diff)
downloadmana-6cd8881f1b11c99f8e72735017e743c50094e922.tar.gz
mana-6cd8881f1b11c99f8e72735017e743c50094e922.tar.bz2
mana-6cd8881f1b11c99f8e72735017e743c50094e922.tar.xz
mana-6cd8881f1b11c99f8e72735017e743c50094e922.zip
Turned the PlayerRelation struct into an enum class
Less code to achieve the same thing (strong type and namespaced values). The permissions related values have been moved to a PlayerPermissions struct, which is also a bit less confusing.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chatwindow.cpp2
-rw-r--r--src/gui/setup_players.cpp26
2 files changed, 14 insertions, 14 deletions
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 29bf9c1b..b4b03450 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -406,7 +406,7 @@ void ChatWindow::event(Event::Channel channel, const Event &event)
}
else if (event.getType() == Event::Being)
{
- if (event.getInt("permissions") & PlayerRelation::SPEECH_LOG)
+ if (event.getInt("permissions") & PlayerPermissions::SPEECH_LOG)
localChatTab->chatLog(event.getString("message"), BY_OTHER);
}
}
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index 89c588c0..a771d7ae 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -56,7 +56,7 @@ static const char *table_titles[COLUMNS_NR] =
N_("Relation")
};
-static const char *RELATION_NAMES[PlayerRelation::RELATIONS_NR] =
+static const char *RELATION_NAMES[RELATIONS_NR] =
{
N_("Neutral"),
N_("Friend"),
@@ -71,7 +71,7 @@ public:
int getNumberOfElements() override
{
- return PlayerRelation::RELATIONS_NR;
+ return RELATIONS_NR;
}
std::string getElementAt(int i) override
@@ -135,7 +135,7 @@ public:
mWidgets.push_back(widget);
gcn::DropDown *choicebox = new DropDown(mListModel);
- choicebox->setSelected(player_relations.getRelation(name));
+ choicebox->setSelected(static_cast<int>(player_relations.getRelation(name)));
mWidgets.push_back(choicebox);
}
@@ -147,8 +147,8 @@ public:
auto *choicebox = static_cast<gcn::DropDown *>(
getElementAt(row, RELATION_CHOICE_COLUMN));
player_relations.setRelation(getPlayerAt(row),
- static_cast<PlayerRelation::Relation>(
- choicebox->getSelected()));
+ static_cast<PlayerRelation>(
+ choicebox->getSelected()));
}
@@ -212,9 +212,9 @@ Setup_Players::Setup_Players():
mPlayerTitleTable(new GuiTable(mPlayerTableTitleModel)),
mPlayerScrollArea(new ScrollArea(mPlayerTable)),
mDefaultTrading(new CheckBox(_("Allow trading"),
- player_relations.getDefault() & PlayerRelation::TRADE)),
+ player_relations.getDefault() & PlayerPermissions::TRADE)),
mDefaultWhisper(new CheckBox(_("Allow whispers"),
- player_relations.getDefault() & PlayerRelation::WHISPER)),
+ player_relations.getDefault() & PlayerPermissions::WHISPER)),
mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)),
mWhisperTab(config.getBoolValue("whispertab")),
mWhisperTabCheckBox(new CheckBox(_("Put all whispers in tabs"), mWhisperTab)),
@@ -316,13 +316,13 @@ void Setup_Players::apply()
player_relations.store();
unsigned int old_default_relations = player_relations.getDefault() &
- ~(PlayerRelation::TRADE |
- PlayerRelation::WHISPER);
+ ~(PlayerPermissions::TRADE |
+ PlayerPermissions::WHISPER);
player_relations.setDefault(old_default_relations
| (mDefaultTrading->isSelected() ?
- PlayerRelation::TRADE : 0)
+ PlayerPermissions::TRADE : 0)
| (mDefaultWhisper->isSelected() ?
- PlayerRelation::WHISPER : 0));
+ PlayerPermissions::WHISPER : 0));
config.setValue("whispertab", mWhisperTab);
bool showGender = config.getBoolValue("showgender");
@@ -398,7 +398,7 @@ void Setup_Players::playerRelationsUpdated()
{
mPlayerTableModel->playerRelationsUpdated();
mDefaultTrading->setSelected(
- player_relations.getDefault() & PlayerRelation::TRADE);
+ player_relations.getDefault() & PlayerPermissions::TRADE);
mDefaultWhisper->setSelected(
- player_relations.getDefault() & PlayerRelation::WHISPER);
+ player_relations.getDefault() & PlayerPermissions::WHISPER);
}