Moved settings related to the game itself into its own settings save file. Emscripten build also saves a separate system settings file in indexeddb. Added checks to prevent menu sounds from playing when the menu is not currently open, but adjusted in a different location in the game. Implemented different button icon sets and a setting to toggle between them. Removed the double button display (caused more confusion and took up more room). Fixed a bug with iterating through navigation groups when a button was removed/disabled from the list. Removed iconscaling dependency based on MenuIconButton sizes.

pull/35/head
sigonasr2 9 months ago
parent 0d295021b6
commit 66b0648a59
  1. 4
      Adventures in Lestoria/Adventures in Lestoria.vcxproj
  2. 3
      Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters
  3. 35
      Adventures in Lestoria/AdventuresInLestoria.cpp
  4. 7
      Adventures in Lestoria/Audio.cpp
  5. 2
      Adventures in Lestoria/Audio.h
  6. 4
      Adventures in Lestoria/BlacksmithCraftingWindow.cpp
  7. 2
      Adventures in Lestoria/CharacterMenuWindow.cpp
  8. 2
      Adventures in Lestoria/Checkbox.h
  9. 73
      Adventures in Lestoria/GameSettings.cpp
  10. 5
      Adventures in Lestoria/GameSettings.h
  11. 44
      Adventures in Lestoria/IconType.h
  12. 6
      Adventures in Lestoria/InputHelper.cpp
  13. 19
      Adventures in Lestoria/InputKeyboardWindow.cpp
  14. 6
      Adventures in Lestoria/InventoryConsumableWindow.cpp
  15. 2
      Adventures in Lestoria/InventoryWindow.cpp
  16. 9
      Adventures in Lestoria/ItemLoadoutWindow.cpp
  17. 33
      Adventures in Lestoria/Key.cpp
  18. 7
      Adventures in Lestoria/Key.h
  19. 10
      Adventures in Lestoria/LoadGameWindow.cpp
  20. 29
      Adventures in Lestoria/Menu.cpp
  21. 2
      Adventures in Lestoria/Menu.h
  22. 6
      Adventures in Lestoria/MenuComponent.cpp
  23. 10
      Adventures in Lestoria/MenuIconButton.h
  24. 2
      Adventures in Lestoria/MenuType.h
  25. 6
      Adventures in Lestoria/MerchantWindow.cpp
  26. 58
      Adventures in Lestoria/SaveFile.cpp
  27. 49
      Adventures in Lestoria/SettingsWindow.cpp
  28. 4
      Adventures in Lestoria/SoundEffect.cpp
  29. 2
      Adventures in Lestoria/State_MainMenu.cpp
  30. 4
      Adventures in Lestoria/TODO.txt
  31. 2
      Adventures in Lestoria/Version.h
  32. 15
      Adventures in Lestoria/assets/config/gfx/gfx.txt
  33. 6
      Adventures in Lestoria/assets/config/settings/input.txt
  34. BIN
      Adventures in Lestoria/assets/themes/button_d_ps.png
  35. BIN
      Adventures in Lestoria/assets/themes/button_d_xb.png
  36. BIN
      Adventures in Lestoria/assets/themes/button_l_ps.png
  37. BIN
      Adventures in Lestoria/assets/themes/button_l_xb.png
  38. BIN
      Adventures in Lestoria/assets/themes/button_r_ps.png
  39. BIN
      Adventures in Lestoria/assets/themes/button_r_xb.png
  40. BIN
      Adventures in Lestoria/assets/themes/button_u_ps.png
  41. BIN
      Adventures in Lestoria/assets/themes/button_u_xb.png
  42. BIN
      Adventures in Lestoria/assets/themes/ps.png
  43. BIN
      Adventures in Lestoria/assets/themes/xb.png
  44. BIN
      Adventures in Lestoria/assets/themes/xb_reversed.png
  45. BIN
      x64/Release/Adventures in Lestoria.exe

@ -355,6 +355,10 @@
</SubType>
</ClInclude>
<ClInclude Include="GameState.h" />
<ClInclude Include="IconType.h">
<SubType>
</SubType>
</ClInclude>
<ClInclude Include="InputDisplayComponent.h">
<SubType>
</SubType>

@ -462,6 +462,9 @@
<ClInclude Include="GameSettings.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="IconType.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Player.cpp">

@ -288,6 +288,24 @@ bool AiL::OnUserCreate(){
Stats::InitializeDamageReductionTable();
#ifdef __EMSCRIPTEN__
emscripten_idb_async_load("/assets",("save_file_path"_S+"system.conf").c_str(),0,[](void*arg,void*data,int length){
std::cout<<"Loaded System Save File successfully!"<<std::endl;
std::string rawMetadata=(char*)data;
std::ofstream file("save_file_path"_S+"system.conf");
for(int i=0;i<length;i++){
file<<rawMetadata[i];
}
file.close();
GameSettings::Initialize();
},[](void*arg){
std::cout<<"Failed to load System Save File!"<<std::endl;
});
#else
GameSettings::Initialize();
#endif
utils::datafile::INITIAL_SETUP_COMPLETE=true;
ValidateGameStatus(); //Checks to make sure everything has been initialized properly.
@ -2602,6 +2620,8 @@ void AiL::InitializeDefaultKeybinds(){
TieMenuNameToMenuInputGroup(KEY_DOWN);
TieMenuNameToMenuInputGroup(KEY_MENU);
TieMenuNameToMenuInputGroup(KEY_BACK);
TieMenuNameToMenuInputGroup(KEY_FACEUP);
TieMenuNameToMenuInputGroup(KEY_FACELEFT);
TieMenuNameToGameplayInputGroup(KEY_ATTACK);
TieMenuNameToGameplayInputGroup(Player::KEY_ABILITY1);
TieMenuNameToGameplayInputGroup(Player::KEY_ABILITY2);
@ -3186,12 +3206,13 @@ const uint8_t AiL::BossEncounterMobCount()const{
return totalBossEncounterMobs;
}
void AiL::GetAnyKeyRelease(Key key){
if(key!=0){
#pragma region New keyboard input binding listener
using A=Attribute;
if(Menu::IsMenuOpen()&&Menu::stack.back()==Menu::menus[NEW_INPUT]&&Menu::menus[NEW_INPUT]->B(A::IS_KEYBOARD)){ //We are requesting a brand new input.
if(Menu::IsMenuOpen()&&Menu::stack.back()==Menu::menus[NEW_INPUT]){
if(Menu::menus[NEW_INPUT]->B(A::IS_KEYBOARD)){//We are requesting a brand new input.
using A=Attribute;
if(InputGroup::menuNamesToInputGroups.count(Menu::menus[NEW_INPUT]->S(A::KEYBIND))){
InputGroup::menuNamesToInputGroups[Menu::menus[NEW_INPUT]->S(A::KEYBIND)]->SetNewPrimaryKeybind(Input{KEY,key});
@ -3201,6 +3222,9 @@ void AiL::GetAnyKeyRelease(Key key){
}
Menu::CloseMenu();
}
}else{
Menu::CloseMenu();
}
}
#pragma endregion
@ -3217,7 +3241,9 @@ void AiL::GetAnyKeyPress(Key key){
void AiL::GetAnyMouseRelease(int32_t mouseButton){
#pragma region New mouse input binding listener
using A=Attribute;
if(Menu::IsMenuOpen()&&Menu::stack.back()==Menu::menus[NEW_INPUT]&&Menu::menus[NEW_INPUT]->B(A::IS_KEYBOARD)){ //We are requesting a brand new input.
if(Menu::IsMenuOpen()&&Menu::stack.back()==Menu::menus[NEW_INPUT]){
if(Menu::menus[NEW_INPUT]->B(A::IS_KEYBOARD)){//We are requesting a brand new input.
using A=Attribute;
const std::vector<std::string>*inputGroup=&InputGroup::menuInputGroups; //First we detect which input group this mouse binding is for. Each group can individually have one key bound to each mouse button, that's why we first detect which group we actually care about.
for(const std::string&groupName:InputGroup::gameplayInputGroups){
@ -3248,6 +3274,9 @@ void AiL::GetAnyMouseRelease(int32_t mouseButton){
}
Menu::CloseMenu();
}
}else{
Menu::CloseMenu();
}
}
#pragma endregion

@ -46,6 +46,7 @@ INCLUDE_DATA
float Audio::defaultFadeTime=0.f;
float Audio::sfxVol=1.f;
float Audio::bgmVol=1.f;
bool Audio::muted=false;
void Audio::Initialize(){
Engine().SetBackgroundPlay(true);
@ -298,7 +299,7 @@ void Audio::SetBGMVolume(float vol){
BGM&track=Self().bgm[Self().playParams.sound];
for(int channelListIndex=0;int trackID:track.GetChannelIDs()){
float channelVol=track.GetVolume(Self().currentAudioEvent,channelListIndex);
Engine().SetVolume(trackID,channelVol*GetBGMVolume());
Engine().SetVolume(trackID,channelVol*GetBGMVolume()*GetMuteMult());
}
}
void Audio::SetSFXVolume(float vol){
@ -310,3 +311,7 @@ float&Audio::GetBGMVolume(){
float&Audio::GetSFXVolume(){
return sfxVol;
}
float Audio::GetMuteMult(){
if(muted)return 0.f;
return 1.f;
}

@ -71,6 +71,7 @@ public:
static void SetSFXVolume(float vol);
static float&GetBGMVolume();
static float&GetSFXVolume();
static float GetMuteMult();
private:
struct BGMPlayParams{
std::string sound;
@ -122,6 +123,7 @@ private:
bool fullyLoaded=true;
float playBGMWaitTime=0.0f;
BGMPlayParams playParams;
static bool muted;
};
std::string operator""_SFX(const char*key,size_t length);

@ -84,7 +84,9 @@ void Menu::InitializeBlacksmithCraftingWindow(){
}else{
data.menu.SetSelection(std::weak_ptr<MenuComponent>(Component<MenuComponent>(data.menu.GetType(),"Leave Button")));
}
if(Menu::IsCurrentlyActive(data.menu.GetType())){
SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED);
}
return true;
})END;
weaponTab->selected=true;
@ -100,7 +102,9 @@ void Menu::InitializeBlacksmithCraftingWindow(){
}else{
data.menu.SetSelection(std::weak_ptr<MenuComponent>(Component<MenuComponent>(data.menu.GetType(),"Leave Button")));
}
if(Menu::IsCurrentlyActive(data.menu.GetType())){
SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED);
}
return true;
})END;
armorTab->selectionType=SelectionType::HIGHLIGHT;

@ -157,7 +157,9 @@ void Menu::InitializeCharacterMenuWindow(){
if(!comp.expired()){
if(OppositeRingSlotDoesNotMatchCurrentEquip(comp.lock())){ //If we find that the opposite ring slot is equipped to us, this would be an item swap or the exact same ring, therefore no stat calculations apply.
Inventory::EquipItem(comp.lock()->GetItem(),EquipSlot(comp.lock()->I(Attribute::EQUIP_TYPE)));
if(Menu::IsCurrentlyActive(data.menu.GetType())){
SoundEffect::PlaySFX(comp.lock()->GetItem().lock()->UseSound(),SoundEffect::CENTERED);
}
for(std::weak_ptr<MenuComponent>button:DYNAMIC_POINTER_CAST<ScrollableWindowComponent>(data.parentComponent.lock())->GetComponents()){
std::weak_ptr<RowItemDisplay>comp=DYNAMIC_POINTER_CAST<RowItemDisplay>(button.lock());
comp.lock()->SetSelected(false);

@ -66,12 +66,14 @@ public:
inline void SetChecked(bool checked){
this->checked=checked;
if(Menu::IsCurrentlyActive(parentMenu)){
if(checked){
SoundEffect::PlaySFX("Toggle On",SoundEffect::CENTERED);
}else{
SoundEffect::PlaySFX("Toggle Off",SoundEffect::CENTERED);
}
}
}
inline void DrawDecal(ViewPort&window,bool focused)override{
geom2d::line<float>checkmarkLine1=geom2d::line<float>({rect.left().start.x+rect.size.x*0.125f,rect.left().start.y+rect.size.y*0.5f},{rect.top().start.x+rect.size.x*0.375f,rect.top().start.y+rect.size.y*0.875f});

@ -37,12 +37,20 @@ All rights reserved.
#pragma endregion
#include "GameSettings.h"
#include "olcUTIL_DataFile.h"
#include "config.h"
#include "Checkbox.h"
#include "MenuIconButton.h"
#include "InputDisplayComponent.h"
INCLUDE_DATA
bool GameSettings::screenShake=true;
bool GameSettings::rumble=true;
bool GameSettings::terrainCollisionBoxes=true;
bool GameSettings::keyboardAutoAim=false;
vi2d GameSettings::windowPos{30,30};
IconType GameSettings::iconType=IconType::XB;
const bool GameSettings::ScreenShakeEnabled(){
return screenShake;
@ -59,6 +67,9 @@ const bool GameSettings::KeyboardAutoAimEnabled(){
const vi2d GameSettings::GetWindowPos(){
return windowPos;
}
const IconType GameSettings::GetIconType(){
return iconType;
}
void GameSettings::SetScreenShake(bool screenShakeEnabled){
screenShake=screenShakeEnabled;
@ -75,3 +86,65 @@ void GameSettings::SetKeyboardAutoAim(bool autoAimEnabled){
void GameSettings::SetWindowPos(vi2d windowPos){
GameSettings::windowPos=windowPos;
}
void GameSettings::SetIconType(IconType type){
iconType=type;
}
void GameSettings::Initialize(){
utils::datafile loadSystemFile;
std::string loadSystemFilename="save_file_path"_S+"system.conf";
utils::datafile::Read(loadSystemFile,loadSystemFilename);
if(loadSystemFile.HasProperty("Screen Shake")){
GameSettings::SetScreenShake(loadSystemFile["Screen Shake"].GetBool());
Component<Checkbox>(SETTINGS,"Screen Shake Checkbox")->SetChecked(loadSystemFile["Screen Shake"].GetBool());
}
if(loadSystemFile.HasProperty("Controller Rumble")){
GameSettings::SetRumble(loadSystemFile["Controller Rumble"].GetBool());
Component<Checkbox>(SETTINGS,"Controller Rumble Checkbox")->SetChecked(loadSystemFile["Controller Rumble"].GetBool());
}
if(loadSystemFile.HasProperty("Terrain Collision Boxes")){
GameSettings::SetTerrainCollisionBoxes(loadSystemFile["Terrain Collision Boxes"].GetBool());
Component<Checkbox>(SETTINGS,"Terrain Collision Boxes Checkbox")->SetChecked(loadSystemFile["Terrain Collision Boxes"].GetBool());
}
if(loadSystemFile.HasProperty("Keyboard Auto-Aim")){
GameSettings::SetKeyboardAutoAim(loadSystemFile["Keyboard Auto-Aim"].GetBool());
Component<Checkbox>(SETTINGS,"Keyboard Play Auto-Aim Checkbox")->SetChecked(loadSystemFile["Keyboard Auto-Aim"].GetBool());
}
if(loadSystemFile.HasProperty("Controller Icons")){
const int maxIterations=10;
int iterationCount=0;
IconType targetIconType=IconType(loadSystemFile["Controller Icons"].GetInt());
while(iterationCount<maxIterations&&GameSettings::GetIconType()!=targetIconType){
Component<MenuIconButton>(SETTINGS,"Button Set Toggle Box")->Click();
iterationCount++;
}
if(iterationCount>=maxIterations)ERR("WARNING! Reached the max iteration count while cycling through controller icons! Failed to reach target icon set. THIS SHOULD NOT BE HAPPENING!")
}
if(loadSystemFile.HasProperty("BGM Level"))Audio::SetBGMVolume(loadSystemFile["BGM Level"].GetReal());
if(loadSystemFile.HasProperty("SFX Level"))Audio::SetSFXVolume(loadSystemFile["SFX Level"].GetReal());
#pragma region Load up Menu Keybinds
const int menuRowCount=DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()%2==0?DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()/2:DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()/2+1;
const int menuColCount=2;
for(int row=0;row<menuRowCount;row++){
for(int col=0;col<menuColCount;col++){
int inputID=row*menuColCount+col;
if(DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()%2==1&&col==1&&row==menuRowCount-1)continue; //We only continue on a blank space when we have an odd number of elements.
std::string keyName="Menu Keyboard Input_"+"Inputs.Menu Input Names"_s[inputID];
if(loadSystemFile.HasProperty(keyName)){
InputGroup&group=Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Input Displayer",row,col))->GetInput();
group.SetNewPrimaryKeybind({KEY,loadSystemFile[keyName].GetInt()});
}
keyName="Menu Controller Input_"+"Inputs.Menu Input Names"_s[inputID];
if(loadSystemFile.HasProperty(keyName)){
InputGroup&group=Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Input Displayer",row,col))->GetInput();
group.SetNewPrimaryKeybind({CONTROLLER,loadSystemFile[keyName].GetInt()});
}
}
}
#pragma endregion
}

@ -38,6 +38,7 @@ All rights reserved.
#pragma once
#include "olcUTIL_Geometry2D.h"
#include "IconType.h"
class GameSettings{
static bool screenShake;
@ -45,15 +46,19 @@ class GameSettings{
static bool terrainCollisionBoxes;
static bool keyboardAutoAim;
static vi2d windowPos;
static IconType iconType;
public:
static const bool ScreenShakeEnabled();
static const bool RumbleEnabled();
static const bool TerrainCollisionBoxesEnabled();
static const bool KeyboardAutoAimEnabled();
static const vi2d GetWindowPos();
static const IconType GetIconType();
static void SetScreenShake(bool screenShakeEnabled);
static void SetRumble(bool rumbleEnabled);
static void SetTerrainCollisionBoxes(bool terrainCollisionBoxesEnabled);
static void SetKeyboardAutoAim(bool autoAimEnabled);
static void SetWindowPos(vi2d windowPos);
static void SetIconType(IconType type);
static void Initialize();
};

@ -0,0 +1,44 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions or derivations of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice. This list of conditions and the following disclaimer must be
reproduced in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2024 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#pragma once
enum class IconType{
XB,
PS,
XB_REVERSED,
};

@ -39,6 +39,7 @@ All rights reserved.
#include "AdventuresInLestoria.h"
#include "Menu.h"
#include "MenuComponent.h"
#include "GameSettings.h"
INCLUDE_game
INCLUDE_GFX
@ -79,7 +80,6 @@ void InputHelper::Draw(){
std::vector<std::string>buttonDescriptions;
#pragma region Populate all buttons to display
for(auto&[group,display]:inputGroups){
size_t groupedInputCount=1;
std::vector<InputGroup>inputGroupsToCheck;
if(std::holds_alternative<std::string>(display)&&groupedInputs.count(std::get<std::string>(display))){
@ -108,6 +108,10 @@ void InputHelper::Draw(){
auto&primaryKey=group.GetPrimaryKey(mode);
if(displayName.length()>0&&primaryKey.has_value()){
if(primaryKey.value().HasExtendedIcons()){//This means it follows the specialized icon controller schemes, now pick based on these icons.
buttonImgWidth+=primaryKey.value().GetIcon(GameSettings::GetIconType()).Sprite()->width+"Interface.InputHelperSpacing"_I;
iconList.push_back(primaryKey.value().GetIcon(GameSettings::GetIconType()).Decal());
}else
if(primaryKey.value().HasIcon()){
buttonImgWidth+=primaryKey.value().GetIcon().Sprite()->width+"Interface.InputHelperSpacing"_I;
iconList.push_back(primaryKey.value().GetIcon().Decal());

@ -57,7 +57,7 @@ void Menu::InitializeKeyboardInputWindow(){
inputKeyboardWindow->ADD("Keyboard Mapping Label",MenuLabel)(geom2d::rect<float>{{4,0},{menuSize.x-8.f,24.f}},"Keyboard Mappings",2.f,ComponentAttr::SHADOW|ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE)END;
inputKeyboardWindow->ADD("Menu Inputs Background",MenuLabel)(geom2d::rect<float>{{4,32},{menuSize.x-8,56.f}},"",1.f,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE)END;
inputKeyboardWindow->ADD("Menu Inputs Background",MenuLabel)(geom2d::rect<float>{{4,32},{menuSize.x-8,65.f}},"",1.f,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE)END;
const int menuRowCount=DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()%2==0?DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()/2:DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()/2+1;
const int menuColCount=2;
@ -91,7 +91,7 @@ void Menu::InitializeKeyboardInputWindow(){
}
}
inputKeyboardWindow->ADD("Controller Inputs Background",MenuLabel)(geom2d::rect<float>{{4,100},{menuSize.x-8,68.f}},"",1.f,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE)END;
inputKeyboardWindow->ADD("Controller Inputs Background",MenuLabel)(geom2d::rect<float>{{4,100},{menuSize.x-8,65.f}},"",1.f,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE)END;
const int ingameControlsRowCount=DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()%2==0?DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()/2:DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()/2+1;
const int ingameControlsColCount=2;
@ -126,4 +126,19 @@ void Menu::InitializeKeyboardInputWindow(){
Menu::CloseMenu();
return true;
})END;
inputKeyboardWindow->SetupKeyboardNavigation(
[](MenuType type,Data&returnData){ //On Open
returnData="Input_0_0 Input Displayer";
},
{ //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
});
}

@ -121,6 +121,12 @@ void Menu::InitializeConsumableInventoryWindow(){
{game->KEY_BACK,{"Back",[](MenuType type){
Menu::CloseMenu();
}}},
{game->KEY_START,{"Set Loadout Item",[](MenuType type){
if(!Menu::menus[type]->GetSelection().expired()&&
!Menu::menus[type]->GetSelection().lock()->parentComponent.expired()){
Menu::menus[type]->GetSelection().lock()->Click();
}
}}},
{game->KEY_CONFIRM,{"Set Loadout Item",[](MenuType type){}}},
}
,{ //Button Navigation Rules

@ -97,7 +97,9 @@ void Menu::InitializeInventoryWindow(){
if(data.menu.I(A::ITEM_SLOT)>=0){
data.menu.SetSelection(Component<RowInventoryScrollableWindowComponent>(data.menu.GetType(),"Inventory Display - "+data.component.lock()->S(A::CATEGORY_NAME))->GetComponents()[0],true);
}
if(Menu::IsCurrentlyActive(data.menu.GetType())){
SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED);
}
return true;
},vf2d{textScaling,1.f})END;
button->SetSelectionType(HIGHLIGHT);

@ -64,7 +64,8 @@ void Menu::InitializeItemLoadoutWindow(){
Component<MenuLabel>(ITEM_LOADOUT,"Item Name Label")->SetLabel("");
Component<MenuLabel>(ITEM_LOADOUT,"Item Description")->SetLabel("");
return true;
},"Item Name Label","Item Description")END;
},"Item Name Label","Item Description")END
->SetIconScale({2.f,2.f});
itemLoadoutWindow->ADD("Loadout Item 2",MenuItemItemButton)(geom2d::rect<float>{{itemLoadoutWindowWidth/2-24,84},{48,48}},game->GetLoadoutItem(1),[](MenuFuncData data){
Menu::menus.at(INVENTORY_CONSUMABLES)->I(A::LOADOUT_SLOT)=1;
Menu::OpenMenu(INVENTORY_CONSUMABLES);
@ -75,7 +76,8 @@ void Menu::InitializeItemLoadoutWindow(){
Component<MenuLabel>(ITEM_LOADOUT,"Item Name Label")->SetLabel("");
Component<MenuLabel>(ITEM_LOADOUT,"Item Description")->SetLabel("");
return true;
},"Item Name Label","Item Description")END;
},"Item Name Label","Item Description")END
->SetIconScale({2.f,2.f});
itemLoadoutWindow->ADD("Loadout Item 3",MenuItemItemButton)(geom2d::rect<float>{{itemLoadoutWindowWidth-48-64,84},{48,48}},game->GetLoadoutItem(2),[](MenuFuncData data){
Menu::menus.at(INVENTORY_CONSUMABLES)->I(A::LOADOUT_SLOT)=2;
Menu::OpenMenu(INVENTORY_CONSUMABLES);
@ -86,7 +88,8 @@ void Menu::InitializeItemLoadoutWindow(){
Component<MenuLabel>(ITEM_LOADOUT,"Item Name Label")->SetLabel("");
Component<MenuLabel>(ITEM_LOADOUT,"Item Description")->SetLabel("");
return true;
},"Item Name Label","Item Description")END;
},"Item Name Label","Item Description")END
->SetIconScale({2.f,2.f});
itemLoadoutWindow->ADD("Item Name Label",MenuLabel)(geom2d::rect<float>{{0,146},{itemLoadoutWindowWidth,12}},"",1,ComponentAttr::SHADOW)END;
itemLoadoutWindow->ADD("Item Description",MenuLabel)(geom2d::rect<float>{{0,158},{itemLoadoutWindowWidth,24}},"",1,ComponentAttr::SHADOW)END;

@ -400,9 +400,27 @@ void InputGroup::DrawInput(const std::variant<AiL*const,TileTransformedView*cons
const bool Input::HasIcon()const{
return GenericKey::keyLiteral.at({type,key}).iconName.length()>0;
}
const bool Input::HasExtendedIcons()const{
return GenericKey::keyLiteral.at({type,key}).iconName.length()>0&&GenericKey::keyLiteral.at({type,key}).iconName2.length()>0&&GenericKey::keyLiteral.at({type,key}).iconName3.length()>0;
}
const Renderable&Input::GetIcon()const{
return GFX.at(GenericKey::keyLiteral.at({type,key}).iconName);
}
const Renderable&Input::GetIcon(IconType type)const{
switch(type){
case IconType::XB:{
return GFX.at(GenericKey::keyLiteral.at({this->type,key}).iconName);
}break;
case IconType::PS:{
return GFX.at(GenericKey::keyLiteral.at({this->type,key}).iconName2);
}break;
case IconType::XB_REVERSED:{
return GFX.at(GenericKey::keyLiteral.at({this->type,key}).iconName3);
}break;
}
ERR("WARNING! Did not handle a valid controller icon type. THIS SHOULD NOT BE HAPPENING!");
return GFX.at("themes/button_d_xb.png");
}
#undef END
@ -510,10 +528,10 @@ std::map<std::pair<InputType,int>,GenericKey::KeyInfo> GenericKey::keyLiteral={
{{MOUSE, Mouse::LEFT},{"L.MOUSE","themes/lmb.png"}},
{{MOUSE, Mouse::RIGHT},{"R.MOUSE","themes/rmb.png"}},
{{MOUSE, Mouse::MIDDLE},{"M.MOUSE","themes/mmb.png"}},
{{CONTROLLER, static_cast<int>(GPButtons::FACE_D)},{"A/X","themes/button_d.png"}},
{{CONTROLLER, static_cast<int>(GPButtons::FACE_L)},{"X/Square","themes/button_l.png"}},
{{CONTROLLER, static_cast<int>(GPButtons::FACE_R)},{"B/Circle","themes/button_r.png"}},
{{CONTROLLER, static_cast<int>(GPButtons::FACE_U)},{"Y/Triangle","themes/button_u.png"}},
{{CONTROLLER, static_cast<int>(GPButtons::FACE_D)},{"A/X","themes/button_d_xb.png","themes/button_d_ps.png","themes/button_r_xb.png"}},
{{CONTROLLER, static_cast<int>(GPButtons::FACE_L)},{"X/Square","themes/button_l_xb.png","themes/button_l_ps.png","themes/button_u_xb.png"}},
{{CONTROLLER, static_cast<int>(GPButtons::FACE_R)},{"B/Circle","themes/button_r_xb.png","themes/button_r_ps.png","themes/button_d_xb.png"}},
{{CONTROLLER, static_cast<int>(GPButtons::FACE_U)},{"Y/Triangle","themes/button_u_xb.png","themes/button_u_ps.png","themes/button_l_xb.png"}},
{{CONTROLLER, static_cast<int>(GPButtons::L1)},{"L1","themes/button_l1.png"}},
{{CONTROLLER, static_cast<int>(GPButtons::L2)},{"L2","themes/button_l2.png"}},
{{CONTROLLER, static_cast<int>(GPButtons::L3)},{"L3"}},
@ -648,7 +666,8 @@ void InputGroup::SetNewPrimaryKeybind(Input key){
void InputListener::Update(){
#pragma region New controller input binding listener
using A=Attribute;
if(Menu::IsMenuOpen()&&Menu::stack.back()==Menu::menus[NEW_INPUT]&&!Menu::menus[NEW_INPUT]->B(A::IS_KEYBOARD)){ //We are requesting a brand new controller input.
if(Menu::IsMenuOpen()&&Menu::stack.back()==Menu::menus[NEW_INPUT]){
if(!Menu::menus[NEW_INPUT]->B(A::IS_KEYBOARD)){//We are requesting a brand new controller input.
if(InputGroup::menuNamesToInputGroups.count(Menu::menus[NEW_INPUT]->S(A::KEYBIND))){
for(GamePad*gamepad:GamePad::getGamepads()){
for(size_t button=0;bool hasButton:gamepad->availableButtons){
@ -666,6 +685,10 @@ void InputListener::Update(){
}
}
}
}else{
Menu::alreadyClicked=true;
Menu::CloseMenu();
}
}
#pragma endregion
}

@ -43,6 +43,7 @@ All rights reserved.
#include "safemap.h"
#include "olcPGEX_TransformedView.h"
#include <variant>
#include "IconType.h"
class AiL;
@ -80,7 +81,9 @@ public:
const InputType GetType()const;
const std::string str()const;
const bool HasIcon()const;
const bool HasExtendedIcons()const; //Whether or not this input has extended icons for all the button sets (See IconType.h)
const Renderable&GetIcon()const;
const Renderable&GetIcon(IconType type)const;
const int GetKeyCode()const;
friend const bool operator==(const Input&input1,const Input&input2);
};
@ -147,7 +150,9 @@ public:
class GenericKey{
struct KeyInfo{
std::string displayName;
std::string iconName;
std::string iconName="";
std::string iconName2="";
std::string iconName3="";
};
public:
static std::map<std::pair<InputType,int>,KeyInfo>keyLiteral; //The displayed text for a given key for a given input type.

@ -56,7 +56,9 @@ void Menu::InitializeLoadGameWindow(){
Component<ScrollableWindowComponent>(data.menu.GetType(),"Online Game Files List")->Disable();
Component<MenuComponent>(data.menu.GetType(),"Online Character Tab")->SetSelected(false);
data.component.lock()->SetSelected(true);
if(Menu::IsCurrentlyActive(data.menu.GetType())){
SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED);
}
SaveFile::SetOnlineMode(false);
if(Component<ScrollableWindowComponent>(data.menu.GetType(),"Game Files List")->GetComponents().size()>0){
data.menu.SetSelection(Component<ScrollableWindowComponent>(data.menu.GetType(),"Game Files List")->GetComponents()[0],true);
@ -69,7 +71,9 @@ void Menu::InitializeLoadGameWindow(){
Component<ScrollableWindowComponent>(data.menu.GetType(),"Game Files List")->Disable();
Component<ScrollableWindowComponent>(data.menu.GetType(),"Online Game Files List")->Enable();
Component<MenuComponent>(data.menu.GetType(),"Offline Character Tab")->SetSelected(false);
if(Menu::IsCurrentlyActive(data.menu.GetType())){
SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED);
}
data.component.lock()->SetSelected(true);
if(!SaveFile::IsOnline()){
if(SaveFile::GetUserID().length()==0){
@ -137,10 +141,16 @@ void Menu::InitializeLoadGameWindow(){
{{game->KEY_SHOULDER,Pressed},{"Scroll",[](MenuType type){}}},
{{game->KEY_FASTSCROLLDOWN,PressedDAS,InputEngageGroup::NOT_VISIBLE},{"Scroll",[](MenuType type){
auto gameFilesList=Component<ScrollableWindowComponent>(type,"Game Files List");
if(!Component<MenuComponent>(type,"Offline Character Tab")->selected){
gameFilesList=Component<ScrollableWindowComponent>(type,"Online Game Files List");
}
gameFilesList->IncreaseSelectionIndex(3.f);
}}},
{{game->KEY_FASTSCROLLUP,PressedDAS,InputEngageGroup::NOT_VISIBLE},{"Scroll",[](MenuType type){
auto gameFilesList=Component<ScrollableWindowComponent>(type,"Game Files List");
if(!Component<MenuComponent>(type,"Offline Character Tab")->selected){
gameFilesList=Component<ScrollableWindowComponent>(type,"Online Game Files List");
}
gameFilesList->IncreaseSelectionIndex(-3.f);
}}},
}

@ -374,17 +374,6 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
if(navigationGroups.count(selectionButtonName)){
Navigation nav=navigationGroups[selectionButtonName];
if(selection.lock()->IsGreyedOut()||selection.lock()->IsDisabled()){
// If the button is greyed out or disabled, this is an invalid selection. We will try to reset to a default, but we need to break out of this loop.
if(onOpenFunc){
Data returnData;
onOpenFunc(GetType(),returnData);
defaultButton=returnData;
if(std::holds_alternative<ButtonName>(returnData)&&std::get<ButtonName>(returnData).length()>0||std::holds_alternative<std::weak_ptr<MenuComponent>>(returnData))SetSelection(returnData,true);
}
break;
}
if(game->KEY_UP.PressedDAS()||game->KEY_SCROLLUP.AnalogDAS(0.5f)<-0.5f){
SoundEffect::PlaySFX("Menu Navigate",SoundEffect::CENTERED);
SetMouseNavigation(false);
@ -441,7 +430,18 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
break; //There's no reason to be doing anything here if we navigate with the mouse.
}
iterationCount++;
if(iterationCount==MAX_ITERATIONS)ERR("WARNING! We've entered the max iteration count of automatic Menu navigation! THIS LIKELY MEANS WE'VE DONE SOMETHING TERRIBLY WRONG!");
if(iterationCount==MAX_ITERATIONS){
if(selection.lock()->IsGreyedOut()||selection.lock()->IsDisabled()){
// If the button is greyed out or disabled, this is an invalid selection. We will try to reset to a default, but we need to break out of this loop.
if(onOpenFunc){
Data returnData;
onOpenFunc(GetType(),returnData);
defaultButton=returnData;
if(std::holds_alternative<ButtonName>(returnData)&&std::get<ButtonName>(returnData).length()>0||std::holds_alternative<std::weak_ptr<MenuComponent>>(returnData))SetSelection(returnData,true);
}
break;
}
}
}while(iterationCount<MAX_ITERATIONS&&(selection.lock()->grayedOut||selection.lock()->disable));
}
@ -771,3 +771,8 @@ void Menu::SetSelection(Data button,const bool reset){
void Menu::IgnoreNextMouseNavigationAttempt(){
nextMouseNavigationIsIgnored=true;
}
bool Menu::IsCurrentlyActive(MenuType type){
if(Menu::stack.size()==0)return false;
return Menu::stack.back()->GetType()==type;
}

@ -198,6 +198,8 @@ public:
const std::weak_ptr<MenuComponent>GetSelection()const;
const std::weak_ptr<MenuComponent>GetKeySelection()const;
static void IgnoreNextMouseNavigationAttempt();
//Returns whether or not this menu type is currently in the foreground of the game, and thus being interacted with by the user.
static bool IsCurrentlyActive(MenuType type);
private:
Menu(vf2d pos,vf2d size);
static MenuType lastMenuTypeCreated;

@ -259,7 +259,11 @@ void MenuComponent::OnChapterUpdate(uint8_t newChapter){}
void MenuComponent::Click(){
if(grayedOut||disable||disableOutsideWindow)return;
onClick(MenuFuncData{*Menu::menus[parentMenu],game,Menu::menus[parentMenu]->components[name]});
std::weak_ptr<ScrollableWindowComponent>parent;
if(!Menu::menus[parentMenu]->components[name]->parentComponent.expired()){//HACK ALERT! We assume every parent is a scrollable window component.
parent=Menu::menus[parentMenu]->components[name]->parentComponent;
}
onClick(MenuFuncData{*Menu::menus[parentMenu],game,Menu::menus[parentMenu]->components[name],parent});
}
void MenuComponent::SetLabel(std::string newLabel){
label=newLabel;

@ -53,6 +53,7 @@ enum class IconButtonAttr{
class MenuIconButton:public MenuComponent{
protected:
Decal*icon;
vf2d iconScale{1,1};
Pixel tint=WHITE;
public:
inline MenuIconButton(geom2d::rect<float>rect,Decal*icon,MenuFunc onClick,IconButtonAttr attributes=IconButtonAttr::SELECTABLE)
@ -60,6 +61,12 @@ public:
border=!(attributes&IconButtonAttr::NO_OUTLINE);
background=!(attributes&IconButtonAttr::NO_BACKGROUND);
}
virtual inline void SetIcon(Decal*newIcon){
icon=newIcon;
}
virtual inline void SetIconScale(vf2d iconScale){
this->iconScale=iconScale;
}
protected:
virtual inline void Update(AiL*game)override{
MenuComponent::Update(game);
@ -67,8 +74,7 @@ protected:
virtual inline void DrawDecal(ViewPort&window,bool focused)override{
MenuComponent::DrawDecal(window,focused);
if(icon!=nullptr){
vf2d iconScale=rect.size/24.f;
window.DrawDecal(rect.middle()-icon->sprite->Size()*iconScale/2,icon,iconScale,tint);
window.DrawRotatedDecal(rect.middle(),icon,0.f,icon->sprite->Size()/2,iconScale,tint);
}
}
};

@ -65,7 +65,7 @@ enum MenuType{
SETTINGS, //100% Controller Compatibility
SHERMAN, //100% Controller Compatibility
INPUT_KEY_DISPLAY, //25% Controller Compatibility
NEW_INPUT, //100% Controller Compatibility
NEW_INPUT, //75% Controller Compatibility
PAUSE, //0% Controller Compatibility
///////////////////////////////////////////////////////////
/*DO NOT REMOVE!!*/ENUM_END////////////////////////////////

@ -78,7 +78,9 @@ void Menu::InitializeMerchantWindow(){
Component<RowInventoryScrollableWindowComponent>(data.menu.GetType(),"Inventory Display - "+data.menu.S(A::LAST_INVENTORY_TYPE_OPENED))->Disable();
Component<MenuComponent>(data.menu.GetType(),data.menu.S(A::LAST_INVENTORY_TYPE_OPENED)+" Inventory Tab")->Disable();
data.component.lock()->selected=true;
if(Menu::IsCurrentlyActive(data.menu.GetType())){
SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED);
}
return true;
})END;
buyTab->selected=true;
@ -95,7 +97,9 @@ void Menu::InitializeMerchantWindow(){
Component<RowInventoryScrollableWindowComponent>(data.menu.GetType(),"Inventory Display - "+data.menu.S(A::LAST_INVENTORY_TYPE_OPENED))->Enable();
Component<MenuComponent>(data.menu.GetType(),data.menu.S(A::LAST_INVENTORY_TYPE_OPENED)+" Inventory Tab")->Enable();
data.component.lock()->selected=true;
if(Menu::IsCurrentlyActive(data.menu.GetType())){
SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED);
}
return true;
})END;
sellTab->selectionType=SelectionType::HIGHLIGHT;
@ -162,7 +166,9 @@ void Menu::InitializeMerchantWindow(){
if(data.menu.I(A::ITEM_SLOT)>=0){
data.menu.SetSelection(Component<RowInventoryScrollableWindowComponent>(data.menu.GetType(),"Inventory Display - "+data.component.lock()->S(A::CATEGORY_NAME))->GetComponents()[0],true);
}
if(Menu::IsCurrentlyActive(data.menu.GetType())){
SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED);
}
return true;
},vf2d{textScaling,1.f})END;
button->SetSelectionType(HIGHLIGHT);

@ -125,21 +125,17 @@ const void SaveFile::SaveGame(){
saveFile["Game Time"].SetReal(game->GetRuntime());
saveFile["TravelingMerchant"].SetString(std::string(Merchant::GetCurrentTravelingMerchant().GetKeyName()));
saveFile["Screen Shake"].SetBool(GameSettings::ScreenShakeEnabled());
saveFile["Controller Rumble"].SetBool(GameSettings::RumbleEnabled());
saveFile["Terrain Collision Boxes"].SetBool(GameSettings::TerrainCollisionBoxesEnabled());
saveFile["Keyboard Auto-Aim"].SetBool(GameSettings::KeyboardAutoAimEnabled());
#pragma region Save Keyboard/Controller mappings
//NOTE: We are shadowing code from InputKeyboardWindow! If at some point the retrival method for getting input displays changes, we likely will be changing the code here as well!
//ALSO NOTE: The menu inputs are saved to the system file while gameplay inputs are per-character and saved to the character settings file!
const int menuRowCount=DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()%2==0?DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()/2:DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()/2+1;
const int menuColCount=2;
for(int row=0;row<menuRowCount;row++){
for(int col=0;col<menuColCount;col++){
int inputID=row*menuColCount+col;
if(DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()%2==1&&col==1&&row==menuRowCount-1)continue; //We only continue on a blank space when we have an odd number of elements.
saveFile["Menu Keyboard Input_"+"Inputs.Menu Input Names"_s[inputID]].SetInt(Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Input Displayer",row,col))->GetInput().GetPrimaryKey(KEY).value().GetKeyCode());
saveFile["Menu Controller Input_"+"Inputs.Menu Input Names"_s[inputID]].SetInt(Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Input Displayer",row,col))->GetInput().GetPrimaryKey(CONTROLLER).value().GetKeyCode());
saveSystemFile["Menu Keyboard Input_"+"Inputs.Menu Input Names"_s[inputID]].SetInt(Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Input Displayer",row,col))->GetInput().GetPrimaryKey(KEY).value().GetKeyCode());
saveSystemFile["Menu Controller Input_"+"Inputs.Menu Input Names"_s[inputID]].SetInt(Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Input Displayer",row,col))->GetInput().GetPrimaryKey(CONTROLLER).value().GetKeyCode());
}
}
const int ingameControlsRowCount=DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()%2==0?DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()/2:DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()/2+1;
@ -155,7 +151,14 @@ const void SaveFile::SaveGame(){
#pragma endregion
#pragma region Save System Settings
//HACK ALERT! It's possible that on X11 the actual reported window position is offset later when we set it. We will set it now to see if it moves or adjusts, and use that new position instead as the position we save.
saveSystemFile["BGM Level"].SetReal(Audio::GetBGMVolume());
saveSystemFile["SFX Level"].SetReal(Audio::GetSFXVolume());
saveSystemFile["Screen Shake"].SetBool(GameSettings::ScreenShakeEnabled());
saveSystemFile["Controller Rumble"].SetBool(GameSettings::RumbleEnabled());
saveSystemFile["Terrain Collision Boxes"].SetBool(GameSettings::TerrainCollisionBoxesEnabled());
saveSystemFile["Keyboard Auto-Aim"].SetBool(GameSettings::KeyboardAutoAimEnabled());
saveSystemFile["Controller Icons"].SetInt(int(GameSettings::GetIconType()));
saveSystemFile["Window Pos"].SetInt(game->GetActualWindowPos().x,0);
saveSystemFile["Window Pos"].SetInt(game->GetActualWindowPos().y,1);
saveSystemFile["Window Size"].SetInt(game->GetWindowSize().x,0);
@ -238,6 +241,22 @@ const void SaveFile::SaveGame(){
metafile.close();
}
std::stringstream systemFileContents;
std::ifstream systemfile("save_file_path"_S+"system.conf");
while(systemfile.good()){
int val=systemfile.get();
if(val!=-1){
systemFileContents<<char(val);
}
}
std::string systemContents=systemFileContents.str();
emscripten_idb_async_store("/assets",("save_file_path"_S+"system.conf").c_str(),systemContents.data(),systemContents.length(),0,[](void*arg){
std::cout<<"Successfully saved system file!"<<std::endl;
},[](void*arg){
std::cout<<"Successfully saved system file!"<<std::endl;
});
systemfile.close();
#endif
}
@ -293,31 +312,8 @@ void SaveFile::LoadFile(){
game->GetPlayer()->RecalculateEquipStats();
if(loadFile.HasProperty("TravelingMerchant"))Merchant::SetTravelingMerchant(loadFile["TravelingMerchant"].GetString());
if(loadFile.HasProperty("Screen Shake"))GameSettings::SetScreenShake(loadFile["Screen Shake"].GetBool());
if(loadFile.HasProperty("Controller Rumble"))GameSettings::SetRumble(loadFile["Controller Rumble"].GetBool());
if(loadFile.HasProperty("Terrain Collision Boxes"))GameSettings::SetTerrainCollisionBoxes(loadFile["Terrain Collision Boxes"].GetBool());
if(loadFile.HasProperty("Keyboard Auto-Aim"))GameSettings::SetKeyboardAutoAim(loadFile["Keyboard Auto-Aim"].GetBool());
#pragma region Load Keyboard/Controller mappings
//NOTE: We are shadowing code from InputKeyboardWindow! If at some point the retrival method for getting input displays changes, we likely will be changing the code here as well!
const int menuRowCount=DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()%2==0?DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()/2:DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()/2+1;
const int menuColCount=2;
for(int row=0;row<menuRowCount;row++){
for(int col=0;col<menuColCount;col++){
int inputID=row*menuColCount+col;
if(DATA.GetProperty("Inputs.Menu Input Names").GetValueCount()%2==1&&col==1&&row==menuRowCount-1)continue; //We only continue on a blank space when we have an odd number of elements.
std::string keyName="Menu Keyboard Input_"+"Inputs.Menu Input Names"_s[inputID];
if(loadFile.HasProperty(keyName)){
InputGroup&group=Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Input Displayer",row,col))->GetInput();
group.SetNewPrimaryKeybind({KEY,loadFile[keyName].GetInt()});
}
keyName="Menu Controller Input_"+"Inputs.Menu Input Names"_s[inputID];
if(loadFile.HasProperty(keyName)){
InputGroup&group=Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Input Displayer",row,col))->GetInput();
group.SetNewPrimaryKeybind({CONTROLLER,loadFile[keyName].GetInt()});
}
}
}
const int ingameControlsRowCount=DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()%2==0?DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()/2:DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()/2+1;
const int ingameControlsColCount=2;
for(int row=0;row<ingameControlsRowCount;row++){

@ -49,6 +49,7 @@ All rights reserved.
#include "Checkbox.h"
#include "InputDisplayComponent.h"
#include "GameSettings.h"
#include "MenuIconButton.h"
INCLUDE_DATA
INCLUDE_game
@ -60,11 +61,13 @@ 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-12},{72,12}},"Unlock All",[](MenuFuncData data){
settingsWindow->ADD("Unlock All Button",MenuComponent)(geom2d::rect<float>{{4,windowSize.y-20},{72,12}},"Unlock All",[](MenuFuncData data){
if(Menu::IsCurrentlyActive(SETTINGS)){
for(auto&cp:State_OverworldMap::connections){
Unlock::UnlockArea(cp.map);
}
SoundEffect::PlaySFX("Buy Item",SoundEffect::CENTERED);
}
return true;
})END;
@ -74,17 +77,21 @@ void Menu::InitializeSettingsWindow(){
settingsWindow->F(A::LAST_SFX_VOLUME)=1.f;
settingsWindow->ADD("BGM Slider",Slider)(geom2d::rect<float>{vf2d{windowSize.x/2-64,32},{172,16}},"BGM Volume:",Audio::GetBGMVolume(),[](float val){
if(Menu::IsCurrentlyActive(SETTINGS)){
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,52},{172,16}},"SFX Volume:",Audio::GetSFXVolume(),[](float val){
if(Menu::IsCurrentlyActive(SETTINGS)){
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,72},{16.f,16.f}},[](ToggleFuncData data){
GameSettings::SetScreenShake(data.checked);
@ -92,6 +99,7 @@ void Menu::InitializeSettingsWindow(){
},true)END;
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){
if(Menu::IsCurrentlyActive(SETTINGS)){
GameSettings::SetRumble(data.checked);
if(GameSettings::RumbleEnabled()){
Input::StartVibration();
@ -99,6 +107,7 @@ void Menu::InitializeSettingsWindow(){
}else{
Input::StopVibration();
}
}
return true;
},true)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;
@ -130,6 +139,27 @@ void Menu::InitializeSettingsWindow(){
fullscreenToggleLabel->Disable();
#endif
settingsWindow->ADD("Button Set Toggle Box",MenuIconButton)(geom2d::rect<float>{{windowSize.x/8.f,112},{windowSize.x/4.f,16.f}},GFX["themes/xb.png"].Decal(),[](MenuFuncData data){
switch(GameSettings::GetIconType()){
case IconType::XB:{
GameSettings::SetIconType(IconType::PS);
DYNAMIC_POINTER_CAST<MenuIconButton>(data.component)->SetIcon(GFX["themes/ps.png"].Decal());
}break;
case IconType::PS:{
GameSettings::SetIconType(IconType::XB_REVERSED);
DYNAMIC_POINTER_CAST<MenuIconButton>(data.component)->SetIcon(GFX["themes/xb_reversed.png"].Decal());
}break;
case IconType::XB_REVERSED:{
GameSettings::SetIconType(IconType::XB);
DYNAMIC_POINTER_CAST<MenuIconButton>(data.component)->SetIcon(GFX["themes/xb.png"].Decal());
}break;
default:{
ERR(std::format("WARNING! Unhandled icon type {}!",int(GameSettings::GetIconType())));
}
}
return true;
})END;
#pragma region Setup all input displays as keyboard controls.
//NOTE: We are shadowing code from InputKeyboardWindow! If at some point the retrival method for getting input displays changes, we likely will be changing the code here as well!
auto ChangeKeybindDisplayType=[&](InputType inputType){
@ -165,7 +195,7 @@ void Menu::InitializeSettingsWindow(){
return true;
},vf2d{1.5f,2.f})END;
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){
settingsWindow->ADD("Go Back",MenuComponent)(geom2d::rect<float>{vf2d{windowSize.x/2.f,windowSize.y-12}-vf2d{36,8},{72,12}},"Go Back",[](MenuFuncData data){
Menu::CloseMenu();
return true;
})END;
@ -205,16 +235,25 @@ void Menu::InitializeSettingsWindow(){
.right="Terrain Collision Boxes Checkbox",}},
{"Controller Rumble Checkbox",{
.up="Screen Shake Checkbox",
.down="Fullscreen Toggle Checkbox",
.down="Button Set Toggle Box",
.left="Keyboard Play Auto-Aim Checkbox",
.right="Keyboard Play Auto-Aim Checkbox",}},
{"Button Set Toggle Box",{
.up="Controller Rumble Checkbox",
.down="Keyboard Bindings Button",
.left="Fullscreen Toggle Checkbox",
.right="Fullscreen Toggle Checkbox",}},
{"Fullscreen Toggle Checkbox",{
.up="Keyboard Play Auto-Aim Checkbox",
.down="Keyboard Bindings Button",
.left="Controller Rumble Checkbox",
.right="Controller Rumble Checkbox",}},
.left="Button Set Toggle Box",
.right="Button Set Toggle Box",}},
{"Keyboard Bindings Button",{
#ifdef __EMSCRIPTEN__
.up="Button Set Toggle Box",
#else
.up="Fullscreen Toggle Checkbox",
#endif
.down="Controller Bindings Button",}},
{"Controller Bindings Button",{
.up="Keyboard Bindings Button",

@ -88,7 +88,7 @@ void SoundEffect::PlaySFX(const std::string_view eventName,const vf2d&pos){
float pitch=util::random(pitchDiff)+sfx.minPitch;
if(pos==CENTERED){
Audio::Engine().Play(operator""_SFX(sfx.filename.c_str(),sfx.filename.length()),sfx.vol*Audio::GetSFXVolume(),0.0f,pitch);
Audio::Engine().Play(operator""_SFX(sfx.filename.c_str(),sfx.filename.length()),sfx.vol*Audio::GetSFXVolume()*Audio::GetMuteMult(),0.0f,pitch);
}else{
const float soundActivationRange="Audio.Environmental Audio Activation Range"_F;
@ -97,7 +97,7 @@ void SoundEffect::PlaySFX(const std::string_view eventName,const vf2d&pos){
float distRatio=1-distanceFromPlayer/soundActivationRange; //0-1 where 1 is full volume.
float xDistRatio=(pos.x-game->GetPlayer()->GetX())/soundActivationRange; //0-1 where 1 is full volume.
float vol=distRatio*sfx.vol*Audio::GetSFXVolume();
float vol=distRatio*sfx.vol*Audio::GetSFXVolume()*Audio::GetMuteMult();
float pan=xDistRatio;
Audio::Engine().Play(operator""_SFX(sfx.filename.c_str(),sfx.filename.length()),vol,pan,pitch);
}

@ -53,8 +53,6 @@ void State_MainMenu::OnUserUpdate(AiL*game){
if(AiL::KEY_CONFIRM.Released()){
TitleScreen::Skip();
}
if(game->GetKey(W).bPressed)game->SetWindowPos({5200,60});
if(game->GetKey(S).bPressed)game->SetWindowSize({400,400});
};
void State_MainMenu::Draw(AiL*game){
TitleScreen::Draw();

@ -8,7 +8,7 @@ January 1st
- Track items used during a stage, on death, restore the loadout item quantities used.
- Toggle between Playstation / Xbox controller gamepad displays
- Rebind FACELEFT/FACERIGHT menu keys (as they are used constantly throughout menus and would need to be rebinded if the player wants). (Or make confirm/back not rebindable)
- Rebind FACELEFT/FACERIGHT menu keys
Open window to the correct position/size at the beginning of the game if possible.
@ -32,5 +32,3 @@ January 31st
- Auto aim causes retreat-type moves to aim away from the auto target, and prefer the direction the player's moving in.
- Condense stage track (loading times)
- If you enter the keyboard config menu and press a controller button, it cancels the request. If you enter the controller config menu and press a keyboard/mouse button, it also cancels the request.

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

@ -52,14 +52,21 @@ Images
GFX_AimingLine = aiming_line.png
GFX_Button_AnalogStick_Horz = themes/button_analogstick_horz.png
GFX_Button_AnalogStick_Vert = themes/button_analogstick_vert.png
GFX_Button_Face_Down = themes/button_d.png
GFX_Button_Face_Left = themes/button_l.png
GFX_Button_Face_Right = themes/button_r.png
GFX_Button_Face_Up = themes/button_u.png
GFX_Button_Face_Down = themes/button_d_xb.png
GFX_Button_Face_Left = themes/button_l_xb.png
GFX_Button_Face_Right = themes/button_r_xb.png
GFX_Button_Face_Up = themes/button_u_xb.png
GFX_Button_Face_Down2 = themes/button_d_ps.png
GFX_Button_Face_Left2 = themes/button_l_ps.png
GFX_Button_Face_Right2 = themes/button_r_ps.png
GFX_Button_Face_Up2 = themes/button_u_ps.png
GFX_Button_Face_L1 = themes/button_l1.png
GFX_Button_Face_L2 = themes/button_l2.png
GFX_Button_Face_R1 = themes/button_r1.png
GFX_Button_Face_R2 = themes/button_r2.png
GFX_Button_SetXB = themes/xb.png
GFX_Button_SetPS = themes/ps.png
GFX_Button_SetXB_Reversed = themes/xb_reversed.png
GFX_LMB = themes/lmb.png
GFX_RMB = themes/rmb.png
GFX_MMB = themes/mmb.png

@ -1,8 +1,8 @@
Inputs
{
Menu Input Names = Confirm, Back, Menu, Up, Right, Down, Left
Menu Input Names = Confirm, Back, Function 1, Function 2, Menu, Up, Right, Down, Left
Gameplay Input Names = Basic Attack, Ability 1, Ability 2, Ability 3, Ability 4, Defensive, Item 1, Item 2, Item 3
Gameplay Input Names = Basic Attack, Defensive, Ability 1, Ability 2, Ability 3, Ability 4, Item 1, Item 2, Item 3
KEY_CONFIRM = Confirm
@ -14,6 +14,8 @@ Inputs
KEY_DOWN=Down
KEY_MENU=Menu
KEY_BACK=Back
KEY_FACELEFT=Function 2
KEY_FACEUP=Function 1
Player::KEY_ABILITY1=Ability 1
Player::KEY_ABILITY2=Ability 2
Player::KEY_ABILITY3=Ability 3

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 685 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 695 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 799 B

Loading…
Cancel
Save