mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
Fix credits scrolling
This commit is contained in:
@@ -22,13 +22,15 @@
|
||||
#include "../../AUTHORS.h"
|
||||
|
||||
CreditsScreen::CreditsScreen(Rect rect)
|
||||
: CIntObject(LCLICK), positionCounter(0)
|
||||
: CIntObject(LCLICK), timePassed(0)
|
||||
{
|
||||
pos.w = rect.w;
|
||||
pos.h = rect.h;
|
||||
setRedrawParent(true);
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
||||
|
||||
addUsedEvents(TIME);
|
||||
|
||||
std::string contributorsText = "";
|
||||
std::string contributorsTask = "";
|
||||
for (auto & element : contributors)
|
||||
@@ -48,15 +50,15 @@ CreditsScreen::CreditsScreen(Rect rect)
|
||||
credits->scrollTextTo(-600); // move all text below the screen
|
||||
}
|
||||
|
||||
void CreditsScreen::show(Canvas & to)
|
||||
void CreditsScreen::tick(uint32_t msPassed)
|
||||
{
|
||||
CIntObject::show(to);
|
||||
positionCounter++;
|
||||
if(positionCounter % 2 == 0)
|
||||
credits->scrollTextBy(1);
|
||||
static const int timeToScrollByOnePx = 20;
|
||||
timePassed += msPassed;
|
||||
int scrollPosition = timePassed / timeToScrollByOnePx - 600;
|
||||
credits->scrollTextTo(scrollPosition);
|
||||
|
||||
//end of credits, close this screen
|
||||
if(credits->textSize.y + 600 < positionCounter / 2)
|
||||
if(credits->textSize.y < scrollPosition)
|
||||
clickPressed(GH.getCursorPosition());
|
||||
}
|
||||
|
||||
|
@@ -15,11 +15,11 @@ class CMultiLineLabel;
|
||||
|
||||
class CreditsScreen : public CIntObject
|
||||
{
|
||||
int positionCounter;
|
||||
int timePassed;
|
||||
std::shared_ptr<CMultiLineLabel> credits;
|
||||
|
||||
public:
|
||||
CreditsScreen(Rect rect);
|
||||
void show(Canvas & to) override;
|
||||
void tick(uint32_t msPassed) override;
|
||||
void clickPressed(const Point & cursorPosition) override;
|
||||
};
|
||||
|
Reference in New Issue
Block a user