diff --git a/src/CRE/task.cpp b/src/CRE/task.cpp index 0d4748b8..1f878f48 100644 --- a/src/CRE/task.cpp +++ b/src/CRE/task.cpp @@ -66,8 +66,6 @@ namespace app { field_2C = false; is_frame_dependent = false; SetName("(unknown)"); - field_4E = false; - field_4F = false; base_calc_time = 0; calc_time = 0; calc_time_max = 0; diff --git a/src/CRE/task.hpp b/src/CRE/task.hpp index 52729b7e..2734e646 100644 --- a/src/CRE/task.hpp +++ b/src/CRE/task.hpp @@ -57,8 +57,6 @@ namespace app { bool field_2C; bool is_frame_dependent; char name[32]; - bool field_4E; - bool field_4F; uint32_t base_calc_time; uint32_t calc_time; uint32_t calc_time_max; diff --git a/src/ReDIVA/data_test/glitter_test.cpp b/src/ReDIVA/data_test/glitter_test.cpp index f83cf0b8..4080f200 100644 --- a/src/ReDIVA/data_test/glitter_test.cpp +++ b/src/ReDIVA/data_test/glitter_test.cpp @@ -7,6 +7,7 @@ #include "../../KKdLib/io/path.hpp" #include "../../KKdLib/str_utils.hpp" #include "../../CRE/clear_color.hpp" +#include "../../CRE/data.hpp" #include "../../CRE/render_context.hpp" #include "../../CRE/stage.hpp" #include "../imgui_helper.hpp" diff --git a/src/ReDIVA/data_test/glitter_test.hpp b/src/ReDIVA/data_test/glitter_test.hpp index 8a2f9742..a3979783 100644 --- a/src/ReDIVA/data_test/glitter_test.hpp +++ b/src/ReDIVA/data_test/glitter_test.hpp @@ -9,7 +9,6 @@ #include #include "../../KKdLib/default.hpp" #include "../../CRE/Glitter/glitter.hpp" -#include "../../CRE/data.hpp" #include "../../CRE/task.hpp" #include "../dw.hpp" diff --git a/src/ReDIVA/data_test/selector.cpp b/src/ReDIVA/data_test/selector.cpp new file mode 100644 index 00000000..7e917c6b --- /dev/null +++ b/src/ReDIVA/data_test/selector.cpp @@ -0,0 +1,110 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#include "selector.hpp" +#include "../game_state.hpp" +#include "../input_state.hpp" +#include "../print_work.hpp" + +struct DataTestSelData { + SubGameStateEnum state; + int32_t index; + const char* name; +}; + +static const DataTestSelData data_test_sel_data[] = { + { SUB_GAME_STATE_DATA_TEST_MISC , 0, "MISC TEST" }, + { SUB_GAME_STATE_DATA_TEST_OBJ , 1, "OBJECT TEST" }, + { SUB_GAME_STATE_DATA_TEST_STG , 2, "STAGE TEST" }, + { SUB_GAME_STATE_DATA_TEST_MOT , 3, "MOTION TEST" }, + { SUB_GAME_STATE_DATA_TEST_COLLISION, 4, "COLLISION TEST" }, + { SUB_GAME_STATE_DATA_TEST_SPR , 5, "SPRITE TEST" }, + { SUB_GAME_STATE_DATA_TEST_AET , 6, "2DAUTH TEST" }, + { SUB_GAME_STATE_DATA_TEST_AUTH_3D , 7, "3DAUTH TEST" }, + { SUB_GAME_STATE_DATA_TEST_CHR , 8, "CHARA TEST" }, + { SUB_GAME_STATE_DATA_TEST_ITEM , 9, "ITEM TEST" }, + { SUB_GAME_STATE_DATA_TEST_OPD , 10, "OPD TEST" }, + { SUB_GAME_STATE_DATA_TEST_PERF , 11, "PERFORMANCE TEST" }, + { SUB_GAME_STATE_DATA_TEST_PRINT , 12, "PRINT TEST" }, + { SUB_GAME_STATE_DATA_TEST_CARD , 13, "CARD TEST'" }, + { SUB_GAME_STATE_DATA_TEST_PVSCRIPT , 14, "PVSCRIPT TEST" }, + { SUB_GAME_STATE_DATA_TEST_GLITTER , 15, "GLITTER TEST" }, +}; + +static const int32_t data_test_sel_data_count = sizeof(data_test_sel_data) / sizeof(DataTestSelData); + +DataTestSel* data_test_sel; + +DataTestSel::DataTestSel() : selected_index(), item_index() { + Init(); +} + +DataTestSel::~DataTestSel() { + +} + +bool DataTestSel::Init() { + selected_index = -1; + item_index = 0; + return true; +} + +bool DataTestSel::Ctrl() { + InputState* input_state = input_state_get(0); + if (input_state->CheckTapped(91)) + item_index--; + if (input_state->CheckTapped(93)) + item_index++; + + if (item_index >= data_test_sel_data_count) + item_index = 0; + else if (item_index < 0) + item_index = data_test_sel_data_count - 1; + + if (input_state->CheckTapped(80)) + selected_index = data_test_sel_data[item_index].index; + + return false; +} + +bool DataTestSel::Dest() { + return true; +} + +void DataTestSel::Disp() { + PrintWork print_work; + font_info font(16); + print_work.SetFont(&font); + const vec2 pos = { 540.0f, 180.0f }; + print_work.line_origin_loc = pos; + print_work.text_current_loc = pos; + print_work.SetResolutionMode(RESOLUTION_MODE_HD); + print_work.prio = spr::SPR_PRIO_02; + + int32_t index = 0; + for (const DataTestSelData& i : data_test_sel_data) { + print_work.color = index == item_index ? color_yellow : color_white; + print_work.printf_align_left("%s\n", i.name); + index++; + } +} + +void data_test_sel_init() { + if (!data_test_sel) + data_test_sel = new DataTestSel; +} + +int32_t data_test_sel_get_sub_state() { + if (data_test_sel_data[data_test_sel->item_index].index == data_test_sel->selected_index) + return data_test_sel_data[data_test_sel->item_index].state; + return -1; +} + +void data_test_sel_free() { + if (data_test_sel) { + delete data_test_sel; + data_test_sel = 0; + } +} diff --git a/src/ReDIVA/data_test/selector.hpp b/src/ReDIVA/data_test/selector.hpp new file mode 100644 index 00000000..bf76db03 --- /dev/null +++ b/src/ReDIVA/data_test/selector.hpp @@ -0,0 +1,30 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#pragma once + +#include "../../KKdLib/default.hpp" +#include "../../CRE/Glitter/glitter.hpp" +#include "../../CRE/task.hpp" + +class DataTestSel : public app::Task { +public: + int32_t selected_index; + int32_t item_index; + + DataTestSel(); + ~DataTestSel(); + + virtual bool Init() override; + virtual bool Ctrl() override; + virtual bool Dest() override; + virtual void Disp() override; +}; + +extern DataTestSel* data_test_sel; + +extern void data_test_sel_init(); +extern int32_t data_test_sel_get_sub_state(); +extern void data_test_sel_free(); diff --git a/src/ReDIVA/game_state.cpp b/src/ReDIVA/game_state.cpp index 263e7d33..c03240f7 100644 --- a/src/ReDIVA/game_state.cpp +++ b/src/ReDIVA/game_state.cpp @@ -14,6 +14,7 @@ #include "data_test/auth_3d_test.hpp" #include "data_test/glitter_test.hpp" #include "data_test/motion_test.hpp" +#include "data_test/selector.hpp" #include "data_test/stage_test.hpp" #include "pv_game/player_data.hpp" #include "pv_game/pv_game.hpp" @@ -1329,14 +1330,19 @@ bool SubGameState::GameOver::Dest() { } bool SubGameState::DataTestMain::Init() { + app::TaskWork::AddTask(data_test_sel, "DATA_TEST_MAIN"); return true; } bool SubGameState::DataTestMain::Ctrl() { + int32_t state = data_test_sel_get_sub_state(); + if (state >= 0) + game_state_set_sub_game_state_next((SubGameStateEnum)state); return false; } bool SubGameState::DataTestMain::Dest() { + data_test_sel->DelTask(); return true; } diff --git a/src/ReDIVA/render.cpp b/src/ReDIVA/render.cpp index c6dfe9a1..76a56d68 100644 --- a/src/ReDIVA/render.cpp +++ b/src/ReDIVA/render.cpp @@ -51,6 +51,7 @@ #include "data_test/auth_3d_test.hpp" #include "data_test/glitter_test.hpp" #include "data_test/motion_test.hpp" +#include "data_test/selector.hpp" #include "data_test/stage_test.hpp" #include "pv_game/pv_game.hpp" #include "game_state.hpp" @@ -585,6 +586,7 @@ static render_context* render_context_load() { dw_init(); + data_test_sel_init(); auth_3d_test_window_init(); dtm_aet_init(); dtm_stg_init(); @@ -1053,10 +1055,8 @@ static void render_context_ctrl(render_context* rctx) { else if (Input::IsKeyTapped(GLFW_KEY_F5)) game_state_set_game_state_next(GAME_STATE_GAME); #endif - else if (Input::IsKeyTapped(GLFW_KEY_F6)) { + else if (Input::IsKeyTapped(GLFW_KEY_F6)) game_state_set_game_state_next(GAME_STATE_DATA_TEST); - game_state_set_sub_game_state_next(SUB_GAME_STATE_DATA_TEST_AET); - } else if (Input::IsKeyTapped(GLFW_KEY_F7)) game_state_set_game_state_next(GAME_STATE_TEST_MODE); else if (Input::IsKeyTapped(GLFW_KEY_F8)) @@ -1222,6 +1222,7 @@ static void render_context_dispose(render_context* rctx) { dtm_stg_free(); dtm_aet_free(); auth_3d_test_window_free(); + data_test_sel_free(); dw_free();