Added ability to set controller keybinds. Fixed initial loading of save data when no metadata file is detected or present for online builds. Fixed "Online Character" checkbox being desynced when selecting the Online character mode, enabling online mode. Display context-sensitive messages for setting keys depending on whether we are in keyboard mode or controller mode. Release build 6866.

pull/35/head
sigonasr2 1 year ago
parent 3fff17417e
commit 4015f485ea
  1. 4
      Adventures in Lestoria/Adventures in Lestoria.vcxproj
  2. 4
      Adventures in Lestoria/Checkbox.h
  3. 3
      Adventures in Lestoria/InputDisplayComponent.h
  4. 21
      Adventures in Lestoria/InputKeyboardWindow.cpp
  5. 14
      Adventures in Lestoria/Key.cpp
  6. 7
      Adventures in Lestoria/SaveFile.cpp
  7. 39
      Adventures in Lestoria/SettingsWindow.cpp
  8. 2
      Adventures in Lestoria/TODO.txt
  9. 2
      Adventures in Lestoria/Version.h
  10. 7
      Adventures in Lestoria/olcPGEX_Gamepad.h
  11. 2
      emscripten_build.ps1
  12. 2
      emscripten_debug_build.ps1
  13. BIN
      x64/Release/Adventures in Lestoria.exe

@ -163,7 +163,7 @@
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalIncludeDirectories>C:\Users\sigon\source\repos\AdventuresInLestoria\Adventures in Lestoria\discord-files;C:\Users\sigon\OneDrive\Documents\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/MP8 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/MP20 %(AdditionalOptions)</AdditionalOptions>
<TreatSpecificWarningsAsErrors>4099;5030;4715;4172;4834</TreatSpecificWarningsAsErrors>
</ClCompile>
<Link>
@ -189,7 +189,7 @@
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions>/MP8 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/MP20 %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>C:\Users\sigon\source\repos\AdventuresInLestoria\Adventures in Lestoria\discord-files;C:\Users\sigon\OneDrive\Documents\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>

@ -63,6 +63,10 @@ public:
return checked;
}
inline void SetChecked(bool checked){
this->checked=checked;
}
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});
geom2d::line<float>checkmarkLine2=geom2d::line<float>(checkmarkLine1.end,{rect.left().start.x+rect.size.x*0.875f,rect.top().start.y+rect.size.y*0.25f});

@ -48,6 +48,9 @@ public:
inline void SetKeyType(const InputType type){
this->type=type;
}
inline const InputType GetType()const{
return type;
}
protected:
inline void DrawDecal(ViewPort&window,bool focused)override{
MenuComponent::DrawDecal(window,focused);

@ -41,6 +41,7 @@ All rights reserved.
#include "MenuLabel.h"
#include "Key.h"
#include "InputDisplayComponent.h"
#include "olcPGEX_Gamepad.h"
using A=Attribute;
@ -72,10 +73,16 @@ void Menu::InitializeKeyboardInputWindow(){
inputKeyboardWindow->ADD(std::format("Input_{}_{} Background",row,col),MenuLabel)(geom2d::rect<float>{vf2d{4,36}+vf2d{inputWindowWidth/2.f*col,row*12.f},{inputWindowWidth/4.f,11.f}},inputDisplayName,1.f,ComponentAttr::FIT_TO_LABEL|ComponentAttr::SHADOW)END;
auto inputChangeButton=inputKeyboardWindow->ADD(std::format("Input_{}_{} Input Displayer",row,col),InputDisplayComponent)(geom2d::rect<float>{vf2d{4,36}+vf2d{inputWindowWidth/2.f*col,row*12.f}+vf2d{inputWindowWidth/4.f,-1.f},vf2d{inputWindowWidth/4.f,11.f}},*InputGroup::menuNamesToInputGroups[inputDisplayName],InputType::KEY,[](MenuFuncData data){
Menu::menus[NEW_INPUT]->B(A::IS_KEYBOARD)=true;
Menu::menus[NEW_INPUT]->B(A::IS_KEYBOARD)=DYNAMIC_POINTER_CAST<InputDisplayComponent>(data.component)->GetType()==InputType::KEY;
std::string keybindName=data.component.lock()->S(A::KEYBIND);
Menu::menus[NEW_INPUT]->S(A::KEYBIND)=keybindName;
Component<MenuLabel>(NEW_INPUT,"New Keybind Label")->SetLabel(std::format("Press a new key for '{}'\n\nPress Esc to cancel.",keybindName));
std::string cancelButtonDisplayName=GenericKey::keyLiteral[{KEY,ESCAPE}].displayName;
std::string keyTypeName="key";
if(!Menu::menus[NEW_INPUT]->B(A::IS_KEYBOARD)){ //Check if this is for a controller instead.
cancelButtonDisplayName=GenericKey::keyLiteral[{CONTROLLER,static_cast<int>(GPButtons::SELECT)}].displayName;
keyTypeName="button";
}
Component<MenuLabel>(NEW_INPUT,"New Keybind Label")->SetLabel(std::format("Press a new {} for '{}'\n\nPress {} to cancel.",keyTypeName,keybindName,cancelButtonDisplayName));
Menu::OpenMenu(NEW_INPUT);
return true;
})END;
@ -97,10 +104,16 @@ void Menu::InitializeKeyboardInputWindow(){
inputKeyboardWindow->ADD(std::format("GameplayInput_{}_{} Background",row,col),MenuLabel)(geom2d::rect<float>{vf2d{4,104}+vf2d{inputWindowWidth/2.f*col,row*12.f},{inputWindowWidth/4.f,11.f}},inputDisplayName,1.f,ComponentAttr::FIT_TO_LABEL|ComponentAttr::SHADOW)END;
auto inputChangeButton=inputKeyboardWindow->ADD(std::format("Input_{}_{} Gameplay Input Displayer",row,col),InputDisplayComponent)(geom2d::rect<float>{vf2d{4,104}+vf2d{inputWindowWidth/2.f*col,row*12.f}+vf2d{inputWindowWidth/4.f,-1.f},vf2d{inputWindowWidth/4.f,11.f}},*InputGroup::menuNamesToInputGroups[inputDisplayName],InputType::KEY,[](MenuFuncData data){
Menu::menus[NEW_INPUT]->B(A::IS_KEYBOARD)=true;
Menu::menus[NEW_INPUT]->B(A::IS_KEYBOARD)=DYNAMIC_POINTER_CAST<InputDisplayComponent>(data.component)->GetType()==InputType::KEY;
std::string keybindName=data.component.lock()->S(A::KEYBIND);
Menu::menus[NEW_INPUT]->S(A::KEYBIND)=keybindName;
Component<MenuLabel>(NEW_INPUT,"New Keybind Label")->SetLabel(std::format("Press a new key for '{}'\n\nPress Esc to cancel.",keybindName));
std::string cancelButtonDisplayName=GenericKey::keyLiteral[{KEY,ESCAPE}].displayName;
std::string keyTypeName="key";
if(!Menu::menus[NEW_INPUT]->B(A::IS_KEYBOARD)){ //Check if this is for a controller instead.
cancelButtonDisplayName=GenericKey::keyLiteral[{CONTROLLER,static_cast<int>(GPButtons::SELECT)}].displayName;
keyTypeName="button";
}
Component<MenuLabel>(NEW_INPUT,"New Keybind Label")->SetLabel(std::format("Press a new {} for '{}'\n\nPress {} to cancel.",keyTypeName,keybindName,cancelButtonDisplayName));
Menu::OpenMenu(NEW_INPUT);
return true;
})END;

@ -266,7 +266,17 @@ void InputGroup::DrawInput(const std::variant<AiL*const,TileTransformedView*cons
for(auto&button:buttonImgs){
if(std::holds_alternative<Decal*>(button)){
Decal*img=std::get<Decal*>(button);
game->view.DrawDecal(pos+offset,img,{1.f,1.f},{255,255,255,alpha});
#pragma region Render Macro
#define Render(rendererType) \
std::get<rendererType*const>(renderer)->DrawDecal(pos+offset,img,{1.f,1.f},{255,255,255,alpha});
#pragma endregion
if(std::holds_alternative<AiL*const>(renderer)){
Render(AiL);
}else
if(std::holds_alternative<TileTransformedView*const>(renderer)){
Render(TileTransformedView);
}
offset.x+=img->sprite->width+"Interface.InputHelperSpacing"_I;
}else
if(std::holds_alternative<std::string>(button)){
@ -564,7 +574,7 @@ void InputListener::Update(){
for(GamePad*gamepad:GamePad::getGamepads()){
for(size_t button=0;bool hasButton:gamepad->availableButtons){
GPButtons releasedButton=olc::GPButtons(button);
if(hasButton&&gamepad->getButton(releasedButton).bReleased){
if(gamepad->getButton(releasedButton).bReleased){
if(releasedButton==GPButtons::SELECT){ //If we hit select we don't bother with setting the input and leave immediately.
Menu::CloseMenu();
return;

@ -45,6 +45,7 @@ All rights reserved.
#include "ClassInfo.h"
#include "ScrollableWindowComponent.h"
#include "LoadFileButton.h"
#include "Checkbox.h"
INCLUDE_game
@ -318,7 +319,9 @@ const void SaveFile::SetSaveFileOfflineID_TransitionToOverworldMap(){
SaveFile::saveFileID=saveFileCount;
GameState::ChangeState(States::OVERWORLD_MAP);
},[](void*arg){
std::cout<<"Failed to load metadata!"<<std::endl;
std::cout<<"Failed to load metadata! Initializing as save file 0."<<std::endl;
SaveFile::saveFileID=0; //Since we couldn't find metadata, we are assuming we start at save file 0.
GameState::ChangeState(States::OVERWORLD_MAP);
});
#else
ERR("WARNING! Calling wrong save file ID setting function! Use SetSaveFileID() instead!")
@ -405,6 +408,7 @@ const void SaveFile::UpdateSaveGameData(std::function<void()>afterSaveGameDataUp
SaveFile::afterSaveGameDataUpdate();
},[](void*arg){
std::cout<<"Failed to load metadata!"<<std::endl;
SaveFile::afterSaveGameDataUpdate();
});
#endif
};
@ -536,4 +540,5 @@ const bool SaveFile::IsOnline(){
void SaveFile::SetOnlineMode(bool online){
onlineMode=online;
Component<Checkbox>(CLASS_SELECTION,"Online Character Checkbox")->SetChecked(onlineMode);
}

@ -47,6 +47,7 @@ All rights reserved.
#include "MenuLabel.h"
#include "Slider.h"
#include "Checkbox.h"
#include "InputDisplayComponent.h"
INCLUDE_DATA
INCLUDE_game
@ -92,9 +93,41 @@ void Menu::InitializeSettingsWindow(){
return true;
},false)END;
settingsWindow->ADD("Keyboard Play Auto-Aim Label",MenuLabel)(geom2d::rect<float>{{windowSize.x/2-68.f,104},{windowSize.x/2+54.f,16.f}},"Keyboard Aim Assist\n (For Keyboard Only Players)",1.f,ComponentAttr::SHADOW)END;
settingsWindow->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect<float>{{28,132.f},vf2d{windowSize.x-32,24}},"Keyboard Bindings",MenuType::INPUT_KEY_DISPLAY,DO_NOTHING,vf2d{1.5f,2.f})END;
settingsWindow->ADD("Controller Bindings Button",MenuComponent)(geom2d::rect<float>{{28,160.f},vf2d{windowSize.x-32,24}},"Controller Bindings",MenuType::INPUT_KEY_DISPLAY,DO_NOTHING,vf2d{1.5f,2.f})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){
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++){
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.
Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Input Displayer",row,col))->SetKeyType(inputType);
}
}
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++){
for(int col=0;col<ingameControlsColCount;col++){
if(DATA.GetProperty("Inputs.Gameplay Input Names").GetValueCount()%2==1&&col==1&&row==ingameControlsRowCount-1)continue; //We only continue on a blank space when we have an odd number of elements.
Component<InputDisplayComponent>(INPUT_KEY_DISPLAY,std::format("Input_{}_{} Gameplay Input Displayer",row,col))->SetKeyType(inputType);
}
}
};
#pragma endregion
settingsWindow->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect<float>{{28,132.f},vf2d{windowSize.x-32,24}},"Keyboard Bindings",MenuType::ENUM_END,[&](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,160.f},vf2d{windowSize.x-32,24}},"Controller Bindings",MenuType::ENUM_END,[&](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,16},{72,12}},"Go Back",[](MenuFuncData data){
Menu::CloseMenu();

@ -62,3 +62,5 @@ Story proofreading/correcting/storyboarding
- Icon displays / Proper key displays above skill keys
- Auto aim causes retreat-type moves to aim away from the auto target, and prefer the direction the player's moving in.
- Save window position and size

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

@ -234,9 +234,14 @@ namespace olc {
float axes[GP_AXIS_COUNT]{0};
olc::HWButton buttons[GP_BUTTON_COUNT];
bool ff = false;
#ifdef __EMSCRIPTEN__
public:
#endif
bool availableButtons[GP_BUTTON_COUNT] = {false};
bool availableAxes[GP_AXIS_COUNT] = {false};
#ifdef __EMSCRIPTEN__
private:
#endif
float deadZone=0.2f;
float deadZoneOuter=0.2f;

@ -1,3 +1,3 @@
clear
emcmake cmake -DCMAKE_BUILD_TYPE=Release .
cmake --build . -j 8
cmake --build . -j 20

@ -1,3 +1,3 @@
clear
emcmake cmake -DCMAKE_BUILD_TYPE=Debug -D_DEBUG=1 .
cmake --build . -j 8
cmake --build . -j 20
Loading…
Cancel
Save