feat(资源加载): 替换stb_image为SDL_image并添加脚本解析功能
- 将stb_image替换为SDL_image以解决Switch平台兼容性问题 - 添加PVF资源包解析器和脚本解析器功能 - 修改各平台配置文件添加SDL_image依赖 - 更新纹理加载逻辑使用SDL_image API - 新增脚本解析相关类用于处理游戏脚本数据
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
#include <frostbite2D/scene/scene.h>
|
||||
#include <frostbite2D/scene/scene_manager.h>
|
||||
#include <frostbite2D/utils/binary_reader.h>
|
||||
|
||||
#include <frostbite2D/utils/pvf_archive.h>
|
||||
#include <frostbite2D/utils/script_parser.h>
|
||||
|
||||
using namespace frostbite2D;
|
||||
|
||||
@@ -18,8 +19,8 @@ int main(int argc, char **argv) {
|
||||
AppConfig config = AppConfig::createDefault();
|
||||
config.appName = "Frostbite2D Test App";
|
||||
config.appVersion = "1.0.0";
|
||||
config.windowConfig.width = 800;
|
||||
config.windowConfig.height = 600;
|
||||
config.windowConfig.width = 1920;
|
||||
config.windowConfig.height = 1080;
|
||||
config.windowConfig.title = "Frostbite2D - Renderer Test";
|
||||
|
||||
Application& app = Application::get();
|
||||
@@ -34,9 +35,6 @@ int main(int argc, char **argv) {
|
||||
auto menuScene = MakePtr<Scene>();
|
||||
SceneManager::get().PushScene(menuScene);
|
||||
|
||||
// 先测试彩色四边形,排除纹理问题
|
||||
SDL_Log("Testing colored quad...");
|
||||
|
||||
// 尝试加载精灵
|
||||
auto sprite = Sprite::createFromFile("assets/player.png");
|
||||
if (sprite) {
|
||||
@@ -47,7 +45,53 @@ int main(int argc, char **argv) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create sprite from file!");
|
||||
}
|
||||
|
||||
|
||||
auto &archive = PvfArchive::get();
|
||||
if (archive.open("assets/Script.pvf")) {
|
||||
archive.init();
|
||||
// 文件内容读取
|
||||
if (auto rawData = archive.getFileRawData("region/balmayer_north.rgn")) {
|
||||
ScriptParser parser(*rawData, "script/example.bin");
|
||||
// // 方式1:迭代解析
|
||||
// while (!parser.isEnd()) {
|
||||
// if (auto value = parser.next()) {
|
||||
// switch (value->type) {
|
||||
// case ScriptValueType::Integer:
|
||||
// SDL_Log("Integer: %d", value->intValue);
|
||||
// break;
|
||||
// case ScriptValueType::Float:
|
||||
// SDL_Log("Float: %f", value->floatValue);
|
||||
// break;
|
||||
// case ScriptValueType::String:
|
||||
// SDL_Log("String: %s", value->stringValue.c_str());
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 方式2:批量解析
|
||||
// parser.reset();
|
||||
auto allValues = parser.parseAll();
|
||||
for (const auto &value : allValues) {
|
||||
// 处理 value
|
||||
switch (value.type) {
|
||||
case ScriptValueType::Integer:
|
||||
SDL_Log("Integer: %d", value.intValue);
|
||||
break;
|
||||
case ScriptValueType::Float:
|
||||
SDL_Log("Float: %f", value.floatValue);
|
||||
break;
|
||||
case ScriptValueType::String:
|
||||
SDL_Log("String: %s", value.stringValue.c_str());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
app.run();
|
||||
|
||||
app.shutdown();
|
||||
|
||||
Reference in New Issue
Block a user