Added hover button functionality to MenuItemButton component and to InventorySrollableWindowComponent item buttons created via that component. Implemented inventory screen.
This commit is contained in:
parent
e4f63a3550
commit
5abc789bcd
@ -55,15 +55,25 @@ private:
|
|||||||
std::string itemDescriptionLabelName;
|
std::string itemDescriptionLabelName;
|
||||||
bool inventoryButtonsActive=true;
|
bool inventoryButtonsActive=true;
|
||||||
std::function<bool(MenuFuncData)>inventoryButtonClickAction;
|
std::function<bool(MenuFuncData)>inventoryButtonClickAction;
|
||||||
|
std::function<bool(MenuFuncData)>inventoryButtonHoverAction;
|
||||||
|
std::function<bool(MenuFuncData)>inventoryButtonMouseOutAction;
|
||||||
InventoryWindowOptions options;
|
InventoryWindowOptions options;
|
||||||
|
CompactText compact=COMPACT;
|
||||||
protected:
|
protected:
|
||||||
ITCategory inventoryType;
|
ITCategory inventoryType;
|
||||||
public:
|
public:
|
||||||
inline InventoryScrollableWindowComponent(geom2d::rect<float>rect,ITCategory invType,std::string itemNameLabelName,std::string itemDescriptionLabelName,std::function<bool(MenuFuncData)>inventoryButtonClickAction,InventoryWindowOptions options={.padding=8,.size=24},bool inventoryButtonsActive=true,ComponentAttr attributes=ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE)
|
inline InventoryScrollableWindowComponent(geom2d::rect<float>rect,ITCategory invType,std::string itemNameLabelName,std::string itemDescriptionLabelName,std::function<bool(MenuFuncData)>inventoryButtonClickAction,InventoryWindowOptions options={.padding=8,.size=24},bool inventoryButtonsActive=true,ComponentAttr attributes=ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE)
|
||||||
:ScrollableWindowComponent(rect,attributes),inventoryType(invType),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName),
|
:ScrollableWindowComponent(rect,attributes),inventoryType(invType),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName),
|
||||||
options(options),inventoryButtonClickAction(inventoryButtonClickAction),inventoryButtonsActive(inventoryButtonsActive){
|
options(options),inventoryButtonClickAction(inventoryButtonClickAction),inventoryButtonsActive(inventoryButtonsActive){
|
||||||
|
this->inventoryButtonHoverAction=DO_NOTHING;
|
||||||
|
this->inventoryButtonMouseOutAction=DO_NOTHING;
|
||||||
Menu::AddInventoryListener(this,invType);
|
Menu::AddInventoryListener(this,invType);
|
||||||
}
|
}
|
||||||
|
inline InventoryScrollableWindowComponent(geom2d::rect<float>rect,ITCategory invType,std::string itemNameLabelName,std::string itemDescriptionLabelName,std::function<bool(MenuFuncData)>inventoryButtonClickAction,std::function<bool(MenuFuncData)>inventoryButtonHoverAction,std::function<bool(MenuFuncData)>inventoryButtonMouseOutAction,InventoryWindowOptions options={.padding=8,.size=24},bool inventoryButtonsActive=true,ComponentAttr attributes=ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE)
|
||||||
|
:InventoryScrollableWindowComponent(rect,invType,itemNameLabelName,itemDescriptionLabelName,inventoryButtonClickAction,options,inventoryButtonsActive,attributes){
|
||||||
|
this->inventoryButtonHoverAction=inventoryButtonHoverAction;
|
||||||
|
this->inventoryButtonMouseOutAction=inventoryButtonMouseOutAction;
|
||||||
|
}
|
||||||
virtual inline void Update(Crawler*game)override{
|
virtual inline void Update(Crawler*game)override{
|
||||||
ScrollableWindowComponent::Update(game);
|
ScrollableWindowComponent::Update(game);
|
||||||
bool noneHovered=true;
|
bool noneHovered=true;
|
||||||
@ -78,6 +88,16 @@ public:
|
|||||||
if(itemDescriptionLabelName.length()>0)Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->SetLabel("");
|
if(itemDescriptionLabelName.length()>0)Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->SetLabel("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
inline void SetCompactDescriptions(bool compact){
|
||||||
|
if(compact)this->compact=COMPACT;
|
||||||
|
else this->compact=NON_COMPACT;
|
||||||
|
for(MenuComponent*component:components){
|
||||||
|
MenuItemButton*itemButton=dynamic_cast<MenuItemButton*>(component);
|
||||||
|
if(itemButton){
|
||||||
|
itemButton->SetCompactDescriptions(compact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
inline void RemoveEmptySlots(){
|
inline void RemoveEmptySlots(){
|
||||||
//Algorithm will iterate through all slots, finding blank slots. Each time a blank slot is found, all items will shift over by one, and then the last item will be removed. Repeat until all slots iterated through.
|
//Algorithm will iterate through all slots, finding blank slots. Each time a blank slot is found, all items will shift over by one, and then the last item will be removed. Repeat until all slots iterated through.
|
||||||
@ -111,7 +131,8 @@ protected:
|
|||||||
int buttonSize=options.size;
|
int buttonSize=options.size;
|
||||||
int totalSpacing=options.padding+buttonSize;
|
int totalSpacing=options.padding+buttonSize;
|
||||||
|
|
||||||
ADD("item_"+cat+"_"+std::to_string(itemIndex),MenuItemButton)({{float(totalSpacing*x),float(totalSpacing*y)},{float(buttonSize),float(buttonSize)}},Inventory::get(cat),itemIndex,inventoryButtonClickAction,parentMenu,itemNameLabelName,itemDescriptionLabelName,inventoryButtonsActive?IconButtonAttr::SELECTABLE:IconButtonAttr::NOT_SELECTABLE)END;
|
ADD("item_"+cat+"_"+std::to_string(itemIndex),MenuItemButton)({{float(totalSpacing*x),float(totalSpacing*y)},{float(buttonSize),float(buttonSize)}},Inventory::get(cat),itemIndex,inventoryButtonClickAction,inventoryButtonHoverAction,inventoryButtonMouseOutAction,parentMenu,itemNameLabelName,itemDescriptionLabelName,inventoryButtonsActive?IconButtonAttr::SELECTABLE:IconButtonAttr::NOT_SELECTABLE)END
|
||||||
|
->SetCompactDescriptions(compact==COMPACT);
|
||||||
}else
|
}else
|
||||||
if(components.size()>invSize){ //There are empty spots, so let's clean up.
|
if(components.size()>invSize){ //There are empty spots, so let's clean up.
|
||||||
RemoveEmptySlots();
|
RemoveEmptySlots();
|
||||||
|
@ -40,6 +40,9 @@ All rights reserved.
|
|||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "MenuLabel.h"
|
#include "MenuLabel.h"
|
||||||
#include "InventoryScrollableWindowComponent.h"
|
#include "InventoryScrollableWindowComponent.h"
|
||||||
|
#include "MenuIconButton.h"
|
||||||
|
#include "MenuItemButton.h"
|
||||||
|
#include "MenuItemItemButton.h"
|
||||||
|
|
||||||
INCLUDE_game
|
INCLUDE_game
|
||||||
INCLUDE_ITEM_CATEGORIES
|
INCLUDE_ITEM_CATEGORIES
|
||||||
@ -84,7 +87,15 @@ void Menu::InitializeInventoryWindow(){
|
|||||||
button->SetSelectionType(HIGHLIGHT);
|
button->SetSelectionType(HIGHLIGHT);
|
||||||
button->S(A::CATEGORY_NAME)=category;
|
button->S(A::CATEGORY_NAME)=category;
|
||||||
|
|
||||||
auto inventoryDisplay=inventoryWindow->ADD("Inventory Display - "+category,InventoryScrollableWindowComponent)({{72,28},{150,inventoryWindow->size.y-44}},category,"","",DO_NOTHING)END;
|
auto inventoryDisplay=inventoryWindow->ADD("Inventory Display - "+category,InventoryScrollableWindowComponent)({{72,28},{150,inventoryWindow->size.y-44}},category,"Item Name Label","Item Description Label",DO_NOTHING,
|
||||||
|
[](MenuFuncData data){
|
||||||
|
Component<MenuItemItemButton>(data.menu.GetType(),"Item Icon")->SetItem(dynamic_cast<MenuItemButton*>(data.component)->GetItem());
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
[](MenuFuncData data){
|
||||||
|
Component<MenuItemItemButton>(data.menu.GetType(),"Item Icon")->SetItem(Item::BLANK);
|
||||||
|
return true;
|
||||||
|
})END;
|
||||||
|
|
||||||
if(first){
|
if(first){
|
||||||
lastInventoryTypeOpened=category;
|
lastInventoryTypeOpened=category;
|
||||||
@ -92,9 +103,24 @@ void Menu::InitializeInventoryWindow(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
inventoryDisplay->Enable(first);
|
inventoryDisplay->Enable(first);
|
||||||
|
inventoryDisplay->SetCompactDescriptions(false);
|
||||||
|
|
||||||
yOffset+=20;
|
yOffset+=20;
|
||||||
first=false;
|
first=false;
|
||||||
}
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Inventory Description
|
||||||
|
float inventoryDescriptionWidth=inventoryWindow->pos.x+inventoryWindow->size.x-26-224;
|
||||||
|
inventoryWindow->ADD("Item Description Outline",MenuLabel)({{224,28},{inventoryDescriptionWidth,inventoryWindow->size.y-44}},"",1,LEFT_ALIGN|OUTLINE|BACKGROUND)END
|
||||||
|
->decal=true;
|
||||||
|
auto itemIcon=inventoryWindow->ADD("Item Icon",MenuItemItemButton)({{226+inventoryDescriptionWidth/2-24,30},{48,48}},Item::BLANK,MenuType::ENUM_END,DO_NOTHING,"","",IconButtonAttr::NOT_SELECTABLE)END;
|
||||||
|
itemIcon->SetShowQuantity(false);
|
||||||
|
itemIcon->decal=true;
|
||||||
|
inventoryWindow->ADD("Item Name Label",MenuLabel)({{226,84},{inventoryDescriptionWidth-6,12}},"",0.75f,LEFT_ALIGN|SHADOW)END
|
||||||
|
->decal=true;
|
||||||
|
inventoryWindow->ADD("Item Description Label",MenuLabel)({{226,94},{inventoryDescriptionWidth-6,inventoryWindow->size.y-44-66}},"",0.5f,LEFT_ALIGN|SHADOW)END
|
||||||
|
->decal=true;
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
}
|
}
|
@ -96,7 +96,6 @@ protected:
|
|||||||
bool disabled=false; //If set to true, this component will not be rendered or updated.
|
bool disabled=false; //If set to true, this component will not be rendered or updated.
|
||||||
bool renderInMain=true; //If set to false, this component is the responsibility of some other windowing system and won't be rendered or updated via the main window loop.
|
bool renderInMain=true; //If set to false, this component is the responsibility of some other windowing system and won't be rendered or updated via the main window loop.
|
||||||
bool valid=true; //If set to false, this would cause the component to be removed.
|
bool valid=true; //If set to false, this would cause the component to be removed.
|
||||||
bool decal=false; //If set to true, will use decal rendering (For foreground shenanigans)
|
|
||||||
vf2d labelScaling={1,1};
|
vf2d labelScaling={1,1};
|
||||||
virtual void Update(Crawler*game);
|
virtual void Update(Crawler*game);
|
||||||
virtual void Draw(Crawler*game,vf2d parentPos);
|
virtual void Draw(Crawler*game,vf2d parentPos);
|
||||||
@ -130,4 +129,5 @@ public:
|
|||||||
virtual void SetSelectionType(SelectionType selectionType)final;
|
virtual void SetSelectionType(SelectionType selectionType)final;
|
||||||
virtual void Enable(bool enabled);
|
virtual void Enable(bool enabled);
|
||||||
virtual void Cleanup();
|
virtual void Cleanup();
|
||||||
|
bool decal=false; //If set to true, will use decal rendering (For foreground shenanigans)
|
||||||
};
|
};
|
@ -60,11 +60,21 @@ protected:
|
|||||||
MenuComponent::Update(game);
|
MenuComponent::Update(game);
|
||||||
}
|
}
|
||||||
virtual inline void Draw(Crawler*game,vf2d parentPos)override{
|
virtual inline void Draw(Crawler*game,vf2d parentPos)override{
|
||||||
|
if(!decal){
|
||||||
MenuComponent::Draw(game,parentPos);
|
MenuComponent::Draw(game,parentPos);
|
||||||
if(icon!=nullptr){
|
if(icon!=nullptr){
|
||||||
game->DrawSprite(parentPos+rect.middle()-icon->sprite->Size()/2,icon->sprite,1,Sprite::Flip::NONE);
|
game->DrawSprite(parentPos+rect.middle()-icon->sprite->Size()/2,icon->sprite,1,Sprite::Flip::NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
virtual inline void DrawDecal(Crawler*game,vf2d parentPos,bool focused)override{
|
||||||
|
if(decal){
|
||||||
|
MenuComponent::DrawDecal(game,parentPos,focused);
|
||||||
|
if(icon!=nullptr){
|
||||||
|
game->DrawDecal(Menu::menus[parentMenu]->pos+parentPos+rect.middle()-icon->sprite->Size()/2,icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr auto operator|(IconButtonAttr attribute,IconButtonAttr attribute2) noexcept
|
constexpr auto operator|(IconButtonAttr attribute,IconButtonAttr attribute2) noexcept
|
||||||
|
@ -56,6 +56,11 @@ private:
|
|||||||
MenuType itemDescriptionMenu;
|
MenuType itemDescriptionMenu;
|
||||||
std::string itemNameLabelName;
|
std::string itemNameLabelName;
|
||||||
std::string itemDescriptionLabelName;
|
std::string itemDescriptionLabelName;
|
||||||
|
CompactText compact=COMPACT;
|
||||||
|
bool hoverState=false;
|
||||||
|
bool runHoverFunctions=false;
|
||||||
|
MenuFunc onHover;
|
||||||
|
MenuFunc onMouseOut;
|
||||||
public:
|
public:
|
||||||
int selected=-1; //0-2 representing which loadout slot this item consumes. -1 means not selected.
|
int selected=-1; //0-2 representing which loadout slot this item consumes. -1 means not selected.
|
||||||
inline MenuItemButton(geom2d::rect<float>rect,std::vector<Item>&invRef,int invIndex,MenuFunc onClick,MenuType itemDescriptionMenu,std::string itemNameLabelName,std::string itemDescriptionLabelName,IconButtonAttr attributes=IconButtonAttr::SELECTABLE)
|
inline MenuItemButton(geom2d::rect<float>rect,std::vector<Item>&invRef,int invIndex,MenuFunc onClick,MenuType itemDescriptionMenu,std::string itemNameLabelName,std::string itemDescriptionLabelName,IconButtonAttr attributes=IconButtonAttr::SELECTABLE)
|
||||||
@ -63,7 +68,13 @@ public:
|
|||||||
draggable=false;
|
draggable=false;
|
||||||
valid=invRef.size()>invIndex;
|
valid=invRef.size()>invIndex;
|
||||||
}
|
}
|
||||||
inline Item GetItem(){
|
inline MenuItemButton(geom2d::rect<float>rect,std::vector<Item>&invRef,int invIndex,MenuFunc onClick,MenuFunc onHover,MenuFunc onMouseOut,MenuType itemDescriptionMenu,std::string itemNameLabelName,std::string itemDescriptionLabelName,IconButtonAttr attributes=IconButtonAttr::SELECTABLE)
|
||||||
|
:MenuIconButton(rect,invRef.size()>invIndex?invRef[invIndex].Decal():nullptr,onClick,attributes),onHover(onHover),onMouseOut(onMouseOut),invRef(invRef),inventoryIndex(invIndex),itemDescriptionMenu(itemDescriptionMenu),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName){
|
||||||
|
draggable=false;
|
||||||
|
runHoverFunctions=true;
|
||||||
|
valid=invRef.size()>invIndex;
|
||||||
|
}
|
||||||
|
inline Item&GetItem(){
|
||||||
return Inventory::GetItem(invRef.at(inventoryIndex).Name());
|
return Inventory::GetItem(invRef.at(inventoryIndex).Name());
|
||||||
}
|
}
|
||||||
//Returns true if the item has been consumed completely and there are 0 remaining of that type in our inventory.
|
//Returns true if the item has been consumed completely and there are 0 remaining of that type in our inventory.
|
||||||
@ -71,31 +82,67 @@ public:
|
|||||||
if(invRef.size()<=inventoryIndex)return false;
|
if(invRef.size()<=inventoryIndex)return false;
|
||||||
return Inventory::UseItem(invRef.at(inventoryIndex).Name(),amt);
|
return Inventory::UseItem(invRef.at(inventoryIndex).Name(),amt);
|
||||||
}
|
}
|
||||||
|
inline void SetCompactDescriptions(bool compact){
|
||||||
|
if(compact)this->compact=COMPACT;
|
||||||
|
else this->compact=NON_COMPACT;
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
|
virtual inline void BeforeUpdate(Crawler*game)override{
|
||||||
|
if(!hovered&&runHoverFunctions&&hoverState){
|
||||||
|
hoverState=false;
|
||||||
|
if(itemNameLabelName!=""){
|
||||||
|
Component<MenuLabel>(parentMenu,itemNameLabelName)->Enable(false);
|
||||||
|
}
|
||||||
|
if(itemDescriptionLabelName!=""){
|
||||||
|
Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->Enable(false);
|
||||||
|
}
|
||||||
|
onMouseOut(MenuFuncData{*Menu::menus[parentMenu],game,this,(ScrollableWindowComponent*)(parentComponent)});
|
||||||
|
}
|
||||||
|
}
|
||||||
virtual inline void Update(Crawler*game)override{
|
virtual inline void Update(Crawler*game)override{
|
||||||
MenuIconButton::Update(game);
|
MenuIconButton::Update(game);
|
||||||
valid=invRef.size()>inventoryIndex&&ITEM_DATA.count(invRef[inventoryIndex].Name());
|
valid=invRef.size()>inventoryIndex&&ITEM_DATA.count(invRef[inventoryIndex].Name());
|
||||||
|
std::string labelNameText;
|
||||||
|
std::string labelDescriptionText;
|
||||||
if(valid){
|
if(valid){
|
||||||
icon=invRef[inventoryIndex].Decal();
|
icon=invRef[inventoryIndex].Decal();
|
||||||
if(hovered){
|
labelNameText=invRef[inventoryIndex].Name();
|
||||||
if(itemNameLabelName.length()>0)Component<MenuLabel>(itemDescriptionMenu,itemNameLabelName)->label=invRef[inventoryIndex].Name();
|
labelDescriptionText=invRef[inventoryIndex].Description(compact);
|
||||||
if(itemDescriptionLabelName.length()>0)Component<MenuLabel>(itemDescriptionMenu,itemDescriptionLabelName)->label=invRef[inventoryIndex].Description();
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
icon=nullptr;
|
icon=nullptr;
|
||||||
|
labelNameText="";
|
||||||
|
labelDescriptionText="";
|
||||||
|
}
|
||||||
|
|
||||||
if(hovered){
|
if(hovered){
|
||||||
if(itemNameLabelName.length()>0)Component<MenuLabel>(itemDescriptionMenu,itemNameLabelName)->label="";
|
if(itemNameLabelName!=""){
|
||||||
if(itemDescriptionLabelName.length()>0)Component<MenuLabel>(itemDescriptionMenu,itemDescriptionLabelName)->label="";
|
Component<MenuLabel>(parentMenu,itemNameLabelName)->label=labelNameText;
|
||||||
|
}
|
||||||
|
if(itemDescriptionLabelName!=""){
|
||||||
|
Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->label=labelDescriptionText;
|
||||||
|
}
|
||||||
|
if(runHoverFunctions&&!hoverState){
|
||||||
|
hoverState=true;
|
||||||
|
if(itemNameLabelName!=""&&labelNameText.length()>0){
|
||||||
|
Component<MenuLabel>(parentMenu,itemNameLabelName)->Enable(true);
|
||||||
|
}
|
||||||
|
if(itemDescriptionLabelName!=""&&labelDescriptionText.length()>0){
|
||||||
|
Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->Enable(true);
|
||||||
|
}
|
||||||
|
onHover(MenuFuncData{*Menu::menus[parentMenu],game,this,(ScrollableWindowComponent*)(parentComponent)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual inline void Draw(Crawler*game,vf2d parentPos)override{
|
virtual inline void Draw(Crawler*game,vf2d parentPos)override{
|
||||||
|
if(!decal){
|
||||||
MenuIconButton::Draw(game,parentPos);
|
MenuIconButton::Draw(game,parentPos);
|
||||||
if(selected!=-1){
|
if(selected!=-1){
|
||||||
drawutil::DrawCrosshair(game,{parentPos+rect.pos,rect.size},0);
|
drawutil::DrawCrosshair(game,{parentPos+rect.pos,rect.size},0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
virtual inline void DrawDecal(Crawler*game,vf2d parentPos,bool focused)override{
|
virtual inline void DrawDecal(Crawler*game,vf2d parentPos,bool focused)override{
|
||||||
|
if(decal){
|
||||||
MenuIconButton::DrawDecal(game,parentPos,focused);
|
MenuIconButton::DrawDecal(game,parentPos,focused);
|
||||||
if(valid){
|
if(valid){
|
||||||
int itemQuantity=Inventory::GetItemCount(invRef.at(inventoryIndex).Name()); //Normally we'd retrieve how many of this item we have from our inventory...However Monster Loot and Stage Loot inventories are special and hold their own inventory counts...
|
int itemQuantity=Inventory::GetItemCount(invRef.at(inventoryIndex).Name()); //Normally we'd retrieve how many of this item we have from our inventory...However Monster Loot and Stage Loot inventories are special and hold their own inventory counts...
|
||||||
@ -110,6 +157,7 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
inline MenuComponent*PickUpDraggableItem()override final{
|
inline MenuComponent*PickUpDraggableItem()override final{
|
||||||
if(valid){
|
if(valid){
|
||||||
MenuItemButton*pickUp=NEW MenuItemButton(rect,invRef,inventoryIndex,onClick,itemDescriptionMenu,itemNameLabelName,itemDescriptionLabelName);
|
MenuItemButton*pickUp=NEW MenuItemButton(rect,invRef,inventoryIndex,onClick,itemDescriptionMenu,itemNameLabelName,itemDescriptionLabelName);
|
||||||
|
@ -60,13 +60,13 @@ private:
|
|||||||
bool hideQty=false;
|
bool hideQty=false;
|
||||||
CompactText compact=COMPACT;
|
CompactText compact=COMPACT;
|
||||||
public:
|
public:
|
||||||
inline MenuItemItemButton(geom2d::rect<float>rect,Item&itemRef,MenuType menuDest,MenuFunc onClick,std::string itemNameLabelName,std::string itemDescriptionLabelName)
|
inline MenuItemItemButton(geom2d::rect<float>rect,Item&itemRef,MenuType menuDest,MenuFunc onClick,std::string itemNameLabelName,std::string itemDescriptionLabelName,IconButtonAttr attributes=IconButtonAttr::SELECTABLE)
|
||||||
:MenuIconButton(rect,(!itemRef.IsBlank())?itemRef.Decal():nullptr,menuDest,onClick),itemRef(itemRef),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName),onHover(DO_NOTHING){
|
:MenuIconButton(rect,(!itemRef.IsBlank())?itemRef.Decal():nullptr,menuDest,onClick,attributes),itemRef(itemRef),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName),onHover(DO_NOTHING){
|
||||||
draggable=false;
|
draggable=false;
|
||||||
valid=!itemRef.IsBlank();
|
valid=!itemRef.IsBlank();
|
||||||
}
|
}
|
||||||
inline MenuItemItemButton(geom2d::rect<float>rect,Item&itemRef,MenuType menuDest,MenuFunc onClick,MenuFunc onHover,MenuFunc onMouseOut,std::string itemNameLabelName="",std::string itemDescriptionLabelName="")
|
inline MenuItemItemButton(geom2d::rect<float>rect,Item&itemRef,MenuType menuDest,MenuFunc onClick,MenuFunc onHover,MenuFunc onMouseOut,std::string itemNameLabelName="",std::string itemDescriptionLabelName="",IconButtonAttr attributes=IconButtonAttr::SELECTABLE)
|
||||||
:MenuIconButton(rect,(!itemRef.IsBlank())?itemRef.Decal():nullptr,menuDest,onClick),itemRef(itemRef),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName),onHover(onHover),onMouseOut(onMouseOut){
|
:MenuIconButton(rect,(!itemRef.IsBlank())?itemRef.Decal():nullptr,menuDest,onClick,attributes),itemRef(itemRef),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName),onHover(onHover),onMouseOut(onMouseOut){
|
||||||
runHoverFunctions=true;
|
runHoverFunctions=true;
|
||||||
draggable=false;
|
draggable=false;
|
||||||
valid=!itemRef.IsBlank();
|
valid=!itemRef.IsBlank();
|
||||||
|
@ -45,16 +45,17 @@ INCLUDE_game
|
|||||||
|
|
||||||
class MenuLabel:public MenuComponent{
|
class MenuLabel:public MenuComponent{
|
||||||
private:
|
private:
|
||||||
int scale=1;
|
float scale=1;
|
||||||
protected:
|
protected:
|
||||||
bool shadow=false;
|
bool shadow=false;
|
||||||
bool centered=true;
|
bool centered=true;
|
||||||
public:
|
public:
|
||||||
inline MenuLabel(geom2d::rect<float>rect,std::string label,int 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),centered(!(attributes&ComponentAttr::LEFT_ALIGN)),shadow(attributes&ComponentAttr::SHADOW){
|
:MenuComponent(rect,label,MenuFunc{},ButtonAttr::UNSELECTABLE|ButtonAttr::UNSELECTABLE_VIA_KEYBOARD),scale(scale),centered(!(attributes&ComponentAttr::LEFT_ALIGN)),shadow(attributes&ComponentAttr::SHADOW){
|
||||||
border=attributes&ComponentAttr::OUTLINE;
|
border=attributes&ComponentAttr::OUTLINE;
|
||||||
this->background=attributes&ComponentAttr::BACKGROUND;
|
this->background=attributes&ComponentAttr::BACKGROUND;
|
||||||
showDefaultLabel=false;
|
showDefaultLabel=false;
|
||||||
|
if(fmod(scale,1)>0.001)decal=true;
|
||||||
}
|
}
|
||||||
inline virtual void SetLabel(std::string text){
|
inline virtual void SetLabel(std::string text){
|
||||||
label=text;
|
label=text;
|
||||||
|
@ -39,7 +39,7 @@ All rights reserved.
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 1
|
#define VERSION_PATCH 1
|
||||||
#define VERSION_BUILD 3761
|
#define VERSION_BUILD 3803
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user