Add in class display labels, animated sprite icons, and title of the window.
This commit is contained in:
parent
debced946e
commit
02c7165b37
@ -9,7 +9,7 @@ class CharacterRotatingDisplay:public MenuComponent{
|
|||||||
protected:
|
protected:
|
||||||
Decal*icon;
|
Decal*icon;
|
||||||
float timer;
|
float timer;
|
||||||
float rotatingFactor=18;
|
float rotatingFactor=7;
|
||||||
float perspectiveFactor=6;
|
float perspectiveFactor=6;
|
||||||
public:
|
public:
|
||||||
inline CharacterRotatingDisplay(MenuType parent,geom2d::rect<float>rect,Decal*icon)
|
inline CharacterRotatingDisplay(MenuType parent,geom2d::rect<float>rect,Decal*icon)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "DEFINES.h"
|
#include "DEFINES.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "MenuLabel.h"
|
#include "MenuLabel.h"
|
||||||
|
#include "MenuAnimatedIconButton.h"
|
||||||
|
|
||||||
INCLUDE_game
|
INCLUDE_game
|
||||||
typedef Attribute A;
|
typedef Attribute A;
|
||||||
@ -14,58 +15,62 @@ void Menu::InitializeClassSelectionWindow(){
|
|||||||
|
|
||||||
vf2d outlineSize=classSelectionWindow->size-vf2d{13,13};
|
vf2d outlineSize=classSelectionWindow->size-vf2d{13,13};
|
||||||
|
|
||||||
|
MenuLabel*classSelectionLabel=new MenuLabel(CLASS_SELECTION,{{4,20},{outlineSize.x,32}},"Choose a Character Class",2,true,true,true,true);
|
||||||
|
classSelectionWindow->AddComponent("Class Selection Title Label",classSelectionLabel);
|
||||||
|
|
||||||
MenuLabel*outline=new MenuLabel(CLASS_SELECTION,{{4,4},outlineSize},"",1,true,false,true,false);
|
MenuLabel*outline=new MenuLabel(CLASS_SELECTION,{{4,4},outlineSize},"",1,true,false,true,false);
|
||||||
|
|
||||||
classSelectionWindow->AddComponent("Outline Border",outline);
|
classSelectionWindow->AddComponent("Outline Border",outline);
|
||||||
|
|
||||||
vf2d buttonPadding={2,2};
|
vf2d buttonPadding={2,2};
|
||||||
vf2d buttonSize={outlineSize.y/3-buttonPadding.y*3,outlineSize.y/3-buttonPadding.y*3};
|
vf2d buttonSize={floor(outlineSize.y/3-buttonPadding.y*3),outlineSize.y/9-buttonPadding.y*3}; //The floor is for fixing a small pixel rounding bug.
|
||||||
|
|
||||||
float buttonTotalWidth=(buttonSize.x+buttonPadding.x)*3;
|
float buttonTotalWidth=(buttonSize.x+buttonPadding.x)*3;
|
||||||
|
|
||||||
vf2d buttonStartPos=outline->GetPos()+vf2d{outlineSize.x/2,outlineSize.y/3}-vf2d{buttonTotalWidth/2,0};
|
vf2d buttonStartPos=outline->GetPos()+vf2d{outlineSize.x/2,outlineSize.y/3}-vf2d{buttonTotalWidth/2,0};
|
||||||
|
|
||||||
MenuComponent*warriorButton=new MenuComponent(CLASS_SELECTION,{buttonStartPos+(buttonSize+buttonPadding)*vf2d{0,0},buttonSize},Warrior::name,CLASS_INFO,
|
std::array<std::string,6>classNames={
|
||||||
[](MenuFuncData data){
|
Warrior::name,
|
||||||
data.menu.S(A::CLASS_SELECTION)=Warrior::name;
|
Ranger::name,
|
||||||
delete Menu::menus[CLASS_INFO];
|
Wizard::name,
|
||||||
Menu::InitializeClassInfoWindow();
|
Thief::name,
|
||||||
});
|
Trapper::name,
|
||||||
MenuComponent*rangerButton=new MenuComponent(CLASS_SELECTION,{buttonStartPos+(buttonSize+buttonPadding)*vf2d{1,0},buttonSize},Ranger::name,CLASS_INFO,
|
Witch::name,
|
||||||
[](MenuFuncData data){
|
};
|
||||||
data.menu.S(A::CLASS_SELECTION)=Ranger::name;
|
std::array<std::string,6>classAnimationNames={
|
||||||
delete Menu::menus[CLASS_INFO];
|
Warrior::walk_s,
|
||||||
Menu::InitializeClassInfoWindow();
|
Ranger::walk_s,
|
||||||
});
|
Wizard::walk_s,
|
||||||
MenuComponent*wizardButton=new MenuComponent(CLASS_SELECTION,{buttonStartPos+(buttonSize+buttonPadding)*vf2d{2,0},buttonSize},Wizard::name,CLASS_INFO,
|
Thief::walk_s,
|
||||||
[](MenuFuncData data){
|
Trapper::walk_s,
|
||||||
data.menu.S(A::CLASS_SELECTION)=Wizard::name;
|
Witch::walk_s,
|
||||||
delete Menu::menus[CLASS_INFO];
|
};
|
||||||
Menu::InitializeClassInfoWindow();
|
|
||||||
});
|
|
||||||
MenuComponent*thiefButton=new MenuComponent(CLASS_SELECTION,{buttonStartPos+(buttonSize+buttonPadding)*vf2d{0,1},buttonSize},Thief::name,CLASS_INFO,
|
|
||||||
[](MenuFuncData data){
|
|
||||||
data.menu.S(A::CLASS_SELECTION)=Thief::name;
|
|
||||||
delete Menu::menus[CLASS_INFO];
|
|
||||||
Menu::InitializeClassInfoWindow();
|
|
||||||
});
|
|
||||||
MenuComponent*trapperButton=new MenuComponent(CLASS_SELECTION,{buttonStartPos+(buttonSize+buttonPadding)*vf2d{1,1},buttonSize},Trapper::name,CLASS_INFO,
|
|
||||||
[](MenuFuncData data){
|
|
||||||
data.menu.S(A::CLASS_SELECTION)=Trapper::name;
|
|
||||||
delete Menu::menus[CLASS_INFO];
|
|
||||||
Menu::InitializeClassInfoWindow();
|
|
||||||
});
|
|
||||||
MenuComponent*witchButton=new MenuComponent(CLASS_SELECTION,{buttonStartPos+(buttonSize+buttonPadding)*vf2d{2,1},buttonSize},Witch::name,CLASS_INFO,
|
|
||||||
[](MenuFuncData data){
|
|
||||||
data.menu.S(A::CLASS_SELECTION)=Witch::name;
|
|
||||||
delete Menu::menus[CLASS_INFO];
|
|
||||||
Menu::InitializeClassInfoWindow();
|
|
||||||
});
|
|
||||||
|
|
||||||
classSelectionWindow->AddComponent("Warrior Button",warriorButton);
|
for(int i=0;i<6;i++){
|
||||||
classSelectionWindow->AddComponent("Ranger Button",rangerButton);
|
std::string className=classNames[i];
|
||||||
classSelectionWindow->AddComponent("Wizard Button",wizardButton);
|
std::string classAnimationName=classAnimationNames[i];
|
||||||
classSelectionWindow->AddComponent("Thief Button",thiefButton);
|
vf2d offsetPos={
|
||||||
classSelectionWindow->AddComponent("Trapper Button",trapperButton);
|
buttonStartPos.x+(buttonSize.x+buttonPadding.x)*float(i%3),
|
||||||
classSelectionWindow->AddComponent("Witch Button",witchButton);
|
buttonStartPos.y+(buttonSize.y+buttonPadding.y+2*outlineSize.y/9)*float(i/3)+2*outlineSize.y/9,
|
||||||
|
};
|
||||||
|
vf2d backgroundOffsetPos={
|
||||||
|
buttonStartPos.x+(buttonSize.x+buttonPadding.x)*float(i%3),
|
||||||
|
buttonStartPos.y+(buttonSize.y+buttonPadding.y+2*outlineSize.y/9)*float(i/3),
|
||||||
|
};
|
||||||
|
vf2d backgroundSize={floor(outlineSize.y/3-buttonPadding.y*3),outlineSize.y/3-buttonPadding.y*3}; //The floor is for fixing a small pixel rounding bug.
|
||||||
|
MenuLabel*backgroundOutline=new MenuLabel(CLASS_SELECTION,{backgroundOffsetPos,backgroundSize},"",1,true,false,true,true);
|
||||||
|
MenuLabel*classLabel=new MenuLabel(CLASS_SELECTION,{backgroundOffsetPos,buttonSize},className,1,true,true);
|
||||||
|
MenuAnimatedIconButton*classSprite=new MenuAnimatedIconButton(CLASS_SELECTION,{backgroundOffsetPos+vf2d{0,12},backgroundSize+vf2d{0,-buttonSize.y-12}},classAnimationName,[](MenuFuncData data){},false);
|
||||||
|
MenuComponent*classButton=new MenuComponent(CLASS_SELECTION,{offsetPos,buttonSize},"Info",CLASS_INFO,
|
||||||
|
[](MenuFuncData data){
|
||||||
|
data.menu.S(A::CLASS_SELECTION)=data.component->S(A::CLASS_SELECTION);
|
||||||
|
delete Menu::menus[CLASS_INFO];
|
||||||
|
Menu::InitializeClassInfoWindow();
|
||||||
|
});
|
||||||
|
classButton->S(A::CLASS_SELECTION)=className;
|
||||||
|
classSelectionWindow->AddComponent(className+" Button",classButton);
|
||||||
|
classSelectionWindow->AddComponent(className+" Background",backgroundOutline);
|
||||||
|
classSelectionWindow->AddComponent(className+" Label",classLabel);
|
||||||
|
classSelectionWindow->AddComponent(className+" Icon",classSprite);
|
||||||
|
}
|
||||||
}
|
}
|
@ -109,6 +109,14 @@ bool Crawler::OnUserCreate(){
|
|||||||
InitializeGraphics();
|
InitializeGraphics();
|
||||||
InitializeClasses();
|
InitializeClasses();
|
||||||
|
|
||||||
|
Monster::InitializeStrategies();
|
||||||
|
//Animations
|
||||||
|
sig::Animation::InitializeAnimations();
|
||||||
|
MonsterData::InitializeMonsterData();
|
||||||
|
|
||||||
|
sig::Animation::SetupPlayerAnimations();
|
||||||
|
view=TileTransformedView{GetScreenSize(),{1,1}};
|
||||||
|
|
||||||
Menu::InitializeMenus();
|
Menu::InitializeMenus();
|
||||||
|
|
||||||
Inventory::AddItem("Small Health Potion",16);
|
Inventory::AddItem("Small Health Potion",16);
|
||||||
@ -130,14 +138,6 @@ bool Crawler::OnUserCreate(){
|
|||||||
Inventory::AddItem("Bandages",10);
|
Inventory::AddItem("Bandages",10);
|
||||||
Inventory::AddItem("Blue Slime Remains",22);
|
Inventory::AddItem("Blue Slime Remains",22);
|
||||||
|
|
||||||
Monster::InitializeStrategies();
|
|
||||||
//Animations
|
|
||||||
sig::Animation::InitializeAnimations();
|
|
||||||
MonsterData::InitializeMonsterData();
|
|
||||||
|
|
||||||
sig::Animation::SetupPlayerAnimations();
|
|
||||||
view=TileTransformedView{GetScreenSize(),{1,1}};
|
|
||||||
|
|
||||||
LoadLevel(LEVEL_NAMES["starting_map"_S]);
|
LoadLevel(LEVEL_NAMES["starting_map"_S]);
|
||||||
ChangePlayerClass(WARRIOR);
|
ChangePlayerClass(WARRIOR);
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Desktop|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Desktop|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
@ -219,7 +219,7 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Desktop|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Desktop|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
@ -331,6 +331,7 @@
|
|||||||
<ClCompile Include="MainMenuWindow.cpp" />
|
<ClCompile Include="MainMenuWindow.cpp" />
|
||||||
<ClCompile Include="Map.cpp" />
|
<ClCompile Include="Map.cpp" />
|
||||||
<ClCompile Include="Menu.cpp" />
|
<ClCompile Include="Menu.cpp" />
|
||||||
|
<ClCompile Include="MenuAnimatedIconButton.h" />
|
||||||
<ClCompile Include="MenuComponent.cpp" />
|
<ClCompile Include="MenuComponent.cpp" />
|
||||||
<ClCompile Include="Meteor.cpp" />
|
<ClCompile Include="Meteor.cpp" />
|
||||||
<ClCompile Include="RunAway.cpp" />
|
<ClCompile Include="RunAway.cpp" />
|
||||||
|
@ -350,6 +350,9 @@
|
|||||||
<ClCompile Include="MainMenuWindow.cpp">
|
<ClCompile Include="MainMenuWindow.cpp">
|
||||||
<Filter>Source Files\Interface</Filter>
|
<Filter>Source Files\Interface</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="MenuAnimatedIconButton.h">
|
||||||
|
<Filter>Header Files\Interface</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="cpp.hint" />
|
<None Include="cpp.hint" />
|
||||||
|
@ -14,6 +14,18 @@ safeunorderedmap<std::string,Theme>Menu::themes;
|
|||||||
safemap<ITCategory,std::vector<MenuComponent*>>Menu::inventoryListeners;
|
safemap<ITCategory,std::vector<MenuComponent*>>Menu::inventoryListeners;
|
||||||
const vf2d Menu::CENTERED = {-456,-456};
|
const vf2d Menu::CENTERED = {-456,-456};
|
||||||
std::vector<MenuComponent*>Menu::unhandledComponents;
|
std::vector<MenuComponent*>Menu::unhandledComponents;
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
///__/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//| |////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//| |/////WARNING! If you are adding something here you likely are adding another container with MenuComponent pointers in it right now.
|
||||||
|
//| |/////Because we are handling raw pointers, you must also add this container to the list of iterating search removal contains that occur in the
|
||||||
|
//| |/////DESTRUCTOR of MenuComponents!!!!! THIS IS NOT A DRILL!
|
||||||
|
//|__|////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
///__/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//|__/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
MenuType Menu::lastMenuTypeCreated;
|
MenuType Menu::lastMenuTypeCreated;
|
||||||
std::string Menu::lastRegisteredComponent;
|
std::string Menu::lastRegisteredComponent;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ private:
|
|||||||
static void InitializeClassInfoWindow();
|
static void InitializeClassInfoWindow();
|
||||||
static void InitializeClassSelectionWindow();
|
static void InitializeClassSelectionWindow();
|
||||||
static void InitializeMainMenuWindow();
|
static void InitializeMainMenuWindow();
|
||||||
//X (0-3), Y (0-2) for specific 9-patch tile (tiled version).
|
//X (0-2), Y (0-2) for specific 9-patch tile (tiled version).
|
||||||
static Renderable&GetPatchPart(int x,int y);
|
static Renderable&GetPatchPart(int x,int y);
|
||||||
|
|
||||||
void KeyboardButtonNavigation(Crawler*game,vf2d menuPos);
|
void KeyboardButtonNavigation(Crawler*game,vf2d menuPos);
|
||||||
|
28
Crawler/MenuAnimatedIconButton.h
Normal file
28
Crawler/MenuAnimatedIconButton.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "MenuIconButton.h"
|
||||||
|
#include "DEFINES.h"
|
||||||
|
#include "Crawler.h"
|
||||||
|
|
||||||
|
INCLUDE_game
|
||||||
|
INCLUDE_ANIMATION_DATA
|
||||||
|
|
||||||
|
class MenuAnimatedIconButton:public MenuIconButton{
|
||||||
|
protected:
|
||||||
|
std::string animation;
|
||||||
|
private:
|
||||||
|
float animationTime=0;
|
||||||
|
public:
|
||||||
|
inline MenuAnimatedIconButton(MenuType parent,geom2d::rect<float>rect,std::string animation,MenuFunc onClick,bool selectable=true)
|
||||||
|
:MenuIconButton(parent,rect,nullptr,onClick,selectable),animation(animation){}
|
||||||
|
protected:
|
||||||
|
virtual inline void Update(Crawler*game)override{
|
||||||
|
MenuIconButton::Update(game);
|
||||||
|
animationTime+=game->GetElapsedTime();
|
||||||
|
}
|
||||||
|
virtual inline void Draw(Crawler*game,vf2d parentPos,bool focused)override{
|
||||||
|
MenuComponent::Draw(game,parentPos,focused); //INTENTIONAL! The way we draw animations is different from static images, we skip over MenuIconButton's draw!
|
||||||
|
Sprite*spr=ANIMATION_DATA[animation].GetFrame(animationTime).GetSourceImage()->Sprite();
|
||||||
|
geom2d::rect<int>sprRect=ANIMATION_DATA[animation].GetFrame(animationTime).GetSourceRect();
|
||||||
|
game->DrawPartialSprite(parentPos+rect.middle()-sprRect.size/2,spr,sprRect.pos,sprRect.size,1,Sprite::Flip::NONE);
|
||||||
|
}
|
||||||
|
};
|
@ -107,3 +107,7 @@ vf2d MenuComponent::GetPos(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MenuComponent::OnInventorySlotsUpdate(ITCategory cat){}
|
void MenuComponent::OnInventorySlotsUpdate(ITCategory cat){}
|
||||||
|
|
||||||
|
std::string MenuComponent::GetLabel(){
|
||||||
|
return label;
|
||||||
|
}
|
@ -52,4 +52,5 @@ public:
|
|||||||
virtual bool HandleOutsideDisabledButtonSelection(MenuComponent*disabledButton);
|
virtual bool HandleOutsideDisabledButtonSelection(MenuComponent*disabledButton);
|
||||||
//Called whenever an inventory slot gets updated, whether it's adding or removing an item.
|
//Called whenever an inventory slot gets updated, whether it's adding or removing an item.
|
||||||
virtual void OnInventorySlotsUpdate(ITCategory cat);
|
virtual void OnInventorySlotsUpdate(ITCategory cat);
|
||||||
|
std::string GetLabel();
|
||||||
};
|
};
|
@ -9,8 +9,8 @@ class MenuIconButton:public MenuComponent{
|
|||||||
protected:
|
protected:
|
||||||
Decal*icon;
|
Decal*icon;
|
||||||
public:
|
public:
|
||||||
inline MenuIconButton(MenuType parent,geom2d::rect<float>rect,Decal*icon,MenuFunc onClick)
|
inline MenuIconButton(MenuType parent,geom2d::rect<float>rect,Decal*icon,MenuFunc onClick,bool selectable=true)
|
||||||
:MenuComponent(parent,rect,"",onClick),icon(icon){}
|
:MenuComponent(parent,rect,"",onClick,selectable),icon(icon){}
|
||||||
protected:
|
protected:
|
||||||
virtual inline void Update(Crawler*game)override{
|
virtual inline void Update(Crawler*game)override{
|
||||||
MenuComponent::Update(game);
|
MenuComponent::Update(game);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 2335
|
#define VERSION_BUILD 2391
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 9.1 KiB |
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user