mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-16 21:34:01 +02:00
Remove dt
This commit is contained in:
@@ -116,7 +116,7 @@ void ConsoleView::OnDraw()
|
||||
g->BlendLine(Position + Vec2{ 0, Size.Y }, Position + Size, 0xFFFFFF_rgb .WithAlpha(200));
|
||||
}
|
||||
|
||||
void ConsoleView::OnTick(float dt)
|
||||
void ConsoleView::OnTick()
|
||||
{
|
||||
if (doClose)
|
||||
{
|
||||
|
@@ -21,7 +21,7 @@ class ConsoleView: public ui::Window
|
||||
public:
|
||||
ConsoleView();
|
||||
void OnDraw() override;
|
||||
void OnTick(float dt) override;
|
||||
void OnTick() override;
|
||||
void DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) override;
|
||||
void DoTextInput(String text) override;
|
||||
void AttachController(ConsoleController * c_) { c = c_; }
|
||||
|
@@ -24,7 +24,6 @@ ElementSearchActivity::ElementSearchActivity(GameController * gameController, st
|
||||
gameController(gameController),
|
||||
tools(tools),
|
||||
toolTip(""),
|
||||
toolTipPresence(0),
|
||||
shiftPressed(false),
|
||||
ctrlPressed(false),
|
||||
altPressed(false),
|
||||
@@ -231,22 +230,17 @@ void ElementSearchActivity::OnDraw()
|
||||
}
|
||||
}
|
||||
|
||||
void ElementSearchActivity::OnTick(float dt)
|
||||
void ElementSearchActivity::OnTick()
|
||||
{
|
||||
if (exit)
|
||||
Exit();
|
||||
|
||||
if (isToolTipFadingIn)
|
||||
{
|
||||
isToolTipFadingIn = false;
|
||||
if (toolTipPresence < 120)
|
||||
toolTipPresence += int(dt*2)>1?int(dt*2):2;
|
||||
}
|
||||
else if (toolTipPresence>0)
|
||||
{
|
||||
toolTipPresence -= int(dt)>0?int(dt):1;
|
||||
if (toolTipPresence<0)
|
||||
toolTipPresence = 0;
|
||||
toolTipPresence.MarkGoingUpwardThisTick();
|
||||
}
|
||||
toolTipPresence.Tick();
|
||||
}
|
||||
|
||||
void ElementSearchActivity::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#include "Activity.h"
|
||||
#include "common/String.h"
|
||||
#include "gui/interface/Point.h"
|
||||
#include "gui/interface/Fade.h"
|
||||
#include <vector>
|
||||
|
||||
class Tool;
|
||||
@@ -23,7 +24,7 @@ class ElementSearchActivity: public WindowActivity
|
||||
std::vector<ToolButton*> toolButtons;
|
||||
ui::ScrollPanel *scrollPanel = nullptr;
|
||||
String toolTip;
|
||||
int toolTipPresence;
|
||||
ui::Fade toolTipPresence{ 0, 0, 120, 120, 60, 1000 };
|
||||
bool shiftPressed;
|
||||
bool ctrlPressed;
|
||||
bool altPressed;
|
||||
@@ -36,7 +37,7 @@ public:
|
||||
ElementSearchActivity(GameController * gameController, std::vector<Tool*> tools);
|
||||
void SetActiveTool(int selectionState, Tool * tool);
|
||||
virtual ~ElementSearchActivity();
|
||||
void OnTick(float dt) override;
|
||||
void OnTick() override;
|
||||
void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) override;
|
||||
void OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) override;
|
||||
void OnDraw() override;
|
||||
|
@@ -259,7 +259,7 @@ void FileBrowserActivity::NotifyStatus(Task * task)
|
||||
|
||||
}
|
||||
|
||||
void FileBrowserActivity::OnTick(float dt)
|
||||
void FileBrowserActivity::OnTick()
|
||||
{
|
||||
if(loadFiles)
|
||||
loadFiles->Poll();
|
||||
@@ -283,7 +283,7 @@ void FileBrowserActivity::OnTick(float dt)
|
||||
ui::Point(buttonWidth, buttonHeight),
|
||||
saveFile.get());
|
||||
saveButton->AddContextMenu(1);
|
||||
saveButton->Tick(dt);
|
||||
saveButton->Tick();
|
||||
saveButton->SetActionCallback({
|
||||
[this, i] { SelectSave(i); },
|
||||
[this, i] { RenameSave(i); },
|
||||
|
@@ -48,7 +48,7 @@ public:
|
||||
virtual ~FileBrowserActivity();
|
||||
|
||||
void OnDraw() override;
|
||||
void OnTick(float dt) override;
|
||||
void OnTick() override;
|
||||
void OnTryExit(ExitMethod method) override;
|
||||
void OnMouseDown(int x, int y, unsigned button) override;
|
||||
void loadDirectory(ByteString directory, ByteString search);
|
||||
|
@@ -185,16 +185,12 @@ GameView::GameView():
|
||||
currentSaveType(0),
|
||||
lastMenu(-1),
|
||||
|
||||
toolTipPresence(0),
|
||||
toolTip(""),
|
||||
isToolTipFadingIn(false),
|
||||
toolTipPosition(-1, -1),
|
||||
infoTipPresence(0),
|
||||
infoTip(""),
|
||||
buttonTipShow(0),
|
||||
buttonTip(""),
|
||||
isButtonTipFadingIn(false),
|
||||
introText(2048),
|
||||
introTextMessage(IntroText().FromUtf8()),
|
||||
|
||||
doScreenshot(false),
|
||||
@@ -1728,7 +1724,7 @@ void GameView::SkipIntroText()
|
||||
introText = 0;
|
||||
}
|
||||
|
||||
void GameView::OnTick(float dt)
|
||||
void GameView::OnTick()
|
||||
{
|
||||
if (selectMode == PlaceSave && !placeSaveThumb)
|
||||
selectMode = SelectNone;
|
||||
@@ -1786,50 +1782,20 @@ void GameView::OnTick(float dt)
|
||||
}
|
||||
}
|
||||
|
||||
if(introText)
|
||||
{
|
||||
introText -= int(dt)>0?(int(dt) < 5? int(dt):5):1;
|
||||
if(introText < 0)
|
||||
introText = 0;
|
||||
}
|
||||
if(infoTipPresence>0)
|
||||
{
|
||||
infoTipPresence -= int(dt)>0?int(dt):1;
|
||||
if(infoTipPresence<0)
|
||||
infoTipPresence = 0;
|
||||
}
|
||||
introText.Tick();
|
||||
infoTipPresence.Tick();
|
||||
if (isButtonTipFadingIn || (selectMode != PlaceSave && selectMode != SelectNone))
|
||||
{
|
||||
isButtonTipFadingIn = false;
|
||||
if(buttonTipShow < 120)
|
||||
{
|
||||
buttonTipShow += int(dt*2)>0?int(dt*2):1;
|
||||
if(buttonTipShow>120)
|
||||
buttonTipShow = 120;
|
||||
}
|
||||
}
|
||||
else if(buttonTipShow>0)
|
||||
{
|
||||
buttonTipShow -= int(dt)>0?int(dt):1;
|
||||
if(buttonTipShow<0)
|
||||
buttonTipShow = 0;
|
||||
buttonTipShow.MarkGoingUpwardThisTick();
|
||||
}
|
||||
buttonTipShow.Tick();
|
||||
if (isToolTipFadingIn)
|
||||
{
|
||||
isToolTipFadingIn = false;
|
||||
if(toolTipPresence < 120)
|
||||
{
|
||||
toolTipPresence += int(dt*2)>0?int(dt*2):1;
|
||||
if(toolTipPresence>120)
|
||||
toolTipPresence = 120;
|
||||
}
|
||||
}
|
||||
else if(toolTipPresence>0)
|
||||
{
|
||||
toolTipPresence -= int(dt)>0?int(dt):1;
|
||||
if(toolTipPresence<0)
|
||||
toolTipPresence = 0;
|
||||
toolTipPresence.MarkGoingUpwardThisTick();
|
||||
}
|
||||
toolTipPresence.Tick();
|
||||
}
|
||||
|
||||
void GameView::OnSimTick()
|
||||
@@ -2639,7 +2605,7 @@ void GameView::OnDraw()
|
||||
//Tooltips
|
||||
if(infoTipPresence)
|
||||
{
|
||||
int infoTipAlpha = (infoTipPresence>50?50:infoTipPresence)*5;
|
||||
int infoTipAlpha = (infoTipPresence>50?50:int(infoTipPresence))*5;
|
||||
g->BlendTextOutline({ (XRES - (Graphics::TextSize(infoTip).X - 1)) / 2, YRES / 2 - 2 }, infoTip, 0xFFFFFF_rgb .WithAlpha(infoTipAlpha));
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "common/String.h"
|
||||
#include "gui/interface/Window.h"
|
||||
#include "gui/interface/Fade.h"
|
||||
#include "simulation/Sample.h"
|
||||
#include "graphics/FindingElement.h"
|
||||
#include "graphics/RendererFrame.h"
|
||||
@@ -65,16 +66,16 @@ private:
|
||||
int currentSaveType;
|
||||
int lastMenu;
|
||||
|
||||
int toolTipPresence;
|
||||
ui::Fade toolTipPresence{ 0, 0, 120, 120, 60, 1000 };
|
||||
String toolTip;
|
||||
bool isToolTipFadingIn;
|
||||
ui::Point toolTipPosition;
|
||||
int infoTipPresence;
|
||||
ui::Fade infoTipPresence{ 0, 0, 120, 60, 60, 1000 };
|
||||
String infoTip;
|
||||
int buttonTipShow;
|
||||
ui::Fade buttonTipShow{ 0, 0, 120, 120, 60, 1000 };
|
||||
String buttonTip;
|
||||
bool isButtonTipFadingIn;
|
||||
int introText;
|
||||
ui::Fade introText{ 2048, 0, 10000, 60, 60, 1000 };
|
||||
String introTextMessage;
|
||||
|
||||
bool doScreenshot;
|
||||
@@ -246,7 +247,7 @@ public:
|
||||
void OnMouseWheel(int x, int y, int d) override;
|
||||
void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) override;
|
||||
void OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) override;
|
||||
void OnTick(float dt) override;
|
||||
void OnTick() override;
|
||||
void OnSimTick() override;
|
||||
void OnDraw() override;
|
||||
void OnBlur() override;
|
||||
|
@@ -19,7 +19,7 @@ AvatarButton::AvatarButton(Point position, Point size, ByteString username, int
|
||||
|
||||
}
|
||||
|
||||
void AvatarButton::Tick(float dt)
|
||||
void AvatarButton::Tick()
|
||||
{
|
||||
if (!avatar && !tried && name.size() > 0)
|
||||
{
|
||||
|
@@ -38,7 +38,7 @@ public:
|
||||
void OnContextMenuAction(int item) override;
|
||||
|
||||
void Draw(const Point& screenPos) override;
|
||||
void Tick(float dt) override;
|
||||
void Tick() override;
|
||||
|
||||
void DoAction();
|
||||
|
||||
|
@@ -157,7 +157,7 @@ void Component::Draw(const Point& screenPos)
|
||||
drawn = true;
|
||||
}
|
||||
|
||||
void Component::Tick(float dt)
|
||||
void Component::Tick()
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -69,10 +69,8 @@ namespace ui
|
||||
|
||||
///
|
||||
// Called: Every tick.
|
||||
// Params:
|
||||
// dt: The change in time.
|
||||
///
|
||||
virtual void Tick(float dt);
|
||||
virtual void Tick();
|
||||
|
||||
///
|
||||
// Called: When ready to draw.
|
||||
|
@@ -17,7 +17,7 @@ Engine::Engine():
|
||||
windowTargetPosition(0, 0),
|
||||
FastQuit(1),
|
||||
GlobalQuit(true),
|
||||
lastTick(0),
|
||||
lastTick(Platform::GetTime()),
|
||||
mouseb_(0),
|
||||
mousex_(0),
|
||||
mousey_(0),
|
||||
|
54
src/gui/interface/Fade.cpp
Normal file
54
src/gui/interface/Fade.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "Fade.h"
|
||||
#include "Engine.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace ui
|
||||
{
|
||||
constexpr int64_t bias = 1000;
|
||||
|
||||
void Fade::SetRange(int newMinValue, int newMaxValue)
|
||||
{
|
||||
minValueBiased = int64_t(newMinValue) * bias;
|
||||
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());
|
||||
goingUpward = nextGoingUpward;
|
||||
}
|
||||
}
|
||||
|
||||
void Fade::SetValue(int newValue)
|
||||
{
|
||||
uint64_t now = Engine::Ref().LastTick();
|
||||
referenceValueBiased = newValue * bias;
|
||||
referenceTime = now;
|
||||
}
|
||||
|
||||
int Fade::GetValue() const
|
||||
{
|
||||
uint64_t now = Engine::Ref().LastTick();
|
||||
auto minValueNow = goingUpward ? referenceValueBiased : minValueBiased;
|
||||
auto maxValueNow = goingUpward ? maxValueBiased : referenceValueBiased;
|
||||
auto changeNow = goingUpward ? changeUpwardBiased : changeDownwardBiased;
|
||||
auto diff = std::min(int64_t(now - referenceTime), (maxValueNow - minValueNow) / changeNow);
|
||||
return int(goingUpward ? (minValueNow + changeNow * diff) : (maxValueNow - changeNow * diff)) / bias;
|
||||
}
|
||||
}
|
43
src/gui/interface/Fade.h
Normal file
43
src/gui/interface/Fade.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
namespace ui
|
||||
{
|
||||
class Fade
|
||||
{
|
||||
public:
|
||||
int64_t minValueBiased; // real value * 1000
|
||||
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);
|
||||
SetRateOfChange(changeUpward, changeDownward, ticks);
|
||||
SetValue(currentValue);
|
||||
}
|
||||
|
||||
void SetRange(int newMinValue, int newMaxValue);
|
||||
void SetRateOfChange(int changeUpward, int changeDownward, int ticks);
|
||||
void MarkGoingUpwardThisTick(); // this is retained until the next Tick call
|
||||
void Tick();
|
||||
void SetValue(int newValue);
|
||||
int GetValue() const;
|
||||
|
||||
operator int() const
|
||||
{
|
||||
return GetValue();
|
||||
}
|
||||
|
||||
Fade &operator =(int newValue)
|
||||
{
|
||||
SetValue(newValue);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
}
|
@@ -166,7 +166,7 @@ void Label::OnMouseMoved(int localx, int localy)
|
||||
}
|
||||
}
|
||||
|
||||
void Label::Tick(float dt)
|
||||
void Label::Tick()
|
||||
{
|
||||
if (multiline)
|
||||
{
|
||||
|
@@ -63,6 +63,6 @@ namespace ui
|
||||
void OnMouseMoved(int localx, int localy) override;
|
||||
void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) override;
|
||||
void Draw(const Point& screenPos) override;
|
||||
void Tick(float dt) override;
|
||||
void Tick() override;
|
||||
};
|
||||
}
|
||||
|
@@ -87,14 +87,14 @@ void Panel::Draw(const Point& screenPos)
|
||||
GetGraphics()->SwapClipRect(clip); // apply old cliprect
|
||||
}
|
||||
|
||||
void Panel::Tick(float dt)
|
||||
void Panel::Tick()
|
||||
{
|
||||
// tick ourself first
|
||||
XTick(dt);
|
||||
XTick();
|
||||
|
||||
// tick our children
|
||||
for(unsigned i = 0; i < children.size(); ++i)
|
||||
children[i]->Tick(dt);
|
||||
children[i]->Tick();
|
||||
}
|
||||
|
||||
void Panel::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
|
||||
@@ -305,7 +305,7 @@ void Panel::XDraw(const Point& screenPos)
|
||||
{
|
||||
}
|
||||
|
||||
void Panel::XTick(float dt)
|
||||
void Panel::XTick()
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -47,7 +47,7 @@ namespace ui
|
||||
//Get child of this component by index.
|
||||
Component* GetChild(unsigned idx);
|
||||
|
||||
void Tick(float dt) override;
|
||||
void Tick() override;
|
||||
void Draw(const Point& screenPos) override;
|
||||
|
||||
void OnMouseHover(int localx, int localy) override;
|
||||
@@ -67,7 +67,7 @@ namespace ui
|
||||
std::vector<ui::Component*> children;
|
||||
|
||||
// Overridable. Called by XComponent::Tick()
|
||||
virtual void XTick(float dt);
|
||||
virtual void XTick();
|
||||
|
||||
// Overridable. Called by XComponent::Draw()
|
||||
virtual void XDraw(const Point& screenPos);
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include "graphics/Graphics.h"
|
||||
|
||||
#include "gui/Style.h"
|
||||
#include "gui/interface/Engine.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -73,9 +74,7 @@ void ProgressBar::Draw(const Point &screenPos)
|
||||
}
|
||||
}
|
||||
|
||||
void ProgressBar::Tick(float dt)
|
||||
void ProgressBar::Tick()
|
||||
{
|
||||
intermediatePos += 1.0f*dt;
|
||||
if(intermediatePos>100.0f)
|
||||
intermediatePos = 0.0f;
|
||||
intermediatePos = std::fmod(ui::Engine::Ref().LastTick() / 600.f, 100.f);
|
||||
}
|
||||
|
@@ -16,6 +16,6 @@ namespace ui
|
||||
void SetStatus(String status);
|
||||
String GetStatus();
|
||||
void Draw(const Point & screenPos) override;
|
||||
void Tick(float dt) override;
|
||||
void Tick() override;
|
||||
};
|
||||
}
|
||||
|
@@ -116,7 +116,7 @@ SaveButton::~SaveButton()
|
||||
}
|
||||
}
|
||||
|
||||
void SaveButton::Tick(float dt)
|
||||
void SaveButton::Tick()
|
||||
{
|
||||
if (!thumbnail)
|
||||
{
|
||||
|
@@ -59,7 +59,7 @@ public:
|
||||
void OnContextMenuAction(int item) override;
|
||||
|
||||
void Draw(const Point& screenPos) override;
|
||||
void Tick(float dt) override;
|
||||
void Tick() override;
|
||||
|
||||
void SetSelected(bool selected_) { selected = selected_; }
|
||||
bool GetSelected() { return selected; }
|
||||
|
@@ -171,7 +171,7 @@ void ScrollPanel::XOnMouseMoved(int x, int y)
|
||||
}
|
||||
}
|
||||
|
||||
void ScrollPanel::XTick(float dt)
|
||||
void ScrollPanel::XTick()
|
||||
{
|
||||
auto oldViewportPositionY = ViewportPosition.Y;
|
||||
|
||||
|
@@ -39,7 +39,7 @@ namespace ui
|
||||
void SetScrollPosition(int position);
|
||||
|
||||
void Draw(const Point& screenPos) override;
|
||||
void XTick(float dt) override;
|
||||
void XTick() override;
|
||||
void XOnMouseWheelInside(int localx, int localy, int d) override;
|
||||
void XOnMouseDown(int localx, int localy, unsigned int button) override;
|
||||
void XOnMouseUp(int x, int y, unsigned int button) override;
|
||||
|
@@ -9,7 +9,7 @@ Spinner::Spinner(Point position, Point size):
|
||||
tickInternal(0)
|
||||
{
|
||||
}
|
||||
void Spinner::Tick(float dt)
|
||||
void Spinner::Tick()
|
||||
{
|
||||
tickInternal++;
|
||||
if(tickInternal == 4)
|
||||
|
@@ -10,7 +10,7 @@ class Spinner: public Component
|
||||
int tickInternal;
|
||||
public:
|
||||
Spinner(Point position, Point size);
|
||||
void Tick(float dt) override;
|
||||
void Tick() override;
|
||||
void Draw(const Point& screenPos) override;
|
||||
virtual ~Spinner();
|
||||
};
|
||||
|
@@ -247,9 +247,9 @@ bool Textbox::StringValid(String text)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Textbox::Tick(float dt)
|
||||
void Textbox::Tick()
|
||||
{
|
||||
Label::Tick(dt);
|
||||
Label::Tick();
|
||||
auto tp = textPosition - Vec2{ scrollX, 0 };
|
||||
if (GetParentWindow() && Visible && Enabled && IsFocused())
|
||||
{
|
||||
|
@@ -51,7 +51,7 @@ public:
|
||||
bool CharacterValid(int character);
|
||||
bool StringValid(String text);
|
||||
|
||||
void Tick(float dt) override;
|
||||
void Tick() override;
|
||||
void OnContextMenuAction(int item) override;
|
||||
void OnMouseDown(int x, int y, unsigned button) override;
|
||||
void OnMouseUp(int x, int y, unsigned button) override;
|
||||
|
@@ -260,13 +260,13 @@ void Window::DoTick()
|
||||
//tick
|
||||
for (int i = 0, sz = Components.size(); i < sz && !halt; ++i)
|
||||
{
|
||||
Components[i]->Tick(dt);
|
||||
Components[i]->Tick();
|
||||
}
|
||||
|
||||
halt = false;
|
||||
stop = false;
|
||||
|
||||
OnTick(dt);
|
||||
OnTick();
|
||||
|
||||
if (destruct)
|
||||
finalise();
|
||||
@@ -614,26 +614,9 @@ void Window::Halt()
|
||||
void Window::SetFps(float newFps)
|
||||
{
|
||||
fps = newFps;
|
||||
if (std::holds_alternative<FpsLimitExplicit>(fpsLimit))
|
||||
{
|
||||
dt = 60/fps;
|
||||
}
|
||||
else
|
||||
{
|
||||
dt = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void Window::SetFpsLimit(FpsLimit newFpsLimit)
|
||||
{
|
||||
fpsLimit = newFpsLimit;
|
||||
// Populate dt with whatever that makes any sort of sense.
|
||||
if (auto *explicitFpsLimit = std::get_if<FpsLimitExplicit>(&fpsLimit))
|
||||
{
|
||||
SetFps(explicitFpsLimit->value);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFps(1);
|
||||
}
|
||||
}
|
||||
|
@@ -104,7 +104,7 @@ namespace ui
|
||||
|
||||
virtual void OnInitialized() {}
|
||||
virtual void OnExit() {}
|
||||
virtual void OnTick(float dt) {}
|
||||
virtual void OnTick() {}
|
||||
virtual void OnSimTick() {}
|
||||
virtual void OnDraw() {}
|
||||
virtual void OnFocus() {}
|
||||
@@ -134,7 +134,6 @@ namespace ui
|
||||
bool destruct;
|
||||
bool stop;
|
||||
|
||||
float dt;
|
||||
float fps;
|
||||
FpsLimit fpsLimit = FpsLimitFollowDraw{};
|
||||
};
|
||||
|
@@ -7,6 +7,7 @@ gui_files += files(
|
||||
'CopyTextButton.cpp',
|
||||
'DirectionSelector.cpp',
|
||||
'DropDown.cpp',
|
||||
'Fade.cpp',
|
||||
'Engine.cpp',
|
||||
'Label.cpp',
|
||||
'Panel.cpp',
|
||||
|
@@ -68,7 +68,7 @@ void LocalBrowserView::textChanged()
|
||||
lastChanged = GetTicks()+600;
|
||||
}
|
||||
|
||||
void LocalBrowserView::OnTick(float dt)
|
||||
void LocalBrowserView::OnTick()
|
||||
{
|
||||
c->Update();
|
||||
if (changed && lastChanged < GetTicks())
|
||||
|
@@ -31,7 +31,7 @@ class LocalBrowserView: public ui::Window {
|
||||
public:
|
||||
LocalBrowserView();
|
||||
//virtual void OnDraw();
|
||||
void OnTick(float dt) override;
|
||||
void OnTick() override;
|
||||
void AttachController(LocalBrowserController * c_) { c = c_; }
|
||||
void NotifyPageChanged(LocalBrowserModel * sender);
|
||||
void NotifySavesListChanged(LocalBrowserModel * sender);
|
||||
|
@@ -108,7 +108,7 @@ void LoginView::NotifyStatusChanged(LoginModel * sender)
|
||||
}
|
||||
}
|
||||
|
||||
void LoginView::OnTick(float dt)
|
||||
void LoginView::OnTick()
|
||||
{
|
||||
c->Tick();
|
||||
//if(targetSize != Size)
|
||||
|
@@ -27,5 +27,5 @@ public:
|
||||
void AttachController(LoginController * c_) { c = c_; }
|
||||
void NotifyStatusChanged(LoginModel * sender);
|
||||
void OnDraw() override;
|
||||
void OnTick(float dt) override;
|
||||
void OnTick() override;
|
||||
};
|
||||
|
@@ -574,7 +574,7 @@ void OptionsView::AttachController(OptionsController * c_)
|
||||
c = c_;
|
||||
}
|
||||
|
||||
void OptionsView::OnTick(float dt)
|
||||
void OptionsView::OnTick()
|
||||
{
|
||||
UpdateStartupRequestStatus();
|
||||
}
|
||||
|
@@ -58,6 +58,6 @@ public:
|
||||
void NotifySettingsChanged(OptionsModel * sender);
|
||||
void AttachController(OptionsController * c_);
|
||||
void OnDraw() override;
|
||||
void OnTick(float dt) final override;
|
||||
void OnTick() final override;
|
||||
void OnTryExit(ExitMethod method) override;
|
||||
};
|
||||
|
@@ -363,7 +363,7 @@ void PreviewView::OnDraw()
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewView::OnTick(float dt)
|
||||
void PreviewView::OnTick()
|
||||
{
|
||||
if(addCommentBox)
|
||||
{
|
||||
|
@@ -94,7 +94,7 @@ public:
|
||||
void SaveLoadingError(String errorMessage);
|
||||
void OnDraw() override;
|
||||
void DoDraw() override;
|
||||
void OnTick(float dt) override;
|
||||
void OnTick() override;
|
||||
void OnTryExit(ExitMethod method) override;
|
||||
void OnMouseWheel(int x, int y, int d) override;
|
||||
void OnMouseUp(int x, int y, unsigned int button) override;
|
||||
|
@@ -197,7 +197,7 @@ void ProfileActivity::setUserInfo(UserInfo newInfo)
|
||||
scrollPanel->InnerSize = ui::Point(Size.X, currentY);
|
||||
}
|
||||
|
||||
void ProfileActivity::OnTick(float dt)
|
||||
void ProfileActivity::OnTick()
|
||||
{
|
||||
if (doError)
|
||||
{
|
||||
|
@@ -33,7 +33,7 @@ class ProfileActivity: public WindowActivity {
|
||||
public:
|
||||
ProfileActivity(ByteString username);
|
||||
virtual ~ProfileActivity();
|
||||
void OnTick(float dt) override;
|
||||
void OnTick() override;
|
||||
void OnDraw() override;
|
||||
void OnTryExit(ExitMethod method) override;
|
||||
|
||||
|
@@ -23,7 +23,6 @@ RenderView::RenderView():
|
||||
ui::Window(ui::Point(0, 0), ui::Point(XRES, WINDOWH)),
|
||||
ren(nullptr),
|
||||
toolTip(""),
|
||||
toolTipPresence(0),
|
||||
isToolTipFadingIn(false)
|
||||
{
|
||||
auto addPresetButton = [this](int index, Icon icon, ui::Point offset, String tooltip) {
|
||||
@@ -213,24 +212,14 @@ void RenderView::OnDraw()
|
||||
}
|
||||
}
|
||||
|
||||
void RenderView::OnTick(float dt)
|
||||
void RenderView::OnTick()
|
||||
{
|
||||
if (isToolTipFadingIn)
|
||||
{
|
||||
isToolTipFadingIn = false;
|
||||
if(toolTipPresence < 120)
|
||||
{
|
||||
toolTipPresence += int(dt*2)>1?int(dt*2):2;
|
||||
if(toolTipPresence > 120)
|
||||
toolTipPresence = 120;
|
||||
}
|
||||
}
|
||||
if(toolTipPresence>0)
|
||||
{
|
||||
toolTipPresence -= int(dt)>0?int(dt):1;
|
||||
if(toolTipPresence<0)
|
||||
toolTipPresence = 0;
|
||||
toolTipPresence.MarkGoingUpwardThisTick();
|
||||
}
|
||||
toolTipPresence.Tick();
|
||||
}
|
||||
|
||||
void RenderView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "gui/interface/Window.h"
|
||||
#include "gui/interface/Fade.h"
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
@@ -19,7 +20,7 @@ class RenderView: public ui::Window {
|
||||
std::vector<ModeCheckbox *> displayModes;
|
||||
std::vector<ModeCheckbox *> colourModes;
|
||||
String toolTip;
|
||||
int toolTipPresence;
|
||||
ui::Fade toolTipPresence{ 0, 0, 120, 120, 60, 1000 };
|
||||
bool isToolTipFadingIn;
|
||||
int line1, line2, line3, line4;
|
||||
uint32_t CalculateRenderMode();
|
||||
@@ -34,7 +35,7 @@ public:
|
||||
void OnMouseDown(int x, int y, unsigned button) override;
|
||||
void OnTryExit(ExitMethod method) override;
|
||||
void OnDraw() override;
|
||||
void OnTick(float dt) override;
|
||||
void OnTick() override;
|
||||
void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) override;
|
||||
void ToolTip(ui::Point senderPosition, String toolTip) override;
|
||||
virtual ~RenderView();
|
||||
|
@@ -61,7 +61,7 @@ LocalSaveActivity::LocalSaveActivity(std::unique_ptr<SaveFile> newSave, OnSaved
|
||||
}
|
||||
}
|
||||
|
||||
void LocalSaveActivity::OnTick(float dt)
|
||||
void LocalSaveActivity::OnTick()
|
||||
{
|
||||
if (thumbnailRenderer)
|
||||
{
|
||||
|
@@ -36,6 +36,6 @@ public:
|
||||
void saveWrite(ByteString finalFilename);
|
||||
void Save();
|
||||
void OnDraw() override;
|
||||
void OnTick(float dt) override;
|
||||
void OnTick() override;
|
||||
virtual ~LocalSaveActivity();
|
||||
};
|
||||
|
@@ -351,7 +351,7 @@ void ServerSaveActivity::CheckName(String newname)
|
||||
titleLabel->SetText("Upload new simulation:");
|
||||
}
|
||||
|
||||
void ServerSaveActivity::OnTick(float dt)
|
||||
void ServerSaveActivity::OnTick()
|
||||
{
|
||||
if (thumbnailRenderer)
|
||||
{
|
||||
|
@@ -45,7 +45,7 @@ public:
|
||||
void ShowRules();
|
||||
void CheckName(String newname);
|
||||
virtual void OnDraw() override;
|
||||
virtual void OnTick(float dt) override;
|
||||
virtual void OnTick() override;
|
||||
virtual ~ServerSaveActivity();
|
||||
protected:
|
||||
void AddAuthorInfo();
|
||||
|
@@ -672,7 +672,7 @@ void SearchView::NotifySelectedChanged(SearchModel * sender)
|
||||
}
|
||||
}
|
||||
|
||||
void SearchView::OnTick(float dt)
|
||||
void SearchView::OnTick()
|
||||
{
|
||||
c->Update();
|
||||
if (changed && lastChanged < GetTicks())
|
||||
|
@@ -67,7 +67,7 @@ public:
|
||||
virtual ~SearchView();
|
||||
void AttachController(SearchController * _c) { c = _c; }
|
||||
virtual void Search(String);
|
||||
void OnTick(float dt) override;
|
||||
void OnTick() override;
|
||||
void OnMouseWheel(int x, int y, int d) override;
|
||||
void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) override;
|
||||
void OnKeyRelease(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) override;
|
||||
|
@@ -51,7 +51,7 @@ TagsView::TagsView():
|
||||
AddComponent(title);
|
||||
}
|
||||
|
||||
void TagsView::OnTick(float dt)
|
||||
void TagsView::OnTick()
|
||||
{
|
||||
c->Tick();
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ class TagsView: public ui::Window {
|
||||
public:
|
||||
TagsView();
|
||||
void OnDraw() override;
|
||||
void OnTick(float dt) override;
|
||||
void OnTick() override;
|
||||
void AttachController(TagsController * c_) { c = c_; }
|
||||
void OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) override;
|
||||
void NotifyTagsChanged(TagsModel * sender);
|
||||
|
@@ -69,7 +69,7 @@ LuaWindow::LuaWindow(lua_State *L)
|
||||
}
|
||||
void OnInitialized() override { luaWindow->triggerOnInitialized(); }
|
||||
void OnExit() override { luaWindow->triggerOnExit(); }
|
||||
void OnTick(float dt) override { luaWindow->triggerOnTick( dt); }
|
||||
void OnTick() override { luaWindow->triggerOnTick(); }
|
||||
void OnFocus() override { luaWindow->triggerOnFocus(); }
|
||||
void OnBlur() override { luaWindow->triggerOnBlur(); }
|
||||
void OnTryExit(ExitMethod) override { luaWindow->triggerOnTryExit(); }
|
||||
@@ -226,12 +226,12 @@ void LuaWindow::triggerOnExit()
|
||||
}
|
||||
}
|
||||
|
||||
void LuaWindow::triggerOnTick(float dt)
|
||||
void LuaWindow::triggerOnTick()
|
||||
{
|
||||
if(onTickFunction)
|
||||
{
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, onTickFunction);
|
||||
lua_pushnumber(L, dt);
|
||||
lua_pushnumber(L, 1); // this used to be dt, which was measured in 60ths of a second; this hardcodes 60fps
|
||||
if(tpt_lua_pcall(L, 1, 0, 0, eventTraitNone))
|
||||
{
|
||||
ci->Log(CommandInterface::LogError, tpt_lua_toString(L, -1));
|
||||
|
@@ -54,7 +54,7 @@ class LuaWindow
|
||||
|
||||
void triggerOnInitialized();
|
||||
void triggerOnExit();
|
||||
void triggerOnTick(float deltaTime);
|
||||
void triggerOnTick();
|
||||
void triggerOnDraw();
|
||||
void triggerOnFocus();
|
||||
void triggerOnBlur();
|
||||
|
@@ -77,11 +77,9 @@ void TaskWindow::NotifyProgress(Task * task)
|
||||
progressBar->SetStatus(progressStatus);
|
||||
}
|
||||
|
||||
void TaskWindow::OnTick(float dt)
|
||||
void TaskWindow::OnTick()
|
||||
{
|
||||
intermediatePos += 1.0f*dt;
|
||||
if(intermediatePos>100.0f)
|
||||
intermediatePos = 0.0f;
|
||||
intermediatePos = std::fmod(ui::Engine::Ref().LastTick() / 600.f, 100.f);
|
||||
task->Poll();
|
||||
if (done)
|
||||
Exit();
|
||||
|
@@ -26,7 +26,7 @@ public:
|
||||
void NotifyDone(Task * task) override;
|
||||
void NotifyProgress(Task * task) override;
|
||||
void NotifyError(Task * task) override;
|
||||
void OnTick(float dt) override;
|
||||
void OnTick() override;
|
||||
void OnDraw() override;
|
||||
void Exit();
|
||||
};
|
||||
|
Reference in New Issue
Block a user