Remove Resume input helper on the death menu. Add multi-line centering label support. Add credits configuration and credits menu to the game. Release Build 7841. Push game Version to 0.4.

mac-build
sigonasr2 9 months ago
parent a803531a4d
commit 3145bef2cc
  1. 9
      Adventures in Lestoria/Adventures in Lestoria.vcxproj
  2. 9
      Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters
  3. 3
      Adventures in Lestoria/AdventuresInLestoria.cpp
  4. 89
      Adventures in Lestoria/CreditsWindow.cpp
  5. 5
      Adventures in Lestoria/DeathMenu.cpp
  6. 107
      Adventures in Lestoria/FloatingMenuComponent.h
  7. 1
      Adventures in Lestoria/LoadFileButton.h
  8. 1
      Adventures in Lestoria/LoadGameWindow.cpp
  9. 40
      Adventures in Lestoria/MainMenuWindow.cpp
  10. 10
      Adventures in Lestoria/Menu.cpp
  11. 1
      Adventures in Lestoria/Menu.h
  12. 2
      Adventures in Lestoria/MenuComponent.h
  13. 2
      Adventures in Lestoria/MenuItemButton.h
  14. 66
      Adventures in Lestoria/MenuLabel.h
  15. 3
      Adventures in Lestoria/MenuType.h
  16. 4
      Adventures in Lestoria/ScrollableWindowComponent.h
  17. 6
      Adventures in Lestoria/TODO.txt
  18. 4
      Adventures in Lestoria/Version.h
  19. 3
      Adventures in Lestoria/assets/config/configuration.txt
  20. 62
      Adventures in Lestoria/assets/config/credits.txt
  21. BIN
      x64/Release/Adventures in Lestoria.exe

@ -342,6 +342,10 @@
</SubType> </SubType>
</ClInclude> </ClInclude>
<ClInclude Include="Error.h" /> <ClInclude Include="Error.h" />
<ClInclude Include="FloatingMenuComponent.h">
<SubType>
</SubType>
</ClInclude>
<ClInclude Include="GameEvent.h"> <ClInclude Include="GameEvent.h">
<SubType> <SubType>
</SubType> </SubType>
@ -574,6 +578,10 @@
</SubType> </SubType>
</ClCompile> </ClCompile>
<ClCompile Include="AdventuresInLestoria.cpp" /> <ClCompile Include="AdventuresInLestoria.cpp" />
<ClCompile Include="CreditsWindow.cpp">
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="DamageNumber.cpp" /> <ClCompile Include="DamageNumber.cpp" />
<ClCompile Include="DeathMenu.cpp"> <ClCompile Include="DeathMenu.cpp">
<SubType> <SubType>
@ -791,6 +799,7 @@
<Text Include="assets\config\classes\Witch.txt" /> <Text Include="assets\config\classes\Witch.txt" />
<Text Include="assets\config\classes\Wizard.txt" /> <Text Include="assets\config\classes\Wizard.txt" />
<Text Include="assets\config\configuration.txt" /> <Text Include="assets\config\configuration.txt" />
<Text Include="assets\config\credits.txt" />
<Text Include="assets\config\gfx\backdrops.txt" /> <Text Include="assets\config\gfx\backdrops.txt" />
<Text Include="assets\config\gfx\gfx.txt" /> <Text Include="assets\config\gfx\gfx.txt" />
<Text Include="assets\config\gfx\themes.txt" /> <Text Include="assets\config\gfx\themes.txt" />

@ -474,6 +474,9 @@
<ClInclude Include="Tutorial.h"> <ClInclude Include="Tutorial.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="FloatingMenuComponent.h">
<Filter>Header Files\Interface</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Player.cpp"> <ClCompile Include="Player.cpp">
@ -836,6 +839,9 @@
<ClCompile Include="Tutorial.cpp"> <ClCompile Include="Tutorial.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="CreditsWindow.cpp">
<Filter>Source Files\Interface</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="cpp.hint" /> <None Include="cpp.hint" />
@ -990,6 +996,9 @@
<Text Include="assets\config\settings\input.txt"> <Text Include="assets\config\settings\input.txt">
<Filter>Configurations\Setttings</Filter> <Filter>Configurations\Setttings</Filter>
</Text> </Text>
<Text Include="assets\config\credits.txt">
<Filter>Configurations</Filter>
</Text>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="assets\heart.ico"> <Image Include="assets\heart.ico">

@ -221,6 +221,9 @@ AiL::AiL()
std::string ENVIRONMENTAL_AUDIO_CONFIG = CONFIG_PATH + "environmental_audio_config"_S; std::string ENVIRONMENTAL_AUDIO_CONFIG = CONFIG_PATH + "environmental_audio_config"_S;
utils::datafile::Read(DATA,ENVIRONMENTAL_AUDIO_CONFIG); utils::datafile::Read(DATA,ENVIRONMENTAL_AUDIO_CONFIG);
std::string CREDITS_CONFIG = CONFIG_PATH + "credits_config"_S;
utils::datafile::Read(DATA,CREDITS_CONFIG);
utils::datafile::DEBUG_ACCESS_OPTIONS="debug_access_options"_I; utils::datafile::DEBUG_ACCESS_OPTIONS="debug_access_options"_I;
sAppName = "GAME_NAME"_S; sAppName = "GAME_NAME"_S;

@ -0,0 +1,89 @@
#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 "AdventuresInLestoria.h"
#include "Menu.h"
#include "ScrollableWindowComponent.h"
#include "MenuLabel.h"
INCLUDE_WINDOW_SIZE
void Menu::InitializeCreditsWindow(){
vf2d windowSize=WINDOW_SIZE-vf2d{78,78};
Menu*creditsWindow=CreateMenu(MenuType::CREDITS,CENTERED,windowSize);
auto displayScrollWindow=creditsWindow->ADD("Display Text Scroll Window",ScrollableWindowComponent)(geom2d::rect<float>{{4,4},windowSize-vf2d{8,8}})END;
displayScrollWindow->ADD("Display Text",MenuLabel)(geom2d::rect<float>{{2,2},windowSize-vf2d{24,12}},"Test Text\nEven more testing text that we could use for this game.",1.f,ComponentAttr::CENTER)END;
creditsWindow->ADD("Go Back Button",MenuComponent)(geom2d::rect<float>{{windowSize.x/2.f-48.f,windowSize.y},{96.f,12.f}},"Back",[](MenuFuncData data){
Menu::CloseMenu();
return true;
})END;
creditsWindow->SetupKeyboardNavigation(
[](MenuType type,Data&returnData){ //On Open
returnData="Go Back Button";
},
{ //Button Key
{{game->KEY_SCROLLUP,Held},{"",[](MenuType type){
Component<ScrollableWindowComponent>(type,"Display Text Scroll Window")->Scroll(1.f);
}}},
{{game->KEY_SCROLLDOWN,Held},{"",[](MenuType type){
Component<ScrollableWindowComponent>(type,"Display Text Scroll Window")->Scroll(-1.f);
}}},
{{game->KEY_SHOULDER,Pressed},{"Scroll Encounters",[](MenuType type){
Component<ScrollableWindowComponent>(type,"Display Text Scroll Window")->Scroll(-1.0f);
}}},
{{game->KEY_FASTSCROLLUP,Held,InputEngageGroup::NOT_VISIBLE},{"Scroll",[](MenuType type){
Component<ScrollableWindowComponent>(type,"Display Text Scroll Window")->Scroll(-1.0f);
}}},
{{game->KEY_FASTSCROLLDOWN,Held,InputEngageGroup::NOT_VISIBLE},{"Scroll",[](MenuType type){
Component<ScrollableWindowComponent>(type,"Display Text Scroll Window")->Scroll(1.0f);
}}},
{{game->KEY_SCROLLVERT_R,Analog,InputEngageGroup::NOT_VISIBLE},{"Scroll",[](MenuType type){
Component<ScrollableWindowComponent>(type,"Display Text Scroll Window")->Scroll(game->KEY_SCROLLVERT.Analog());
}}},
{game->KEY_BACK,{"Back",[](MenuType type){
Component<MenuComponent>(type,"Go Back Button")->Click();
}}},
{game->KEY_CONFIRM,{"Back",[](MenuType type){}}},
}
,{ //Button Navigation Rules
});
}

@ -69,11 +69,6 @@ void Menu::InitializeDeathWindow(){
}, },
{ //Button Key { //Button Key
{game->KEY_SCROLL,{"Navigate",[](MenuType type){}}}, {game->KEY_SCROLL,{"Navigate",[](MenuType type){}}},
{game->KEY_MENU,{"Resume",[](MenuType type){
if(!Menu::menus[type]->GetSelection().expired()){
Menu::menus[type]->GetSelection().lock()->Click();
}
}}},
{game->KEY_CONFIRM,{"Select",[](MenuType type){}}}, {game->KEY_CONFIRM,{"Select",[](MenuType type){}}},
} }
,{ //Button Navigation Rules ,{ //Button Navigation Rules

@ -0,0 +1,107 @@
#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"
#include "AdventuresInLestoria.h"
#include "drawutil.h"
#include "util.h"
#include "ScrollableWindowComponent.h"
using A=Attribute;
INCLUDE_game
//A button that directly draws in a location in the game.
class FloatingMenuComponent:public MenuComponent{
public:
inline FloatingMenuComponent(geom2d::rect<float>rect,std::string label,MenuFunc onClick,ButtonAttr attributes=ButtonAttr::NONE)
:MenuComponent(rect,label,onClick,attributes){};
inline virtual bool HandleOutsideDisabledButtonSelection(std::weak_ptr<MenuComponent>disabledButton)override final{
return true;
};
inline virtual bool GetHoverState(AiL*game){
if(!parentComponent.expired()){
return parentComponent.lock()->GetHoverState(game,this);
}else{
return geom2d::overlaps(geom2d::rect<float>{rect.pos,rect.size},game->GetMousePos());
}
}
inline virtual void DrawDecal(ViewPort&window,bool focused)override final{
if(background){
Pixel backCol=PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),hoverEffect/"ThemeGlobal.HighlightTime"_F);
if(grayedOut){
backCol=DARK_GREY;
}
game->FillRectDecal(rect.pos+V(A::DRAW_OFFSET),rect.size,backCol);
}
if(selected&&selectionType==HIGHLIGHT){
game->FillRectDecal(rect.pos+V(A::DRAW_OFFSET),rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),util::lerp(0.75f,1.0f,hoverEffect/"ThemeGlobal.HighlightTime"_F)));
}
if(border){
game->FillRectDecal(rect.pos+V(A::DRAW_OFFSET),{rect.size.x+1,1},borderCol);
game->FillRectDecal(rect.pos+V(A::DRAW_OFFSET),{1,rect.size.y+1},borderCol);
game->FillRectDecal(rect.pos+V(A::DRAW_OFFSET)+vf2d{rect.size.x-1+1,0},{1,rect.size.y+1},borderCol);
game->FillRectDecal(rect.pos+V(A::DRAW_OFFSET)+vf2d{0,rect.size.y-1+1},{rect.size.x+1,1},borderCol);
}
if(showDefaultLabel){
vf2d adjustedScale=labelScaling;
vi2d labelTextSize=vf2d(game->GetTextSizeProp(label))*adjustedScale;
if(fitToLabel){
float sizeRatio=(vf2d(labelTextSize).x)/(rect.size.x-2);
if(sizeRatio>1){
adjustedScale.x/=sizeRatio;
labelTextSize.x/=sizeRatio;
}
}
game->DrawStringPropDecal(rect.pos+V(A::DRAW_OFFSET)+rect.size/2-vf2d(labelTextSize)/2.f,label,WHITE,adjustedScale);
}
if(selected){
switch(selectionType){
case CROSSHAIR:drawutil::DrawCrosshairDecal(game,{rect.pos+V(A::DRAW_OFFSET),rect.size},0);break;
case INNER_BOX:game->DrawRectDecal(rect.pos+V(A::DRAW_OFFSET)+vi2d{1,1},rect.size-vi2d{2,2});break;
case HIGHLIGHT:break;//Not used.
case SelectionType::NONE:break;//Displays nothing.
default:ERR("Undefined selection type selected: "<<int(selectionType));
}
}
}
};

@ -39,6 +39,7 @@ All rights reserved.
#include "MenuComponent.h" #include "MenuComponent.h"
#include "ClassInfo.h" #include "ClassInfo.h"
#include "util.h"
INCLUDE_ANIMATION_DATA INCLUDE_ANIMATION_DATA

@ -40,6 +40,7 @@ All rights reserved.
#include "ScrollableWindowComponent.h" #include "ScrollableWindowComponent.h"
#include "SaveFile.h" #include "SaveFile.h"
#include "SoundEffect.h" #include "SoundEffect.h"
#include "MenuLabel.h"
void Menu::InitializeLoadGameWindow(){ void Menu::InitializeLoadGameWindow(){
Menu*loadGameWindow=CreateMenu(LOAD_GAME,CENTERED,vi2d{192,144}); Menu*loadGameWindow=CreateMenu(LOAD_GAME,CENTERED,vi2d{192,144});

@ -38,7 +38,7 @@ All rights reserved.
#include "AdventuresInLestoria.h" #include "AdventuresInLestoria.h"
#include "DEFINES.h" #include "DEFINES.h"
#include "Menu.h" #include "Menu.h"
#include "MenuComponent.h" #include "FloatingMenuComponent.h"
#include "SaveFile.h" #include "SaveFile.h"
#include "util.h" #include "util.h"
@ -68,6 +68,10 @@ void Menu::InitializeMainMenuWindow(){
game->EndGame(); game->EndGame();
return true; return true;
})END; })END;
mainMenuWindow->ADD("Credits Button",FloatingMenuComponent)(geom2d::rect<float>{{game->ScreenWidth()-74.f,game->ScreenHeight()-38.f},{72.f,20.f}},"Credits",[](MenuFuncData data){
Menu::OpenMenu(CREDITS);
return true;
})END;
mainMenuWindow->SetupKeyboardNavigation( mainMenuWindow->SetupKeyboardNavigation(
[](MenuType type,Data&returnData){ //On Open [](MenuType type,Data&returnData){ //On Open
@ -79,19 +83,45 @@ void Menu::InitializeMainMenuWindow(){
}, },
{ //Button Key { //Button Key
{game->KEY_CONFIRM,{"Select",[](MenuType type){}}}, {game->KEY_CONFIRM,{"Select",[](MenuType type){}}},
{game->KEY_SELECT,{"Credits",[](MenuType type){}}},
} }
,{ //Button Navigation Rules ,{ //Button Navigation Rules
{"New Game Button",{ {"New Game Button",{
.up="Quit Game Button", .up="Quit Game Button",
.down="Load Game Button",}}, .down="Load Game Button",
.left="Credits Button",
.right="Credits Button",}},
{"Load Game Button",{ {"Load Game Button",{
.up="New Game Button", .up="New Game Button",
.down="Settings Button",}}, .down="Settings Button",
.left="Credits Button",
.right="Credits Button",}},
{"Settings Button",{ {"Settings Button",{
.up="Load Game Button", .up="Load Game Button",
.down="Quit Game Button",}}, .down="Quit Game Button",
.left="Credits Button",
.right="Credits Button",}},
{"Quit Game Button",{ {"Quit Game Button",{
.up="Settings Button", .up="Settings Button",
.down="New Game Button",}}, .down="New Game Button",
.left="Credits Button",
.right="Credits Button",}},
{"Credits Button",{
.up="Load Game Button",
.down="Quit Game Button",
.left=[](MenuType type,Data&returnData){
if(SaveFile::GetSaveFileCount()>0){
returnData="Load Game Button";
}else{
returnData="New Game Button";
}
},
.right=[](MenuType type,Data&returnData){
if(SaveFile::GetSaveFileCount()>0){
returnData="Load Game Button";
}else{
returnData="New Game Button";
}
},}},
}); });
} }

@ -107,6 +107,7 @@ void Menu::InitializeMenus(){
InitializeNewKeybindInputWindow(); InitializeNewKeybindInputWindow();
InitializePauseWindow(); InitializePauseWindow();
InitializeDeathWindow(); InitializeDeathWindow();
InitializeCreditsWindow();
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){
@ -117,6 +118,15 @@ void Menu::InitializeMenus(){
} }
if(menus.size()>MAX_MENUS)ERR("WARNING! Exceeded maximum expected menu count of "<<MAX_MENUS<<"!"); if(menus.size()>MAX_MENUS)ERR("WARNING! Exceeded maximum expected menu count of "<<MAX_MENUS<<"!");
} }
//Initialize Credits window.
int line=0;
std::string credits{""};
while(DATA["Credits"].HasProperty(std::format("LINE[{}]",line))){
credits+=DATA["Credits"][std::format("LINE[{}]",line)].GetString()+"\n";
line++;
}
Component<MenuLabel>(CREDITS,"Display Text")->SetLabel(credits);
} }
Menu*Menu::CreateMenu(MenuType type,vf2d pos,vf2d size){ Menu*Menu::CreateMenu(MenuType type,vf2d pos,vf2d size){

@ -111,6 +111,7 @@ class Menu:public IAttributable{
static void InitializeNewKeybindInputWindow(); static void InitializeNewKeybindInputWindow();
static void InitializePauseWindow(); static void InitializePauseWindow();
static void InitializeDeathWindow(); static void InitializeDeathWindow();
static void InitializeCreditsWindow();
friend class AiL; friend class AiL;
friend class ItemInfo; friend class ItemInfo;

@ -55,6 +55,7 @@ enum class ComponentAttr{
BACKGROUND= 0b0'0001'0000, //Renders the background of the menu theme for this component. BACKGROUND= 0b0'0001'0000, //Renders the background of the menu theme for this component.
FIT_TO_LABEL= 0b0'0010'0000, //Scales the text horizontally to fit the label if the text takes up more space rather than wrapping. FIT_TO_LABEL= 0b0'0010'0000, //Scales the text horizontally to fit the label if the text takes up more space rather than wrapping.
FIXED_WIDTH_FONT= 0b0'0100'0000, //Uses a fixed-width font (instead of a proportional one) for text rendering. FIXED_WIDTH_FONT= 0b0'0100'0000, //Uses a fixed-width font (instead of a proportional one) for text rendering.
CENTER= 0b0'1000'0000, //Multi-line Centering for MenuLabels.
}; };
enum class SelectionType{ enum class SelectionType{
@ -79,6 +80,7 @@ class MenuComponent:public IAttributable{
friend class MenuItemItemButton; friend class MenuItemItemButton;
friend class RowItemDisplay; friend class RowItemDisplay;
friend class InventoryConsumableWindow; friend class InventoryConsumableWindow;
friend class FloatingMenuComponent;
MenuFunc onHover=[](MenuFuncData dat){return true;}; MenuFunc onHover=[](MenuFuncData dat){return true;};
MenuFunc onMouseOut=[](MenuFuncData dat){return true;}; MenuFunc onMouseOut=[](MenuFuncData dat){return true;};
bool hoverState=false; bool hoverState=false;

@ -37,8 +37,8 @@ All rights reserved.
#pragma endregion #pragma endregion
#pragma once #pragma once
#include "Menu.h" #include "Menu.h"
#include "MenuLabel.h"
#include "MenuIconButton.h" #include "MenuIconButton.h"
#include "MenuLabel.h"
#include "DEFINES.h" #include "DEFINES.h"
#include "AdventuresInLestoria.h" #include "AdventuresInLestoria.h"
#include "Item.h" #include "Item.h"

@ -41,6 +41,7 @@ All rights reserved.
#include "DEFINES.h" #include "DEFINES.h"
#include "olcPGEX_ViewPort.h" #include "olcPGEX_ViewPort.h"
#include "util.h" #include "util.h"
#include "ScrollableWindowComponent.h"
INCLUDE_game INCLUDE_game
@ -49,10 +50,16 @@ protected:
float scale=1; float scale=1;
bool shadow=false; bool shadow=false;
bool centered=true; bool centered=true;
bool multiLineCentered=false;
bool rightAlign=false; bool rightAlign=false;
bool proportional=true; bool proportional=true;
bool runOnLabelChangeFunc=false; bool runOnLabelChangeFunc=false;
std::function<void(std::string_view newLabel)>onLabelChangeFunc; std::function<void(std::string_view newLabel)>onLabelChangeFunc;
//Specific wrapping members.
std::string wrappedLabel;
std::vector<std::string_view>lines;
std::vector<float>offsets;
public: public:
inline MenuLabel(geom2d::rect<float>rect,std::string label,std::function<void(std::string_view newLabel)>onLabelChangeFunc,float scale=1,ComponentAttr attributes=ComponentAttr::NONE) inline MenuLabel(geom2d::rect<float>rect,std::string label,std::function<void(std::string_view newLabel)>onLabelChangeFunc,float scale=1,ComponentAttr attributes=ComponentAttr::NONE)
:MenuLabel(rect,label,scale,attributes){ :MenuLabel(rect,label,scale,attributes){
@ -60,14 +67,16 @@ public:
this->onLabelChangeFunc=onLabelChangeFunc; this->onLabelChangeFunc=onLabelChangeFunc;
} }
inline MenuLabel(geom2d::rect<float>rect,std::string label,float scale=1,ComponentAttr attributes=ComponentAttr::NONE) inline MenuLabel(geom2d::rect<float>rect,std::string label,float scale=1,ComponentAttr attributes=ComponentAttr::NONE)
:MenuComponent(rect,label,MenuFunc{},ButtonAttr::UNSELECTABLE|ButtonAttr::UNSELECTABLE_VIA_KEYBOARD),scale(scale),rightAlign(attributes&ComponentAttr::RIGHT_ALIGN),centered(!(attributes&ComponentAttr::LEFT_ALIGN)&&!(attributes&ComponentAttr::RIGHT_ALIGN)),shadow(attributes&ComponentAttr::SHADOW),proportional(!(attributes&ComponentAttr::FIXED_WIDTH_FONT)){ :MenuComponent(rect,label,MenuFunc{},ButtonAttr::UNSELECTABLE|ButtonAttr::UNSELECTABLE_VIA_KEYBOARD),scale(scale),rightAlign(attributes&ComponentAttr::RIGHT_ALIGN),centered(!(attributes&ComponentAttr::LEFT_ALIGN)&&!(attributes&ComponentAttr::RIGHT_ALIGN)),shadow(attributes&ComponentAttr::SHADOW),proportional(!(attributes&ComponentAttr::FIXED_WIDTH_FONT)),multiLineCentered(attributes&ComponentAttr::CENTER){
border=attributes&ComponentAttr::OUTLINE; border=attributes&ComponentAttr::OUTLINE;
this->background=attributes&ComponentAttr::BACKGROUND; this->background=attributes&ComponentAttr::BACKGROUND;
showDefaultLabel=false; showDefaultLabel=false;
fitToLabel=attributes&ComponentAttr::FIT_TO_LABEL; fitToLabel=attributes&ComponentAttr::FIT_TO_LABEL;
CalculateWrappedLabel();
} }
inline virtual void SetLabel(std::string text)override{ inline virtual void SetLabel(std::string text)override{
MenuComponent::SetLabel(text); MenuComponent::SetLabel(text);
CalculateWrappedLabel();
if(runOnLabelChangeFunc)onLabelChangeFunc(text); if(runOnLabelChangeFunc)onLabelChangeFunc(text);
} }
protected: protected:
@ -102,7 +111,27 @@ protected:
drawPos=vf2d{rect.pos.x+2,rect.middle().y-labelTextSize.y/2}; //We should at least vertically align here. drawPos=vf2d{rect.pos.x+2,rect.middle().y-labelTextSize.y/2}; //We should at least vertically align here.
} }
} }
if(multiLineCentered){
if(shadow){
if(proportional){
for(int counter=0;const std::string_view&text:lines){
window.DrawShadowStringPropDecal(rect.pos+vf2d{offsets[counter],counter*10.f},text,WHITE,BLACK);
counter++;
}
}else{
ERR("WARNING! Unsupported Feature!");
}
}else{
if(proportional){
for(int counter=0;const std::string_view&text:lines){
window.DrawStringPropDecal(rect.pos+vf2d{offsets[counter],counter*10.f},text,WHITE);
counter++;
}
}else{
ERR("WARNING! Unsupported Feature!");
}
}
}else{
if(shadow){ if(shadow){
if(proportional){ if(proportional){
window.DrawShadowStringPropDecal(drawPos,GetLabel(),WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-2,1.0f); window.DrawShadowStringPropDecal(drawPos,GetLabel(),WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-2,1.0f);
@ -117,4 +146,37 @@ protected:
} }
} }
} }
}
private:
inline void CalculateWrappedLabel(){
lines.clear();
offsets.clear();
if(multiLineCentered){
wrappedLabel=util::WrapText(game,GetLabel(),rect.size.x,true,{1.f,1.f});
int labelInd=0;
float largestWidth=0;
while(labelInd!=wrappedLabel.length()){
auto nextLine=std::find(wrappedLabel.begin()+labelInd,wrappedLabel.end(),'\n');
std::string_view text;
if(nextLine!=wrappedLabel.end()){
text=std::string_view(GetLabel()).substr(labelInd,std::distance(wrappedLabel.begin()+labelInd,nextLine));
lines.push_back(text);
labelInd+=std::distance(wrappedLabel.begin(),nextLine)-labelInd+1;
}else{
text=std::string_view(wrappedLabel).substr(labelInd);
lines.push_back(text);
labelInd=wrappedLabel.length();
}
}
for(const std::string_view&text:lines){
float width=game->GetTextSizeProp(text).x;
offsets.push_back(rect.size.x/2.f-width/2);
}
}
//Recalculate label height based on line count.
rect.size.y=lines.size()*10.f;
if(!parentComponent.expired()){
parentComponent.lock()->CalculateBounds();
}
}
}; };

@ -41,7 +41,7 @@ enum MenuType{
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
/*DO NOT REMOVE!!*/ENUM_START,/////////////////////////////// /*DO NOT REMOVE!!*/ENUM_START,///////////////////////////////
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// 100% Controller Compatibility. (104 total items, 4 items per menu * 26 menus) // 100% Controller Compatibility. (108 total items, 4 items per menu * 27 menus)
INVENTORY_CONSUMABLES, //100% Controller Compatibility INVENTORY_CONSUMABLES, //100% Controller Compatibility
CLASS_INFO, //100% Controller Compatibility CLASS_INFO, //100% Controller Compatibility
CLASS_SELECTION, //100% Controller Compatibility CLASS_SELECTION, //100% Controller Compatibility
@ -68,6 +68,7 @@ enum MenuType{
NEW_INPUT, //100% Controller Compatibility NEW_INPUT, //100% Controller Compatibility
PAUSE, //100% Controller Compatibility PAUSE, //100% Controller Compatibility
DEATH, //100% Controller Compatibility DEATH, //100% Controller Compatibility
CREDITS, //100% Controller Compatibility
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
/*DO NOT REMOVE!!*/ENUM_END//////////////////////////////// /*DO NOT REMOVE!!*/ENUM_END////////////////////////////////
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////

@ -38,11 +38,12 @@ All rights reserved.
#pragma once #pragma once
#include "Menu.h" #include "Menu.h"
#include "MenuComponent.h" #include "MenuComponent.h"
#include "MenuItemButton.h"
#include "AdventuresInLestoria.h" #include "AdventuresInLestoria.h"
using A=Attribute; using A=Attribute;
INCLUDE_game
class ScrollableWindowComponent:public MenuComponent{ class ScrollableWindowComponent:public MenuComponent{
friend class Menu; friend class Menu;
protected: protected:
@ -273,6 +274,7 @@ protected:
DrawScrollbar(window,{},focused); DrawScrollbar(window,{},focused);
} }
} }
public:
//Calculates the bounds of all components. //Calculates the bounds of all components.
inline void CalculateBounds(){ inline void CalculateBounds(){
bounds={}; bounds={};

@ -2,10 +2,4 @@ February 28th -> Begin Internal Game Playtesting
March 6th -> Discord/Friend Playtesting March 6th -> Discord/Friend Playtesting
March 30th -> Public Demo Release March 30th -> Public Demo Release
- Hide mouse cursor during controller play. Reveal it again during mouse play.
- Condense stage track (loading times)
- Credits/Licensing
- Check online username boxes (does not show the *?)\ - Check online username boxes (does not show the *?)\

@ -37,9 +37,9 @@ All rights reserved.
#pragma endregion #pragma endregion
#pragma once #pragma once
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 3 #define VERSION_MINOR 4
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#define VERSION_BUILD 7795 #define VERSION_BUILD 7841
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -91,6 +91,9 @@ interface_config = Interface.txt
# Path to Keyboard Input configuration # Path to Keyboard Input configuration
input_config = settings/input.txt input_config = settings/input.txt
# Path to Credits configuration file
credits_config = credits.txt
# Path to character images # Path to character images
character_image_location = characters/commercial_assets/ character_image_location = characters/commercial_assets/

@ -0,0 +1,62 @@
Credits
{
LINE[0]="Development Team"
LINE[1]="~~~~~~~~~~~~~~~~"
LINE[2]=" "
LINE[3]="Production & Programming"
LINE[4]="#C03EE5sigonasr2#FFFFFF"
LINE[5]=" "
LINE[6]="Game Designer"
LINE[7]="#7DDA58Quapsel#FFFFFF"
LINE[8]=" "
LINE[9]="Music Design"
LINE[10]="#5DE2E7A2Z#FFFFFF"
LINE[11]=" "
LINE[12]="Tools & Tech"
LINE[13]="~~~~~~~~~~~~~~~~"
LINE[14]="Game Engine"
LINE[15]="#FE9900javidx9#FFFFFF"
LINE[16]="#FEF500olc::PixelGameEngine v.2.24#FFFFFF"
LINE[17]=" "
LINE[18]="olcPGEX_MiniAudio Copyright© 2024 by Moros Smith under the OLC-3 License"
LINE[19]=" "
LINE[20]="miniaudio library Copyright© 2024 by David Reid under the MIT No Attribution License"
LINE[21]="Ogg Vorbis audio decoder - v1.22 - public domain http://nothings.org/stb_vorbis/"
LINE[22]=" "
LINE[23]="Portions of this software are copyright © 2024 The FreeType Project (www.freetype.org). All rights reserved."
LINE[24]=" "
LINE[25]="Assets"
LINE[26]="~~~~~~~~~~~~~~~~"
LINE[27]="ERA OF FANTASY - GRASSLANDS"
LINE[28]="X: @Namatnieks"
LINE[29]=" "
LINE[30]="*** Minifantasy - Tiny Overworld v1.0 ***"
LINE[31]="Minifantasy is an original idea by Krishna Palacio"
LINE[32]=" "
LINE[33]="Public Domain Font Authors"
LINE[34]="c64esque by andraaspar"
LINE[35]="Habbo by Omni"
LINE[36]="Unknown by Anonymous"
LINE[37]=" "
LINE[38]="Nb Pixel Font Bundle"
LINE[39]="Nb Pixel Font Bundle 2"
LINE[40]=" "
LINE[41]=" "
LINE[42]="Game License"
LINE[43]="~~~~~~~~~~~~~~~~"
LINE[44]="License (OLC-3)"
LINE[45]="~~~~~~~~~~~~~~~"
LINE[46]=" "
LINE[47]="Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>"
LINE[48]=" "
LINE[49]="Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:"
LINE[50]=" "
LINE[51]="1. Redistributions or derivations of source code must retain the above copyright notice, this list of conditions and the following disclaimer."
LINE[52]=" "
LINE[53]="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."
LINE[54]=" "
LINE[55]="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."
LINE[56]=" "
LINE[57]="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."
}
Loading…
Cancel
Save