-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor singleton with global context (#200)
- Loading branch information
Showing
43 changed files
with
672 additions
and
641 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,69 @@ | ||
#pragma once | ||
#include <vector> | ||
//#include <runtime/function/render/include/render/surface_io.h> | ||
#include "runtime/function/render/render_camera.h" | ||
|
||
#include "runtime/core/math/vector2.h" | ||
|
||
#include "runtime/function/render/render_camera.h" | ||
|
||
#include <vector> | ||
|
||
namespace Pilot | ||
{ | ||
class PilotEditor; | ||
class PilotEditor; | ||
|
||
enum class EditorCommand : unsigned int | ||
{ | ||
camera_left = 1 << 0, // A | ||
camera_back = 1 << 1, // S | ||
camera_foward = 1 << 2, // W | ||
camera_right = 1 << 3, // D | ||
camera_up = 1 << 4, // Q | ||
camera_down = 1 << 5, // E | ||
translation_mode = 1 << 6, // T | ||
rotation_mode = 1 << 7, // R | ||
scale_mode = 1 << 8, // C | ||
exit = 1 << 9, // Esc | ||
delete_object = 1 << 10, // Delete | ||
}; | ||
|
||
class EditorInputManager | ||
{ | ||
public: | ||
void initialize(); | ||
void tick(float delta_time); | ||
|
||
enum class EditorCommand : unsigned int | ||
{ | ||
camera_left = 1 << 0, // A | ||
camera_back = 1 << 1, // S | ||
camera_foward = 1 << 2, // W | ||
camera_right = 1 << 3, // D | ||
camera_up = 1 << 4, // Q | ||
camera_down = 1 << 5, // E | ||
translation_mode = 1 << 6, // T | ||
rotation_mode = 1 << 7, // R | ||
scale_mode = 1 << 8, // C | ||
exit = 1 << 9, // Esc | ||
delete_object = 1 << 10, // Delete | ||
}; | ||
public: | ||
void registerInput(); | ||
void updateCursorOnAxis(Vector2 cursor_uv); | ||
void processEditorCommand(); | ||
void onKeyInEditorMode(int key, int scancode, int action, int mods); | ||
|
||
class EditorInputManager | ||
{ | ||
public: | ||
void initialize(); | ||
void tick(float delta_time); | ||
public: | ||
void registerInput(); | ||
void updateCursorOnAxis(Vector2 cursor_uv); | ||
void processEditorCommand(); | ||
void onKeyInEditorMode(int key, int scancode, int action, int mods); | ||
void onKey(int key, int scancode, int action, int mods); | ||
void onReset(); | ||
void onCursorPos(double xpos, double ypos); | ||
void onCursorEnter(int entered); | ||
void onScroll(double xoffset, double yoffset); | ||
void onMouseButtonClicked(int key, int action); | ||
void onWindowClosed(); | ||
|
||
bool isCursorInRect(Vector2 pos, Vector2 size) const; | ||
|
||
void onKey(int key, int scancode, int action, int mods); | ||
void onReset(); | ||
void onCursorPos(double xpos, double ypos); | ||
void onCursorEnter(int entered); | ||
void onScroll(double xoffset, double yoffset); | ||
void onMouseButtonClicked(int key, int action); | ||
void onWindowClosed(); | ||
public: | ||
Vector2 getEngineWindowPos() const { return m_engine_window_pos; }; | ||
Vector2 getEngineWindowSize() const { return m_engine_window_size; }; | ||
float getCameraSpeed() const { return m_camera_speed; }; | ||
|
||
bool isCursorInRect(Vector2 pos, Vector2 size) const; | ||
public: | ||
Vector2 getEngineWindowPos() { return m_engine_window_pos; }; | ||
Vector2 getEngineWindowSize() { return m_engine_window_size; }; | ||
float getCameraSpeed() { return m_camera_speed; }; | ||
void setEngineWindowPos(Vector2 new_window_pos) { m_engine_window_pos = new_window_pos; }; | ||
void setEngineWindowSize(Vector2 new_window_size) { m_engine_window_size = new_window_size; }; | ||
void resetEditorCommand() { m_editor_command = 0; } | ||
|
||
void setEngineWindowPos(Vector2 new_window_pos) { m_engine_window_pos = new_window_pos; }; | ||
void setEngineWindowSize(Vector2 new_window_size) { m_engine_window_size = new_window_size; }; | ||
void resetEditorCommand() { m_editor_command = 0; } | ||
private: | ||
Vector2 m_engine_window_pos{ 0.0f, 0.0f }; | ||
Vector2 m_engine_window_size{ 1280.0f, 768.0f }; | ||
float m_mouse_x{ 0.0f }; | ||
float m_mouse_y{ 0.0f }; | ||
float m_camera_speed{ 0.05f }; | ||
private: | ||
Vector2 m_engine_window_pos {0.0f, 0.0f}; | ||
Vector2 m_engine_window_size {1280.0f, 768.0f}; | ||
float m_mouse_x {0.0f}; | ||
float m_mouse_y {0.0f}; | ||
float m_camera_speed {0.05f}; | ||
|
||
size_t m_cursor_on_axis{ 3 }; | ||
unsigned int m_editor_command{ 0 }; | ||
}; | ||
} | ||
size_t m_cursor_on_axis {3}; | ||
unsigned int m_editor_command {0}; | ||
}; | ||
} // namespace Pilot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.