-
Notifications
You must be signed in to change notification settings - Fork 1
/
StateManager.h
56 lines (43 loc) · 1021 Bytes
/
StateManager.h
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
53
54
55
56
#pragma once
#include "4dm.h"
#include "State.h"
namespace fdm
{
class StateManager
{
public:
std::vector<State *> states;
GLFWwindow* window; // 0x18
void pushState(State* state)
{
return reinterpret_cast<void (__thiscall*)(StateManager* self, State* state)>(getFuncAddr((int)Func::StateManager::pushState))(this, state);
}
// thanks mashpoe for telling me about the fact that those funcs exist
// thanks to me the tr1ngledev for writing them
/* // I COMPLETELY FORGOT PUSHSTATE IS COMPILED IN THE GAME AND EXISTS IN HERE LMFAO
void pushState(State* state)
{
State* lastState = states.back();
if (lastState != state)
lastState->pause(*this);
states.push_back(state);
state->init(*this);
}
*/
void popState()
{
if (!states.empty())
{
states.back()->close(*this);
states.pop_back();
if (!states.empty())
states.back()->resume(*this);
}
}
void changeState(State* newState)
{
popState();
pushState(newState);
}
};
}