Content error messages

This commit is contained in:
MihailRis 2024-01-09 20:19:46 +03:00
parent dfeb7293b2
commit abd28514e4
4 changed files with 25 additions and 9 deletions

View File

@ -14,6 +14,7 @@ menu.Quit=Выход
menu.Continue=Продолжить
menu.Save and Quit to Menu=Сохранить и Выйти в Меню
menu.missing-content=Отсутствует Контент!
menu.Content Error=Ошибка Контента
menu.Controls=Управление
menu.Back to Main Menu=Вернуться в Меню
menu.Settings=Настройки

View File

@ -309,7 +309,8 @@ void HudRenderer::draw(const GfxContext& ctx){
batch->texture(atlas->getTexture());
}
}
batch->rect(width - 56, uicamera->getFov() - 56, 48, 48, 0, 0, 0, region, false, true, glm::vec4(1.0f));
batch->rect(width - 56, uicamera->getFov() - 56, 48, 48, 0, 0, 0,
region, false, true, glm::vec4(1.0f));
batch->render();
}
}

View File

@ -68,6 +68,22 @@ Button* create_button(std::wstring text,
return btn;
}
void show_content_error_page(Engine* engine, std::string message) {
auto* gui = engine->getGUI();
auto* menu = gui->getMenu();
auto panel = create_page(engine, "error", 800, 0.5f, 8);
panel->add(new Label(langs::get(L"Content Error", L"menu")));
panel->add(new Label(util::str2wstr_utf8(message)));
panel->add((new Button(langs::get(L"Back to Main Menu", L"menu"),
vec4(8.0f)))
->listenAction([=](GUI*){
menu->back();
}));
menu->set("error");
}
void show_content_missing(Engine* engine, const Content* content, ContentLUT* lut) {
auto* gui = engine->getGUI();
auto* menu = gui->getMenu();
@ -163,7 +179,12 @@ void open_world(std::string name, Engine* engine) {
L": "+util::str2wstr_utf8(error.getPackId()));
return;
}
engine->loadContent();
try {
engine->loadContent();
} catch (const std::runtime_error& error) {
show_content_error_page(engine, error.what());
return;
}
auto* content = engine->getContent();
auto& settings = engine->getSettings();

View File

@ -171,13 +171,6 @@ void PlayerController::updateKeyboard() {
input.cameraMode = Events::jactive(BIND_CAM_MODE);
input.noclip = Events::jactive(BIND_PLAYER_NOCLIP);
input.flight = Events::jactive(BIND_PLAYER_FLIGHT);
// block choice
for (int i = 1; i < 10; i++){
if (Events::jpressed(keycode::NUM_0+i)){
player->chosenItem = i;
}
}
}
void PlayerController::updateCamera(float delta, bool movement) {