Added new input keybind menu. Fixed MenuLabels to account for the 2 pixel border in width when rendering menu labels. Also corrected minor bugs with spaces being counted in wrapped text string lengths.
This commit is contained in:
parent
a6d2765585
commit
d576e6143e
@ -602,6 +602,10 @@
|
||||
<SubType>
|
||||
</SubType>
|
||||
</ClCompile>
|
||||
<ClCompile Include="InputNewKeybindWindow.cpp">
|
||||
<SubType>
|
||||
</SubType>
|
||||
</ClCompile>
|
||||
<ClCompile Include="InventoryConsumableWindow.cpp" />
|
||||
<ClCompile Include="InventoryCreator.cpp">
|
||||
<SubType>
|
||||
|
||||
@ -791,6 +791,9 @@
|
||||
<ClCompile Include="InputControllerWindow.cpp">
|
||||
<Filter>Source Files\Interface</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="InputNewKeybindWindow.cpp">
|
||||
<Filter>Source Files\Interface</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="cpp.hint" />
|
||||
|
||||
@ -2459,17 +2459,17 @@ void AiL::InitializeDefaultKeybinds(){
|
||||
Player::KEY_ITEM3.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::R3)});
|
||||
KEY_ATTACK.AddKeybind({MOUSE,Mouse::LEFT});
|
||||
KEY_ATTACK.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::L2)});
|
||||
KEY_LEFT.AddKeybind({KEY,LEFT});
|
||||
KEY_LEFT.AddKeybind({KEY,A});
|
||||
KEY_LEFT.AddKeybind({KEY,LEFT});
|
||||
KEY_LEFT.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::DPAD_L)});
|
||||
KEY_RIGHT.AddKeybind({KEY,RIGHT});
|
||||
KEY_RIGHT.AddKeybind({KEY,D});
|
||||
KEY_RIGHT.AddKeybind({KEY,RIGHT});
|
||||
KEY_RIGHT.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::DPAD_R)});
|
||||
KEY_UP.AddKeybind({KEY,UP});
|
||||
KEY_UP.AddKeybind({KEY,W});
|
||||
KEY_UP.AddKeybind({KEY,UP});
|
||||
KEY_UP.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::DPAD_U)});
|
||||
KEY_DOWN.AddKeybind({KEY,DOWN});
|
||||
KEY_DOWN.AddKeybind({KEY,S});
|
||||
KEY_DOWN.AddKeybind({KEY,DOWN});
|
||||
KEY_DOWN.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::DPAD_D)});
|
||||
KEY_CONFIRM.AddKeybind({MOUSE,Mouse::LEFT});
|
||||
KEY_CONFIRM.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::FACE_R)});
|
||||
|
||||
@ -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<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_{}_{} 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;
|
||||
|
||||
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){
|
||||
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){
|
||||
return true;
|
||||
})END;
|
||||
}
|
||||
@ -83,6 +83,7 @@ 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;
|
||||
|
||||
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::OpenMenu(NEW_INPUT);
|
||||
return true;
|
||||
})END;
|
||||
}
|
||||
|
||||
46
Adventures in Lestoria/InputNewKeybindWindow.cpp
Normal file
46
Adventures in Lestoria/InputNewKeybindWindow.cpp
Normal file
@ -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 © 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<float>{{0.f,24.f},{192.f,24.f}},"Press a new key for {}",2.f,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE|ComponentAttr::SHADOW)END;
|
||||
}
|
||||
@ -102,6 +102,7 @@ void Menu::InitializeMenus(){
|
||||
InitializeShermanWindow();
|
||||
InitializeKeyboardInputWindow();
|
||||
InitializeControllerInputWindow();
|
||||
InitializeNewKeybindInputWindow();
|
||||
|
||||
for(MenuType type=MenuType(int(MenuType::ENUM_START)+1);type<MenuType::ENUM_END;type=MenuType(int(type+1))){
|
||||
if(menus.count(type)==0){
|
||||
|
||||
@ -114,6 +114,7 @@ class Menu:public IAttributable{
|
||||
static void InitializeShermanWindow();
|
||||
static void InitializeKeyboardInputWindow();
|
||||
static void InitializeControllerInputWindow();
|
||||
static void InitializeNewKeybindInputWindow();
|
||||
|
||||
friend class AiL;
|
||||
friend class ItemInfo;
|
||||
|
||||
@ -100,15 +100,15 @@ protected:
|
||||
|
||||
if(shadow){
|
||||
if(proportional){
|
||||
window.DrawShadowStringPropDecal(drawPos,label,WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x,1.0f);
|
||||
window.DrawShadowStringPropDecal(drawPos,label,WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-2,1.0f);
|
||||
}else{
|
||||
window.DrawShadowStringDecal(drawPos,label,WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x,1.0f);
|
||||
window.DrawShadowStringDecal(drawPos,label,WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-2,1.0f);
|
||||
}
|
||||
}else{
|
||||
if(proportional){
|
||||
window.DrawStringPropDecal(drawPos,label,WHITE,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x,1.0f);
|
||||
window.DrawStringPropDecal(drawPos,label,WHITE,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-2,1.0f);
|
||||
}else{
|
||||
window.DrawStringDecal(drawPos,label,WHITE,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x,1.0f);
|
||||
window.DrawStringDecal(drawPos,label,WHITE,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-2,1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,6 +67,7 @@ enum MenuType{
|
||||
SHERMAN,
|
||||
INPUT_KEYBOARD,
|
||||
INPUT_CONTROLLER,
|
||||
NEW_INPUT,
|
||||
///////////////////////////////////////////////////////////
|
||||
/*DO NOT REMOVE!!*/ENUM_END////////////////////////////////
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user