mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-23 12:08:45 +02:00
Merge pull request #2250 from IvanSavenko/event_handling_fixes
Slider input event fix
This commit is contained in:
commit
a84ccb37c2
@ -88,7 +88,7 @@ void CMinimapInstance::showAll(Canvas & to)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CMinimap::CMinimap(const Rect & position)
|
CMinimap::CMinimap(const Rect & position)
|
||||||
: CIntObject(LCLICK | SHOW_POPUP | HOVER | MOVE | GESTURE, position.topLeft()),
|
: CIntObject(LCLICK | SHOW_POPUP | DRAG | MOVE | GESTURE, position.topLeft()),
|
||||||
level(0)
|
level(0)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
@ -162,9 +162,8 @@ void CMinimap::hover(bool on)
|
|||||||
GH.statusbar()->clear();
|
GH.statusbar()->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMinimap::mouseMoved(const Point & cursorPosition)
|
void CMinimap::mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance)
|
||||||
{
|
{
|
||||||
if(isMouseLeftButtonPressed())
|
|
||||||
moveAdvMapSelection(cursorPosition);
|
moveAdvMapSelection(cursorPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ class CMinimap : public CIntObject
|
|||||||
void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) override;
|
void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) override;
|
||||||
void clickLeft(tribool down, bool previousState) override;
|
void clickLeft(tribool down, bool previousState) override;
|
||||||
void showPopupWindow() override;
|
void showPopupWindow() override;
|
||||||
void hover (bool on) override;
|
void hover(bool on) override;
|
||||||
void mouseMoved (const Point & cursorPosition) override;
|
void mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance) override;
|
||||||
|
|
||||||
/// relocates center of adventure map screen to currently hovered tile
|
/// relocates center of adventure map screen to currently hovered tile
|
||||||
void moveAdvMapSelection(const Point & positionGlobal);
|
void moveAdvMapSelection(const Point & positionGlobal);
|
||||||
|
@ -202,7 +202,7 @@ void BattleFieldController::gesturePanning(const Point & initialPosition, const
|
|||||||
owner.actionsController->onHexHovered(getHoveredHex());
|
owner.actionsController->onHexHovered(getHoveredHex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleFieldController::mouseMoved(const Point & cursorPosition)
|
void BattleFieldController::mouseMoved(const Point & cursorPosition, const Point & lastUpdateDistance)
|
||||||
{
|
{
|
||||||
hoveredHex = getHexAtPosition(cursorPosition);
|
hoveredHex = getHexAtPosition(cursorPosition);
|
||||||
currentAttackOriginPoint = cursorPosition;
|
currentAttackOriginPoint = cursorPosition;
|
||||||
|
@ -99,7 +99,7 @@ class BattleFieldController : public CIntObject
|
|||||||
|
|
||||||
void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
|
void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
|
||||||
void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) override;
|
void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) override;
|
||||||
void mouseMoved(const Point & cursorPosition) override;
|
void mouseMoved(const Point & cursorPosition, const Point & lastUpdateDistance) override;
|
||||||
void clickLeft(tribool down, bool previousState) override;
|
void clickLeft(tribool down, bool previousState) override;
|
||||||
void showPopupWindow() override;
|
void showPopupWindow() override;
|
||||||
void activate() override;
|
void activate() override;
|
||||||
|
@ -75,7 +75,7 @@ void InputHandler::handleCurrentEvent(const SDL_Event & current)
|
|||||||
void InputHandler::processEvents()
|
void InputHandler::processEvents()
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> lock(eventsMutex);
|
boost::unique_lock<boost::mutex> lock(eventsMutex);
|
||||||
for (auto const & currentEvent : eventsQueue)
|
for(const auto & currentEvent : eventsQueue)
|
||||||
handleCurrentEvent(currentEvent);
|
handleCurrentEvent(currentEvent);
|
||||||
|
|
||||||
eventsQueue.clear();
|
eventsQueue.clear();
|
||||||
@ -87,7 +87,7 @@ bool InputHandler::ignoreEventsUntilInput()
|
|||||||
bool inputFound = false;
|
bool inputFound = false;
|
||||||
|
|
||||||
boost::unique_lock<boost::mutex> lock(eventsMutex);
|
boost::unique_lock<boost::mutex> lock(eventsMutex);
|
||||||
for (auto const & event : eventsQueue)
|
for(const auto & event : eventsQueue)
|
||||||
{
|
{
|
||||||
switch(event.type)
|
switch(event.type)
|
||||||
{
|
{
|
||||||
@ -226,7 +226,7 @@ void InputHandler::moveCursorPosition(const Point & distance)
|
|||||||
void InputHandler::setCursorPosition(const Point & position)
|
void InputHandler::setCursorPosition(const Point & position)
|
||||||
{
|
{
|
||||||
cursorPosition = position;
|
cursorPosition = position;
|
||||||
GH.events().dispatchMouseMoved(position);
|
GH.events().dispatchMouseMoved(Point(0, 0), position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputHandler::startTextInput(const Rect & where)
|
void InputHandler::startTextInput(const Rect & where)
|
||||||
@ -244,11 +244,6 @@ bool InputHandler::hasTouchInputDevice() const
|
|||||||
return fingerHandler->hasTouchInputDevice();
|
return fingerHandler->hasTouchInputDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputHandler::isMouseButtonPressed(MouseButton button) const
|
|
||||||
{
|
|
||||||
return mouseHandler->isMouseButtonPressed(button) || fingerHandler->isMouseButtonPressed(button);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputHandler::pushUserEvent(EUserEvent usercode, void * userdata)
|
void InputHandler::pushUserEvent(EUserEvent usercode, void * userdata)
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
@ -66,9 +66,6 @@ public:
|
|||||||
/// returns true if system has active touchscreen
|
/// returns true if system has active touchscreen
|
||||||
bool hasTouchInputDevice() const;
|
bool hasTouchInputDevice() const;
|
||||||
|
|
||||||
/// Returns true if selected mouse button is pressed at the moment
|
|
||||||
bool isMouseButtonPressed(MouseButton button) const;
|
|
||||||
|
|
||||||
/// Generates new user event that will be processed on next frame
|
/// Generates new user event that will be processed on next frame
|
||||||
void pushUserEvent(EUserEvent usercode, void * userdata);
|
void pushUserEvent(EUserEvent usercode, void * userdata);
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@ void InputSourceMouse::handleEventMouseMotion(const SDL_MouseMotionEvent & motio
|
|||||||
|
|
||||||
if (mouseButtonsMask & SDL_BUTTON(SDL_BUTTON_MIDDLE))
|
if (mouseButtonsMask & SDL_BUTTON(SDL_BUTTON_MIDDLE))
|
||||||
GH.events().dispatchGesturePanning(middleClickPosition, newPosition, distance);
|
GH.events().dispatchGesturePanning(middleClickPosition, newPosition, distance);
|
||||||
|
else if (mouseButtonsMask & SDL_BUTTON(SDL_BUTTON_LEFT))
|
||||||
|
GH.events().dispatchMouseDragged(newPosition, distance);
|
||||||
else
|
else
|
||||||
GH.input().setCursorPosition(newPosition);
|
GH.input().setCursorPosition(newPosition);
|
||||||
|
|
||||||
@ -76,15 +78,3 @@ void InputSourceMouse::handleEventMouseButtonUp(const SDL_MouseButtonEvent & but
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputSourceMouse::isMouseButtonPressed(MouseButton button) const
|
|
||||||
{
|
|
||||||
static_assert(static_cast<uint32_t>(MouseButton::LEFT) == SDL_BUTTON_LEFT, "mismatch between VCMI and SDL enum!");
|
|
||||||
static_assert(static_cast<uint32_t>(MouseButton::MIDDLE) == SDL_BUTTON_MIDDLE, "mismatch between VCMI and SDL enum!");
|
|
||||||
static_assert(static_cast<uint32_t>(MouseButton::RIGHT) == SDL_BUTTON_RIGHT, "mismatch between VCMI and SDL enum!");
|
|
||||||
static_assert(static_cast<uint32_t>(MouseButton::EXTRA1) == SDL_BUTTON_X1, "mismatch between VCMI and SDL enum!");
|
|
||||||
static_assert(static_cast<uint32_t>(MouseButton::EXTRA2) == SDL_BUTTON_X2, "mismatch between VCMI and SDL enum!");
|
|
||||||
|
|
||||||
uint32_t index = static_cast<uint32_t>(button);
|
|
||||||
return mouseButtonsMask & SDL_BUTTON(index);
|
|
||||||
}
|
|
||||||
|
@ -28,6 +28,4 @@ public:
|
|||||||
void handleEventMouseButtonDown(const SDL_MouseButtonEvent & current);
|
void handleEventMouseButtonDown(const SDL_MouseButtonEvent & current);
|
||||||
void handleEventMouseWheel(const SDL_MouseWheelEvent & current);
|
void handleEventMouseWheel(const SDL_MouseWheelEvent & current);
|
||||||
void handleEventMouseButtonUp(const SDL_MouseButtonEvent & current);
|
void handleEventMouseButtonUp(const SDL_MouseButtonEvent & current);
|
||||||
|
|
||||||
bool isMouseButtonPressed(MouseButton button) const;
|
|
||||||
};
|
};
|
||||||
|
@ -237,17 +237,6 @@ bool InputSourceTouch::hasTouchInputDevice() const
|
|||||||
return SDL_GetNumTouchDevices() > 0;
|
return SDL_GetNumTouchDevices() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputSourceTouch::isMouseButtonPressed(MouseButton button) const
|
|
||||||
{
|
|
||||||
if (state == TouchState::TAP_DOWN_LONG)
|
|
||||||
{
|
|
||||||
if (button == MouseButton::RIGHT)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputSourceTouch::emitPanningEvent(const SDL_TouchFingerEvent & tfinger)
|
void InputSourceTouch::emitPanningEvent(const SDL_TouchFingerEvent & tfinger)
|
||||||
{
|
{
|
||||||
Point distance = convertTouchToMouse(-tfinger.dx, -tfinger.dy);
|
Point distance = convertTouchToMouse(-tfinger.dx, -tfinger.dy);
|
||||||
|
@ -105,5 +105,4 @@ public:
|
|||||||
void handleUpdate();
|
void handleUpdate();
|
||||||
|
|
||||||
bool hasTouchInputDevice() const;
|
bool hasTouchInputDevice() const;
|
||||||
bool isMouseButtonPressed(MouseButton button) const;
|
|
||||||
};
|
};
|
||||||
|
@ -82,7 +82,7 @@ void UserEventHandler::handleUserEvent(const SDL_UserEvent & user)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EUserEvent::FAKE_MOUSE_MOVE:
|
case EUserEvent::FAKE_MOUSE_MOVE:
|
||||||
GH.events().dispatchMouseMoved(GH.getCursorPosition());
|
GH.events().dispatchMouseMoved(Point(0, 0), GH.getCursorPosition());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logGlobal->error("Unknown user event. Code %d", user.code);
|
logGlobal->error("Unknown user event. Code %d", user.code);
|
||||||
|
@ -189,11 +189,6 @@ Point CGuiHandler::screenDimensions() const
|
|||||||
return Point(screen->w, screen->h);
|
return Point(screen->w, screen->h);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGuiHandler::isMouseButtonPressed(MouseButton button) const
|
|
||||||
{
|
|
||||||
return inputHandlerInstance->isMouseButtonPressed(button);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CGuiHandler::drawFPSCounter()
|
void CGuiHandler::drawFPSCounter()
|
||||||
{
|
{
|
||||||
static SDL_Rect overlay = { 0, 0, 64, 32};
|
static SDL_Rect overlay = { 0, 0, 64, 32};
|
||||||
|
@ -70,9 +70,6 @@ public:
|
|||||||
/// May not match size of window if user has UI scaling different from 100%
|
/// May not match size of window if user has UI scaling different from 100%
|
||||||
Point screenDimensions() const;
|
Point screenDimensions() const;
|
||||||
|
|
||||||
/// returns true if specified mouse button is pressed
|
|
||||||
bool isMouseButtonPressed(MouseButton button) const;
|
|
||||||
|
|
||||||
/// returns true if chosen keyboard key is currently pressed down
|
/// returns true if chosen keyboard key is currently pressed down
|
||||||
bool isKeyboardAltDown() const;
|
bool isKeyboardAltDown() const;
|
||||||
bool isKeyboardCtrlDown() const;
|
bool isKeyboardCtrlDown() const;
|
||||||
|
@ -31,6 +31,7 @@ void EventDispatcher::processLists(ui16 activityFlag, const Functor & cb)
|
|||||||
processList(AEventsReceiver::SHOW_POPUP, rclickable);
|
processList(AEventsReceiver::SHOW_POPUP, rclickable);
|
||||||
processList(AEventsReceiver::HOVER, hoverable);
|
processList(AEventsReceiver::HOVER, hoverable);
|
||||||
processList(AEventsReceiver::MOVE, motioninterested);
|
processList(AEventsReceiver::MOVE, motioninterested);
|
||||||
|
processList(AEventsReceiver::DRAG, draginterested);
|
||||||
processList(AEventsReceiver::KEYBOARD, keyinterested);
|
processList(AEventsReceiver::KEYBOARD, keyinterested);
|
||||||
processList(AEventsReceiver::TIME, timeinterested);
|
processList(AEventsReceiver::TIME, timeinterested);
|
||||||
processList(AEventsReceiver::WHEEL, wheelInterested);
|
processList(AEventsReceiver::WHEEL, wheelInterested);
|
||||||
@ -63,7 +64,7 @@ void EventDispatcher::dispatchTimer(uint32_t msPassed)
|
|||||||
for (auto & elem : hlp)
|
for (auto & elem : hlp)
|
||||||
{
|
{
|
||||||
if(!vstd::contains(timeinterested,elem)) continue;
|
if(!vstd::contains(timeinterested,elem)) continue;
|
||||||
(elem)->tick(msPassed);
|
elem->tick(msPassed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +271,7 @@ void EventDispatcher::dispatchGesturePinch(const Point & initialPosition, double
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::dispatchMouseMoved(const Point & position)
|
void EventDispatcher::dispatchMouseMoved(const Point & distance, const Point & position)
|
||||||
{
|
{
|
||||||
EventReceiversList newlyHovered;
|
EventReceiversList newlyHovered;
|
||||||
|
|
||||||
@ -288,8 +289,8 @@ void EventDispatcher::dispatchMouseMoved(const Point & position)
|
|||||||
{
|
{
|
||||||
if (elem->isHovered())
|
if (elem->isHovered())
|
||||||
{
|
{
|
||||||
(elem)->hover(false);
|
elem->hover(false);
|
||||||
(elem)->hoveredState = false;
|
elem->hoveredState = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -308,8 +309,16 @@ void EventDispatcher::dispatchMouseMoved(const Point & position)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(elem->receiveEvent(position, AEventsReceiver::HOVER))
|
if(elem->receiveEvent(position, AEventsReceiver::HOVER))
|
||||||
{
|
elem->mouseMoved(position, distance);
|
||||||
(elem)->mouseMoved(position);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EventDispatcher::dispatchMouseDragged(const Point & currentPosition, const Point & lastUpdateDistance)
|
||||||
|
{
|
||||||
|
EventReceiversList diCopy = draginterested;
|
||||||
|
for(auto & elem : diCopy)
|
||||||
|
{
|
||||||
|
if (elem->mouseClickedState)
|
||||||
|
elem->mouseDragged(currentPosition, lastUpdateDistance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ class EventDispatcher
|
|||||||
EventReceiversList hoverable;
|
EventReceiversList hoverable;
|
||||||
EventReceiversList keyinterested;
|
EventReceiversList keyinterested;
|
||||||
EventReceiversList motioninterested;
|
EventReceiversList motioninterested;
|
||||||
|
EventReceiversList draginterested;
|
||||||
EventReceiversList timeinterested;
|
EventReceiversList timeinterested;
|
||||||
EventReceiversList wheelInterested;
|
EventReceiversList wheelInterested;
|
||||||
EventReceiversList doubleClickInterested;
|
EventReceiversList doubleClickInterested;
|
||||||
@ -59,7 +60,9 @@ public:
|
|||||||
void dispatchMouseLeftButtonReleased(const Point & position);
|
void dispatchMouseLeftButtonReleased(const Point & position);
|
||||||
void dispatchMouseScrolled(const Point & distance, const Point & position);
|
void dispatchMouseScrolled(const Point & distance, const Point & position);
|
||||||
void dispatchMouseDoubleClick(const Point & position);
|
void dispatchMouseDoubleClick(const Point & position);
|
||||||
void dispatchMouseMoved(const Point & distance);
|
void dispatchMouseMoved(const Point & distance, const Point & position);
|
||||||
|
|
||||||
|
void dispatchMouseDragged(const Point & currentPosition, const Point & lastUpdateDistance);
|
||||||
|
|
||||||
void dispatchShowPopup(const Point & position);
|
void dispatchShowPopup(const Point & position);
|
||||||
void dispatchClosePopup(const Point & position);
|
void dispatchClosePopup(const Point & position);
|
||||||
|
@ -45,7 +45,8 @@ protected:
|
|||||||
virtual void gesturePinch(const Point & centerPosition, double lastUpdateFactor) {}
|
virtual void gesturePinch(const Point & centerPosition, double lastUpdateFactor) {}
|
||||||
|
|
||||||
virtual void wheelScrolled(int distance) {}
|
virtual void wheelScrolled(int distance) {}
|
||||||
virtual void mouseMoved(const Point & cursorPosition) {}
|
virtual void mouseMoved(const Point & cursorPosition, const Point & lastUpdateDistance) {}
|
||||||
|
virtual void mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance) {}
|
||||||
|
|
||||||
/// Called when UI element hover status changes
|
/// Called when UI element hover status changes
|
||||||
virtual void hover(bool on) {}
|
virtual void hover(bool on) {}
|
||||||
@ -84,6 +85,7 @@ public:
|
|||||||
DOUBLECLICK = 256,
|
DOUBLECLICK = 256,
|
||||||
TEXTINPUT = 512,
|
TEXTINPUT = 512,
|
||||||
GESTURE = 1024,
|
GESTURE = 1024,
|
||||||
|
DRAG = 2048,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Returns true if element is currently hovered by mouse
|
/// Returns true if element is currently hovered by mouse
|
||||||
|
@ -453,7 +453,7 @@ std::shared_ptr<CSlider> InterfaceObjectConfigurable::buildSlider(const JsonNode
|
|||||||
auto value = config["selected"].Integer();
|
auto value = config["selected"].Integer();
|
||||||
bool horizontal = config["orientation"].String() == "horizontal";
|
bool horizontal = config["orientation"].String() == "horizontal";
|
||||||
const auto & result =
|
const auto & result =
|
||||||
std::make_shared<CSlider>(position, length, callbacks.at(config["callback"].String()), itemsVisible, itemsTotal, value, horizontal, style);
|
std::make_shared<CSlider>(position, length, callbacks.at(config["callback"].String()), itemsVisible, itemsTotal, value, horizontal ? Orientation::HORIZONTAL : Orientation::VERTICAL, style);
|
||||||
|
|
||||||
if (!config["scrollBounds"].isNull())
|
if (!config["scrollBounds"].isNull())
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@ OptionsTab::OptionsTab() : humanPlayers(0)
|
|||||||
labelStartingBonus = std::make_shared<CMultiLineLabel>(Rect(315, 86, 70, (int)graphics->fonts[EFonts::FONT_SMALL]->getLineHeight()*2), EFonts::FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[520]);
|
labelStartingBonus = std::make_shared<CMultiLineLabel>(Rect(315, 86, 70, (int)graphics->fonts[EFonts::FONT_SMALL]->getLineHeight()*2), EFonts::FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[520]);
|
||||||
if(SEL->screenType == ESelectionScreen::newGame || SEL->screenType == ESelectionScreen::loadGame || SEL->screenType == ESelectionScreen::scenarioInfo)
|
if(SEL->screenType == ESelectionScreen::newGame || SEL->screenType == ESelectionScreen::loadGame || SEL->screenType == ESelectionScreen::scenarioInfo)
|
||||||
{
|
{
|
||||||
sliderTurnDuration = std::make_shared<CSlider>(Point(55, 551), 194, std::bind(&IServerAPI::setTurnLength, CSH, _1), 1, (int)GameConstants::POSSIBLE_TURNTIME.size(), (int)GameConstants::POSSIBLE_TURNTIME.size(), true, CSlider::BLUE);
|
sliderTurnDuration = std::make_shared<CSlider>(Point(55, 551), 194, std::bind(&IServerAPI::setTurnLength, CSH, _1), 1, (int)GameConstants::POSSIBLE_TURNTIME.size(), (int)GameConstants::POSSIBLE_TURNTIME.size(), Orientation::HORIZONTAL, CSlider::BLUE);
|
||||||
sliderTurnDuration->setScrollBounds(Rect(-3, -25, 337, 43));
|
sliderTurnDuration->setScrollBounds(Rect(-3, -25, 337, 43));
|
||||||
sliderTurnDuration->setPanningStep(20);
|
sliderTurnDuration->setPanningStep(20);
|
||||||
labelPlayerTurnDuration = std::make_shared<CLabel>(222, 538, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[521]);
|
labelPlayerTurnDuration = std::make_shared<CLabel>(222, 538, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[521]);
|
||||||
|
@ -448,6 +448,11 @@ TemplatesDropBox::TemplatesDropBox(RandomMapTab & randomMapTab, int3 size):
|
|||||||
w->setAmount(curItems.size());
|
w->setAmount(curItems.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FIXME: this should be done by InterfaceObjectConfigurable, but might have side-effects
|
||||||
|
pos = children.front()->pos;
|
||||||
|
for (auto const & child : children)
|
||||||
|
pos = pos.include(child->pos);
|
||||||
|
|
||||||
updateListItems();
|
updateListItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,17 +474,11 @@ void TemplatesDropBox::sliderMove(int slidPos)
|
|||||||
|
|
||||||
void TemplatesDropBox::clickLeft(tribool down, bool previousState)
|
void TemplatesDropBox::clickLeft(tribool down, bool previousState)
|
||||||
{
|
{
|
||||||
if(down && !isActive())
|
if (!pos.isInside(GH.getCursorPosition()))
|
||||||
{
|
|
||||||
auto w = widget<CSlider>("slider");
|
|
||||||
|
|
||||||
// pop the interface only if the mouse is not clicking on the slider
|
|
||||||
if (!w || !w->isMouseLeftButtonPressed())
|
|
||||||
{
|
{
|
||||||
assert(GH.windows().isTopWindow(this));
|
assert(GH.windows().isTopWindow(this));
|
||||||
GH.windows().popWindows(1);
|
GH.windows().popWindows(1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TemplatesDropBox::updateListItems()
|
void TemplatesDropBox::updateListItems()
|
||||||
|
@ -205,8 +205,12 @@ SelectionTab::SelectionTab(ESelectionScreen Type)
|
|||||||
listItems.push_back(std::make_shared<ListItem>(Point(30, 129 + i * 25), iconsMapFormats, iconsVictoryCondition, iconsLossCondition));
|
listItems.push_back(std::make_shared<ListItem>(Point(30, 129 + i * 25), iconsMapFormats, iconsVictoryCondition, iconsLossCondition));
|
||||||
|
|
||||||
labelTabTitle = std::make_shared<CLabel>(205, 28, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, tabTitle);
|
labelTabTitle = std::make_shared<CLabel>(205, 28, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, tabTitle);
|
||||||
slider = std::make_shared<CSlider>(Point(372, 86), tabType != ESelectionScreen::saveGame ? 480 : 430, std::bind(&SelectionTab::sliderMove, this, _1), positionsToShow, (int)curItems.size(), 0, false, CSlider::BLUE);
|
slider = std::make_shared<CSlider>(Point(372, 86), tabType != ESelectionScreen::saveGame ? 480 : 430, std::bind(&SelectionTab::sliderMove, this, _1), positionsToShow, (int)curItems.size(), 0, Orientation::VERTICAL, CSlider::BLUE);
|
||||||
slider->setPanningStep(24);
|
slider->setPanningStep(24);
|
||||||
|
|
||||||
|
// create scroll bounds that encompass all area in this UI element to the left of slider (including area of slider itself)
|
||||||
|
// entire screen can't be used in here since map description might also have slider
|
||||||
|
slider->setScrollBounds(Rect(pos.x - slider->pos.x, 0, slider->pos.x + slider->pos.w - pos.x, slider->pos.h ));
|
||||||
filter(0);
|
filter(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ void MapViewActions::showPopupWindow()
|
|||||||
adventureInt->onTileRightClicked(tile);
|
adventureInt->onTileRightClicked(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapViewActions::mouseMoved(const Point & cursorPosition)
|
void MapViewActions::mouseMoved(const Point & cursorPosition, const Point & lastUpdateDistance)
|
||||||
{
|
{
|
||||||
handleHover(cursorPosition);
|
handleHover(cursorPosition);
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,6 @@ public:
|
|||||||
void gesturePinch(const Point & centerPosition, double lastUpdateFactor) override;
|
void gesturePinch(const Point & centerPosition, double lastUpdateFactor) override;
|
||||||
void hover(bool on) override;
|
void hover(bool on) override;
|
||||||
void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
|
void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
|
||||||
void mouseMoved(const Point & cursorPosition) override;
|
void mouseMoved(const Point & cursorPosition, const Point & lastUpdateDistance) override;
|
||||||
void wheelScrolled(int distance) override;
|
void wheelScrolled(int distance) override;
|
||||||
};
|
};
|
||||||
|
@ -92,8 +92,16 @@ CListBox::CListBox(CreateFunc create, Point Pos, Point ItemOffset, size_t Visibl
|
|||||||
if(Slider & 1)
|
if(Slider & 1)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
slider = std::make_shared<CSlider>(SliderPos.topLeft(), SliderPos.w, std::bind(&CListBox::moveToPos, this, _1),
|
slider = std::make_shared<CSlider>(
|
||||||
(int)VisibleSize, (int)TotalSize, (int)InitialPos, Slider & 2, Slider & 4 ? CSlider::BLUE : CSlider::BROWN);
|
SliderPos.topLeft(),
|
||||||
|
SliderPos.w,
|
||||||
|
std::bind(&CListBox::moveToPos, this, _1),
|
||||||
|
(int)VisibleSize,
|
||||||
|
(int)TotalSize,
|
||||||
|
(int)InitialPos,
|
||||||
|
Slider & 2 ? Orientation::HORIZONTAL : Orientation::VERTICAL,
|
||||||
|
Slider & 4 ? CSlider::BLUE : CSlider::BROWN
|
||||||
|
);
|
||||||
|
|
||||||
slider->setPanningStep(itemOffset.x + itemOffset.y);
|
slider->setPanningStep(itemOffset.x + itemOffset.y);
|
||||||
}
|
}
|
||||||
|
@ -18,26 +18,17 @@
|
|||||||
#include "../gui/CGuiHandler.h"
|
#include "../gui/CGuiHandler.h"
|
||||||
#include "../render/Canvas.h"
|
#include "../render/Canvas.h"
|
||||||
|
|
||||||
void CSlider::sliderClicked()
|
void CSlider::mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance)
|
||||||
{
|
|
||||||
addUsedEvents(MOVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSlider::mouseMoved (const Point & cursorPosition)
|
|
||||||
{
|
{
|
||||||
double v = 0;
|
double v = 0;
|
||||||
if(getOrientation() == Orientation::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;
|
|
||||||
v = cursorPosition.x - pos.x - 24;
|
v = cursorPosition.x - pos.x - 24;
|
||||||
v *= positions;
|
v *= positions;
|
||||||
v /= (pos.w - 48);
|
v /= (pos.w - 48);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(std::abs(cursorPosition.x-(pos.x+pos.w/2)) > pos.w/2+40 || std::abs(cursorPosition.y-(pos.y+pos.h/2)) > pos.h/2 )
|
|
||||||
return;
|
|
||||||
v = cursorPosition.y - pos.y - 24;
|
v = cursorPosition.y - pos.y - 24;
|
||||||
v *= positions;
|
v *= positions;
|
||||||
v /= (pos.h - 48);
|
v /= (pos.h - 48);
|
||||||
@ -49,6 +40,14 @@ void CSlider::mouseMoved (const Point & cursorPosition)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSlider::gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance)
|
||||||
|
{
|
||||||
|
if (getOrientation() == Orientation::VERTICAL)
|
||||||
|
Scrollable::gesturePanning(initialPosition, currentPosition, lastUpdateDistance);
|
||||||
|
else
|
||||||
|
mouseDragged(currentPosition, lastUpdateDistance);
|
||||||
|
}
|
||||||
|
|
||||||
void CSlider::setScrollBounds(const Rect & bounds )
|
void CSlider::setScrollBounds(const Rect & bounds )
|
||||||
{
|
{
|
||||||
scrollBounds = bounds;
|
scrollBounds = bounds;
|
||||||
@ -138,20 +137,16 @@ void CSlider::clickLeft(tribool down, bool previousState)
|
|||||||
pw = GH.getCursorPosition().y-pos.y-24;
|
pw = GH.getCursorPosition().y-pos.y-24;
|
||||||
rw = pw / (pos.h-48);
|
rw = pw / (pos.h-48);
|
||||||
}
|
}
|
||||||
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->isMouseLeftButtonPressed());
|
slider->clickLeft(true, slider->isMouseLeftButtonPressed());
|
||||||
scrollTo((int)(rw * positions + 0.5));
|
scrollTo((int)(rw * positions + 0.5));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
removeUsedEvents(MOVE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSlider::receiveEvent(const Point &position, int eventType) const
|
bool CSlider::receiveEvent(const Point &position, int eventType) const
|
||||||
{
|
{
|
||||||
if (eventType != WHEEL && eventType != GESTURE)
|
if(eventType != WHEEL && eventType != GESTURE)
|
||||||
{
|
{
|
||||||
return CIntObject::receiveEvent(position, eventType);
|
return CIntObject::receiveEvent(position, eventType);
|
||||||
}
|
}
|
||||||
@ -164,8 +159,8 @@ bool CSlider::receiveEvent(const Point &position, int eventType) const
|
|||||||
return testTarget.isInside(position);
|
return testTarget.isInside(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSlider::CSlider(Point position, int totalw, std::function<void(int)> Moved, int Capacity, int Amount, int Value, bool Horizontal, CSlider::EStyle style)
|
CSlider::CSlider(Point position, int totalw, std::function<void(int)> Moved, int Capacity, int Amount, int Value, Orientation orientation, CSlider::EStyle style)
|
||||||
: Scrollable(LCLICK, position, Horizontal ? Orientation::HORIZONTAL : Orientation::VERTICAL ),
|
: Scrollable(LCLICK | DRAG, position, orientation ),
|
||||||
capacity(Capacity),
|
capacity(Capacity),
|
||||||
amount(Amount),
|
amount(Amount),
|
||||||
value(Value),
|
value(Value),
|
||||||
@ -207,7 +202,6 @@ CSlider::CSlider(Point position, int totalw, std::function<void(int)> Moved, int
|
|||||||
|
|
||||||
left->addCallback(std::bind(&CSlider::scrollPrev,this));
|
left->addCallback(std::bind(&CSlider::scrollPrev,this));
|
||||||
right->addCallback(std::bind(&CSlider::scrollNext,this));
|
right->addCallback(std::bind(&CSlider::scrollNext,this));
|
||||||
slider->addCallback(std::bind(&CSlider::sliderClicked,this));
|
|
||||||
|
|
||||||
if(getOrientation() == Orientation::HORIZONTAL)
|
if(getOrientation() == Orientation::HORIZONTAL)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,6 @@ class CSlider : public Scrollable
|
|||||||
CFunctionList<void(int)> moved;
|
CFunctionList<void(int)> moved;
|
||||||
|
|
||||||
void updateSliderPos();
|
void updateSliderPos();
|
||||||
void sliderClicked();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum EStyle
|
enum EStyle
|
||||||
@ -71,7 +70,8 @@ public:
|
|||||||
bool receiveEvent(const Point & position, int eventType) const override;
|
bool receiveEvent(const Point & position, int eventType) const override;
|
||||||
void keyPressed(EShortcut key) override;
|
void keyPressed(EShortcut key) override;
|
||||||
void clickLeft(tribool down, bool previousState) override;
|
void clickLeft(tribool down, bool previousState) override;
|
||||||
void mouseMoved (const Point & cursorPosition) override;
|
void mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance) override;
|
||||||
|
void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) override;
|
||||||
void showAll(Canvas & to) override;
|
void showAll(Canvas & to) override;
|
||||||
|
|
||||||
/// @param position coordinates of slider
|
/// @param position coordinates of slider
|
||||||
@ -81,6 +81,6 @@ public:
|
|||||||
/// @param Amount total amount of elements, including not visible
|
/// @param Amount total amount of elements, including not visible
|
||||||
/// @param Value starting position
|
/// @param Value starting position
|
||||||
CSlider(Point position, int length, std::function<void(int)> Moved, int Capacity, int Amount,
|
CSlider(Point position, int length, std::function<void(int)> Moved, int Capacity, int Amount,
|
||||||
int Value=0, bool Horizontal=true, EStyle style = BROWN);
|
int Value, Orientation orientation, EStyle style = BROWN);
|
||||||
~CSlider();
|
~CSlider();
|
||||||
};
|
};
|
||||||
|
@ -349,8 +349,10 @@ void CTextBox::setText(const std::string & text)
|
|||||||
|
|
||||||
OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255 - DISPOSE);
|
OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255 - DISPOSE);
|
||||||
slider = std::make_shared<CSlider>(Point(pos.w - 32, 0), pos.h, std::bind(&CTextBox::sliderMoved, this, _1),
|
slider = std::make_shared<CSlider>(Point(pos.w - 32, 0), pos.h, std::bind(&CTextBox::sliderMoved, this, _1),
|
||||||
label->pos.h, label->textSize.y, 0, false, CSlider::EStyle(sliderStyle));
|
label->pos.h, label->textSize.y, 0, Orientation::VERTICAL, CSlider::EStyle(sliderStyle));
|
||||||
slider->setScrollStep((int)graphics->fonts[label->font]->getLineHeight());
|
slider->setScrollStep((int)graphics->fonts[label->font]->getLineHeight());
|
||||||
|
slider->setPanningStep(1);
|
||||||
|
slider->setScrollBounds(pos - slider->pos.topLeft());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ CBuildingRect::CBuildingRect(CCastleBuildings * Par, const CGTownInstance * Town
|
|||||||
area(nullptr),
|
area(nullptr),
|
||||||
stateTimeCounter(BUILD_ANIMATION_FINISHED_TIMEPOINT)
|
stateTimeCounter(BUILD_ANIMATION_FINISHED_TIMEPOINT)
|
||||||
{
|
{
|
||||||
addUsedEvents(LCLICK | SHOW_POPUP | HOVER | TIME);
|
addUsedEvents(LCLICK | SHOW_POPUP | MOVE | HOVER | TIME);
|
||||||
pos.x += str->pos.x;
|
pos.x += str->pos.x;
|
||||||
pos.y += str->pos.y;
|
pos.y += str->pos.y;
|
||||||
|
|
||||||
@ -108,19 +108,24 @@ const CBuilding * CBuildingRect::getBuilding()
|
|||||||
bool CBuildingRect::operator<(const CBuildingRect & p2) const
|
bool CBuildingRect::operator<(const CBuildingRect & p2) const
|
||||||
{
|
{
|
||||||
return (str->pos.z) < (p2.str->pos.z);
|
return (str->pos.z) < (p2.str->pos.z);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBuildingRect::hover(bool on)
|
void CBuildingRect::hover(bool on)
|
||||||
{
|
{
|
||||||
|
if (!area)
|
||||||
|
return;
|
||||||
|
|
||||||
if(on)
|
if(on)
|
||||||
{
|
{
|
||||||
addUsedEvents(MOVE);
|
if(! parent->selectedBuilding //no building hovered
|
||||||
|
|| (*parent->selectedBuilding)<(*this)) //or we are on top
|
||||||
|
{
|
||||||
|
parent->selectedBuilding = this;
|
||||||
|
GH.statusbar()->write(getSubtitle());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
removeUsedEvents(MOVE);
|
|
||||||
|
|
||||||
if(parent->selectedBuilding == this)
|
if(parent->selectedBuilding == this)
|
||||||
{
|
{
|
||||||
parent->selectedBuilding = nullptr;
|
parent->selectedBuilding = nullptr;
|
||||||
@ -132,21 +137,17 @@ void CBuildingRect::hover(bool on)
|
|||||||
void CBuildingRect::clickLeft(tribool down, bool previousState)
|
void CBuildingRect::clickLeft(tribool down, bool previousState)
|
||||||
{
|
{
|
||||||
if(previousState && getBuilding() && area && !down && (parent->selectedBuilding==this))
|
if(previousState && getBuilding() && area && !down && (parent->selectedBuilding==this))
|
||||||
{
|
|
||||||
if(!area->isTransparent(GH.getCursorPosition() - pos.topLeft())) //inside building image
|
|
||||||
{
|
{
|
||||||
auto building = getBuilding();
|
auto building = getBuilding();
|
||||||
parent->buildingClicked(building->bid, building->subId, building->upgrade);
|
parent->buildingClicked(building->bid, building->subId, building->upgrade);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBuildingRect::showPopupWindow()
|
void CBuildingRect::showPopupWindow()
|
||||||
{
|
{
|
||||||
if((!area) || (this!=parent->selectedBuilding) || getBuilding() == nullptr)
|
if((!area) || (this!=parent->selectedBuilding) || getBuilding() == nullptr)
|
||||||
return;
|
return;
|
||||||
if( !area->isTransparent(GH.getCursorPosition() - pos.topLeft()) ) //inside building image
|
|
||||||
{
|
|
||||||
BuildingID bid = getBuilding()->bid;
|
BuildingID bid = getBuilding()->bid;
|
||||||
const CBuilding *bld = town->town->buildings.at(bid);
|
const CBuilding *bld = town->town->buildings.at(bid);
|
||||||
if (bid < BuildingID::DWELL_FIRST)
|
if (bid < BuildingID::DWELL_FIRST)
|
||||||
@ -159,7 +160,6 @@ void CBuildingRect::showPopupWindow()
|
|||||||
int level = ( bid - BuildingID::DWELL_FIRST ) % GameConstants::CREATURES_PER_TOWN;
|
int level = ( bid - BuildingID::DWELL_FIRST ) % GameConstants::CREATURES_PER_TOWN;
|
||||||
GH.windows().createAndPushWindow<CDwellingInfoBox>(parent->pos.x+parent->pos.w / 2, parent->pos.y+parent->pos.h /2, town, level);
|
GH.windows().createAndPushWindow<CDwellingInfoBox>(parent->pos.x+parent->pos.w / 2, parent->pos.y+parent->pos.h /2, town, level);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBuildingRect::show(Canvas & to)
|
void CBuildingRect::show(Canvas & to)
|
||||||
@ -245,28 +245,20 @@ std::string CBuildingRect::getSubtitle()//hover text for building
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBuildingRect::mouseMoved (const Point & cursorPosition)
|
void CBuildingRect::mouseMoved (const Point & cursorPosition, const Point & lastUpdateDistance)
|
||||||
{
|
{
|
||||||
if(area && pos.isInside(cursorPosition.x, cursorPosition.y))
|
hover(true);
|
||||||
{
|
}
|
||||||
if(area->isTransparent(cursorPosition - pos.topLeft())) //hovered pixel is inside this building
|
|
||||||
{
|
bool CBuildingRect::receiveEvent(const Point & position, int eventType) const
|
||||||
if(parent->selectedBuilding == this)
|
{
|
||||||
{
|
if (!pos.isInside(position.x, position.y))
|
||||||
parent->selectedBuilding = nullptr;
|
return false;
|
||||||
GH.statusbar()->clear();
|
|
||||||
}
|
if(area && area->isTransparent(position - pos.topLeft()))
|
||||||
}
|
return false;
|
||||||
else //inside the area of this building
|
|
||||||
{
|
return CIntObject::receiveEvent(position, eventType);
|
||||||
if(! parent->selectedBuilding //no building hovered
|
|
||||||
|| (*parent->selectedBuilding)<(*this)) //or we are on top
|
|
||||||
{
|
|
||||||
parent->selectedBuilding = this;
|
|
||||||
GH.statusbar()->write(getSubtitle());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CDwellingInfoBox::CDwellingInfoBox(int centerX, int centerY, const CGTownInstance * Town, int level)
|
CDwellingInfoBox::CDwellingInfoBox(int centerX, int centerY, const CGTownInstance * Town, int level)
|
||||||
|
@ -68,7 +68,8 @@ public:
|
|||||||
void hover(bool on) override;
|
void hover(bool on) override;
|
||||||
void clickLeft(tribool down, bool previousState) override;
|
void clickLeft(tribool down, bool previousState) override;
|
||||||
void showPopupWindow() override;
|
void showPopupWindow() override;
|
||||||
void mouseMoved (const Point & cursorPosition) override;
|
void mouseMoved (const Point & cursorPosition, const Point & lastUpdateDistance) override;
|
||||||
|
bool receiveEvent(const Point & position, int eventType) const override;
|
||||||
void tick(uint32_t msPassed) override;
|
void tick(uint32_t msPassed) override;
|
||||||
void show(Canvas & to) override;
|
void show(Canvas & to) override;
|
||||||
void showAll(Canvas & to) override;
|
void showAll(Canvas & to) override;
|
||||||
|
@ -134,7 +134,8 @@ CQuestLog::CQuestLog (const std::vector<QuestInfo> & Quests)
|
|||||||
// Both button and lable are shifted to -2px by x and y to not make them actually look like they're on same line with quests list and ok button
|
// Both button and lable are shifted to -2px by x and y to not make them actually look like they're on same line with quests list and ok button
|
||||||
hideCompleteButton = std::make_shared<CToggleButton>(Point(10, 396), "sysopchk.def", CButton::tooltipLocalized("vcmi.questLog.hideComplete"), std::bind(&CQuestLog::toggleComplete, this, _1));
|
hideCompleteButton = std::make_shared<CToggleButton>(Point(10, 396), "sysopchk.def", CButton::tooltipLocalized("vcmi.questLog.hideComplete"), std::bind(&CQuestLog::toggleComplete, this, _1));
|
||||||
hideCompleteLabel = std::make_shared<CLabel>(46, 398, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->translate("vcmi.questLog.hideComplete.hover"));
|
hideCompleteLabel = std::make_shared<CLabel>(46, 398, FONT_MEDIUM, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->translate("vcmi.questLog.hideComplete.hover"));
|
||||||
slider = std::make_shared<CSlider>(Point(166, 195), 191, std::bind(&CQuestLog::sliderMoved, this, _1), QUEST_COUNT, 0, false, CSlider::BROWN);
|
slider = std::make_shared<CSlider>(Point(166, 195), 191, std::bind(&CQuestLog::sliderMoved, this, _1), QUEST_COUNT, 0, 0, Orientation::VERTICAL, CSlider::BROWN);
|
||||||
|
slider->setPanningStep(32);
|
||||||
|
|
||||||
recreateLabelList();
|
recreateLabelList();
|
||||||
recreateQuestList(0);
|
recreateQuestList(0);
|
||||||
|
@ -66,7 +66,7 @@ class CQuestMinimap : public CMinimap
|
|||||||
|
|
||||||
void clickLeft(tribool down, bool previousState) override{}; //minimap ignores clicking on its surface
|
void clickLeft(tribool down, bool previousState) override{}; //minimap ignores clicking on its surface
|
||||||
void iconClicked();
|
void iconClicked();
|
||||||
void mouseMoved (const Point & cursorPosition) override{};
|
void mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance) override{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const QuestInfo * currentQuest;
|
const QuestInfo * currentQuest;
|
||||||
|
@ -716,7 +716,7 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket * Market, const CGHeroInsta
|
|||||||
|
|
||||||
if(sliderNeeded)
|
if(sliderNeeded)
|
||||||
{
|
{
|
||||||
slider = std::make_shared<CSlider>(Point(231, 490),137, std::bind(&CMarketplaceWindow::sliderMoved,this,_1),0,0);
|
slider = std::make_shared<CSlider>(Point(231, 490), 137, std::bind(&CMarketplaceWindow::sliderMoved, this, _1), 0, 0, 0, Orientation::HORIZONTAL);
|
||||||
max = std::make_shared<CButton>(Point(229, 520), "IRCBTNS.DEF", CGI->generaltexth->zelp[596], [&](){ setMax(); });
|
max = std::make_shared<CButton>(Point(229, 520), "IRCBTNS.DEF", CGI->generaltexth->zelp[596], [&](){ setMax(); });
|
||||||
max->block(true);
|
max->block(true);
|
||||||
}
|
}
|
||||||
@ -1117,7 +1117,7 @@ CAltarWindow::CAltarWindow(const IMarket * Market, const CGHeroInstance * Hero,
|
|||||||
//To sacrifice creatures, move them from your army on to the Altar and click Sacrifice
|
//To sacrifice creatures, move them from your army on to the Altar and click Sacrifice
|
||||||
new CTextBox(CGI->generaltexth->allTexts[480], Rect(320, 56, 256, 40), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::YELLOW);
|
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);
|
slider = std::make_shared<CSlider>(Point(231, 481), 137, std::bind(&CAltarWindow::sliderMoved, this, _1), 0, 0, 0, Orientation::HORIZONTAL);
|
||||||
max = std::make_shared<CButton>(Point(147, 520), "IRCBTNS.DEF", CGI->generaltexth->zelp[578], std::bind(&CSlider::scrollToMax, 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);
|
sacrificedUnits.resize(GameConstants::ARMY_SIZE, 0);
|
||||||
|
@ -75,7 +75,7 @@ void CreaturePurchaseCard::updateAmountInfo(int value)
|
|||||||
|
|
||||||
void CreaturePurchaseCard::initSlider()
|
void CreaturePurchaseCard::initSlider()
|
||||||
{
|
{
|
||||||
slider = std::make_shared<CSlider>(Point(pos.x, pos.y + 158), 102, std::bind(&CreaturePurchaseCard::sliderMoved, this , _1), 0, maxAmount, 0);
|
slider = std::make_shared<CSlider>(Point(pos.x, pos.y + 158), 102, std::bind(&CreaturePurchaseCard::sliderMoved, this, _1), 0, maxAmount, 0, Orientation::HORIZONTAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreaturePurchaseCard::initCostBox()
|
void CreaturePurchaseCard::initCostBox()
|
||||||
|
@ -215,7 +215,7 @@ CRecruitmentWindow::CRecruitmentWindow(const CGDwelling * Dwelling, int Level, c
|
|||||||
|
|
||||||
statusbar = CGStatusBar::create(std::make_shared<CPicture>(background->getSurface(), Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
|
statusbar = CGStatusBar::create(std::make_shared<CPicture>(background->getSurface(), Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
|
||||||
|
|
||||||
slider = std::make_shared<CSlider>(Point(176,279),135,std::bind(&CRecruitmentWindow::sliderMoved,this, _1),0,0,0,true);
|
slider = std::make_shared<CSlider>(Point(176, 279), 135, std::bind(&CRecruitmentWindow::sliderMoved, this, _1), 0, 0, 0, Orientation::HORIZONTAL);
|
||||||
|
|
||||||
maxButton = std::make_shared<CButton>(Point(134, 313), "IRCBTNS.DEF", CGI->generaltexth->zelp[553], std::bind(&CSlider::scrollToMax, 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);
|
buyButton = std::make_shared<CButton>(Point(212, 313), "IBY6432.DEF", CGI->generaltexth->zelp[554], std::bind(&CRecruitmentWindow::buy, this), EShortcut::GLOBAL_ACCEPT);
|
||||||
@ -338,7 +338,7 @@ CSplitWindow::CSplitWindow(const CCreature * creature, std::function<void(int, i
|
|||||||
animLeft = std::make_shared<CCreaturePic>(20, 54, creature, true, false);
|
animLeft = std::make_shared<CCreaturePic>(20, 54, creature, true, false);
|
||||||
animRight = std::make_shared<CCreaturePic>(177, 54,creature, true, false);
|
animRight = std::make_shared<CCreaturePic>(177, 54,creature, true, false);
|
||||||
|
|
||||||
slider = std::make_shared<CSlider>(Point(21, 194), 257, std::bind(&CSplitWindow::sliderMoved, this, _1), 0, sliderPosition, rightAmount - rightMin, true);
|
slider = std::make_shared<CSlider>(Point(21, 194), 257, std::bind(&CSplitWindow::sliderMoved, this, _1), 0, sliderPosition, rightAmount - rightMin, Orientation::HORIZONTAL);
|
||||||
|
|
||||||
std::string titleStr = CGI->generaltexth->allTexts[256];
|
std::string titleStr = CGI->generaltexth->allTexts[256];
|
||||||
boost::algorithm::replace_first(titleStr,"%s", creature->getNamePluralTranslated());
|
boost::algorithm::replace_first(titleStr,"%s", creature->getNamePluralTranslated());
|
||||||
|
@ -109,6 +109,11 @@ public:
|
|||||||
return Rect(x+p.x,y+p.y,w,h);
|
return Rect(x+p.x,y+p.y,w,h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rect operator-(const Point &p) const
|
||||||
|
{
|
||||||
|
return Rect(x-p.x,y-p.y,w,h);
|
||||||
|
}
|
||||||
|
|
||||||
Rect& operator=(const Rect &p)
|
Rect& operator=(const Rect &p)
|
||||||
{
|
{
|
||||||
x = p.x;
|
x = p.x;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user