ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
Toggle main menu visibility
载入中...
搜索中...
未找到
ResourceManager.h
浏览该文件的文档.
1
#pragma once
2
3
#include <memory>
4
#include <string>
5
6
#include "
ShitEngine/Core/Core.h
"
7
#include "
TextureManager.h
"
8
#include "
AudioManager.h
"
9
#include "
FontManager.h
"
10
11
struct
SDL_Texture;
12
struct
MIX_Audio;
13
struct
TTF_Font;
14
15
namespace
Shit
{
23
class
SHIT_API
ResourceManager
final {
24
public
:
25
ResourceManager
();
26
~ResourceManager
();
27
28
ResourceManager
(
const
ResourceManager
&) =
delete
;
29
ResourceManager
&
operator=
(
const
ResourceManager
&) =
delete
;
30
ResourceManager
(
ResourceManager
&&) =
delete
;
31
ResourceManager
&
operator=
(
ResourceManager
&&) =
delete
;
32
33
// --- 静态API ---
34
static
ResourceManager
&
GetInstance
();
35
inline
static
void
Init
() {
GetInstance
().init(); }
36
37
// --- 纹理 ---
38
static
SDL_Texture*
LoadTexture
(
const
std::string& filePath) {
return
GetInstance
().m_textureManager->loadTexture(filePath); }
39
static
SDL_Texture*
GetTexture
(
const
std::string& filePath) {
return
GetInstance
().m_textureManager->getTexture(filePath); }
40
static
void
UnloadTexture
(
const
std::string& filePath) {
GetInstance
().m_textureManager->unloadTexture(filePath); }
41
static
void
ClearTexture
() {
GetInstance
().m_textureManager->clearTexture(); }
42
43
// --- 音频 ---
44
static
MIX_Audio*
LoadAudio
(
const
std::string& filePath) {
return
GetInstance
().m_audioManager->loadAudio(filePath); }
45
static
MIX_Audio*
GetAudio
(
const
std::string& filePath) {
return
GetInstance
().m_audioManager->getAudio(filePath); }
46
static
void
UnloadAudio
(
const
std::string& filePath) {
GetInstance
().m_audioManager->unloadAudio(filePath); }
47
static
void
ClearAudio
() {
GetInstance
().m_audioManager->clearAudio(); }
48
49
// --- 字体 ---
50
static
TTF_Font*
LoadFont
(
const
std::string& filePath) {
return
GetInstance
().m_fontManager->loadFont(filePath); }
51
static
TTF_Font*
GetFont
(
const
std::string& filePath) {
return
GetInstance
().m_fontManager->getFont(filePath); }
52
static
void
UnloadFont
(
const
std::string& filePath) {
return
GetInstance
().m_fontManager->unloadFont(filePath); }
53
static
void
ClearFont
() {
GetInstance
().m_fontManager->clearFont(); }
54
55
// 内部接口(供 AudioPlayer 注入混音器)
56
static
void
SetAudioMixer
(
struct
MIX_Mixer* mixer) {
GetInstance
().m_audioManager->setMixer(mixer); }
57
58
private
:
59
void
clear();
60
void
init();
61
62
std::unique_ptr<TextureManager> m_textureManager;
63
std::unique_ptr<AudioManager> m_audioManager;
64
std::unique_ptr<FontManager> m_fontManager;
65
};
66
}
AudioManager.h
Core.h
SHIT_API
#define SHIT_API
定义
Core.h:12
FontManager.h
TextureManager.h
Shit::ResourceManager::LoadAudio
static MIX_Audio * LoadAudio(const std::string &filePath)
定义
ResourceManager.h:44
Shit::ResourceManager::GetFont
static TTF_Font * GetFont(const std::string &filePath)
定义
ResourceManager.h:51
Shit::ResourceManager::UnloadTexture
static void UnloadTexture(const std::string &filePath)
定义
ResourceManager.h:40
Shit::ResourceManager::ClearAudio
static void ClearAudio()
定义
ResourceManager.h:47
Shit::ResourceManager::Init
static void Init()
定义
ResourceManager.h:35
Shit::ResourceManager::ResourceManager
ResourceManager(ResourceManager &&)=delete
Shit::ResourceManager::LoadFont
static TTF_Font * LoadFont(const std::string &filePath)
定义
ResourceManager.h:50
Shit::ResourceManager::UnloadAudio
static void UnloadAudio(const std::string &filePath)
定义
ResourceManager.h:46
Shit::ResourceManager::ClearFont
static void ClearFont()
定义
ResourceManager.h:53
Shit::ResourceManager::UnloadFont
static void UnloadFont(const std::string &filePath)
定义
ResourceManager.h:52
Shit::ResourceManager::ClearTexture
static void ClearTexture()
定义
ResourceManager.h:41
Shit::ResourceManager::ResourceManager
ResourceManager()
Shit::ResourceManager::SetAudioMixer
static void SetAudioMixer(struct MIX_Mixer *mixer)
定义
ResourceManager.h:56
Shit::ResourceManager::GetAudio
static MIX_Audio * GetAudio(const std::string &filePath)
定义
ResourceManager.h:45
Shit::ResourceManager::GetTexture
static SDL_Texture * GetTexture(const std::string &filePath)
定义
ResourceManager.h:39
Shit::ResourceManager::GetInstance
static ResourceManager & GetInstance()
Shit::ResourceManager::ResourceManager
ResourceManager(const ResourceManager &)=delete
Shit::ResourceManager::operator=
ResourceManager & operator=(ResourceManager &&)=delete
Shit::ResourceManager::LoadTexture
static SDL_Texture * LoadTexture(const std::string &filePath)
定义
ResourceManager.h:38
Shit::ResourceManager::~ResourceManager
~ResourceManager()
Shit::ResourceManager::operator=
ResourceManager & operator=(const ResourceManager &)=delete
Shit
定义
AudioPlayer.h:9
ShitEngine
Resource
ResourceManager.h
制作者
1.17.0