diff --git a/Adventures in Lestoria/Adventures in Lestoria.vcxproj b/Adventures in Lestoria/Adventures in Lestoria.vcxproj
index 21190f13..a953d549 100644
--- a/Adventures in Lestoria/Adventures in Lestoria.vcxproj
+++ b/Adventures in Lestoria/Adventures in Lestoria.vcxproj
@@ -351,6 +351,10 @@
+
+
+
+
@@ -586,10 +590,18 @@
+
+
+
+
+
+
+
+
@@ -749,6 +761,7 @@
+
diff --git a/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters b/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters
index a4884c87..3cf88cf0 100644
--- a/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters
+++ b/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters
@@ -85,6 +85,9 @@
{c28287fa-b401-4715-b2f2-8ac1021d5ec9}
+
+ {c90a78bc-c74d-4609-b758-69320d7741e5}
+
@@ -447,6 +450,9 @@
Header Files
+
+ Header Files\Interface
+
@@ -779,6 +785,12 @@
Source Files
+
+ Source Files\Interface
+
+
+ Source Files\Interface
+
@@ -930,6 +942,9 @@
Configurations
+
+ Configurations\Setttings
+
diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp
index f1c83335..e36caacc 100644
--- a/Adventures in Lestoria/AdventuresInLestoria.cpp
+++ b/Adventures in Lestoria/AdventuresInLestoria.cpp
@@ -112,6 +112,7 @@ InputGroup AiL::KEY_SCROLLDOWN;
InputGroup AiL::KEY_BACK;
InputGroup AiL::KEY_START;
InputGroup AiL::KEY_SELECT;
+InputGroup AiL::KEY_UNEQUIP;
InputGroup AiL::KEY_SCROLL;
InputGroup AiL::KEY_CHANGE_LOADOUT;
@@ -164,6 +165,9 @@ AiL::AiL()
std::string BACKDROP_CONFIG = CONFIG_PATH + "backdrop_config"_S;
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");
for(auto&[key,value]:keys){
std::string config=DATA["ItemConfiguration"][key].GetString();
@@ -2500,6 +2504,31 @@ void AiL::InitializeDefaultKeybinds(){
KEY_SCROLL.AddKeybind({ANALOG,static_cast(GPAxes::LY)});
KEY_SCROLL.AddKeybind({ANALOG,static_cast(GPAxes::RY)});
+
+ KEY_UNEQUIP.AddKeybind({KEY,R});
+ KEY_UNEQUIP.AddKeybind({CONTROLLER,static_cast(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){
diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h
index 976daa14..7ad537ed 100644
--- a/Adventures in Lestoria/AdventuresInLestoria.h
+++ b/Adventures in Lestoria/AdventuresInLestoria.h
@@ -84,6 +84,7 @@ public:
static InputGroup KEY_UP;
static InputGroup KEY_DOWN;
static InputGroup KEY_MENU;
+ static InputGroup KEY_UNEQUIP;
static InputGroup KEY_START;
static InputGroup KEY_SELECT;
diff --git a/Adventures in Lestoria/C++ Header File (OLC-3).zip b/Adventures in Lestoria/C++ Header File (OLC-3).zip
index 06791b1a..3328c346 100644
Binary files a/Adventures in Lestoria/C++ Header File (OLC-3).zip and b/Adventures in Lestoria/C++ Header File (OLC-3).zip differ
diff --git a/Adventures in Lestoria/C++ Source File (OLC-3).zip b/Adventures in Lestoria/C++ Source File (OLC-3).zip
index 30df570c..797cc85a 100644
Binary files a/Adventures in Lestoria/C++ Source File (OLC-3).zip and b/Adventures in Lestoria/C++ Source File (OLC-3).zip differ
diff --git a/Adventures in Lestoria/InputControllerWindow.cpp b/Adventures in Lestoria/InputControllerWindow.cpp
new file mode 100644
index 00000000..dfb120d8
--- /dev/null
+++ b/Adventures in Lestoria/InputControllerWindow.cpp
@@ -0,0 +1,46 @@
+#pragma region License
+/*
+License (OLC-3)
+~~~~~~~~~~~~~~~
+
+Copyright 2024 Joshua Sigona
+
+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});
+}
\ No newline at end of file
diff --git a/Adventures in Lestoria/InputDisplayComponent.h b/Adventures in Lestoria/InputDisplayComponent.h
new file mode 100644
index 00000000..0e24ae04
--- /dev/null
+++ b/Adventures in Lestoria/InputDisplayComponent.h
@@ -0,0 +1,54 @@
+#pragma region License
+/*
+License (OLC-3)
+~~~~~~~~~~~~~~~
+
+Copyright 2024 Joshua Sigona
+
+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::rectpos,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);
+ }
+};
\ No newline at end of file
diff --git a/Adventures in Lestoria/InputKeyboardWindow.cpp b/Adventures in Lestoria/InputKeyboardWindow.cpp
new file mode 100644
index 00000000..d465834b
--- /dev/null
+++ b/Adventures in Lestoria/InputKeyboardWindow.cpp
@@ -0,0 +1,90 @@
+#pragma region License
+/*
+License (OLC-3)
+~~~~~~~~~~~~~~~
+
+Copyright 2024 Joshua Sigona
+
+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{{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{{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{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{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{{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{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{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;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Adventures in Lestoria/Key.cpp b/Adventures in Lestoria/Key.cpp
index 526ca5de..f921531c 100644
--- a/Adventures in Lestoria/Key.cpp
+++ b/Adventures in Lestoria/Key.cpp
@@ -45,6 +45,7 @@ INCLUDE_game
INCLUDE_GFX
bool Input::usingGamepad;
+safemapInputGroup::menuNamesToInputGroups;
Input::Input(InputType type,int key)
:type(type),key(key){}
@@ -241,15 +242,17 @@ std::string InputGroup::GetDisplayName(){
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::optionalprimaryKey;
- if(Input::UsingGamepad())primaryKey=GetPrimaryKey(CONTROLLER);
- else if(Menu::UsingMouseNavigation())primaryKey=GetPrimaryKey(MOUSE);
- else primaryKey=GetPrimaryKey(KEY);
-
+ switch(type){
+ case CONTROLLER:primaryKey=GetPrimaryKey(CONTROLLER);break;
+ case MOUSE:primaryKey=GetPrimaryKey(MOUSE);break;
+ default:primaryKey=GetPrimaryKey(KEY);break;
+ }
+
vf2d buttonImgSize{};
std::vector>buttonImgs;
- if(displayText.length()>0&&primaryKey.has_value()){
+ 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());
@@ -260,7 +263,6 @@ void InputGroup::DrawInput(const vf2d pos,const std::string_view displayText,con
}
vf2d descriptionTextSize=game->GetTextSizeProp(displayText);
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){
if(std::holds_alternative(button)){
Decal*img=std::get(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::optionalprimaryKey;
+ switch(type){
+ case CONTROLLER:primaryKey=GetPrimaryKey(CONTROLLER);break;
+ case MOUSE:primaryKey=GetPrimaryKey(MOUSE);break;
+ default:primaryKey=GetPrimaryKey(KEY);break;
+ }
+
+ vf2d buttonImgSize{};
+ std::vector>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(button)){
+ Decal*img=std::get(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(button)){
+ std::string label=std::get(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{
return GenericKey::keyLiteral.at({type,key}).iconName.length()>0;
}
diff --git a/Adventures in Lestoria/Key.h b/Adventures in Lestoria/Key.h
index 3b11b78e..c9865a98 100644
--- a/Adventures in Lestoria/Key.h
+++ b/Adventures in Lestoria/Key.h
@@ -40,6 +40,7 @@ All rights reserved.
#include
#include