Implemented controller compatibility with the Game Settings menu. Fullscreen mode now ignores automatic mouse movement due to screen resizes when in keyboard navigation mode. Release Build 7391.

pull/35/head
sigonasr2 9 months ago
parent bf33ad79c9
commit 4dc9505cbd
  1. 2
      Adventures in Lestoria/ConsumableCraftItemWindow.cpp
  2. 10
      Adventures in Lestoria/Menu.cpp
  3. 2
      Adventures in Lestoria/Menu.h
  4. 2
      Adventures in Lestoria/MenuType.h
  5. 103
      Adventures in Lestoria/SettingsWindow.cpp
  6. 5
      Adventures in Lestoria/Slider.h
  7. 1
      Adventures in Lestoria/TODO.txt
  8. 2
      Adventures in Lestoria/Version.h
  9. BIN
      x64/Release/Adventures in Lestoria.exe

@ -102,6 +102,8 @@ void Menu::InitializeConsumableCraftItemWindow(){
}
data.component.lock()->SetGrayedOut(!item.lock()->CanEnhanceItem(qty));
Menu::CloseMenu();
return true;
})END;

@ -51,6 +51,7 @@ INCLUDE_ITEM_CATEGORIES
INCLUDE_DATA
bool Menu::MOUSE_NAVIGATION=true;
bool Menu::nextMouseNavigationIsIgnored=false;
vi2d Menu::lastActiveMousePos{};
std::vector<Menu*>Menu::stack;
std::map<MenuType,Menu*>Menu::menus;
@ -159,7 +160,12 @@ void Menu::Update(AiL*game){
}
if(!UsingMouseNavigation()&&geom2d::line<float>(lastActiveMousePos,game->GetMousePos()).length()>="ThemeGlobal.MouseActivationDistance"_F){
if(!nextMouseNavigationIsIgnored){
SetMouseNavigation(true);
}else{ //Update the last active mouse position as if we were going to change to mouse navigation mode because we want to ignore this one and not trigger it until we move the mouse on purpose.
lastActiveMousePos=game->GetMousePos();
nextMouseNavigationIsIgnored=false;
}
}
for(auto&[key,button]:components){
@ -761,3 +767,7 @@ void Menu::SetSelection(Data button,const bool reset){
ERR("WARNING! Specified menu opening function does not hold neither a string nor a pointer to a component to use!");
}
}
void Menu::IgnoreNextMouseNavigationAttempt(){
nextMouseNavigationIsIgnored=true;
}

@ -197,6 +197,7 @@ public:
void SetSelection(Data button,const bool reset=false); // Use the reset parameter when a window is opening up, as this will cause the window now to scroll to its previous target.
const std::weak_ptr<MenuComponent>GetSelection()const;
const std::weak_ptr<MenuComponent>GetKeySelection()const;
static void IgnoreNextMouseNavigationAttempt();
private:
Menu(vf2d pos,vf2d size);
static MenuType lastMenuTypeCreated;
@ -230,6 +231,7 @@ private:
static bool MOUSE_NAVIGATION;
static std::weak_ptr<MenuComponent>lastHover;
static bool nextMouseNavigationIsIgnored; //This variable will blatantly ignore the next mouse move signal to set mouse navigation to true, useful when toggling between windowed and full screen.
bool cover; //A black cover for when a menu pops up to fade out the stuff behind it.
};

@ -62,7 +62,7 @@ enum MenuType{
SAVE_FILE_NAME, //100% Controller Compatibility
LOAD_GAME, //100% Controller Compatibility - Online Mode Tab switching
USER_ID, //100% Controller Compatibility
SETTINGS, //0% Controller Compatibility
SETTINGS, //100% Controller Compatibility
SHERMAN, //0% Controller Compatibility
INPUT_KEY_DISPLAY, //25% Controller Compatibility
NEW_INPUT, //100% Controller Compatibility

@ -60,7 +60,7 @@ void Menu::InitializeSettingsWindow(){
vf2d windowSize=WINDOW_SIZE-vf2d{28,28};
Menu*settingsWindow=CreateMenu(SETTINGS,CENTERED,windowSize);
settingsWindow->ADD("Unlock All Button",MenuComponent)(geom2d::rect<float>{{4,windowSize.y},{72,12}},"Unlock All",[](MenuFuncData data){
settingsWindow->ADD("Unlock All Button",MenuComponent)(geom2d::rect<float>{{4,windowSize.y-12},{72,12}},"Unlock All",[](MenuFuncData data){
for(auto&cp:State_OverworldMap::connections){
Unlock::UnlockArea(cp.map);
}
@ -68,30 +68,30 @@ void Menu::InitializeSettingsWindow(){
return true;
})END;
settingsWindow->ADD("Settings Label",MenuLabel)(geom2d::rect<float>{{4,4},vf2d{windowSize.x-8,24}},"Game Settings",2.f,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE|ComponentAttr::SHADOW)END;
settingsWindow->ADD("Settings Label",MenuLabel)(geom2d::rect<float>{{4,4},vf2d{windowSize.x-20,24}},"Game Settings",2.f,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE|ComponentAttr::SHADOW)END;
settingsWindow->F(A::LAST_BGM_VOLUME)=1.f;
settingsWindow->F(A::LAST_SFX_VOLUME)=1.f;
settingsWindow->ADD("BGM Slider",Slider)(geom2d::rect<float>{vf2d{windowSize.x/2-64,44},{172,16}},"BGM Volume:",Audio::GetBGMVolume(),[](float val){
settingsWindow->ADD("BGM Slider",Slider)(geom2d::rect<float>{vf2d{windowSize.x/2-64,32},{172,16}},"BGM Volume:",Audio::GetBGMVolume(),[](float val){
if(abs(Menu::menus[SETTINGS]->F(A::LAST_BGM_VOLUME)-val)>=0.04f){
SoundEffect::PlaySFX("Change Volume",SoundEffect::CENTERED);
Menu::menus[SETTINGS]->F(A::LAST_BGM_VOLUME)=val;
}
Audio::SetBGMVolume(val);
})END;
settingsWindow->ADD("SFX Slider",Slider)(geom2d::rect<float>{vf2d{windowSize.x/2-64,64},{172,16}},"SFX Volume:",Audio::GetSFXVolume(),[](float val){
settingsWindow->ADD("SFX Slider",Slider)(geom2d::rect<float>{vf2d{windowSize.x/2-64,52},{172,16}},"SFX Volume:",Audio::GetSFXVolume(),[](float val){
if(abs(Menu::menus[SETTINGS]->F(A::LAST_SFX_VOLUME)-val)>=0.04f){
SoundEffect::PlaySFX("Change Volume",SoundEffect::CENTERED);
Menu::menus[SETTINGS]->F(A::LAST_SFX_VOLUME)=val;
}
})END;
settingsWindow->ADD("Screen Shake Checkbox",Checkbox)(geom2d::rect<float>{{4.f,84},{16.f,16.f}},[](ToggleFuncData data){
settingsWindow->ADD("Screen Shake Checkbox",Checkbox)(geom2d::rect<float>{{4.f,72},{16.f,16.f}},[](ToggleFuncData data){
GameSettings::SetScreenShake(data.checked);
return true;
},true)END;
settingsWindow->ADD("Screen Shake Label",MenuLabel)(geom2d::rect<float>{{22.f,84},{windowSize.x/2-24.f,16.f}},"Screen Shake",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
settingsWindow->ADD("Controller Rumble Checkbox",Checkbox)(geom2d::rect<float>{{4.f,104},{16.f,16.f}},[](ToggleFuncData data){
settingsWindow->ADD("Screen Shake Label",MenuLabel)(geom2d::rect<float>{{22.f,72},{windowSize.x/2-24.f,16.f}},"Screen Shake",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
settingsWindow->ADD("Controller Rumble Checkbox",Checkbox)(geom2d::rect<float>{{4.f,92},{16.f,16.f}},[](ToggleFuncData data){
GameSettings::SetRumble(data.checked);
if(GameSettings::RumbleEnabled()){
Input::StartVibration();
@ -101,27 +101,33 @@ void Menu::InitializeSettingsWindow(){
}
return true;
},true)END;
settingsWindow->ADD("Controller Rumble Label",MenuLabel)(geom2d::rect<float>{{22.f,104},{windowSize.x/2-24.f,16.f}},"Gamepad Rumble",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
settingsWindow->ADD("Controller Rumble Label",MenuLabel)(geom2d::rect<float>{{22.f,92},{windowSize.x/2-24.f,16.f}},"Gamepad Rumble",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
settingsWindow->ADD("Terrain Collision Boxes Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,84},{16.f,16.f}},[](ToggleFuncData data){
settingsWindow->ADD("Terrain Collision Boxes Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,72},{16.f,16.f}},[](ToggleFuncData data){
GameSettings::SetTerrainCollisionBoxes(data.checked);
return true;
},true)END;
settingsWindow->ADD("Terrain Collision Boxes Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2+22.f,84},{windowSize.x/2-24.f,16.f}},"Terrain Collision Boxes",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
settingsWindow->ADD("Keyboard Play Auto-Aim Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,104},{16.f,16.f}},[](ToggleFuncData data){
settingsWindow->ADD("Terrain Collision Boxes Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2+22.f,72},{windowSize.x/2-24.f,16.f}},"Terrain Collision Boxes",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
settingsWindow->ADD("Keyboard Play Auto-Aim Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,92},{16.f,16.f}},[](ToggleFuncData data){
GameSettings::SetKeyboardAutoAim(data.checked);
return true;
},false)END;
settingsWindow->ADD("Keyboard Play Auto-Aim Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2+22.f,104},{windowSize.x/2-24.f,16.f}},"Aim Assist\n(No Mouse Players)",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
#ifndef __EMSCRIPTEN__
settingsWindow->ADD("Fullscreen Toggle Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,124},{16.f,16.f}},[](ToggleFuncData data){
settingsWindow->ADD("Keyboard Play Auto-Aim Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2+22.f,92},{windowSize.x/2-24.f,16.f}},"Aim Assist\n(No Mouse Players)",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
auto fullscreenToggle=settingsWindow->ADD("Fullscreen Toggle Checkbox",Checkbox)(geom2d::rect<float>{{windowSize.x/2+4.f,112},{16.f,16.f}},[](ToggleFuncData data){
if(data.checked){ //When going to fullscreen mode, the windowed mode positioning needs to be saved to be restored later.
GameSettings::SetWindowPos(game->GetActualWindowPos());
}
if(!Menu::UsingMouseNavigation()){ //This prevents the fullscreen toggle from losing focus upon a window resize.
Menu::IgnoreNextMouseNavigationAttempt();
}
game->SetFullscreen(data.checked,GameSettings::GetWindowPos());
return true;
},game->IsFullscreen())END;
settingsWindow->ADD("Fullscreen Toggle Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2+22.f,124},{windowSize.x/2-24.f,16.f}},"Fullscreen",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
auto fullscreenToggleLabel=settingsWindow->ADD("Fullscreen Toggle Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2+22.f,112},{windowSize.x/2-24.f,16.f}},"Fullscreen",1.f,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
#ifdef __EMSCRIPTEN__
fullscreenToggle->Disable();
fullscreenToggleLabel->Disable();
#endif
#pragma region Setup all input displays as keyboard controls.
@ -146,21 +152,82 @@ void Menu::InitializeSettingsWindow(){
};
#pragma endregion
settingsWindow->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect<float>{{28,144.f},vf2d{windowSize.x-32,24}},"Keyboard Bindings",[&](MenuFuncData data){
settingsWindow->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect<float>{{28,132.f},vf2d{windowSize.x-32,24}},"Keyboard Bindings",[&](MenuFuncData data){
ChangeKeybindDisplayType(KEY);
Component<MenuLabel>(INPUT_KEY_DISPLAY,"Keyboard Mapping Label")->SetLabel("Keyboard Mappings");
Menu::OpenMenu(INPUT_KEY_DISPLAY);
return true;
},vf2d{1.5f,2.f})END;
settingsWindow->ADD("Controller Bindings Button",MenuComponent)(geom2d::rect<float>{{28,172.f},vf2d{windowSize.x-32,24}},"Controller Bindings",[&](MenuFuncData data){
settingsWindow->ADD("Controller Bindings Button",MenuComponent)(geom2d::rect<float>{{28,160.f},vf2d{windowSize.x-32,24}},"Controller Bindings",[&](MenuFuncData data){
ChangeKeybindDisplayType(CONTROLLER);
Component<MenuLabel>(INPUT_KEY_DISPLAY,"Keyboard Mapping Label")->SetLabel("Controller Mappings");
Menu::OpenMenu(INPUT_KEY_DISPLAY);
return true;
},vf2d{1.5f,2.f})END;
settingsWindow->ADD("Go Back",MenuComponent)(geom2d::rect<float>{vf2d{windowSize.x/2.f,windowSize.y}-vf2d{36,4},{72,12}},"Go Back",[](MenuFuncData data){
settingsWindow->ADD("Go Back",MenuComponent)(geom2d::rect<float>{vf2d{windowSize.x/2.f,windowSize.y-12}-vf2d{36,4},{72,12}},"Go Back",[](MenuFuncData data){
Menu::CloseMenu();
return true;
})END;
settingsWindow->SetupKeyboardNavigation(
[](MenuType type,Data&returnData){ //On Open
returnData="BGM Slider";
},
{ //Button Key
{game->KEY_SCROLL,{"Navigate",[](MenuType type){}}},
{game->KEY_BACK,{"Back",[](MenuType type){
Menu::CloseMenu();
}}},
{game->KEY_CONFIRM,{"Select",[](MenuType type){}}},
}
,{ //Button Navigation Rules
{"BGM Slider",{
.up="Go Back",
.down="SFX Slider",}},
{"SFX Slider",{
.up="BGM Slider",
.down="Terrain Collision Boxes Checkbox",}},
{"Terrain Collision Boxes Checkbox",{
.up="SFX Slider",
.down="Keyboard Play Auto-Aim Checkbox",
.left="Screen Shake Checkbox",
.right="Screen Shake Checkbox",}},
{"Keyboard Play Auto-Aim Checkbox",{
.up="Terrain Collision Boxes Checkbox",
.down="Fullscreen Toggle Checkbox",
.left="Controller Rumble Checkbox",
.right="Controller Rumble Checkbox",}},
{"Screen Shake Checkbox",{
.up="SFX Slider",
.down="Controller Rumble Checkbox",
.left="Terrain Collision Boxes Checkbox",
.right="Terrain Collision Boxes Checkbox",}},
{"Controller Rumble Checkbox",{
.up="Screen Shake Checkbox",
.down="Fullscreen Toggle Checkbox",
.left="Keyboard Play Auto-Aim Checkbox",
.right="Keyboard Play Auto-Aim Checkbox",}},
{"Fullscreen Toggle Checkbox",{
.up="Keyboard Play Auto-Aim Checkbox",
.down="Keyboard Bindings Button",
.left="Controller Rumble Checkbox",
.right="Controller Rumble Checkbox",}},
{"Keyboard Bindings Button",{
.up="Fullscreen Toggle Checkbox",
.down="Controller Bindings Button",}},
{"Controller Bindings Button",{
.up="Keyboard Bindings Button",
.down="Go Back",}},
{"Go Back",{
.up="Controller Bindings Button",
.down="BGM Slider",
.left="Unlock All Button",
.right="Unlock All Button",}},
{"Unlock All Button",{
.up="Controller Bindings Button",
.down="BGM Slider",
.left="Go Back",
.right="Go Back",}},
});
}

@ -83,7 +83,7 @@ public:
dragging=true;
}
if(dragging){
if(dragging||(hovered&&!Menu::UsingMouseNavigation())){
if(Menu::UsingMouseNavigation()){
val=GetSliderVal(game->GetMouseX()-Menu::menus[parentMenu]->pos.x-8);
}else{
@ -93,6 +93,9 @@ public:
if(game->KEY_RIGHT.Held()){
val+=1.f*game->GetElapsedTime();
}
if(game->KEY_SCROLLHORZ.Analog()){
val+=game->KEY_SCROLLHORZ.Analog()*game->GetElapsedTime();
}
}
val=std::clamp(val,0.f,1.f);
if(abs(prevVal-val)>=0.01f){

@ -13,7 +13,6 @@ January 1st
Open window to the correct position/size at the beginning of the game if possible.
Input HElper disappearing? (Possibly on loads)
Boss
January 31st
============

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0
#define VERSION_MINOR 3
#define VERSION_PATCH 0
#define VERSION_BUILD 7382
#define VERSION_BUILD 7391
#define stringify(a) stringify_(a)
#define stringify_(a) #a

Loading…
Cancel
Save