Conquer Space 0.0.0
A space themed grand strategy game set in the near future, with realistic orbital mechanics, and an emphasis on economics and politics.
asset.h
Go to the documentation of this file.
1/* Conquer Space
2 * Copyright (C) 2021-2023 Conquer Space
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <string>
20
29namespace cqsp {
30namespace asset {
31enum class AssetType {
32 NONE,
37 TEXTURE,
42 SHADER,
47 HJSON,
52 TEXT,
56 MODEL,
61 FONT,
66 CUBEMAP,
73 AUDIO,
79 SCRIPT,
80 BINARY
81};
82
83// This will be hell to maintain
84
90inline AssetType FromString(const std::string& name) {
91 if (name == "none") {
92 return AssetType::NONE;
93 } else if (name == "texture") {
94 return AssetType::TEXTURE;
95 } else if (name == "shader") {
96 return AssetType::SHADER;
97 } else if (name == "hjson") {
98 return AssetType::HJSON;
99 } else if (name == "text") {
100 return AssetType::TEXT;
101 } else if (name == "model") {
102 return AssetType::MODEL;
103 } else if (name == "font") {
104 return AssetType::FONT;
105 } else if (name == "cubemap") {
106 return AssetType::CUBEMAP;
107 } else if (name == "directory") {
109 } else if (name == "audio") {
110 return AssetType::AUDIO;
111 } else if (name == "shader_def") {
113 } else if (name == "binary") {
114 return AssetType::BINARY;
115 }
116 return AssetType::NONE;
117}
118
124inline std::string ToString(AssetType type) {
125 switch (type) {
126 default:
127 case AssetType::NONE:
128 return "none";
130 return "texture";
132 return "shader";
133 case AssetType::HJSON:
134 return "hjson";
135 case AssetType::TEXT:
136 return "text";
137 case AssetType::MODEL:
138 return "model";
139 case AssetType::FONT:
140 return "font";
142 return "cubemap";
144 return "directory";
145 case AssetType::AUDIO:
146 return "audio";
148 return "binary";
150 return "shader_def";
151 }
152}
153
157class Asset {
158 public:
159 // Virtual destructor to make class virtual
160 virtual ~Asset() = default;
161 virtual AssetType GetAssetType() = 0;
162 std::string path;
163 int accessed = 0;
164};
165} // namespace asset
166} // namespace cqsp
The base class for assets.
Definition: asset.h:157
virtual AssetType GetAssetType()=0
std::string path
Definition: asset.h:162
virtual ~Asset()=default
int accessed
Definition: asset.h:163
std::string ToString(AssetType type)
Converts asset type to asset type names for display
Definition: asset.h:124
AssetType
Definition: asset.h:31
@ SHADER_DEFINITION
shader_def as the type parameter in resource.hjson
@ TEXT
text as the type parameter in resource.hjson
@ HJSON
hjson as the type parameter in resource.hjson
@ AUDIO
audio as the type parameter in resource.hjson
AssetType FromString(const std::string &name)
Converts asset type names to asset types
Definition: asset.h:90
@ FONT
Font prototype.
Definition: assetprototype.h:28
@ NONE
Definition: assetprototype.h:25
@ SHADER
shader prototype
Definition: assetprototype.h:27
@ TEXTURE
texture prototype
Definition: assetprototype.h:26
@ CUBEMAP
cubemap prototype
Definition: assetprototype.h:29
@ MODEL
Model prototype.
Definition: assetprototype.h:30
When adding assets, it is extremely crucial that you read cqsp::asset::AssetLoader::LoadResources to ...
Definition: clientctx.h:21