minor refactor

This commit is contained in:
MihailRis
2024-03-20 09:10:35 +03:00
parent 4b25cc38d9
commit 1b1f11e0b8
6 changed files with 83 additions and 86 deletions
+3 -2
View File
@@ -31,12 +31,13 @@ public:
};
class Engine {
EngineSettings& settings;
EnginePaths* paths;
std::unique_ptr<Assets> assets = nullptr;
std::shared_ptr<Screen> screen = nullptr;
std::vector<ContentPack> contentPacks;
EngineSettings& settings;
std::unique_ptr<Content> content = nullptr;
EnginePaths* paths;
std::unique_ptr<ResPaths> resPaths = nullptr;
uint64_t frame = 0;
-1
View File
@@ -7,7 +7,6 @@
#include <functional>
#include "../../content/ContentPack.h"
namespace gui {
class Panel;
}
+6 -7
View File
@@ -71,18 +71,17 @@ void GUI::actMouse(float delta) {
pressed = nullptr;
}
if (hover) {//WTF?! FIXME
for (int i = static_cast<int>(mousecode::BUTTON_1); i < static_cast<int>(mousecode::BUTTON_1)+12; i++) {
if (Events::jclicked(i)) {
hover->clicked(this, static_cast<mousecode>(i));
if (hover) {
for (mousecode code : MOUSECODES_ALL) {
if (Events::jclicked(code)) {
hover->clicked(this, code);
}
}
}
}
/** Processing user input and UI logic
* @param delta delta time
*/
/// @brief Processing user input and UI logic
/// @param delta delta time
void GUI::act(float delta) {
while (!postRunnables.empty()) {
runnable callback = postRunnables.back();
+2 -6
View File
@@ -18,9 +18,7 @@ void Binding::reset(mousecode code) {
reset(inputtype::mouse, static_cast<int>(code));
}
namespace input_util {
std::string to_string(keycode code) {
std::string input_util::to_string(keycode code) {
int icode_repr = static_cast<int>(code);
#ifdef _WIN32
char name[64];
@@ -79,7 +77,7 @@ namespace input_util {
#endif // _WIN32
}
std::string to_string(mousecode code) {
std::string input_util::to_string(mousecode code) {
switch (code) {
case mousecode::BUTTON_1: return "LMB";
case mousecode::BUTTON_2: return "RMB";
@@ -87,5 +85,3 @@ namespace input_util {
}
return "unknown button";
}
}
+11 -9
View File
@@ -3,9 +3,7 @@
#include <string>
/**
* @brief Represents glfw3 keycode values.
*/
/// @brief Represents glfw3 keycode values.
enum class keycode : int {
ENTER = 257,
TAB = 258,
@@ -88,21 +86,25 @@ enum class keycode : int {
};
/**
* @brief Represents glfw3 mouse button IDs.
* @details There is a subset of glfw3 mouse button IDs.
*/
/// @brief Represents glfw3 mouse button IDs.
/// @details There is a subset of glfw3 mouse button IDs.
enum class mousecode : int {
BUTTON_1 = 0, // Left mouse button
BUTTON_2 = 1, // Right mouse button
BUTTON_3 = 2, // Middle mouse button
};
inline mousecode MOUSECODES_ALL[] {
mousecode::BUTTON_1,
mousecode::BUTTON_2,
mousecode::BUTTON_3
};
namespace input_util {
// @return Key label by keycode
/// @return Key label by keycode
std::string to_string(keycode code);
// @return Mouse button label by keycode
/// @return Mouse button label by keycode
std::string to_string(mousecode code);
}