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. 17
      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_GFX
INCLUDE_DATA
typedef Attribute A;
using A=Attribute;
void Menu::InitializeClassInfoWindow(){
Menu*classInfoWindow=CreateMenu(CLASS_INFO,CENTERED,game->GetScreenSize()-vi2d{24,24});

@ -130,7 +130,50 @@ void Menu::InitializeCharacterMenuWindow(){
MenuItemItemButton*comp=(MenuItemItemButton*)data.component;
Inventory::EquipItem(comp->GetItem(),EquipSlot(comp->I(Attribute::EQUIP_TYPE)));
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);
equipList->AddComponent(Menu::menus[CHARACTER_MENU],"Equip Item "+std::to_string(counter),equip);
counter++;
@ -163,6 +206,7 @@ void Menu::InitializeCharacterMenuWindow(){
attrStr+="%";
}
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;
characterMenuWindow->AddComponent("Attribute "+data.name+" Label",attrLabel);
}

@ -44,7 +44,7 @@ All rights reserved.
#include "ClassInfo.h"
INCLUDE_game
typedef Attribute A;
using A=Attribute;
void Menu::InitializeClassSelectionWindow(){
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("Bandages",10);
Inventory::AddItem("Blue Slime Remains",22);
Inventory::AddItem("Copper Armor");
LoadLevel(LEVEL_NAMES["starting_map"_S]);
ChangePlayerClass(WARRIOR);

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

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

@ -545,4 +545,19 @@ 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 ItemProps;
typedef std::string IT;
typedef std::string ITCategory;
using IT=std::string;
using ITCategory=std::string;
typedef std::function<bool(Crawler*,ItemProps)> ItemScript;
using ItemScript=std::function<bool(Crawler*,ItemProps)>;
enum class EquipSlot{
HELMET= 0b0000'0001,
@ -81,6 +81,7 @@ private:
public:
void SetAttribute(int enhanceLevel,ItemAttribute attribute,int value);
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.
@ -112,6 +113,7 @@ public:
ITCategory Category();
EquipSlot GetEquipSlot();
Decal*Decal();
Stats GetStats()const;
ItemScript&OnUseAction();
float CastTime();
float CooldownTime();
@ -199,6 +201,7 @@ public:
For the useFunc, return true if the item can be used, false otherwise.
*/
ItemScript&OnUseAction();
Stats GetStats(int enhancementLevel);
float CastTime();
float CooldownTime();
EquipSlot Slot();

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

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

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

@ -164,4 +164,4 @@ struct MenuFuncData{
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 "MenuComponent.h"
typedef Attribute A;
using A=Attribute;
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()){

@ -55,9 +55,19 @@ private:
MenuType itemDescriptionMenu;
std::string itemNameLabelName;
std::string itemDescriptionLabelName;
bool runHoverFunctions=false;
MenuFunc onHover;
MenuFunc onMouseOut;
bool hoverState=false;
public:
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;
valid=!itemRef.IsBlank();
}
@ -68,18 +78,31 @@ protected:
virtual inline void Update(Crawler*game)override{
MenuIconButton::Update(game);
valid=!itemRef.IsBlank();
std::string labelNameText;
std::string labelDescriptionText;
if(valid){
icon=itemRef.Decal();
if(hovered&&itemDescriptionMenu!=MenuType::ENUM_END){
Component<MenuLabel>(itemDescriptionMenu,itemNameLabelName)->label=itemRef.Name();
Component<MenuLabel>(itemDescriptionMenu,itemDescriptionLabelName)->label=itemRef.Description();
}
labelNameText=itemRef.Name();
labelDescriptionText=itemRef.Description();
}else{
icon=nullptr;
if(hovered&&itemDescriptionMenu!=MenuType::ENUM_END){
Component<MenuLabel>(itemDescriptionMenu,itemNameLabelName)->label="";
Component<MenuLabel>(itemDescriptionMenu,itemDescriptionLabelName)->label="";
labelNameText="";
labelDescriptionText="";
}
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{

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

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

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

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

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

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

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 1
#define VERSION_BUILD 3471
#define VERSION_BUILD 3479
#define stringify(a) stringify_(a)
#define stringify_(a) #a

Loading…
Cancel
Save