diff --git a/src/CRE/module_table.cpp b/src/CRE/module_table.cpp index 481c1ee1..1d8a7fb0 100644 --- a/src/CRE/module_table.cpp +++ b/src/CRE/module_table.cpp @@ -189,11 +189,15 @@ void module_table_handler::parse(p_file_handler* pfhndl) { } if (kv.has_key("cos")) { - int32_t cos; - kv.read("cos", cos); - cos--; - if (cos != 9999) - module.cos = cos; + const char* cos_str; + kv.read("cos", cos_str); + + int32_t cos = 0; + if (sscanf_s(cos_str, "COS_%03d", &cos) == 1) { + cos--; + if (cos != 9999) + module.cos = cos; + } } modules.push_back({ module.id, module }); diff --git a/src/ReDIVA/render.cpp b/src/ReDIVA/render.cpp index a229b59b..68d12fc5 100644 --- a/src/ReDIVA/render.cpp +++ b/src/ReDIVA/render.cpp @@ -104,6 +104,8 @@ common_data_struct common_data; render_data* render; +ImFont* imgui_font_arial; + bool draw_imgui = true; bool draw_grid_3d = false; @@ -841,6 +843,10 @@ static render_context* render_context_load() { rctx->render_manager.resize(internal_2d_res.x, internal_2d_res.y); rctx->litproj->resize(internal_3d_res.x, internal_3d_res.y); + resolution_struct* res_wind = res_window_get(); + rctx->camera->initialize(aspect, internal_3d_res.x, internal_3d_res.y, + res_wind->width, res_wind->height); + render_resize_fb(rctx, true); Glitter::glt_particle_manager_add_task(); @@ -876,9 +882,6 @@ static render_context* render_context_load() { camera* cam = rctx->camera; - resolution_struct* res_wind = res_window_get(); - cam->initialize(aspect, internal_3d_res.x, internal_3d_res.y, - res_wind->width, res_wind->height); //cam->set_position({ 1.35542f, 1.41634f, 1.27852f }); //cam->rotate({ -45.0, -32.5 }); //cam->set_position({ -6.67555f, 4.68882f, -3.67537f }); @@ -900,11 +903,28 @@ static render_context* render_context_load() { ImGuiIO& io = ImGui::GetIO(); io.IniFilename = 0; io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; - lock_unlock(imgui_context_lock); + + io.Fonts->AddFontDefault(); + + const char* font_file = "C:\\Windows\\Fonts\\ArialUni.ttf"; + + ImVector ranges; + ImFontGlyphRangesBuilder builder; + builder.AddRanges(io.Fonts->GetGlyphRangesDefault()); + builder.AddRanges(io.Fonts->GetGlyphRangesJapanese()); + builder.AddRanges(io.Fonts->GetGlyphRangesChineseFull()); + builder.AddRanges(io.Fonts->GetGlyphRangesKorean()); + builder.AddRanges(io.Fonts->GetGlyphRangesCyrillic()); + builder.AddRanges(io.Fonts->GetGlyphRangesGreek()); + builder.AddChar((ImWchar)0x2200); + builder.BuildRanges(&ranges); + + imgui_font_arial = io.Fonts->AddFontFromFileTTF(font_file, 14.0f, 0, ranges.Data); ImGui::StyleColorsDark(); ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init("#version 430"); + lock_unlock(imgui_context_lock); clear_color = { 0x60, 0x60, 0x60, 0xFF }; set_clear_color = true; @@ -1028,6 +1048,13 @@ static void render_context_ctrl(render_context* rctx) { game_state_ctrl(); rctx->ctrl(); + if (game_state_get_game_state() == GAME_STATE_STARTUP) + for (int32_t i = 1; i < 0; i++) { + rctx_ptr = rctx; + game_state_ctrl(); + rctx->ctrl(); + } + char buf[0x200]; game_state_print(buf, sizeof(buf)); glfwSetWindowTitle(window, buf); diff --git a/src/ReDIVA/x_pv_game.cpp b/src/ReDIVA/x_pv_game.cpp index abab7804..ba1394d4 100644 --- a/src/ReDIVA/x_pv_game.cpp +++ b/src/ReDIVA/x_pv_game.cpp @@ -198,6 +198,7 @@ enum dsc_x_func { DSC_X_VR_LIVE_TRANSFORM, DSC_X_VR_LIVE_FLY, DSC_X_VR_LIVE_CHARA_VOICE, + DSC_X_MAX, }; #define DOF_BAKE 0 @@ -229,7 +230,7 @@ dof_cam dof_cam_data; #endif x_pv_game* x_pv_game_ptr; x_pv_game_music* x_pv_game_music_ptr; -XPVGameSelector x_pv_game_selector; +XPVGameSelector* x_pv_game_selector_ptr; extern render_context* rctx_ptr; @@ -5827,6 +5828,10 @@ XPVGameSelector::XPVGameSelector() : charas(), modules(), start(), exit() { modules[4] = 40; modules[5] = 31; #endif + + const prj::vector_pair_combine& modules = module_table_handler_data_get_modules(); + for (const auto& i : modules) + modules_data[i.second.chara].push_back(&i.second); } XPVGameSelector::~XPVGameSelector() { @@ -5927,7 +5932,7 @@ void XPVGameSelector::Window() { float_t w = 400.0f; float_t h = (float_t)height; - h = min_def(h, 432.0f); + h = min_def(h, 438.0f); ImGui::SetNextWindowPos({ (float_t)width - w, 0.0f }, ImGuiCond_Always); ImGui::SetNextWindowSize({ w, h }, ImGuiCond_Always); @@ -5972,31 +5977,41 @@ void XPVGameSelector::Window() { } for (int32_t i = 0; i < ROB_CHARA_COUNT; i++) { - const item_table* itm_tbl = item_table_handler_array_get_table(charas[i]); sprintf_s(buf, sizeof(buf), "Module %dP", i + 1); - sprintf_s(buf1, sizeof(buf1), "%d", modules[i] + 1); + + buf1[0] = 0; + for (const auto& j : modules_data[charas[i]]) + if (modules[i] == j->cos) { + sprintf_s(buf1, sizeof(buf1), "%s", j->name.c_str()); + break; + } ImGui::StartPropertyColumn(buf); + extern ImFont* imgui_font_arial; + if (imgui_font_arial) + ImGui::PushFont(imgui_font_arial); if (ImGui::BeginCombo("", buf1, 0)) { - for (const auto& j : itm_tbl->cos) { - if (j.first == 499) + for (const auto& j : modules_data[charas[i]]) { + if (j->cos == 499) continue; ImGui::PushID(&j); - sprintf_s(buf1, sizeof(buf1), "%d", j.first + 1); - if (ImGui::Selectable(buf1, modules[i] == j.first) + sprintf_s(buf1, sizeof(buf1), "%s", j->name.c_str()); + if (ImGui::Selectable(buf1, modules[i] == j->cos) || ImGui::ItemKeyPressed(ImGuiKey_Enter) - || (ImGui::IsItemFocused() && modules[i] != j.first)) - modules[i] = j.first; + || (ImGui::IsItemFocused() && modules[i] != j->cos)) + modules[i] = j->cos; ImGui::PopID(); - if (modules[i] == j.first) + if (modules[i] == j->cos) ImGui::SetItemDefaultFocus(); } window_focus |= true; ImGui::EndCombo(); } + if (imgui_font_arial) + ImGui::PopFont(); ImGui::EndPropertyColumn(); } @@ -6037,6 +6052,21 @@ extern bool x_pv_game_free() { delete x_pv_game_music_ptr; x_pv_game_music_ptr = 0; + + } + return true; +} + +bool x_pv_game_selector_init() { + if (!x_pv_game_selector_ptr) + x_pv_game_selector_ptr = new XPVGameSelector; + return true; +} + +bool x_pv_game_selector_free() { + if (x_pv_game_selector_ptr) { + delete x_pv_game_selector_ptr; + x_pv_game_selector_ptr = 0; } return true; } @@ -6140,7 +6170,7 @@ static bool x_pv_game_dsc_process(x_pv_game* a1, int64_t curr_time) { else v19 = a1->branch_mode == 1; if (!v19) { - if (func < 0 || func > DSC_X_VR_LIVE_CHARA_VOICE) { + if (func < 0 || func >= DSC_X_MAX) { a1->play = false; return false; } diff --git a/src/ReDIVA/x_pv_game.hpp b/src/ReDIVA/x_pv_game.hpp index d55e8932..9857ff9f 100644 --- a/src/ReDIVA/x_pv_game.hpp +++ b/src/ReDIVA/x_pv_game.hpp @@ -18,6 +18,7 @@ #include "../CRE/auth_2d.hpp" #include "../CRE/auth_3d.hpp" #include "../CRE/frame_rate_control.hpp" +#include "../CRE/module_table.hpp" #include "../CRE/ogg_vorbis.hpp" #include "../CRE/stage_modern.hpp" #include "../CRE/task.hpp" @@ -804,6 +805,7 @@ public: int32_t stage_id; chara_index charas[ROB_CHARA_COUNT]; int32_t modules[ROB_CHARA_COUNT]; + std::vector modules_data[CHARA_MAX]; bool start; bool exit; @@ -817,8 +819,11 @@ public: }; extern x_pv_game* x_pv_game_ptr; -extern XPVGameSelector x_pv_game_selector; +extern XPVGameSelector* x_pv_game_selector_ptr; extern bool x_pv_game_init(); extern bool x_pv_game_free(); + +extern bool x_pv_game_selector_init(); +extern bool x_pv_game_selector_free(); #endif