Browse Source

Update fullscreen option in settings menu after Alt+Enter

pull/3817/merge
staphen 4 years ago committed by Anders Jenbo
parent
commit
af59f7e254
  1. 7
      Source/DiabloUI/diabloui.cpp
  2. 2
      Source/DiabloUI/diabloui.h
  3. 2
      Source/DiabloUI/selgame.cpp
  4. 2
      Source/DiabloUI/selhero.cpp
  5. 2
      Source/DiabloUI/selok.cpp
  6. 2
      Source/DiabloUI/selyesno.cpp
  7. 22
      Source/DiabloUI/settingsmenu.cpp

7
Source/DiabloUI/diabloui.cpp

@ -62,6 +62,7 @@ std::size_t listOffset = 0;
void (*gfnListFocus)(int value);
void (*gfnListSelect)(int value);
void (*gfnListEsc)();
void (*gfnFullscreen)();
bool (*gfnListYesNo)();
std::vector<UiItemBase *> gUiItems;
UiList *gUiList = nullptr;
@ -94,7 +95,7 @@ void AdjustListOffset(std::size_t itemIndex)
} // namespace
void UiInitList(void (*fnFocus)(int value), void (*fnSelect)(int value), void (*fnEsc)(), const std::vector<std::unique_ptr<UiItemBase>> &items, bool itemsWraps, bool (*fnYesNo)(), size_t selectedItem /*= 0*/)
void UiInitList(void (*fnFocus)(int value), void (*fnSelect)(int value), void (*fnEsc)(), const std::vector<std::unique_ptr<UiItemBase>> &items, bool itemsWraps, void (*fnFullscreen)(), bool (*fnYesNo)(), size_t selectedItem /*= 0*/)
{
SelectedItem = selectedItem;
SelectedItemMax = 0;
@ -102,6 +103,7 @@ void UiInitList(void (*fnFocus)(int value), void (*fnSelect)(int value), void (*
gfnListFocus = fnFocus;
gfnListSelect = fnSelect;
gfnListEsc = fnEsc;
gfnFullscreen = fnFullscreen;
gfnListYesNo = fnYesNo;
gUiItems.clear();
for (const auto &item : items)
@ -162,6 +164,7 @@ void UiInitList_clear()
gfnListFocus = nullptr;
gfnListSelect = nullptr;
gfnListEsc = nullptr;
gfnFullscreen = nullptr;
gfnListYesNo = nullptr;
gUiList = nullptr;
gUiItems.clear();
@ -445,6 +448,8 @@ void UiHandleEvents(SDL_Event *event)
const Uint8 *state = SDLC_GetKeyState();
if (state[SDLC_KEYSTATE_LALT] != 0 || state[SDLC_KEYSTATE_RALT] != 0) {
sgOptions.Graphics.fullscreen.SetValue(!IsFullScreen());
if (gfnFullscreen != nullptr)
gfnFullscreen();
return;
}
}

2
Source/DiabloUI/diabloui.h

@ -118,7 +118,7 @@ void UiAddLogo(std::vector<std::unique_ptr<UiItemBase>> *vecDialog, int size = L
void UiFocusNavigationSelect();
void UiFocusNavigationEsc();
void UiFocusNavigationYesNo();
void UiInitList(void (*fnFocus)(int value), void (*fnSelect)(int value), void (*fnEsc)(), const std::vector<std::unique_ptr<UiItemBase>> &items, bool wraps = false, bool (*fnYesNo)() = NULL, size_t selectedItem = 0);
void UiInitList(void (*fnFocus)(int value), void (*fnSelect)(int value), void (*fnEsc)(), const std::vector<std::unique_ptr<UiItemBase>> &items, bool wraps = false, void (*fnFullscreen)() = nullptr, bool (*fnYesNo)() = nullptr, size_t selectedItem = 0);
void UiClearScreen();
void UiPollAndRender();
void UiRenderItems(const std::vector<UiItemBase *> &items);

2
Source/DiabloUI/selgame.cpp

@ -121,7 +121,7 @@ void selgame_GameSelection_Init()
int itemValue = vecSelGameDlgItems[index]->m_value;
selgame_GameSelection_Select(itemValue);
};
UiInitList(selgame_GameSelection_Focus, selectFn, selgame_GameSelection_Esc, vecSelGameDialog, true, nullptr, HighlightedItem);
UiInitList(selgame_GameSelection_Focus, selectFn, selgame_GameSelection_Esc, vecSelGameDialog, true, nullptr, nullptr, HighlightedItem);
}
void selgame_GameSelection_Focus(int value)

2
Source/DiabloUI/selhero.cpp

@ -498,7 +498,7 @@ void selhero_List_Init()
SDL_Rect rect5 = { (Sint16)(PANEL_LEFT + 489), (Sint16)(UI_OFFSET_Y + 429), 120, 35 };
vecSelDlgItems.push_back(std::make_unique<UiArtTextButton>(_("Cancel"), &UiFocusNavigationEsc, rect5, UiFlags::AlignCenter | UiFlags::FontSize30 | UiFlags::ColorUiGold));
UiInitList(SelheroListFocus, SelheroListSelect, SelheroListEsc, vecSelDlgItems, false, SelheroListDeleteYesNo, selectedItem);
UiInitList(SelheroListFocus, SelheroListSelect, SelheroListEsc, vecSelDlgItems, false, nullptr, SelheroListDeleteYesNo, selectedItem);
if (selhero_isMultiPlayer) {
title = _("Multi Player Characters");
} else {

2
Source/DiabloUI/selok.cpp

@ -70,7 +70,7 @@ void UiSelOkDialog(const char *title, const char *body, bool background)
strcpy(dialogText, WordWrapString(body, MESSAGE_WIDTH, GameFont24).c_str());
UiInitList(nullptr, selok_Select, selok_Esc, vecSelOkDialog, false, nullptr);
UiInitList(nullptr, selok_Select, selok_Esc, vecSelOkDialog, false);
selok_endMenu = false;
while (!selok_endMenu) {

2
Source/DiabloUI/selyesno.cpp

@ -57,7 +57,7 @@ bool UiSelHeroYesNoDialog(const char *title, const char *body)
strcpy(selyesno_confirmationMessage, WordWrapString(body, MESSAGE_WIDTH, GameFont24).c_str());
UiInitList(nullptr, SelyesnoSelect, SelyesnoEsc, vecSelYesNoDialog, true, nullptr);
UiInitList(nullptr, SelyesnoSelect, SelyesnoEsc, vecSelYesNoDialog, true);
selyesno_value = true;
selyesno_endMenu = false;

22
Source/DiabloUI/settingsmenu.cpp

@ -181,6 +181,26 @@ void EscPressed()
GoBackOneMenuLevel();
}
void FullscreenChanged()
{
auto *fullscreenOption = &sgOptions.Graphics.fullscreen;
for (auto &vecItem : vecDialogItems) {
int vecItemValue = vecItem->m_value;
if (vecItemValue < 0)
continue;
auto *pOption = vecOptions[vecItemValue];
if (pOption != fullscreenOption)
continue;
vecItem->args.clear();
for (auto &arg : CreateDrawStringFormatArgForEntry(pOption))
vecItem->args.push_back(arg);
break;
}
}
} // namespace
void UiSettingsMenu()
@ -247,7 +267,7 @@ void UiSettingsMenu()
vecDialog.push_back(std::make_unique<UiList>(vecDialogItems, rectList.size.height / 26, rectList.position.x, rectList.position.y, rectList.size.width, 26, UiFlags::FontSize24 | UiFlags::AlignCenter));
UiInitList(ItemFocused, ItemSelected, EscPressed, vecDialog, true, nullptr, itemToSelect);
UiInitList(ItemFocused, ItemSelected, EscPressed, vecDialog, true, FullscreenChanged, nullptr, itemToSelect);
while (!endMenu) {
UiClearScreen();

Loading…
Cancel
Save