diff options
Diffstat (limited to 'src/gui')
42 files changed, 219 insertions, 187 deletions
diff --git a/src/gui/chatmsgtype.h b/src/gui/chatmsgtype.h index 5c1cf5589..62fac3e0a 100644 --- a/src/gui/chatmsgtype.h +++ b/src/gui/chatmsgtype.h @@ -37,6 +37,6 @@ namespace ChatMsgType BY_LOGGER, BY_UNKNOWN = -1 }; -} +} // namespace ChatMsgType #endif // GUI_CHATMSGTYPE_H diff --git a/src/gui/dialogtype.h b/src/gui/dialogtype.h index 8da9f37fb..afe88794a 100644 --- a/src/gui/dialogtype.h +++ b/src/gui/dialogtype.h @@ -20,8 +20,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef GUI_DIALOG_TYPE_H -#define GUI_DIALOG_TYPE_H +#ifndef GUI_DIALOGTYPE_H +#define GUI_DIALOGTYPE_H + +#undef ERROR namespace DialogType { @@ -33,4 +35,4 @@ namespace DialogType }; } -#endif // GUI_DIALOG_TYPE_H +#endif // GUI_DIALOGTYPE_H diff --git a/src/gui/fonts/font.cpp b/src/gui/fonts/font.cpp index 2edca6b0b..72a047e57 100644 --- a/src/gui/fonts/font.cpp +++ b/src/gui/fonts/font.cpp @@ -67,7 +67,6 @@ #include "gui/fonts/font.h" #include "logger.h" -#include "main.h" #include "gui/fonts/textchunk.h" diff --git a/src/gui/fonts/font.h b/src/gui/fonts/font.h index c8e39fd7c..ebb2d8dcb 100644 --- a/src/gui/fonts/font.h +++ b/src/gui/fonts/font.h @@ -142,7 +142,7 @@ class Font final }; #ifdef UNITTESTS -extern int sdlTextChunkCnt; +extern int textChunkCnt; #endif #endif // GUI_FONTS_FONT_H diff --git a/src/gui/sdlfont_unittest.cc b/src/gui/fonts/font_unittest.cc index e0f536c01..b5b589e72 100644 --- a/src/gui/sdlfont_unittest.cc +++ b/src/gui/fonts/font_unittest.cc @@ -20,9 +20,12 @@ #include "logger.h" -#include "gui/font.h" #include "gui/theme.h" +#include "gui/fonts/font.h" +#include "gui/fonts/textchunk.h" +#include "gui/fonts/textchunksmall.h" + #include "gtest/gtest.h" #include "debug.h" @@ -42,7 +45,7 @@ TEST(TextChunkList, add1) { TextChunkList list; - SDLTextChunk *chunk = new SDLTextChunk("test", + TextChunk *chunk = new TextChunk("test", Color(1, 2, 3), Color(2, 3, 4)); list.insertFirst(chunk); @@ -54,7 +57,7 @@ TEST(TextChunkList, add1) EXPECT_EQ(nullptr, chunk->next); EXPECT_EQ(1, list.search.size()); - EXPECT_EQ(chunk, (*list.search.find(SDLTextChunkSmall( + EXPECT_EQ(chunk, (*list.search.find(TextChunkSmall( chunk->text, chunk->color, chunk->color2))).second); EXPECT_EQ(1, list.searchWidth.size()); @@ -65,9 +68,9 @@ TEST(TextChunkList, add2) { TextChunkList list; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(3, 4, 5)); - SDLTextChunk *chunk2 = new SDLTextChunk("test", + TextChunk *chunk2 = new TextChunk("test", Color(2, 3, 4), Color(4, 5, 6)); list.insertFirst(chunk2); @@ -82,9 +85,9 @@ TEST(TextChunkList, add2) EXPECT_EQ(nullptr, chunk2->next); EXPECT_EQ(2, list.search.size()); - EXPECT_EQ(chunk1, (*list.search.find(SDLTextChunkSmall( + EXPECT_EQ(chunk1, (*list.search.find(TextChunkSmall( chunk1->text, chunk1->color, chunk1->color2))).second); - EXPECT_EQ(chunk2, (*list.search.find(SDLTextChunkSmall( + EXPECT_EQ(chunk2, (*list.search.find(TextChunkSmall( chunk2->text, chunk2->color, chunk2->color2))).second); EXPECT_EQ(1, list.searchWidth.size()); @@ -95,7 +98,7 @@ TEST(TextChunkList, addRemoveBack1) { TextChunkList list; - SDLTextChunk *chunk = new SDLTextChunk("test", + TextChunk *chunk = new TextChunk("test", Color(1, 2, 3), Color(1, 2, 3)); list.insertFirst(chunk); @@ -112,9 +115,9 @@ TEST(TextChunkList, addRemoveBack2) { TextChunkList list; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunk *chunk2 = new SDLTextChunk("test2", + TextChunk *chunk2 = new TextChunk("test2", Color(1, 2, 4), Color(1, 2, 5)); list.insertFirst(chunk2); @@ -128,7 +131,7 @@ TEST(TextChunkList, addRemoveBack2) EXPECT_EQ(nullptr, chunk1->next); EXPECT_EQ(1, list.search.size()); - EXPECT_EQ(chunk1, (*list.search.find(SDLTextChunkSmall( + EXPECT_EQ(chunk1, (*list.search.find(TextChunkSmall( chunk1->text, chunk1->color, chunk1->color2))).second); EXPECT_EQ(1, list.searchWidth.size()); @@ -139,9 +142,9 @@ TEST(TextChunkList, addRemoveBack3) { TextChunkList list; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunk *chunk2 = new SDLTextChunk("test2", + TextChunk *chunk2 = new TextChunk("test2", Color(2, 3, 4), Color(2, 3, 4)); list.insertFirst(chunk2); @@ -160,11 +163,11 @@ TEST(TextChunkList, addRemoveBack4) { TextChunkList list; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunk *chunk2 = new SDLTextChunk("test2", + TextChunk *chunk2 = new TextChunk("test2", Color(2, 3, 4), Color(2, 3, 4)); - SDLTextChunk *chunk3 = new SDLTextChunk("test", + TextChunk *chunk3 = new TextChunk("test", Color(3, 4, 5), Color(3, 4, 5)); list.insertFirst(chunk3); @@ -180,7 +183,7 @@ TEST(TextChunkList, addRemoveBack4) EXPECT_EQ(nullptr, chunk1->next); EXPECT_EQ(1, list.search.size()); - EXPECT_EQ(chunk1, (*list.search.find(SDLTextChunkSmall( + EXPECT_EQ(chunk1, (*list.search.find(TextChunkSmall( chunk1->text, chunk1->color, chunk1->color2))).second); EXPECT_EQ(0, list.searchWidth.size()); @@ -190,7 +193,7 @@ TEST(TextChunkList, moveToFirst1) { TextChunkList list; - SDLTextChunk *chunk = new SDLTextChunk("test", + TextChunk *chunk = new TextChunk("test", Color(1, 2, 3), Color(2, 3, 4)); list.insertFirst(chunk); @@ -207,9 +210,9 @@ TEST(TextChunkList, moveToFirst2) { TextChunkList list; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunk *chunk2 = new SDLTextChunk("test", + TextChunk *chunk2 = new TextChunk("test", Color(2, 3, 4), Color(1, 2, 3)); list.insertFirst(chunk1); @@ -229,11 +232,11 @@ TEST(TextChunkList, moveToFirst3) { TextChunkList list; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunk *chunk2 = new SDLTextChunk("test", + TextChunk *chunk2 = new TextChunk("test", Color(1, 2, 4), Color(1, 2, 3)); - SDLTextChunk *chunk3 = new SDLTextChunk("test", + TextChunk *chunk3 = new TextChunk("test", Color(1, 2, 5), Color(1, 2, 3)); list.insertFirst(chunk3); @@ -256,11 +259,11 @@ TEST(TextChunkList, moveToFirst4) { TextChunkList list; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(), Color()); - SDLTextChunk *chunk2 = new SDLTextChunk("test2", + TextChunk *chunk2 = new TextChunk("test2", Color(), Color()); - SDLTextChunk *chunk3 = new SDLTextChunk("test3", + TextChunk *chunk3 = new TextChunk("test3", Color(), Color()); list.insertFirst(chunk1); @@ -282,9 +285,9 @@ TEST(TextChunkList, moveToFirst4) TEST(TextChunkList, clear1) { TextChunkList list; - int chunksLeft = sdlTextChunkCnt; + int chunksLeft = textChunkCnt; - SDLTextChunk *chunk = new SDLTextChunk("test", Color(), Color()); + TextChunk *chunk = new TextChunk("test", Color(), Color()); list.insertFirst(chunk); list.clear(); @@ -292,7 +295,7 @@ TEST(TextChunkList, clear1) EXPECT_EQ(0, list.size); EXPECT_EQ(nullptr, list.start); EXPECT_EQ(nullptr, list.end); - EXPECT_EQ(chunksLeft, sdlTextChunkCnt); + EXPECT_EQ(chunksLeft, textChunkCnt); EXPECT_EQ(0, list.search.size()); EXPECT_EQ(0, list.searchWidth.size()); } @@ -300,13 +303,13 @@ TEST(TextChunkList, clear1) TEST(TextChunkList, clear2) { TextChunkList list; - int chunksLeft = sdlTextChunkCnt; + int chunksLeft = textChunkCnt; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(2, 0, 0)); - SDLTextChunk *chunk2 = new SDLTextChunk("test", + TextChunk *chunk2 = new TextChunk("test", Color(1, 2, 3), Color(2, 0, 1)); - SDLTextChunk *chunk3 = new SDLTextChunk("test", + TextChunk *chunk3 = new TextChunk("test", Color(1, 2, 3), Color(2, 0, 2)); list.insertFirst(chunk1); @@ -317,7 +320,7 @@ TEST(TextChunkList, clear2) EXPECT_EQ(0, list.size); EXPECT_EQ(nullptr, list.start); EXPECT_EQ(nullptr, list.end); - EXPECT_EQ(chunksLeft, sdlTextChunkCnt); + EXPECT_EQ(chunksLeft, textChunkCnt); EXPECT_EQ(0, list.search.size()); EXPECT_EQ(0, list.searchWidth.size()); } @@ -325,30 +328,30 @@ TEST(TextChunkList, clear2) TEST(TextChunkList, clear3) { TextChunkList list; - int chunksLeft = sdlTextChunkCnt; + int chunksLeft = textChunkCnt; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(2, 0, 0)); - SDLTextChunk *chunk2 = new SDLTextChunk("test", + TextChunk *chunk2 = new TextChunk("test", Color(1, 2, 3), Color(2, 0, 1)); - SDLTextChunk *chunk3 = new SDLTextChunk("test", + TextChunk *chunk3 = new TextChunk("test", Color(1, 2, 3), Color(2, 0, 2)); list.insertFirst(chunk1); list.insertFirst(chunk2); list.insertFirst(chunk3); list.moveToFirst(chunk1); - EXPECT_EQ(chunksLeft + 3, sdlTextChunkCnt); + EXPECT_EQ(chunksLeft + 3, textChunkCnt); EXPECT_EQ(3, list.search.size()); EXPECT_EQ(1, list.searchWidth.size()); list.removeBack(); - EXPECT_EQ(chunksLeft + 2, sdlTextChunkCnt); + EXPECT_EQ(chunksLeft + 2, textChunkCnt); EXPECT_EQ(2, list.search.size()); EXPECT_EQ(0, list.searchWidth.size()); list.clear(); - EXPECT_EQ(chunksLeft, sdlTextChunkCnt); + EXPECT_EQ(chunksLeft, textChunkCnt); EXPECT_EQ(0, list.search.size()); EXPECT_EQ(0, list.searchWidth.size()); } @@ -356,41 +359,41 @@ TEST(TextChunkList, clear3) TEST(TextChunkList, clear4) { TextChunkList list; - int chunksLeft = sdlTextChunkCnt; + int chunksLeft = textChunkCnt; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(2, 0, 0)); - SDLTextChunk *chunk2 = new SDLTextChunk("test", + TextChunk *chunk2 = new TextChunk("test", Color(1, 2, 3), Color(2, 0, 1)); - SDLTextChunk *chunk3 = new SDLTextChunk("test3", + TextChunk *chunk3 = new TextChunk("test3", Color(1, 2, 3), Color(2, 0, 2)); list.insertFirst(chunk1); list.insertFirst(chunk2); list.insertFirst(chunk3); list.moveToFirst(chunk2); - EXPECT_EQ(chunksLeft + 3, sdlTextChunkCnt); + EXPECT_EQ(chunksLeft + 3, textChunkCnt); EXPECT_EQ(3, list.search.size()); EXPECT_EQ(2, list.searchWidth.size()); list.removeBack(2); - EXPECT_EQ(chunksLeft + 1, sdlTextChunkCnt); + EXPECT_EQ(chunksLeft + 1, textChunkCnt); EXPECT_EQ(1, list.search.size()); EXPECT_EQ(0, list.searchWidth.size()); list.clear(); - EXPECT_EQ(chunksLeft, sdlTextChunkCnt); + EXPECT_EQ(chunksLeft, textChunkCnt); EXPECT_EQ(0, list.search.size()); EXPECT_EQ(0, list.searchWidth.size()); } TEST(TextChunkList, sort1) { - SDLTextChunkSmall item1("test line1", + TextChunkSmall item1("test line1", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunkSmall item2("test line1", + TextChunkSmall item2("test line1", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunkSmall item3("test line2", + TextChunkSmall item3("test line2", Color(1, 2, 3), Color(1, 2, 3)); EXPECT_EQ(false, item1 < item2); EXPECT_EQ(false, item2 < item1); @@ -400,9 +403,9 @@ TEST(TextChunkList, sort1) TEST(TextChunkList, sort2) { - SDLTextChunkSmall item1("test line1", + TextChunkSmall item1("test line1", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunkSmall item2("test line1", + TextChunkSmall item2("test line1", Color(2, 3, 4), Color(1, 2, 3)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); @@ -410,9 +413,9 @@ TEST(TextChunkList, sort2) TEST(TextChunkList, sort3) { - SDLTextChunkSmall item1("test line1", + TextChunkSmall item1("test line1", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunkSmall item2("test line1", + TextChunkSmall item2("test line1", Color(1, 3, 4), Color(1, 2, 3)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); @@ -420,9 +423,9 @@ TEST(TextChunkList, sort3) TEST(TextChunkList, sort4) { - SDLTextChunkSmall item1("test line1", + TextChunkSmall item1("test line1", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunkSmall item2("test line1", + TextChunkSmall item2("test line1", Color(1, 2, 4), Color(1, 2, 3)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); @@ -430,9 +433,9 @@ TEST(TextChunkList, sort4) TEST(TextChunkList, sort5) { - SDLTextChunkSmall item1("test line1", + TextChunkSmall item1("test line1", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunkSmall item2("test line1", + TextChunkSmall item2("test line1", Color(1, 2, 3), Color(2, 2, 3)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); @@ -440,9 +443,9 @@ TEST(TextChunkList, sort5) TEST(TextChunkList, sort6) { - SDLTextChunkSmall item1("test line1", + TextChunkSmall item1("test line1", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunkSmall item2("test line1", + TextChunkSmall item2("test line1", Color(1, 2, 3), Color(1, 3, 3)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); @@ -450,9 +453,9 @@ TEST(TextChunkList, sort6) TEST(TextChunkList, sort7) { - SDLTextChunkSmall item1("test line1", + TextChunkSmall item1("test line1", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunkSmall item2("test line1", + TextChunkSmall item2("test line1", Color(1, 2, 3), Color(1, 2, 4)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); diff --git a/src/gui/fonts/textchunk.cpp b/src/gui/fonts/textchunk.cpp index 632dfaf7b..be0509562 100644 --- a/src/gui/fonts/textchunk.cpp +++ b/src/gui/fonts/textchunk.cpp @@ -41,7 +41,7 @@ namespace char *strBuf = nullptr; #ifdef UNITTESTS -int sdlTextChunkCnt = 0; +int textChunkCnt = 0; #endif TextChunk::TextChunk(const std::string &text0, const Color &color0, @@ -54,7 +54,7 @@ TextChunk::TextChunk(const std::string &text0, const Color &color0, next(nullptr) { #ifdef UNITTESTS - sdlTextChunkCnt ++; + textChunkCnt ++; #endif } @@ -62,7 +62,7 @@ TextChunk::~TextChunk() { delete2(img); #ifdef UNITTESTS - sdlTextChunkCnt --; + textChunkCnt --; #endif } diff --git a/src/gui/fonts/textchunk.h b/src/gui/fonts/textchunk.h index 6f124346d..f9aa41406 100644 --- a/src/gui/fonts/textchunk.h +++ b/src/gui/fonts/textchunk.h @@ -58,7 +58,7 @@ class TextChunk final }; #ifdef UNITTESTS -extern int sdlTextChunkCnt; +extern int textChunkCnt; #endif #endif // GUI_FONTS_TEXTCHUNK_H diff --git a/src/gui/fonts/textchunklist.cpp b/src/gui/fonts/textchunklist.cpp index 98d90e23d..ec6083d7d 100644 --- a/src/gui/fonts/textchunklist.cpp +++ b/src/gui/fonts/textchunklist.cpp @@ -54,10 +54,10 @@ void TextChunkList::moveToFirst(TextChunk *const item) if (item == start) return; - TextChunk *oldPrev = item->prev; + TextChunk *const oldPrev = item->prev; if (oldPrev) oldPrev->next = item->next; - TextChunk *oldNext = item->next; + TextChunk *const oldNext = item->next; if (oldNext) oldNext->prev = item->prev; else @@ -121,7 +121,7 @@ void TextChunkList::clear() TextChunk *item = start; while (item) { - TextChunk *item2 = item->next; + TextChunk *const item2 = item->next; delete item; item = item2; } diff --git a/src/gui/fonts/textchunksmall.cpp b/src/gui/fonts/textchunksmall.cpp index 84c1aa378..aa5661dee 100644 --- a/src/gui/fonts/textchunksmall.cpp +++ b/src/gui/fonts/textchunksmall.cpp @@ -72,4 +72,3 @@ bool TextChunkSmall::operator<(const TextChunkSmall &chunk) const return false; } - diff --git a/src/gui/models/playertablemodel.cpp b/src/gui/models/playertablemodel.cpp index 119a4fba8..41e846f55 100644 --- a/src/gui/models/playertablemodel.cpp +++ b/src/gui/models/playertablemodel.cpp @@ -26,7 +26,6 @@ #include "gui/widgets/label.h" #include "gui/models/playerrelationlistmodel.h" -#include "gui/models/tablemodel.h" #include "utils/delete2.h" #include "utils/dtor.h" diff --git a/src/gui/models/serverslistmodel.h b/src/gui/models/serverslistmodel.h index 0b15aefae..a62dabc40 100644 --- a/src/gui/models/serverslistmodel.h +++ b/src/gui/models/serverslistmodel.h @@ -31,8 +31,6 @@ #include "gui/windows/serverdialog.h" -#include "utils/mutex.h" - #include "gui/models/listmodel.h" #include <string> diff --git a/src/gui/popups/createpartypopup.h b/src/gui/popups/createpartypopup.h index 16dc5c9af..c3de37259 100644 --- a/src/gui/popups/createpartypopup.h +++ b/src/gui/popups/createpartypopup.h @@ -19,6 +19,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifndef GUI_POPUPS_CREATEPARTYPOPUP_H +#define GUI_POPUPS_CREATEPARTYPOPUP_H + #include "gui/widgets/browserbox.h" #include "gui/widgets/linkhandler.h" #include "gui/widgets/popup.h" @@ -91,3 +94,5 @@ class CreatePartyPopup final : public Popup, private: BrowserBox* mBrowserBox; }; + +#endif // GUI_POPUPS_CREATEPARTYPOPUP_H diff --git a/src/gui/setupactiondata.h b/src/gui/setupactiondata.h index 94a16668f..891875d7c 100644 --- a/src/gui/setupactiondata.h +++ b/src/gui/setupactiondata.h @@ -34,9 +34,9 @@ struct SetupActionData final { #ifdef ADVGCC - SetupActionData(const std::string name0, + SetupActionData(const std::string &name0, const int actionId0, - const std::string text0) : + const std::string &text0) : name(name0), actionId(actionId0), text(text0) diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index d96b7c943..a33104084 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -48,8 +48,6 @@ #include "gui/windows/ministatuswindow.h" -#include "listeners/updatestatuslistener.h" - #include "utils/delete2.h" #include "debug.h" diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index b5d3c3593..e098cda34 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -113,7 +113,7 @@ void AvatarListBox::draw(Graphics *graphics) Font *const font = getFont(); const int fontHeight = getFont()->getHeight(); - const std::string name = player_node->getName(); + const std::string &name = player_node->getName(); // Draw the list elements graphics->setColorAll(mForegroundColor, mForegroundColor2); @@ -242,15 +242,15 @@ void AvatarListBox::draw(Graphics *graphics) { switch (a->getGender()) { - case GENDER_FEMALE: + case Gender::FEMALE: text.append(" \u2640 "); break; - case GENDER_MALE: + case Gender::MALE: text.append(" \u2642 "); break; default: - case GENDER_UNSPECIFIED: - case GENDER_OTHER: + case Gender::UNSPECIFIED: + case Gender::OTHER: break; } } @@ -261,17 +261,17 @@ void AvatarListBox::draw(Graphics *graphics) { switch (a->getGender()) { - case GENDER_FEMALE: + case Gender::FEMALE: text.append(strprintf(" \u2640 %s", a->getAdditionString().c_str())); break; - case GENDER_MALE: + case Gender::MALE: text.append(strprintf(" \u2642 %s", a->getAdditionString().c_str())); break; default: - case GENDER_UNSPECIFIED: - case GENDER_OTHER: + case Gender::UNSPECIFIED: + case Gender::OTHER: break; } } diff --git a/src/gui/widgets/browserbox_unittest.cc b/src/gui/widgets/browserbox_unittest.cc index f8b5e149e..0a3e06f27 100644 --- a/src/gui/widgets/browserbox_unittest.cc +++ b/src/gui/widgets/browserbox_unittest.cc @@ -22,9 +22,10 @@ #include "client.h" -#include "gui/font.h" #include "gui/theme.h" +#include "gui/fonts/font.h" + #include "gui/widgets/browserbox.h" #include "resources/sdlimagehelper.h" diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 400365a84..e6d3119fb 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -32,8 +32,6 @@ #include "listeners/guitableactionlistener.h" -#include "render/graphics.h" - #include "utils/delete2.h" #include "utils/dtor.h" diff --git a/src/gui/widgets/statuswindowattrs.h b/src/gui/widgets/statuswindowattrs.h index d266b2086..1cc755907 100644 --- a/src/gui/widgets/statuswindowattrs.h +++ b/src/gui/widgets/statuswindowattrs.h @@ -20,8 +20,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef GUI_WINDOWS_STATUSWINDOWATTRS_H -#define GUI_WINDOWS_STATUSWINDOWATTRS_H +#ifndef GUI_WIDGETS_STATUSWINDOWATTRS_H +#define GUI_WIDGETS_STATUSWINDOWATTRS_H #include "gui/widgets/container.h" @@ -121,4 +121,4 @@ class ChangeDisplay final : public AttrDisplay, Button *mInc; }; -#endif // GUI_WINDOWS_STATUSWINDOWATTRS_H +#endif // GUI_WIDGETS_STATUSWINDOWATTRS_H diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp index 47787d25d..4f81d2aa7 100644 --- a/src/gui/widgets/tabs/chattab.cpp +++ b/src/gui/widgets/tabs/chattab.cpp @@ -212,10 +212,13 @@ void ChatTab::chatLog(std::string line, ChatMsgType::Type own, // if configured, move magic messages log to debug chat tab if (localChatTab && this == localChatTab - && ((config.getBoolValue("showMagicInDebug") && own == ChatMsgType::BY_PLAYER - && tmp.text.length() > 1 && tmp.text.at(0) == '#' + && ((config.getBoolValue("showMagicInDebug") + && own == ChatMsgType::BY_PLAYER + && tmp.text.length() > 1 + && tmp.text.at(0) == '#' && tmp.text.at(1) != '#') - || (config.getBoolValue("serverMsgInDebug") && (own == ChatMsgType::BY_SERVER + || (config.getBoolValue("serverMsgInDebug") + && (own == ChatMsgType::BY_SERVER || tmp.nick.empty())))) { if (debugChatTab) diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp index 723131edc..b14208c3b 100644 --- a/src/gui/widgets/tabs/setup_relations.cpp +++ b/src/gui/widgets/tabs/setup_relations.cpp @@ -39,7 +39,6 @@ #include "gui/widgets/guitable.h" #include "utils/delete2.h" -#include "utils/gettext.h" #include "debug.h" diff --git a/src/gui/widgets/tabs/socialattacktab.h b/src/gui/widgets/tabs/socialattacktab.h index 01921b016..17ee78eb0 100644 --- a/src/gui/widgets/tabs/socialattacktab.h +++ b/src/gui/widgets/tabs/socialattacktab.h @@ -31,8 +31,6 @@ #include "gui/widgets/tabs/socialtabbase.h" -#include "resources/map/mapitem.h" - #include "utils/delete2.h" #include "utils/gettext.h" diff --git a/src/gui/widgets/tabs/socialfriendsfunctor.h b/src/gui/widgets/tabs/socialfriendsfunctor.h new file mode 100644 index 000000000..1ad209adb --- /dev/null +++ b/src/gui/widgets/tabs/socialfriendsfunctor.h @@ -0,0 +1,52 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GUI_WIDGETS_TABS_SOCIALFRIENDSFUNCTOR_H +#define GUI_WIDGETS_TABS_SOCIALFRIENDSFUNCTOR_H + +#include "avatar.h" + +#include "localconsts.h" + +class SortFriendsFunctor final +{ + public: + bool operator() (const Avatar *const m1, + const Avatar *const m2) const + { + if (!m1 || !m2) + return false; + + if (m1->getOnline() != m2->getOnline()) + return m1->getOnline() > m2->getOnline(); + + if (m1->getName() != m2->getName()) + { + std::string s1 = m1->getName(); + std::string s2 = m2->getName(); + toLower(s1); + toLower(s2); + return s1 < s2; + } + return false; + } +}; + +#endif // GUI_WIDGETS_TABS_SOCIALFRIENDSFUNCTOR_H diff --git a/src/gui/widgets/tabs/socialfriendstab.h b/src/gui/widgets/tabs/socialfriendstab.h index 3d65e2678..0a43c6e2f 100644 --- a/src/gui/widgets/tabs/socialfriendstab.h +++ b/src/gui/widgets/tabs/socialfriendstab.h @@ -24,15 +24,15 @@ #include "gui/widgets/tabs/socialtab.h" #include "actormanager.h" -#include "avatar.h" -#include "being/actortype.h" #include "being/playerrelations.h" #include "gui/models/beingslistmodel.h" #include "gui/windows/whoisonline.h" +#include "gui/widgets/tabs/socialfriendsfunctor.h" + #include "utils/delete2.h" #include "utils/gettext.h" #include "utils/stringutils.h" @@ -41,33 +41,6 @@ #include "localconsts.h" -namespace -{ - static class SortFriendsFunctor final - { - public: - bool operator() (const Avatar *const m1, - const Avatar *const m2) const - { - if (!m1 || !m2) - return false; - - if (m1->getOnline() != m2->getOnline()) - return m1->getOnline() > m2->getOnline(); - - if (m1->getName() != m2->getName()) - { - std::string s1 = m1->getName(); - std::string s2 = m2->getName(); - toLower(s1); - toLower(s2); - return s1 < s2; - } - return false; - } - } friendSorter; -} // namespace - class SocialFriendsTab final : public SocialTab { public: @@ -75,7 +48,8 @@ class SocialFriendsTab final : public SocialTab std::string name, const bool showBackground) : SocialTab(widget), - mBeings(new BeingsListModel) + mBeings(new BeingsListModel), + mFriendSorter() { createControls(mBeings, showBackground); @@ -139,7 +113,7 @@ class SocialFriendsTab final : public SocialTab total ++; avatars->push_back(ava); } - std::sort(avatars->begin(), avatars->end(), friendSorter); + std::sort(avatars->begin(), avatars->end(), mFriendSorter); delete players; // TRANSLATORS: social window label @@ -151,6 +125,7 @@ class SocialFriendsTab final : public SocialTab private: BeingsListModel *mBeings; + SortFriendsFunctor mFriendSorter; }; #endif // GUI_WIDGETS_TABS_SOCIALFRIENDSTAB_H diff --git a/src/gui/widgets/tabs/socialguildtab.h b/src/gui/widgets/tabs/socialguildtab.h index ee40e146f..0347087b7 100644 --- a/src/gui/widgets/tabs/socialguildtab.h +++ b/src/gui/widgets/tabs/socialguildtab.h @@ -54,7 +54,8 @@ class SocialGuildTab final : public SocialTab, setHighlightedTabColor(&getThemeColor( Theme::GUILD_SOCIAL_TAB_HIGHLIGHTED), &getThemeColor( Theme::GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE)); - setSelectedTabColor(&getThemeColor(Theme::GUILD_SOCIAL_TAB_SELECTED), + setSelectedTabColor(&getThemeColor( + Theme::GUILD_SOCIAL_TAB_SELECTED), &getThemeColor(Theme::GUILD_SOCIAL_TAB_SELECTED_OUTLINE)); createControls(guild, showBackground); @@ -81,7 +82,9 @@ class SocialGuildTab final : public SocialTab, localChatTab->chatLog(strprintf( // TRANSLATORS: chat message _("Invited user %s to guild %s."), - name.c_str(), mGuild->getName().c_str()), ChatMsgType::BY_SERVER); + name.c_str(), + mGuild->getName().c_str()), + ChatMsgType::BY_SERVER); } mInviteDialog = nullptr; } @@ -95,8 +98,10 @@ class SocialGuildTab final : public SocialTab, if (localChatTab) { // TRANSLATORS: chat message - localChatTab->chatLog(strprintf(_("Guild %s quit requested."), - mGuild->getName().c_str()), ChatMsgType::BY_SERVER); + localChatTab->chatLog(strprintf( + _("Guild %s quit requested."), + mGuild->getName().c_str()), + ChatMsgType::BY_SERVER); } mConfirmDialog = nullptr; } diff --git a/src/gui/widgets/tabs/socialguildtab2.h b/src/gui/widgets/tabs/socialguildtab2.h index c5702b17d..ba40d7c4f 100644 --- a/src/gui/widgets/tabs/socialguildtab2.h +++ b/src/gui/widgets/tabs/socialguildtab2.h @@ -52,7 +52,8 @@ class SocialGuildTab2 final : public SocialTab, setHighlightedTabColor(&getThemeColor( Theme::GUILD_SOCIAL_TAB_HIGHLIGHTED), &getThemeColor( Theme::GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE)); - setSelectedTabColor(&getThemeColor(Theme::GUILD_SOCIAL_TAB_SELECTED), + setSelectedTabColor(&getThemeColor( + Theme::GUILD_SOCIAL_TAB_SELECTED), &getThemeColor(Theme::GUILD_SOCIAL_TAB_SELECTED_OUTLINE)); createControls(guild, showBackground); @@ -70,7 +71,8 @@ class SocialGuildTab2 final : public SocialTab, { } - void buildCounter(const int online0 A_UNUSED, const int total0 A_UNUSED) + void buildCounter(const int online0 A_UNUSED, + const int total0 A_UNUSED) { if (!player_node) return; diff --git a/src/gui/widgets/tabs/socialnavigationtab.h b/src/gui/widgets/tabs/socialnavigationtab.h index e8925cbb2..4344e1251 100644 --- a/src/gui/widgets/tabs/socialnavigationtab.h +++ b/src/gui/widgets/tabs/socialnavigationtab.h @@ -204,7 +204,8 @@ class SocialNavigationTab final : public SocialTab if (item) { const std::string name = strprintf("%s [%d %d]", - item->getComment().c_str(), item->getX(), item->getY()); + item->getComment().c_str(), + item->getX(), item->getY()); ava->setName(name); ava->setOriginalName(name); } diff --git a/src/gui/widgets/tabs/socialpartytab.h b/src/gui/widgets/tabs/socialpartytab.h index 247414851..847a43d42 100644 --- a/src/gui/widgets/tabs/socialpartytab.h +++ b/src/gui/widgets/tabs/socialpartytab.h @@ -55,7 +55,8 @@ class SocialPartyTab final : public SocialTab, setHighlightedTabColor(&getThemeColor( Theme::PARTY_SOCIAL_TAB_HIGHLIGHTED), &getThemeColor( Theme::PARTY_SOCIAL_TAB_HIGHLIGHTED_OUTLINE)); - setSelectedTabColor(&getThemeColor(Theme::PARTY_SOCIAL_TAB_SELECTED), + setSelectedTabColor(&getThemeColor( + Theme::PARTY_SOCIAL_TAB_SELECTED), &getThemeColor(Theme::PARTY_SOCIAL_TAB_SELECTED_OUTLINE)); createControls(party, showBackground); @@ -80,8 +81,10 @@ class SocialPartyTab final : public SocialTab, if (localChatTab) { // TRANSLATORS: chat message - localChatTab->chatLog(strprintf(_("Invited user %s to party."), - name.c_str()), ChatMsgType::BY_SERVER); + localChatTab->chatLog(strprintf( + _("Invited user %s to party."), + name.c_str()), + ChatMsgType::BY_SERVER); } mInviteDialog = nullptr; } @@ -95,8 +98,10 @@ class SocialPartyTab final : public SocialTab, if (localChatTab) { // TRANSLATORS: tab in social window - localChatTab->chatLog(strprintf(_("Party %s quit requested."), - mParty->getName().c_str()), ChatMsgType::BY_SERVER); + localChatTab->chatLog(strprintf( + _("Party %s quit requested."), + mParty->getName().c_str()), + ChatMsgType::BY_SERVER); } mConfirmDialog = nullptr; } @@ -129,7 +134,8 @@ class SocialPartyTab final : public SocialTab, mConfirmDialog->addActionListener(this); } - void buildCounter(const int online0 A_UNUSED, const int total0 A_UNUSED) + void buildCounter(const int online0 A_UNUSED, + const int total0 A_UNUSED) { if (!player_node) return; diff --git a/src/gui/widgets/tabs/socialpickuptab.h b/src/gui/widgets/tabs/socialpickuptab.h index 15d7c3aeb..3dd4d5959 100644 --- a/src/gui/widgets/tabs/socialpickuptab.h +++ b/src/gui/widgets/tabs/socialpickuptab.h @@ -46,7 +46,8 @@ class SocialPickupTab final : public SocialTab { createControls(mBeings, showBackground); - // TRANSLATORS: Pickup filter tab name in social window. Should be small + // TRANSLATORS: Pickup filter tab name in social window. + // TRANSLATORS: Should be small setCaption(_("Pik")); } diff --git a/src/gui/widgets/tabs/socialplayerstab.h b/src/gui/widgets/tabs/socialplayerstab.h index bb2e2250a..78c03feb4 100644 --- a/src/gui/widgets/tabs/socialplayerstab.h +++ b/src/gui/widgets/tabs/socialplayerstab.h @@ -78,7 +78,8 @@ class SocialPlayersTab final : public SocialTab return; if (Party::getParty(1)) { - const PartyMember *const pm = Party::getParty(1)->getMember(name); + const PartyMember *const + pm = Party::getParty(1)->getMember(name); if (pm && pm->getMaxHp() > 0) { avatar->setMaxHp(pm->getMaxHp()); diff --git a/src/gui/windows/botcheckerwindow.cpp b/src/gui/windows/botcheckerwindow.cpp index aa991b36b..8e4bdd047 100644 --- a/src/gui/windows/botcheckerwindow.cpp +++ b/src/gui/windows/botcheckerwindow.cpp @@ -29,12 +29,9 @@ #include "gui/models/userstablemodel.h" -#include "actormanager.h" #include "client.h" #include "configuration.h" -#include "being/localplayer.h" - #include "utils/gettext.h" #include "debug.h" diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index f0daaeef2..6799bcaf8 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -159,7 +159,7 @@ namespace return type1 < type2; } } itemTypeBuySorter; -} +} // namespace BuyDialog::DialogList BuyDialog::instances; diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 203ab01d2..cc254bce0 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -148,7 +148,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, setSticky(true); setWindowName("NewCharacter"); - mPlayer->setGender(GENDER_MALE); + mPlayer->setGender(Gender::MALE); const std::vector<int> &items = CharDB::getDefaultItems(); int i = 1; for (std::vector<int>::const_iterator it = items.begin(), @@ -410,9 +410,9 @@ void CharCreateDialog::action(const ActionEvent &event) else if (id == "gender") { if (mMale->isSelected()) - mPlayer->setGender(GENDER_MALE); + mPlayer->setGender(Gender::MALE); else - mPlayer->setGender(GENDER_FEMALE); + mPlayer->setGender(Gender::FEMALE); } else if (id == "action") { @@ -537,15 +537,16 @@ void CharCreateDialog::setAttributes(const StringVect &labels, setButtonsPosition(w, h); } -void CharCreateDialog::setFixedGender(const bool fixed, const Gender gender) +void CharCreateDialog::setFixedGender(const bool fixed, + const Gender::Type gender) { - if (gender == GENDER_FEMALE) + if (gender == Gender::FEMALE) { mFemale->setSelected(true); mMale->setSelected(false); mOther->setSelected(false); } - else if (gender == GENDER_MALE) + else if (gender == Gender::MALE) { mFemale->setSelected(false); mMale->setSelected(true); diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h index e0a188303..58395e21e 100644 --- a/src/gui/windows/charcreatedialog.h +++ b/src/gui/windows/charcreatedialog.h @@ -73,7 +73,7 @@ class CharCreateDialog final : public Window, const int min, const int max); void setFixedGender(const bool fixed, - const Gender gender = GENDER_FEMALE); + const Gender::Type gender = Gender::FEMALE); void logic() override final; diff --git a/src/gui/windows/chardeleteconfirm.h b/src/gui/windows/chardeleteconfirm.h index 4ab990eae..06840ceda 100644 --- a/src/gui/windows/chardeleteconfirm.h +++ b/src/gui/windows/chardeleteconfirm.h @@ -20,6 +20,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifndef GUI_WINDOWS_CHARDELETECONFIRM_H +#define GUI_WINDOWS_CHARDELETECONFIRM_H + #include "gui/windows/charselectdialog.h" #include "gui/windows/confirmdialog.h" @@ -58,3 +61,5 @@ class CharDeleteConfirm final : public ConfirmDialog CharSelectDialog *mMaster; int mIndex; }; + +#endif // GUI_WINDOWS_CHARDELETECONFIRM_H diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 66460f4e7..74a135bab 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -48,8 +48,6 @@ #include "net/loginhandler.h" #include "net/net.h" -#include "utils/gettext.h" - #include "debug.h" // Character slots per row in the dialog diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp index 8dc915604..bcf51d023 100644 --- a/src/gui/windows/debugwindow.cpp +++ b/src/gui/windows/debugwindow.cpp @@ -147,4 +147,3 @@ void DebugWindow::logicChildren() BLOCK_END("DebugWindow::logicChildren") } #endif - diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index c2b00e87e..4d49eedd9 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -49,7 +49,6 @@ #include "gui/widgets/slider.h" #include "utils/delete2.h" -#include "utils/gettext.h" #include <cmath> diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index 01d1bcd61..99354f4fb 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -44,11 +44,9 @@ #include "gui/widgets/layoutcell.h" #include "net/charserverhandler.h" -#include "net/logindata.h" #include "net/loginhandler.h" #include "net/net.h" -#include "utils/gettext.h" #include "utils/paths.h" #include "debug.h" diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp index 2ecf5fc87..61b7e0dac 100644 --- a/src/gui/windows/registerdialog.cpp +++ b/src/gui/windows/registerdialog.cpp @@ -253,11 +253,11 @@ void RegisterDialog::action(const ActionEvent &event) mLoginData->username = mUserField->getText(); mLoginData->password = mPasswordField->getText(); if (mFemaleButton && mFemaleButton->isSelected()) - mLoginData->gender = GENDER_FEMALE; + mLoginData->gender = Gender::FEMALE; else if (mOtherButton && mOtherButton->isSelected()) - mLoginData->gender = GENDER_OTHER; + mLoginData->gender = Gender::OTHER; else - mLoginData->gender = GENDER_MALE; + mLoginData->gender = Gender::MALE; if (mEmailField) mLoginData->email = mEmailField->getText(); diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 04e2f1511..903a21a57 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -49,7 +49,6 @@ #include "inventory.h" #include "item.h" #include "shopitem.h" -#include "soundconsts.h" #include "soundmanager.h" #include "being/attributes.h" diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 2a858d964..7b0aa849a 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -50,13 +50,6 @@ #include "gui/popups/createpartypopup.h" -#include "net/net.h" -#include "net/guildhandler.h" -#include "net/partyhandler.h" - -#include "utils/delete2.h" -#include "utils/gettext.h" - #include "debug.h" extern unsigned int tmwServerVersion; diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index 7ae87c470..797ba68fe 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -22,6 +22,9 @@ #include "gui/windows/whoisonline.h" +#include "actormanager.h" +#include "client.h" +#include "configuration.h" #include "guild.h" #include "party.h" @@ -35,11 +38,6 @@ #include "gui/widgets/browserbox.h" #include "gui/widgets/scrollarea.h" -#include "actormanager.h" -#include "client.h" -#include "configuration.h" -#include "main.h" - #include "being/beingflag.h" #include "being/localplayer.h" #include "being/playerrelations.h" @@ -440,7 +438,7 @@ void WhoIsOnline::loadWebList() OnlinePlayer *const player = new OnlinePlayer(nick, static_cast<unsigned char>(255), level, - GENDER_UNSPECIFIED, -1); + Gender::UNSPECIFIED, -1); mOnlinePlayers.insert(player); mOnlineNicks.insert(nick); @@ -829,9 +827,9 @@ void OnlinePlayer::setText(std::string color) if (mLevel > 0) mText.append(strprintf("%d", mLevel)); - if (mGender == GENDER_FEMALE) + if (mGender == Gender::FEMALE) mText.append("\u2640"); - else if (mGender == GENDER_MALE) + else if (mGender == Gender::MALE) mText.append("\u2642"); if (mStatus > 0 && mStatus != 255) |