-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplication.cpp
More file actions
55 lines (43 loc) · 1.09 KB
/
Application.cpp
File metadata and controls
55 lines (43 loc) · 1.09 KB
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
#include "pch.h"
#include "Application.h"
#include "log.h"
namespace TextScript {
Application::Application(std::string name)
: m_ApplicationName(name) {
// app initialization logic here
}
Application::~Application() {
// cleanup logic here
}
void Application::Run() {
OnStart();
initscr();
while (m_IsRunning) {
OnUpdate();
m_CurrentKeyboardKey = getch();
if (m_CurrentKeyboardKey == ""){}
else {
OnInput(m_CurrentKeyboardKey);
m_CurrentKeyboardKey = "";
}
std::this_thread::sleep_for(std::chrono::milliseconds(100)); // sleep for 0.1 second
}
}
void Application::Close() {
m_IsRunning = false;
endwin();
LOG_INFO("\033[48;5;208m\033[37m Engine \033[0m User exited Application");
}
void Application::RefreshScreen(){
refresh();
}
void Application::OnStart(){
// Override in derived class
}
void Application::OnUpdate() {
// Override in derived class
}
void Application::OnInput(const std::string& Key){
// Override in derived class
}
} // namespace TextScript