mirror of
https://github.com/zhenyan121/SporeBG-Conid.git
synced 2026-04-10 06:14:08 +08:00
Fixed the issue with the board display
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#include "SceneManager.h"
|
#include "SceneManager.h"
|
||||||
|
#include "utils/Config.h"
|
||||||
SceneManager::SceneManager(SDL_Renderer* renderer, UIRenderer* uiRenderer, SDL_Window* window) :
|
SceneManager::SceneManager(SDL_Renderer* renderer, UIRenderer* uiRenderer, SDL_Window* window) :
|
||||||
m_renderer(renderer),
|
m_renderer(renderer),
|
||||||
m_uiRenderer(uiRenderer),
|
m_uiRenderer(uiRenderer),
|
||||||
@@ -92,8 +92,8 @@ void SceneManager::pushScene(const std::string& sceneName) {
|
|||||||
m_scene = it->second;
|
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()) {
|
if (!m_scenes.empty()) {
|
||||||
m_scene = m_scenes.top();
|
m_scene = m_scenes.top();
|
||||||
m_scenes.pop();
|
m_scenes.pop();
|
||||||
auto [w, h] = getWindowDimensions();
|
|
||||||
if (m_scene) {
|
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;
|
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() {
|
void SceneManager::renderUI() {
|
||||||
if (m_scene) m_scene->renderUI();
|
if (m_scene) m_scene->renderUI();
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
std::pair<int, int> SceneManager::getWindowDimensions() const {
|
std::pair<int, int> SceneManager::getWindowDimensions() const {
|
||||||
// 获取窗口尺寸的辅助方法
|
// 获取窗口尺寸的辅助方法
|
||||||
int w = 0, h = 0;
|
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};
|
return {w > 0 ? w : 1600, h > 0 ? h : 900};
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
void SceneManager::handleSceneEvent(const SceneEvent& event) {
|
void SceneManager::handleSceneEvent(const SceneEvent& event) {
|
||||||
// 根据事件类型处理场景事件
|
// 根据事件类型处理场景事件
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
|
|||||||
@@ -135,5 +135,6 @@ private:
|
|||||||
* @brief 获取窗口尺寸的辅助方法
|
* @brief 获取窗口尺寸的辅助方法
|
||||||
* @return 返回 {宽度, 高度},如果获取失败则返回默认值 {1600, 900}
|
* @return 返回 {宽度, 高度},如果获取失败则返回默认值 {1600, 900}
|
||||||
*/
|
*/
|
||||||
std::pair<int, int> getWindowDimensions() const;
|
//std::pair<int, int> getWindowDimensions() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -40,12 +40,14 @@ namespace UI
|
|||||||
constexpr int SlotSize = 16;
|
constexpr int SlotSize = 16;
|
||||||
constexpr int PanelPadding = 4;
|
constexpr int PanelPadding = 4;
|
||||||
constexpr int FontHeight = 8;
|
constexpr int FontHeight = 8;
|
||||||
|
constexpr int LogicalWidth = 640;
|
||||||
|
constexpr int LogicalHeight = 360;
|
||||||
constexpr int StartWindowWidth = 320 * 4; // 初始窗口宽度(像素)
|
constexpr int StartWindowWidth = 320 * 4; // 初始窗口宽度(像素)
|
||||||
constexpr int StartWindowHeight = 180 * 4; // 初始窗口高度(像素)
|
constexpr int StartWindowHeight = 180 * 4; // 初始窗口高度(像素)
|
||||||
// 字体大小(逻辑像素)
|
// 字体大小(逻辑像素)
|
||||||
constexpr int DIALOG_FONT_SIZE = 14;
|
constexpr int DIALOG_FONT_SIZE = 14;
|
||||||
constexpr int UI_SMALL_FONT_SIZE = 8;
|
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;
|
constexpr int UI_LARGE_FONT_SIZE = 16;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user