Remove remaining dependence on tick rate

Similar to ce2f36c0a9, except this fixes up all code that assumed that dt was always 1, which is even funnier.
This commit is contained in:
Tamás Bálint Misius
2025-01-31 15:55:40 +01:00
parent d1c0680a54
commit b131567345
18 changed files with 182 additions and 181 deletions

View File

@@ -238,9 +238,12 @@ void ElementSearchActivity::OnTick()
if (isToolTipFadingIn) if (isToolTipFadingIn)
{ {
isToolTipFadingIn = false; isToolTipFadingIn = false;
toolTipPresence.MarkGoingUpwardThisTick(); toolTipPresence.SetTarget(120);
}
else
{
toolTipPresence.SetTarget(0);
} }
toolTipPresence.Tick();
} }
void ElementSearchActivity::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) void ElementSearchActivity::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)

View File

@@ -24,7 +24,7 @@ class ElementSearchActivity: public WindowActivity
std::vector<ToolButton*> toolButtons; std::vector<ToolButton*> toolButtons;
ui::ScrollPanel *scrollPanel = nullptr; ui::ScrollPanel *scrollPanel = nullptr;
String toolTip; String toolTip;
ui::Fade toolTipPresence{ 0, 0, 120, 120, 60, 1000 }; ui::Fade toolTipPresence{ ui::Fade::LinearProfile{ 120.f, 60.f }, 0, 0 };
bool shiftPressed; bool shiftPressed;
bool ctrlPressed; bool ctrlPressed;
bool altPressed; bool altPressed;

View File

@@ -1782,20 +1782,24 @@ void GameView::OnTick()
} }
} }
introText.Tick();
infoTipPresence.Tick();
if (isButtonTipFadingIn || (selectMode != PlaceSave && selectMode != SelectNone)) if (isButtonTipFadingIn || (selectMode != PlaceSave && selectMode != SelectNone))
{ {
isButtonTipFadingIn = false; isButtonTipFadingIn = false;
buttonTipShow.MarkGoingUpwardThisTick(); buttonTipShow.SetTarget(120);
}
else
{
buttonTipShow.SetTarget(0);
} }
buttonTipShow.Tick();
if (isToolTipFadingIn) if (isToolTipFadingIn)
{ {
isToolTipFadingIn = false; isToolTipFadingIn = false;
toolTipPresence.MarkGoingUpwardThisTick(); toolTipPresence.SetTarget(120);
}
else
{
toolTipPresence.SetTarget(0);
} }
toolTipPresence.Tick();
} }
void GameView::OnSimTick() void GameView::OnSimTick()

View File

@@ -66,16 +66,16 @@ private:
int currentSaveType; int currentSaveType;
int lastMenu; int lastMenu;
ui::Fade toolTipPresence{ 0, 0, 120, 120, 60, 1000 }; ui::Fade toolTipPresence{ ui::Fade::LinearProfile{ 120.f, 60.f }, 0, 0 };
String toolTip; String toolTip;
bool isToolTipFadingIn; bool isToolTipFadingIn;
ui::Point toolTipPosition; ui::Point toolTipPosition;
ui::Fade infoTipPresence{ 0, 0, 120, 60, 60, 1000 }; ui::Fade infoTipPresence{ ui::Fade::LinearProfile{ 60.f, 60.f }, 0, 0 };
String infoTip; String infoTip;
ui::Fade buttonTipShow{ 0, 0, 120, 120, 60, 1000 }; ui::Fade buttonTipShow{ ui::Fade::LinearProfile{ 120.f, 60.f }, 0, 0 };
String buttonTip; String buttonTip;
bool isButtonTipFadingIn; bool isButtonTipFadingIn;
ui::Fade introText{ 2048, 0, 10000, 60, 60, 1000 }; ui::Fade introText{ ui::Fade::LinearProfile{ 60.f, 60.f }, 0, 2048 };
String introTextMessage; String introTextMessage;
bool doScreenshot; bool doScreenshot;

View File

@@ -1,54 +1,62 @@
#include "Fade.h" #include "Fade.h"
#include "Engine.h" #include "Engine.h"
#include <algorithm>
namespace ui namespace ui
{ {
constexpr int64_t bias = 1000; void Fade::SetTarget(float newTarget)
void Fade::SetRange(int newMinValue, int newMaxValue)
{ {
minValueBiased = int64_t(newMinValue) * bias; if (target == newTarget)
maxValueBiased = int64_t(newMaxValue) * bias;
SetValue(newMinValue);
}
void Fade::SetRateOfChange(int changeUpward, int changeDownward, int ticks)
{
changeUpwardBiased = changeUpward * bias / ticks;
changeDownwardBiased = changeDownward * bias / ticks;
}
void Fade::MarkGoingUpwardThisTick()
{
goingUpwardThisTick = true;
}
void Fade::Tick()
{
auto nextGoingUpward = goingUpwardThisTick;
goingUpwardThisTick = false;
if (goingUpward != nextGoingUpward)
{ {
SetValue(GetValue()); return;
goingUpward = nextGoingUpward;
} }
auto value = GetValue();
target = newTarget;
SetValue(value);
} }
void Fade::SetValue(int newValue) void Fade::SetProfile(Profile newProfile)
{ {
uint64_t now = Engine::Ref().LastTick(); profile = newProfile;
referenceValueBiased = newValue * bias;
referenceTime = now;
} }
int Fade::GetValue() const void Fade::SetValue(float newValue)
{ {
uint64_t now = Engine::Ref().LastTick(); referenceTick = int64_t(Engine::Ref().LastTick());
auto minValueNow = goingUpward ? referenceValueBiased : minValueBiased; referenceValue = newValue;
auto maxValueNow = goingUpward ? maxValueBiased : referenceValueBiased; }
auto changeNow = goingUpward ? changeUpwardBiased : changeDownwardBiased;
auto diff = std::min(int64_t(now - referenceTime), (maxValueNow - minValueNow) / changeNow); float Fade::GetValue() const
return int(goingUpward ? (minValueNow + changeNow * diff) : (maxValueNow - changeNow * diff)) / bias; {
constexpr auto tickBias = 1000.f;
auto nowTick = int64_t(Engine::Ref().LastTick());
auto diffTick = nowTick - referenceTick;
if (auto *linearProfile = std::get_if<LinearProfile>(&profile))
{
auto change = linearProfile->change;
if (target < referenceValue)
{
if (linearProfile->changeDownward.has_value())
{
change = *linearProfile->changeDownward;
}
change = -change;
}
auto maxDiffTick = int64_t((target - referenceValue) / change * tickBias);
if (diffTick >= maxDiffTick)
{
return target;
}
return referenceValue + diffTick * change / tickBias;
}
if (auto *exponentialProfile = std::get_if<ExponentialProfile>(&profile))
{
auto maxDiffTick = int64_t(std::log(exponentialProfile->margin / std::abs(referenceValue - target)) / std::log(exponentialProfile->decay) * tickBias);
if (diffTick >= maxDiffTick)
{
return target;
}
return target + (referenceValue - target) * std::pow(exponentialProfile->decay, diffTick / tickBias);
}
return 0.f;
} }
} }

View File

@@ -1,43 +1,65 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include <variant>
#include <optional>
namespace ui namespace ui
{ {
class Fade class Fade
{ {
public: public:
int64_t minValueBiased; // real value * 1000 struct LinearProfile
int64_t maxValueBiased; // real value * 1000
int64_t referenceValueBiased; // real value * 1000
int64_t changeUpwardBiased; // real value * 1000
int64_t changeDownwardBiased; // real value * 1000
bool goingUpwardThisTick = false;
bool goingUpward = false;
uint64_t referenceTime = 0;
Fade(int currentValue, int minValue, int maxValue, int changeUpward, int changeDownward, int ticks)
{ {
SetRange(minValue, maxValue); float change; // per second
SetRateOfChange(changeUpward, changeDownward, ticks); std::optional<float> changeDownward; // per second, ::change is upward change if set
SetValue(currentValue); };
struct ExponentialProfile
{
float decay; // per second
float margin; // unit
};
using Profile = std::variant<
LinearProfile,
ExponentialProfile
>;
private:
float target = 0;
int64_t referenceTick = 0;
float referenceValue = 0;
Profile profile;
public:
Fade(Profile newProfile, float newTarget = 0.f)
{
SetProfile(newProfile);
SetTarget(newTarget);
SetValue(newTarget);
} }
void SetRange(int newMinValue, int newMaxValue); Fade(Profile newProfile, float newTarget, float newValue)
void SetRateOfChange(int changeUpward, int changeDownward, int ticks); {
void MarkGoingUpwardThisTick(); // this is retained until the next Tick call SetProfile(newProfile);
void Tick(); SetTarget(newTarget);
void SetValue(int newValue); SetValue(newValue);
int GetValue() const; }
void SetTarget(float newTarget);
void SetProfile(Profile newProfile);
void SetValue(float newValue);
float GetValue() const;
operator int() const operator int() const
{ {
return GetValue(); return int(GetValue());
} }
Fade &operator =(int newValue) Fade &operator =(int newValue)
{ {
SetValue(newValue); SetValue(float(newValue));
return *this; return *this;
} }
static constexpr ExponentialProfile BasicDimensionProfile{ 1.532496e-06f, 0.5f };
}; };
} }

View File

@@ -76,5 +76,5 @@ void ProgressBar::Draw(const Point &screenPos)
void ProgressBar::Tick() void ProgressBar::Tick()
{ {
intermediatePos = std::fmod(ui::Engine::Ref().LastTick() / 600.f, 100.f); intermediatePos = std::fmod(ui::Engine::Ref().LastTick() * 0.06f, 100.f);
} }

View File

@@ -14,14 +14,13 @@ ScrollPanel::ScrollPanel(Point position, Point size):
maxOffset(0, 0), maxOffset(0, 0),
offsetX(0), offsetX(0),
offsetY(0), offsetY(0),
yScrollVel(0.0f),
xScrollVel(0.0f),
isMouseInsideScrollbar(false), isMouseInsideScrollbar(false),
isMouseInsideScrollbarArea(false), isMouseInsideScrollbarArea(false),
scrollbarSelected(false), scrollbarSelected(false),
scrollbarInitialYOffset(0), scrollbarInitialYOffset(0),
scrollbarInitialYClick(0), scrollbarInitialYClick(0),
scrollbarClickLocation(0) scrollbarClickLocation(0),
scrollLastTick(int64_t(Engine::Ref().LastTick()))
{ {
} }
@@ -45,9 +44,9 @@ void ScrollPanel::XOnMouseWheelInside(int localx, int localy, int d)
if (!d) if (!d)
return; return;
if (ui::Engine::Ref().MomentumScroll) if (ui::Engine::Ref().MomentumScroll)
yScrollVel -= d * 2; yScrollVel.SetValue(yScrollVel.GetValue() - d * 2);
else else
yScrollVel -= d * 20; yScrollVel.SetValue(yScrollVel.GetValue() - d * 20);
} }
void ScrollPanel::Draw(const Point& screenPos) void ScrollPanel::Draw(const Point& screenPos)
@@ -109,7 +108,7 @@ void ScrollPanel::XOnMouseUp(int x, int y, unsigned int button)
{ {
auto offsetYDiff = oldPanHistory.back()->offsetY - (*it)->offsetY; auto offsetYDiff = oldPanHistory.back()->offsetY - (*it)->offsetY;
auto tickDiff = oldPanHistory.back()->ticks - (*it)->ticks; auto tickDiff = oldPanHistory.back()->ticks - (*it)->ticks;
yScrollVel += offsetYDiff / tickDiff * (1000.f / Engine::Ref().GetFps()); yScrollVel.SetValue(yScrollVel.GetValue() + offsetYDiff / tickDiff * (1000.f / Engine::Ref().GetFps()));
} }
} }
isMouseInsideScrollbarArea = false; isMouseInsideScrollbarArea = false;
@@ -198,22 +197,23 @@ void ScrollPanel::XTick()
maxOffset.X = std::max(0, maxOffset.X); maxOffset.X = std::max(0, maxOffset.X);
auto oldOffsetY = int(offsetY); auto oldOffsetY = int(offsetY);
offsetY += yScrollVel;
offsetX += xScrollVel;
if (ui::Engine::Ref().MomentumScroll)
{ {
if (yScrollVel > -0.5f && yScrollVel < 0.5) // the correct way to do this would be to add another profile to ui::Fade that analytically
yScrollVel = 0; // integrates the value of the fade and assign that here; way too much hassle for now though
yScrollVel *= 0.98f; auto now = int64_t(Engine::Ref().LastTick());
auto diff = now - scrollLastTick;
scrollLastTick = now;
offsetY += yScrollVel * diff * 0.06f;
offsetX += xScrollVel * diff * 0.06f;
} }
else
if (!ui::Engine::Ref().MomentumScroll)
{ {
yScrollVel = 0.0f; yScrollVel = 0.0f;
xScrollVel = 0.0f;
} }
xScrollVel*=0.98f;
if (oldOffsetY!=int(offsetY)) if (oldOffsetY!=int(offsetY))
{ {

View File

@@ -1,5 +1,6 @@
#pragma once #pragma once
#include "Panel.h" #include "Panel.h"
#include "Fade.h"
#include <optional> #include <optional>
#include <array> #include <array>
@@ -14,14 +15,15 @@ namespace ui
Point maxOffset; Point maxOffset;
float offsetX; float offsetX;
float offsetY; float offsetY;
float yScrollVel; ui::Fade yScrollVel{ ui::Fade::ExponentialProfile{ 0.297553f, 0.5f }, 0, 0 };
float xScrollVel; ui::Fade xScrollVel{ ui::Fade::ExponentialProfile{ 0.297553f, 0.5f }, 0, 0 };
bool isMouseInsideScrollbar; bool isMouseInsideScrollbar;
bool isMouseInsideScrollbarArea; bool isMouseInsideScrollbarArea;
bool scrollbarSelected; bool scrollbarSelected;
int scrollbarInitialYOffset; int scrollbarInitialYOffset;
int scrollbarInitialYClick; int scrollbarInitialYClick;
int scrollbarClickLocation; int scrollbarClickLocation;
int64_t scrollLastTick;
int initialOffsetY; int initialOffsetY;
bool panning = false; bool panning = false;
static constexpr int PanOffsetThreshold = 10; static constexpr int PanOffsetThreshold = 10;

View File

@@ -1,23 +1,14 @@
#include "Spinner.h" #include "Spinner.h"
#include "graphics/Graphics.h" #include "graphics/Graphics.h"
#include "Engine.h"
#include <cmath> #include <cmath>
using namespace ui; using namespace ui;
Spinner::Spinner(Point position, Point size): Spinner::Spinner(Point position, Point size):
Component(position, size), cValue(0), Component(position, size)
tickInternal(0)
{ {
} }
void Spinner::Tick()
{
tickInternal++;
if(tickInternal == 4)
{
cValue += 0.25f;//0.05f;
tickInternal = 0;
}
}
void Spinner::Draw(const Point& screenPos) void Spinner::Draw(const Point& screenPos)
{ {
Graphics * g = GetGraphics(); Graphics * g = GetGraphics();
@@ -25,11 +16,12 @@ void Spinner::Draw(const Point& screenPos)
int baseY = screenPos.Y+(Size.Y/2); int baseY = screenPos.Y+(Size.Y/2);
int lineInner = (Size.X/2); int lineInner = (Size.X/2);
int lineOuter = (Size.X/2)+3; int lineOuter = (Size.X/2)+3;
auto cValue = std::floor(ui::Engine::Ref().LastTick() * 0.015f) * 0.25f;
for(float t = 0.0f; t < 6.0f; t+=0.25f) for(float t = 0.0f; t < 6.0f; t+=0.25f)
{ {
g->DrawLine( g->DrawLine(
{ int(baseX+(sin(cValue+t)*lineInner)), int(baseY+(cos(cValue+t)*lineInner)) }, { int(baseX+(std::sin(cValue+t)*lineInner)), int(baseY+(std::cos(cValue+t)*lineInner)) },
{ int(baseX+(sin(cValue+t)*lineOuter)), int(baseY+(cos(cValue+t)*lineOuter)) }, { int(baseX+(std::sin(cValue+t)*lineOuter)), int(baseY+(std::cos(cValue+t)*lineOuter)) },
RGB(int((t/6)*255), int((t/6)*255), int((t/6)*255))); RGB(int((t/6)*255), int((t/6)*255), int((t/6)*255)));
} }
} }

View File

@@ -6,11 +6,8 @@ namespace ui
class Spinner: public Component class Spinner: public Component
{ {
float cValue;
int tickInternal;
public: public:
Spinner(Point position, Point size); Spinner(Point position, Point size);
void Tick() override;
void Draw(const Point& screenPos) override; void Draw(const Point& screenPos) override;
virtual ~Spinner(); virtual ~Spinner();
}; };

View File

@@ -21,9 +21,10 @@ LoginView::LoginView():
titleLabel(new ui::Label(ui::Point(4, 5), ui::Point(200-16, 16), "Server login")), titleLabel(new ui::Label(ui::Point(4, 5), ui::Point(200-16, 16), "Server login")),
infoLabel(new ui::RichLabel(ui::Point(6, 67), ui::Point(200-12, 16), "")), infoLabel(new ui::RichLabel(ui::Point(6, 67), ui::Point(200-12, 16), "")),
usernameField(new ui::Textbox(ui::Point(8, 25), ui::Point(200-16, 17), Client::Ref().GetAuthUser().Username.FromUtf8(), "[username]")), usernameField(new ui::Textbox(ui::Point(8, 25), ui::Point(200-16, 17), Client::Ref().GetAuthUser().Username.FromUtf8(), "[username]")),
passwordField(new ui::Textbox(ui::Point(8, 46), ui::Point(200-16, 17), "", "[password]")), passwordField(new ui::Textbox(ui::Point(8, 46), ui::Point(200-16, 17), "", "[password]"))
targetSize(defaultSize)
{ {
targetSize.SetTarget(Size.Y);
targetSize.SetValue(Size.Y);
FocusComponent(usernameField); FocusComponent(usernameField);
infoLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; infoLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
@@ -97,10 +98,13 @@ void LoginView::NotifyStatusChanged(LoginModel * sender)
cancelButton->Enabled = notWorking && userID; cancelButton->Enabled = notWorking && userID;
usernameField->Enabled = notWorking; usernameField->Enabled = notWorking;
passwordField->Enabled = notWorking; passwordField->Enabled = notWorking;
targetSize = defaultSize;
if (infoLabel->Visible) if (infoLabel->Visible)
{ {
targetSize.Y += infoLabel->Size.Y; targetSize.SetTarget(defaultSize.Y + infoLabel->Size.Y);
}
else
{
targetSize.SetTarget(defaultSize.Y);
} }
if (sender->GetStatus() == loginSucceeded) if (sender->GetStatus() == loginSucceeded)
{ {
@@ -111,27 +115,9 @@ void LoginView::NotifyStatusChanged(LoginModel * sender)
void LoginView::OnTick() void LoginView::OnTick()
{ {
c->Tick(); c->Tick();
//if(targetSize != Size) Size.Y = targetSize.GetValue();
{ loginButton->Position.Y = Size.Y-17;
ui::Point difference = targetSize-Size; cancelButton->Position.Y = Size.Y-17;
if(difference.X!=0)
{
int xdiff = difference.X/5;
if(xdiff == 0)
xdiff = 1*isign(difference.X);
Size.X += xdiff;
}
if(difference.Y!=0)
{
int ydiff = difference.Y/5;
if(ydiff == 0)
ydiff = 1*isign(difference.Y);
Size.Y += ydiff;
}
loginButton->Position.Y = Size.Y-17;
cancelButton->Position.Y = Size.Y-17;
}
} }
void LoginView::OnDraw() void LoginView::OnDraw()

View File

@@ -1,5 +1,6 @@
#pragma once #pragma once
#include "gui/interface/Window.h" #include "gui/interface/Window.h"
#include "gui/interface/Fade.h"
namespace ui namespace ui
{ {
@@ -19,7 +20,7 @@ class LoginView: public ui::Window
ui::Label *infoLabel{}; ui::Label *infoLabel{};
ui::Textbox *usernameField{}; ui::Textbox *usernameField{};
ui::Textbox *passwordField{}; ui::Textbox *passwordField{};
ui::Point targetSize; ui::Fade targetSize{ ui::Fade::BasicDimensionProfile };
public: public:
LoginView(); LoginView();
void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) override; void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) override;

View File

@@ -209,10 +209,10 @@ void PreviewView::commentBoxAutoHeight()
addCommentBox->Size.Y = oldSize; addCommentBox->Size.Y = oldSize;
commentBoxHeight = newSize+22; commentBoxHeight = newSize+22;
commentBoxPositionX = (XRES/2)+4; commentBoxPositionX.SetTarget((XRES/2)+4);
commentBoxPositionY = float(Size.Y-(newSize+21)); commentBoxPositionY.SetTarget(float(Size.Y-(newSize+21)));
commentBoxSizeX = float(Size.X-(XRES/2)-8); commentBoxSizeX.SetTarget(float(Size.X-(XRES/2)-8));
commentBoxSizeY = float(newSize); commentBoxSizeY.SetTarget(float(newSize));
if (commentWarningLabel && commentHelpText && !commentWarningLabel->Visible && addCommentBox->Position.Y+addCommentBox->Size.Y < Size.Y-14) if (commentWarningLabel && commentHelpText && !commentWarningLabel->Visible && addCommentBox->Position.Y+addCommentBox->Size.Y < Size.Y-14)
{ {
@@ -224,10 +224,10 @@ void PreviewView::commentBoxAutoHeight()
commentBoxHeight = 20; commentBoxHeight = 20;
addCommentBox->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; addCommentBox->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
commentBoxPositionX = (XRES/2)+4; commentBoxPositionX.SetTarget((XRES/2)+4);
commentBoxPositionY = float(Size.Y-19); commentBoxPositionY.SetTarget(float(Size.Y-19));
commentBoxSizeX = float(Size.X-(XRES/2)-48); commentBoxSizeX.SetTarget(float(Size.X-(XRES/2)-48));
commentBoxSizeY = 17; commentBoxSizeY.SetTarget(17);
if (commentWarningLabel && commentWarningLabel->Visible) if (commentWarningLabel && commentWarningLabel->Visible)
{ {
@@ -367,40 +367,19 @@ void PreviewView::OnTick()
{ {
if(addCommentBox) if(addCommentBox)
{ {
ui::Point positionDiff = ui::Point(int(commentBoxPositionX), int(commentBoxPositionY))-addCommentBox->Position; addCommentBox->Position.X = commentBoxPositionX;
ui::Point sizeDiff = ui::Point(int(commentBoxSizeX), int(commentBoxSizeY))-addCommentBox->Size; addCommentBox->Position.Y = commentBoxPositionY;
if(positionDiff.X!=0) if(addCommentBox->Size.X != commentBoxSizeX)
{ {
int xdiff = positionDiff.X/5; addCommentBox->Size.X = commentBoxSizeX;
if(xdiff == 0)
xdiff = 1*isign(positionDiff.X);
addCommentBox->Position.X += xdiff;
}
if(positionDiff.Y!=0)
{
int ydiff = positionDiff.Y/5;
if(ydiff == 0)
ydiff = 1*isign(positionDiff.Y);
addCommentBox->Position.Y += ydiff;
}
if(sizeDiff.X!=0)
{
int xdiff = sizeDiff.X/5;
if(xdiff == 0)
xdiff = 1*isign(sizeDiff.X);
addCommentBox->Size.X += xdiff;
addCommentBox->Invalidate(); addCommentBox->Invalidate();
commentBoxAutoHeight(); //make sure textbox height is correct after resizes commentBoxAutoHeight(); //make sure textbox height is correct after resizes
addCommentBox->resetCursorPosition(); //make sure cursor is in correct position after resizes addCommentBox->resetCursorPosition(); //make sure cursor is in correct position after resizes
} }
if(sizeDiff.Y!=0) if(addCommentBox->Size.Y != commentBoxSizeY)
{ {
int ydiff = sizeDiff.Y/5; addCommentBox->Size.Y = commentBoxSizeY;
if(ydiff == 0)
ydiff = 1*isign(sizeDiff.Y);
addCommentBox->Size.Y += ydiff;
addCommentBox->Invalidate(); addCommentBox->Invalidate();
} }
commentsPanel->Size.Y = addCommentBox->Position.Y-1; commentsPanel->Size.Y = addCommentBox->Position.Y-1;
@@ -656,12 +635,15 @@ void PreviewView::NotifyCommentBoxEnabledChanged(PreviewModel * sender)
} }
if(sender->GetCommentBoxEnabled()) if(sender->GetCommentBoxEnabled())
{ {
commentBoxPositionX = (XRES/2)+4;
commentBoxPositionY = float(Size.Y-19);
commentBoxSizeX = float(Size.X-(XRES/2)-48);
commentBoxSizeY = 17;
addCommentBox = new ui::Textbox(ui::Point((XRES/2)+4, Size.Y-19), ui::Point(Size.X-(XRES/2)-48, 17), "", "Add Comment"); addCommentBox = new ui::Textbox(ui::Point((XRES/2)+4, Size.Y-19), ui::Point(Size.X-(XRES/2)-48, 17), "", "Add Comment");
commentBoxPositionX.SetTarget(addCommentBox->Position.X);
commentBoxPositionX.SetValue(addCommentBox->Position.X);
commentBoxPositionY.SetTarget(addCommentBox->Position.Y);
commentBoxPositionY.SetValue(addCommentBox->Position.Y);
commentBoxSizeX.SetTarget(addCommentBox->Size.X);
commentBoxSizeX.SetValue(addCommentBox->Size.X);
commentBoxSizeY.SetTarget(addCommentBox->Size.Y);
commentBoxSizeY.SetValue(addCommentBox->Size.Y);
addCommentBox->SetActionCallback({ [this] { addCommentBox->SetActionCallback({ [this] {
CheckComment(); CheckComment();
commentBoxAutoHeight(); commentBoxAutoHeight();

View File

@@ -4,6 +4,7 @@
#include <vector> #include <vector>
#include "common/String.h" #include "common/String.h"
#include "gui/interface/Window.h" #include "gui/interface/Window.h"
#include "gui/interface/Fade.h"
#include "simulation/MissingElements.h" #include "simulation/MissingElements.h"
namespace http namespace http
@@ -63,10 +64,10 @@ class PreviewView: public ui::Window
bool isRefreshingComments = false; bool isRefreshingComments = false;
int commentBoxHeight; int commentBoxHeight;
float commentBoxPositionX; ui::Fade commentBoxPositionX{ ui::Fade::BasicDimensionProfile };
float commentBoxPositionY; ui::Fade commentBoxPositionY{ ui::Fade::BasicDimensionProfile };
float commentBoxSizeX; ui::Fade commentBoxSizeX{ ui::Fade::BasicDimensionProfile };
float commentBoxSizeY; ui::Fade commentBoxSizeY{ ui::Fade::BasicDimensionProfile };
bool commentHelpText; bool commentHelpText;
std::set<String> swearWords; std::set<String> swearWords;

View File

@@ -217,9 +217,12 @@ void RenderView::OnTick()
if (isToolTipFadingIn) if (isToolTipFadingIn)
{ {
isToolTipFadingIn = false; isToolTipFadingIn = false;
toolTipPresence.MarkGoingUpwardThisTick(); toolTipPresence.SetTarget(120);
}
else
{
toolTipPresence.SetTarget(0);
} }
toolTipPresence.Tick();
} }
void RenderView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) void RenderView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)

View File

@@ -20,7 +20,7 @@ class RenderView: public ui::Window {
std::vector<ModeCheckbox *> displayModes; std::vector<ModeCheckbox *> displayModes;
std::vector<ModeCheckbox *> colourModes; std::vector<ModeCheckbox *> colourModes;
String toolTip; String toolTip;
ui::Fade toolTipPresence{ 0, 0, 120, 120, 60, 1000 }; ui::Fade toolTipPresence{ ui::Fade::LinearProfile{ 120.f, 60.f }, 0, 0 };
bool isToolTipFadingIn; bool isToolTipFadingIn;
int line1, line2, line3, line4; int line1, line2, line3, line4;
uint32_t CalculateRenderMode(); uint32_t CalculateRenderMode();

View File

@@ -79,7 +79,7 @@ void TaskWindow::NotifyProgress(Task * task)
void TaskWindow::OnTick() void TaskWindow::OnTick()
{ {
intermediatePos = std::fmod(ui::Engine::Ref().LastTick() / 600.f, 100.f); intermediatePos = std::fmod(ui::Engine::Ref().LastTick() * 0.06f, 100.f);
task->Poll(); task->Poll();
if (done) if (done)
Exit(); Exit();