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