Add in keyboard mapping display settings window. Add in keybind display buttons.

pull/35/head
sigonasr2 10 months ago
parent 407a105993
commit cd599b73e0
  1. 13
      Adventures in Lestoria/Adventures in Lestoria.vcxproj
  2. 15
      Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters
  3. 29
      Adventures in Lestoria/AdventuresInLestoria.cpp
  4. 1
      Adventures in Lestoria/AdventuresInLestoria.h
  5. BIN
      Adventures in Lestoria/C++ Header File (OLC-3).zip
  6. BIN
      Adventures in Lestoria/C++ Source File (OLC-3).zip
  7. 46
      Adventures in Lestoria/InputControllerWindow.cpp
  8. 54
      Adventures in Lestoria/InputDisplayComponent.h
  9. 90
      Adventures in Lestoria/InputKeyboardWindow.cpp
  10. 75
      Adventures in Lestoria/Key.cpp
  11. 7
      Adventures in Lestoria/Key.h
  12. 2
      Adventures in Lestoria/Menu.cpp
  13. 2
      Adventures in Lestoria/Menu.h
  14. 4
      Adventures in Lestoria/MenuType.h
  15. 2
      Adventures in Lestoria/NPC.cpp
  16. 4
      Adventures in Lestoria/SettingsWindow.cpp
  17. 15
      Adventures in Lestoria/TODO.txt
  18. 2
      Adventures in Lestoria/Version.h
  19. 3
      Adventures in Lestoria/assets/config/configuration.txt
  20. 25
      Adventures in Lestoria/assets/config/settings/input.txt
  21. BIN
      x64/Release/Adventures in Lestoria.exe

@ -351,6 +351,10 @@
</SubType> </SubType>
</ClInclude> </ClInclude>
<ClInclude Include="GameState.h" /> <ClInclude Include="GameState.h" />
<ClInclude Include="InputDisplayComponent.h">
<SubType>
</SubType>
</ClInclude>
<ClInclude Include="InputHelper.h"> <ClInclude Include="InputHelper.h">
<SubType> <SubType>
</SubType> </SubType>
@ -586,10 +590,18 @@
</SubType> </SubType>
</ClCompile> </ClCompile>
<ClCompile Include="GameState.cpp" /> <ClCompile Include="GameState.cpp" />
<ClCompile Include="InputControllerWindow.cpp">
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="InputHelper.cpp"> <ClCompile Include="InputHelper.cpp">
<SubType> <SubType>
</SubType> </SubType>
</ClCompile> </ClCompile>
<ClCompile Include="InputKeyboardWindow.cpp">
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="InventoryConsumableWindow.cpp" /> <ClCompile Include="InventoryConsumableWindow.cpp" />
<ClCompile Include="InventoryCreator.cpp"> <ClCompile Include="InventoryCreator.cpp">
<SubType> <SubType>
@ -749,6 +761,7 @@
<Text Include="assets\config\MonsterStrategies.txt" /> <Text Include="assets\config\MonsterStrategies.txt" />
<Text Include="assets\config\NPCs.txt" /> <Text Include="assets\config\NPCs.txt" />
<Text Include="assets\config\Player.txt" /> <Text Include="assets\config\Player.txt" />
<Text Include="assets\config\settings\input.txt" />
<Text Include="assets\config\shops\Chapter 1 Merchants.txt" /> <Text Include="assets\config\shops\Chapter 1 Merchants.txt" />
<Text Include="assets\config\shops\Chapter 2 Merchants.txt" /> <Text Include="assets\config\shops\Chapter 2 Merchants.txt" />
<Text Include="assets\config\shops\Chapter 3 Merchants.txt" /> <Text Include="assets\config\shops\Chapter 3 Merchants.txt" />

@ -85,6 +85,9 @@
<Filter Include="Configurations\Audio"> <Filter Include="Configurations\Audio">
<UniqueIdentifier>{c28287fa-b401-4715-b2f2-8ac1021d5ec9}</UniqueIdentifier> <UniqueIdentifier>{c28287fa-b401-4715-b2f2-8ac1021d5ec9}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Configurations\Setttings">
<UniqueIdentifier>{c90a78bc-c74d-4609-b758-69320d7741e5}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="olcPixelGameEngine.h"> <ClInclude Include="olcPixelGameEngine.h">
@ -447,6 +450,9 @@
<ClInclude Include="IT.h"> <ClInclude Include="IT.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="InputDisplayComponent.h">
<Filter>Header Files\Interface</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Player.cpp"> <ClCompile Include="Player.cpp">
@ -779,6 +785,12 @@
<ClCompile Include="IT.cpp"> <ClCompile Include="IT.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="InputKeyboardWindow.cpp">
<Filter>Source Files\Interface</Filter>
</ClCompile>
<ClCompile Include="InputControllerWindow.cpp">
<Filter>Source Files\Interface</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="cpp.hint" /> <None Include="cpp.hint" />
@ -930,6 +942,9 @@
<Text Include="assets\config\NPCs.txt"> <Text Include="assets\config\NPCs.txt">
<Filter>Configurations</Filter> <Filter>Configurations</Filter>
</Text> </Text>
<Text Include="assets\config\settings\input.txt">
<Filter>Configurations\Setttings</Filter>
</Text>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="assets\heart.ico"> <Image Include="assets\heart.ico">

@ -112,6 +112,7 @@ InputGroup AiL::KEY_SCROLLDOWN;
InputGroup AiL::KEY_BACK; InputGroup AiL::KEY_BACK;
InputGroup AiL::KEY_START; InputGroup AiL::KEY_START;
InputGroup AiL::KEY_SELECT; InputGroup AiL::KEY_SELECT;
InputGroup AiL::KEY_UNEQUIP;
InputGroup AiL::KEY_SCROLL; InputGroup AiL::KEY_SCROLL;
InputGroup AiL::KEY_CHANGE_LOADOUT; InputGroup AiL::KEY_CHANGE_LOADOUT;
@ -164,6 +165,9 @@ AiL::AiL()
std::string BACKDROP_CONFIG = CONFIG_PATH + "backdrop_config"_S; std::string BACKDROP_CONFIG = CONFIG_PATH + "backdrop_config"_S;
utils::datafile::Read(DATA,BACKDROP_CONFIG); utils::datafile::Read(DATA,BACKDROP_CONFIG);
std::string INPUT_CONFIG = CONFIG_PATH + "input_config"_S;
utils::datafile::Read(DATA,INPUT_CONFIG);
auto keys=DATA.GetProperty("ItemConfiguration"); auto keys=DATA.GetProperty("ItemConfiguration");
for(auto&[key,value]:keys){ for(auto&[key,value]:keys){
std::string config=DATA["ItemConfiguration"][key].GetString(); std::string config=DATA["ItemConfiguration"][key].GetString();
@ -2500,6 +2504,31 @@ void AiL::InitializeDefaultKeybinds(){
KEY_SCROLL.AddKeybind({ANALOG,static_cast<int>(GPAxes::LY)}); KEY_SCROLL.AddKeybind({ANALOG,static_cast<int>(GPAxes::LY)});
KEY_SCROLL.AddKeybind({ANALOG,static_cast<int>(GPAxes::RY)}); KEY_SCROLL.AddKeybind({ANALOG,static_cast<int>(GPAxes::RY)});
KEY_UNEQUIP.AddKeybind({KEY,R});
KEY_UNEQUIP.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::FACE_U)});
#define TieMenuNameToGroup(KEY_NAME) \
InputGroup::menuNamesToInputGroups[DATA["Inputs"][#KEY_NAME].GetString()]=&KEY_NAME;
TieMenuNameToGroup(KEY_CONFIRM)
TieMenuNameToGroup(KEY_ATTACK);
TieMenuNameToGroup(KEY_LEFT);
TieMenuNameToGroup(KEY_RIGHT);
TieMenuNameToGroup(KEY_UP);
TieMenuNameToGroup(KEY_DOWN);
TieMenuNameToGroup(KEY_MENU);
TieMenuNameToGroup(KEY_BACK);
TieMenuNameToGroup(Player::KEY_ABILITY1);
TieMenuNameToGroup(Player::KEY_ABILITY2);
TieMenuNameToGroup(Player::KEY_ABILITY3);
TieMenuNameToGroup(Player::KEY_ABILITY4);
TieMenuNameToGroup(Player::KEY_DEFENSIVE);
TieMenuNameToGroup(Player::KEY_ITEM1);
TieMenuNameToGroup(Player::KEY_ITEM2);
TieMenuNameToGroup(Player::KEY_ITEM3);
InputGroup::menuNamesToInputGroups.SetInitialized();
} }
void AiL::SetBossNameDisplay(std::string name,float time){ void AiL::SetBossNameDisplay(std::string name,float time){

@ -84,6 +84,7 @@ public:
static InputGroup KEY_UP; static InputGroup KEY_UP;
static InputGroup KEY_DOWN; static InputGroup KEY_DOWN;
static InputGroup KEY_MENU; static InputGroup KEY_MENU;
static InputGroup KEY_UNEQUIP;
static InputGroup KEY_START; static InputGroup KEY_START;
static InputGroup KEY_SELECT; static InputGroup KEY_SELECT;

@ -0,0 +1,46 @@
#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 © 2023 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#include "Menu.h"
#include "DEFINES.h"
INCLUDE_WINDOW_SIZE
void Menu::InitializeControllerInputWindow(){
Menu*inputKeyboardWindow=CreateMenu(INPUT_CONTROLLER,CENTERED,WINDOW_SIZE-vf2d{28,28});
}

@ -0,0 +1,54 @@
#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
#include "MenuComponent.h"
class InputDisplayComponent:public MenuComponent{
const InputGroup&input;
const InputType type;
public:
inline InputDisplayComponent(geom2d::rect<float>pos,InputGroup&input,InputType type,MenuFunc onClick)
:MenuComponent(pos,"",onClick,ButtonAttr::NONE),input(input),type(type){}
protected:
inline void DrawDecal(ViewPort&window,bool focused)override{
MenuComponent::DrawDecal(window,focused);
input.DrawInput(Menu::menus[parentMenu]->pos+vf2d{rect.middle().x,rect.bottom().end.y+1},""sv,255,type);
}
};

@ -0,0 +1,90 @@
#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 © 2023 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#include "Menu.h"
#include "DEFINES.h"
#include "MenuLabel.h"
#include "Key.h"
#include "InputDisplayComponent.h"
INCLUDE_WINDOW_SIZE
void Menu::InitializeKeyboardInputWindow(){
vf2d menuSize={WINDOW_SIZE.x-52.f,176.f};
Menu*inputKeyboardWindow=CreateMenu(INPUT_KEYBOARD,CENTERED,menuSize);
float inputWindowWidth=menuSize.x-8;
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,28},{menuSize.x-8,56.f}},"",1.f,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE)END;
for(int row=0;row<4;row++){
for(int col=0;col<2;col++){
if(col==1&&row==3)continue;
//Exclude the very last item because we only have 9 inputs to list.
int inputID=row*2+col;
std::string inputDisplayName="Inputs.Menu Input Names"_s[inputID];
inputKeyboardWindow->ADD(std::format("Input_{}_{} Background",row,col),MenuLabel)(geom2d::rect<float>{vf2d{4,32}+vf2d{inputWindowWidth/2.f*col,row*12.f},{inputWindowWidth/4.f,11.f}},inputDisplayName,1.f,ComponentAttr::FIT_TO_LABEL|ComponentAttr::SHADOW)END;
inputKeyboardWindow->ADD(std::format("Input_{}_{} Input Displayer",row,col),InputDisplayComponent)(geom2d::rect<float>{vf2d{4,32}+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){
return true;
})END;
}
}
inputKeyboardWindow->ADD("Controller Inputs Background",MenuLabel)(geom2d::rect<float>{{4,100},{menuSize.x-8,68.f}},"",1.f,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE)END;
for(int row=0;row<5;row++){
for(int col=0;col<2;col++){
if(col==1&&row==4)continue;
int inputID=row*2+col;
std::string inputDisplayName="Inputs.Gameplay Input Names"_s[inputID];
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;
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){
return true;
})END;
}
}
}

@ -45,6 +45,7 @@ INCLUDE_game
INCLUDE_GFX INCLUDE_GFX
bool Input::usingGamepad; bool Input::usingGamepad;
safemap<std::string,InputGroup*>InputGroup::menuNamesToInputGroups;
Input::Input(InputType type,int key) Input::Input(InputType type,int key)
:type(type),key(key){} :type(type),key(key){}
@ -241,15 +242,17 @@ std::string InputGroup::GetDisplayName(){
return combinationDisplay; return combinationDisplay;
} }
void InputGroup::DrawInput(const vf2d pos,const std::string_view displayText,const uint8_t alpha)const{ void InputGroup::DrawInputView(const vf2d pos,const std::string_view displayText,const uint8_t alpha,InputType type)const{
std::optional<Input>primaryKey; std::optional<Input>primaryKey;
if(Input::UsingGamepad())primaryKey=GetPrimaryKey(CONTROLLER); switch(type){
else if(Menu::UsingMouseNavigation())primaryKey=GetPrimaryKey(MOUSE); case CONTROLLER:primaryKey=GetPrimaryKey(CONTROLLER);break;
else primaryKey=GetPrimaryKey(KEY); case MOUSE:primaryKey=GetPrimaryKey(MOUSE);break;
default:primaryKey=GetPrimaryKey(KEY);break;
}
vf2d buttonImgSize{}; vf2d buttonImgSize{};
std::vector<std::variant<Decal*,std::string>>buttonImgs; std::vector<std::variant<Decal*,std::string>>buttonImgs;
if(displayText.length()>0&&primaryKey.has_value()){ if(primaryKey.has_value()){
if(primaryKey.value().HasIcon()){ if(primaryKey.value().HasIcon()){
buttonImgSize+=primaryKey.value().GetIcon().Sprite()->Size()+vf2d{"Interface.InputHelperSpacing"_F,"Interface.InputHelperSpacing"_F}; buttonImgSize+=primaryKey.value().GetIcon().Sprite()->Size()+vf2d{"Interface.InputHelperSpacing"_F,"Interface.InputHelperSpacing"_F};
buttonImgs.push_back(primaryKey.value().GetIcon().Decal()); buttonImgs.push_back(primaryKey.value().GetIcon().Decal());
@ -260,7 +263,6 @@ void InputGroup::DrawInput(const vf2d pos,const std::string_view displayText,con
} }
vf2d descriptionTextSize=game->GetTextSizeProp(displayText); vf2d descriptionTextSize=game->GetTextSizeProp(displayText);
vf2d offset=-((buttonImgSize+descriptionTextSize)/2.f); vf2d offset=-((buttonImgSize+descriptionTextSize)/2.f);
if(buttonImgs.size()!=1)ERR("WARNING! Did not have two elements when rendering input button group display! THIS SHOULD NOT BE HAPPENING!")
for(auto&button:buttonImgs){ for(auto&button:buttonImgs){
if(std::holds_alternative<Decal*>(button)){ if(std::holds_alternative<Decal*>(button)){
Decal*img=std::get<Decal*>(button); Decal*img=std::get<Decal*>(button);
@ -285,6 +287,67 @@ void InputGroup::DrawInput(const vf2d pos,const std::string_view displayText,con
} }
} }
void InputGroup::DrawInputView(const vf2d pos,const std::string_view displayText,const uint8_t alpha)const{
InputType primaryType;
if(Input::UsingGamepad())primaryType=CONTROLLER;
else if(Menu::UsingMouseNavigation())primaryType=MOUSE;
else primaryType=KEY;
DrawInputView(pos,displayText,alpha,primaryType);
}
void InputGroup::DrawInput(const vf2d pos,const std::string_view displayText,const uint8_t alpha,InputType type)const{
std::optional<Input>primaryKey;
switch(type){
case CONTROLLER:primaryKey=GetPrimaryKey(CONTROLLER);break;
case MOUSE:primaryKey=GetPrimaryKey(MOUSE);break;
default:primaryKey=GetPrimaryKey(KEY);break;
}
vf2d buttonImgSize{};
std::vector<std::variant<Decal*,std::string>>buttonImgs;
if(primaryKey.has_value()){
if(primaryKey.value().HasIcon()){
buttonImgSize+=primaryKey.value().GetIcon().Sprite()->Size()+vf2d{"Interface.InputHelperSpacing"_F,"Interface.InputHelperSpacing"_F};
buttonImgs.push_back(primaryKey.value().GetIcon().Decal());
}else{
buttonImgSize+=game->GetTextSizeProp(primaryKey.value().GetDisplayName())+vf2d{"Interface.InputHelperSpacing"_F,"Interface.InputHelperSpacing"_F};
buttonImgs.push_back(primaryKey.value().GetDisplayName());
}
}
vf2d descriptionTextSize=game->GetTextSizeProp(displayText);
vf2d offset=-((buttonImgSize+descriptionTextSize)/2.f);
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});
offset.x+=img->sprite->width+"Interface.InputHelperSpacing"_I;
}else
if(std::holds_alternative<std::string>(button)){
std::string label=std::get<std::string>(button);
vf2d textSize=game->GetTextSizeProp(label);
Pixel buttonBackCol="Interface.InputButtonBackCol"_Pixel;
Pixel buttonTextCol="Interface.InputButtonTextCol"_Pixel;
buttonBackCol.a=alpha;
buttonTextCol.a=alpha;
game->FillRectDecal(pos+offset+vf2d{-2.f,0.f},vf2d{textSize.x+4,textSize.y},buttonBackCol);
game->FillRectDecal(pos+offset+vf2d{-1.f,-1.f},vf2d{textSize.x+2,textSize.y},buttonBackCol);
game->FillRectDecal(pos+offset+vf2d{-1.f,0.f},vf2d{textSize.x+2,textSize.y+1.f},buttonBackCol);
game->DrawStringPropDecal(pos+offset+vf2d{0.f,0.f},label,buttonTextCol);
offset.x+=textSize.x+"Interface.InputHelperSpacing"_I;
}else [[unlikely]]ERR("WARNING! Hit a state where no data is inside of the button! THIS SHOULD NOT BE HAPPENING!");
game->DrawShadowStringPropDecal(pos+offset,displayText,{255,255,255,alpha},{0,0,0,alpha});
}
}
void InputGroup::DrawInput(const vf2d pos,const std::string_view displayText,const uint8_t alpha)const{
InputType primaryType;
if(Input::UsingGamepad())primaryType=CONTROLLER;
else if(Menu::UsingMouseNavigation())primaryType=MOUSE;
else primaryType=KEY;
DrawInput(pos,displayText,alpha,primaryType);
}
const bool Input::HasIcon()const{ const bool Input::HasIcon()const{
return GenericKey::keyLiteral.at({type,key}).iconName.length()>0; return GenericKey::keyLiteral.at({type,key}).iconName.length()>0;
} }

@ -40,6 +40,7 @@ All rights reserved.
#include <string> #include <string>
#include <map> #include <map>
#include "olcPixelGameEngine.h" #include "olcPixelGameEngine.h"
#include "safemap.h"
//Future-proof game controller support. //Future-proof game controller support.
enum InputType{ enum InputType{
@ -78,8 +79,11 @@ public:
}; };
class InputGroup{ class InputGroup{
friend class AiL;
friend class Menu;
std::set<Input>keys; std::set<Input>keys;
std::vector<Input>keyOrder; //A list of keys inserted in order, for primary key mapping. std::vector<Input>keyOrder; //A list of keys inserted in order, for primary key mapping.
static safemap<std::string,InputGroup*>menuNamesToInputGroups;
public: public:
InputGroup(); InputGroup();
void AddKeybind(Input bind); void AddKeybind(Input bind);
@ -90,7 +94,10 @@ public:
const float Analog()const; const float Analog()const;
std::string GetDisplayName(); std::string GetDisplayName();
//Draws an input display with accompanying text centered at given position. //Draws an input display with accompanying text centered at given position.
void DrawInputView(const vf2d pos,const std::string_view displayText,const uint8_t alpha)const;
void DrawInputView(const vf2d pos,const std::string_view displayText,const uint8_t alpha,const InputType type)const;
void DrawInput(const vf2d pos,const std::string_view displayText,const uint8_t alpha)const; void DrawInput(const vf2d pos,const std::string_view displayText,const uint8_t alpha)const;
void DrawInput(const vf2d pos,const std::string_view displayText,const uint8_t alpha,const InputType type)const;
const std::optional<Input>GetPrimaryKey(InputType type)const; const std::optional<Input>GetPrimaryKey(InputType type)const;
}; };

@ -100,6 +100,8 @@ void Menu::InitializeMenus(){
InitializeUserIDWindow(); InitializeUserIDWindow();
InitializeSettingsWindow(); InitializeSettingsWindow();
InitializeShermanWindow(); InitializeShermanWindow();
InitializeKeyboardInputWindow();
InitializeControllerInputWindow();
for(MenuType type=MenuType(int(MenuType::ENUM_START)+1);type<MenuType::ENUM_END;type=MenuType(int(type+1))){ for(MenuType type=MenuType(int(MenuType::ENUM_START)+1);type<MenuType::ENUM_END;type=MenuType(int(type+1))){
if(menus.count(type)==0){ if(menus.count(type)==0){

@ -112,6 +112,8 @@ class Menu:public IAttributable{
static void InitializeUserIDWindow(); static void InitializeUserIDWindow();
static void InitializeSettingsWindow(); static void InitializeSettingsWindow();
static void InitializeShermanWindow(); static void InitializeShermanWindow();
static void InitializeKeyboardInputWindow();
static void InitializeControllerInputWindow();
friend class AiL; friend class AiL;
friend class ItemInfo; friend class ItemInfo;

@ -37,6 +37,8 @@ All rights reserved.
#pragma endregion #pragma endregion
#pragma once #pragma once
#undef INPUT_KEYBOARD //Stupid Windows.
enum MenuType{ enum MenuType{
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
/*DO NOT REMOVE!!*/ENUM_START,/////////////////////////////// /*DO NOT REMOVE!!*/ENUM_START,///////////////////////////////
@ -63,6 +65,8 @@ enum MenuType{
USER_ID, USER_ID,
SETTINGS, SETTINGS,
SHERMAN, SHERMAN,
INPUT_KEYBOARD,
INPUT_CONTROLLER,
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
/*DO NOT REMOVE!!*/ENUM_END//////////////////////////////// /*DO NOT REMOVE!!*/ENUM_END////////////////////////////////
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////

@ -57,7 +57,7 @@ void Monster::STRATEGY::NPC(Monster&m,float fElapsedTime,std::string strategy){
vf2d nameTextSize=game->GetTextSizeProp(m.GetName()); vf2d nameTextSize=game->GetTextSizeProp(m.GetName());
uint8_t alpha=uint8_t(util::lerp(0.f,255.f,m.F(A::TARGET_TIMER)/ConfigFloat("Interaction Display Ease in Timer"))); uint8_t alpha=uint8_t(util::lerp(0.f,255.f,m.F(A::TARGET_TIMER)/ConfigFloat("Interaction Display Ease in Timer")));
game->view.DrawShadowStringPropDecal(m.GetPos()-vf2d{0,12}-nameTextSize/2.f,m.GetName(),{255,255,0},{0,0,0}); game->view.DrawShadowStringPropDecal(m.GetPos()-vf2d{0,12}-nameTextSize/2.f,m.GetName(),{255,255,0},{0,0,0});
game->KEY_CONFIRM.DrawInput(m.GetPos()+vf2d{ConfigFloatArr("Interaction Display Offset",0),ConfigFloatArr("Interaction Display Offset",1)},"Interact",alpha); game->KEY_CONFIRM.DrawInputView(m.GetPos()+vf2d{ConfigFloatArr("Interaction Display Offset",0),ConfigFloatArr("Interaction Display Offset",1)},"Interact",alpha);
}); });
} }
m.phase=1; m.phase=1;

@ -93,8 +93,8 @@ void Menu::InitializeSettingsWindow(){
},false)END; },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 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 Label",MenuComponent)(geom2d::rect<float>{{28,132.f},vf2d{windowSize.x-32,24}},"Keyboard Bindings",MenuType::ENUM_END,DO_NOTHING,vf2d{1.5f,2.f})END; settingsWindow->ADD("Keyboard Bindings Label",MenuComponent)(geom2d::rect<float>{{28,132.f},vf2d{windowSize.x-32,24}},"Keyboard Bindings",MenuType::INPUT_KEYBOARD,DO_NOTHING,vf2d{1.5f,2.f})END;
settingsWindow->ADD("Controller Bindings Label",MenuComponent)(geom2d::rect<float>{{28,160.f},vf2d{windowSize.x-32,24}},"Controller Bindings",MenuType::ENUM_END,DO_NOTHING,vf2d{1.5f,2.f})END; settingsWindow->ADD("Controller Bindings Label",MenuComponent)(geom2d::rect<float>{{28,160.f},vf2d{windowSize.x-32,24}},"Controller Bindings",MenuType::INPUT_CONTROLLER,DO_NOTHING,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){ 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(); Menu::CloseMenu();

@ -11,6 +11,21 @@ Settings Menu
remove that bind from the list. Up to two keys may be binded per action. remove that bind from the list. Up to two keys may be binded per action.
-We have to save keybinds to the save file. -We have to save keybinds to the save file.
Menu Inputs
- Confirm
- Back
- Menu
- Change Loadout (Overworld Map)
- Unequip
- Left
- Right
- Up
- Down
Gameplay Inputs
- Ability 1,2,3,4
- Item 1,2,3
- Basic Attack
- XP Bar - XP Bar

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

@ -83,6 +83,9 @@ event_config = audio/events.txt
# Path to interface configuration # Path to interface configuration
interface_config = Interface.txt interface_config = Interface.txt
# Path to Keyboard Input configuration
input_config = settings/input.txt
# Path to character images # Path to character images
character_image_location = characters/commercial_assets/ character_image_location = characters/commercial_assets/

@ -0,0 +1,25 @@
Inputs
{
Menu Input Names = Confirm, Back, 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
KEY_CONFIRM = Confirm
KEY_ATTACK = Basic Attack
KEY_LEFT=Left
KEY_RIGHT=Right
KEY_UP=Up
KEY_DOWN=Down
KEY_MENU=Menu
KEY_BACK=Back
Player::KEY_ABILITY1=Ability 1
Player::KEY_ABILITY2=Ability 2
Player::KEY_ABILITY3=Ability 3
Player::KEY_ABILITY4=Ability 4
Player::KEY_DEFENSIVE=Defensive
Player::KEY_ITEM1=Item 1
Player::KEY_ITEM2=Item 2
Player::KEY_ITEM3=Item 3
}
Loading…
Cancel
Save