diff --git a/Adventures in Lestoria/Adventures in Lestoria.vcxproj b/Adventures in Lestoria/Adventures in Lestoria.vcxproj index a953d549..9a5e5d07 100644 --- a/Adventures in Lestoria/Adventures in Lestoria.vcxproj +++ b/Adventures in Lestoria/Adventures in Lestoria.vcxproj @@ -602,6 +602,10 @@ + + + + diff --git a/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters b/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters index 3cf88cf0..802feda9 100644 --- a/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters +++ b/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters @@ -791,6 +791,9 @@ Source Files\Interface + + Source Files\Interface + diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index e36caacc..75c5ba88 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -2459,17 +2459,17 @@ void AiL::InitializeDefaultKeybinds(){ Player::KEY_ITEM3.AddKeybind({CONTROLLER,static_cast(GPButtons::R3)}); KEY_ATTACK.AddKeybind({MOUSE,Mouse::LEFT}); KEY_ATTACK.AddKeybind({CONTROLLER,static_cast(GPButtons::L2)}); - KEY_LEFT.AddKeybind({KEY,LEFT}); KEY_LEFT.AddKeybind({KEY,A}); + KEY_LEFT.AddKeybind({KEY,LEFT}); KEY_LEFT.AddKeybind({CONTROLLER,static_cast(GPButtons::DPAD_L)}); - KEY_RIGHT.AddKeybind({KEY,RIGHT}); KEY_RIGHT.AddKeybind({KEY,D}); + KEY_RIGHT.AddKeybind({KEY,RIGHT}); KEY_RIGHT.AddKeybind({CONTROLLER,static_cast(GPButtons::DPAD_R)}); - KEY_UP.AddKeybind({KEY,UP}); KEY_UP.AddKeybind({KEY,W}); + KEY_UP.AddKeybind({KEY,UP}); KEY_UP.AddKeybind({CONTROLLER,static_cast(GPButtons::DPAD_U)}); - KEY_DOWN.AddKeybind({KEY,DOWN}); KEY_DOWN.AddKeybind({KEY,S}); + KEY_DOWN.AddKeybind({KEY,DOWN}); KEY_DOWN.AddKeybind({CONTROLLER,static_cast(GPButtons::DPAD_D)}); KEY_CONFIRM.AddKeybind({MOUSE,Mouse::LEFT}); KEY_CONFIRM.AddKeybind({CONTROLLER,static_cast(GPButtons::FACE_R)}); diff --git a/Adventures in Lestoria/InputKeyboardWindow.cpp b/Adventures in Lestoria/InputKeyboardWindow.cpp index 0d98a33c..c128de23 100644 --- a/Adventures in Lestoria/InputKeyboardWindow.cpp +++ b/Adventures in Lestoria/InputKeyboardWindow.cpp @@ -64,9 +64,9 @@ void Menu::InitializeKeyboardInputWindow(){ 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_{}_{} Background",row,col),MenuLabel)(geom2d::rect{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; - 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){ + inputKeyboardWindow->ADD(std::format("Input_{}_{} Input Displayer",row,col),InputDisplayComponent)(geom2d::rect{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){ return true; })END; } @@ -83,6 +83,7 @@ void Menu::InitializeKeyboardInputWindow(){ 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){ + Menu::OpenMenu(NEW_INPUT); return true; })END; } diff --git a/Adventures in Lestoria/InputNewKeybindWindow.cpp b/Adventures in Lestoria/InputNewKeybindWindow.cpp new file mode 100644 index 00000000..5c2d2793 --- /dev/null +++ b/Adventures in Lestoria/InputNewKeybindWindow.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 © 2024 The FreeType +Project (www.freetype.org). Please see LICENSE_FT.txt for more information. +All rights reserved. +*/ +#pragma endregion + +#include "Menu.h" +#include "MenuLabel.h" + +void Menu::InitializeNewKeybindInputWindow(){ + Menu*newKeybindWindow=CreateMenu(NEW_INPUT,CENTERED,vf2d{192,96}); + + newKeybindWindow->ADD("New Keybind Label",MenuLabel)(geom2d::rect{{0.f,24.f},{192.f,24.f}},"Press a new key for {}",2.f,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE|ComponentAttr::SHADOW)END; +} \ No newline at end of file diff --git a/Adventures in Lestoria/Menu.cpp b/Adventures in Lestoria/Menu.cpp index ed077250..4422463a 100644 --- a/Adventures in Lestoria/Menu.cpp +++ b/Adventures in Lestoria/Menu.cpp @@ -102,6 +102,7 @@ void Menu::InitializeMenus(){ InitializeShermanWindow(); InitializeKeyboardInputWindow(); InitializeControllerInputWindow(); + InitializeNewKeybindInputWindow(); for(MenuType type=MenuType(int(MenuType::ENUM_START)+1);type::max():rect.size.x,1.0f); + window.DrawShadowStringPropDecal(drawPos,label,WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits::max():rect.size.x-2,1.0f); }else{ - window.DrawShadowStringDecal(drawPos,label,WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits::max():rect.size.x,1.0f); + window.DrawShadowStringDecal(drawPos,label,WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits::max():rect.size.x-2,1.0f); } }else{ if(proportional){ - window.DrawStringPropDecal(drawPos,label,WHITE,adjustedScale,fitToLabel?std::numeric_limits::max():rect.size.x,1.0f); + window.DrawStringPropDecal(drawPos,label,WHITE,adjustedScale,fitToLabel?std::numeric_limits::max():rect.size.x-2,1.0f); }else{ - window.DrawStringDecal(drawPos,label,WHITE,adjustedScale,fitToLabel?std::numeric_limits::max():rect.size.x,1.0f); + window.DrawStringDecal(drawPos,label,WHITE,adjustedScale,fitToLabel?std::numeric_limits::max():rect.size.x-2,1.0f); } } } diff --git a/Adventures in Lestoria/MenuType.h b/Adventures in Lestoria/MenuType.h index eaad6e7b..8006e659 100644 --- a/Adventures in Lestoria/MenuType.h +++ b/Adventures in Lestoria/MenuType.h @@ -67,6 +67,7 @@ enum MenuType{ SHERMAN, INPUT_KEYBOARD, INPUT_CONTROLLER, + NEW_INPUT, /////////////////////////////////////////////////////////// /*DO NOT REMOVE!!*/ENUM_END//////////////////////////////// /////////////////////////////////////////////////////////// diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 70d86a72..04fe698b 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 3 #define VERSION_PATCH 0 -#define VERSION_BUILD 6812 +#define VERSION_BUILD 6836 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/olcPixelGameEngine.h b/Adventures in Lestoria/olcPixelGameEngine.h index 215aac68..81dea74b 100644 --- a/Adventures in Lestoria/olcPixelGameEngine.h +++ b/Adventures in Lestoria/olcPixelGameEngine.h @@ -3764,11 +3764,13 @@ namespace olc { planningMarker.x += 8.0f; if(planningMarker.x>adjustedWidth){ - if(drawingMarker.x==0){ //The text has overflowed a full line, so we have to dump the line. + if(drawingMarker.x==0){ //The text has overflowed a full line because there were no spaces, so we have to dump the line. drawingMarker.x+=lettersWidth; lettersWidth=0; - maxWidth=std::max(maxWidth,drawingMarker.x); + }else{ + drawingMarker.x-=vFontSpacing[' '-32].y; //Don't include the space in the sizing when wrapping. } + maxWidth=std::max(maxWidth,drawingMarker.x); planningMarker.x = 0; planningMarker.y += 8.0f; drawingMarker=planningMarker; wrappingOccurred=true; @@ -3913,6 +3915,8 @@ namespace olc drawingMarker.x += 8.0f * scale; } letters.clear(); + }else{ + drawingMarker.x-=vFontSpacing[' '-32].y*scale; //Don't include the space in the sizing when wrapping. } planningMarker.x = 0; planningMarker.y += 8.0f * scale; drawingMarker=planningMarker; @@ -3958,7 +3962,7 @@ namespace olc size.y *= 8; return size; } - + olc::vi2d PixelGameEngine::GetWrappedTextSizeProp(std::string_view s,const float width,const vf2d scale) { float adjustedWidth=width; @@ -4020,11 +4024,13 @@ namespace olc { planningMarker.x += vFontSpacing[c-32].y; if(planningMarker.x>adjustedWidth){ - if(drawingMarker.x==0){ //The text has overflowed a full line, so we have to dump the line. + if(drawingMarker.x==0){ //The text has overflowed a full line because there are no spaces, so we have to dump the line. drawingMarker.x+=lettersWidth; lettersWidth=0; - maxWidth=std::max(maxWidth,drawingMarker.x); + }else{ + drawingMarker.x-=vFontSpacing[' '-32].y; } + maxWidth=std::max(maxWidth,drawingMarker.x); planningMarker.x = 0; planningMarker.y += 8.0f; drawingMarker=planningMarker; wrappingOccurred=true; @@ -4143,6 +4149,8 @@ namespace olc drawingMarker.x += float(vFontSpacing[letter.c - 32].y) * scale; } letters.clear(); + }else{ + drawingMarker.x-=vFontSpacing[' '-32].y*scale; //Don't include the space in the sizing when wrapping. } planningMarker.x = 0; planningMarker.y += 8.0f * scale; drawingMarker=planningMarker;