diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp
index 2ec3588d..353f9c77 100644
--- a/Crawler/Crawler.cpp
+++ b/Crawler/Crawler.cpp
@@ -108,6 +108,27 @@ bool Crawler::OnUserCreate(){
Inventory::AddItem("Small Health Potion",16);
Inventory::AddItem("Large Health Potion",3);
Inventory::AddItem("Medium Mana Potion",1);
+ Inventory::AddItem("Dummy Item 1",78);
+ Inventory::AddItem("Dummy Item 2",3);
+ Inventory::AddItem("Dummy Item 3",5);
+ Inventory::AddItem("Dummy Item 4",8);
+ Inventory::AddItem("Dummy Item 5",6);
+ Inventory::AddItem("Dummy Item 6",3);
+ Inventory::AddItem("Dummy Item 7",5);
+ Inventory::AddItem("Dummy Item 8",8);
+ Inventory::AddItem("Dummy Item 9",3);
+ Inventory::AddItem("Dummy Item 10",4);
+ Inventory::AddItem("Dummy Item 11",8);
+ Inventory::AddItem("Dummy Item 12",3);
+ Inventory::AddItem("Dummy Item 13",6);
+ Inventory::AddItem("Dummy Item 14",192);
+ Inventory::AddItem("Dummy Item 15",35);
+ Inventory::AddItem("Dummy Item 16",6);
+ Inventory::AddItem("Dummy Item 17",3);
+ Inventory::AddItem("Dummy Item 18",1);
+ Inventory::AddItem("Dummy Item 19",8);
+ Inventory::AddItem("Dummy Item 20",4);
+ Inventory::AddItem("Bandages",10);
Inventory::AddItem("Blue Slime Remains",22);
InitializeGraphics();
diff --git a/Crawler/Crawler.vcxproj b/Crawler/Crawler.vcxproj
index 4edb87fc..c7e6540e 100644
--- a/Crawler/Crawler.vcxproj
+++ b/Crawler/Crawler.vcxproj
@@ -295,6 +295,7 @@
+
diff --git a/Crawler/Crawler.vcxproj.filters b/Crawler/Crawler.vcxproj.filters
index 7f5bcf5f..3cad7224 100644
--- a/Crawler/Crawler.vcxproj.filters
+++ b/Crawler/Crawler.vcxproj.filters
@@ -186,6 +186,9 @@
Header Files
+
+ Header Files\Interface
+
diff --git a/Crawler/InventoryWindow.cpp b/Crawler/InventoryWindow.cpp
index 3637f5c7..a335cd2a 100644
--- a/Crawler/InventoryWindow.cpp
+++ b/Crawler/InventoryWindow.cpp
@@ -6,39 +6,42 @@
#include "Item.h"
#include "MenuItemButton.h"
#include "MenuLabel.h"
+#include "ScrollableWindowComponent.h"
INCLUDE_GFX
typedef Attribute A;
Menu*Menu::InitializeInventoryWindow(){
constexpr int invWidth=5;
- constexpr int invHeight=3;
- constexpr int totalItemSlots=invWidth*invHeight;
+ constexpr int initialInvHeight=3;
constexpr int itemSpacing=8;
constexpr int buttonSize=24;
constexpr int totalSpacing=buttonSize+itemSpacing;
- vf2d windowSize={totalSpacing*invWidth-itemSpacing+1,totalSpacing*(invHeight+1)-itemSpacing+24};
+ vf2d windowSize={totalSpacing*invWidth-itemSpacing+1,totalSpacing*(3+1)-itemSpacing+24};
Menu*inventoryWindow=new Menu(CENTERED,windowSize);
+ ScrollableWindowComponent*inventory=new ScrollableWindowComponent(INVENTORY,{{0,0},{windowSize.x,totalSpacing*3-itemSpacing}},nullptr,[](MenuFuncData data){});
+ inventoryWindow->AddComponent("inventory",inventory);
+
MenuFunc useItemFunc=[](MenuFuncData data){
MenuItemButton*button=(MenuItemButton*)data.component;
button->UseItem();
};
- for(int y=0;yAddComponent("item"+std::to_string(itemIndex),button);
- }
+ for(int i=0;iAddComponent(inventoryWindow,"item"+std::to_string(itemIndex),button);
}
- MenuLabel*itemNameLabel=new MenuLabel{INVENTORY,geom2d::rect(vf2d{2,invHeight*totalSpacing-4},windowSize),"",false,true};
+ MenuLabel*itemNameLabel=new MenuLabel{INVENTORY,geom2d::rect(vf2d{2,initialInvHeight*totalSpacing-4},windowSize),"",false,true};
inventoryWindow->AddComponent("itemName",itemNameLabel);
- MenuLabel*itemDescriptionLabel=new MenuLabel{INVENTORY,geom2d::rect(vf2d{2,invHeight*totalSpacing+itemSpacing},{windowSize.x-4,windowSize.y-108}),"",true,true};
+ MenuLabel*itemDescriptionLabel=new MenuLabel{INVENTORY,geom2d::rect(vf2d{2,initialInvHeight*totalSpacing+itemSpacing},{windowSize.x-4,windowSize.y-108}),"",true,true};
inventoryWindow->AddComponent("itemDescription",itemDescriptionLabel);
return inventoryWindow;
diff --git a/Crawler/Menu.cpp b/Crawler/Menu.cpp
index 1399bcaf..b97dc39f 100644
--- a/Crawler/Menu.cpp
+++ b/Crawler/Menu.cpp
@@ -131,11 +131,15 @@ void Menu::Update(Crawler*game){
KeyboardButtonNavigation(game,pos);
for(auto&key:buttons){
for(auto&button:key.second){
- button->Update(game);
+ if(button->renderInMain){
+ button->Update(game);
+ }
}
}
for(auto&component:displayComponents){
- component->Update(game);
+ if(component->renderInMain){
+ component->Update(game);
+ }
}
};
@@ -152,11 +156,15 @@ void Menu::Draw(Crawler*game){
game->Clear(BLANK);
for(auto&key:buttons){
for(auto&button:key.second){
- button->Draw(game,{0,0},this==Menu::stack.back());
+ if(button->renderInMain){
+ button->Draw(game,{0,0},this==Menu::stack.back());
+ }
}
}
for(auto&component:displayComponents){
- component->Draw(game,{0,0},this==Menu::stack.back());
+ if(component->renderInMain){
+ component->Draw(game,{0,0},this==Menu::stack.back());
+ }
}
game->SetPixelMode(prevMode);
game->SetDrawTarget(nullptr);
@@ -164,11 +172,15 @@ void Menu::Draw(Crawler*game){
game->DrawDecal(pos,r.Decal());
for(auto&key:buttons){
for(auto&button:key.second){
- button->DrawDecal(game,{0,0},this==Menu::stack.back());
+ if(button->renderInMain){
+ button->DrawDecal(game,pos,this==Menu::stack.back());
+ }
}
}
for(auto&component:displayComponents){
- component->DrawDecal(game,{0,0},this==Menu::stack.back());
+ if(component->renderInMain){
+ component->DrawDecal(game,pos,this==Menu::stack.back());
+ }
}
if(GetCurrentTheme().IsScaled()){
@@ -195,9 +207,9 @@ void Menu::Draw(Crawler*game){
game->DrawDecal({0,0},overlay.Decal());
if(!MOUSE_NAVIGATION){
MenuComponent*selectedComponent=buttons[selection.y][selection.x];
- draggingComponent->DrawDecal(game,-offsetPos+selectedComponent->rect.pos+vi2d{1,-4},this==Menu::stack.back());
+ draggingComponent->DrawDecal(game,pos-offsetPos+selectedComponent->rect.pos+vi2d{1,-4},this==Menu::stack.back());
}else{
- draggingComponent->DrawDecal(game,-pos-offsetPos+game->GetMousePos(),this==Menu::stack.back());
+ draggingComponent->DrawDecal(game,-offsetPos+game->GetMousePos(),this==Menu::stack.back());
}
}
};
diff --git a/Crawler/MenuComponent.h b/Crawler/MenuComponent.h
index 418caed6..3077c689 100644
--- a/Crawler/MenuComponent.h
+++ b/Crawler/MenuComponent.h
@@ -4,8 +4,8 @@
class MenuComponent{
friend class Menu;
friend class MenuItemButton;
+ friend class ScrollableWindowComponent;
MenuType menuDest;
- bool selectable=true;
private:
float hoverEffect=0;
protected:
@@ -16,6 +16,8 @@ protected:
MenuFunc onClick;
MenuType parentMenu=MenuType::ENUM_END;
bool hovered=false;
+ bool selectable=true;
+ 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.
public:
MenuComponent(MenuType parent,geom2d::rectrect,std::string label,MenuFunc onClick,bool selectable=true);
MenuComponent(MenuType parent,geom2d::rectrect,std::string label,MenuType menuDest,MenuFunc onClick,bool selectable=true);
diff --git a/Crawler/MenuItemButton.h b/Crawler/MenuItemButton.h
index 2c64e5a4..acf7a835 100644
--- a/Crawler/MenuItemButton.h
+++ b/Crawler/MenuItemButton.h
@@ -63,7 +63,7 @@ protected:
if(valid){
std::string quantityText="x"+std::to_string(Inventory::GetItemCount(invRef.at(inventoryIndex)));
vf2d textSize=vf2d(game->GetTextSizeProp(quantityText))*0.5;
- game->DrawShadowStringDecal(Menu::menus[parentMenu]->pos+parentPos+rect.pos+rect.size-textSize,quantityText,WHITE,BLACK,{0.5,0.5},0.5);
+ game->DrawShadowStringDecal(parentPos+rect.pos+rect.size-textSize,quantityText,WHITE,BLACK,{0.5,0.5},0.5);
}
}
virtual inline MenuComponent*PickUpDraggableItem()override{
diff --git a/Crawler/ScrollableWindowComponent.h b/Crawler/ScrollableWindowComponent.h
new file mode 100644
index 00000000..d043afbc
--- /dev/null
+++ b/Crawler/ScrollableWindowComponent.h
@@ -0,0 +1,68 @@
+#pragma once
+#include "Menu.h"
+#include "MenuComponent.h"
+#include "Crawler.h"
+
+class ScrollableWindowComponent:public MenuComponent{
+protected:
+ Renderable r;
+ std::vectorcomponents;
+ vf2d scrollOffset{};
+ geom2d::rectbounds;
+public:
+ inline ScrollableWindowComponent(MenuType parent,geom2d::rectrect,Decal*icon,MenuFunc onClick)
+ :MenuComponent(parent,rect,"",onClick,false){
+ r.Create(rect.size.x,rect.size.y);
+ }
+protected:
+ virtual inline void Update(Crawler*game)override{
+ MenuComponent::Update(game);
+ for(MenuComponent*component:components){
+ component->Update(game);
+ }
+ }
+ virtual inline void Draw(Crawler*game,vf2d parentPos,bool focused)override{
+ MenuComponent::Draw(game,parentPos,focused);
+ Sprite*prevDrawTarget=game->GetDrawTarget();
+ game->SetDrawTarget(r.Sprite());
+ game->Clear(BLANK);
+ for(MenuComponent*component:components){
+ component->Draw(game,scrollOffset,focused);
+ }
+ game->SetDrawTarget(prevDrawTarget);
+ game->DrawSprite(parentPos,r.Sprite());
+ }
+ virtual inline void DrawDecal(Crawler*game,vf2d parentPos,bool focused)override{
+ MenuComponent::DrawDecal(game,parentPos,focused);
+ game->DrawRectDecal(parentPos,rect.size);
+ for(MenuComponent*component:components){
+ component->DrawDecal(game,parentPos+scrollOffset,focused);
+ }
+ }
+public:
+ void inline AddComponent(Menu*parentMenu,std::string key,MenuComponent*button){
+ components.push_back(button);
+ button->renderInMain=false; //Now we are in control!
+
+ if(button->rect.pos.xrect.pos.x;
+ bounds.size.x+=sizeIncrease;
+ bounds.pos.x=button->rect.pos.x;
+ }
+ if(button->rect.right().start.x>bounds.right().start.x){
+ float sizeIncrease=button->rect.right().start.x-bounds.right().start.x;
+ bounds.size.x+=sizeIncrease;
+ }
+ if(button->rect.pos.yrect.pos.y;
+ bounds.size.y+=sizeIncrease;
+ bounds.pos.y=button->rect.pos.y;
+ }
+ if(button->rect.bottom().start.y>bounds.bottom().start.y){
+ float sizeIncrease=button->rect.bottom().start.y-bounds.bottom().start.y;
+ bounds.size.y+=sizeIncrease;
+ }
+
+ parentMenu->AddComponent(key,button);
+ }
+};
\ No newline at end of file
diff --git a/Crawler/Version.h b/Crawler/Version.h
index 2498cb57..929ddfcd 100644
--- a/Crawler/Version.h
+++ b/Crawler/Version.h
@@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 0
-#define VERSION_BUILD 1954
+#define VERSION_BUILD 1972
#define stringify(a) stringify_(a)
#define stringify_(a) #a
diff --git a/Crawler/assets/config/items/ItemDatabase.txt b/Crawler/assets/config/items/ItemDatabase.txt
index 78080fb8..66786956 100644
--- a/Crawler/assets/config/items/ItemDatabase.txt
+++ b/Crawler/assets/config/items/ItemDatabase.txt
@@ -42,6 +42,106 @@ ItemDatabase
MP Restore = 320
ItemCategory = Consumables
}
+ Dummy Item 1
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 2
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 3
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 4
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 5
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 6
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 7
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 8
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 9
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 10
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 11
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 12
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 13
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 14
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 15
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 16
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 17
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 18
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 19
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
+ Dummy Item 20
+ {
+ Description = Does nothing apparently.
+ ItemCategory = Consumables
+ }
Bandages
{
ItemScript = Restore
diff --git a/Crawler/assets/items/Dummy Item 1.png b/Crawler/assets/items/Dummy Item 1.png
new file mode 100644
index 00000000..aadcffd5
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 1.png differ
diff --git a/Crawler/assets/items/Dummy Item 10.png b/Crawler/assets/items/Dummy Item 10.png
new file mode 100644
index 00000000..59da7e66
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 10.png differ
diff --git a/Crawler/assets/items/Dummy Item 11.png b/Crawler/assets/items/Dummy Item 11.png
new file mode 100644
index 00000000..db027f2f
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 11.png differ
diff --git a/Crawler/assets/items/Dummy Item 12.png b/Crawler/assets/items/Dummy Item 12.png
new file mode 100644
index 00000000..2a6bc0b7
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 12.png differ
diff --git a/Crawler/assets/items/Dummy Item 13.png b/Crawler/assets/items/Dummy Item 13.png
new file mode 100644
index 00000000..65c0a948
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 13.png differ
diff --git a/Crawler/assets/items/Dummy Item 14.png b/Crawler/assets/items/Dummy Item 14.png
new file mode 100644
index 00000000..03f1659b
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 14.png differ
diff --git a/Crawler/assets/items/Dummy Item 15.png b/Crawler/assets/items/Dummy Item 15.png
new file mode 100644
index 00000000..6c7fb331
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 15.png differ
diff --git a/Crawler/assets/items/Dummy Item 16.png b/Crawler/assets/items/Dummy Item 16.png
new file mode 100644
index 00000000..1f90cb81
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 16.png differ
diff --git a/Crawler/assets/items/Dummy Item 17.png b/Crawler/assets/items/Dummy Item 17.png
new file mode 100644
index 00000000..2552558d
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 17.png differ
diff --git a/Crawler/assets/items/Dummy Item 18.png b/Crawler/assets/items/Dummy Item 18.png
new file mode 100644
index 00000000..0312411b
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 18.png differ
diff --git a/Crawler/assets/items/Dummy Item 19.png b/Crawler/assets/items/Dummy Item 19.png
new file mode 100644
index 00000000..3a82e155
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 19.png differ
diff --git a/Crawler/assets/items/Dummy Item 2.png b/Crawler/assets/items/Dummy Item 2.png
new file mode 100644
index 00000000..cbe5a165
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 2.png differ
diff --git a/Crawler/assets/items/Dummy Item 20.png b/Crawler/assets/items/Dummy Item 20.png
new file mode 100644
index 00000000..9f1e19ec
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 20.png differ
diff --git a/Crawler/assets/items/Dummy Item 3.png b/Crawler/assets/items/Dummy Item 3.png
new file mode 100644
index 00000000..40609430
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 3.png differ
diff --git a/Crawler/assets/items/Dummy Item 4.png b/Crawler/assets/items/Dummy Item 4.png
new file mode 100644
index 00000000..8a36e290
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 4.png differ
diff --git a/Crawler/assets/items/Dummy Item 5.png b/Crawler/assets/items/Dummy Item 5.png
new file mode 100644
index 00000000..dd5b2e5c
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 5.png differ
diff --git a/Crawler/assets/items/Dummy Item 6.png b/Crawler/assets/items/Dummy Item 6.png
new file mode 100644
index 00000000..3a9a8ccb
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 6.png differ
diff --git a/Crawler/assets/items/Dummy Item 7.png b/Crawler/assets/items/Dummy Item 7.png
new file mode 100644
index 00000000..bd791007
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 7.png differ
diff --git a/Crawler/assets/items/Dummy Item 8.png b/Crawler/assets/items/Dummy Item 8.png
new file mode 100644
index 00000000..213225e4
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 8.png differ
diff --git a/Crawler/assets/items/Dummy Item 9.png b/Crawler/assets/items/Dummy Item 9.png
new file mode 100644
index 00000000..8c72f5f3
Binary files /dev/null and b/Crawler/assets/items/Dummy Item 9.png differ