mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-22 22:13:35 +02:00
Merge pull request #2625 from dydzio0614/artifacts-backpack-gui
Artifacts backpack GUI
This commit is contained in:
commit
5be87b30c1
8
Mods/vcmi/Sprites/buttons/backpack.json
Normal file
8
Mods/vcmi/Sprites/buttons/backpack.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"basepath" : "buttons/",
|
||||||
|
"images" :
|
||||||
|
[
|
||||||
|
{ "frame" : 0, "file" : "backpackNormal.png"},
|
||||||
|
{ "frame" : 1, "file" : "backpackPressed.png"}
|
||||||
|
]
|
||||||
|
}
|
BIN
Mods/vcmi/Sprites/buttons/backpackNormal.png
Normal file
BIN
Mods/vcmi/Sprites/buttons/backpackNormal.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
BIN
Mods/vcmi/Sprites/buttons/backpackPressed.png
Normal file
BIN
Mods/vcmi/Sprites/buttons/backpackPressed.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
BIN
Mods/vcmi/Sprites/heroWindow/artifactSlotEmpty.png
Normal file
BIN
Mods/vcmi/Sprites/heroWindow/artifactSlotEmpty.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 133 B |
@ -173,6 +173,8 @@
|
|||||||
|
|
||||||
"vcmi.heroWindow.openCommander.hover" : "Open commander info window",
|
"vcmi.heroWindow.openCommander.hover" : "Open commander info window",
|
||||||
"vcmi.heroWindow.openCommander.help" : "Shows details about the commander of this hero",
|
"vcmi.heroWindow.openCommander.help" : "Shows details about the commander of this hero",
|
||||||
|
"vcmi.heroWindow.openBackpack.hover" : "Open artifact backpack window",
|
||||||
|
"vcmi.heroWindow.openBackpack.help" : "Opens window that allows easier artifact backpack management",
|
||||||
|
|
||||||
"vcmi.commanderWindow.artifactMessage" : "Do you want to return this artifact to the hero?",
|
"vcmi.commanderWindow.artifactMessage" : "Do you want to return this artifact to the hero?",
|
||||||
|
|
||||||
|
@ -173,6 +173,8 @@
|
|||||||
|
|
||||||
"vcmi.heroWindow.openCommander.hover" : "Otwórz okno dowódcy",
|
"vcmi.heroWindow.openCommander.hover" : "Otwórz okno dowódcy",
|
||||||
"vcmi.heroWindow.openCommander.help" : "Wyświetla informacje o dowódcy przynależącym do tego bohatera",
|
"vcmi.heroWindow.openCommander.help" : "Wyświetla informacje o dowódcy przynależącym do tego bohatera",
|
||||||
|
"vcmi.heroWindow.openBackpack.hover" : "Otwórz okno sakwy",
|
||||||
|
"vcmi.heroWindow.openBackpack.help" : "Otwiera okno pozwalające łatwiej zarządzać artefaktami w sakwie",
|
||||||
|
|
||||||
"vcmi.commanderWindow.artifactMessage" : "Czy chcesz zwrócić ten artefakt bohaterowi?",
|
"vcmi.commanderWindow.artifactMessage" : "Czy chcesz zwrócić ten artefakt bohaterowi?",
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "../gui/Shortcut.h"
|
#include "../gui/Shortcut.h"
|
||||||
|
|
||||||
#include "Buttons.h"
|
#include "Buttons.h"
|
||||||
|
#include "Images.h"
|
||||||
#include "GameSettings.h"
|
#include "GameSettings.h"
|
||||||
#include "IHandlerBase.h"
|
#include "IHandlerBase.h"
|
||||||
#include "ObjectLists.h"
|
#include "ObjectLists.h"
|
||||||
@ -27,25 +28,37 @@ CArtifactsOfHeroBackpack::CArtifactsOfHeroBackpack(const Point & position)
|
|||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
|
||||||
pos += position;
|
pos += position;
|
||||||
|
setRedrawParent(true);
|
||||||
|
|
||||||
const auto backpackCap = VLC->settings()->getInteger(EGameSettings::HEROES_BACKPACK_CAP);
|
const auto backpackCap = VLC->settings()->getInteger(EGameSettings::HEROES_BACKPACK_CAP);
|
||||||
auto visibleCapasityMax = HERO_BACKPACK_WINDOW_SLOT_LINES * HERO_BACKPACK_WINDOW_SLOT_COLUMNS;
|
auto visibleCapacityMax = HERO_BACKPACK_WINDOW_SLOT_ROWS * HERO_BACKPACK_WINDOW_SLOT_COLUMNS;
|
||||||
if(backpackCap >= 0)
|
if(backpackCap >= 0)
|
||||||
visibleCapasityMax = visibleCapasityMax > backpackCap ? backpackCap : visibleCapasityMax;
|
visibleCapacityMax = visibleCapacityMax > backpackCap ? backpackCap : visibleCapacityMax;
|
||||||
|
|
||||||
backpack.resize(visibleCapasityMax);
|
backpack.resize(visibleCapacityMax);
|
||||||
size_t artPlaceIdx = 0;
|
size_t artPlaceIdx = 0;
|
||||||
|
|
||||||
|
const int slotSizeWithMargin = 46;
|
||||||
|
|
||||||
|
for(int i = 0; i < visibleCapacityMax; i++)
|
||||||
|
{
|
||||||
|
auto artifactSlotBackground = std::make_shared<CPicture>("heroWindow/artifactSlotEmpty",
|
||||||
|
Point(slotSizeWithMargin * (i % HERO_BACKPACK_WINDOW_SLOT_COLUMNS), slotSizeWithMargin * (i / HERO_BACKPACK_WINDOW_SLOT_COLUMNS)));
|
||||||
|
|
||||||
|
backpackSlotsBackgrounds.emplace_back(artifactSlotBackground);
|
||||||
|
}
|
||||||
|
|
||||||
for(auto & artPlace : backpack)
|
for(auto & artPlace : backpack)
|
||||||
{
|
{
|
||||||
artPlace = std::make_shared<CHeroArtPlace>(
|
artPlace = std::make_shared<CHeroArtPlace>(
|
||||||
Point(46 * (artPlaceIdx % HERO_BACKPACK_WINDOW_SLOT_COLUMNS), 46 * (artPlaceIdx / HERO_BACKPACK_WINDOW_SLOT_COLUMNS)));
|
Point(slotSizeWithMargin * (artPlaceIdx % HERO_BACKPACK_WINDOW_SLOT_COLUMNS), slotSizeWithMargin * (artPlaceIdx / HERO_BACKPACK_WINDOW_SLOT_COLUMNS)));
|
||||||
artPlace->setArtifact(nullptr);
|
artPlace->setArtifact(nullptr);
|
||||||
artPlace->leftClickCallback = std::bind(&CArtifactsOfHeroBase::leftClickArtPlace, this, _1);
|
artPlace->leftClickCallback = std::bind(&CArtifactsOfHeroBase::leftClickArtPlace, this, _1);
|
||||||
artPlace->rightClickCallback = std::bind(&CArtifactsOfHeroBase::rightClickArtPlace, this, _1);
|
artPlace->rightClickCallback = std::bind(&CArtifactsOfHeroBase::rightClickArtPlace, this, _1);
|
||||||
artPlaceIdx++;
|
artPlaceIdx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(backpackCap < 0 || visibleCapasityMax < backpackCap)
|
if(backpackCap < 0 || visibleCapacityMax < backpackCap)
|
||||||
{
|
{
|
||||||
auto onCreate = [](size_t index) -> std::shared_ptr<CIntObject>
|
auto onCreate = [](size_t index) -> std::shared_ptr<CIntObject>
|
||||||
{
|
{
|
||||||
@ -56,8 +69,8 @@ CArtifactsOfHeroBackpack::CArtifactsOfHeroBackpack(const Point & position)
|
|||||||
scrollBackpack(static_cast<int>(pos) * HERO_BACKPACK_WINDOW_SLOT_COLUMNS - backpackPos);
|
scrollBackpack(static_cast<int>(pos) * HERO_BACKPACK_WINDOW_SLOT_COLUMNS - backpackPos);
|
||||||
};
|
};
|
||||||
backpackListBox = std::make_shared<CListBoxWithCallback>(
|
backpackListBox = std::make_shared<CListBoxWithCallback>(
|
||||||
posMoved, onCreate, Point(0, 0), Point(0, 0), HERO_BACKPACK_WINDOW_SLOT_LINES, 0, 0, 1,
|
posMoved, onCreate, Point(0, 0), Point(0, 0), HERO_BACKPACK_WINDOW_SLOT_ROWS, 0, 0, 1,
|
||||||
Rect(HERO_BACKPACK_WINDOW_SLOT_COLUMNS * 46 + 10, 0, HERO_BACKPACK_WINDOW_SLOT_LINES * 46 - 5, 0));
|
Rect(HERO_BACKPACK_WINDOW_SLOT_COLUMNS * slotSizeWithMargin + 10, 0, HERO_BACKPACK_WINDOW_SLOT_ROWS * slotSizeWithMargin - 5, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<CListBoxWithCallback> backpackListBox;
|
std::shared_ptr<CListBoxWithCallback> backpackListBox;
|
||||||
|
std::vector<std::shared_ptr<CPicture>> backpackSlotsBackgrounds;
|
||||||
const size_t HERO_BACKPACK_WINDOW_SLOT_COLUMNS = 8;
|
const size_t HERO_BACKPACK_WINDOW_SLOT_COLUMNS = 8;
|
||||||
const size_t HERO_BACKPACK_WINDOW_SLOT_LINES = 8;
|
const size_t HERO_BACKPACK_WINDOW_SLOT_ROWS = 8;
|
||||||
};
|
};
|
||||||
|
@ -14,17 +14,33 @@
|
|||||||
#include "../gui/Shortcut.h"
|
#include "../gui/Shortcut.h"
|
||||||
|
|
||||||
#include "../widgets/Buttons.h"
|
#include "../widgets/Buttons.h"
|
||||||
|
#include "../widgets/Images.h"
|
||||||
|
#include "CMessage.h"
|
||||||
|
#include "render/Canvas.h"
|
||||||
|
#include "CPlayerInterface.h"
|
||||||
|
|
||||||
CHeroBackpackWindow::CHeroBackpackWindow(const CGHeroInstance * hero)
|
CHeroBackpackWindow::CHeroBackpackWindow(const CGHeroInstance * hero)
|
||||||
: CWindowObject(PLAYER_COLORED)
|
: CWindowObject((EOptions)0)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
|
|
||||||
arts = std::make_shared<CArtifactsOfHeroBackpack>(Point(-100, -170));
|
stretchedBackground = std::make_shared<CFilledTexture>("DIBOXBCK", Rect(0, 0, 410, 425));
|
||||||
|
pos.w = stretchedBackground->pos.w;
|
||||||
|
pos.h = stretchedBackground->pos.h;
|
||||||
|
center();
|
||||||
|
|
||||||
|
|
||||||
|
arts = std::make_shared<CArtifactsOfHeroBackpack>(/*Point(-100, -170)*/Point(10, 10));
|
||||||
arts->setHero(hero);
|
arts->setHero(hero);
|
||||||
addSet(arts);
|
addSet(arts);
|
||||||
|
|
||||||
addCloseCallback(std::bind(&CHeroBackpackWindow::close, this));
|
addCloseCallback(std::bind(&CHeroBackpackWindow::close, this));
|
||||||
|
|
||||||
quitButton = std::make_shared<CButton>(Point(242, 200), "hsbtns.def", CButton::tooltip(""), [this]() { close(); }, EShortcut::GLOBAL_RETURN);
|
quitButton = std::make_shared<CButton>(Point(173, 385), "IOKAY32.def", CButton::tooltip(""), [this]() { close(); }, EShortcut::GLOBAL_RETURN);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CHeroBackpackWindow::showAll(Canvas &to)
|
||||||
|
{
|
||||||
|
CIntObject::showAll(to);
|
||||||
|
CMessage::drawBorder(PlayerColor(LOCPLINT->playerID), to.getInternalSurface(), pos.w+28, pos.h+29, pos.x-14, pos.y-15);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#include "../widgets/CWindowWithArtifacts.h"
|
#include "../widgets/CWindowWithArtifacts.h"
|
||||||
#include "CWindowObject.h"
|
#include "CWindowObject.h"
|
||||||
|
|
||||||
|
class CFilledTexture;
|
||||||
|
|
||||||
class CHeroBackpackWindow : public CWindowObject, public CWindowWithArtifacts
|
class CHeroBackpackWindow : public CWindowObject, public CWindowWithArtifacts
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -20,4 +22,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
std::shared_ptr<CArtifactsOfHeroBackpack> arts;
|
std::shared_ptr<CArtifactsOfHeroBackpack> arts;
|
||||||
std::shared_ptr<CButton> quitButton;
|
std::shared_ptr<CButton> quitButton;
|
||||||
|
std::shared_ptr<CFilledTexture> stretchedBackground;
|
||||||
|
|
||||||
|
void showAll(Canvas &to) override;
|
||||||
};
|
};
|
||||||
|
@ -84,11 +84,19 @@ CHeroWindow::CHeroWindow(const CGHeroInstance * hero)
|
|||||||
|
|
||||||
quitButton = std::make_shared<CButton>(Point(609, 516), "hsbtns.def", CButton::tooltip(heroscrn[17]), [=](){ close(); }, EShortcut::GLOBAL_RETURN);
|
quitButton = std::make_shared<CButton>(Point(609, 516), "hsbtns.def", CButton::tooltip(heroscrn[17]), [=](){ close(); }, EShortcut::GLOBAL_RETURN);
|
||||||
|
|
||||||
dismissLabel = std::make_shared<CTextBox>(CGI->generaltexth->jktexts[8], Rect(370, 430, 65, 35), 0, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
|
if(settings["general"]["enableUiEnhancements"].Bool())
|
||||||
dismissButton = std::make_shared<CButton>(Point(454, 429), "hsbtns2.def", CButton::tooltip(heroscrn[28]), [=](){ dismissCurrent(); }, EShortcut::HERO_DISMISS);
|
{
|
||||||
|
questlogButton = std::make_shared<CButton>(Point(314, 429), "hsbtns4.def", CButton::tooltip(heroscrn[0]), [=](){ LOCPLINT->showQuestLog(); }, EShortcut::ADVENTURE_QUEST_LOG);
|
||||||
questlogLabel = std::make_shared<CTextBox>(CGI->generaltexth->jktexts[9], Rect(510, 430, 65, 35), 0, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
|
backpackButton = std::make_shared<CButton>(Point(424, 429), "buttons/backpack", CButton::tooltipLocalized("vcmi.heroWindow.Backpack"), [=](){ createBackpackWindow(); }, EShortcut::HERO_BACKPACK);
|
||||||
questlogButton = std::make_shared<CButton>(Point(314, 429), "hsbtns4.def", CButton::tooltip(heroscrn[0]), [=](){ LOCPLINT->showQuestLog(); }, EShortcut::ADVENTURE_QUEST_LOG);
|
dismissButton = std::make_shared<CButton>(Point(534, 429), "hsbtns2.def", CButton::tooltip(heroscrn[28]), [=](){ dismissCurrent(); }, EShortcut::HERO_DISMISS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dismissLabel = std::make_shared<CTextBox>(CGI->generaltexth->jktexts[8], Rect(370, 430, 65, 35), 0, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
|
||||||
|
questlogLabel = std::make_shared<CTextBox>(CGI->generaltexth->jktexts[9], Rect(510, 430, 65, 35), 0, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
|
||||||
|
dismissButton = std::make_shared<CButton>(Point(454, 429), "hsbtns2.def", CButton::tooltip(heroscrn[28]), [=](){ dismissCurrent(); }, EShortcut::HERO_DISMISS);
|
||||||
|
questlogButton = std::make_shared<CButton>(Point(314, 429), "hsbtns4.def", CButton::tooltip(heroscrn[0]), [=](){ LOCPLINT->showQuestLog(); }, EShortcut::ADVENTURE_QUEST_LOG);
|
||||||
|
}
|
||||||
|
|
||||||
formations = std::make_shared<CToggleGroup>(0);
|
formations = std::make_shared<CToggleGroup>(0);
|
||||||
formations->addToggle(0, std::make_shared<CToggleButton>(Point(481, 483), "hsbtns6.def", std::make_pair(heroscrn[23], heroscrn[29]), 0, EShortcut::HERO_TIGHT_FORMATION));
|
formations->addToggle(0, std::make_shared<CToggleButton>(Point(481, 483), "hsbtns6.def", std::make_pair(heroscrn[23], heroscrn[29]), 0, EShortcut::HERO_TIGHT_FORMATION));
|
||||||
|
@ -38,7 +38,8 @@
|
|||||||
"autosaveCountLimit",
|
"autosaveCountLimit",
|
||||||
"useSavePrefix",
|
"useSavePrefix",
|
||||||
"savePrefix",
|
"savePrefix",
|
||||||
"startTurnAutosave"
|
"startTurnAutosave",
|
||||||
|
"enableUiEnhancements"
|
||||||
],
|
],
|
||||||
"properties" : {
|
"properties" : {
|
||||||
"playerName" : {
|
"playerName" : {
|
||||||
@ -126,6 +127,10 @@
|
|||||||
"startTurnAutosave" : {
|
"startTurnAutosave" : {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false
|
"default": false
|
||||||
|
},
|
||||||
|
"enableUiEnhancements" : {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user