Proper theming controls added, attributes are now an inheritable interface for anything.

pull/28/head
sigonasr2 1 year ago
parent bff7eabef5
commit 999855c6e8
  1. 40
      Crawler/Attributable.h
  2. 39
      Crawler/Crawler.cpp
  3. 6
      Crawler/Crawler.vcxproj
  4. 29
      Crawler/Crawler.vcxproj.filters
  5. 24
      Crawler/Menu.cpp
  6. 13
      Crawler/Menu.h
  7. 14
      Crawler/MenuComponent.cpp
  8. 18
      Crawler/MenuComponent.h
  9. 15
      Crawler/MenuIconButton.cpp
  10. 22
      Crawler/MenuIconButton.h
  11. 24
      Crawler/MenuLabel.h
  12. 35
      Crawler/Monster.cpp
  13. 10
      Crawler/Monster.h
  14. 1
      Crawler/MonsterAttribute.h
  15. 8
      Crawler/TestMenu.cpp
  16. 49
      Crawler/TestSubMenu.cpp
  17. 22
      Crawler/Theme.h
  18. 2
      Crawler/Version.h
  19. 6
      Crawler/assets/config/configuration.txt
  20. 3
      Crawler/assets/config/gfx/gfx.txt
  21. 25
      Crawler/assets/config/gfx/themes.txt
  22. 0
      Crawler/assets/themes/9patch.png
  23. BIN
      Crawler/assets/themes/9patch_2.png
  24. 6
      Crawler/olcUTIL_DataFile.h

@ -0,0 +1,40 @@
#pragma once
#include "olcPixelGameEngine.h"
#include "MonsterAttribute.h"
#include "DEFINES.h"
#include <variant>
class IAttributable{
protected:
std::map<Attribute,std::variant<VARIANTS>>attributes;
inline float&GetFloat(Attribute a){
if(attributes.count(a)==0){
attributes[a]=0.f;
}
return std::get<float>(attributes[a]);
};
inline int&GetInt(Attribute a){
if(attributes.count(a)==0){
attributes[a]=0;
}
return std::get<int>(attributes[a]);
};
inline std::string&GetString(Attribute a){
if(attributes.count(a)==0){
attributes[a]="";
}
return std::get<std::string>(attributes[a]);
};
inline bool&GetBool(Attribute a){
if(attributes.count(a)==0){
attributes[a]=false;
}
return std::get<bool>(attributes[a]);
};
inline vf2d&GetVf2d(Attribute a){
if(attributes.count(a)==0){
attributes[a]=vf2d{};
}
return std::get<vf2d>(attributes[a]);
};
};

@ -68,6 +68,9 @@ Crawler::Crawler()
std::string MONSTERSTRATEGIES_CONFIG = CONFIG_PATH + "monsterstrategies_config"_S;
utils::datafile::Read(DATA,MONSTERSTRATEGIES_CONFIG);
std::string THEMES_CONFIG = CONFIG_PATH + "themes_config"_S;
utils::datafile::Read(DATA,THEMES_CONFIG);
DEBUG_PATHFINDING="debug_pathfinding"_I;
for(std::string&cl:DATA.GetProperty("class_list").GetValues()){
@ -1685,23 +1688,31 @@ void Crawler::InitializeGraphics(){
}
}
//Specifically split up the 9 patch image into multiple pieces.
Renderable&patchImg=GFX["GFX_Prefix"_S+"Images.GFX_9Patch"_S];
Pixel::Mode prevMode=GetPixelMode();
SetPixelMode(Pixel::Mode::MASK);
for(int x=0;x<3;x++){
for(int y=0;y<3;y++){
std::string patchKey="9patch_"+std::to_string(x)+std::to_string(y)+".png";
GFX[patchKey].Create("Interface.9PatchSize"_i[0],"Interface.9PatchSize"_i[1],false,false);
SetDrawTarget(GFX[patchKey].Sprite());
Clear(BLANK);
DrawPartialSprite({0,0},patchImg.Sprite(),{x*"Interface.9PatchSize"_i[0],y*"Interface.9PatchSize"_i[1]},{"Interface.9PatchSize"_i[0],"Interface.9PatchSize"_i[1]});
GFX[patchKey].Decal()->Update();
SetDrawTarget(nullptr);
//Specifically split up the 9 patch image into multiple pieces for each theme.
for(auto&key:DATA["Themes"].GetKeys()){
std::string themeName=key.first;
std::string imgPath=DATA["Themes"][themeName]["Name"].GetString();
Renderable&patchImg=GFX["theme_img_directory"_S+imgPath+".png"];
Pixel::Mode prevMode=GetPixelMode();
SetPixelMode(Pixel::Mode::MASK);
for(int x=0;x<3;x++){
for(int y=0;y<3;y++){
std::string patchKey=imgPath+"_"+std::to_string(x)+std::to_string(y)+".png";
GFX[patchKey].Create("Interface.9PatchSize"_i[0],"Interface.9PatchSize"_i[1],false,false);
SetDrawTarget(GFX[patchKey].Sprite());
Clear(BLANK);
DrawPartialSprite({0,0},patchImg.Sprite(),{x*"Interface.9PatchSize"_i[0],y*"Interface.9PatchSize"_i[1]},{"Interface.9PatchSize"_i[0],"Interface.9PatchSize"_i[1]});
GFX[patchKey].Decal()->Update();
SetDrawTarget(nullptr);
}
}
SetPixelMode(prevMode);
Menu::themes[imgPath]=Theme{themeName,imgPath,DATA["Themes"][themeName]["ButtonColor"].GetPixel(),DATA["Themes"][themeName]["HighlightColor"].GetPixel()};
std::cout<<"Theme "<<themeName<<" Loaded."<<std::endl;
}
SetPixelMode(prevMode);
Menu::themes.SetInitialized();
std::cout<<Menu::themes.size()<<" themes have been loaded."<<std::endl;
GFX.SetInitialized();
std::cout<<GFX.size()<<" images have been loaded."<<std::endl;
}

@ -260,6 +260,7 @@
<ItemGroup>
<ClInclude Include="Ability.h" />
<ClInclude Include="Animation.h" />
<ClInclude Include="Attributable.h" />
<ClInclude Include="Buff.h" />
<ClInclude Include="Bullet.h" />
<ClInclude Include="BulletTypes.h" />
@ -270,6 +271,8 @@
<ClInclude Include="DEFINES.h" />
<ClInclude Include="Effect.h" />
<ClInclude Include="Emitter.h" />
<ClInclude Include="MenuIconButton.h" />
<ClInclude Include="MenuLabel.h" />
<ClInclude Include="MenuType.h" />
<ClInclude Include="Key.h" />
<ClInclude Include="Map.h" />
@ -290,6 +293,7 @@
<ClInclude Include="resource1.h" />
<ClInclude Include="safemap.h" />
<ClInclude Include="State.h" />
<ClInclude Include="Theme.h" />
<ClInclude Include="TMXParser.h" />
<ClInclude Include="TSXParser.h" />
<ClInclude Include="utils.h" />
@ -314,7 +318,6 @@
<ClCompile Include="Map.cpp" />
<ClCompile Include="Menu.cpp" />
<ClCompile Include="MenuComponent.cpp" />
<ClCompile Include="MenuIconButton.cpp" />
<ClCompile Include="Meteor.cpp" />
<ClCompile Include="RunAway.cpp" />
<ClCompile Include="RunTowards.cpp" />
@ -351,6 +354,7 @@
<Text Include="assets\config\classes\Wizard.txt" />
<Text Include="assets\config\configuration.txt" />
<Text Include="assets\config\gfx\gfx.txt" />
<Text Include="assets\config\gfx\themes.txt" />
<Text Include="assets\config\levels.txt" />
<Text Include="assets\config\Monsters.txt" />
<Text Include="assets\config\MonsterStrategies.txt" />

@ -43,6 +43,9 @@
<Filter Include="Source Files\Interface">
<UniqueIdentifier>{f90a901c-026c-4c22-9fab-58927f1e5536}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Interface">
<UniqueIdentifier>{45ecf440-1472-4e9a-a4d9-e9eac538a2b0}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="olcPixelGameEngine.h">
@ -144,14 +147,26 @@
<ClInclude Include="Key.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Menu.h">
<ClInclude Include="MenuType.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MenuComponent.h">
<ClInclude Include="Theme.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MenuType.h">
<Filter>Header Files</Filter>
<ClInclude Include="Menu.h">
<Filter>Header Files\Interface</Filter>
</ClInclude>
<ClInclude Include="MenuComponent.h">
<Filter>Header Files\Interface</Filter>
</ClInclude>
<ClInclude Include="MenuIconButton.h">
<Filter>Header Files\Interface</Filter>
</ClInclude>
<ClInclude Include="MenuLabel.h">
<Filter>Header Files\Interface</Filter>
</ClInclude>
<ClInclude Include="Attributable.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
@ -275,9 +290,6 @@
<ClCompile Include="TestSubMenu.cpp">
<Filter>Source Files\Interface</Filter>
</ClCompile>
<ClCompile Include="MenuIconButton.cpp">
<Filter>Source Files\Interface</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />
@ -329,6 +341,9 @@
<Text Include="Slime_King_Encounter.txt">
<Filter>Documentation</Filter>
</Text>
<Text Include="assets\config\gfx\themes.txt">
<Filter>Configurations\GFX</Filter>
</Text>
</ItemGroup>
<ItemGroup>
<Image Include="assets\heart.ico">

@ -6,6 +6,8 @@
bool Menu::MOUSE_NAVIGATION=true;
std::vector<Menu*>Menu::stack;
std::map<MenuType,Menu>Menu::menus;
std::string Menu::themeSelection="9patch";
safemap<std::string,Theme>Menu::themes;
INCLUDE_GFX
@ -24,11 +26,21 @@ void Menu::InitializeMenus(){
std::cout<<"WARNING! Menu Type "<<type<<" does not exist!"<<std::endl;
throw;
}
menus[type].components.SetInitialized(); //Lock all known components to prevent invalid access.
}
}
void Menu::AddComponent(MenuComponent*button){
buttons[button->rect.pos.y].push_back(button);
void Menu::AddComponent(std::string key,MenuComponent*button){
if(button->selectable){
buttons[button->rect.pos.y].push_back(button);
}else{
displayComponents.push_back(button);
}
if(components.count(key)){
std::cout<<"WARNING! Key "<<key<<" for this sub-menu already exists! Key names must be unique!"<<std::endl;
throw;
}
components[key]=button;
}
void Menu::MenuSelect(Crawler*game){
@ -70,6 +82,9 @@ void Menu::Update(Crawler*game){
button->Update(game);
}
}
for(auto&component:displayComponents){
component->Update(game);
}
};
void Menu::Draw(Crawler*game){
@ -86,6 +101,9 @@ void Menu::Draw(Crawler*game){
button->Draw(game,upperLeftPos);
}
}
for(auto&component:displayComponents){
component->Draw(game,upperLeftPos);
}
};
void Menu::OpenMenu(MenuType menu){
@ -272,5 +290,5 @@ void Menu::DrawTiledWindow(Crawler*game,vf2d menuPos){
}
Renderable&Menu::GetPatchPart(int x,int y){
return GFX["9patch_"+std::to_string(x)+std::to_string(y)+".png"];
return GFX[themeSelection+"_"+std::to_string(x)+std::to_string(y)+".png"];
}

@ -2,31 +2,36 @@
#include "MenuComponent.h"
#include "olcPixelGameEngine.h"
#include <stack>
#define MENUFUNC [](Menu&menu,Crawler*game)
#include "safemap.h"
#include "Theme.h"
#include "Attributable.h"
class Crawler;
class Menu{
class Menu:IAttributable{
friend class Crawler;
friend class Player;
static bool MOUSE_NAVIGATION;
static std::map<MenuType,Menu>menus;
std::map<int/*Y*/,std::vector<MenuComponent*>>buttons; //Buttons are stored in rows followed by their column order.
std::vector<MenuComponent*>displayComponents; //Components that are only for displaying purposes.
safemap<std::string,MenuComponent*>components; //A friendly way to interrogate any component we are interested in.
vi2d selection={-1,-1};
vf2d size; //Size in tiles (24x24), every menu will be tile-based
bool scaled=false; //Whether or not the patch border is supposed to be scaled or tiled.
public:
Menu();
Menu(vf2d size);
void AddComponent(MenuComponent*button);
void AddComponent(std::string key,MenuComponent*button);
void Update(Crawler*game);
void Draw(Crawler*game);
void SetScaledPatchBorder(bool scaled);
static void InitializeMenus();
static void OpenMenu(MenuType menu);
static std::vector<Menu*>stack;
static std::string themeSelection;
static safemap<std::string,Theme>themes;
private:
void MenuSelect(Crawler*game);
static const Menu InitializeTestMenu();

@ -1,11 +1,11 @@
#include "Crawler.h"
#include "Menu.h"
MenuComponent::MenuComponent(geom2d::rect<float>rect,std::string label,MenuFunc onClick)
:rect(rect),label(label),menuDest(MenuType::ENUM_END),onClick(onClick),hoverEffect(0){}
MenuComponent::MenuComponent(geom2d::rect<float>rect,std::string label,MenuFunc onClick,bool selectable)
:rect(rect),label(label),menuDest(MenuType::ENUM_END),onClick(onClick),hoverEffect(0),selectable(selectable){}
MenuComponent::MenuComponent(geom2d::rect<float>rect,std::string label,MenuType menuDest,MenuFunc onClick)
:rect(rect),label(label),menuDest(menuDest),onClick(onClick),hoverEffect(0){}
MenuComponent::MenuComponent(geom2d::rect<float>rect,std::string label,MenuType menuDest,MenuFunc onClick,bool selectable)
:rect(rect),label(label),menuDest(menuDest),onClick(onClick),hoverEffect(0),selectable(selectable){}
void MenuComponent::Update(Crawler*game){
if(hovered){
@ -16,7 +16,9 @@ void MenuComponent::Update(Crawler*game){
}
void MenuComponent::Draw(Crawler*game,vf2d parentPos){
game->FillRectDecal(rect.pos+parentPos,rect.size,PixelLerp(VERY_DARK_BLUE,CYAN,hoverEffect));
game->DrawRectDecal(rect.pos+parentPos,rect.size,GREY);
game->FillRectDecal(rect.pos+parentPos,rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),hoverEffect));
if(border){
game->DrawRectDecal(rect.pos+parentPos,rect.size,GREY);
}
game->DrawStringPropDecal(rect.pos+parentPos+rect.size/2-game->GetTextSizeProp(label)/2,label);
}

@ -9,26 +9,18 @@ class Crawler;
class MenuComponent{
friend class Menu;
MenuType menuDest;
std::string label;
MenuFunc onClick;
bool hovered=false;
bool selectable=true;
private:
float hoverEffect=0;
protected:
geom2d::rect<float>rect;
std::string label;
bool border=true;
public:
MenuComponent(geom2d::rect<float>rect,std::string label,MenuFunc onClick);
MenuComponent(geom2d::rect<float>rect,std::string label,MenuType menuDest,MenuFunc onClick);
MenuComponent(geom2d::rect<float>rect,std::string label,MenuFunc onClick,bool selectable=true);
MenuComponent(geom2d::rect<float>rect,std::string label,MenuType menuDest,MenuFunc onClick,bool selectable=true);
virtual void Update(Crawler*game);
virtual void Draw(Crawler*game,vf2d parentPos);
};
class MenuIconButton:public MenuComponent{
private:
Decal*icon;
public:
MenuIconButton(geom2d::rect<float>rect,Decal*icon,MenuFunc onClick);
protected:
virtual void Update(Crawler*game)override;
virtual void Draw(Crawler*game,vf2d parentPos)override;
};

@ -1,15 +0,0 @@
#include "MenuComponent.h"
#include "Crawler.h"
MenuIconButton::MenuIconButton(geom2d::rect<float>rect,Decal*icon,MenuFunc onClick)
:MenuComponent(rect,"",onClick),icon(icon)
{}
void MenuIconButton::Update(Crawler*game){
MenuComponent::Update(game);
}
void MenuIconButton::Draw(Crawler*game,vf2d parentPos){
MenuComponent::Draw(game,parentPos);
game->DrawRotatedDecal(parentPos+rect.middle(),icon,0,icon->sprite->Size()/2);
}

@ -0,0 +1,22 @@
#pragma once
#include "MenuComponent.h"
#include "DEFINES.h"
#include "Crawler.h"
INCLUDE_game
class MenuIconButton:public MenuComponent{
private:
Decal*icon;
public:
inline MenuIconButton(geom2d::rect<float>rect,Decal*icon,MenuFunc onClick)
:MenuComponent(rect,"",onClick),icon(icon){}
protected:
virtual void inline Update(Crawler*game)override{
MenuComponent::Update(game);
}
virtual void inline Draw(Crawler*game,vf2d parentPos)override{
MenuComponent::Draw(game,parentPos);
game->DrawRotatedDecal(parentPos+rect.middle(),icon,0,icon->sprite->Size()/2);
}
};

@ -0,0 +1,24 @@
#pragma once
#include "MenuComponent.h"
#include "DEFINES.h"
#include "Crawler.h"
INCLUDE_game
class MenuLabel:public MenuComponent{
public:
inline MenuLabel(geom2d::rect<float>rect,std::string label)
:MenuComponent(rect,label,MenuFunc{},false){
border=false;
}
inline void SetLabel(std::string text){
label=text;
}
protected:
virtual void inline Update(Crawler*game)override{
MenuComponent::Update(game);
}
virtual void inline Draw(Crawler*game,vf2d parentPos)override{
MenuComponent::Draw(game,parentPos);
}
};

@ -401,41 +401,6 @@ void Monster::SetSize(float newSize,bool immediate){
}
}
float&Monster::GetFloat(Attribute a){
if(attributes.count(a)==0){
attributes[a]=0.f;
}
return std::get<float>(attributes[a]);
}
int&Monster::GetInt(Attribute a){
if(attributes.count(a)==0){
attributes[a]=0;
}
return std::get<int>(attributes[a]);
}
std::string&Monster::GetString(Attribute a){
if(attributes.count(a)==0){
attributes[a]="";
}
return std::get<std::string>(attributes[a]);
}
bool&Monster::GetBool(Attribute a){
if(attributes.count(a)==0){
attributes[a]=false;
}
return std::get<bool>(attributes[a]);
}
vf2d&Monster::GetVf2d(Attribute a){
if(attributes.count(a)==0){
attributes[a]=vf2d{};
}
return std::get<vf2d>(attributes[a]);
}
void Monster::SetZ(float z){
this->z=z;
}

@ -6,7 +6,7 @@
#include "olcUTIL_Animate2D.h"
#include "DamageNumber.h"
#include "DEFINES.h"
#include <variant>
#include "Attributable.h"
struct Player;
class Crawler;
@ -56,7 +56,7 @@ struct MonsterData{
};
struct Monster{
struct Monster:IAttributable{
friend struct STRATEGY;
private:
int id=0;
@ -93,7 +93,6 @@ private:
int phase=0;
bool diesNormally=true; //If set to false, the monster death is handled in a special way. Set it to true when it's time to die.
float targetSize=0;
std::map<Attribute,std::variant<VARIANTS>>attributes;
bool isBoss=false;
protected:
public:
@ -142,11 +141,6 @@ public:
void SetZ(float z);
std::string GetStrategy();
void SetSize(float newSize,bool immediate=true);
float&GetFloat(Attribute a);
int&GetInt(Attribute a);
std::string&GetString(Attribute a);
bool&GetBool(Attribute a);
vf2d&GetVf2d(Attribute a);
void SetStrategyDrawFunction(std::function<void(Crawler*)>func);
std::function<void(Crawler*)>strategyDraw=[](Crawler*pge){};
private:

@ -27,4 +27,5 @@ enum class Attribute{
PHASE_REPEAT_COUNT,
JUMP_TOWARDS_PLAYER,
HITS_UNTIL_DEATH, //When this is set, it is reduced by 1 each time the monster is hit.
INDEXED_THEME,
};

@ -8,19 +8,19 @@ const Menu Menu::InitializeTestMenu(){
menu.stack.clear();
};
testMenu.AddComponent(new MenuComponent({{24*1,24*1},{24*2,24*1}},"Close",quitWindow));
testMenu.AddComponent("Close",new MenuComponent({{24*1,24*1},{24*2,24*1}},"Close",quitWindow));
MenuFunc doNothing=[](Menu&menu,Crawler*game){};
testMenu.AddComponent(new MenuComponent({{24*4,24*1},{24*3,24*1}},"Test",doNothing));
testMenu.AddComponent("Test",new MenuComponent({{24*4,24*1},{24*3,24*1}},"Test",doNothing));
MenuFunc HurtPlayer=[](Menu&menu,Crawler*game){
game->GetPlayer()->Hurt(20,game->GetPlayer()->OnUpperLevel(),game->GetPlayer()->GetZ());
};
testMenu.AddComponent(new MenuComponent({{24*4,24*3},{24*3,24*1}},"Hurt Player",HurtPlayer));
testMenu.AddComponent("Hurt Player",new MenuComponent({{24*4,24*3},{24*3,24*1}},"Hurt Player",HurtPlayer));
testMenu.AddComponent(new MenuComponent({{24*2,24*4.5},{24*4,24*1}},"Open Another\n Menu",TEST_2,doNothing));
testMenu.AddComponent("Open SubMenu",new MenuComponent({{24*2,24*4.5},{24*4,24*1}},"Open Another\n Menu",TEST_2,doNothing));
return testMenu;
}

@ -3,29 +3,58 @@
#include "DEFINES.h"
#include "olcPixelGameEngine.h"
#include "safemap.h"
#include "MenuIconButton.h"
#include "MenuLabel.h"
INCLUDE_GFX
typedef Attribute A;
const Menu Menu::InitializeTestSubMenu(){
Menu testSubMenu({24*4,24*5});
MenuFunc goBack=MENUFUNC{
MenuFunc goBack=[](Menu&menu,Crawler*game){
menu.stack.pop_back();
};
testSubMenu.AddComponent(new MenuComponent({{24*1,24*1},{24*2,24*1}},"Go Back",goBack));
MenuFunc quitWindow=MENUFUNC{
menu.stack.clear();
testSubMenu.AddComponent("BACK",new MenuComponent({{24*1,24*1},{24*2,24*1}},"Go Back",goBack));
testSubMenu.I(A::INDEXED_THEME)=0;
MenuFunc themePrev=[](Menu&menu,Crawler*game){
bool found=false;
menu.I(A::INDEXED_THEME)--;
if(menu.I(A::INDEXED_THEME)<0){
menu.I(A::INDEXED_THEME)=themes.size()-1;
}
int index=0;
for(auto&theme:Menu::themes){
if(index==menu.I(A::INDEXED_THEME)){
Menu::themeSelection=theme.first;
((MenuLabel*)(menu.components["THEME_DISPLAY"]))->SetLabel("Theme\n"+Menu::themes[themeSelection].GetThemeName());
break;
}
index++;
}
};
testSubMenu.AddComponent(new MenuComponent({{24*1,24*3},{24*3,24*1}},"Close Window",quitWindow));
MenuFunc restoreMana=MENUFUNC{
game->GetPlayer()->SetMana(game->GetPlayer()->GetMaxMana());
testSubMenu.AddComponent("PREV_THEME",new MenuComponent({{24*-0.5,24*3},{24*1,24*1}},"<",themePrev));
testSubMenu.AddComponent("THEME_DISPLAY",new MenuLabel({{24*0.5,24*3},{24*3,24*1}},"Theme\n"+Menu::themes[themeSelection].GetThemeName()));
MenuFunc themeNext=[](Menu&menu,Crawler*game){
menu.I(A::INDEXED_THEME)=(size_t(menu.I(A::INDEXED_THEME))+1)%themes.size();
int index=0;
for(auto&theme:Menu::themes){
if(index==menu.I(A::INDEXED_THEME)){
Menu::themeSelection=theme.first;
((MenuLabel*)(menu.components["THEME_DISPLAY"]))->SetLabel("Theme\n"+Menu::themes[themeSelection].GetThemeName());
break;
}
index++;
}
};
testSubMenu.AddComponent(new MenuIconButton({{24*0,24*3},{24*1,24*2}},GFX["mana.png"].Decal(),restoreMana));
testSubMenu.AddComponent("NEXT_THEME",new MenuComponent({{24*3.5,24*3},{24*1,24*1}},">",themeNext));
return testSubMenu;
}

@ -0,0 +1,22 @@
#pragma once
#include "olcPixelGameEngine.h"
class Theme{
std::string displayName;
std::string imgPath;
Pixel buttonCol,highlightCol;
public:
inline Theme(){}
inline Theme(std::string displayName,std::string imgPath,Pixel buttonCol,Pixel highlightCol)
:displayName(displayName),imgPath(imgPath),buttonCol(buttonCol),highlightCol(highlightCol){}
inline Pixel GetButtonCol(){
return buttonCol;
}
inline Pixel GetHighlightCol(){
return highlightCol;
}
inline std::string GetThemeName(){
return displayName;
}
};

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 0
#define VERSION_BUILD 1651
#define VERSION_BUILD 1676
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -27,6 +27,12 @@ monsters_config = Monsters.txt
# Monster Strategy Config
monsterstrategies_config = MonsterStrategies.txt
# Interface Theme Config
themes_config = gfx/themes.txt
# Path to theme image files
theme_img_directory = themes/
# Path to class configuration files
class_directory = classes/

@ -39,7 +39,8 @@ Images
GFX_SkillOverlayIcon = skill_overlay_icon.png
GFX_SkillOverlayIconOverlay = skill_overlay_icon_overlay.png
GFX_9Patch = 9patch.png
GFX_9Patch = themes/9patch.png
GFX_9Patch2 = themes/9patch_2.png
# Ability Icons
GFX_Warrior_BattleCry_Icon = Ability Icons/battlecry.png

@ -0,0 +1,25 @@
Themes
{
# Provide the patch image names without the .png extensions.
BlueDefault
{
Name = "9patch"
ButtonColor = 0,0,64,255
HighlightColor = 0,200,200,255
# If set to 0, stretches the edges and center instead of tiling it.
Tiled = 1
}
Purple
{
Name = "9patch_2"
ButtonColor = 40,16,71,255
HighlightColor = 192,128,238,255
# If set to 0, stretches the edges and center instead of tiling it.
Tiled = 1
}
}

Before

Width:  |  Height:  |  Size: 618 B

After

Width:  |  Height:  |  Size: 618 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

@ -119,6 +119,10 @@ namespace olc::utils
SetString(std::to_string(n), nItem);
}
inline Pixel GetPixel(const size_t nItem = 0){
return {uint8_t(GetInt(nItem)),uint8_t(GetInt(nItem+1)),uint8_t(GetInt(nItem+2)),uint8_t(GetInt(nItem+3))};
}
// Returns the number of Values a property consists of
inline size_t GetValueCount() const
{
@ -429,6 +433,8 @@ namespace olc::utils
}
// File not found, so fail
std::cout<<"WARNING! Could not open file "<<sFileName<<"!"<<std::endl;
throw;
return false;
}

Loading…
Cancel
Save