diff --git a/Source/DiabloUI/button.cpp b/Source/DiabloUI/button.cpp index 609d0911503..6bffa152dd7 100644 --- a/Source/DiabloUI/button.cpp +++ b/Source/DiabloUI/button.cpp @@ -29,7 +29,7 @@ void RenderButton(UiButton *button) SDL_Color color1 = { 243, 243, 243, 0 }; SDL_Color color2 = { 0, 0, 0, 0 }; - DrawTTF(button->m_text, textRect, UIS_CENTER, + DrawTTF(button->m_text, textRect, UiFlags::AlignCenter, color1, color2, button->m_render_cache); } diff --git a/Source/DiabloUI/diabloui.cpp b/Source/DiabloUI/diabloui.cpp index 1900e9518bc..d03aec0b474 100644 --- a/Source/DiabloUI/diabloui.cpp +++ b/Source/DiabloUI/diabloui.cpp @@ -102,7 +102,7 @@ void UiInitList(int count, void (*fnFocus)(int value), void (*fnSelect)(int valu #endif textInputActive = false; for (const auto &item : items) { - if (item->m_type == UI_EDIT) { + if (item->m_type == UiType::Edit) { auto *pItemUIEdit = static_cast(item.get()); SDL_SetTextInputRect(&item->m_rect); textInputActive = true; @@ -121,14 +121,14 @@ void UiInitList(int count, void (*fnFocus)(int value), void (*fnSelect)(int valu } } -void UiInitScrollBar(UiScrollBar *uiSb, std::size_t viewportSize, const std::size_t *currentOffset) +void UiInitScrollBar(UiScrollbar *uiSb, std::size_t viewportSize, const std::size_t *currentOffset) { ListViewportSize = viewportSize; ListOffset = currentOffset; if (ListViewportSize >= static_cast(SelectedItemMax + 1)) { - uiSb->add_flag(UIS_HIDDEN); + uiSb->add_flag(UiFlags::ElementHidden); } else { - uiSb->remove_flag(UIS_HIDDEN); + uiSb->remove_flag(UiFlags::ElementHidden); } } @@ -636,17 +636,17 @@ void UiAddBackground(std::vector> *vecDialog) { if (ArtBackgroundWidescreen.surface != nullptr) { SDL_Rect rectw = { 0, UI_OFFSET_Y, 0, 0 }; - vecDialog->push_back(std::make_unique(&ArtBackgroundWidescreen, /*bAnimated=*/false, /*iFrame=*/0, rectw, UIS_CENTER)); + vecDialog->push_back(std::make_unique(&ArtBackgroundWidescreen, rectw, UiFlags::AlignCenter)); } SDL_Rect rect = { 0, UI_OFFSET_Y, 0, 0 }; - vecDialog->push_back(std::make_unique(&ArtBackground, /*bAnimated=*/false, /*iFrame=*/0, rect, UIS_CENTER)); + vecDialog->push_back(std::make_unique(&ArtBackground, rect, UiFlags::AlignCenter)); } void UiAddLogo(std::vector> *vecDialog, int size, int y) { SDL_Rect rect = { 0, (Sint16)(UI_OFFSET_Y + y), 0, 0 }; - vecDialog->push_back(std::make_unique(&ArtLogos[size], /*bAnimated=*/true, /*iFrame=*/0, rect, UIS_CENTER)); + vecDialog->push_back(std::make_unique(&ArtLogos[size], rect, UiFlags::AlignCenter, /*bAnimated=*/true)); } void UiFadeIn() @@ -734,7 +734,7 @@ void Render(const UiArtText *uiArtText) void Render(const UiImage *uiImage) { int x = uiImage->m_rect.x; - if ((uiImage->m_iFlags & UIS_CENTER) != 0 && uiImage->m_art != nullptr) { + if (HasAnyOf(uiImage->m_iFlags, UiFlags::AlignCenter) && uiImage->m_art != nullptr) { const int xOffset = GetCenterOffset(uiImage->m_art->w(), uiImage->m_rect.w); x += xOffset; } @@ -761,7 +761,7 @@ void Render(const UiList *uiList) } } -void Render(const UiScrollBar *uiSb) +void Render(const UiScrollbar *uiSb) { // Bar background (tiled): { @@ -805,31 +805,31 @@ void Render(const UiEdit *uiEdit) void RenderItem(UiItemBase *item) { - if (item->has_flag(UIS_HIDDEN)) + if (item->has_flag(UiFlags::ElementHidden)) return; switch (item->m_type) { - case UI_TEXT: + case UiType::Text: Render(static_cast(item)); break; - case UI_ART_TEXT: + case UiType::ArtText: Render(static_cast(item)); break; - case UI_IMAGE: + case UiType::Image: Render(static_cast(item)); break; - case UI_ART_TEXT_BUTTON: + case UiType::ArtTextButton: Render(static_cast(item)); break; - case UI_BUTTON: + case UiType::Button: RenderButton(static_cast(item)); break; - case UI_LIST: + case UiType::List: Render(static_cast(item)); break; - case UI_SCROLLBAR: - Render(static_cast(item)); + case UiType::Scrollbar: + Render(static_cast(item)); break; - case UI_EDIT: + case UiType::Edit: Render(static_cast(item)); break; } @@ -873,7 +873,7 @@ bool HandleMouseEventList(const SDL_Event &event, UiList *uiList) return true; } -bool HandleMouseEventScrollBar(const SDL_Event &event, const UiScrollBar *uiSb) +bool HandleMouseEventScrollBar(const SDL_Event &event, const UiScrollbar *uiSb) { if (event.button.button != SDL_BUTTON_LEFT) return false; @@ -911,17 +911,17 @@ bool HandleMouseEventScrollBar(const SDL_Event &event, const UiScrollBar *uiSb) bool HandleMouseEvent(const SDL_Event &event, UiItemBase *item) { - if (item->has_any_flag(UIS_HIDDEN | UIS_DISABLED) || !IsInsideRect(event, item->m_rect)) + if (item->has_any_flag(UiFlags::ElementHidden | UiFlags::ElementDisabled) || !IsInsideRect(event, item->m_rect)) return false; switch (item->m_type) { - case UI_ART_TEXT_BUTTON: + case UiType::ArtTextButton: return HandleMouseEventArtTextButton(event, static_cast(item)); - case UI_BUTTON: + case UiType::Button: return HandleMouseEventButton(event, static_cast(item)); - case UI_LIST: + case UiType::List: return HandleMouseEventList(event, static_cast(item)); - case UI_SCROLLBAR: - return HandleMouseEventScrollBar(event, static_cast(item)); + case UiType::Scrollbar: + return HandleMouseEventScrollBar(event, static_cast(item)); default: return false; } @@ -970,7 +970,7 @@ bool UiItemMouseEvents(SDL_Event *event, const std::vector &items) if (event->type == SDL_MOUSEBUTTONUP && event->button.button == SDL_BUTTON_LEFT) { scrollBarState.downArrowPressed = scrollBarState.upArrowPressed = false; for (const auto &item : items) { - if (item->m_type == UI_BUTTON) + if (item->m_type == UiType::Button) HandleGlobalMouseUpButton(static_cast(item)); } } @@ -1000,7 +1000,7 @@ bool UiItemMouseEvents(SDL_Event *event, const std::vectortype == SDL_MOUSEBUTTONUP && event->button.button == SDL_BUTTON_LEFT) { scrollBarState.downArrowPressed = scrollBarState.upArrowPressed = false; for (const auto &item : items) { - if (item->m_type == UI_BUTTON) + if (item->m_type == UiType::Button) HandleGlobalMouseUpButton(static_cast(item.get())); } } diff --git a/Source/DiabloUI/diabloui.h b/Source/DiabloUI/diabloui.h index 7e8ff999ee6..9b5a8ff6071 100644 --- a/Source/DiabloUI/diabloui.h +++ b/Source/DiabloUI/diabloui.h @@ -120,7 +120,7 @@ void UiFocusNavigationSelect(); void UiFocusNavigationEsc(); void UiFocusNavigationYesNo(); void UiInitList(int count, void (*fnFocus)(int value), void (*fnSelect)(int value), void (*fnEsc)(), const std::vector> &items, bool wraps = false, bool (*fnYesNo)() = NULL); -void UiInitScrollBar(UiScrollBar *uiSb, std::size_t viewportSize, const std::size_t *currentOffset); +void UiInitScrollBar(UiScrollbar *uiSb, std::size_t viewportSize, const std::size_t *currentOffset); void UiClearScreen(); void UiPollAndRender(); void UiRenderItems(const std::vector &items); diff --git a/Source/DiabloUI/dialogs.cpp b/Source/DiabloUI/dialogs.cpp index 342a01483cf..87e50f85033 100644 --- a/Source/DiabloUI/dialogs.cpp +++ b/Source/DiabloUI/dialogs.cpp @@ -166,23 +166,23 @@ void Init(const char *text, const char *caption, bool error, bool renderBehind) vecOkDialog.push_back(std::make_unique(&dialogArt, rect1)); SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 200), (Sint16)(UI_OFFSET_Y + 211), 240, 80 }; - vecOkDialog.push_back(std::make_unique(text, rect2, UIS_CENTER)); + vecOkDialog.push_back(std::make_unique(text, rect2, UiFlags::AlignCenter)); SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 265), (Sint16)(UI_OFFSET_Y + 265), SML_BUTTON_WIDTH, SML_BUTTON_HEIGHT }; - vecOkDialog.push_back(std::make_unique(&SmlButton, _("OK"), &DialogActionOK, rect3, 0)); + vecOkDialog.push_back(std::make_unique(&SmlButton, _("OK"), &DialogActionOK, rect3)); } else { SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 127), (Sint16)(UI_OFFSET_Y + 100), 385, 280 }; vecOkDialog.push_back(std::make_unique(&dialogArt, rect1)); SDL_Color color = { 255, 255, 0, 0 }; SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 147), (Sint16)(UI_OFFSET_Y + 110), 345, 20 }; - vecOkDialog.push_back(std::make_unique(text, color, rect2, UIS_CENTER)); + vecOkDialog.push_back(std::make_unique(text, rect2, UiFlags::AlignCenter, color)); SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 147), (Sint16)(UI_OFFSET_Y + 141), 345, 190 }; - vecOkDialog.push_back(std::make_unique(caption, rect3, UIS_CENTER)); + vecOkDialog.push_back(std::make_unique(caption, rect3, UiFlags::AlignCenter)); SDL_Rect rect4 = { (Sint16)(PANEL_LEFT + 264), (Sint16)(UI_OFFSET_Y + 335), SML_BUTTON_WIDTH, SML_BUTTON_HEIGHT }; - vecOkDialog.push_back(std::make_unique(&SmlButton, _("OK"), &DialogActionOK, rect4, 0)); + vecOkDialog.push_back(std::make_unique(&SmlButton, _("OK"), &DialogActionOK, rect4)); } if (!renderBehind) { diff --git a/Source/DiabloUI/mainmenu.cpp b/Source/DiabloUI/mainmenu.cpp index f2abd68d05f..669206ada95 100644 --- a/Source/DiabloUI/mainmenu.cpp +++ b/Source/DiabloUI/mainmenu.cpp @@ -56,10 +56,10 @@ void MainmenuLoad(const char *name, void (*fnSound)(const char *file)) UiAddBackground(&vecMainMenuDialog); UiAddLogo(&vecMainMenuDialog); - vecMainMenuDialog.push_back(std::make_unique(vecMenuItems, PANEL_LEFT + 64, (UI_OFFSET_Y + 192), 510, 43, UIS_HUGE | UIS_GOLD | UIS_CENTER)); + vecMainMenuDialog.push_back(std::make_unique(vecMenuItems, PANEL_LEFT + 64, (UI_OFFSET_Y + 192), 510, 43, UiFlags::FontHuge | UiFlags::ColorGold | UiFlags::AlignCenter)); SDL_Rect rect = { 17, (Sint16)(gnScreenHeight - 36), 605, 21 }; - vecMainMenuDialog.push_back(std::make_unique(name, rect, UIS_SMALL)); + vecMainMenuDialog.push_back(std::make_unique(name, rect, UiFlags::FontSmall)); UiInitList(vecMenuItems.size(), nullptr, UiMainMenuSelect, MainmenuEsc, vecMainMenuDialog, true); } diff --git a/Source/DiabloUI/progress.cpp b/Source/DiabloUI/progress.cpp index 6a4a4120b4c..5c1d9d43c48 100644 --- a/Source/DiabloUI/progress.cpp +++ b/Source/DiabloUI/progress.cpp @@ -44,7 +44,7 @@ void ProgressLoad(const char *msg) msgShadow = TTF_RenderText_Solid(font, msg, black); } SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 265), (Sint16)(UI_OFFSET_Y + 267), SML_BUTTON_WIDTH, SML_BUTTON_HEIGHT }; - vecProgress.push_back(std::make_unique(&SmlButton, _("Cancel"), &DialogActionCancel, rect3, 0)); + vecProgress.push_back(std::make_unique(&SmlButton, _("Cancel"), &DialogActionCancel, rect3)); } void ProgressFree() diff --git a/Source/DiabloUI/scrollbar.h b/Source/DiabloUI/scrollbar.h index f47d67800f3..f94a3d493e2 100644 --- a/Source/DiabloUI/scrollbar.h +++ b/Source/DiabloUI/scrollbar.h @@ -23,7 +23,7 @@ enum ScrollBarArrowFrame : uint8_t { extern Art ArtScrollBarThumb; const Uint16 SCROLLBAR_ARROW_WIDTH = 25; -inline SDL_Rect UpArrowRect(const UiScrollBar *sb) +inline SDL_Rect UpArrowRect(const UiScrollbar *sb) { SDL_Rect Tmp; Tmp.x = sb->m_rect.x; @@ -34,7 +34,7 @@ inline SDL_Rect UpArrowRect(const UiScrollBar *sb) return Tmp; } -inline SDL_Rect DownArrowRect(const UiScrollBar *sb) +inline SDL_Rect DownArrowRect(const UiScrollbar *sb) { SDL_Rect Tmp; Tmp.x = sb->m_rect.x; @@ -45,12 +45,12 @@ inline SDL_Rect DownArrowRect(const UiScrollBar *sb) return Tmp; } -inline Uint16 BarHeight(const UiScrollBar *sb) +inline Uint16 BarHeight(const UiScrollbar *sb) { return sb->m_rect.h - 2 * sb->m_arrow->h(); } -inline SDL_Rect BarRect(const UiScrollBar *sb) +inline SDL_Rect BarRect(const UiScrollbar *sb) { SDL_Rect Tmp; Tmp.x = sb->m_rect.x; @@ -61,7 +61,7 @@ inline SDL_Rect BarRect(const UiScrollBar *sb) return Tmp; } -inline SDL_Rect ThumbRect(const UiScrollBar *sb, std::size_t selected_index, std::size_t num_items) +inline SDL_Rect ThumbRect(const UiScrollbar *sb, std::size_t selected_index, std::size_t num_items) { const int THUMB_OFFSET_X = 3; const int thumb_max_y = BarHeight(sb) - sb->m_thumb->h(); diff --git a/Source/DiabloUI/selconn.cpp b/Source/DiabloUI/selconn.cpp index 9749113bb27..c8af62f2462 100644 --- a/Source/DiabloUI/selconn.cpp +++ b/Source/DiabloUI/selconn.cpp @@ -45,7 +45,7 @@ void SelconnLoad() UiAddLogo(&vecSelConnDlg); SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 24), (Sint16)(Sint16)(UI_OFFSET_Y + 161), 590, 35 }; - vecSelConnDlg.push_back(std::make_unique(_("Multi Player Game"), rect1, UIS_CENTER | UIS_BIG)); + vecSelConnDlg.push_back(std::make_unique(_("Multi Player Game"), rect1, UiFlags::AlignCenter | UiFlags::FontBig)); SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 35), (Sint16)(UI_OFFSET_Y + 218), DESCRIPTION_WIDTH, 21 }; vecSelConnDlg.push_back(std::make_unique(selconn_MaxPlayers, rect2)); @@ -57,24 +57,24 @@ void SelconnLoad() vecSelConnDlg.push_back(std::make_unique(selconn_Description, rect4)); SDL_Rect rect5 = { (Sint16)(PANEL_LEFT + 30), (Sint16)(UI_OFFSET_Y + 356), 220, 31 }; - vecSelConnDlg.push_back(std::make_unique(_("no gateway needed"), rect5, UIS_CENTER | UIS_MED)); + vecSelConnDlg.push_back(std::make_unique(_("no gateway needed"), rect5, UiFlags::AlignCenter | UiFlags::FontMedium)); SDL_Rect rect6 = { (Sint16)(PANEL_LEFT + 35), (Sint16)(UI_OFFSET_Y + 393), DESCRIPTION_WIDTH, 21 }; - vecSelConnDlg.push_back(std::make_unique(selconn_Gateway, rect6, UIS_CENTER)); + vecSelConnDlg.push_back(std::make_unique(selconn_Gateway, rect6, UiFlags::AlignCenter)); SDL_Rect rect7 = { (Sint16)(PANEL_LEFT + 300), (Sint16)(UI_OFFSET_Y + 211), 295, 33 }; - vecSelConnDlg.push_back(std::make_unique(_("Select Connection"), rect7, UIS_CENTER | UIS_BIG)); + vecSelConnDlg.push_back(std::make_unique(_("Select Connection"), rect7, UiFlags::AlignCenter | UiFlags::FontBig)); SDL_Rect rect8 = { (Sint16)(PANEL_LEFT + 16), (Sint16)(UI_OFFSET_Y + 427), 250, 35 }; - vecSelConnDlg.push_back(std::make_unique(_("Change Gateway"), nullptr, rect8, UIS_CENTER | UIS_VCENTER | UIS_BIG | UIS_GOLD | UIS_HIDDEN)); + vecSelConnDlg.push_back(std::make_unique(_("Change Gateway"), nullptr, rect8, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::FontBig | UiFlags::ColorGold | UiFlags::ElementHidden)); - vecSelConnDlg.push_back(std::make_unique(vecConnItems, PANEL_LEFT + 305, (UI_OFFSET_Y + 256), 285, 26, UIS_CENTER | UIS_VCENTER | UIS_GOLD)); + vecSelConnDlg.push_back(std::make_unique(vecConnItems, PANEL_LEFT + 305, (UI_OFFSET_Y + 256), 285, 26, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::ColorGold)); SDL_Rect rect9 = { (Sint16)(PANEL_LEFT + 299), (Sint16)(UI_OFFSET_Y + 427), 140, 35 }; - vecSelConnDlg.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect9, UIS_CENTER | UIS_VCENTER | UIS_BIG | UIS_GOLD)); + vecSelConnDlg.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect9, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::FontBig | UiFlags::ColorGold)); SDL_Rect rect10 = { (Sint16)(PANEL_LEFT + 454), (Sint16)(UI_OFFSET_Y + 427), 140, 35 }; - vecSelConnDlg.push_back(std::make_unique(_("Cancel"), &UiFocusNavigationEsc, rect10, UIS_CENTER | UIS_VCENTER | UIS_BIG | UIS_GOLD)); + vecSelConnDlg.push_back(std::make_unique(_("Cancel"), &UiFocusNavigationEsc, rect10, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::FontBig | UiFlags::ColorGold)); UiInitList(vecConnItems.size(), SelconnFocus, SelconnSelect, SelconnEsc, vecSelConnDlg); } diff --git a/Source/DiabloUI/selgame.cpp b/Source/DiabloUI/selgame.cpp index 994aa1ccbea..b2f72909790 100644 --- a/Source/DiabloUI/selgame.cpp +++ b/Source/DiabloUI/selgame.cpp @@ -75,27 +75,27 @@ void selgame_GameSelection_Init() UiAddLogo(&vecSelGameDialog); SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 24), (Sint16)(UI_OFFSET_Y + 161), 590, 35 }; - vecSelGameDialog.push_back(std::make_unique(_("Client-Server (TCP)"), rect1, UIS_CENTER | UIS_BIG)); + vecSelGameDialog.push_back(std::make_unique(_("Client-Server (TCP)"), rect1, UiFlags::AlignCenter | UiFlags::FontBig)); SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 35), (Sint16)(UI_OFFSET_Y + 211), 205, 192 }; - vecSelGameDialog.push_back(std::make_unique(_("Description:"), rect2, UIS_MED)); + vecSelGameDialog.push_back(std::make_unique(_("Description:"), rect2, UiFlags::FontMedium)); SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 35), (Sint16)(UI_OFFSET_Y + 256), DESCRIPTION_WIDTH, 192 }; vecSelGameDialog.push_back(std::make_unique(selgame_Description, rect3)); SDL_Rect rect4 = { (Sint16)(PANEL_LEFT + 300), (Sint16)(UI_OFFSET_Y + 211), 295, 33 }; - vecSelGameDialog.push_back(std::make_unique(_("Select Action"), rect4, UIS_CENTER | UIS_BIG)); + vecSelGameDialog.push_back(std::make_unique(_("Select Action"), rect4, UiFlags::AlignCenter | UiFlags::FontBig)); vecSelGameDlgItems.push_back(std::make_unique(_("Create Game"), 0)); vecSelGameDlgItems.push_back(std::make_unique(_("Join Game"), 1)); - vecSelGameDialog.push_back(std::make_unique(vecSelGameDlgItems, PANEL_LEFT + 305, (UI_OFFSET_Y + 255), 285, 26, UIS_CENTER | UIS_MED | UIS_GOLD)); + vecSelGameDialog.push_back(std::make_unique(vecSelGameDlgItems, PANEL_LEFT + 305, (UI_OFFSET_Y + 255), 285, 26, UiFlags::AlignCenter | UiFlags::FontMedium | UiFlags::ColorGold)); SDL_Rect rect5 = { (Sint16)(PANEL_LEFT + 299), (Sint16)(UI_OFFSET_Y + 427), 140, 35 }; - vecSelGameDialog.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect5, UIS_CENTER | UIS_VCENTER | UIS_BIG | UIS_GOLD)); + vecSelGameDialog.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect5, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::FontBig | UiFlags::ColorGold)); SDL_Rect rect6 = { (Sint16)(PANEL_LEFT + 449), (Sint16)(UI_OFFSET_Y + 427), 140, 35 }; - vecSelGameDialog.push_back(std::make_unique(_("CANCEL"), &UiFocusNavigationEsc, rect6, UIS_CENTER | UIS_VCENTER | UIS_BIG | UIS_GOLD)); + vecSelGameDialog.push_back(std::make_unique(_("CANCEL"), &UiFocusNavigationEsc, rect6, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::FontBig | UiFlags::ColorGold)); UiInitList(vecSelGameDlgItems.size(), selgame_GameSelection_Focus, selgame_GameSelection_Select, selgame_GameSelection_Esc, vecSelGameDialog); } @@ -139,10 +139,10 @@ void selgame_GameSelection_Select(int value) UiAddLogo(&vecSelGameDialog); SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 24), (Sint16)(UI_OFFSET_Y + 161), 590, 35 }; - vecSelGameDialog.push_back(std::make_unique(&title, rect1, UIS_CENTER | UIS_BIG)); + vecSelGameDialog.push_back(std::make_unique(&title, rect1, UiFlags::AlignCenter | UiFlags::FontBig)); SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 34), (Sint16)(UI_OFFSET_Y + 211), 205, 33 }; - vecSelGameDialog.push_back(std::make_unique(selgame_Label, rect2, UIS_CENTER | UIS_BIG)); + vecSelGameDialog.push_back(std::make_unique(selgame_Label, rect2, UiFlags::AlignCenter | UiFlags::FontBig)); SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 35), (Sint16)(UI_OFFSET_Y + 256), DESCRIPTION_WIDTH, 192 }; vecSelGameDialog.push_back(std::make_unique(selgame_Description, rect3)); @@ -152,19 +152,19 @@ void selgame_GameSelection_Select(int value) title = _("Create Game"); SDL_Rect rect4 = { (Sint16)(PANEL_LEFT + 299), (Sint16)(UI_OFFSET_Y + 211), 295, 35 }; - vecSelGameDialog.push_back(std::make_unique(_("Select Difficulty"), rect4, UIS_CENTER | UIS_BIG)); + vecSelGameDialog.push_back(std::make_unique(_("Select Difficulty"), rect4, UiFlags::AlignCenter | UiFlags::FontBig)); vecSelGameDlgItems.push_back(std::make_unique(_("Normal"), DIFF_NORMAL)); vecSelGameDlgItems.push_back(std::make_unique(_("Nightmare"), DIFF_NIGHTMARE)); vecSelGameDlgItems.push_back(std::make_unique(_("Hell"), DIFF_HELL)); - vecSelGameDialog.push_back(std::make_unique(vecSelGameDlgItems, PANEL_LEFT + 300, (UI_OFFSET_Y + 282), 295, 26, UIS_CENTER | UIS_MED | UIS_GOLD)); + vecSelGameDialog.push_back(std::make_unique(vecSelGameDlgItems, PANEL_LEFT + 300, (UI_OFFSET_Y + 282), 295, 26, UiFlags::AlignCenter | UiFlags::FontMedium | UiFlags::ColorGold)); SDL_Rect rect5 = { (Sint16)(PANEL_LEFT + 299), (Sint16)(UI_OFFSET_Y + 427), 140, 35 }; - vecSelGameDialog.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect5, UIS_CENTER | UIS_VCENTER | UIS_BIG | UIS_GOLD)); + vecSelGameDialog.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect5, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::FontBig | UiFlags::ColorGold)); SDL_Rect rect6 = { (Sint16)(PANEL_LEFT + 449), (Sint16)(UI_OFFSET_Y + 427), 140, 35 }; - vecSelGameDialog.push_back(std::make_unique(_("CANCEL"), &UiFocusNavigationEsc, rect6, UIS_CENTER | UIS_VCENTER | UIS_BIG | UIS_GOLD)); + vecSelGameDialog.push_back(std::make_unique(_("CANCEL"), &UiFocusNavigationEsc, rect6, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::FontBig | UiFlags::ColorGold)); UiInitList(vecSelGameDlgItems.size(), selgame_Diff_Focus, selgame_Diff_Select, selgame_Diff_Esc, vecSelGameDialog, true); break; @@ -173,16 +173,16 @@ void selgame_GameSelection_Select(int value) title = _("Join TCP Games"); SDL_Rect rect4 = { (Sint16)(PANEL_LEFT + 305), (Sint16)(UI_OFFSET_Y + 211), 285, 33 }; - vecSelGameDialog.push_back(std::make_unique(_("Enter address"), rect4, UIS_CENTER | UIS_BIG)); + vecSelGameDialog.push_back(std::make_unique(_("Enter address"), rect4, UiFlags::AlignCenter | UiFlags::FontBig)); SDL_Rect rect5 = { (Sint16)(PANEL_LEFT + 305), (Sint16)(UI_OFFSET_Y + 314), 285, 33 }; - vecSelGameDialog.push_back(std::make_unique(_("Enter address"), selgame_Ip, 128, rect5, UIS_MED | UIS_GOLD)); + vecSelGameDialog.push_back(std::make_unique(_("Enter address"), selgame_Ip, 128, rect5, UiFlags::FontMedium | UiFlags::ColorGold)); SDL_Rect rect6 = { (Sint16)(PANEL_LEFT + 299), (Sint16)(UI_OFFSET_Y + 427), 140, 35 }; - vecSelGameDialog.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect6, UIS_CENTER | UIS_VCENTER | UIS_BIG | UIS_GOLD)); + vecSelGameDialog.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect6, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::FontBig | UiFlags::ColorGold)); SDL_Rect rect7 = { (Sint16)(PANEL_LEFT + 449), (Sint16)(UI_OFFSET_Y + 427), 140, 35 }; - vecSelGameDialog.push_back(std::make_unique(_("CANCEL"), &UiFocusNavigationEsc, rect7, UIS_CENTER | UIS_VCENTER | UIS_BIG | UIS_GOLD)); + vecSelGameDialog.push_back(std::make_unique(_("CANCEL"), &UiFocusNavigationEsc, rect7, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::FontBig | UiFlags::ColorGold)); UiInitList(0, nullptr, selgame_Password_Init, selgame_GameSelection_Init, vecSelGameDialog); break; @@ -293,29 +293,29 @@ void selgame_GameSpeedSelection() UiAddLogo(&vecSelGameDialog); SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 24), (Sint16)(UI_OFFSET_Y + 161), 590, 35 }; - vecSelGameDialog.push_back(std::make_unique(_("Create Game"), rect1, UIS_CENTER | UIS_BIG)); + vecSelGameDialog.push_back(std::make_unique(_("Create Game"), rect1, UiFlags::AlignCenter | UiFlags::FontBig)); SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 34), (Sint16)(UI_OFFSET_Y + 211), 205, 33 }; - vecSelGameDialog.push_back(std::make_unique(selgame_Label, rect2, UIS_CENTER | UIS_BIG)); + vecSelGameDialog.push_back(std::make_unique(selgame_Label, rect2, UiFlags::AlignCenter | UiFlags::FontBig)); SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 35), (Sint16)(UI_OFFSET_Y + 256), DESCRIPTION_WIDTH, 192 }; vecSelGameDialog.push_back(std::make_unique(selgame_Description, rect3)); SDL_Rect rect4 = { (Sint16)(PANEL_LEFT + 299), (Sint16)(UI_OFFSET_Y + 211), 295, 35 }; - vecSelGameDialog.push_back(std::make_unique(_("Select Game Speed"), rect4, UIS_CENTER | UIS_BIG)); + vecSelGameDialog.push_back(std::make_unique(_("Select Game Speed"), rect4, UiFlags::AlignCenter | UiFlags::FontBig)); vecSelGameDlgItems.push_back(std::make_unique(_("Normal"), 20)); vecSelGameDlgItems.push_back(std::make_unique(_("Fast"), 30)); vecSelGameDlgItems.push_back(std::make_unique(_("Faster"), 40)); vecSelGameDlgItems.push_back(std::make_unique(_("Fastest"), 50)); - vecSelGameDialog.push_back(std::make_unique(vecSelGameDlgItems, PANEL_LEFT + 300, (UI_OFFSET_Y + 279), 295, 26, UIS_CENTER | UIS_MED | UIS_GOLD)); + vecSelGameDialog.push_back(std::make_unique(vecSelGameDlgItems, PANEL_LEFT + 300, (UI_OFFSET_Y + 279), 295, 26, UiFlags::AlignCenter | UiFlags::FontMedium | UiFlags::ColorGold)); SDL_Rect rect5 = { (Sint16)(PANEL_LEFT + 299), (Sint16)(UI_OFFSET_Y + 427), 140, 35 }; - vecSelGameDialog.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect5, UIS_CENTER | UIS_VCENTER | UIS_BIG | UIS_GOLD)); + vecSelGameDialog.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect5, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::FontBig | UiFlags::ColorGold)); SDL_Rect rect6 = { (Sint16)(PANEL_LEFT + 449), (Sint16)(UI_OFFSET_Y + 427), 140, 35 }; - vecSelGameDialog.push_back(std::make_unique(_("CANCEL"), &UiFocusNavigationEsc, rect6, UIS_CENTER | UIS_VCENTER | UIS_BIG | UIS_GOLD)); + vecSelGameDialog.push_back(std::make_unique(_("CANCEL"), &UiFocusNavigationEsc, rect6, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::FontBig | UiFlags::ColorGold)); UiInitList(vecSelGameDlgItems.size(), selgame_Speed_Focus, selgame_Speed_Select, selgame_Speed_Esc, vecSelGameDialog, true); } @@ -370,25 +370,25 @@ void selgame_Password_Init(int /*value*/) UiAddLogo(&vecSelGameDialog); SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 24), (Sint16)(UI_OFFSET_Y + 161), 590, 35 }; - vecSelGameDialog.push_back(std::make_unique(_("Client-Server (TCP)"), rect1, UIS_CENTER | UIS_BIG)); + vecSelGameDialog.push_back(std::make_unique(_("Client-Server (TCP)"), rect1, UiFlags::AlignCenter | UiFlags::FontBig)); SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 35), (Sint16)(UI_OFFSET_Y + 211), 205, 192 }; - vecSelGameDialog.push_back(std::make_unique(_("Description:"), rect2, UIS_MED)); + vecSelGameDialog.push_back(std::make_unique(_("Description:"), rect2, UiFlags::FontMedium)); SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 35), (Sint16)(UI_OFFSET_Y + 256), DESCRIPTION_WIDTH, 192 }; vecSelGameDialog.push_back(std::make_unique(selgame_Description, rect3)); SDL_Rect rect4 = { (Sint16)(PANEL_LEFT + 305), (Sint16)(UI_OFFSET_Y + 211), 285, 33 }; - vecSelGameDialog.push_back(std::make_unique(_("Enter Password"), rect4, UIS_CENTER | UIS_BIG)); + vecSelGameDialog.push_back(std::make_unique(_("Enter Password"), rect4, UiFlags::AlignCenter | UiFlags::FontBig)); SDL_Rect rect5 = { (Sint16)(PANEL_LEFT + 305), (Sint16)(UI_OFFSET_Y + 314), 285, 33 }; - vecSelGameDialog.push_back(std::make_unique(_("Enter Password"), selgame_Password, 15, rect5, UIS_MED | UIS_GOLD)); + vecSelGameDialog.push_back(std::make_unique(_("Enter Password"), selgame_Password, 15, rect5, UiFlags::FontMedium | UiFlags::ColorGold)); SDL_Rect rect6 = { (Sint16)(PANEL_LEFT + 299), (Sint16)(UI_OFFSET_Y + 427), 140, 35 }; - vecSelGameDialog.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect6, UIS_CENTER | UIS_VCENTER | UIS_BIG | UIS_GOLD)); + vecSelGameDialog.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect6, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::FontBig | UiFlags::ColorGold)); SDL_Rect rect7 = { (Sint16)(PANEL_LEFT + 449), (Sint16)(UI_OFFSET_Y + 427), 140, 35 }; - vecSelGameDialog.push_back(std::make_unique(_("CANCEL"), &UiFocusNavigationEsc, rect7, UIS_CENTER | UIS_VCENTER | UIS_BIG | UIS_GOLD)); + vecSelGameDialog.push_back(std::make_unique(_("CANCEL"), &UiFocusNavigationEsc, rect7, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::FontBig | UiFlags::ColorGold)); UiInitList(0, nullptr, selgame_Password_Select, selgame_Password_Esc, vecSelGameDialog); } diff --git a/Source/DiabloUI/selhero.cpp b/Source/DiabloUI/selhero.cpp index 564d434174f..35545e1a0e3 100644 --- a/Source/DiabloUI/selhero.cpp +++ b/Source/DiabloUI/selhero.cpp @@ -127,11 +127,11 @@ void SelheroListFocus(int value) { const auto index = static_cast(value); SelheroScrollIntoView(index); - int baseFlags = UIS_CENTER | UIS_BIG; + UiFlags baseFlags = UiFlags::AlignCenter | UiFlags::FontBig; if (selhero_SaveCount != 0 && index < selhero_SaveCount) { memcpy(&selhero_heroInfo, &selhero_heros[index], sizeof(selhero_heroInfo)); SelheroSetStats(); - SELLIST_DIALOG_DELETE_BUTTON->m_iFlags = baseFlags | UIS_GOLD; + SELLIST_DIALOG_DELETE_BUTTON->m_iFlags = baseFlags | UiFlags::ColorGold; selhero_deleteEnabled = true; return; } @@ -143,7 +143,7 @@ void SelheroListFocus(int value) strncpy(textStats[3], "--", sizeof(textStats[3]) - 1); strncpy(textStats[4], "--", sizeof(textStats[4]) - 1); strncpy(textStats[5], "--", sizeof(textStats[5]) - 1); - SELLIST_DIALOG_DELETE_BUTTON->m_iFlags = baseFlags | UIS_DISABLED; + SELLIST_DIALOG_DELETE_BUTTON->m_iFlags = baseFlags | UiFlags::ElementDisabled; selhero_deleteEnabled = false; } @@ -160,7 +160,7 @@ void SelheroListSelect(int value) vecSelDlgItems.clear(); SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 264), (Sint16)(UI_OFFSET_Y + 211), 320, 33 }; - vecSelDlgItems.push_back(std::make_unique(_("Choose Class"), rect1, UIS_CENTER | UIS_BIG)); + vecSelDlgItems.push_back(std::make_unique(_("Choose Class"), rect1, UiFlags::AlignCenter | UiFlags::FontBig)); vecSelHeroDlgItems.clear(); int itemH = 33; @@ -179,13 +179,13 @@ void SelheroListSelect(int value) if (vecSelHeroDlgItems.size() > 4) itemH = 26; int itemY = 246 + (176 - vecSelHeroDlgItems.size() * itemH) / 2; - vecSelDlgItems.push_back(std::make_unique(vecSelHeroDlgItems, PANEL_LEFT + 264, (UI_OFFSET_Y + itemY), 320, itemH, UIS_CENTER | UIS_MED | UIS_GOLD)); + vecSelDlgItems.push_back(std::make_unique(vecSelHeroDlgItems, PANEL_LEFT + 264, (UI_OFFSET_Y + itemY), 320, itemH, UiFlags::AlignCenter | UiFlags::FontMedium | UiFlags::ColorGold)); SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 279), (Sint16)(UI_OFFSET_Y + 429), 140, 35 }; - vecSelDlgItems.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect2, UIS_CENTER | UIS_BIG | UIS_GOLD)); + vecSelDlgItems.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect2, UiFlags::AlignCenter | UiFlags::FontBig | UiFlags::ColorGold)); SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 429), (Sint16)(UI_OFFSET_Y + 429), 140, 35 }; - vecSelDlgItems.push_back(std::make_unique(_("Cancel"), &UiFocusNavigationEsc, rect3, UIS_CENTER | UIS_BIG | UIS_GOLD)); + vecSelDlgItems.push_back(std::make_unique(_("Cancel"), &UiFocusNavigationEsc, rect3, UiFlags::AlignCenter | UiFlags::FontBig | UiFlags::ColorGold)); UiInitList(vecSelHeroDlgItems.size(), SelheroClassSelectorFocus, SelheroClassSelectorSelect, SelheroClassSelectorEsc, vecSelDlgItems); memset(&selhero_heroInfo.name, 0, sizeof(selhero_heroInfo.name)); @@ -198,18 +198,18 @@ void SelheroListSelect(int value) vecSelDlgItems.clear(); SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 264), (Sint16)(UI_OFFSET_Y + 211), 320, 33 }; - vecSelDlgItems.push_back(std::make_unique(_("Save File Exists"), rect1, UIS_CENTER | UIS_BIG)); + vecSelDlgItems.push_back(std::make_unique(_("Save File Exists"), rect1, UiFlags::AlignCenter | UiFlags::FontBig)); vecSelHeroDlgItems.clear(); vecSelHeroDlgItems.push_back(std::make_unique(_("Load Game"), 0)); vecSelHeroDlgItems.push_back(std::make_unique(_("New Game"), 1)); - vecSelDlgItems.push_back(std::make_unique(vecSelHeroDlgItems, PANEL_LEFT + 265, (UI_OFFSET_Y + 285), 320, 33, UIS_CENTER | UIS_MED | UIS_GOLD)); + vecSelDlgItems.push_back(std::make_unique(vecSelHeroDlgItems, PANEL_LEFT + 265, (UI_OFFSET_Y + 285), 320, 33, UiFlags::AlignCenter | UiFlags::FontMedium | UiFlags::ColorGold)); SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 279), (Sint16)(UI_OFFSET_Y + 427), 140, 35 }; - vecSelDlgItems.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect2, UIS_CENTER | UIS_VCENTER | UIS_BIG | UIS_GOLD)); + vecSelDlgItems.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect2, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::FontBig | UiFlags::ColorGold)); SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 429), (Sint16)(UI_OFFSET_Y + 427), 140, 35 }; - vecSelDlgItems.push_back(std::make_unique(_("Cancel"), &UiFocusNavigationEsc, rect3, UIS_CENTER | UIS_VCENTER | UIS_BIG | UIS_GOLD)); + vecSelDlgItems.push_back(std::make_unique(_("Cancel"), &UiFocusNavigationEsc, rect3, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::FontBig | UiFlags::ColorGold)); UiInitList(vecSelHeroDlgItems.size(), SelheroLoadFocus, SelheroLoadSelect, selhero_List_Init, vecSelDlgItems, true); title = _("Single Player Characters"); @@ -270,16 +270,16 @@ void SelheroClassSelectorSelect(int value) strncpy(selhero_heroInfo.name, SelheroGenerateName(selhero_heroInfo.heroclass), sizeof(selhero_heroInfo.name) - 1); vecSelDlgItems.clear(); SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 264), (Sint16)(UI_OFFSET_Y + 211), 320, 33 }; - vecSelDlgItems.push_back(std::make_unique(_("Enter Name"), rect1, UIS_CENTER | UIS_BIG)); + vecSelDlgItems.push_back(std::make_unique(_("Enter Name"), rect1, UiFlags::AlignCenter | UiFlags::FontBig)); SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 265), (Sint16)(UI_OFFSET_Y + 317), 320, 33 }; - vecSelDlgItems.push_back(std::make_unique(_("Enter Name"), selhero_heroInfo.name, 15, rect2, UIS_MED | UIS_GOLD)); + vecSelDlgItems.push_back(std::make_unique(_("Enter Name"), selhero_heroInfo.name, 15, rect2, UiFlags::FontMedium | UiFlags::ColorGold)); SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 279), (Sint16)(UI_OFFSET_Y + 429), 140, 35 }; - vecSelDlgItems.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect3, UIS_CENTER | UIS_BIG | UIS_GOLD)); + vecSelDlgItems.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect3, UiFlags::AlignCenter | UiFlags::FontBig | UiFlags::ColorGold)); SDL_Rect rect4 = { (Sint16)(PANEL_LEFT + 429), (Sint16)(UI_OFFSET_Y + 429), 140, 35 }; - vecSelDlgItems.push_back(std::make_unique(_("Cancel"), &UiFocusNavigationEsc, rect4, UIS_CENTER | UIS_BIG | UIS_GOLD)); + vecSelDlgItems.push_back(std::make_unique(_("Cancel"), &UiFocusNavigationEsc, rect4, UiFlags::AlignCenter | UiFlags::FontBig | UiFlags::ColorGold)); UiInitList(0, nullptr, SelheroNameSelect, SelheroNameEsc, vecSelDlgItems); } @@ -454,46 +454,46 @@ void selhero_Init() vecSelDlgItems.clear(); SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 24), (Sint16)(UI_OFFSET_Y + 161), 590, 35 }; - vecSelHeroDialog.push_back(std::make_unique(&title, rect1, UIS_CENTER | UIS_BIG)); + vecSelHeroDialog.push_back(std::make_unique(&title, rect1, UiFlags::AlignCenter | UiFlags::FontBig)); SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 30), (Sint16)(UI_OFFSET_Y + 211), 180, 76 }; - auto heroImg = std::make_unique(&ArtHero, static_cast(enum_size::value), rect2); + auto heroImg = std::make_unique(&ArtHero, rect2, UiFlags::None, /*bAnimated=*/false, static_cast(enum_size::value)); SELHERO_DIALOG_HERO_IMG = heroImg.get(); vecSelHeroDialog.push_back(std::move(heroImg)); SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 39), (Sint16)(UI_OFFSET_Y + 323), 110, 21 }; - vecSelHeroDialog.push_back(std::make_unique(_("Level:"), rect3, UIS_RIGHT)); + vecSelHeroDialog.push_back(std::make_unique(_("Level:"), rect3, UiFlags::AlignRight)); SDL_Rect rect4 = { (Sint16)(PANEL_LEFT + 39), (Sint16)(UI_OFFSET_Y + 323), 110, 21 }; - vecSelHeroDialog.push_back(std::make_unique(_("Level:"), rect4, UIS_RIGHT)); + vecSelHeroDialog.push_back(std::make_unique(_("Level:"), rect4, UiFlags::AlignRight)); SDL_Rect rect5 = { (Sint16)(PANEL_LEFT + 159), (Sint16)(UI_OFFSET_Y + 323), 40, 21 }; - vecSelHeroDialog.push_back(std::make_unique(textStats[0], rect5, UIS_CENTER)); + vecSelHeroDialog.push_back(std::make_unique(textStats[0], rect5, UiFlags::AlignCenter)); SDL_Rect rect6 = { (Sint16)(PANEL_LEFT + 39), (Sint16)(UI_OFFSET_Y + 358), 110, 21 }; - vecSelHeroDialog.push_back(std::make_unique(_("Strength:"), rect6, UIS_RIGHT)); + vecSelHeroDialog.push_back(std::make_unique(_("Strength:"), rect6, UiFlags::AlignRight)); SDL_Rect rect7 = { (Sint16)(PANEL_LEFT + 159), (Sint16)(UI_OFFSET_Y + 358), 40, 21 }; - vecSelHeroDialog.push_back(std::make_unique(textStats[1], rect7, UIS_CENTER)); + vecSelHeroDialog.push_back(std::make_unique(textStats[1], rect7, UiFlags::AlignCenter)); SDL_Rect rect8 = { (Sint16)(PANEL_LEFT + 39), (Sint16)(UI_OFFSET_Y + 380), 110, 21 }; - vecSelHeroDialog.push_back(std::make_unique(_("Magic:"), rect8, UIS_RIGHT)); + vecSelHeroDialog.push_back(std::make_unique(_("Magic:"), rect8, UiFlags::AlignRight)); SDL_Rect rect9 = { (Sint16)(PANEL_LEFT + 159), (Sint16)(UI_OFFSET_Y + 380), 40, 21 }; - vecSelHeroDialog.push_back(std::make_unique(textStats[2], rect9, UIS_CENTER)); + vecSelHeroDialog.push_back(std::make_unique(textStats[2], rect9, UiFlags::AlignCenter)); SDL_Rect rect10 = { (Sint16)(PANEL_LEFT + 39), (Sint16)(UI_OFFSET_Y + 401), 110, 21 }; - vecSelHeroDialog.push_back(std::make_unique(_("Dexterity:"), rect10, UIS_RIGHT)); + vecSelHeroDialog.push_back(std::make_unique(_("Dexterity:"), rect10, UiFlags::AlignRight)); SDL_Rect rect11 = { (Sint16)(PANEL_LEFT + 159), (Sint16)(UI_OFFSET_Y + 401), 40, 21 }; - vecSelHeroDialog.push_back(std::make_unique(textStats[3], rect11, UIS_CENTER)); + vecSelHeroDialog.push_back(std::make_unique(textStats[3], rect11, UiFlags::AlignCenter)); SDL_Rect rect12 = { (Sint16)(PANEL_LEFT + 39), (Sint16)(UI_OFFSET_Y + 422), 110, 21 }; - vecSelHeroDialog.push_back(std::make_unique(_("Vitality:"), rect12, UIS_RIGHT)); + vecSelHeroDialog.push_back(std::make_unique(_("Vitality:"), rect12, UiFlags::AlignRight)); SDL_Rect rect13 = { (Sint16)(PANEL_LEFT + 159), (Sint16)(UI_OFFSET_Y + 422), 40, 21 }; - vecSelHeroDialog.push_back(std::make_unique(textStats[4], rect13, UIS_CENTER)); + vecSelHeroDialog.push_back(std::make_unique(textStats[4], rect13, UiFlags::AlignCenter)); #if _DEBUG SDL_Rect rect14 = { (Sint16)(PANEL_LEFT + 39), (Sint16)(UI_OFFSET_Y + 443), 110, 21 }; - vecSelHeroDialog.push_back(std::make_unique(_("Savegame:"), rect14, UIS_RIGHT)); + vecSelHeroDialog.push_back(std::make_unique(_("Savegame:"), rect14, UiFlags::AlignRight)); SDL_Rect rect15 = { (Sint16)(PANEL_LEFT + 159), (Sint16)(UI_OFFSET_Y + 443), 40, 21 }; - vecSelHeroDialog.push_back(std::make_unique(textStats[5], rect15, UIS_CENTER)); + vecSelHeroDialog.push_back(std::make_unique(textStats[5], rect15, UiFlags::AlignCenter)); #endif } @@ -503,7 +503,7 @@ void selhero_List_Init() vecSelDlgItems.clear(); SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 264), (Sint16)(UI_OFFSET_Y + 211), 320, 33 }; - vecSelDlgItems.push_back(std::make_unique(_("Select Hero"), rect1, UIS_CENTER | UIS_BIG)); + vecSelDlgItems.push_back(std::make_unique(_("Select Hero"), rect1, UiFlags::AlignCenter | UiFlags::FontBig)); vecSelHeroDlgItems.clear(); const size_t numViewportHeroes = std::min(selhero_SaveCount + 1, MaxViewportItems); @@ -512,23 +512,23 @@ void selhero_List_Init() } SelheroUpdateViewportItems(); - vecSelDlgItems.push_back(std::make_unique(vecSelHeroDlgItems, PANEL_LEFT + 265, (UI_OFFSET_Y + 256), 320, 26, UIS_CENTER | UIS_MED | UIS_GOLD)); + vecSelDlgItems.push_back(std::make_unique(vecSelHeroDlgItems, PANEL_LEFT + 265, (UI_OFFSET_Y + 256), 320, 26, UiFlags::AlignCenter | UiFlags::FontMedium | UiFlags::ColorGold)); SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 585), (Sint16)(UI_OFFSET_Y + 244), 25, 178 }; - auto pinnedScrollBar = std::make_unique(&ArtScrollBarBackground, &ArtScrollBarThumb, &ArtScrollBarArrow, rect2); + auto pinnedScrollBar = std::make_unique(&ArtScrollBarBackground, &ArtScrollBarThumb, &ArtScrollBarArrow, rect2); auto *scrollBar = pinnedScrollBar.get(); vecSelDlgItems.push_back(std::move(pinnedScrollBar)); SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 239), (Sint16)(UI_OFFSET_Y + 429), 120, 35 }; - vecSelDlgItems.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect3, UIS_CENTER | UIS_BIG | UIS_GOLD)); + vecSelDlgItems.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect3, UiFlags::AlignCenter | UiFlags::FontBig | UiFlags::ColorGold)); SDL_Rect rect4 = { (Sint16)(PANEL_LEFT + 364), (Sint16)(UI_OFFSET_Y + 429), 120, 35 }; - auto setlistDialogDeleteButton = std::make_unique(_("Delete"), &SelheroUiFocusNavigationYesNo, rect4, UIS_CENTER | UIS_BIG | UIS_DISABLED); + auto setlistDialogDeleteButton = std::make_unique(_("Delete"), &SelheroUiFocusNavigationYesNo, rect4, UiFlags::AlignCenter | UiFlags::FontBig | UiFlags::ElementDisabled); SELLIST_DIALOG_DELETE_BUTTON = setlistDialogDeleteButton.get(); vecSelDlgItems.push_back(std::move(setlistDialogDeleteButton)); SDL_Rect rect5 = { (Sint16)(PANEL_LEFT + 489), (Sint16)(UI_OFFSET_Y + 429), 120, 35 }; - vecSelDlgItems.push_back(std::make_unique(_("Cancel"), &UiFocusNavigationEsc, rect5, UIS_CENTER | UIS_BIG | UIS_GOLD)); + vecSelDlgItems.push_back(std::make_unique(_("Cancel"), &UiFocusNavigationEsc, rect5, UiFlags::AlignCenter | UiFlags::FontBig | UiFlags::ColorGold)); UiInitList(selhero_SaveCount + 1, SelheroListFocus, SelheroListSelect, SelheroListEsc, vecSelDlgItems, false, SelheroListDeleteYesNo); UiInitScrollBar(scrollBar, MaxViewportItems, &listOffset); diff --git a/Source/DiabloUI/selok.cpp b/Source/DiabloUI/selok.cpp index c552a51368c..bfc62f89984 100644 --- a/Source/DiabloUI/selok.cpp +++ b/Source/DiabloUI/selok.cpp @@ -56,17 +56,17 @@ void UiSelOkDialog(const char *title, const char *body, bool background) if (title != nullptr) { SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 24), (Sint16)(UI_OFFSET_Y + 161), 590, 35 }; - vecSelOkDialog.push_back(std::make_unique(title, rect1, UIS_CENTER | UIS_BIG)); + vecSelOkDialog.push_back(std::make_unique(title, rect1, UiFlags::AlignCenter | UiFlags::FontBig)); SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 140), (Sint16)(UI_OFFSET_Y + 210), 560, 168 }; - vecSelOkDialog.push_back(std::make_unique(dialogText, rect2, UIS_MED)); + vecSelOkDialog.push_back(std::make_unique(dialogText, rect2, UiFlags::FontMedium)); } else { SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 140), (Sint16)(UI_OFFSET_Y + 197), 560, 168 }; - vecSelOkDialog.push_back(std::make_unique(dialogText, rect1, UIS_MED)); + vecSelOkDialog.push_back(std::make_unique(dialogText, rect1, UiFlags::FontMedium)); } vecSelOkDialogItems.push_back(std::make_unique(_("OK"), 0)); - vecSelOkDialog.push_back(std::make_unique(vecSelOkDialogItems, PANEL_LEFT + 230, (UI_OFFSET_Y + 390), 180, 35, UIS_CENTER | UIS_BIG | UIS_GOLD)); + vecSelOkDialog.push_back(std::make_unique(vecSelOkDialogItems, PANEL_LEFT + 230, (UI_OFFSET_Y + 390), 180, 35, UiFlags::AlignCenter | UiFlags::FontBig | UiFlags::ColorGold)); strncpy(dialogText, body, sizeof(dialogText) - 1); WordWrapArtStr(dialogText, MESSAGE_WIDTH); diff --git a/Source/DiabloUI/selyesno.cpp b/Source/DiabloUI/selyesno.cpp index 92c15ab18df..1f87ed2c21c 100644 --- a/Source/DiabloUI/selyesno.cpp +++ b/Source/DiabloUI/selyesno.cpp @@ -47,14 +47,14 @@ bool UiSelHeroYesNoDialog(const char *title, const char *body) UiAddLogo(&vecSelYesNoDialog); SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 24), (Sint16)(UI_OFFSET_Y + 161), 590, 35 }; - vecSelYesNoDialog.push_back(std::make_unique(title, rect1, UIS_CENTER | UIS_BIG)); + vecSelYesNoDialog.push_back(std::make_unique(title, rect1, UiFlags::AlignCenter | UiFlags::FontBig)); SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 120), (Sint16)(UI_OFFSET_Y + 236), MESSAGE_WIDTH, 168 }; - vecSelYesNoDialog.push_back(std::make_unique(selyesno_confirmationMessage, rect2, UIS_MED)); + vecSelYesNoDialog.push_back(std::make_unique(selyesno_confirmationMessage, rect2, UiFlags::FontMedium)); vecSelYesNoDialogItems.push_back(std::make_unique(_("Yes"), 0)); vecSelYesNoDialogItems.push_back(std::make_unique(_("No"), 1)); - vecSelYesNoDialog.push_back(std::make_unique(vecSelYesNoDialogItems, PANEL_LEFT + 230, (UI_OFFSET_Y + 390), 180, 35, UIS_CENTER | UIS_BIG | UIS_GOLD)); + vecSelYesNoDialog.push_back(std::make_unique(vecSelYesNoDialogItems, PANEL_LEFT + 230, (UI_OFFSET_Y + 390), 180, 35, UiFlags::AlignCenter | UiFlags::FontBig | UiFlags::ColorGold)); strncpy(selyesno_confirmationMessage, body, sizeof(selyesno_confirmationMessage) - 1); WordWrapArtStr(selyesno_confirmationMessage, MESSAGE_WIDTH); diff --git a/Source/DiabloUI/text_draw.cpp b/Source/DiabloUI/text_draw.cpp index e30840f15c9..3b949a0db32 100644 --- a/Source/DiabloUI/text_draw.cpp +++ b/Source/DiabloUI/text_draw.cpp @@ -12,27 +12,27 @@ namespace devilution { namespace { -TextAlignment XAlignmentFromFlags(int flags) +TextAlignment XAlignmentFromFlags(UiFlags flags) { - if ((flags & UIS_CENTER) != 0) + if (HasAnyOf(flags, UiFlags::AlignCenter)) return TextAlignment_CENTER; - if ((flags & UIS_RIGHT) != 0) + if (HasAnyOf(flags, UiFlags::AlignRight)) return TextAlignment_END; return TextAlignment_BEGIN; } -int AlignXOffset(int flags, const SDL_Rect &dest, int w) +int AlignXOffset(UiFlags flags, const SDL_Rect &dest, int w) { - if ((flags & UIS_CENTER) != 0) + if (HasAnyOf(flags, UiFlags::AlignCenter)) return (dest.w - w) / 2; - if ((flags & UIS_RIGHT) != 0) + if (HasAnyOf(flags, UiFlags::AlignRight)) return dest.w - w; return 0; } } // namespace -void DrawTTF(const char *text, const SDL_Rect &rectIn, int flags, +void DrawTTF(const char *text, const SDL_Rect &rectIn, UiFlags flags, const SDL_Color &textColor, const SDL_Color &shadowColor, TtfSurfaceCache &renderCache) { @@ -54,7 +54,7 @@ void DrawTTF(const char *text, const SDL_Rect &rectIn, int flags, SDL_Rect destRect = rect; ScaleOutputRect(&destRect); destRect.x += AlignXOffset(flags, destRect, textSurface->w); - destRect.y += (flags & UIS_VCENTER) != 0 ? (destRect.h - textSurface->h) / 2 : 0; + destRect.y += HasAnyOf(flags, UiFlags::VerticalCenter) ? (destRect.h - textSurface->h) / 2 : 0; SDL_Rect shadowRect = destRect; ++shadowRect.x; @@ -65,20 +65,20 @@ void DrawTTF(const char *text, const SDL_Rect &rectIn, int flags, ErrSdl(); } -void DrawArtStr(const char *text, const SDL_Rect &rect, int flags, bool drawTextCursor) +void DrawArtStr(const char *text, const SDL_Rect &rect, UiFlags flags, bool drawTextCursor) { _artFontTables size = AFT_SMALL; - _artFontColors color = (flags & UIS_GOLD) != 0 ? AFC_GOLD : AFC_SILVER; + _artFontColors color = HasAnyOf(flags, UiFlags::ColorGold) ? AFC_GOLD : AFC_SILVER; - if ((flags & UIS_MED) != 0) + if (HasAnyOf(flags, UiFlags::FontMedium)) size = AFT_MED; - else if ((flags & UIS_BIG) != 0) + else if (HasAnyOf(flags, UiFlags::FontBig)) size = AFT_BIG; - else if ((flags & UIS_HUGE) != 0) + else if (HasAnyOf(flags, UiFlags::FontHuge)) size = AFT_HUGE; const int x = rect.x + AlignXOffset(flags, rect, GetArtStrWidth(text, size)); - const int y = rect.y + ((flags & UIS_VCENTER) != 0 ? (rect.h - ArtFonts[size][color].h()) / 2 : 0); + const int y = rect.y + (HasAnyOf(flags, UiFlags::VerticalCenter) ? (rect.h - ArtFonts[size][color].h()) / 2 : 0); int sx = x; int sy = y; diff --git a/Source/DiabloUI/text_draw.h b/Source/DiabloUI/text_draw.h index 40e26b5811e..2e946f519ef 100644 --- a/Source/DiabloUI/text_draw.h +++ b/Source/DiabloUI/text_draw.h @@ -11,10 +11,12 @@ struct TtfSurfaceCache { SDLSurfaceUniquePtr shadow; }; -void DrawTTF(const char *text, const SDL_Rect &rect, int flags, +enum class UiFlags; // Defined in ui_item.h, declared here to avoid circular dependency + +void DrawTTF(const char *text, const SDL_Rect &rect, UiFlags flags, const SDL_Color &textColor, const SDL_Color &shadowColor, TtfSurfaceCache &renderCache); -void DrawArtStr(const char *text, const SDL_Rect &rect, int flags, bool drawTextCursor = false); +void DrawArtStr(const char *text, const SDL_Rect &rect, UiFlags flags, bool drawTextCursor = false); } // namespace devilution diff --git a/Source/DiabloUI/title.cpp b/Source/DiabloUI/title.cpp index 43fba3f483a..6d52722b1f0 100644 --- a/Source/DiabloUI/title.cpp +++ b/Source/DiabloUI/title.cpp @@ -34,14 +34,14 @@ void UiTitleDialog() { if (gbIsHellfire) { SDL_Rect rect = { 0, UI_OFFSET_Y, 0, 0 }; - vecTitleScreen.push_back(std::make_unique(&ArtBackgroundWidescreen, /*bAnimated=*/true, /*iFrame=*/0, rect, UIS_CENTER)); - vecTitleScreen.push_back(std::make_unique(&ArtBackground, /*bAnimated=*/true, /*iFrame=*/0, rect, UIS_CENTER)); + vecTitleScreen.push_back(std::make_unique(&ArtBackgroundWidescreen, rect, UiFlags::AlignCenter, /*bAnimated=*/true)); + vecTitleScreen.push_back(std::make_unique(&ArtBackground, rect, UiFlags::AlignCenter, /*bAnimated=*/true)); } else { UiAddBackground(&vecTitleScreen); UiAddLogo(&vecTitleScreen, LOGO_BIG, 182); SDL_Rect rect = { (Sint16)(PANEL_LEFT + 49), (Sint16)(UI_OFFSET_Y + 410), 550, 26 }; - vecTitleScreen.push_back(std::make_unique(_("Copyright © 1996-2001 Blizzard Entertainment"), rect, UIS_MED | UIS_CENTER)); + vecTitleScreen.push_back(std::make_unique(_("Copyright © 1996-2001 Blizzard Entertainment"), rect, UiFlags::FontMedium | UiFlags::AlignCenter)); } TitleLoad(); diff --git a/Source/DiabloUI/ui_item.h b/Source/DiabloUI/ui_item.h index 0a7ba6cad2f..c0194be8eea 100644 --- a/Source/DiabloUI/ui_item.h +++ b/Source/DiabloUI/ui_item.h @@ -11,67 +11,92 @@ namespace devilution { -enum UiType : uint8_t { - UI_TEXT, - UI_ART_TEXT, - UI_ART_TEXT_BUTTON, - UI_IMAGE, - UI_BUTTON, - UI_LIST, - UI_SCROLLBAR, - UI_EDIT, +enum class UiType { + Text, + ArtText, + ArtTextButton, + Image, + Button, + List, + Scrollbar, + Edit, }; -enum UiFlags : uint16_t { +enum class UiFlags { // clang-format off - UIS_SMALL = 1 << 0, - UIS_MED = 1 << 1, - UIS_BIG = 1 << 2, - UIS_HUGE = 1 << 3, - UIS_CENTER = 1 << 4, - UIS_RIGHT = 1 << 5, - UIS_VCENTER = 1 << 6, - UIS_SILVER = 1 << 7, - UIS_GOLD = 1 << 8, - UIS_RED = 1 << 9, - UIS_BLUE = 1 << 10, - UIS_BLACK = 1 << 11, - UIS_DISABLED = 1 << 12, - UIS_HIDDEN = 1 << 13, - UIS_FIT_SPACING = 1 << 14, + None = 0, + FontSmall = 1 << 0, + FontMedium = 1 << 1, + FontBig = 1 << 2, + FontHuge = 1 << 3, + AlignCenter = 1 << 4, + AlignRight = 1 << 5, + VerticalCenter = 1 << 6, + ColorSilver = 1 << 7, + ColorGold = 1 << 8, + ColorRed = 1 << 9, + ColorBlue = 1 << 10, + ColorBlack = 1 << 11, + ElementDisabled = 1 << 12, + ElementHidden = 1 << 13, + KerningFitSpacing = 1 << 14, // clang-format on }; +inline UiFlags operator|(UiFlags lhs, UiFlags rhs) +{ + using T = std::underlying_type_t; + return static_cast(static_cast(lhs) | static_cast(rhs)); +} + +inline UiFlags operator|=(UiFlags &lhs, UiFlags rhs) +{ + lhs = lhs | rhs; + return lhs; +} + +inline UiFlags operator&(UiFlags lhs, UiFlags rhs) +{ + using T = std::underlying_type_t; + return static_cast(static_cast(lhs) & static_cast(rhs)); +} + +inline UiFlags operator&=(UiFlags &lhs, UiFlags rhs) +{ + lhs = lhs & rhs; + return lhs; +} + +inline UiFlags operator~(UiFlags value) +{ + using T = std::underlying_type_t; + return static_cast(~static_cast(value)); +} + +inline bool HasAnyOf(UiFlags lhs, UiFlags test) +{ + return (lhs & test) != UiFlags::None; +} + class UiItemBase { public: - UiItemBase(SDL_Rect rect, int flags) + UiItemBase(UiType type, SDL_Rect rect, UiFlags flags) + : m_type(type) + , m_rect(rect) + , m_iFlags(flags) { - m_rect = rect; - m_iFlags = flags; - }; - - UiItemBase(Sint16 x, Sint16 y, Uint16 item_width, Uint16 item_height, int flags) - { - SDL_Rect tmp; - tmp.x = x; - tmp.y = y; - tmp.w = item_width; - tmp.h = item_height; - - m_rect = tmp; - m_iFlags = flags; - }; + } virtual ~UiItemBase() {}; bool has_flag(UiFlags flag) const { - return m_iFlags & flag; + return (m_iFlags & flag) == flag; } - bool has_any_flag(int flags) const + bool has_any_flag(UiFlags flags) const { - return (m_iFlags & flags) != 0; + return HasAnyOf(m_iFlags, flags); } void add_flag(UiFlags flag) @@ -87,38 +112,19 @@ class UiItemBase { //protected: UiType m_type; SDL_Rect m_rect; - int m_iFlags; + UiFlags m_iFlags; }; //============================================================================= class UiImage : public UiItemBase { public: - UiImage(Art *art, SDL_Rect rect, int flags = 0) - : UiItemBase(rect, flags) + UiImage(Art *art, SDL_Rect rect, UiFlags flags = UiFlags::None, bool animated = false, int frame = 0) + : UiItemBase(UiType::Image, rect, flags) + , m_art(art) + , m_animated(animated) + , m_frame(frame) { - m_type = UI_IMAGE; - m_art = art; - m_animated = false; - m_frame = 0; - }; - - UiImage(Art *art, bool bAnimated, int iFrame, SDL_Rect rect, int flags) - : UiItemBase(rect, flags) - { - m_type = UI_IMAGE; - m_art = art; - m_animated = bAnimated; - m_frame = iFrame; - }; - - UiImage(Art *art, int frame, SDL_Rect rect, int flags = 0) - : UiItemBase(rect, flags) - { - m_type = UI_IMAGE; - m_art = art; - m_animated = false; - m_frame = frame; } ~UiImage() {}; @@ -133,19 +139,29 @@ class UiImage : public UiItemBase { class UiArtText : public UiItemBase { public: - UiArtText(const char *text, SDL_Rect rect, int flags = 0) - : UiItemBase(rect, flags) + /** + * @brief Constructs a UI element containing a (presumed to be) static line of text + * @param text Pointer to the first character of a c-string + * @param rect screen region defining the area to draw the text + * @param flags UiFlags controlling color/alignment/size + */ + UiArtText(const char *text, SDL_Rect rect, UiFlags flags = UiFlags::None) + : UiItemBase(UiType::ArtText, rect, flags) , m_text(text) { - m_type = UI_ART_TEXT; - }; + } - UiArtText(const char **ptext, SDL_Rect rect, int flags = 0) - : UiItemBase(rect, flags) + /** + * @brief Constructs a UI element containing a line of text that may change between frames + * @param ptext Pointer to a c-string (pointer to a pointer to the first character) + * @param rect screen region defining the area to draw the text + * @param flags UiFlags controlling color/alignment/size + */ + UiArtText(const char **ptext, SDL_Rect rect, UiFlags flags = UiFlags::None) + : UiItemBase(UiType::ArtText, rect, flags) , m_ptext(ptext) { - m_type = UI_ART_TEXT; - }; + } const char *text() const { @@ -163,16 +179,15 @@ class UiArtText : public UiItemBase { //============================================================================= -class UiScrollBar : public UiItemBase { +class UiScrollbar : public UiItemBase { public: - UiScrollBar(Art *bg, Art *thumb, Art *arrow, SDL_Rect rect, int flags = 0) - : UiItemBase(rect, flags) + UiScrollbar(Art *bg, Art *thumb, Art *arrow, SDL_Rect rect, UiFlags flags = UiFlags::None) + : UiItemBase(UiType::Scrollbar, rect, flags) + , m_bg(bg) + , m_thumb(thumb) + , m_arrow(arrow) { - m_type = UI_SCROLLBAR; - m_bg = bg; - m_thumb = thumb; - m_arrow = arrow; - }; + } //private: Art *m_bg; @@ -184,13 +199,13 @@ class UiScrollBar : public UiItemBase { class UiArtTextButton : public UiItemBase { public: - UiArtTextButton(const char *text, void (*action)(), SDL_Rect rect, int flags = 0) - : UiItemBase(rect, flags) + UiArtTextButton(const char *text, void (*action)(), SDL_Rect rect, UiFlags flags = UiFlags::None) + : UiItemBase(UiType::ArtTextButton, rect, flags) + , m_text(text) + , m_action(action) { - m_type = UI_ART_TEXT_BUTTON; - m_text = text; - m_action = action; - }; + } + //private: const char *m_text; void (*m_action)(); @@ -200,13 +215,12 @@ class UiArtTextButton : public UiItemBase { class UiEdit : public UiItemBase { public: - UiEdit(const char *hint, char *value, std::size_t max_length, SDL_Rect rect, int flags = 0) - : UiItemBase(rect, flags) + UiEdit(const char *hint, char *value, std::size_t max_length, SDL_Rect rect, UiFlags flags = UiFlags::None) + : UiItemBase(UiType::Edit, rect, flags) + , m_hint(hint) + , m_value(value) + , m_max_length(max_length) { - m_type = UI_EDIT; - m_hint = hint; - m_value = value; - m_max_length = max_length; } //private: @@ -221,30 +235,13 @@ class UiEdit : public UiItemBase { class UiText : public UiItemBase { public: - UiText(const char *text, SDL_Color color1, SDL_Rect rect, int flags = 0) - : UiItemBase(rect, flags) - { - m_type = UI_TEXT; - m_color = color1; - - SDL_Color color2 = { 0, 0, 0, 0 }; - m_shadow_color = color2; - - m_text = text; - } - - UiText(const char *text, SDL_Rect rect, int flags = 0) - : UiItemBase(rect, flags) + UiText(const char *text, SDL_Rect rect, UiFlags flags = UiFlags::None, SDL_Color color = { 243, 243, 243, 0 }) + : UiItemBase(UiType::Text, rect, flags) + , m_color(color) + , m_shadow_color({ 0, 0, 0, 0 }) + , m_text(text) + , m_render_cache() { - m_type = UI_TEXT; - - SDL_Color color1 = { 243, 243, 243, 0 }; - m_color = color1; - - SDL_Color color2 = { 0, 0, 0, 0 }; - m_shadow_color = color2; - - m_text = text; } //private: @@ -262,14 +259,14 @@ class UiText : public UiItemBase { class UiButton : public UiItemBase { public: - UiButton(Art *art, const char *text, void (*action)(), SDL_Rect rect, int flags = 0) - : UiItemBase(rect, flags) + UiButton(Art *art, const char *text, void (*action)(), SDL_Rect rect, UiFlags flags = UiFlags::None) + : UiItemBase(UiType::Button, rect, flags) + , m_art(art) + , m_text(text) + , m_action(action) + , m_pressed(false) + , m_render_cache() { - m_type = UI_BUTTON; - m_art = art; - m_text = text; - m_action = action; - m_pressed = false; } enum FrameKey : uint8_t { @@ -294,14 +291,12 @@ class UiButton : public UiItemBase { class UiListItem { public: UiListItem(const char *text = "", int value = 0) + : m_text(text) + , m_value(value) { - m_text = text; - m_value = value; } - ~UiListItem() - { - } + ~UiListItem() {}; //private: const char *m_text; @@ -312,17 +307,16 @@ typedef std::vector> vUiListItem; class UiList : public UiItemBase { public: - UiList(const vUiListItem &vItems, Sint16 x, Sint16 y, Uint16 item_width, Uint16 item_height, int flags = 0) - : UiItemBase(x, y, item_width, static_cast(item_height * vItems.size()), flags) + UiList(const vUiListItem &vItems, Sint16 x, Sint16 y, Uint16 item_width, Uint16 item_height, UiFlags flags = UiFlags::None) + : UiItemBase(UiType::List, { x, y, item_width, static_cast(item_height * vItems.size()) }, flags) + , m_x(x) + , m_y(y) + , m_width(item_width) + , m_height(item_height) { - m_type = UI_LIST; for (auto &item : vItems) m_vecItems.push_back(item.get()); - m_x = x; - m_y = y; - m_width = item_width; - m_height = item_height; - }; + } ~UiList() {}; diff --git a/Source/control.cpp b/Source/control.cpp index f992d1a8560..e70abe06b46 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -48,7 +48,7 @@ bool chrbtnactive; int pnumlines; bool pinfoflag; spell_id pSpell; -uint16_t infoclr; +UiFlags InfoColor; char tempstr[256]; int sbooktab; spell_type pSplType; @@ -309,9 +309,9 @@ void PrintSBookHotkey(const Surface &out, Point position, const std::string &tex position += Displacement { SPLICONLENGTH - (GetLineWidth(text.c_str()) + 5), 17 - SPLICONLENGTH }; // Draw a drop shadow below and to the left of the text - DrawString(out, text.c_str(), position + Displacement { -1, 1 }, UIS_BLACK); + DrawString(out, text.c_str(), position + Displacement { -1, 1 }, UiFlags::ColorBlack); // Then draw the text over the top - DrawString(out, text.c_str(), position, UIS_SILVER); + DrawString(out, text.c_str(), position, UiFlags::ColorSilver); } /** @@ -403,14 +403,14 @@ void PrintInfo(const Surface &out) int yo = 0; int lo = 1; if (infostr[0] != '\0') { - DrawString(out, infostr, line, infoclr | UIS_CENTER | UIS_FIT_SPACING, 2); + DrawString(out, infostr, line, InfoColor | UiFlags::AlignCenter | UiFlags::KerningFitSpacing, 2); yo = 1; lo = 0; } for (int i = 0; i < pnumlines; i++) { line.position.y = PANEL_Y + LineOffsets[pnumlines - lo][i + yo]; - DrawString(out, panelstr[i], line, infoclr | UIS_CENTER | UIS_FIT_SPACING, 2); + DrawString(out, panelstr[i], line, InfoColor | UiFlags::AlignCenter | UiFlags::KerningFitSpacing, 2); } } @@ -457,7 +457,7 @@ int DrawDurIcon4Item(const Surface &out, ItemStruct *pItem, int x, int c) void PrintSBookStr(const Surface &out, Point position, const char *text) { - DrawString(out, text, { { RIGHT_PANEL_X + SPLICONLENGTH + position.x, position.y }, { 222, 0 } }, UIS_SILVER); + DrawString(out, text, { { RIGHT_PANEL_X + SPLICONLENGTH + position.x, position.y }, { 222, 0 } }, UiFlags::ColorSilver); } spell_type GetSBookTrans(spell_id ii, bool townok) @@ -1084,14 +1084,14 @@ void CheckPanelInfo() strcpy(tempstr, fmt::format(_("Hotkey: {:s}"), _(PanBtnHotKey[i])).c_str()); AddPanelString(tempstr); } - infoclr = UIS_SILVER; + InfoColor = UiFlags::ColorSilver; panelflag = true; pinfoflag = true; } } if (!spselflag && MousePosition.x >= 565 + PANEL_LEFT && MousePosition.x < 621 + PANEL_LEFT && MousePosition.y >= 64 + PANEL_TOP && MousePosition.y < 120 + PANEL_TOP) { strcpy(infostr, _("Select current spell button")); - infoclr = UIS_SILVER; + InfoColor = UiFlags::ColorSilver; panelflag = true; pinfoflag = true; strcpy(tempstr, _("Hotkey: 's'")); @@ -1257,11 +1257,11 @@ void DrawInfoBox(const Surface &out) DrawPanelBox(out, { 177, 62, 288, 60 }, { PANEL_X + 177, PANEL_Y + 46 }); if (!panelflag && !trigflag && pcursinvitem == -1 && !spselflag) { infostr[0] = '\0'; - infoclr = UIS_SILVER; + InfoColor = UiFlags::ColorSilver; ClearPanel(); } if (spselflag || trigflag) { - infoclr = UIS_SILVER; + InfoColor = UiFlags::ColorSilver; } else if (pcurs >= CURSOR_FIRSTITEM) { auto &myPlayer = Players[MyPlayerId]; if (myPlayer.HoldItem._itype == ITYPE_GOLD) { @@ -1276,7 +1276,7 @@ void DrawInfoBox(const Surface &out) strcpy(infostr, myPlayer.HoldItem._iIName); else strcpy(infostr, myPlayer.HoldItem._iName); - infoclr = myPlayer.HoldItem.getTextColor(); + InfoColor = myPlayer.HoldItem.getTextColor(); } } else { if (pcursitem != -1) @@ -1286,11 +1286,11 @@ void DrawInfoBox(const Surface &out) if (pcursmonst != -1) { const auto &monster = Monsters[pcursmonst]; if (leveltype != DTYPE_TOWN) { - infoclr = UIS_SILVER; + InfoColor = UiFlags::ColorSilver; strcpy(infostr, _(monster.mName)); ClearPanel(); if (monster._uniqtype != 0) { - infoclr = UIS_GOLD; + InfoColor = UiFlags::ColorGold; PrintUniqueHistory(); } else { PrintMonstHistory(monster.MType->mtype); @@ -1302,7 +1302,7 @@ void DrawInfoBox(const Surface &out) } } if (pcursplr != -1) { - infoclr = UIS_GOLD; + InfoColor = UiFlags::ColorGold; auto &target = Players[pcursplr]; strcpy(infostr, target._pName); ClearPanel(); @@ -1318,55 +1318,55 @@ void DrawInfoBox(const Surface &out) void DrawChr(const Surface &out) { - uint32_t style = UIS_SILVER; + UiFlags style = UiFlags::ColorSilver; char chrstr[64]; auto &myPlayer = Players[MyPlayerId]; CelDrawTo(out, { 0, 351 }, *pChrPanel, 1); - DrawString(out, myPlayer._pName, { { 20, 32 }, { 131, 0 } }, UIS_SILVER | UIS_CENTER); + DrawString(out, myPlayer._pName, { { 20, 32 }, { 131, 0 } }, UiFlags::ColorSilver | UiFlags::AlignCenter); - DrawString(out, _(ClassStrTbl[static_cast(myPlayer._pClass)]), { { 168, 32 }, { 131, 0 } }, UIS_SILVER | UIS_CENTER); + DrawString(out, _(ClassStrTbl[static_cast(myPlayer._pClass)]), { { 168, 32 }, { 131, 0 } }, UiFlags::ColorSilver | UiFlags::AlignCenter); sprintf(chrstr, "%i", myPlayer._pLevel); - DrawString(out, chrstr, { { 66, 69 }, { 43, 0 } }, UIS_SILVER | UIS_CENTER); + DrawString(out, chrstr, { { 66, 69 }, { 43, 0 } }, UiFlags::ColorSilver | UiFlags::AlignCenter); sprintf(chrstr, "%i", myPlayer._pExperience); - DrawString(out, chrstr, { { 216, 69 }, { 84, 0 } }, UIS_SILVER | UIS_CENTER); + DrawString(out, chrstr, { { 216, 69 }, { 84, 0 } }, UiFlags::ColorSilver | UiFlags::AlignCenter); if (myPlayer._pLevel == MAXCHARLEVEL - 1) { strcpy(chrstr, _("None")); - style = UIS_GOLD; + style = UiFlags::ColorGold; } else { sprintf(chrstr, "%i", myPlayer._pNextExper); - style = UIS_SILVER; + style = UiFlags::ColorSilver; } - DrawString(out, chrstr, { { 216, 97 }, { 84, 0 } }, style | UIS_CENTER); + DrawString(out, chrstr, { { 216, 97 }, { 84, 0 } }, style | UiFlags::AlignCenter); sprintf(chrstr, "%i", myPlayer._pGold); - DrawString(out, chrstr, { { 216, 146 }, { 84, 0 } }, UIS_SILVER | UIS_CENTER); + DrawString(out, chrstr, { { 216, 146 }, { 84, 0 } }, UiFlags::ColorSilver | UiFlags::AlignCenter); - style = UIS_SILVER; + style = UiFlags::ColorSilver; if (myPlayer._pIBonusAC > 0) - style = UIS_BLUE; + style = UiFlags::ColorBlue; if (myPlayer._pIBonusAC < 0) - style = UIS_RED; + style = UiFlags::ColorRed; sprintf(chrstr, "%i", myPlayer._pIBonusAC + myPlayer._pIAC + myPlayer._pDexterity / 5); - DrawString(out, chrstr, { { 258, 183 }, { 43, 0 } }, style | UIS_CENTER); + DrawString(out, chrstr, { { 258, 183 }, { 43, 0 } }, style | UiFlags::AlignCenter); - style = UIS_SILVER; + style = UiFlags::ColorSilver; if (myPlayer._pIBonusToHit > 0) - style = UIS_BLUE; + style = UiFlags::ColorBlue; if (myPlayer._pIBonusToHit < 0) - style = UIS_RED; + style = UiFlags::ColorRed; sprintf(chrstr, "%i%%", (myPlayer._pDexterity / 2) + myPlayer._pIBonusToHit + 50); - DrawString(out, chrstr, { { 258, 211 }, { 43, 0 } }, style | UIS_CENTER); + DrawString(out, chrstr, { { 258, 211 }, { 43, 0 } }, style | UiFlags::AlignCenter); - style = UIS_SILVER; + style = UiFlags::ColorSilver; if (myPlayer._pIBonusDam > 0) - style = UIS_BLUE; + style = UiFlags::ColorBlue; if (myPlayer._pIBonusDam < 0) - style = UIS_RED; + style = UiFlags::ColorRed; int mindam = myPlayer._pIMinDam; mindam += myPlayer._pIBonusDam * mindam / 100; mindam += myPlayer._pIBonusDamMod; @@ -1391,98 +1391,98 @@ void DrawChr(const Surface &out) } sprintf(chrstr, "%i-%i", mindam, maxdam); if (mindam >= 100 || maxdam >= 100) - DrawString(out, chrstr, { { 254, 239 }, { 51, 0 } }, style | UIS_CENTER, -1); + DrawString(out, chrstr, { { 254, 239 }, { 51, 0 } }, style | UiFlags::AlignCenter, -1); else - DrawString(out, chrstr, { { 258, 239 }, { 43, 0 } }, style | UIS_CENTER, 0); + DrawString(out, chrstr, { { 258, 239 }, { 43, 0 } }, style | UiFlags::AlignCenter, 0); - style = UIS_BLUE; + style = UiFlags::ColorBlue; if (myPlayer._pMagResist == 0) - style = UIS_SILVER; + style = UiFlags::ColorSilver; if (myPlayer._pMagResist < MAXRESIST) { sprintf(chrstr, "%i%%", myPlayer._pMagResist); } else { - style = UIS_GOLD; + style = UiFlags::ColorGold; strcpy(chrstr, _(/* TRANSLATORS: UI Constrains. Keep translation short please!*/ "MAX")); } - DrawString(out, chrstr, { { 257, 276 }, { 43, 0 } }, style | UIS_CENTER); + DrawString(out, chrstr, { { 257, 276 }, { 43, 0 } }, style | UiFlags::AlignCenter); - style = UIS_BLUE; + style = UiFlags::ColorBlue; if (myPlayer._pFireResist == 0) - style = UIS_SILVER; + style = UiFlags::ColorSilver; if (myPlayer._pFireResist < MAXRESIST) { sprintf(chrstr, "%i%%", myPlayer._pFireResist); } else { - style = UIS_GOLD; + style = UiFlags::ColorGold; strcpy(chrstr, _("MAX")); } - DrawString(out, chrstr, { { 257, 304 }, { 43, 0 } }, style | UIS_CENTER); + DrawString(out, chrstr, { { 257, 304 }, { 43, 0 } }, style | UiFlags::AlignCenter); - style = UIS_BLUE; + style = UiFlags::ColorBlue; if (myPlayer._pLghtResist == 0) - style = UIS_SILVER; + style = UiFlags::ColorSilver; if (myPlayer._pLghtResist < MAXRESIST) { sprintf(chrstr, "%i%%", myPlayer._pLghtResist); } else { - style = UIS_GOLD; + style = UiFlags::ColorGold; strcpy(chrstr, _("MAX")); } - DrawString(out, chrstr, { { 257, 332 }, { 43, 0 } }, style | UIS_CENTER); + DrawString(out, chrstr, { { 257, 332 }, { 43, 0 } }, style | UiFlags::AlignCenter); - style = UIS_SILVER; + style = UiFlags::ColorSilver; sprintf(chrstr, "%i", myPlayer._pBaseStr); if (myPlayer.GetMaximumAttributeValue(CharacterAttribute::Strength) == myPlayer._pBaseStr) - style = UIS_GOLD; - DrawString(out, chrstr, { { 95, 155 }, { 31, 0 } }, style | UIS_CENTER); + style = UiFlags::ColorGold; + DrawString(out, chrstr, { { 95, 155 }, { 31, 0 } }, style | UiFlags::AlignCenter); - style = UIS_SILVER; + style = UiFlags::ColorSilver; sprintf(chrstr, "%i", myPlayer._pBaseMag); if (myPlayer.GetMaximumAttributeValue(CharacterAttribute::Magic) == myPlayer._pBaseMag) - style = UIS_GOLD; - DrawString(out, chrstr, { { 95, 183 }, { 31, 0 } }, style | UIS_CENTER); + style = UiFlags::ColorGold; + DrawString(out, chrstr, { { 95, 183 }, { 31, 0 } }, style | UiFlags::AlignCenter); - style = UIS_SILVER; + style = UiFlags::ColorSilver; sprintf(chrstr, "%i", myPlayer._pBaseDex); if (myPlayer.GetMaximumAttributeValue(CharacterAttribute::Dexterity) == myPlayer._pBaseDex) - style = UIS_GOLD; - DrawString(out, chrstr, { { 95, 211 }, { 31, 0 } }, style | UIS_CENTER); + style = UiFlags::ColorGold; + DrawString(out, chrstr, { { 95, 211 }, { 31, 0 } }, style | UiFlags::AlignCenter); - style = UIS_SILVER; + style = UiFlags::ColorSilver; sprintf(chrstr, "%i", myPlayer._pBaseVit); if (myPlayer.GetMaximumAttributeValue(CharacterAttribute::Vitality) == myPlayer._pBaseVit) - style = UIS_GOLD; - DrawString(out, chrstr, { { 95, 239 }, { 31, 0 } }, style | UIS_CENTER); + style = UiFlags::ColorGold; + DrawString(out, chrstr, { { 95, 239 }, { 31, 0 } }, style | UiFlags::AlignCenter); - style = UIS_SILVER; + style = UiFlags::ColorSilver; if (myPlayer._pStrength > myPlayer._pBaseStr) - style = UIS_BLUE; + style = UiFlags::ColorBlue; if (myPlayer._pStrength < myPlayer._pBaseStr) - style = UIS_RED; + style = UiFlags::ColorRed; sprintf(chrstr, "%i", myPlayer._pStrength); - DrawString(out, chrstr, { { 143, 155 }, { 30, 0 } }, style | UIS_CENTER); + DrawString(out, chrstr, { { 143, 155 }, { 30, 0 } }, style | UiFlags::AlignCenter); - style = UIS_SILVER; + style = UiFlags::ColorSilver; if (myPlayer._pMagic > myPlayer._pBaseMag) - style = UIS_BLUE; + style = UiFlags::ColorBlue; if (myPlayer._pMagic < myPlayer._pBaseMag) - style = UIS_RED; + style = UiFlags::ColorRed; sprintf(chrstr, "%i", myPlayer._pMagic); - DrawString(out, chrstr, { { 143, 183 }, { 30, 0 } }, style | UIS_CENTER); + DrawString(out, chrstr, { { 143, 183 }, { 30, 0 } }, style | UiFlags::AlignCenter); - style = UIS_SILVER; + style = UiFlags::ColorSilver; if (myPlayer._pDexterity > myPlayer._pBaseDex) - style = UIS_BLUE; + style = UiFlags::ColorBlue; if (myPlayer._pDexterity < myPlayer._pBaseDex) - style = UIS_RED; + style = UiFlags::ColorRed; sprintf(chrstr, "%i", myPlayer._pDexterity); - DrawString(out, chrstr, { { 143, 211 }, { 30, 0 } }, style | UIS_CENTER); + DrawString(out, chrstr, { { 143, 211 }, { 30, 0 } }, style | UiFlags::AlignCenter); - style = UIS_SILVER; + style = UiFlags::ColorSilver; if (myPlayer._pVitality > myPlayer._pBaseVit) - style = UIS_BLUE; + style = UiFlags::ColorBlue; if (myPlayer._pVitality < myPlayer._pBaseVit) - style = UIS_RED; + style = UiFlags::ColorRed; sprintf(chrstr, "%i", myPlayer._pVitality); - DrawString(out, chrstr, { { 143, 239 }, { 30, 0 } }, style | UIS_CENTER); + DrawString(out, chrstr, { { 143, 239 }, { 30, 0 } }, style | UiFlags::AlignCenter); if (myPlayer._pStatPts > 0) { if (CalcStatDiff(myPlayer) < myPlayer._pStatPts) { @@ -1491,7 +1491,7 @@ void DrawChr(const Surface &out) } if (myPlayer._pStatPts > 0) { sprintf(chrstr, "%i", myPlayer._pStatPts); - DrawString(out, chrstr, { { 95, 266 }, { 31, 0 } }, UIS_RED | UIS_CENTER); + DrawString(out, chrstr, { { 95, 266 }, { 31, 0 } }, UiFlags::ColorRed | UiFlags::AlignCenter); if (myPlayer._pBaseStr < myPlayer.GetMaximumAttributeValue(CharacterAttribute::Strength)) CelDrawTo(out, { 137, 159 }, *pChrButtons, chrbtn[static_cast(CharacterAttribute::Strength)] ? 3 : 2); if (myPlayer._pBaseMag < myPlayer.GetMaximumAttributeValue(CharacterAttribute::Magic)) @@ -1502,25 +1502,25 @@ void DrawChr(const Surface &out) CelDrawTo(out, { 137, 244 }, *pChrButtons, chrbtn[static_cast(CharacterAttribute::Vitality)] ? 9 : 8); } - style = UIS_SILVER; + style = UiFlags::ColorSilver; if (myPlayer._pMaxHP > myPlayer._pMaxHPBase) - style = UIS_BLUE; + style = UiFlags::ColorBlue; sprintf(chrstr, "%i", myPlayer._pMaxHP >> 6); - DrawString(out, chrstr, { { 95, 304 }, { 31, 0 } }, style | UIS_CENTER); + DrawString(out, chrstr, { { 95, 304 }, { 31, 0 } }, style | UiFlags::AlignCenter); if (myPlayer._pHitPoints != myPlayer._pMaxHP) - style = UIS_RED; + style = UiFlags::ColorRed; sprintf(chrstr, "%i", myPlayer._pHitPoints >> 6); - DrawString(out, chrstr, { { 143, 304 }, { 31, 0 } }, style | UIS_CENTER); + DrawString(out, chrstr, { { 143, 304 }, { 31, 0 } }, style | UiFlags::AlignCenter); - style = UIS_SILVER; + style = UiFlags::ColorSilver; if (myPlayer._pMaxMana > myPlayer._pMaxManaBase) - style = UIS_BLUE; + style = UiFlags::ColorBlue; sprintf(chrstr, "%i", myPlayer._pMaxMana >> 6); - DrawString(out, chrstr, { { 95, 332 }, { 31, 0 } }, style | UIS_CENTER); + DrawString(out, chrstr, { { 95, 332 }, { 31, 0 } }, style | UiFlags::AlignCenter); if (myPlayer._pMana != myPlayer._pMaxMana) - style = UIS_RED; + style = UiFlags::ColorRed; sprintf(chrstr, "%i", myPlayer._pMana >> 6); - DrawString(out, chrstr, { { 143, 332 }, { 31, 0 } }, style | UIS_CENTER); + DrawString(out, chrstr, { { 143, 332 }, { 31, 0 } }, style | UiFlags::AlignCenter); } void CheckLvlBtn() @@ -1540,7 +1540,7 @@ void DrawLevelUpIcon(const Surface &out) { if (stextflag == STORE_NONE) { int nCel = lvlbtndown ? 3 : 2; - DrawString(out, _("Level Up"), { { PANEL_LEFT + 0, PANEL_TOP - 49 }, { 120, 0 } }, UIS_SILVER | UIS_CENTER); + DrawString(out, _("Level Up"), { { PANEL_LEFT + 0, PANEL_TOP - 49 }, { 120, 0 } }, UiFlags::ColorSilver | UiFlags::AlignCenter); CelDrawTo(out, { 40 + PANEL_X, -17 + PANEL_Y }, *pChrButtons, nCel); } } @@ -1776,7 +1776,7 @@ void DrawGoldSplit(const Surface &out, int amount) // The split gold dialog is roughly 4 lines high, but we need at least one line for the player to input an amount. // Using a clipping region 50 units high (approx 3 lines with a lineheight of 17) to ensure there is enough room left // for the text entered by the player. - DrawString(out, tempstr, { { dialogX + 31, 87 }, { 200, 50 } }, UIS_GOLD | UIS_CENTER, 1, 17); + DrawString(out, tempstr, { { dialogX + 31, 87 }, { 200, 50 } }, UiFlags::ColorGold | UiFlags::AlignCenter, 1, 17); tempstr[0] = '\0'; if (amount > 0) { @@ -1785,7 +1785,7 @@ void DrawGoldSplit(const Surface &out, int amount) } // Even a ten digit amount of gold only takes up about half a line. There's no need to wrap or clip text here so we // use the Point form of DrawString. - DrawString(out, tempstr, Point { dialogX + 37, 140 }, UIS_SILVER, 1, -1, true); + DrawString(out, tempstr, Point { dialogX + 37, 140 }, UiFlags::ColorSilver, 1, -1, true); } void control_drop_gold(char vkey) @@ -1843,7 +1843,7 @@ void DrawTalkPan(const Surface &out) int x = PANEL_LEFT + 200; int y = PANEL_Y + 22; - int idx = DrawString(out, msg, { { x, y }, { 250, 39 } }, UIS_SILVER, 1, 13, true); + int idx = DrawString(out, msg, { { x, y }, { 250, 39 } }, UiFlags::ColorSilver, 1, 13, true); msg[idx] = '\0'; x += 46; @@ -1852,10 +1852,10 @@ void DrawTalkPan(const Surface &out) if (i == MyPlayerId) continue; - uint16_t color = UIS_RED; + UiFlags color = UiFlags::ColorRed; const Point talkPanPosition { 172 + PANEL_X, 84 + 18 * talkBtn + PANEL_Y }; if (WhisperList[i]) { - color = UIS_GOLD; + color = UiFlags::ColorGold; if (TalkButtonsDown[talkBtn]) { int nCel = talkBtn != 0 ? 4 : 3; CelDrawTo(out, talkPanPosition, *talkButtons, nCel); diff --git a/Source/control.h b/Source/control.h index 195e1e98f6d..7d066e56f56 100644 --- a/Source/control.h +++ b/Source/control.h @@ -40,7 +40,7 @@ extern bool chrbtnactive; extern int pnumlines; extern bool pinfoflag; extern spell_id pSpell; -extern uint16_t infoclr; +extern UiFlags InfoColor; extern char tempstr[256]; extern int sbooktab; extern spell_type pSplType; diff --git a/Source/controls/modifier_hints.cpp b/Source/controls/modifier_hints.cpp index 42531bfbbcc..c44cde4c743 100644 --- a/Source/controls/modifier_hints.cpp +++ b/Source/controls/modifier_hints.cpp @@ -93,9 +93,9 @@ bool IsLeftActive(const CircleMenuHint &hint) return IsControllerButtonPressed(ControllerButton_BUTTON_X); } -uint16_t CircleMenuHintTextColor(bool active) +UiFlags CircleMenuHintTextColor(bool active) { - return active ? UIS_BLUE : UIS_GOLD; + return active ? UiFlags::ColorBlue : UiFlags::ColorGold; } /** diff --git a/Source/engine/render/text_render.cpp b/Source/engine/render/text_render.cpp index 037747a2dda..9f4838eb56f 100644 --- a/Source/engine/render/text_render.cpp +++ b/Source/engine/render/text_render.cpp @@ -271,39 +271,39 @@ void WordWrapGameString(char *text, size_t width, GameFontTables size, int spaci /** * @todo replace Rectangle with cropped Surface */ -uint16_t DrawString(const Surface &out, const char *text, const Rectangle &rect, uint16_t flags, int spacing, int lineHeight, bool drawTextCursor) +uint16_t DrawString(const Surface &out, const char *text, const Rectangle &rect, UiFlags flags, int spacing, int lineHeight, bool drawTextCursor) { GameFontTables size = GameFontSmall; - if ((flags & UIS_MED) != 0) + if (HasAnyOf(flags, UiFlags::FontMedium)) size = GameFontMed; - else if ((flags & UIS_HUGE) != 0) + else if (HasAnyOf(flags, UiFlags::FontHuge)) size = GameFontBig; text_color color = ColorGold; - if ((flags & UIS_SILVER) != 0) + if (HasAnyOf(flags, UiFlags::ColorSilver)) color = ColorWhite; - else if ((flags & UIS_BLUE) != 0) + else if (HasAnyOf(flags, UiFlags::ColorBlue)) color = ColorBlue; - else if ((flags & UIS_RED) != 0) + else if (HasAnyOf(flags, UiFlags::ColorRed)) color = ColorRed; - else if ((flags & UIS_BLACK) != 0) + else if (HasAnyOf(flags, UiFlags::ColorBlack)) color = ColorBlack; const size_t textLength = strlen(text); int charactersInLine = 0; int lineWidth = 0; - if ((flags & (UIS_CENTER | UIS_RIGHT | UIS_FIT_SPACING)) != 0) + if (HasAnyOf(flags, (UiFlags::AlignCenter | UiFlags::AlignRight | UiFlags::KerningFitSpacing))) lineWidth = GetLineWidth(text, size, spacing, &charactersInLine); int maxSpacing = spacing; - if ((flags & UIS_FIT_SPACING) != 0) + if (HasAnyOf(flags, UiFlags::KerningFitSpacing)) spacing = AdjustSpacingToFitHorizontally(lineWidth, maxSpacing, charactersInLine, rect.size.width); Point characterPosition = rect.position; - if ((flags & UIS_CENTER) != 0) + if (HasAnyOf(flags, UiFlags::AlignCenter)) characterPosition.x += (rect.size.width - lineWidth) / 2; - else if ((flags & UIS_RIGHT) != 0) + else if (HasAnyOf(flags, UiFlags::AlignRight)) characterPosition.x += rect.size.width - lineWidth; int rightMargin = rect.position.x + rect.size.width; @@ -321,16 +321,16 @@ uint16_t DrawString(const Surface &out, const char *text, const Rectangle &rect, break; characterPosition.y += lineHeight; - if ((flags & (UIS_CENTER | UIS_RIGHT | UIS_FIT_SPACING)) != 0) + if (HasAnyOf(flags, (UiFlags::AlignCenter | UiFlags::AlignRight | UiFlags::KerningFitSpacing))) lineWidth = GetLineWidth(&text[i + 1], size, spacing, &charactersInLine); - if ((flags & UIS_FIT_SPACING) != 0) + if (HasAnyOf(flags, UiFlags::KerningFitSpacing)) spacing = AdjustSpacingToFitHorizontally(lineWidth, maxSpacing, charactersInLine, rect.size.width); characterPosition.x = rect.position.x; - if ((flags & UIS_CENTER) != 0) + if (HasAnyOf(flags, UiFlags::AlignCenter)) characterPosition.x += (rect.size.width - lineWidth) / 2; - else if ((flags & UIS_RIGHT) != 0) + else if (HasAnyOf(flags, UiFlags::AlignRight)) characterPosition.x += rect.size.width - lineWidth; } if (frame != 0) { diff --git a/Source/engine/render/text_render.hpp b/Source/engine/render/text_render.hpp index 85cdb1dbdeb..a139f1cab21 100644 --- a/Source/engine/render/text_render.hpp +++ b/Source/engine/render/text_render.hpp @@ -58,7 +58,7 @@ void WordWrapGameString(char *text, size_t width, GameFontTables size = GameFont * @param drawTextCursor Whether to draw an animated cursor sprite at the end of the text (default is to display nothing). * @return The number of characters rendered, including characters "drawn" outside the buffer. */ -uint16_t DrawString(const Surface &out, const char *text, const Rectangle &rect, uint16_t flags = 0, int spacing = 1, int lineHeight = -1, bool drawTextCursor = false); +uint16_t DrawString(const Surface &out, const char *text, const Rectangle &rect, UiFlags flags = UiFlags::None, int spacing = 1, int lineHeight = -1, bool drawTextCursor = false); /** * @brief Draws a line of text at the given position relative to the origin of the output buffer. @@ -78,7 +78,7 @@ uint16_t DrawString(const Surface &out, const char *text, const Rectangle &rect, * @param drawTextCursor Whether to draw an animated cursor sprite at the end of the text (default is to display nothing). * @return The number of characters rendered (could be less than the string length if it wrapped past the bottom of the buffer). */ -inline uint16_t DrawString(const Surface &out, const char *text, const Point &position, uint16_t flags = 0, int spacing = 1, int lineHeight = -1, bool drawTextCursor = false) +inline uint16_t DrawString(const Surface &out, const char *text, const Point &position, UiFlags flags = UiFlags::None, int spacing = 1, int lineHeight = -1, bool drawTextCursor = false) { return DrawString(out, text, { position, { out.w() - position.x, 0 } }, flags, spacing, lineHeight, drawTextCursor); } diff --git a/Source/error.cpp b/Source/error.cpp index 8cea3b61f47..4ad4a4da944 100644 --- a/Source/error.cpp +++ b/Source/error.cpp @@ -133,7 +133,7 @@ void DrawDiabloMsg(const Surface &out) DrawHalfTransparentRectTo(out, PANEL_X + 104, DIALOG_Y - 8, 432, 54); strcpy(tempstr, _(MsgStrings[msgflag])); - DrawString(out, tempstr, { { PANEL_X + 101, DIALOG_Y + 24 }, { 442, 0 } }, UIS_CENTER); + DrawString(out, tempstr, { { PANEL_X + 101, DIALOG_Y + 24 }, { 442, 0 } }, UiFlags::AlignCenter); if (msgdelay > 0 && msgdelay <= SDL_GetTicks() - 3500) { msgdelay = 0; diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index a504ffcff3e..aaa6fef93f9 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -113,8 +113,8 @@ void GmenuDrawMenuItem(const Surface &out, TMenuItem *pItem, int y) } int x = (gnScreenWidth - w) / 2; - uint16_t style = (pItem->dwFlags & GMENU_ENABLED) != 0 ? UIS_SILVER : UIS_BLACK; - DrawString(out, _(pItem->pszStr), Point { x, y }, style | UIS_HUGE, 2); + UiFlags style = (pItem->dwFlags & GMENU_ENABLED) != 0 ? UiFlags::ColorSilver : UiFlags::ColorBlack; + DrawString(out, _(pItem->pszStr), Point { x, y }, style | UiFlags::FontHuge, 2); if (pItem == sgpCurrItem) { CelDrawTo(out, { x - 54, y + 1 }, *PentSpin_cel, PentSpn2Spin()); CelDrawTo(out, { x + 4 + w, y + 1 }, *PentSpin_cel, PentSpn2Spin()); @@ -163,7 +163,7 @@ void gmenu_draw_pause(const Surface &out) RedBack(out); if (sgpCurrentMenu == nullptr) { LightTableIndex = 0; - DrawString(out, _("Pause"), Point { 0, PANEL_TOP / 2 }, UIS_HUGE | UIS_CENTER, 2); + DrawString(out, _("Pause"), Point { 0, PANEL_TOP / 2 }, UiFlags::FontHuge | UiFlags::AlignCenter, 2); } } diff --git a/Source/help.cpp b/Source/help.cpp index 14351d5901e..89dc11381c5 100644 --- a/Source/help.cpp +++ b/Source/help.cpp @@ -130,7 +130,7 @@ void DrawHelp(const Surface &out) title = gbIsSpawn ? _("Shareware Hellfire Help") : _("Hellfire Help"); else title = gbIsSpawn ? _("Shareware Diablo Help") : _("Diablo Help"); - PrintSString(out, 0, 2, title, UIS_GOLD | UIS_CENTER); + PrintSString(out, 0, 2, title, UiFlags::ColorGold | UiFlags::AlignCenter); DrawSLine(out, 5); @@ -144,16 +144,16 @@ void DrawHelp(const Surface &out) } int offset = 0; - uint16_t style = UIS_SILVER; + UiFlags style = UiFlags::ColorSilver; if (line[0] == '$') { offset = 1; - style = UIS_RED; + style = UiFlags::ColorRed; } DrawString(out, &line[offset], { { sx, sy + i * 12 }, { 577, 12 } }, style); } - PrintSString(out, 0, 23, _("Press ESC to end or the arrow keys to scroll."), UIS_GOLD | UIS_CENTER); + PrintSString(out, 0, 23, _("Press ESC to end or the arrow keys to scroll."), UiFlags::ColorGold | UiFlags::AlignCenter); } void DisplayHelp() diff --git a/Source/inv.cpp b/Source/inv.cpp index 18a455813da..93c9a20d94a 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -1267,7 +1267,7 @@ void DrawInvBelt(const Surface &out) && myPlayer.SpdList[i]._iStatFlag && myPlayer.SpdList[i]._itype != ITYPE_GOLD) { snprintf(tempstr, sizeof(tempstr) / sizeof(*tempstr), "%i", i + 1); - DrawString(out, tempstr, { position, InventorySlotSizeInPixels }, UIS_SILVER | UIS_RIGHT); + DrawString(out, tempstr, { position, InventorySlotSizeInPixels }, UiFlags::ColorSilver | UiFlags::AlignRight); } } } @@ -1899,7 +1899,7 @@ char CheckInvHLight() return -1; int8_t rv = -1; - infoclr = UIS_SILVER; + InfoColor = UiFlags::ColorSilver; ItemStruct *pi = nullptr; auto &myPlayer = Players[MyPlayerId]; @@ -1954,7 +1954,7 @@ char CheckInvHLight() int nGold = pi->_ivalue; strcpy(infostr, fmt::format(ngettext("{:d} gold piece", "{:d} gold pieces", nGold), nGold).c_str()); } else { - infoclr = pi->getTextColor(); + InfoColor = pi->getTextColor(); if (pi->_iIdentified) { strcpy(infostr, pi->_iIName); PrintItemDetails(pi); diff --git a/Source/items.cpp b/Source/items.cpp index cbc96e79ea7..7a6cc7ec13a 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -3761,7 +3761,7 @@ void GetItemStr(int i) else strcpy(infostr, Items[i]._iName); - infoclr = Items[i].getTextColor(); + InfoColor = Items[i].getTextColor(); } else { int nGold = Items[i]._ivalue; strcpy(infostr, fmt::format(ngettext("{:d} gold piece", "{:d} gold pieces", nGold), nGold).c_str()); @@ -4138,7 +4138,7 @@ void DrawUniqueInfo(const Surface &out) Rectangle rect { { 32 + RIGHT_PANEL - SPANEL_WIDTH, 44 + 2 * 12 }, { 257, 0 } }; const UItemStruct &uitem = UniqueItemList[curruitem._iUid]; - DrawString(out, _(uitem.UIName), rect, UIS_CENTER); + DrawString(out, _(uitem.UIName), rect, UiFlags::AlignCenter); DrawUniqueInfoDevider(out, 5); @@ -4149,7 +4149,7 @@ void DrawUniqueInfo(const Surface &out) break; rect.position.y += 2 * 12; PrintItemPower(power.type, &curruitem); - DrawString(out, tempstr, rect, UIS_SILVER | UIS_CENTER); + DrawString(out, tempstr, rect, UiFlags::ColorSilver | UiFlags::AlignCenter); } } diff --git a/Source/items.h b/Source/items.h index ce37b55cbd5..d17c63383ba 100644 --- a/Source/items.h +++ b/Source/items.h @@ -361,18 +361,18 @@ struct ItemStruct { { switch (_iMagical) { case ITEM_QUALITY_MAGIC: - return UIS_BLUE; + return UiFlags::ColorBlue; case ITEM_QUALITY_UNIQUE: - return UIS_GOLD; + return UiFlags::ColorGold; default: - return UIS_SILVER; + return UiFlags::ColorSilver; } } UiFlags getTextColorWithStatCheck() const { if (!_iStatFlag) - return UIS_RED; + return UiFlags::ColorRed; return getTextColor(); } diff --git a/Source/minitext.cpp b/Source/minitext.cpp index 020d56b9b56..f6621d48500 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -117,7 +117,7 @@ void DrawQTextContent(const Surface &out) continue; } - DrawString(out, line, { { sx, sy + i * LineHeight }, { 543, LineHeight } }, UIS_MED, 2); + DrawString(out, line, { { sx, sy + i * LineHeight }, { 543, LineHeight } }, UiFlags::FontMedium, 2); } } diff --git a/Source/objects.cpp b/Source/objects.cpp index 56b6bccb577..d689bb88012 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -5552,13 +5552,13 @@ void GetObjectStr(int i) if (Objects[i]._oTrapFlag) { strcpy(tempstr, fmt::format(_(/* TRANSLATORS: {:s} will either be a chest or a door */ "Trapped {:s}"), infostr).c_str()); strcpy(infostr, tempstr); - infoclr = UIS_RED; + InfoColor = UiFlags::ColorRed; } } if (objectIsDisabled(i)) { strcpy(tempstr, fmt::format(_(/* TRANSLATORS: If user enabled diablo.ini setting "Disable Crippling Shrines" is set to 1; also used for Na-Kruls leaver */ "{:s} (disabled)"), infostr).c_str()); strcpy(infostr, tempstr); - infoclr = UIS_RED; + InfoColor = UiFlags::ColorRed; } } diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index c706f0e1c42..b39efbbe60b 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -22,9 +22,9 @@ uint8_t plr_msg_slot; _plrmsg plr_msgs[PMSG_COUNT]; /** Maps from player_num to text color, as used in chat messages. */ -const UiFlags TextColorFromPlayerId[MAX_PLRS + 1] = { UIS_SILVER, UIS_SILVER, UIS_SILVER, UIS_SILVER, UIS_GOLD }; +const UiFlags TextColorFromPlayerId[MAX_PLRS + 1] = { UiFlags::ColorSilver, UiFlags::ColorSilver, UiFlags::ColorSilver, UiFlags::ColorSilver, UiFlags::ColorGold }; -void PrintChatMessage(const Surface &out, int x, int y, int width, char *text, uint16_t style) +void PrintChatMessage(const Surface &out, int x, int y, int width, char *text, UiFlags style) { int length = strlen(text); for (int i = 0; i < length; i++) { diff --git a/Source/qol/monhealthbar.cpp b/Source/qol/monhealthbar.cpp index d1e033a4510..7521244a5e1 100644 --- a/Source/qol/monhealthbar.cpp +++ b/Source/qol/monhealthbar.cpp @@ -96,13 +96,13 @@ void DrawMonsterHealthBar(const Surface &out) } int barLabelY = yPos + 10 + (height - 11) / 2; - DrawString(out, monster.mName, { { xPos - 1, barLabelY + 1 }, { width, height } }, UIS_CENTER | UIS_BLACK); - uint16_t style = UIS_SILVER; + DrawString(out, monster.mName, { { xPos - 1, barLabelY + 1 }, { width, height } }, UiFlags::AlignCenter | UiFlags::ColorBlack); + UiFlags style = UiFlags::ColorSilver; if (monster._uniqtype != 0) - style = UIS_GOLD; + style = UiFlags::ColorGold; else if (monster.leader != 0) - style = UIS_BLUE; - DrawString(out, monster.mName, { { xPos, barLabelY }, { width, height } }, UIS_CENTER | style); + style = UiFlags::ColorBlue; + DrawString(out, monster.mName, { { xPos, barLabelY }, { width, height } }, UiFlags::AlignCenter | style); if (monster._uniqtype != 0 || MonsterKillCounts[monster.MType->mtype] >= 15) { monster_resistance immunes[] = { IMMUNE_MAGIC, IMMUNE_FIRE, IMMUNE_LIGHTNING }; diff --git a/Source/qol/xpbar.cpp b/Source/qol/xpbar.cpp index 4ddfd00a262..f668249b444 100644 --- a/Source/qol/xpbar.cpp +++ b/Source/qol/xpbar.cpp @@ -130,7 +130,7 @@ bool CheckXPBarInfo() if (charLevel == MAXCHARLEVEL - 1) { // Show a maximum level indicator for max level players. - infoclr = UIS_GOLD; + InfoColor = UiFlags::ColorGold; strcpy(tempstr, _("Experience: ")); PrintWithSeparator(tempstr + strlen(tempstr), ExpLvlsTbl[charLevel - 1]); @@ -141,7 +141,7 @@ bool CheckXPBarInfo() return true; } - infoclr = UIS_SILVER; + InfoColor = UiFlags::ColorSilver; strcpy(tempstr, _("Experience: ")); PrintWithSeparator(tempstr + strlen(tempstr), player._pExperience); diff --git a/Source/quests.cpp b/Source/quests.cpp index 15a4830100c..6f94bf057d6 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -254,7 +254,7 @@ void PrintQLString(const Surface &out, int x, int line, const char *str) if (qline == line) { CelDrawTo(out, { sx - 20, sy + 1 }, *pSPentSpn2Cels, PentSpn2Spin()); } - DrawString(out, str, { { sx, sy }, { 257, 0 } }, UIS_SILVER); + DrawString(out, str, { { sx, sy }, { 257, 0 } }, UiFlags::ColorSilver); if (qline == line) { CelDrawTo(out, { sx + width + 7, sy + 1 }, *pSPentSpn2Cels, PentSpn2Spin()); } @@ -730,7 +730,7 @@ void ResyncQuests() void DrawQuestLog(const Surface &out) { - DrawString(out, _("Quest Log"), { { 32, 44 }, { 257, 0 } }, UIS_CENTER); + DrawString(out, _("Quest Log"), { { 32, 44 }, { 257, 0 } }, UiFlags::AlignCenter); CelDrawTo(out, { 0, 351 }, *pQLogCel, 1); int line = qtopline; for (int i = 0; i < numqlines; i++) { diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index c7bf28b9525..10129691c42 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -1269,7 +1269,7 @@ void DrawFPS(const Surface &out) frameend = 0; } snprintf(string, 12, "%i FPS", framerate); - DrawString(out, string, Point { 8, 65 }, UIS_RED); + DrawString(out, string, Point { 8, 65 }, UiFlags::ColorRed); } /** diff --git a/Source/stores.cpp b/Source/stores.cpp index 4791de4abb9..7fd19e1f12d 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -150,7 +150,7 @@ void OffsetSTextY(int y, int yo) stext[y]._syoff = yo; } -void AddSText(int x, int y, const char *str, uint16_t flags, bool sel) +void AddSText(int x, int y, const char *str, UiFlags flags, bool sel) { stext[y]._sx = x; stext[y]._syoff = 0; @@ -160,7 +160,7 @@ void AddSText(int x, int y, const char *str, uint16_t flags, bool sel) stext[y]._ssel = sel; } -void PrintStoreItem(ItemStruct *x, int l, uint16_t flags) +void PrintStoreItem(ItemStruct *x, int l, UiFlags flags) { char sstr[128]; @@ -239,15 +239,15 @@ void StartSmith() { stextsize = false; stextscrl = false; - AddSText(0, 1, _("Welcome to the"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 3, _("Blacksmith's shop"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 7, _("Would you like to:"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 10, _("Talk to Griswold"), UIS_BLUE | UIS_CENTER, true); - AddSText(0, 12, _("Buy basic items"), UIS_SILVER | UIS_CENTER, true); - AddSText(0, 14, _("Buy premium items"), UIS_SILVER | UIS_CENTER, true); - AddSText(0, 16, _("Sell items"), UIS_SILVER | UIS_CENTER, true); - AddSText(0, 18, _("Repair items"), UIS_SILVER | UIS_CENTER, true); - AddSText(0, 20, _("Leave the shop"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 1, _("Welcome to the"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 3, _("Blacksmith's shop"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 7, _("Would you like to:"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 10, _("Talk to Griswold"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); + AddSText(0, 12, _("Buy basic items"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); + AddSText(0, 14, _("Buy premium items"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); + AddSText(0, 16, _("Sell items"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); + AddSText(0, 18, _("Repair items"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); + AddSText(0, 20, _("Leave the shop"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); AddSLine(5); storenumh = 20; } @@ -259,16 +259,16 @@ void ScrollSmithBuy(int idx) for (int l = 5; l < 20; l += 4) { if (!smithitem[idx].isEmpty()) { - uint16_t iclr = smithitem[idx].getTextColorWithStatCheck(); + UiFlags itemColor = smithitem[idx].getTextColorWithStatCheck(); if (smithitem[idx]._iMagical != ITEM_QUALITY_NORMAL) { - AddSText(20, l, smithitem[idx]._iIName, iclr, true); + AddSText(20, l, smithitem[idx]._iIName, itemColor, true); } else { - AddSText(20, l, smithitem[idx]._iName, iclr, true); + AddSText(20, l, smithitem[idx]._iName, itemColor, true); } AddSTextVal(l, smithitem[idx]._iIvalue); - PrintStoreItem(&smithitem[idx], l + 1, iclr); + PrintStoreItem(&smithitem[idx], l + 1, itemColor); stextdown = l; idx++; } @@ -287,11 +287,11 @@ void StartSmithBuy() /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ strcpy(tempstr, fmt::format(_("I have these items for sale: Your gold: {:d}"), Players[MyPlayerId]._pGold).c_str()); - AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); + AddSText(0, 1, tempstr, UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(3); AddSLine(21); ScrollSmithBuy(stextsval); - AddSText(0, 22, _("Back"), UIS_SILVER | UIS_CENTER, false); + AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, false); OffsetSTextY(22, 6); storenumh = 0; @@ -317,10 +317,10 @@ void ScrollSmithPremiumBuy(int boughtitems) for (int l = 5; l < 20 && idx < SMITH_PREMIUM_ITEMS; l += 4) { if (!premiumitems[idx].isEmpty()) { - uint16_t iclr = premiumitems[idx].getTextColorWithStatCheck(); - AddSText(20, l, premiumitems[idx]._iIName, iclr, true); + UiFlags itemColor = premiumitems[idx].getTextColorWithStatCheck(); + AddSText(20, l, premiumitems[idx]._iIName, itemColor, true); AddSTextVal(l, premiumitems[idx]._iIvalue); - PrintStoreItem(&premiumitems[idx], l + 1, iclr); + PrintStoreItem(&premiumitems[idx], l + 1, itemColor); stextdown = l; } else { l -= 4; @@ -351,10 +351,10 @@ bool StartSmithPremiumBuy() /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ strcpy(tempstr, fmt::format(_("I have these premium items for sale: Your gold: {:d}"), Players[MyPlayerId]._pGold).c_str()); - AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); + AddSText(0, 1, tempstr, UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(3); AddSLine(21); - AddSText(0, 22, _("Back"), UIS_SILVER | UIS_CENTER, false); + AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, false); OffsetSTextY(22, 6); stextsmax = storenumh - 4; @@ -405,17 +405,17 @@ void ScrollSmithSell(int idx) if (idx >= storenumh) break; if (!storehold[idx].isEmpty()) { - uint16_t iclr = storehold[idx].getTextColorWithStatCheck(); + UiFlags itemColor = storehold[idx].getTextColorWithStatCheck(); if (storehold[idx]._iMagical != ITEM_QUALITY_NORMAL && storehold[idx]._iIdentified) { - AddSText(20, l, storehold[idx]._iIName, iclr, true); + AddSText(20, l, storehold[idx]._iIName, itemColor, true); AddSTextVal(l, storehold[idx]._iIvalue); } else { - AddSText(20, l, storehold[idx]._iName, iclr, true); + AddSText(20, l, storehold[idx]._iName, itemColor, true); AddSTextVal(l, storehold[idx]._ivalue); } - PrintStoreItem(&storehold[idx], l + 1, iclr); + PrintStoreItem(&storehold[idx], l + 1, itemColor); stextdown = l; } idx++; @@ -478,10 +478,10 @@ void StartSmithSell() /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ strcpy(tempstr, fmt::format(_("You have nothing I want. Your gold: {:d}"), myPlayer._pGold).c_str()); - AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); + AddSText(0, 1, tempstr, UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(3); AddSLine(21); - AddSText(0, 22, _("Back"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); OffsetSTextY(22, 6); return; } @@ -493,11 +493,11 @@ void StartSmithSell() /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ strcpy(tempstr, fmt::format(_("Which item is for sale? Your gold: {:d}"), myPlayer._pGold).c_str()); - AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); + AddSText(0, 1, tempstr, UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(3); AddSLine(21); ScrollSmithSell(stextsval); - AddSText(0, 22, _("Back"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); OffsetSTextY(22, 6); } @@ -568,10 +568,10 @@ void StartSmithRepair() /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ strcpy(tempstr, fmt::format(_("You have nothing to repair. Your gold: {:d}"), myPlayer._pGold).c_str()); - AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); + AddSText(0, 1, tempstr, UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(3); AddSLine(21); - AddSText(0, 22, _("Back"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); OffsetSTextY(22, 6); return; } @@ -583,11 +583,11 @@ void StartSmithRepair() /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ strcpy(tempstr, fmt::format(_("Repair which item? Your gold: {:d}"), myPlayer._pGold).c_str()); - AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); + AddSText(0, 1, tempstr, UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(3); AddSLine(21); ScrollSmithSell(stextsval); - AddSText(0, 22, _("Back"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); OffsetSTextY(22, 6); } @@ -611,13 +611,13 @@ void StartWitch() FillManaPlayer(); stextsize = false; stextscrl = false; - AddSText(0, 2, _("Witch's shack"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 9, _("Would you like to:"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 12, _("Talk to Adria"), UIS_BLUE | UIS_CENTER, true); - AddSText(0, 14, _("Buy items"), UIS_SILVER | UIS_CENTER, true); - AddSText(0, 16, _("Sell items"), UIS_SILVER | UIS_CENTER, true); - AddSText(0, 18, _("Recharge staves"), UIS_SILVER | UIS_CENTER, true); - AddSText(0, 20, _("Leave the shack"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 2, _("Witch's shack"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 9, _("Would you like to:"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 12, _("Talk to Adria"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); + AddSText(0, 14, _("Buy items"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); + AddSText(0, 16, _("Sell items"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); + AddSText(0, 18, _("Recharge staves"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); + AddSText(0, 20, _("Leave the shack"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); AddSLine(5); storenumh = 20; } @@ -629,16 +629,16 @@ void ScrollWitchBuy(int idx) for (int l = 5; l < 20; l += 4) { if (!witchitem[idx].isEmpty()) { - uint16_t iclr = witchitem[idx].getTextColorWithStatCheck(); + UiFlags itemColor = witchitem[idx].getTextColorWithStatCheck(); if (witchitem[idx]._iMagical != ITEM_QUALITY_NORMAL) { - AddSText(20, l, witchitem[idx]._iIName, iclr, true); + AddSText(20, l, witchitem[idx]._iIName, itemColor, true); } else { - AddSText(20, l, witchitem[idx]._iName, iclr, true); + AddSText(20, l, witchitem[idx]._iName, itemColor, true); } AddSTextVal(l, witchitem[idx]._iIvalue); - PrintStoreItem(&witchitem[idx], l + 1, iclr); + PrintStoreItem(&witchitem[idx], l + 1, itemColor); stextdown = l; idx++; } @@ -658,11 +658,11 @@ void StartWitchBuy() /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ strcpy(tempstr, fmt::format(_("I have these items for sale: Your gold: {:d}"), Players[MyPlayerId]._pGold).c_str()); - AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); + AddSText(0, 1, tempstr, UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(3); AddSLine(21); ScrollWitchBuy(stextsval); - AddSText(0, 22, _("Back"), UIS_SILVER | UIS_CENTER, false); + AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, false); OffsetSTextY(22, 6); storenumh = 0; @@ -752,10 +752,10 @@ void StartWitchSell() /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ strcpy(tempstr, fmt::format(_("You have nothing I want. Your gold: {:d}"), myPlayer._pGold).c_str()); - AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); + AddSText(0, 1, tempstr, UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(3); AddSLine(21); - AddSText(0, 22, _("Back"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); OffsetSTextY(22, 6); return; } @@ -767,11 +767,11 @@ void StartWitchSell() /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ strcpy(tempstr, fmt::format(_("Which item is for sale? Your gold: {:d}"), myPlayer._pGold).c_str()); - AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); + AddSText(0, 1, tempstr, UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(3); AddSLine(21); ScrollSmithSell(stextsval); - AddSText(0, 22, _("Back"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); OffsetSTextY(22, 6); } @@ -833,10 +833,10 @@ void StartWitchRecharge() /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ strcpy(tempstr, fmt::format(_("You have nothing to recharge. Your gold: {:d}"), myPlayer._pGold).c_str()); - AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); + AddSText(0, 1, tempstr, UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(3); AddSLine(21); - AddSText(0, 22, _("Back"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); OffsetSTextY(22, 6); return; } @@ -848,11 +848,11 @@ void StartWitchRecharge() /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ strcpy(tempstr, fmt::format(_("Recharge which item? Your gold: {:d}"), myPlayer._pGold).c_str()); - AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); + AddSText(0, 1, tempstr, UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(3); AddSLine(21); ScrollSmithSell(stextsval); - AddSText(0, 22, _("Back"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); OffsetSTextY(22, 6); } @@ -862,7 +862,7 @@ void StoreNoMoney() stextscrl = false; stextsize = true; ClearSText(5, 23); - AddSText(0, 14, _("You do not have enough gold"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 14, _("You do not have enough gold"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); } void StoreNoRoom() @@ -870,7 +870,7 @@ void StoreNoRoom() StartStore(stextshold); stextscrl = false; ClearSText(5, 23); - AddSText(0, 14, _("You do not have enough room in inventory"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 14, _("You do not have enough room in inventory"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); } void StoreConfirm() @@ -881,7 +881,7 @@ void StoreConfirm() auto &item = Players[MyPlayerId].HoldItem; - uint16_t iclr = item.getTextColorWithStatCheck(); + UiFlags itemColor = item.getTextColorWithStatCheck(); bool idprint = item._iMagical != ITEM_QUALITY_NORMAL; @@ -898,12 +898,12 @@ void StoreConfirm() idprint = false; } if (idprint) - AddSText(20, 8, item._iIName, iclr, false); + AddSText(20, 8, item._iIName, itemColor, false); else - AddSText(20, 8, item._iName, iclr, false); + AddSText(20, 8, item._iName, itemColor, false); AddSTextVal(8, item._iIvalue); - PrintStoreItem(&item, 9, iclr); + PrintStoreItem(&item, 9, itemColor); switch (stextshold) { case STORE_BBOY: @@ -931,27 +931,27 @@ void StoreConfirm() default: app_fatal("Unknown store dialog %i", stextshold); } - AddSText(0, 15, tempstr, UIS_SILVER | UIS_CENTER, false); - AddSText(0, 18, _("Yes"), UIS_SILVER | UIS_CENTER, true); - AddSText(0, 20, _("No"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 15, tempstr, UiFlags::ColorSilver | UiFlags::AlignCenter, false); + AddSText(0, 18, _("Yes"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); + AddSText(0, 20, _("No"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); } void StartBoy() { stextsize = false; stextscrl = false; - AddSText(0, 2, _("Wirt the Peg-legged boy"), UIS_GOLD | UIS_CENTER, false); + AddSText(0, 2, _("Wirt the Peg-legged boy"), UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(5); if (!boyitem.isEmpty()) { - AddSText(0, 8, _("Talk to Wirt"), UIS_BLUE | UIS_CENTER, true); - AddSText(0, 12, _("I have something for sale,"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 14, _("but it will cost 50 gold"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 16, _("just to take a look. "), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 18, _("What have you got?"), UIS_SILVER | UIS_CENTER, true); - AddSText(0, 20, _("Say goodbye"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 8, _("Talk to Wirt"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); + AddSText(0, 12, _("I have something for sale,"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 14, _("but it will cost 50 gold"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 16, _("just to take a look. "), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 18, _("What have you got?"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); + AddSText(0, 20, _("Say goodbye"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); } else { - AddSText(0, 12, _("Talk to Wirt"), UIS_BLUE | UIS_CENTER, true); - AddSText(0, 18, _("Say goodbye"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 12, _("Talk to Wirt"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); + AddSText(0, 18, _("Say goodbye"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); } } @@ -963,22 +963,22 @@ void SStartBoyBuy() /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ strcpy(tempstr, fmt::format(_("I have this item for sale: Your gold: {:d}"), Players[MyPlayerId]._pGold).c_str()); - AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); + AddSText(0, 1, tempstr, UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(3); AddSLine(21); - uint16_t iclr = boyitem.getTextColorWithStatCheck(); + UiFlags itemColor = boyitem.getTextColorWithStatCheck(); if (boyitem._iMagical != ITEM_QUALITY_NORMAL) - AddSText(20, 10, boyitem._iIName, iclr, true); + AddSText(20, 10, boyitem._iIName, itemColor, true); else - AddSText(20, 10, boyitem._iName, iclr, true); + AddSText(20, 10, boyitem._iName, itemColor, true); if (gbIsHellfire) AddSTextVal(10, boyitem._iIvalue - (boyitem._iIvalue / 4)); else AddSTextVal(10, boyitem._iIvalue + (boyitem._iIvalue / 2)); - PrintStoreItem(&boyitem, 11, iclr); - AddSText(0, 22, _("Leave"), UIS_SILVER | UIS_CENTER, true); + PrintStoreItem(&boyitem, 11, itemColor); + AddSText(0, 22, _("Leave"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); OffsetSTextY(22, 6); } @@ -999,12 +999,12 @@ void StartHealer() HealPlayer(); stextsize = false; stextscrl = false; - AddSText(0, 1, _("Welcome to the"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 3, _("Healer's home"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 9, _("Would you like to:"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 12, _("Talk to Pepin"), UIS_BLUE | UIS_CENTER, true); - AddSText(0, 14, _("Buy items"), UIS_SILVER | UIS_CENTER, true); - AddSText(0, 16, _("Leave Healer's home"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 1, _("Welcome to the"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 3, _("Healer's home"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 9, _("Would you like to:"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 12, _("Talk to Pepin"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); + AddSText(0, 14, _("Buy items"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); + AddSText(0, 16, _("Leave Healer's home"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); AddSLine(5); storenumh = 20; } @@ -1015,11 +1015,11 @@ void ScrollHealerBuy(int idx) stextup = 5; for (int l = 5; l < 20; l += 4) { if (!healitem[idx].isEmpty()) { - uint16_t iclr = healitem[idx].getTextColorWithStatCheck(); + UiFlags itemColor = healitem[idx].getTextColorWithStatCheck(); - AddSText(20, l, healitem[idx]._iName, iclr, true); + AddSText(20, l, healitem[idx]._iName, itemColor, true); AddSTextVal(l, healitem[idx]._iIvalue); - PrintStoreItem(&healitem[idx], l + 1, iclr); + PrintStoreItem(&healitem[idx], l + 1, itemColor); stextdown = l; idx++; } @@ -1038,11 +1038,11 @@ void StartHealerBuy() /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ strcpy(tempstr, fmt::format(_("I have these items for sale: Your gold: {:d}"), Players[MyPlayerId]._pGold).c_str()); - AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); + AddSText(0, 1, tempstr, UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(3); AddSLine(21); ScrollHealerBuy(stextsval); - AddSText(0, 22, _("Back"), UIS_SILVER | UIS_CENTER, false); + AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, false); OffsetSTextY(22, 6); storenumh = 0; @@ -1058,11 +1058,11 @@ void StartStoryteller() { stextsize = false; stextscrl = false; - AddSText(0, 2, _("The Town Elder"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 9, _("Would you like to:"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 12, _("Talk to Cain"), UIS_BLUE | UIS_CENTER, true); - AddSText(0, 14, _("Identify an item"), UIS_SILVER | UIS_CENTER, true); - AddSText(0, 18, _("Say goodbye"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 2, _("The Town Elder"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 9, _("Would you like to:"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 12, _("Talk to Cain"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); + AddSText(0, 14, _("Identify an item"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); + AddSText(0, 18, _("Say goodbye"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); AddSLine(5); } @@ -1156,10 +1156,10 @@ void StartStorytellerIdentify() /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ strcpy(tempstr, fmt::format(_("You have nothing to identify. Your gold: {:d}"), myPlayer._pGold).c_str()); - AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); + AddSText(0, 1, tempstr, UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(3); AddSLine(21); - AddSText(0, 22, _("Back"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); OffsetSTextY(22, 6); return; } @@ -1171,11 +1171,11 @@ void StartStorytellerIdentify() /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ strcpy(tempstr, fmt::format(_("Identify which item? Your gold: {:d}"), myPlayer._pGold).c_str()); - AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); + AddSText(0, 1, tempstr, UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(3); AddSLine(21); ScrollSmithSell(stextsval); - AddSText(0, 22, _("Back"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); OffsetSTextY(22, 6); } @@ -1187,12 +1187,12 @@ void StartStorytellerIdentifyShow() auto &item = Players[MyPlayerId].HoldItem; - uint16_t iclr = item.getTextColorWithStatCheck(); + UiFlags itemColor = item.getTextColorWithStatCheck(); - AddSText(0, 7, _("This item is:"), UIS_SILVER | UIS_CENTER, false); - AddSText(20, 11, item._iIName, iclr, false); - PrintStoreItem(&item, 12, iclr); - AddSText(0, 18, _("Done"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 7, _("This item is:"), UiFlags::ColorSilver | UiFlags::AlignCenter, false); + AddSText(20, 11, item._iIName, itemColor, false); + PrintStoreItem(&item, 12, itemColor); + AddSText(0, 18, _("Done"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); } void StartTalk() @@ -1202,15 +1202,15 @@ void StartTalk() stextsize = false; stextscrl = false; strcpy(tempstr, fmt::format(_("Talk to {:s}"), TownerNames[talker]).c_str()); - AddSText(0, 2, tempstr, UIS_GOLD | UIS_CENTER, false); + AddSText(0, 2, tempstr, UiFlags::ColorGold | UiFlags::AlignCenter, false); AddSLine(5); if (gbIsSpawn) { strcpy(tempstr, fmt::format(_("Talking to {:s}"), TownerNames[talker]).c_str()); - AddSText(0, 10, tempstr, UIS_SILVER | UIS_CENTER, false); - AddSText(0, 12, _("is not available"), UIS_SILVER | UIS_CENTER, false); - AddSText(0, 14, _("in the shareware"), UIS_SILVER | UIS_CENTER, false); - AddSText(0, 16, _("version"), UIS_SILVER | UIS_CENTER, false); - AddSText(0, 22, _("Back"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 10, tempstr, UiFlags::ColorSilver | UiFlags::AlignCenter, false); + AddSText(0, 12, _("is not available"), UiFlags::ColorSilver | UiFlags::AlignCenter, false); + AddSText(0, 14, _("in the shareware"), UiFlags::ColorSilver | UiFlags::AlignCenter, false); + AddSText(0, 16, _("version"), UiFlags::ColorSilver | UiFlags::AlignCenter, false); + AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); return; } @@ -1232,23 +1232,23 @@ void StartTalk() for (int i = 0; i < MAXQUESTS; i++) { if (Quests[i]._qactive == QUEST_ACTIVE && QuestDialogTable[talker][i] != TEXT_NONE && Quests[i]._qlog) { - AddSText(0, sn, _(QuestData[i]._qlstr), UIS_SILVER | UIS_CENTER, true); + AddSText(0, sn, _(QuestData[i]._qlstr), UiFlags::ColorSilver | UiFlags::AlignCenter, true); sn += la; } } - AddSText(0, sn2, _("Gossip"), UIS_BLUE | UIS_CENTER, true); - AddSText(0, 22, _("Back"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, sn2, _("Gossip"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); + AddSText(0, 22, _("Back"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); } void StartTavern() { stextsize = false; stextscrl = false; - AddSText(0, 1, _("Welcome to the"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 3, _("Rising Sun"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 9, _("Would you like to:"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 12, _("Talk to Ogden"), UIS_BLUE | UIS_CENTER, true); - AddSText(0, 18, _("Leave the tavern"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 1, _("Welcome to the"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 3, _("Rising Sun"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 9, _("Would you like to:"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 12, _("Talk to Ogden"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); + AddSText(0, 18, _("Leave the tavern"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); AddSLine(5); storenumh = 20; } @@ -1257,10 +1257,10 @@ void StartBarmaid() { stextsize = false; stextscrl = false; - AddSText(0, 2, "Gillian", UIS_GOLD | UIS_CENTER, false); - AddSText(0, 9, _("Would you like to:"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 12, _("Talk to Gillian"), UIS_BLUE | UIS_CENTER, true); - AddSText(0, 18, _("Say goodbye"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 2, "Gillian", UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 9, _("Would you like to:"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 12, _("Talk to Gillian"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); + AddSText(0, 18, _("Say goodbye"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); AddSLine(5); storenumh = 20; } @@ -1269,10 +1269,10 @@ void StartDrunk() { stextsize = false; stextscrl = false; - AddSText(0, 2, _("Farnham the Drunk"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 9, _("Would you like to:"), UIS_GOLD | UIS_CENTER, false); - AddSText(0, 12, _("Talk to Farnham"), UIS_BLUE | UIS_CENTER, true); - AddSText(0, 18, _("Say Goodbye"), UIS_SILVER | UIS_CENTER, true); + AddSText(0, 2, _("Farnham the Drunk"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 9, _("Would you like to:"), UiFlags::ColorGold | UiFlags::AlignCenter, false); + AddSText(0, 12, _("Talk to Farnham"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); + AddSText(0, 18, _("Say Goodbye"), UiFlags::ColorSilver | UiFlags::AlignCenter, true); AddSLine(5); storenumh = 20; } @@ -2161,18 +2161,18 @@ int TakeGold(PlayerStruct &player, int cost, bool skipMaxPiles) return cost; } -void DrawSelector(const Surface &out, const Rectangle &rect, const char *text, uint16_t flags) +void DrawSelector(const Surface &out, const Rectangle &rect, const char *text, UiFlags flags) { int lineWidth = GetLineWidth(text); int x1 = rect.position.x - 20; - if ((flags & UIS_CENTER) != 0) + if (HasAnyOf(flags, UiFlags::AlignCenter)) x1 += (rect.size.width - lineWidth) / 2; CelDrawTo(out, { x1, rect.position.y + 1 }, *pSPentSpn2Cels, PentSpn2Spin()); int x2 = rect.position.x + rect.size.width + 5; - if ((flags & UIS_CENTER) != 0) + if (HasAnyOf(flags, UiFlags::AlignCenter)) x2 = rect.position.x + (rect.size.width - lineWidth) / 2 + lineWidth + 5; CelDrawTo(out, { x2, rect.position.y + 1 }, *pSPentSpn2Cels, PentSpn2Spin()); @@ -2251,7 +2251,7 @@ void FreeStoreMem() pSTextSlidCels = std::nullopt; } -void PrintSString(const Surface &out, int margin, int line, const char *text, uint16_t flags, int price) +void PrintSString(const Surface &out, int margin, int line, const char *text, UiFlags flags, int price) { int sx = PANEL_X + 32 + margin; if (!stextsize) { @@ -2271,7 +2271,7 @@ void PrintSString(const Surface &out, int margin, int line, const char *text, ui if (price > 0) { char valstr[32]; sprintf(valstr, "%i", price); - DrawString(out, valstr, rect, flags | UIS_RIGHT); + DrawString(out, valstr, rect, flags | UiFlags::AlignRight); } if (stextsel == line) { @@ -2309,7 +2309,7 @@ void ClearSText(int s, int e) stext[i]._sx = 0; stext[i]._syoff = 0; stext[i]._sstr[0] = 0; - stext[i].flags = 0; + stext[i].flags = UiFlags::None; stext[i]._sline = 0; stext[i]._ssel = false; stext[i]._sval = 0; diff --git a/Source/stores.h b/Source/stores.h index c3f5e501585..1b19aff4c90 100644 --- a/Source/stores.h +++ b/Source/stores.h @@ -48,7 +48,7 @@ struct STextStruct { int _sx; int _syoff; char _sstr[128]; - uint16_t flags; + UiFlags flags; int _sline; bool _ssel; int _sval; @@ -98,7 +98,7 @@ void AddStoreHoldRepair(ItemStruct *itm, int8_t i); void InitStores(); void SetupTownStores(); void FreeStoreMem(); -void PrintSString(const Surface &out, int margin, int line, const char *text, uint16_t flags, int price = 0); +void PrintSString(const Surface &out, int margin, int line, const char *text, UiFlags flags, int price = 0); void DrawSLine(const Surface &out, int y); void DrawSTextHelp(); void ClearSText(int s, int e);