mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Implemented Scrollable class, to server as common base for such classes
This commit is contained in:
parent
6fe00ad55c
commit
052d0d314a
@ -202,7 +202,7 @@ void InfoCard::changeSelection()
|
||||
|
||||
mapDescription->label->scrollTextTo(0, false);
|
||||
if(mapDescription->slider)
|
||||
mapDescription->slider->moveToMin();
|
||||
mapDescription->slider->scrollToMin();
|
||||
|
||||
if(SEL->screenType == ESelectionScreen::campaignList)
|
||||
return;
|
||||
@ -337,7 +337,7 @@ void CChatBox::addNewMessage(const std::string & text)
|
||||
CCS->soundh->playSound("CHAT");
|
||||
chatHistory->setText(chatHistory->label->getText() + text + "\n");
|
||||
if(chatHistory->slider)
|
||||
chatHistory->slider->moveToMax();
|
||||
chatHistory->slider->scrollToMax();
|
||||
}
|
||||
|
||||
CFlagBox::CFlagBox(const Rect & rect)
|
||||
|
@ -72,7 +72,7 @@ void OptionsTab::recreate()
|
||||
|
||||
if(sliderTurnDuration)
|
||||
{
|
||||
sliderTurnDuration->moveTo(vstd::find_pos(GameConstants::POSSIBLE_TURNTIME, SEL->getStartInfo()->turnTime));
|
||||
sliderTurnDuration->scrollTo(vstd::find_pos(GameConstants::POSSIBLE_TURNTIME, SEL->getStartInfo()->turnTime));
|
||||
labelTurnDurationValue->setText(CGI->generaltexth->turnDurations[sliderTurnDuration->getValue()]);
|
||||
}
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ void SelectionTab::filter(int size, bool selectFirst)
|
||||
sort();
|
||||
if(selectFirst)
|
||||
{
|
||||
slider->moveTo(0);
|
||||
slider->scrollTo(0);
|
||||
callOnSelect(curItems[0]);
|
||||
selectAbs(0);
|
||||
}
|
||||
@ -406,9 +406,9 @@ void SelectionTab::select(int position)
|
||||
selectionPos = py;
|
||||
|
||||
if(position < 0)
|
||||
slider->moveBy(position);
|
||||
slider->scrollBy(position);
|
||||
else if(position >= listItems.size())
|
||||
slider->moveBy(position - (int)listItems.size() + 1);
|
||||
slider->scrollBy(position - (int)listItems.size() + 1);
|
||||
|
||||
rememberCurrentSelection();
|
||||
|
||||
@ -482,7 +482,7 @@ void SelectionTab::selectFileName(std::string fname)
|
||||
{
|
||||
if(curItems[i]->fileURI == fname)
|
||||
{
|
||||
slider->moveTo(i);
|
||||
slider->scrollTo(i);
|
||||
selectAbs(i);
|
||||
return;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ void CListBox::updatePositions()
|
||||
{
|
||||
redraw();
|
||||
if (slider)
|
||||
slider->moveTo((int)first);
|
||||
slider->scrollTo((int)first);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,3 +10,85 @@
|
||||
|
||||
#include "StdInc.h"
|
||||
#include "Scrollable.h"
|
||||
|
||||
Scrollable::Scrollable(int used, Point position, Orientation orientation)
|
||||
: CIntObject(used | WHEEL | GESTURE_PANNING, position)
|
||||
, scrollStep(1)
|
||||
, panningDistanceSingle(32)
|
||||
, panningDistanceAccumulated(0)
|
||||
, orientation(orientation)
|
||||
{
|
||||
}
|
||||
|
||||
void Scrollable::panning(bool on)
|
||||
{
|
||||
panningDistanceAccumulated = 0;
|
||||
}
|
||||
|
||||
void Scrollable::wheelScrolled(int distance)
|
||||
{
|
||||
if (orientation == Orientation::HORIZONTAL)
|
||||
scrollBy(distance * 3);
|
||||
else
|
||||
scrollBy(-distance * 3);
|
||||
}
|
||||
|
||||
void Scrollable::gesturePanning(const Point & distanceDelta)
|
||||
{
|
||||
if (orientation == Orientation::HORIZONTAL)
|
||||
panningDistanceAccumulated += -distanceDelta.x;
|
||||
else
|
||||
panningDistanceAccumulated += distanceDelta.y;
|
||||
|
||||
if (-panningDistanceAccumulated > panningDistanceSingle )
|
||||
{
|
||||
int scrollAmount = (-panningDistanceAccumulated) / panningDistanceSingle;
|
||||
scrollBy(-scrollAmount);
|
||||
panningDistanceAccumulated += scrollAmount * panningDistanceSingle;
|
||||
}
|
||||
|
||||
if (panningDistanceAccumulated > panningDistanceSingle )
|
||||
{
|
||||
int scrollAmount = panningDistanceAccumulated / panningDistanceSingle;
|
||||
scrollBy(scrollAmount);
|
||||
panningDistanceAccumulated += -scrollAmount * panningDistanceSingle;
|
||||
}
|
||||
}
|
||||
|
||||
int Scrollable::getScrollStep() const
|
||||
{
|
||||
return scrollStep;
|
||||
}
|
||||
|
||||
Orientation Scrollable::getOrientation() const
|
||||
{
|
||||
return orientation;
|
||||
}
|
||||
|
||||
void Scrollable::scrollNext()
|
||||
{
|
||||
scrollBy(+1);
|
||||
}
|
||||
|
||||
void Scrollable::scrollPrev()
|
||||
{
|
||||
scrollBy(-1);
|
||||
}
|
||||
|
||||
void Scrollable::setScrollStep(int to)
|
||||
{
|
||||
scrollStep = to;
|
||||
}
|
||||
|
||||
void Scrollable::setPanningStep(int to)
|
||||
{
|
||||
panningDistanceSingle = to;
|
||||
}
|
||||
|
||||
void Scrollable::setScrollingEnabled(bool on)
|
||||
{
|
||||
if (on)
|
||||
addUsedEvents(WHEEL | GESTURE_PANNING);
|
||||
else
|
||||
removeUsedEvents(WHEEL | GESTURE_PANNING);
|
||||
}
|
||||
|
@ -11,3 +11,51 @@
|
||||
#pragma once
|
||||
|
||||
#include "../gui/CIntObject.h"
|
||||
|
||||
enum class Orientation
|
||||
{
|
||||
HORIZONTAL,
|
||||
VERTICAL
|
||||
};
|
||||
|
||||
/// Simple class that provides scrolling functionality via either mouse wheel or touchscreen gesture
|
||||
class Scrollable : public CIntObject
|
||||
{
|
||||
/// how many elements will be scrolled via one click, default = 1
|
||||
int scrollStep;
|
||||
/// How far player must move finger/mouse to move slider by 1 via gesture
|
||||
int panningDistanceSingle;
|
||||
/// How far have player moved finger/mouse via gesture so far.
|
||||
int panningDistanceAccumulated;
|
||||
|
||||
Orientation orientation;
|
||||
|
||||
protected:
|
||||
Scrollable(int used, Point position, Orientation orientation);
|
||||
|
||||
void panning(bool on) override;
|
||||
void wheelScrolled(int distance) override;
|
||||
void gesturePanning(const Point & distanceDelta) override;
|
||||
|
||||
int getScrollStep() const;
|
||||
Orientation getOrientation() const;
|
||||
|
||||
public:
|
||||
/// Scrolls view by specified number of items
|
||||
virtual void scrollBy(int distance) = 0;
|
||||
|
||||
/// Scrolls view by 1 item, identical to scrollBy(+1)
|
||||
virtual void scrollNext();
|
||||
|
||||
/// Scrolls view by 1 item, identical to scrollBy(-1)
|
||||
virtual void scrollPrev();
|
||||
|
||||
/// Controls how many items wil be scrolled via one click
|
||||
void setScrollStep(int to);
|
||||
|
||||
/// Controls size of panning step needed to move list by 1 item
|
||||
void setPanningStep(int to);
|
||||
|
||||
/// Enables or disabled scrolling
|
||||
void setScrollingEnabled(bool on);
|
||||
};
|
||||
|
@ -26,7 +26,7 @@ void CSlider::sliderClicked()
|
||||
void CSlider::mouseMoved (const Point & cursorPosition)
|
||||
{
|
||||
double v = 0;
|
||||
if(horizontal)
|
||||
if(getOrientation() == Orientation::HORIZONTAL)
|
||||
{
|
||||
if( std::abs(cursorPosition.y-(pos.y+pos.h/2)) > pos.h/2+40 || std::abs(cursorPosition.x-(pos.x+pos.w/2)) > pos.w/2 )
|
||||
return;
|
||||
@ -45,15 +45,10 @@ void CSlider::mouseMoved (const Point & cursorPosition)
|
||||
v += 0.5;
|
||||
if(v!=value)
|
||||
{
|
||||
moveTo(static_cast<int>(v));
|
||||
scrollTo(static_cast<int>(v));
|
||||
}
|
||||
}
|
||||
|
||||
void CSlider::setScrollStep(int to)
|
||||
{
|
||||
scrollStep = to;
|
||||
}
|
||||
|
||||
void CSlider::setScrollBounds(const Rect & bounds )
|
||||
{
|
||||
scrollBounds = bounds;
|
||||
@ -79,24 +74,14 @@ int CSlider::getCapacity() const
|
||||
return capacity;
|
||||
}
|
||||
|
||||
void CSlider::moveLeft()
|
||||
void CSlider::scrollBy(int amount)
|
||||
{
|
||||
moveTo(value-1);
|
||||
}
|
||||
|
||||
void CSlider::moveRight()
|
||||
{
|
||||
moveTo(value+1);
|
||||
}
|
||||
|
||||
void CSlider::moveBy(int amount)
|
||||
{
|
||||
moveTo(value + amount);
|
||||
scrollTo(value + amount);
|
||||
}
|
||||
|
||||
void CSlider::updateSliderPos()
|
||||
{
|
||||
if(horizontal)
|
||||
if(getOrientation() == Orientation::HORIZONTAL)
|
||||
{
|
||||
if(positions)
|
||||
{
|
||||
@ -122,7 +107,7 @@ void CSlider::updateSliderPos()
|
||||
}
|
||||
}
|
||||
|
||||
void CSlider::moveTo(int to)
|
||||
void CSlider::scrollTo(int to)
|
||||
{
|
||||
vstd::amax(to, 0);
|
||||
vstd::amin(to, positions);
|
||||
@ -143,7 +128,7 @@ void CSlider::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
double pw = 0;
|
||||
double rw = 0;
|
||||
if(horizontal)
|
||||
if(getOrientation() == Orientation::HORIZONTAL)
|
||||
{
|
||||
pw = GH.getCursorPosition().x-pos.x-25;
|
||||
rw = pw / static_cast<double>(pos.w - 48);
|
||||
@ -153,12 +138,12 @@ void CSlider::clickLeft(tribool down, bool previousState)
|
||||
pw = GH.getCursorPosition().y-pos.y-24;
|
||||
rw = pw / (pos.h-48);
|
||||
}
|
||||
if(pw < -8 || pw > (horizontal ? pos.w : pos.h) - 40)
|
||||
if(pw < -8 || pw > (getOrientation() == Orientation::HORIZONTAL ? pos.w : pos.h) - 40)
|
||||
return;
|
||||
// if (rw>1) return;
|
||||
// if (rw<0) return;
|
||||
slider->clickLeft(true, slider->isMouseButtonPressed(MouseButton::LEFT));
|
||||
moveTo((int)(rw * positions + 0.5));
|
||||
scrollTo((int)(rw * positions + 0.5));
|
||||
return;
|
||||
}
|
||||
removeUsedEvents(MOVE);
|
||||
@ -179,60 +164,21 @@ bool CSlider::receiveEvent(const Point &position, int eventType) const
|
||||
return testTarget.isInside(position);
|
||||
}
|
||||
|
||||
void CSlider::setPanningStep(int to)
|
||||
{
|
||||
panningDistanceSingle = to;
|
||||
}
|
||||
|
||||
void CSlider::panning(bool on)
|
||||
{
|
||||
panningDistanceAccumulated = 0;
|
||||
}
|
||||
|
||||
void CSlider::gesturePanning(const Point & distanceDelta)
|
||||
{
|
||||
if (horizontal)
|
||||
panningDistanceAccumulated += -distanceDelta.x;
|
||||
else
|
||||
panningDistanceAccumulated += distanceDelta.y;
|
||||
|
||||
if (-panningDistanceAccumulated > panningDistanceSingle )
|
||||
{
|
||||
int scrollAmount = (-panningDistanceAccumulated) / panningDistanceSingle;
|
||||
moveBy(-scrollAmount);
|
||||
panningDistanceAccumulated += scrollAmount * panningDistanceSingle;
|
||||
}
|
||||
|
||||
if (panningDistanceAccumulated > panningDistanceSingle )
|
||||
{
|
||||
int scrollAmount = panningDistanceAccumulated / panningDistanceSingle;
|
||||
moveBy(scrollAmount);
|
||||
panningDistanceAccumulated += -scrollAmount * panningDistanceSingle;
|
||||
}
|
||||
}
|
||||
|
||||
CSlider::CSlider(Point position, int totalw, std::function<void(int)> Moved, int Capacity, int Amount, int Value, bool Horizontal, CSlider::EStyle style)
|
||||
: CIntObject(LCLICK | RCLICK | WHEEL | GESTURE_PANNING ),
|
||||
: Scrollable(LCLICK, position, Horizontal ? Orientation::HORIZONTAL : Orientation::VERTICAL ),
|
||||
capacity(Capacity),
|
||||
horizontal(Horizontal),
|
||||
amount(Amount),
|
||||
value(Value),
|
||||
scrollStep(1),
|
||||
moved(Moved),
|
||||
panningDistanceAccumulated(0),
|
||||
panningDistanceSingle(32)
|
||||
moved(Moved)
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
setAmount(amount);
|
||||
vstd::amax(value, 0);
|
||||
vstd::amin(value, positions);
|
||||
|
||||
pos.x += position.x;
|
||||
pos.y += position.y;
|
||||
|
||||
if(style == BROWN)
|
||||
{
|
||||
std::string name = horizontal ? "IGPCRDIV.DEF" : "OVBUTN2.DEF";
|
||||
std::string name = getOrientation() == Orientation::HORIZONTAL ? "IGPCRDIV.DEF" : "OVBUTN2.DEF";
|
||||
//NOTE: this images do not have "blocked" frames. They should be implemented somehow (e.g. palette transform or something...)
|
||||
|
||||
left = std::make_shared<CButton>(Point(), name, CButton::tooltip());
|
||||
@ -245,8 +191,8 @@ CSlider::CSlider(Point position, int totalw, std::function<void(int)> Moved, int
|
||||
}
|
||||
else
|
||||
{
|
||||
left = std::make_shared<CButton>(Point(), horizontal ? "SCNRBLF.DEF" : "SCNRBUP.DEF", CButton::tooltip());
|
||||
right = std::make_shared<CButton>(Point(), horizontal ? "SCNRBRT.DEF" : "SCNRBDN.DEF", CButton::tooltip());
|
||||
left = std::make_shared<CButton>(Point(), getOrientation() == Orientation::HORIZONTAL ? "SCNRBLF.DEF" : "SCNRBUP.DEF", CButton::tooltip());
|
||||
right = std::make_shared<CButton>(Point(), getOrientation() == Orientation::HORIZONTAL ? "SCNRBRT.DEF" : "SCNRBDN.DEF", CButton::tooltip());
|
||||
slider = std::make_shared<CButton>(Point(), "SCNRBSL.DEF", CButton::tooltip());
|
||||
}
|
||||
slider->actOnDown = true;
|
||||
@ -254,16 +200,16 @@ CSlider::CSlider(Point position, int totalw, std::function<void(int)> Moved, int
|
||||
left->soundDisabled = true;
|
||||
right->soundDisabled = true;
|
||||
|
||||
if (horizontal)
|
||||
if (getOrientation() == Orientation::HORIZONTAL)
|
||||
right->moveBy(Point(totalw - right->pos.w, 0));
|
||||
else
|
||||
right->moveBy(Point(0, totalw - right->pos.h));
|
||||
|
||||
left->addCallback(std::bind(&CSlider::moveLeft,this));
|
||||
right->addCallback(std::bind(&CSlider::moveRight,this));
|
||||
left->addCallback(std::bind(&CSlider::scrollPrev,this));
|
||||
right->addCallback(std::bind(&CSlider::scrollNext,this));
|
||||
slider->addCallback(std::bind(&CSlider::sliderClicked,this));
|
||||
|
||||
if(horizontal)
|
||||
if(getOrientation() == Orientation::HORIZONTAL)
|
||||
{
|
||||
pos.h = slider->pos.h;
|
||||
pos.w = totalw;
|
||||
@ -299,41 +245,32 @@ void CSlider::showAll(Canvas & to)
|
||||
CIntObject::showAll(to);
|
||||
}
|
||||
|
||||
void CSlider::wheelScrolled(int distance)
|
||||
{
|
||||
// vertical slider -> scrolling up move slider upwards
|
||||
// horizontal slider -> scrolling up moves slider towards right
|
||||
bool positive = ((distance < 0) != horizontal);
|
||||
|
||||
moveTo(value + 3 * (positive ? +scrollStep : -scrollStep));
|
||||
}
|
||||
|
||||
void CSlider::keyPressed(EShortcut key)
|
||||
{
|
||||
int moveDest = value;
|
||||
switch(key)
|
||||
{
|
||||
case EShortcut::MOVE_UP:
|
||||
if (!horizontal)
|
||||
moveDest = value - scrollStep;
|
||||
if (getOrientation() == Orientation::VERTICAL)
|
||||
moveDest = value - getScrollStep();
|
||||
break;
|
||||
case EShortcut::MOVE_LEFT:
|
||||
if (horizontal)
|
||||
moveDest = value - scrollStep;
|
||||
if (getOrientation() == Orientation::HORIZONTAL)
|
||||
moveDest = value - getScrollStep();
|
||||
break;
|
||||
case EShortcut::MOVE_DOWN:
|
||||
if (!horizontal)
|
||||
moveDest = value + scrollStep;
|
||||
if (getOrientation() == Orientation::VERTICAL)
|
||||
moveDest = value + getScrollStep();
|
||||
break;
|
||||
case EShortcut::MOVE_RIGHT:
|
||||
if (horizontal)
|
||||
moveDest = value + scrollStep;
|
||||
if (getOrientation() == Orientation::HORIZONTAL)
|
||||
moveDest = value + getScrollStep();
|
||||
break;
|
||||
case EShortcut::MOVE_PAGE_UP:
|
||||
moveDest = value - capacity + scrollStep;
|
||||
moveDest = value - capacity + getScrollStep();
|
||||
break;
|
||||
case EShortcut::MOVE_PAGE_DOWN:
|
||||
moveDest = value + capacity - scrollStep;
|
||||
moveDest = value + capacity - getScrollStep();
|
||||
break;
|
||||
case EShortcut::MOVE_FIRST:
|
||||
moveDest = 0;
|
||||
@ -345,15 +282,15 @@ void CSlider::keyPressed(EShortcut key)
|
||||
return;
|
||||
}
|
||||
|
||||
moveTo(moveDest);
|
||||
scrollTo(moveDest);
|
||||
}
|
||||
|
||||
void CSlider::moveToMin()
|
||||
void CSlider::scrollToMin()
|
||||
{
|
||||
moveTo(0);
|
||||
scrollTo(0);
|
||||
}
|
||||
|
||||
void CSlider::moveToMax()
|
||||
void CSlider::scrollToMax()
|
||||
{
|
||||
moveTo(amount);
|
||||
scrollTo(amount);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
class CButton;
|
||||
|
||||
/// A typical slider which can be orientated horizontally/vertically.
|
||||
class CSlider : public CIntObject
|
||||
class CSlider : public Scrollable
|
||||
{
|
||||
//if vertical then left=up
|
||||
std::shared_ptr<CButton> left;
|
||||
@ -29,19 +29,10 @@ class CSlider : public CIntObject
|
||||
int capacity;
|
||||
/// number of highest position, or 0 if there is only one
|
||||
int positions;
|
||||
/// if true, then slider is not vertical but horizontal
|
||||
bool horizontal;
|
||||
/// total amount of elements in the list
|
||||
int amount;
|
||||
/// topmost vislble (first active) element
|
||||
int value;
|
||||
/// how many elements will be scrolled via one click, default = 1
|
||||
int scrollStep;
|
||||
|
||||
/// How far player must move finger/mouse to move slider by 1 via gesture
|
||||
int panningDistanceSingle;
|
||||
/// How far have player moved finger/mouse via gesture so far.
|
||||
int panningDistanceAccumulated;
|
||||
|
||||
CFunctionList<void(int)> moved;
|
||||
|
||||
@ -57,23 +48,15 @@ public:
|
||||
|
||||
void block(bool on);
|
||||
|
||||
/// Controls how many items wil be scrolled via one click
|
||||
void setScrollStep(int to);
|
||||
|
||||
/// Controls size of panning step needed to move list by 1 item
|
||||
void setPanningStep(int to);
|
||||
|
||||
/// If set, mouse scroll will only scroll slider when inside of this area
|
||||
void setScrollBounds(const Rect & bounds );
|
||||
void clearScrollBounds();
|
||||
|
||||
/// Value modifiers
|
||||
void moveLeft();
|
||||
void moveRight();
|
||||
void moveTo(int value);
|
||||
void moveBy(int amount);
|
||||
void moveToMin();
|
||||
void moveToMax();
|
||||
void scrollTo(int value);
|
||||
void scrollBy(int amount) override;
|
||||
void scrollToMin();
|
||||
void scrollToMax();
|
||||
|
||||
/// Amount modifier
|
||||
void setAmount(int to);
|
||||
@ -86,14 +69,10 @@ public:
|
||||
void addCallback(std::function<void(int)> callback);
|
||||
|
||||
bool receiveEvent(const Point & position, int eventType) const override;
|
||||
|
||||
void keyPressed(EShortcut key) override;
|
||||
void wheelScrolled(int distance) override;
|
||||
void gesturePanning(const Point & distanceDelta) override;
|
||||
void clickLeft(tribool down, bool previousState) override;
|
||||
void mouseMoved (const Point & cursorPosition) override;
|
||||
void showAll(Canvas & to) override;
|
||||
void panning(bool on) override;
|
||||
|
||||
/// @param position coordinates of slider
|
||||
/// @param length length of slider ribbon, including left/right buttons
|
||||
|
@ -194,12 +194,12 @@ void CQuestLog::recreateLabelList()
|
||||
if (currentLabel > QUEST_COUNT)
|
||||
{
|
||||
slider->block(false);
|
||||
slider->moveToMax();
|
||||
slider->scrollToMax();
|
||||
}
|
||||
else
|
||||
{
|
||||
slider->block(true);
|
||||
slider->moveToMin();
|
||||
slider->scrollToMin();
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,7 +239,7 @@ void CQuestLog::selectQuest(int which, int labelId)
|
||||
std::vector<Component> components;
|
||||
currentQuest->quest->getVisitText (text, components, currentQuest->quest->isCustomFirst, true);
|
||||
if(description->slider)
|
||||
description->slider->moveToMin(); // scroll text to start position
|
||||
description->slider->scrollToMin(); // scroll text to start position
|
||||
description->setText(text.toString()); //TODO: use special log entry text
|
||||
|
||||
componentsBox.reset();
|
||||
|
@ -785,7 +785,7 @@ CMarketplaceWindow::~CMarketplaceWindow() = default;
|
||||
|
||||
void CMarketplaceWindow::setMax()
|
||||
{
|
||||
slider->moveToMax();
|
||||
slider->scrollToMax();
|
||||
}
|
||||
|
||||
void CMarketplaceWindow::makeDeal()
|
||||
@ -825,7 +825,7 @@ void CMarketplaceWindow::makeDeal()
|
||||
if(slider)
|
||||
{
|
||||
LOCPLINT->cb->trade(market, mode, leftIdToSend, hRight->id, slider->getValue() * r1, hero);
|
||||
slider->moveTo(0);
|
||||
slider->scrollTo(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -869,7 +869,7 @@ void CMarketplaceWindow::selectionChanged(bool side)
|
||||
assert(0);
|
||||
|
||||
slider->setAmount(newAmount / r1);
|
||||
slider->moveTo(0);
|
||||
slider->scrollTo(0);
|
||||
max->block(false);
|
||||
deal->block(false);
|
||||
}
|
||||
@ -886,7 +886,7 @@ void CMarketplaceWindow::selectionChanged(bool side)
|
||||
{
|
||||
max->block(true);
|
||||
slider->setAmount(0);
|
||||
slider->moveTo(0);
|
||||
slider->scrollTo(0);
|
||||
}
|
||||
deal->block(true);
|
||||
}
|
||||
@ -1121,7 +1121,7 @@ CAltarWindow::CAltarWindow(const IMarket * Market, const CGHeroInstance * Hero,
|
||||
new CTextBox(CGI->generaltexth->allTexts[480], Rect(320, 56, 256, 40), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW);
|
||||
|
||||
slider = std::make_shared<CSlider>(Point(231,481),137,std::bind(&CAltarWindow::sliderMoved,this,_1),0,0);
|
||||
max = std::make_shared<CButton>(Point(147, 520), "IRCBTNS.DEF", CGI->generaltexth->zelp[578], std::bind(&CSlider::moveToMax, slider));
|
||||
max = std::make_shared<CButton>(Point(147, 520), "IRCBTNS.DEF", CGI->generaltexth->zelp[578], std::bind(&CSlider::scrollToMax, slider));
|
||||
|
||||
sacrificedUnits.resize(GameConstants::ARMY_SIZE, 0);
|
||||
sacrificeAll = std::make_shared<CButton>(Point(393, 520), "ALTARMY.DEF", CGI->generaltexth->zelp[579], std::bind(&CAltarWindow::SacrificeAll,this));
|
||||
@ -1214,7 +1214,7 @@ void CAltarWindow::makeDeal()
|
||||
if(mode == EMarketMode::CREATURE_EXP)
|
||||
{
|
||||
blockTrade();
|
||||
slider->moveTo(0);
|
||||
slider->scrollTo(0);
|
||||
|
||||
std::vector<ui32> ids;
|
||||
std::vector<ui32> toSacrifice;
|
||||
@ -1311,7 +1311,7 @@ void CAltarWindow::selectionChanged(bool side)
|
||||
|
||||
slider->setAmount(hero->getStackCount(SlotID(hLeft->serial)) - (stackCount == 1));
|
||||
slider->block(!slider->getAmount());
|
||||
slider->moveTo(sacrificedUnits[hLeft->serial]);
|
||||
slider->scrollTo(sacrificedUnits[hLeft->serial]);
|
||||
max->block(!slider->getAmount());
|
||||
selectOppositeItem(side);
|
||||
readyToTrade = true;
|
||||
|
@ -35,12 +35,12 @@ void CreaturePurchaseCard::initButtons()
|
||||
|
||||
void CreaturePurchaseCard::initMaxButton()
|
||||
{
|
||||
maxButton = std::make_shared<CButton>(Point(pos.x + 52, pos.y + 180), "QuickRecruitmentWindow/QuickRecruitmentAllButton.def", CButton::tooltip(), std::bind(&CSlider::moveToMax,slider), EShortcut::RECRUITMENT_MAX);
|
||||
maxButton = std::make_shared<CButton>(Point(pos.x + 52, pos.y + 180), "QuickRecruitmentWindow/QuickRecruitmentAllButton.def", CButton::tooltip(), std::bind(&CSlider::scrollToMax,slider), EShortcut::RECRUITMENT_MAX);
|
||||
}
|
||||
|
||||
void CreaturePurchaseCard::initMinButton()
|
||||
{
|
||||
minButton = std::make_shared<CButton>(Point(pos.x, pos.y + 180), "QuickRecruitmentWindow/QuickRecruitmentNoneButton.def", CButton::tooltip(), std::bind(&CSlider::moveToMin,slider), EShortcut::RECRUITMENT_MIN);
|
||||
minButton = std::make_shared<CButton>(Point(pos.x, pos.y + 180), "QuickRecruitmentWindow/QuickRecruitmentNoneButton.def", CButton::tooltip(), std::bind(&CSlider::scrollToMin,slider), EShortcut::RECRUITMENT_MIN);
|
||||
}
|
||||
|
||||
void CreaturePurchaseCard::initCreatureSwitcherButton()
|
||||
|
@ -134,7 +134,7 @@ void CRecruitmentWindow::select(std::shared_ptr<CCreatureCard> card)
|
||||
slider->setAmount(maxAmount);
|
||||
|
||||
if(slider->getValue() != maxAmount)
|
||||
slider->moveTo(maxAmount);
|
||||
slider->scrollTo(maxAmount);
|
||||
else // if slider already at 0 - emulate call to sliderMoved()
|
||||
sliderMoved(maxAmount);
|
||||
|
||||
@ -215,7 +215,7 @@ CRecruitmentWindow::CRecruitmentWindow(const CGDwelling * Dwelling, int Level, c
|
||||
|
||||
slider = std::make_shared<CSlider>(Point(176,279),135,std::bind(&CRecruitmentWindow::sliderMoved,this, _1),0,0,0,true);
|
||||
|
||||
maxButton = std::make_shared<CButton>(Point(134, 313), "IRCBTNS.DEF", CGI->generaltexth->zelp[553], std::bind(&CSlider::moveToMax, slider), EShortcut::RECRUITMENT_MAX);
|
||||
maxButton = std::make_shared<CButton>(Point(134, 313), "IRCBTNS.DEF", CGI->generaltexth->zelp[553], std::bind(&CSlider::scrollToMax, slider), EShortcut::RECRUITMENT_MAX);
|
||||
buyButton = std::make_shared<CButton>(Point(212, 313), "IBY6432.DEF", CGI->generaltexth->zelp[554], std::bind(&CRecruitmentWindow::buy, this), EShortcut::GLOBAL_ACCEPT);
|
||||
cancelButton = std::make_shared<CButton>(Point(290, 313), "ICN6432.DEF", CGI->generaltexth->zelp[555], std::bind(&CRecruitmentWindow::close, this), EShortcut::GLOBAL_CANCEL);
|
||||
|
||||
@ -287,7 +287,7 @@ void CRecruitmentWindow::availableCreaturesChanged()
|
||||
select(cards[selectedIndex]);
|
||||
|
||||
if(slider->getValue() == slider->getAmount())
|
||||
slider->moveToMax();
|
||||
slider->scrollToMax();
|
||||
else // if slider already at 0 - emulate call to sliderMoved()
|
||||
sliderMoved(slider->getAmount());
|
||||
}
|
||||
@ -363,7 +363,7 @@ void CSplitWindow::setAmountText(std::string text, bool left)
|
||||
}
|
||||
|
||||
setAmount(amount, left);
|
||||
slider->moveTo(rightAmount - rightMin);
|
||||
slider->scrollTo(rightAmount - rightMin);
|
||||
}
|
||||
|
||||
void CSplitWindow::setAmount(int value, bool left)
|
||||
|
@ -89,11 +89,11 @@ void QuickRecruitmentWindow::maxAllCards(std::vector<std::shared_ptr<CreaturePur
|
||||
i->slider->setAmount(maxAmount);
|
||||
|
||||
if(i->slider->getValue() != maxAmount)
|
||||
i->slider->moveTo(maxAmount);
|
||||
i->slider->scrollTo(maxAmount);
|
||||
else
|
||||
i->sliderMoved(maxAmount);
|
||||
|
||||
i->slider->moveToMax();
|
||||
i->slider->scrollToMax();
|
||||
allAvailableResources -= (i->creatureOnTheCard->getFullRecruitCost() * maxAmount);
|
||||
}
|
||||
maxButton->block(allAvailableResources == LOCPLINT->cb->getResourceAmount());
|
||||
@ -141,7 +141,7 @@ void QuickRecruitmentWindow::updateAllSliders()
|
||||
i->slider->setAmount(i->slider->getValue() + maxAmount);
|
||||
else
|
||||
i->slider->setAmount(i->maxAmount);
|
||||
i->slider->moveTo(i->slider->getValue());
|
||||
i->slider->scrollTo(i->slider->getValue());
|
||||
}
|
||||
totalCost->createItems(LOCPLINT->cb->getResourceAmount() - allAvailableResources);
|
||||
totalCost->set(LOCPLINT->cb->getResourceAmount() - allAvailableResources);
|
||||
|
@ -164,10 +164,10 @@ GeneralOptionsTab::GeneralOptionsTab()
|
||||
framerateCheckbox->setSelected(settings["video"]["showfps"].Bool());
|
||||
|
||||
std::shared_ptr<CSlider> musicSlider = widget<CSlider>("musicSlider");
|
||||
musicSlider->moveTo(CCS->musich->getVolume());
|
||||
musicSlider->scrollTo(CCS->musich->getVolume());
|
||||
|
||||
std::shared_ptr<CSlider> volumeSlider = widget<CSlider>("soundVolumeSlider");
|
||||
volumeSlider->moveTo(CCS->soundh->getVolume());
|
||||
volumeSlider->scrollTo(CCS->soundh->getVolume());
|
||||
|
||||
std::shared_ptr<CToggleGroup> creatureGrowthAsDwellingPicker = widget<CToggleGroup>("availableCreaturesAsDwellingPicker");
|
||||
creatureGrowthAsDwellingPicker->setSelected(settings["gameTweaks"]["availableCreaturesAsDwellingLabel"].Bool());
|
||||
|
Loading…
Reference in New Issue
Block a user