Fixed the issue with the board display

This commit is contained in:
2025-12-24 14:39:40 +08:00
parent 3e9b69bcc9
commit f89c20af6a
3 changed files with 15 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
#include "SceneManager.h"
#include "utils/Config.h"
SceneManager::SceneManager(SDL_Renderer* renderer, UIRenderer* uiRenderer, SDL_Window* window) :
m_renderer(renderer),
m_uiRenderer(uiRenderer),
@@ -92,8 +92,8 @@ void SceneManager::pushScene(const std::string& sceneName) {
m_scene = it->second;
auto [w, h] = getWindowDimensions();
m_scene->onEnter(m_renderer, w, h, m_uiRenderer);
m_scene->onEnter(m_renderer, UI::LogicalWidth, UI::LogicalHeight, m_uiRenderer);
}
@@ -108,9 +108,9 @@ void SceneManager::popScene() {
if (!m_scenes.empty()) {
m_scene = m_scenes.top();
m_scenes.pop();
auto [w, h] = getWindowDimensions();
if (m_scene) {
m_scene->onEnter(m_renderer, w, h, m_uiRenderer);
m_scene->onEnter(m_renderer, UI::LogicalWidth, UI::LogicalHeight, m_uiRenderer);
}
}
}
@@ -141,8 +141,8 @@ void SceneManager::changeScene(const std::string& sceneName) {
// 切换到目标场景
m_scene = target;
auto [w, h] = getWindowDimensions();
m_scene->onEnter(m_renderer, w, h, m_uiRenderer);
m_scene->onEnter(m_renderer, UI::LogicalWidth, UI::LogicalHeight, m_uiRenderer);
}
@@ -169,7 +169,7 @@ void SceneManager::renderWorld() {
void SceneManager::renderUI() {
if (m_scene) m_scene->renderUI();
}
/*
std::pair<int, int> SceneManager::getWindowDimensions() const {
// 获取窗口尺寸的辅助方法
int w = 0, h = 0;
@@ -178,7 +178,7 @@ std::pair<int, int> SceneManager::getWindowDimensions() const {
}
return {w > 0 ? w : 1600, h > 0 ? h : 900};
}
*/
void SceneManager::handleSceneEvent(const SceneEvent& event) {
// 根据事件类型处理场景事件
switch (event.type)

View File

@@ -135,5 +135,6 @@ private:
* @brief 获取窗口尺寸的辅助方法
* @return 返回 {宽度, 高度},如果获取失败则返回默认值 {1600, 900}
*/
std::pair<int, int> getWindowDimensions() const;
//std::pair<int, int> getWindowDimensions() const;
};

View File

@@ -40,12 +40,14 @@ namespace UI
constexpr int SlotSize = 16;
constexpr int PanelPadding = 4;
constexpr int FontHeight = 8;
constexpr int LogicalWidth = 640;
constexpr int LogicalHeight = 360;
constexpr int StartWindowWidth = 320 * 4; // 初始窗口宽度(像素)
constexpr int StartWindowHeight = 180 * 4; // 初始窗口高度(像素)
// 字体大小(逻辑像素)
constexpr int DIALOG_FONT_SIZE = 14;
constexpr int UI_SMALL_FONT_SIZE = 8;
constexpr int UI_NORMAL_FONT_SIZE = 12;
constexpr int UI_NORMAL_FONT_SIZE = 14;
constexpr int UI_LARGE_FONT_SIZE = 16;