82 lines
1.7 KiB
C++
82 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <extra2d/core/module.h>
|
|
#include <extra2d/config/platform_config.h>
|
|
|
|
namespace extra2d {
|
|
|
|
/**
|
|
* @brief 平台模块
|
|
* 管理平台相关的初始化和配置
|
|
*/
|
|
class PlatformModule : public Module {
|
|
public:
|
|
/**
|
|
* @brief 构造函数
|
|
*/
|
|
PlatformModule();
|
|
|
|
/**
|
|
* @brief 析构函数
|
|
*/
|
|
~PlatformModule() override;
|
|
|
|
/**
|
|
* @brief 获取模块名称
|
|
* @return 模块名称
|
|
*/
|
|
const char* getName() const override { return "Platform"; }
|
|
|
|
/**
|
|
* @brief 获取模块优先级
|
|
* @return 优先级
|
|
*/
|
|
int getPriority() const override { return 10; }
|
|
|
|
/**
|
|
* @brief 设置模块
|
|
*/
|
|
void setupModule() override;
|
|
|
|
/**
|
|
* @brief 销毁模块
|
|
*/
|
|
void destroyModule() override;
|
|
|
|
/**
|
|
* @brief 设置目标平台
|
|
* @param platform 目标平台类型
|
|
*/
|
|
void setTargetPlatform(PlatformType platform) { targetPlatform_ = platform; }
|
|
|
|
/**
|
|
* @brief 获取当前平台
|
|
* @return 当前平台类型
|
|
*/
|
|
PlatformType getPlatform() const { return resolvedPlatform_; }
|
|
|
|
/**
|
|
* @brief 获取平台配置
|
|
* @return 平台配置指针
|
|
*/
|
|
PlatformConfig* getPlatformConfig() const { return platformConfig_.get(); }
|
|
|
|
private:
|
|
/**
|
|
* @brief 初始化 Switch 平台
|
|
* @return 初始化成功返回 true
|
|
*/
|
|
bool initSwitch();
|
|
|
|
/**
|
|
* @brief 关闭 Switch 平台
|
|
*/
|
|
void shutdownSwitch();
|
|
|
|
PlatformType targetPlatform_ = PlatformType::Auto;
|
|
PlatformType resolvedPlatform_ = PlatformType::Windows;
|
|
UniquePtr<PlatformConfig> platformConfig_;
|
|
};
|
|
|
|
} // namespace extra2d
|