refactor(core): 重构代码组织结构,将类型定义移至types目录

将核心类型定义从core目录迁移至新创建的types目录,包括:
- 基础类型别名(type_alias.h)
- 数学相关类型(type_math.h)
- 颜色类型(type_color.h)
- 窗口配置合并至application.h
删除不再使用的平台配置和旧类型文件
优化头文件包含关系,减少编译依赖
This commit is contained in:
Lenheart 2026-02-21 02:46:19 +08:00
parent 0f9ea65066
commit ce2cc4d210
10 changed files with 39 additions and 154 deletions

View File

@ -1,39 +0,0 @@
#pragma once
#include <fostbite2D/config/platform_config.h>
#include <fostbite2D/platform/window.h>
#include <string>
namespace frostbite2D {
/**
* @file app_config.h
* @brief
*
*
* IModuleConfig
*
* ModuleRegistry ConfigManager
*
*/
/**
* @brief
*
*/
struct AppConfig {
std::string appName = "frostbite2D App";
std::string appVersion = "1.0.0";
std::string organization = "";
std::string configFile = "config.json";
WindowConfig windowConfig;
PlatformType targetPlatform = PlatformType::Auto;
/**
* @brief
* @return
*/
static AppConfig createDefault();
};
} // namespace frostbite2D

View File

@ -1,86 +0,0 @@
#pragma once
#include <fostbite2D/core/types.h>
namespace frostbite2D {
/**
* @file platform_config.h
* @brief
*
*
* IModuleConfig::applyPlatformConstraints()
*/
/**
* @brief
*/
enum class PlatformType {
Auto,
Windows,
Switch,
Linux,
macOS
};
/**
* @brief
*/
struct PlatformCapabilities {
bool supportsWindowed = true;
bool supportsFullscreen = true;
bool supportsBorderless = true;
bool supportsCursor = true;
bool supportsCursorHide = true;
bool supportsDPIAwareness = true;
bool supportsVSync = true;
bool supportsMultiMonitor = true;
bool supportsClipboard = true;
bool supportsGamepad = true;
bool supportsTouch = false;
bool supportsKeyboard = true;
bool supportsMouse = true;
bool supportsResize = true;
bool supportsHighDPI = true;
int maxTextureSize = 16384;
int preferredScreenWidth = 1920;
int preferredScreenHeight = 1080;
float defaultDPI = 96.0f;
bool hasWindowSupport() const { return supportsWindowed || supportsFullscreen || supportsBorderless; }
bool hasInputSupport() const { return supportsKeyboard || supportsMouse || supportsGamepad || supportsTouch; }
bool isDesktop() const { return supportsKeyboard && supportsMouse && supportsWindowed; }
bool isConsole() const { return !supportsWindowed && supportsGamepad; }
};
/**
* @brief
*/
class PlatformConfig {
public:
virtual ~PlatformConfig() = default;
virtual PlatformType platformType() const = 0;
virtual const char* platformName() const = 0;
virtual const PlatformCapabilities& capabilities() const = 0;
virtual int getRecommendedWidth() const = 0;
virtual int getRecommendedHeight() const = 0;
virtual bool isResolutionSupported(int width, int height) const = 0;
};
/**
* @brief
* @param type Auto
* @return
*/
UniquePtr<PlatformConfig> createPlatformConfig(PlatformType type = PlatformType::Auto);
/**
* @brief
* @param type
* @return
*/
const char* getPlatformTypeName(PlatformType type);
}

View File

@ -1,12 +1,39 @@
#pragma once #pragma once
#include <fostbite2D/core/window.h>
#include <fostbite2D/module/module.h> #include <fostbite2D/module/module.h>
#include <fostbite2D/config/app_config.h> #include <fostbite2D/types/type_alias.h>
#include <fostbite2D/platform/window.h>
#include <string> #include <string>
namespace frostbite2D { namespace frostbite2D {
/**
* @brief
*
*/
struct AppConfig {
std::string appName = "frostbite2D App";
std::string appVersion = "1.0.0";
std::string organization = "frostbite";
WindowConfig windowConfig;
PlatformType targetPlatform = PlatformType::Auto;
/**
* @brief
* @return
*/
static AppConfig createDefault() {
AppConfig config;
config.appName = "Frostbite2D App";
config.appVersion = "1.0.0";
config.organization = "frostbite";
config.targetPlatform = PlatformType::Auto;
config.windowConfig = WindowConfig();
return config;
}
};
/** /**
* @brief * @brief
*/ */

View File

@ -1,8 +1,8 @@
#pragma once #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <fostbite2D/core/math_types.h> #include <fostbite2D/types/type_alias.h>
#include <fostbite2D/core/types.h> #include <fostbite2D/types/type_math.h>
#include <functional> #include <functional>
#include <string> #include <string>

View File

@ -55,4 +55,9 @@ using uint16 = std::uint16_t;
using uint32 = std::uint32_t; using uint32 = std::uint32_t;
using uint64 = std::uint64_t; using uint64 = std::uint64_t;
/**
* @brief
*/
enum class PlatformType { Auto, Windows, Switch, Linux, macOS };
} // namespace frostbite2D } // namespace frostbite2D

View File

@ -2,7 +2,7 @@
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include <fostbite2D/core/types.h> #include <fostbite2D/types/type_alias.h>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include <glm/mat4x4.hpp> #include <glm/mat4x4.hpp>
#include <glm/vec2.hpp> #include <glm/vec2.hpp>

View File

@ -1,20 +0,0 @@
#include <fostbite2D/config/app_config.h>
namespace frostbite2D {
AppConfig AppConfig::createDefault() {
AppConfig config;
config.appName = "Frostbite2D App";
config.appVersion = "1.0.0";
config.organization = "";
config.configFile = "config.json";
config.targetPlatform = PlatformType::Auto;
config.windowConfig.title = "Frostbite2D";
return config;
}
}

View File

@ -1,6 +1,6 @@
#include "SDL_log.h" #include "SDL_log.h"
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <fostbite2D/platform/window.h> #include <fostbite2D/core/window.h>
#include <glad/glad.h> #include <glad/glad.h>

View File

@ -1,10 +1,8 @@
#include "SDL_log.h" #include "SDL_log.h"
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <fostbite2D/core/application.h> #include <fostbite2D/core/application.h>
#include <fostbite2D/core/color.h> #include <fostbite2D/core/window.h>
#include <fostbite2D/platform/window.h>
#include <glad/glad.h> #include <glad/glad.h>
#include <iostream>
using namespace frostbite2D; using namespace frostbite2D;