-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDialog.cpp
52 lines (42 loc) · 1.41 KB
/
Dialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//Dialog.cpp
#include "Dialog.h"
#include <iostream>
#include <math.h>
using namespace sdlUtility;
namespace sdlGUI {
Dialog::Dialog() {
Next = Previous = NULL;
CopyInput = true; Focused = false;
AutoSize = Vector2(true, true);
}
int Dialog::OnInput(SDL_Event &Event) {
int Input = 0;
if (Event.type == SDL_KEYDOWN) {
if (Event.key.keysym.scancode == SDL_SCANCODE_ESCAPE) {
if (Focused && IsShown(true) && Interactable.IsInteractive()) {
Hide();
Input = 212;
Focused = false;
}
}
}
return Input;
}
void Dialog::Render(float Interpolation) {
if (IsShown(true) or IsMoving(Axis::XY, true)) { //TEMP Is this going to be a problem?
Scaled = true;
float TargetX = X(Interpolation, Reference::Origin);
float TargetY = Y(Interpolation, Reference::Origin);
//if (ID() == "Menu.Dialog") std::cout << fabs(X(Reference::Origin, 0, 2)-TargetX) << " " << fabs(Interpolation*Velocity.X()) << std::endl;
Renderable.RenderAsDialog(TargetX, TargetY, Width(), Height());
Scaled = false;
}
}
void Dialog::SetFocused(bool Focused) {
this->Focused = Focused;
}
Dialog::~Dialog() {
Next = Previous = NULL;
Focused = false;
}
}