格式整理

This commit is contained in:
EmsiaetKadosh
2025-03-16 14:18:05 +08:00
parent a1d0f11032
commit c344588924
23 changed files with 467 additions and 257 deletions
+10 -13
View File
@@ -9,10 +9,9 @@
#include "gc.h"
#include "Hud.h"
#include "Task.h"
#include "utils.h"
#include "Window.h"
class Game final : public IRenderable {
class Game final /* : public IRenderable, public ITickable */ {
friend void gameThread();
WindowManager windows;
Hud hud = Hud(); // 8
@@ -21,14 +20,16 @@ class Game final : public IRenderable {
QWORD currentTick = 0; // 8
public:
mutable GarbageCollector gc;
TaskScheduler tasks; // 8
std::minstd_rand random;
explicit Game();
~Game() override;
Game();
~Game();
void render() const noexcept override {
[[nodiscard]] QWORD getTick() const noexcept { return currentTick; }
int closeWindow(Window* const window) noexcept { return windows.pop(window); }
void render() const noexcept {
if (renderer.checkResizing()) return;
renderer.gameStartRender();
caption->render();
@@ -46,7 +47,7 @@ public:
int setWindow(Window* window) noexcept {
if (window) {
if (window->onOpen()) {
for (auto i = windows.begin(); i != windows.end(); ++i) i->passEvent(MouseActionCode::MAC_LEAVE, 0, 0, 0);
for (Window& i : windows) i.passEvent(MouseActionCode::MAC_LEAVE, 0, 0, 0);
windows.pushNewed(window);
Success();
}
@@ -59,15 +60,11 @@ public:
[[nodiscard]] FloatWindow& getFloatWindow() const noexcept { return *floatWindow; }
[[nodiscard]] Window* getWindow() const noexcept {
if (const auto back = windows.back()) return static_cast<Window*>(back);
if (auto *const back = windows.back()) return dynamic_cast<Window*>(back);
Logger.error(L"Game::getWindow returns nullptr");
return nullptr;
}
[[nodiscard]] QWORD getTick() const noexcept { return currentTick; }
int closeWindow(Window* const window) noexcept { return windows.pop(window); }
void tick() noexcept {
++currentTick;
floatWindow->clear();
@@ -89,7 +86,7 @@ public:
void passEvent(const MouseActionCode action, const MouseButtonCode value, const int x, const int y) const noexcept {
caption->passEvent(action, value, x, y);
if (const auto window = getWindow()) window->passEvent(action, value, x, y);
if (Window* const window = getWindow()) window->passEvent(action, value, x, y);
floatWindow->passEvent(action, value, x, y);
}
};