mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
add slider for new mines
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
#include "../../lib/StartInfo.h"
|
#include "../../lib/StartInfo.h"
|
||||||
#include "../../lib/callback/CCallback.h"
|
#include "../../lib/callback/CCallback.h"
|
||||||
#include "../../lib/entities/hero/CHeroHandler.h"
|
#include "../../lib/entities/hero/CHeroHandler.h"
|
||||||
|
#include "../../lib/entities/ResourceTypeHandler.h"
|
||||||
#include "../../lib/texts/TextOperations.h"
|
#include "../../lib/texts/TextOperations.h"
|
||||||
#include "../../lib/mapObjects/CGHeroInstance.h"
|
#include "../../lib/mapObjects/CGHeroInstance.h"
|
||||||
#include "../../lib/mapObjects/CGTownInstance.h"
|
#include "../../lib/mapObjects/CGTownInstance.h"
|
||||||
@@ -476,7 +477,7 @@ CKingdomInterface::CKingdomInterface()
|
|||||||
|
|
||||||
std::vector<const CGObjectInstance * > ownedObjects = GAME->interface()->cb->getMyObjects();
|
std::vector<const CGObjectInstance * > ownedObjects = GAME->interface()->cb->getMyObjects();
|
||||||
generateObjectsList(ownedObjects);
|
generateObjectsList(ownedObjects);
|
||||||
generateMinesList(ownedObjects);
|
generateMinesList(ownedObjects, 0);
|
||||||
generateButtons();
|
generateButtons();
|
||||||
|
|
||||||
statusbar = CGStatusBar::create(std::make_shared<CPicture>(ImagePath::builtin("KSTATBAR"), 10,pos.h - 45));
|
statusbar = CGStatusBar::create(std::make_shared<CPicture>(ImagePath::builtin("KSTATBAR"), 10,pos.h - 45));
|
||||||
@@ -594,12 +595,17 @@ std::shared_ptr<CIntObject> CKingdomInterface::createMainTab(size_t index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKingdomInterface::generateMinesList(const std::vector<const CGObjectInstance *> & ownedObjects)
|
void CKingdomInterface::generateMinesList(const std::vector<const CGObjectInstance *> & ownedObjects, int line)
|
||||||
{
|
{
|
||||||
|
OBJECT_CONSTRUCTION;
|
||||||
|
|
||||||
ui32 footerPos = OVERVIEW_SIZE * 116;
|
ui32 footerPos = OVERVIEW_SIZE * 116;
|
||||||
ResourceSet minesCount = ResourceSet();
|
ResourceSet minesCount = ResourceSet();
|
||||||
int totalIncome=0;
|
int totalIncome=0;
|
||||||
|
|
||||||
|
for(auto & ptr : minesBox)
|
||||||
|
ptr.reset();
|
||||||
|
|
||||||
for(const CGObjectInstance * object : ownedObjects)
|
for(const CGObjectInstance * object : ownedObjects)
|
||||||
{
|
{
|
||||||
//Mines
|
//Mines
|
||||||
@@ -626,6 +632,15 @@ void CKingdomInterface::generateMinesList(const std::vector<const CGObjectInstan
|
|||||||
minesBox[i] = std::make_shared<InfoBox>(Point(20+i*80, 31+footerPos), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL, data);
|
minesBox[i] = std::make_shared<InfoBox>(Point(20+i*80, 31+footerPos), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL, data);
|
||||||
minesBox[i]->removeUsedEvents(LCLICK|SHOW_POPUP); //fixes #890 - mines boxes ignore clicks
|
minesBox[i]->removeUsedEvents(LCLICK|SHOW_POPUP); //fixes #890 - mines boxes ignore clicks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(LIBRARY->resourceTypeHandler->getAllObjects().size() > GameConstants::RESOURCE_QUANTITY)
|
||||||
|
{
|
||||||
|
int lines = vstd::divideAndCeil(LIBRARY->resourceTypeHandler->getAllObjects().size(), GameConstants::RESOURCE_QUANTITY);
|
||||||
|
minesSlider = std::make_shared<CSlider>(Point(723, 495), 57, [this, ownedObjects](int to){ generateMinesList(ownedObjects, to); setRedrawParent(true); redraw(); }, 1, lines, line, Orientation::VERTICAL, CSlider::BROWN);
|
||||||
|
minesSlider->setPanningStep(57);
|
||||||
|
minesSlider->setScrollBounds(Rect(-735, 0, 735, 57));
|
||||||
|
}
|
||||||
|
|
||||||
incomeArea = std::make_shared<CHoverableArea>();
|
incomeArea = std::make_shared<CHoverableArea>();
|
||||||
incomeArea->pos = Rect(pos.x+580, pos.y+31+footerPos, 136, 68);
|
incomeArea->pos = Rect(pos.x+580, pos.y+31+footerPos, 136, 68);
|
||||||
incomeArea->hoverText = LIBRARY->generaltexth->allTexts[255];
|
incomeArea->hoverText = LIBRARY->generaltexth->allTexts[255];
|
||||||
@@ -722,6 +737,7 @@ CKingdHeroList::CKingdHeroList(size_t maxSize, const CreateHeroItemFunctor & onC
|
|||||||
return std::make_shared<CAnimImage>(AnimationPath::builtin("OVSLOT"), (idx - 2) % GameConstants::KINGDOM_WINDOW_HEROES_SLOTS);
|
return std::make_shared<CAnimImage>(AnimationPath::builtin("OVSLOT"), (idx - 2) % GameConstants::KINGDOM_WINDOW_HEROES_SLOTS);
|
||||||
}
|
}
|
||||||
}, Point(19,21), Point(0,116), maxSize, townCount, 0, 1, Rect(-19, -21, size, size));
|
}, Point(19,21), Point(0,116), maxSize, townCount, 0, 1, Rect(-19, -21, size, size));
|
||||||
|
heroes->getSlider()->setScrollBounds(Rect(0, 0, 725, 483));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKingdHeroList::updateGarrisons()
|
void CKingdHeroList::updateGarrisons()
|
||||||
@@ -755,6 +771,7 @@ CKingdTownList::CKingdTownList(size_t maxSize)
|
|||||||
ui32 size = OVERVIEW_SIZE*116 + 19;
|
ui32 size = OVERVIEW_SIZE*116 + 19;
|
||||||
towns = std::make_shared<CListBox>(std::bind(&CKingdTownList::createTownItem, this, _1),
|
towns = std::make_shared<CListBox>(std::bind(&CKingdTownList::createTownItem, this, _1),
|
||||||
Point(19,21), Point(0,116), maxSize, townCount, 0, 1, Rect(-19, -21, size, size));
|
Point(19,21), Point(0,116), maxSize, townCount, 0, 1, Rect(-19, -21, size, size));
|
||||||
|
towns->getSlider()->setScrollBounds(Rect(0, 0, 725, 483));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKingdTownList::townChanged(const CGTownInstance * town)
|
void CKingdTownList::townChanged(const CGTownInstance * town)
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ private:
|
|||||||
std::shared_ptr<CButton> dwellBottom;
|
std::shared_ptr<CButton> dwellBottom;
|
||||||
|
|
||||||
std::array<std::shared_ptr<InfoBox>, 7> minesBox;
|
std::array<std::shared_ptr<InfoBox>, 7> minesBox;
|
||||||
|
std::shared_ptr<CSlider> minesSlider;
|
||||||
|
|
||||||
std::shared_ptr<CHoverableArea> incomeArea;
|
std::shared_ptr<CHoverableArea> incomeArea;
|
||||||
std::shared_ptr<CLabel> incomeAmount;
|
std::shared_ptr<CLabel> incomeAmount;
|
||||||
@@ -244,7 +245,7 @@ private:
|
|||||||
//Internal functions used during construction
|
//Internal functions used during construction
|
||||||
void generateButtons();
|
void generateButtons();
|
||||||
void generateObjectsList(const std::vector<const CGObjectInstance * > &ownedObjects);
|
void generateObjectsList(const std::vector<const CGObjectInstance * > &ownedObjects);
|
||||||
void generateMinesList(const std::vector<const CGObjectInstance * > &ownedObjects);
|
void generateMinesList(const std::vector<const CGObjectInstance * > &ownedObjects, int line);
|
||||||
|
|
||||||
std::shared_ptr<CIntObject> createOwnedObject(size_t index);
|
std::shared_ptr<CIntObject> createOwnedObject(size_t index);
|
||||||
std::shared_ptr<CIntObject> createMainTab(size_t index);
|
std::shared_ptr<CIntObject> createMainTab(size_t index);
|
||||||
|
|||||||
Reference in New Issue
Block a user