Equipment window shows equip stat changes on mouseover.

pull/28/head
sigonasr2 12 months ago
parent 30287c91d2
commit e615831ded
  1. 2
      Crawler/CharacterInfoWindow.cpp
  2. 46
      Crawler/CharacterMenuWindow.cpp
  3. 2
      Crawler/ClassSelectionWindow.cpp
  4. 1
      Crawler/Crawler.cpp
  5. 2
      Crawler/InventoryConsumableWindow.cpp
  6. 2
      Crawler/InventoryScrollableWindowComponent.h
  7. 15
      Crawler/Item.cpp
  8. 9
      Crawler/Item.h
  9. 2
      Crawler/ItemLoadoutWindow.cpp
  10. 2
      Crawler/MainMenuWindow.cpp
  11. 2
      Crawler/Menu.cpp
  12. 2
      Crawler/Menu.h
  13. 2
      Crawler/MenuComponent.cpp
  14. 39
      Crawler/MenuItemItemButton.h
  15. 1
      Crawler/MonsterAttribute.h
  16. 2
      Crawler/OverworldMapLevelWindow.cpp
  17. 2
      Crawler/ScrollableWindowComponent.h
  18. 2
      Crawler/SlimeKing.cpp
  19. 2
      Crawler/TestSubMenu.cpp
  20. 2
      Crawler/Turret.cpp
  21. 2
      Crawler/Version.h

@ -45,7 +45,7 @@ All rights reserved.
INCLUDE_game INCLUDE_game
INCLUDE_GFX INCLUDE_GFX
INCLUDE_DATA INCLUDE_DATA
typedef Attribute A; using A=Attribute;
void Menu::InitializeClassInfoWindow(){ void Menu::InitializeClassInfoWindow(){
Menu*classInfoWindow=CreateMenu(CLASS_INFO,CENTERED,game->GetScreenSize()-vi2d{24,24}); Menu*classInfoWindow=CreateMenu(CLASS_INFO,CENTERED,game->GetScreenSize()-vi2d{24,24});

@ -130,7 +130,50 @@ void Menu::InitializeCharacterMenuWindow(){
MenuItemItemButton*comp=(MenuItemItemButton*)data.component; MenuItemItemButton*comp=(MenuItemItemButton*)data.component;
Inventory::EquipItem(comp->GetItem(),EquipSlot(comp->I(Attribute::EQUIP_TYPE))); Inventory::EquipItem(comp->GetItem(),EquipSlot(comp->I(Attribute::EQUIP_TYPE)));
return true; return true;
},MenuType::ENUM_END,"",""); },[&](MenuFuncData data){
MenuItemItemButton*button=(MenuItemItemButton*)data.component;
Item&buttonItem=button->GetItem();
const std::array<ItemAttribute,7>displayAttrs{
ItemAttribute::health,
ItemAttribute::attack,
ItemAttribute::defense,
ItemAttribute::moveSpdPct,
ItemAttribute::cdrPct,
ItemAttribute::critPct,
ItemAttribute::critDmgPct,
};
for(ItemAttribute attribute:displayAttrs){
int stat=buttonItem.GetStats().get(attribute);
if(stat>0){
MenuLabel*statDisplayLabel=Component<MenuLabel>(CHARACTER_MENU,"Attribute "+ItemAttributable::GetDisplayInfo(attribute).name+" Label");
std::string baseLabel=statDisplayLabel->S(Attribute::DISPLAY_TEXT);
std::string newLabel=baseLabel+" (+"+std::to_string(stat)+")";
statDisplayLabel->SetLabel(newLabel);
}
}
return true;
},[&](MenuFuncData data){
MenuItemItemButton*button=(MenuItemItemButton*)data.component;
Item&buttonItem=button->GetItem();
const std::array<ItemAttribute,7>displayAttrs{
ItemAttribute::health,
ItemAttribute::attack,
ItemAttribute::defense,
ItemAttribute::moveSpdPct,
ItemAttribute::cdrPct,
ItemAttribute::critPct,
ItemAttribute::critDmgPct,
};
for(ItemAttribute attribute:displayAttrs){
int stat=buttonItem.GetStats().get(attribute);
if(stat>0){
MenuLabel*statDisplayLabel=Component<MenuLabel>(CHARACTER_MENU,"Attribute "+ItemAttributable::GetDisplayInfo(attribute).name+" Label");
std::string baseLabel=statDisplayLabel->S(Attribute::DISPLAY_TEXT);
statDisplayLabel->SetLabel(baseLabel);
}
}
return true;
});
equip->I(Attribute::EQUIP_TYPE)=int(slot); equip->I(Attribute::EQUIP_TYPE)=int(slot);
equipList->AddComponent(Menu::menus[CHARACTER_MENU],"Equip Item "+std::to_string(counter),equip); equipList->AddComponent(Menu::menus[CHARACTER_MENU],"Equip Item "+std::to_string(counter),equip);
counter++; counter++;
@ -163,6 +206,7 @@ void Menu::InitializeCharacterMenuWindow(){
attrStr+="%"; attrStr+="%";
} }
MenuLabel*attrLabel=NEW MenuLabel(CHARACTER_MENU,{{245,36+2+float(yOffset)},{62,18}},attrStr,1,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN); MenuLabel*attrLabel=NEW MenuLabel(CHARACTER_MENU,{{245,36+2+float(yOffset)},{62,18}},attrStr,1,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN);
attrLabel->S(Attribute::DISPLAY_TEXT)=attrStr;
yOffset+=20; yOffset+=20;
characterMenuWindow->AddComponent("Attribute "+data.name+" Label",attrLabel); characterMenuWindow->AddComponent("Attribute "+data.name+" Label",attrLabel);
} }

@ -44,7 +44,7 @@ All rights reserved.
#include "ClassInfo.h" #include "ClassInfo.h"
INCLUDE_game INCLUDE_game
typedef Attribute A; using A=Attribute;
void Menu::InitializeClassSelectionWindow(){ void Menu::InitializeClassSelectionWindow(){
Menu*classSelectionWindow=CreateMenu(CLASS_SELECTION,CENTERED,game->GetScreenSize()-vi2d{24,24}); Menu*classSelectionWindow=CreateMenu(CLASS_SELECTION,CENTERED,game->GetScreenSize()-vi2d{24,24});

@ -192,6 +192,7 @@ bool Crawler::OnUserCreate(){
Inventory::AddItem("Dummy Item 13",6); Inventory::AddItem("Dummy Item 13",6);
Inventory::AddItem("Bandages",10); Inventory::AddItem("Bandages",10);
Inventory::AddItem("Blue Slime Remains",22); Inventory::AddItem("Blue Slime Remains",22);
Inventory::AddItem("Copper Armor");
LoadLevel(LEVEL_NAMES["starting_map"_S]); LoadLevel(LEVEL_NAMES["starting_map"_S]);
ChangePlayerClass(WARRIOR); ChangePlayerClass(WARRIOR);

@ -43,7 +43,7 @@ All rights reserved.
#include "MenuLabel.h" #include "MenuLabel.h"
#include "InventoryScrollableWindowComponent.h" #include "InventoryScrollableWindowComponent.h"
typedef Attribute A; using A=Attribute;
void Menu::InitializeConsumableInventoryWindow(){ void Menu::InitializeConsumableInventoryWindow(){
int invWidth="ThemeGlobal.InventoryWidth"_I; int invWidth="ThemeGlobal.InventoryWidth"_I;

@ -42,7 +42,7 @@ All rights reserved.
#include "Crawler.h" #include "Crawler.h"
#include "ScrollableWindowComponent.h" #include "ScrollableWindowComponent.h"
typedef Attribute A; using A=Attribute;
class InventoryScrollableWindowComponent:public ScrollableWindowComponent{ class InventoryScrollableWindowComponent:public ScrollableWindowComponent{
private: private:

@ -546,3 +546,18 @@ void ItemInfo::InitializeSets(){
} }
} }
} }
Stats ItemInfo::GetStats(int enhancementLevel){
if(enhancement.size()<=enhancementLevel){
return {};
}
return enhancement[enhancementLevel];
}
Stats Item::GetStats()const{
return it->GetStats(enhancementLevel);
};
const size_t EnhancementInfo::size()const{
return enhancementStats.size();
};

@ -48,10 +48,10 @@ class Crawler;
class ItemInfo; class ItemInfo;
class ItemProps; class ItemProps;
typedef std::string IT; using IT=std::string;
typedef std::string ITCategory; using ITCategory=std::string;
typedef std::function<bool(Crawler*,ItemProps)> ItemScript; using ItemScript=std::function<bool(Crawler*,ItemProps)>;
enum class EquipSlot{ enum class EquipSlot{
HELMET= 0b0000'0001, HELMET= 0b0000'0001,
@ -81,6 +81,7 @@ private:
public: public:
void SetAttribute(int enhanceLevel,ItemAttribute attribute,int value); void SetAttribute(int enhanceLevel,ItemAttribute attribute,int value);
const Stats&operator[](int level)const; const Stats&operator[](int level)const;
const size_t size()const;
}; };
//You cannot create instances of this class, access sets from ItemSet::sets and add the appropriate set bonuses. //You cannot create instances of this class, access sets from ItemSet::sets and add the appropriate set bonuses.
@ -112,6 +113,7 @@ public:
ITCategory Category(); ITCategory Category();
EquipSlot GetEquipSlot(); EquipSlot GetEquipSlot();
Decal*Decal(); Decal*Decal();
Stats GetStats()const;
ItemScript&OnUseAction(); ItemScript&OnUseAction();
float CastTime(); float CastTime();
float CooldownTime(); float CooldownTime();
@ -199,6 +201,7 @@ public:
For the useFunc, return true if the item can be used, false otherwise. For the useFunc, return true if the item can be used, false otherwise.
*/ */
ItemScript&OnUseAction(); ItemScript&OnUseAction();
Stats GetStats(int enhancementLevel);
float CastTime(); float CastTime();
float CooldownTime(); float CooldownTime();
EquipSlot Slot(); EquipSlot Slot();

@ -43,7 +43,7 @@ All rights reserved.
#include "State_OverworldMap.h" #include "State_OverworldMap.h"
INCLUDE_game INCLUDE_game
typedef Attribute A; using A=Attribute;
void Menu::InitializeItemLoadoutWindow(){ void Menu::InitializeItemLoadoutWindow(){
Menu*itemLoadoutWindow=CreateMenu(ITEM_LOADOUT,CENTERED,game->GetScreenSize()-vi2d{4,4}); Menu*itemLoadoutWindow=CreateMenu(ITEM_LOADOUT,CENTERED,game->GetScreenSize()-vi2d{4,4});

@ -41,7 +41,7 @@ All rights reserved.
#include "MenuLabel.h" #include "MenuLabel.h"
INCLUDE_game INCLUDE_game
typedef Attribute A; using A=Attribute;
void Menu::InitializeMainMenuWindow(){ void Menu::InitializeMainMenuWindow(){
Menu*mainMenuWindow=CreateMenu(MAIN_MENU,CENTERED,game->GetScreenSize()-vi2d{4,4}); Menu*mainMenuWindow=CreateMenu(MAIN_MENU,CENTERED,game->GetScreenSize()-vi2d{4,4});

@ -70,7 +70,7 @@ INCLUDE_game
INCLUDE_GFX INCLUDE_GFX
extern vi2d WINDOW_SIZE; extern vi2d WINDOW_SIZE;
typedef Attribute A; using A=Attribute;
Menu::Menu(vf2d pos,vf2d size) Menu::Menu(vf2d pos,vf2d size)
:pos(pos==CENTERED?WINDOW_SIZE/2-size/2:vi2d{pos}),size(size){ :pos(pos==CENTERED?WINDOW_SIZE/2-size/2:vi2d{pos}),size(size){

@ -164,4 +164,4 @@ struct MenuFuncData{
ScrollableWindowComponent*parentComponent; ScrollableWindowComponent*parentComponent;
}; };
typedef std::function<bool(MenuFuncData)> MenuFunc; using MenuFunc=std::function<bool(MenuFuncData)>;

@ -38,7 +38,7 @@ All rights reserved.
#include "Crawler.h" #include "Crawler.h"
#include "MenuComponent.h" #include "MenuComponent.h"
typedef Attribute A; using A=Attribute;
MenuComponent::MenuComponent(MenuType parent,geom2d::rect<float>rect,std::string label,MenuFunc onClick,ButtonAttr attributes) MenuComponent::MenuComponent(MenuType parent,geom2d::rect<float>rect,std::string label,MenuFunc onClick,ButtonAttr attributes)
:parentMenu(parent),rect(rect),label(label),menuDest(MenuType::ENUM_END),onClick(onClick),hoverEffect(0),selectable(!(attributes&ButtonAttr::UNSELECTABLE)),selectableViaKeyboard(!(attributes&ButtonAttr::UNSELECTABLE_VIA_KEYBOARD)),memoryLeakInfo(Menu::GetMemoryLeakReportInfo()){ :parentMenu(parent),rect(rect),label(label),menuDest(MenuType::ENUM_END),onClick(onClick),hoverEffect(0),selectable(!(attributes&ButtonAttr::UNSELECTABLE)),selectableViaKeyboard(!(attributes&ButtonAttr::UNSELECTABLE_VIA_KEYBOARD)),memoryLeakInfo(Menu::GetMemoryLeakReportInfo()){

@ -55,9 +55,19 @@ private:
MenuType itemDescriptionMenu; MenuType itemDescriptionMenu;
std::string itemNameLabelName; std::string itemNameLabelName;
std::string itemDescriptionLabelName; std::string itemDescriptionLabelName;
bool runHoverFunctions=false;
MenuFunc onHover;
MenuFunc onMouseOut;
bool hoverState=false;
public: public:
inline MenuItemItemButton(MenuType parent,geom2d::rect<float>rect,Item&itemRef,MenuType menuDest,MenuFunc onClick,MenuType itemDescriptionMenu,std::string itemNameLabelName,std::string itemDescriptionLabelName) inline MenuItemItemButton(MenuType parent,geom2d::rect<float>rect,Item&itemRef,MenuType menuDest,MenuFunc onClick,MenuType itemDescriptionMenu,std::string itemNameLabelName,std::string itemDescriptionLabelName)
:MenuIconButton(parent,rect,(!itemRef.IsBlank())?itemRef.Decal():nullptr,menuDest,onClick),itemRef(itemRef),itemDescriptionMenu(itemDescriptionMenu),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName){ :MenuIconButton(parent,rect,(!itemRef.IsBlank())?itemRef.Decal():nullptr,menuDest,onClick),itemRef(itemRef),itemDescriptionMenu(itemDescriptionMenu),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName),onHover(DO_NOTHING){
draggable=false;
valid=!itemRef.IsBlank();
}
inline MenuItemItemButton(MenuType parent,geom2d::rect<float>rect,Item&itemRef,MenuType menuDest,MenuFunc onClick,MenuFunc onHover,MenuFunc onMouseOut)
:MenuIconButton(parent,rect,(!itemRef.IsBlank())?itemRef.Decal():nullptr,menuDest,onClick),itemRef(itemRef),itemDescriptionMenu(MenuType::ENUM_END),itemNameLabelName(""),itemDescriptionLabelName(""),onHover(onHover),onMouseOut(onMouseOut){
runHoverFunctions=true;
draggable=false; draggable=false;
valid=!itemRef.IsBlank(); valid=!itemRef.IsBlank();
} }
@ -68,18 +78,31 @@ protected:
virtual inline void Update(Crawler*game)override{ virtual inline void Update(Crawler*game)override{
MenuIconButton::Update(game); MenuIconButton::Update(game);
valid=!itemRef.IsBlank(); valid=!itemRef.IsBlank();
std::string labelNameText;
std::string labelDescriptionText;
if(valid){ if(valid){
icon=itemRef.Decal(); icon=itemRef.Decal();
if(hovered&&itemDescriptionMenu!=MenuType::ENUM_END){ labelNameText=itemRef.Name();
Component<MenuLabel>(itemDescriptionMenu,itemNameLabelName)->label=itemRef.Name(); labelDescriptionText=itemRef.Description();
Component<MenuLabel>(itemDescriptionMenu,itemDescriptionLabelName)->label=itemRef.Description();
}
}else{ }else{
icon=nullptr; icon=nullptr;
if(hovered&&itemDescriptionMenu!=MenuType::ENUM_END){ labelNameText="";
Component<MenuLabel>(itemDescriptionMenu,itemNameLabelName)->label=""; labelDescriptionText="";
Component<MenuLabel>(itemDescriptionMenu,itemDescriptionLabelName)->label=""; }
if(hovered){
if(itemDescriptionMenu!=MenuType::ENUM_END){
Component<MenuLabel>(itemDescriptionMenu,itemNameLabelName)->label=labelNameText;
Component<MenuLabel>(itemDescriptionMenu,itemDescriptionLabelName)->label=labelDescriptionText;
}
if(runHoverFunctions&&!hoverState){
hoverState=true;
onHover(MenuFuncData{*Menu::menus[parentMenu],game,this,(ScrollableWindowComponent*)(parentComponent)});
} }
}else
if(runHoverFunctions&&hoverState){
hoverState=false;
onMouseOut(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{

@ -70,4 +70,5 @@ enum class Attribute{
LOADOUT_SLOT, //Which loadout slot we are selecting an item for. LOADOUT_SLOT, //Which loadout slot we are selecting an item for.
ALLOW_DRAGGING, //Whether or not to allow inventory dragging. ALLOW_DRAGGING, //Whether or not to allow inventory dragging.
EQUIP_TYPE, EQUIP_TYPE,
DISPLAY_TEXT,
}; };

@ -47,7 +47,7 @@ All rights reserved.
INCLUDE_game INCLUDE_game
INCLUDE_LEVEL_NAMES INCLUDE_LEVEL_NAMES
INCLUDE_MONSTER_DATA INCLUDE_MONSTER_DATA
typedef Attribute A; using A=Attribute;
void Menu::InitializeOverworldMapLevelWindow(){ void Menu::InitializeOverworldMapLevelWindow(){
vf2d windowSize={game->GetScreenSize().x/3.f-24,float(game->GetScreenSize().y)-48}; vf2d windowSize={game->GetScreenSize().x/3.f-24,float(game->GetScreenSize().y)-48};

@ -41,7 +41,7 @@ All rights reserved.
#include "MenuItemButton.h" #include "MenuItemButton.h"
#include "Crawler.h" #include "Crawler.h"
typedef Attribute A; using A=Attribute;
class ScrollableWindowComponent:public MenuComponent{ class ScrollableWindowComponent:public MenuComponent{
protected: protected:

@ -50,7 +50,7 @@ INCLUDE_BULLET_LIST
INCLUDE_ANIMATION_DATA INCLUDE_ANIMATION_DATA
INCLUDE_MONSTER_NAME_DATA INCLUDE_MONSTER_NAME_DATA
typedef Attribute A; using A=Attribute;
void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumber){ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumber){
float bulletSpd=ConfigFloat("BulletSpd")/100*24; float bulletSpd=ConfigFloat("BulletSpd")/100*24;

@ -43,7 +43,7 @@ All rights reserved.
#include "MenuLabel.h" #include "MenuLabel.h"
INCLUDE_GFX INCLUDE_GFX
typedef Attribute A; using A=Attribute;
void Menu::InitializeTestSubMenu(){ void Menu::InitializeTestSubMenu(){
Menu*testSubMenu=CreateMenu(TEST_2,{30,30},{24*4,24*5}); Menu*testSubMenu=CreateMenu(TEST_2,{30,30},{24*4,24*5});

@ -42,7 +42,7 @@ All rights reserved.
#include "util.h" #include "util.h"
#include "MonsterAttribute.h" #include "MonsterAttribute.h"
typedef Attribute A; using A=Attribute;
INCLUDE_game INCLUDE_game
INCLUDE_BULLET_LIST INCLUDE_BULLET_LIST

@ -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 3471 #define VERSION_BUILD 3479
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

Loading…
Cancel
Save