ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
Toggle main menu visibility
载入中...
搜索中...
未找到
Config.h
浏览该文件的文档.
1
#pragma once
2
#include <string>
3
#include <nlohmann/json.hpp>
4
#include "
Log.h
"
5
#include "
Core.h
"
6
7
namespace
Shit
{
8
using
Json
= nlohmann::json;
9
11
struct
ProjectConfig
{
12
std::string
name
=
"Example"
;
13
};
14
16
struct
WindowConfig
{
17
std::string
title
=
"Example"
;
18
unsigned
int
width
= 1280;
19
unsigned
int
height
= 720;
20
unsigned
int
targetFPS
= 144;
21
};
22
29
class
SHIT_API
Config
{
30
public
:
31
bool
init
();
32
void
loadFromJson
(
const
Json
& j);
33
34
// --- 静态API ---
35
static
Config
&
GetInstance
();
36
inline
static
bool
Init
() {
return
GetInstance
().init(); }
37
inline
static
const
ProjectConfig
&
GetProjectConfig
() {
return
GetInstance
().m_projectConfig; }
38
inline
static
const
WindowConfig
&
GetWindowConfig
() {
return
GetInstance
().m_windowConfig; }
39
40
Config
(
const
Config
&) =
delete
;
41
Config
&
operator=
(
const
Config
&) =
delete
;
42
Config
(
Config
&&) =
delete
;
43
Config
&
operator=
(
Config
&&) =
delete
;
44
45
private
:
46
Config
() =
default
;
47
~Config
() =
default
;
48
49
ProjectConfig
m_projectConfig;
50
WindowConfig
m_windowConfig;
51
};
52
}
Core.h
SHIT_API
#define SHIT_API
定义
Core.h:12
Log.h
Shit::Config::GetInstance
static Config & GetInstance()
Shit::Config::operator=
Config & operator=(const Config &)=delete
Shit::Config::operator=
Config & operator=(Config &&)=delete
Shit::Config::Config
Config(const Config &)=delete
Shit::Config::GetProjectConfig
static const ProjectConfig & GetProjectConfig()
项目配置
定义
Config.h:37
Shit::Config::GetWindowConfig
static const WindowConfig & GetWindowConfig()
窗口配置
定义
Config.h:38
Shit::Config::Init
static bool Init()
定义
Config.h:36
Shit::Config::Config
Config(Config &&)=delete
Shit::Config::init
bool init()
加载 settings.json
Shit::Config::loadFromJson
void loadFromJson(const Json &j)
从 JSON 对象加载配置
Shit
定义
AudioPlayer.h:9
Shit::Json
nlohmann::json Json
定义
Config.h:8
Shit::ProjectConfig
项目配置
定义
Config.h:11
Shit::ProjectConfig::name
std::string name
项目名称
定义
Config.h:12
Shit::WindowConfig
窗口配置
定义
Config.h:16
Shit::WindowConfig::targetFPS
unsigned int targetFPS
帧率上限
定义
Config.h:20
Shit::WindowConfig::height
unsigned int height
逻辑分辨率高度
定义
Config.h:19
Shit::WindowConfig::title
std::string title
窗口标题
定义
Config.h:17
Shit::WindowConfig::width
unsigned int width
逻辑分辨率宽度
定义
Config.h:18
ShitEngine
Core
Config.h
制作者
1.17.0