From b3949ba0658e977021d89589bc14cb60a4f7e953 Mon Sep 17 00:00:00 2001 From: korenkonder Date: Sun, 25 Jun 2023 03:55:16 +0300 Subject: [PATCH] Removed dwgui/ImGui render. Replaced with broken dwgui render --- src/CRE/Glitter/effect_inst.cpp | 6 +- src/CRE/Glitter/particle_manager.cpp | 2 +- src/CRE/auth_3d.cpp | 31 +- src/CRE/camera.cpp | 78 +- src/CRE/camera.hpp | 11 +- src/CRE/customize_item_table.cpp | 133 +- src/CRE/customize_item_table.hpp | 28 + src/CRE/module_table.cpp | 13 +- src/CRE/module_table.hpp | 4 +- src/CRE/ogg_vorbis.cpp | 8 +- src/CRE/post_process.cpp | 14 +- src/CRE/post_process.hpp | 1 + src/CRE/render_context.cpp | 13 +- src/CRE/render_manager.cpp | 17 +- src/CRE/rob/rob.cpp | 120 +- src/CRE/rob/rob.hpp | 6 +- src/CRE/sprite.cpp | 17 +- src/CRE/task_effect.cpp | 30 +- src/KKdLib/mat.cpp | 227 +- src/ReDIVA/config.hpp | 2 +- src/ReDIVA/data_initialize.cpp | 2 +- src/ReDIVA/data_test/auth_2d_test.cpp | 12 +- src/ReDIVA/data_test/auth_3d_test.cpp | 5 +- src/ReDIVA/data_test/motion_test.cpp | 144 +- src/ReDIVA/data_test/motion_test.hpp | 42 +- src/ReDIVA/data_test/stage_test.cpp | 30 +- src/ReDIVA/dw.cpp | 3404 ++++++++++++++++------ src/ReDIVA/dw.hpp | 981 ++++--- src/ReDIVA/game_state.cpp | 4 +- src/ReDIVA/print_work.cpp | 2 +- src/ReDIVA/print_work.hpp | 3 +- src/ReDIVA/pv_game/game_2d.cpp | 21 +- src/ReDIVA/pv_game/game_2d.hpp | 10 +- src/ReDIVA/pv_game/pv_game.cpp | 143 +- src/ReDIVA/pv_game/pv_game.hpp | 37 +- src/ReDIVA/pv_game/pv_game_play_data.cpp | 59 + src/ReDIVA/pv_game/pv_game_play_data.hpp | 2 + src/ReDIVA/pv_game/pv_game_pv_data.cpp | 6 +- src/ReDIVA/render.cpp | 24 +- 39 files changed, 4041 insertions(+), 1651 deletions(-) diff --git a/src/CRE/Glitter/effect_inst.cpp b/src/CRE/Glitter/effect_inst.cpp index 7d4c688f..392e9cee 100644 --- a/src/CRE/Glitter/effect_inst.cpp +++ b/src/CRE/Glitter/effect_inst.cpp @@ -300,7 +300,8 @@ namespace Glitter { vec3 scale = this->scale * scale_all; mat4_rotate_zyx_mult(&mat, &rot, &mat); - mat4_scale_rot(&mat, &scale, &mat); + mat4_scale_rot(&mat, &scale, &this->mat); + for (F2EmitterInst*& i : emitters) if (i) i->CtrlInit(GPM_VAL, GLT_VAL, this, delta_frame); @@ -846,7 +847,8 @@ namespace Glitter { mat4 mat; mat4_translate(&trans, &mat); mat4_rotate_zyx_mult(&mat, &rot, &mat); - mat4_scale_rot(&mat, &scale, &mat); + mat4_scale_rot(&mat, &scale, &this->mat); + for (XEmitterInst*& i : emitters) if (i) i->CtrlInit(this, delta_frame); diff --git a/src/CRE/Glitter/particle_manager.cpp b/src/CRE/Glitter/particle_manager.cpp index 3e9f3ef7..c74be6a7 100644 --- a/src/CRE/Glitter/particle_manager.cpp +++ b/src/CRE/Glitter/particle_manager.cpp @@ -344,7 +344,7 @@ namespace Glitter { if (effect_hash == hash_fnv1a64m_empty || effect_hash == hash_murmurhash_empty) return; - if (effect_group_hash == hash_fnv1a64m_empty && effect_group_hash == hash_murmurhash_empty) { + if (effect_group_hash == hash_fnv1a64m_empty || effect_group_hash == hash_murmurhash_empty) { for (Scene*& i : scenes) if (i && i->FreeEffect(this, effect_hash, force_kill)) break; diff --git a/src/CRE/auth_3d.cpp b/src/CRE/auth_3d.cpp index 2c7932a2..599a732f 100644 --- a/src/CRE/auth_3d.cpp +++ b/src/CRE/auth_3d.cpp @@ -368,25 +368,23 @@ void auth_3d::ctrl(render_context* rctx) { for (auth_3d_camera_root& i : camera_root) { i.interpolate(auth_3d_camera_root_calc_frame(&i, frame, rctx)); - vec3 interest = i.interest_value; - vec3 view_point = i.view_point_value; - float_t fov = i.fov_value; - float_t roll = i.roll_value; + cam_struct cam; + + cam.interest = i.interest_value; + cam.view_point = i.view_point_value; + cam.fov = i.fov_value; + cam.roll = i.roll_value; if (left_right_reverse) { - interest.x = -interest.x; - view_point.x = -view_point.x; - roll = -roll; + cam.interest.x = -cam.interest.x; + cam.view_point.x = -cam.view_point.x; + cam.roll = -cam.roll; } - mat4_mult_vec3_trans(&mat, &interest, &interest); - mat4_mult_vec3_trans(&mat, &view_point, &view_point); + mat4_mult_vec3_trans(&mat, &cam.interest, &cam.interest); + mat4_mult_vec3_trans(&mat, &cam.view_point, &cam.view_point); - camera* cam = rctx->camera; - cam->set_interest(interest); - cam->set_view_point(view_point); - cam->set_fov(fov * RAD_TO_DEG); - cam->set_roll(roll * RAD_TO_DEG); + cam.set(rctx->camera); break; } @@ -3562,7 +3560,6 @@ static void auth_3d_camera_auxiliary_set(auth_3d_camera_auxiliary* ca, render_co } static float_t auth_3d_camera_root_calc_frame(auth_3d_camera_root* cr, float_t frame, render_context* rctx) { - camera* cam = rctx->camera; if (auth_3d_key_detect_fast_change(&cr->view_point.model_transform.translation.x, frame, 0.3f) || auth_3d_key_detect_fast_change(&cr->view_point.model_transform.translation.y, frame, 0.3f) || auth_3d_key_detect_fast_change(&cr->view_point.model_transform.translation.z, frame, 0.3f) @@ -3570,7 +3567,7 @@ static float_t auth_3d_camera_root_calc_frame(auth_3d_camera_root* cr, float_t f || auth_3d_key_detect_fast_change(&cr->interest.translation.y, frame, 0.3f) || auth_3d_key_detect_fast_change(&cr->interest.translation.z, frame, 0.3f)) { frame = (float_t)(int32_t)frame; - cam->set_fast_change(true); + rctx->camera->set_fast_change(true); } else { float_t frame_prev = frame - get_delta_frame(); @@ -3582,7 +3579,7 @@ static float_t auth_3d_camera_root_calc_frame(auth_3d_camera_root* cr, float_t f || auth_3d_key_detect_fast_change(&cr->interest.translation.x, frame_prev, 0.3f) || auth_3d_key_detect_fast_change(&cr->interest.translation.y, frame_prev, 0.3f) || auth_3d_key_detect_fast_change(&cr->interest.translation.z, frame_prev, 0.3f)) - cam->set_fast_change_hist0(true); + rctx->camera->set_fast_change_hist0(true); } } return frame; diff --git a/src/CRE/camera.cpp b/src/CRE/camera.cpp index 90cf40a1..9bfb04cb 100644 --- a/src/CRE/camera.cpp +++ b/src/CRE/camera.cpp @@ -4,16 +4,16 @@ */ #include "camera.hpp" +#include "resolution_mode.hpp" static void camera_calculate_projection(camera* c); static void camera_calculate_projection_aet(camera* c); static void camera_calculate_view(camera* c); static void camera_calculate_forward(camera* c); -camera::camera() : forward(), rotation(), view_point(), interest(), fov_correct_height(), -aet_depth(), use_up(), render_width(), render_height(), sprite_width(), sprite_height(), -field_1E4(), field_1F0(), field_1FC(), field_208(), yaw(), pitch(), roll(), aspect(), fov(), -fov_rad(), max_distance(), min_distance(), changed_view(), changed_proj(), changed_proj_aet(), +camera::camera() : forward(), rotation(), view_point(), interest(), fov_correct_height(), aet_depth(), +use_up(), field_1E4(), field_1F0(), field_1FC(), field_208(), yaw(), pitch(), roll(), aspect(), +fov(), fov_rad(), max_distance(), min_distance(), changed_view(), changed_proj(), changed_proj_aet(), fast_change(), fast_change_hist0(), fast_change_hist1(), ignore_fov(), ignore_min_dist() { } @@ -22,8 +22,7 @@ camera::~camera() { } -void camera::initialize(double_t aspect, int32_t render_width, - int32_t render_height, int32_t sprite_width, int32_t sprite_height) { +void camera::initialize(double_t aspect) { this->aspect = aspect; fov = 0.0; fov_correct_height = 0.0f; @@ -32,10 +31,6 @@ void camera::initialize(double_t aspect, int32_t render_width, rotation = { 0.0f, 0.0f, 0.0f }; use_up = false; up = { 0.0f, 1.0f, 0.0f }; - this->render_width = render_width; - this->render_height = render_height; - this->sprite_width = sprite_width; - this->sprite_height = sprite_height; view = mat4_identity; inv_view = mat4_identity; projection = mat4_identity; @@ -220,27 +215,6 @@ void camera::set_up(bool use_up, const vec3&& value) { } } -void camera::get_res(int32_t& render_width, int32_t& render_height, - int32_t& sprite_width, int32_t& sprite_height) { - render_width = this->render_width; - render_height = this->render_height; - sprite_width = this->sprite_width; - sprite_height = this->sprite_height; -} - -void camera::set_res(int32_t render_width, int32_t render_height, - int32_t sprite_width, int32_t sprite_height) { - if (this->render_width != render_width || this->render_height != render_height - || this->sprite_width != sprite_width || this->sprite_height != sprite_height) { - this->render_width = render_width; - this->render_height = render_height; - this->sprite_width = sprite_width; - this->sprite_height = sprite_height; - changed_proj = true; - changed_proj_aet = true; - } -} - void camera::set_fast_change(bool value) { fast_change = value; } @@ -268,6 +242,9 @@ void camera::reset() { set_fov(32.2673416137695); min_distance = 0.05; max_distance = 6000.0; + changed_proj = true; + changed_proj_aet = true; + changed_view = true; fast_change = false; fast_change_hist0 = false; fast_change_hist1 = false; @@ -381,10 +358,12 @@ static void camera_calculate_projection(camera* c) { mat4_persp(c->fov_rad, c->aspect, c->min_distance, c->max_distance, &c->projection); mat4_inverse(&c->projection, &c->inv_projection); - float_t fov_correct_height = (float_t)(((double_t)c->render_height * 0.5) / tan(c->fov_rad * 0.5)); + resolution_struct* res_wind_int = res_window_internal_get(); - float_t height = (float_t)c->render_height * 0.5f; - float_t width = (float_t)c->render_height * (float_t)c->aspect * 0.5f; + float_t fov_correct_height = ((float_t)res_wind_int->height * 0.5f) / tanf((float_t)(c->fov_rad * 0.5)); + + float_t height = (float_t)res_wind_int->height * 0.5f; + float_t width = (float_t)res_wind_int->height * (float_t)c->aspect * 0.5f; c->field_1E4.x = fov_correct_height; c->field_1E4.y = 0.0f; @@ -405,19 +384,25 @@ static void camera_calculate_projection(camera* c) { } static void camera_calculate_projection_aet(camera* c) { - float_t sprite_half_width = (float_t)c->sprite_width * 0.5f; - float_t sprite_half_height = (float_t)c->sprite_height * 0.5f; - float_t render_half_width = (float_t)c->render_width * 0.5f; - float_t render_half_height = (float_t)c->render_height * 0.5f; + resolution_struct* res_wind_int = res_window_internal_get(); + resolution_struct* res_wind = res_window_get(); - float_t aet_depth = sprite_half_height / (tanf(0.34557518363f) * 0.75f); + float_t sprite_half_width = (float_t)res_wind->width * 0.5f; + float_t sprite_half_height = (float_t)res_wind->height * 0.5f; + float_t render_half_width = (float_t)res_wind_int->width * 0.5f; + float_t render_half_height = (float_t)res_wind_int->height * 0.5f; + + static float_t field_20 = tanf(atanf(tanf(0.34557518363f) * 0.75f)); + + float_t aet_depth = sprite_half_height / field_20; c->aet_depth = aet_depth; - float_t fov_correct_height = (float_t)(sprite_half_height / tan(c->fov_rad * 0.5)); + float_t fov_correct_height = sprite_half_height / tanf((float_t)c->fov_rad * 0.5f); c->fov_correct_height = fov_correct_height; - float_t v8a = (float_t)c->min_distance / aet_depth * sprite_half_width; - float_t v8b = (float_t)c->min_distance / aet_depth * sprite_half_height; + float_t v8 = (float_t)c->min_distance / aet_depth; + float_t v8a = v8 * sprite_half_width; + float_t v8b = v8 * sprite_half_height; mat4 spr_2d_proj; mat4_frustrum(-v8a, v8a, v8b, -v8b, c->min_distance, 3000.0, &spr_2d_proj); @@ -430,13 +415,16 @@ static void camera_calculate_projection_aet(camera* c) { mat4_mult(&spr_2d_view, &spr_2d_proj, &c->view_projection_aet_2d); - float_t v13a = (float_t)c->min_distance / aet_depth * render_half_width; - float_t v13b = (float_t)c->min_distance / aet_depth * render_half_height; + float_t v13c = render_half_height / tanf((float_t)c->fov_rad * 0.5f); + + float_t v13 = (float_t)c->min_distance / v13c; + float_t v13a = v13 * render_half_width; + float_t v13b = v13 * render_half_height; mat4 spr_3d_proj; mat4_frustrum(-v13a, v13a, v13b, -v13b, c->min_distance, 3000.0, &spr_3d_proj); - vec3 spr_3d_viewpoint = { render_half_width, render_half_height, render_half_height }; + vec3 spr_3d_viewpoint = { render_half_width, render_half_height, v13c }; vec3 spr_3d_interest = { render_half_width, render_half_height, 0.0f }; vec3 spr_3d_up = { 0.0f, 1.0f, 0.0f }; mat4 spr_3d_view; diff --git a/src/CRE/camera.hpp b/src/CRE/camera.hpp index 1f4b91cc..214bdd19 100644 --- a/src/CRE/camera.hpp +++ b/src/CRE/camera.hpp @@ -32,10 +32,6 @@ struct camera { vec3 interest; bool use_up; vec3 up; - int32_t render_width; - int32_t render_height; - int32_t sprite_width; - int32_t sprite_height; vec3 field_1E4; vec3 field_1F0; vec3 field_1FC; @@ -60,8 +56,7 @@ struct camera { camera(); ~camera(); - void initialize(double_t aspect, int32_t render_width, int32_t render_height, - int32_t sprite_width, int32_t sprite_height); + void initialize(double_t aspect); double_t get_min_distance(); void set_min_distance(double_t value); double_t get_max_distance(); @@ -86,10 +81,6 @@ struct camera { void get_up(bool& use_up, vec3& value); void set_up(bool use_up, const vec3& value); void set_up(bool use_up, const vec3&& value); - void get_res(int32_t& render_width, int32_t& render_height, - int32_t& sprite_width, int32_t& sprite_height); - void set_res(int32_t render_width, int32_t render_height, - int32_t sprite_width, int32_t sprite_height); void set_fast_change(bool value); void set_fast_change_hist0(bool value); void set_fast_change_hist1(bool value); diff --git a/src/CRE/customize_item_table.cpp b/src/CRE/customize_item_table.cpp index 4620a18f..2c00d172 100644 --- a/src/CRE/customize_item_table.cpp +++ b/src/CRE/customize_item_table.cpp @@ -31,7 +31,20 @@ struct customize_item_table_handler { void read(); }; +struct customize_item_data_handler { + std::vector customize_items; + + customize_item_data_handler(); + ~customize_item_data_handler(); + + void add_all_customize_items(); + void add_customize_items(); + bool get_customize_item(int32_t id, customize_item_data& data); + int32_t get_customize_item_obj_id(int32_t id); +}; + customize_item_table_handler* customize_item_table_handler_data; +customize_item_data_handler* customize_item_data_handler_data; customize_item::customize_item() : sort_index(), chara() { id = -1; @@ -43,6 +56,31 @@ customize_item::~customize_item() { } +customize_item_data::customize_item_data() : id(), obj_id(), sort_index(), chara_index(), parts(), +spr_cmnitm_thmb_id_itm_img_spr_id(), field_3C(), field_3D(), field_40(), spr_cmnitm_thmb_id_spr_set_id() { + reset(); +} + +customize_item_data::~customize_item_data() { + +} + +void customize_item_data::reset() { + id = -1; + obj_id = -1; + sort_index = 0; + name.assign(""); + chara_index = CHARA_MIKU; + parts = -1; + spr_cmnitm_thmb_id_itm_img_spr_id = -1; + field_3C = false; + field_3D = false; + field_40 = 0; + field_48 = prj::time::get_default(); + field_50 = prj::time::get_default(); + spr_cmnitm_thmb_id_spr_set_id = -1; +} + void customize_item_table_handler_data_init() { if (!customize_item_table_handler_data) customize_item_table_handler_data = new customize_item_table_handler; @@ -65,13 +103,36 @@ void customize_item_table_handler_data_read() { } void customize_item_table_handler_data_free() { - if (customize_item_table_handler_data) { delete customize_item_table_handler_data; customize_item_table_handler_data = 0; } } +void customize_item_data_handler_data_init() { + if (!customize_item_data_handler_data) + customize_item_data_handler_data = new customize_item_data_handler; +} + +void customize_item_data_handler_data_add_all_customize_items() { + customize_item_data_handler_data->add_all_customize_items(); +} + +bool customize_item_data_handler_data_get_customize_item(int32_t id, customize_item_data& data) { + return customize_item_data_handler_data->get_customize_item(id, data); +} + +int32_t customize_item_data_handler_data_get_customize_item_obj_id(int32_t id) { + return customize_item_data_handler_data->get_customize_item_obj_id(id); +} + +void customize_item_data_handler_data_free() { + if (customize_item_data_handler_data) { + delete customize_item_data_handler_data; + customize_item_data_handler_data = 0; + } +} + customize_item_table_handler::customize_item_table_handler() : ready() { name_map.insert({ }); } @@ -235,3 +296,73 @@ void customize_item_table_handler::read() { } } } + +customize_item_data_handler::customize_item_data_handler() { + +} + +customize_item_data_handler::~customize_item_data_handler() { + +} + +void customize_item_data_handler::add_all_customize_items() { + add_customize_items(); +} + +void customize_item_data_handler::add_customize_items() { + customize_items.clear(); + + data_struct* aft_data = &data_list[DATA_AFT]; + sprite_database* aft_spr_db = &aft_data->data_ft.spr_db; + + char buf[0x80]; + + for (const auto& i : customize_item_table_handler_data_get_customize_items()) { + customize_item_data cstm_itm; + cstm_itm.id = i.second.id; + cstm_itm.obj_id = i.second.obj_id; + cstm_itm.sort_index = i.second.sort_index; + cstm_itm.name.assign(i.second.name); + cstm_itm.chara_index = (chara_index)i.second.chara; + cstm_itm.parts = i.second.parts; + + /*struc_781 v24; + if (sub_1402B7880()->sub_1402B7420(cstm_itm.id, &v24)) { + cstm_itm.field_3C = true; + cstm_itm.field_3D = v24.field_4; + cstm_itm.name.assign(v24.field_8); + cstm_itm.field_40 = v24.field_28; + cstm_itm.field_48.value = v24.field_30.value; + cstm_itm.field_50.value = v24.field_38.value; + cstm_itm.sort_index = v24.sort_index; + } + + int32_t v23 = -1; + if (sub_1402B7880->sub_1402B7510(cstm_itm.id, &v23)) + cstm_itm.field_3D = true;*/ + + sprintf_s(buf, sizeof(buf), "SPR_CMNITM_THMB%03d", cstm_itm.id); + cstm_itm.spr_cmnitm_thmb_id_spr_set_id = aft_spr_db->get_spr_set_by_name(buf)->id; + + sprintf_s(buf, sizeof(buf), "SPR_CMNITM_THMB%03d_ITM_IMG", cstm_itm.id); + cstm_itm.spr_cmnitm_thmb_id_itm_img_spr_id = aft_spr_db->get_spr_by_name(buf)->id; + + customize_items.push_back(cstm_itm); + } +} + +bool customize_item_data_handler::get_customize_item(int32_t id, customize_item_data& data) { + for (customize_item_data& i : customize_items) + if (i.id == id) { + data = i; + return true; + } + return false; +} + +int32_t customize_item_data_handler::get_customize_item_obj_id(int32_t id) { + for (customize_item_data& i : customize_items) + if (i.id == id) + return i.obj_id; + return -1; +} diff --git a/src/CRE/customize_item_table.hpp b/src/CRE/customize_item_table.hpp index 9860a139..58e9ce2a 100644 --- a/src/CRE/customize_item_table.hpp +++ b/src/CRE/customize_item_table.hpp @@ -8,6 +8,7 @@ #include #include "../KKdLib/default.hpp" #include "../KKdLib/database/item_table.hpp" +#include "../KKdLib/prj/time.hpp" #include "../KKdLib/prj/vector_pair_combine.hpp" struct customize_item { @@ -22,6 +23,27 @@ struct customize_item { ~customize_item(); }; +struct customize_item_data { + int32_t id; + int32_t obj_id; + int32_t sort_index; + std::string name; + chara_index chara_index; + int32_t parts; + int32_t spr_cmnitm_thmb_id_itm_img_spr_id; + bool field_3C; + bool field_3D; + int32_t field_40; + prj::time field_48; + prj::time field_50; + int32_t spr_cmnitm_thmb_id_spr_set_id; + + customize_item_data(); + ~customize_item_data(); + + void reset(); +}; + extern void customize_item_table_handler_data_init(); extern const customize_item* customize_item_table_handler_data_get_customize_item(int32_t id); extern const prj::vector_pair_combine& @@ -29,3 +51,9 @@ extern const prj::vector_pair_combine& extern bool customize_item_table_handler_data_load(); extern void customize_item_table_handler_data_read(); extern void customize_item_table_handler_data_free(); + +extern void customize_item_data_handler_data_init(); +extern void customize_item_data_handler_data_add_all_customize_items(); +bool customize_item_data_handler_data_get_customize_item(int32_t id, customize_item_data& data); +int32_t customize_item_data_handler_data_get_customize_item_obj_id(int32_t id); +extern void customize_item_data_handler_data_free(); diff --git a/src/CRE/module_table.cpp b/src/CRE/module_table.cpp index c12dbfdb..bf398252 100644 --- a/src/CRE/module_table.cpp +++ b/src/CRE/module_table.cpp @@ -55,7 +55,6 @@ struct module_data_random { const char* name; }; - module_data_random module_data_random_data[] = { { -2, 0, CHARA_MIKU , 1935, 35031, "オール ランダム" }, { -3, 1, CHARA_MIKU , 1947, 35043, "初音ミク ランダム" }, @@ -82,11 +81,15 @@ module::~module() { } module_data::module_data() : id(), sort_index(), chara_index(), cos(), sleeve_l(), sleeve_r(), -spr_sel_md_id_spr_set_id(), spr_sel_md_id_cmn_spr_set_id(), spr_sel_md_id_cmn_md_img_id_spr_id(), +spr_sel_md_id_spr_set_id(), spr_sel_md_id_cmn_spr_set_id(), spr_sel_md_id_md_img_id_spr_id(), spr_sel_md_id_cmn_md_img_spr_id(), field_78(), field_79(), field_A0() { reset(); } +module_data::~module_data() { + +} + void module_data::reset() { id = -1; sort_index = 0; @@ -96,7 +99,7 @@ void module_data::reset() { sleeve_r = {}; spr_sel_md_id_spr_set_id = -1; spr_sel_md_id_cmn_spr_set_id = -1; - spr_sel_md_id_cmn_md_img_id_spr_id = -1; + spr_sel_md_id_md_img_id_spr_id = -1; spr_sel_md_id_cmn_md_img_spr_id = -1; field_78 = false; field_79 = false; @@ -360,14 +363,14 @@ void module_data_handler::add_modules() { mdl.spr_sel_md_id_cmn_spr_set_id = aft_spr_db->get_spr_set_by_name(buf)->id; sprintf_s(buf, sizeof(buf), "SPR_SEL_MD%03d_MD_IMG_%03d", mdl.id, mdl.id); - mdl.spr_sel_md_id_cmn_md_img_id_spr_id = aft_spr_db->get_spr_by_name(buf)->id; + mdl.spr_sel_md_id_md_img_id_spr_id = aft_spr_db->get_spr_by_name(buf)->id; sprintf_s(buf, sizeof(buf), "SPR_SEL_MD%03dCMN_MD_IMG", mdl.id); mdl.spr_sel_md_id_cmn_md_img_spr_id = aft_spr_db->get_spr_by_name(buf)->id; /*struc_684 v17; if (sub_1402B7880()->sub_1402B7550(i.second.id, v17)) { - mdl.field_78 = 1; + mdl.field_78 = true; mdl.field_79 = v17.field_4; mdl.name.assign(v17.name); mdl.field_A0 = v17.field_28; diff --git a/src/CRE/module_table.hpp b/src/CRE/module_table.hpp index 59a6ec7b..3b98493e 100644 --- a/src/CRE/module_table.hpp +++ b/src/CRE/module_table.hpp @@ -8,6 +8,7 @@ #include #include "../KKdLib/default.hpp" #include "../KKdLib/database/item_table.hpp" +#include "../KKdLib/prj/vector_pair_combine.hpp" #include "../KKdLib/prj/time.hpp" #include "rob/rob.hpp" @@ -31,7 +32,7 @@ struct module_data { rob_sleeve_data sleeve_r; int32_t spr_sel_md_id_spr_set_id; int32_t spr_sel_md_id_cmn_spr_set_id; - int32_t spr_sel_md_id_cmn_md_img_id_spr_id; + int32_t spr_sel_md_id_md_img_id_spr_id; int32_t spr_sel_md_id_cmn_md_img_spr_id; bool field_78; bool field_79; @@ -41,6 +42,7 @@ struct module_data { prj::time field_B0; module_data(); + ~module_data(); void reset(); }; diff --git a/src/CRE/ogg_vorbis.cpp b/src/CRE/ogg_vorbis.cpp index e24fe547..50ed8b51 100644 --- a/src/CRE/ogg_vorbis.cpp +++ b/src/CRE/ogg_vorbis.cpp @@ -302,7 +302,13 @@ void OggFile::ThreadMain(OggFile* of) { waitable_timer timer; while (!of->thread_state.get()) { - of->Ctrl(of->info ? of->info->rate : 44100); + int32_t rate = 44100; + { + std::unique_lock u_lock(of->file_mtx); + if (of->info) + rate = of->info->rate; + } + of->Ctrl(rate); timer.sleep(8); } of->thread_state.set(0); diff --git a/src/CRE/post_process.cpp b/src/CRE/post_process.cpp index abe7b679..3c788b67 100644 --- a/src/CRE/post_process.cpp +++ b/src/CRE/post_process.cpp @@ -204,6 +204,8 @@ void post_process::apply(camera* cam, texture* light_proj_tex, int32_t npr_param get_frame_texture(rend_texture.color_texture->tex, POST_PROCESS_FRAME_TEXTURE_POST_PP); + frame_texture_reset_capture(); + fbo::blit(rend_texture.fbos[0], post_texture.fbos[0], 0, 0, render_width, render_height, 0, 0, render_width, render_height, GL_COLOR_BUFFER_BIT, GL_LINEAR); @@ -698,6 +700,12 @@ void post_process::frame_texture_reset() { } } +void post_process::frame_texture_reset_capture() { + for (post_process_frame_texture& i : frame_texture) + if (&i - frame_texture) + i.capture = false; +} + bool post_process::frame_texture_slot_capture_set(int32_t index) { if (index < 1 || index >= 5) return false; @@ -745,8 +753,7 @@ void post_process::get_frame_texture(GLuint tex, post_process_frame_texture_type texture* dst_tex = j.texture; - glActiveTexture(GL_TEXTURE0); - gl_state_active_bind_texture_2d(GL_TEXTURE_2D, tex); + gl_state_active_bind_texture_2d(0, tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glViewport(0, 0, dst_tex->width, dst_tex->height); @@ -755,9 +762,6 @@ void post_process::get_frame_texture(GLuint tex, post_process_frame_texture_type render_texture::draw_quad(&shaders_ft, dst_tex->width, dst_tex->height); gl_state_bind_framebuffer(0); } - - if (&i - frame_texture) - i.capture = false; } } diff --git a/src/CRE/post_process.hpp b/src/CRE/post_process.hpp index 13746dd1..db153771 100644 --- a/src/CRE/post_process.hpp +++ b/src/CRE/post_process.hpp @@ -130,6 +130,7 @@ struct post_process { void frame_texture_free(); int32_t frame_texture_load(int32_t slot, post_process_frame_texture_type type, texture* tex); void frame_texture_reset(); + void frame_texture_reset_capture(); bool frame_texture_slot_capture_set(int32_t index); bool frame_texture_unload(int32_t slot, texture* tex); void get_frame_texture(GLuint tex, post_process_frame_texture_type type); diff --git a/src/CRE/render_context.cpp b/src/CRE/render_context.cpp index 2a3c2e16..5e140d9c 100644 --- a/src/CRE/render_context.cpp +++ b/src/CRE/render_context.cpp @@ -2016,6 +2016,10 @@ namespace mdl { uniform_value_reset(); gl_state_get(); + rctx_ptr->obj_scene_ubo.Bind(0); + rctx_ptr->obj_batch_ubo.Bind(1); + rctx_ptr->obj_skinning_ubo.Bind(3); + switch (type) { case OBJ_TYPE_TRANSLUCENT_ALPHA_ORDER_1: case OBJ_TYPE_TRANSLUCENT_ALPHA_ORDER_2: @@ -2042,9 +2046,8 @@ namespace mdl { case OBJ_KIND_NORMAL: { int32_t a = (int32_t)(i->args.sub_mesh.blend_color.w * 255.0f); a = clamp_def(a, 0, 255); - if (a == alpha) { + if (a == alpha) draw_sub_mesh(rctx_ptr, &i->args.sub_mesh, &i->mat, func); - } } break; case OBJ_KIND_TRANSLUCENT: { for (uint32_t j = 0; j < i->args.translucent.count; j++) { @@ -3581,8 +3584,10 @@ void render_context::disp() { app::TaskWork::Disp(); render_manager.shadow_ptr->ctrl(this); int32_t sprite_index = sprite_manager_get_index(); - sprite_manager_set_index(3); - //dw_gui_ctrl_disp(); + //sprite_manager_set_index(3); + sprite_manager_set_index(0); + extern void dw_gui_ctrl_disp(); + dw_gui_ctrl_disp(); sprite_manager_set_index(sprite_index); post_process.ctrl(camera); render_manager.render_all(this); diff --git a/src/CRE/render_manager.cpp b/src/CRE/render_manager.cpp index a70e49b9..c152b1d9 100644 --- a/src/CRE/render_manager.cpp +++ b/src/CRE/render_manager.cpp @@ -1453,12 +1453,12 @@ static void draw_pass_3d_translucent(render_context* rctx, bool opaque_enable, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); if (opaque_enable && rctx->disp_manager.get_obj_count(opaque)) - rctx->disp_manager.draw(opaque, alpha); + rctx->disp_manager.draw_translucent(opaque, alpha); if (transparent_enable && rctx->disp_manager.get_obj_count(transparent)) - rctx->disp_manager.draw(transparent, alpha); + rctx->disp_manager.draw_translucent(transparent, alpha); if (translucent_enable && rctx->disp_manager.get_obj_count(translucent)) { gl_state_enable_blend(); - rctx->disp_manager.draw(translucent, alpha); + rctx->disp_manager.draw_translucent(translucent, alpha); gl_state_disable_blend(); } @@ -1501,10 +1501,19 @@ static int32_t draw_pass_3d_translucent_count_layers(render_context* rctx, static void draw_pass_3d_translucent_has_objects(render_context* rctx, bool* arr, mdl::ObjType type) { std::vector& vec = rctx->disp_manager.obj[type]; for (mdl::ObjData*& i : vec) - if (i->kind == mdl::OBJ_KIND_TRANSLUCENT) { + switch (i->kind) { + case mdl::OBJ_KIND_NORMAL: { int32_t alpha = (int32_t)(i->args.sub_mesh.blend_color.w * 255.0f); alpha = clamp_def(alpha, 0, 255); arr[alpha] = true; + } break; + case mdl::OBJ_KIND_TRANSLUCENT: { + for (uint32_t j = 0; j < i->args.translucent.count; j++) { + int32_t alpha = (int32_t)(i->args.translucent.sub_mesh[j]->blend_color.w * 255.0f); + alpha = clamp_def(alpha, 0, 255); + arr[alpha] = true; + } + } break; } } diff --git a/src/CRE/rob/rob.cpp b/src/CRE/rob/rob.cpp index e852d9c6..7927b9ea 100644 --- a/src/CRE/rob/rob.cpp +++ b/src/CRE/rob/rob.cpp @@ -2230,7 +2230,7 @@ float_t chara_size_table_get_value(uint32_t index) { 1.07f, 1.0f, 0.96f, 0.987f, 1.025f, 1.045f }; - if (index >= 0 && index <= 4) + if (index >= 0 && index < 5) return chara_size_table[index]; return 1.0f; } @@ -2240,7 +2240,7 @@ float_t chara_pos_adjust_y_table_get_value(uint32_t index) { 0.071732f, 0.0f, -0.03859f, 0.0f, 0.0f }; - if (index >= 0 && index <= 4) + if (index >= 0 && index < 5) return chara_pos_adjust_y_table[index]; return 0.0f; } @@ -3115,7 +3115,7 @@ static void mothead_apply2_inner(struc_380* a1, int32_t type, const mothead_data } break; case 40: { v19->field_0.field_238 = ((int16_t*)v35)[0]; - if ((a1->rob_chara_data->motion.field_28 & 8) != 0) + if (a1->rob_chara_data->motion.field_28 & 0x08) v19->field_0.field_23C = -((float_t*)v35)[1]; else v19->field_0.field_23C = ((float_t*)v35)[1]; @@ -3129,14 +3129,14 @@ static void mothead_apply2_inner(struc_380* a1, int32_t type, const mothead_data } break; case 46: { if (v19->field_0.field_10.field_0 & 0x100) { - if (a1->rob_chara_data->motion.field_28 & 8) + if (a1->rob_chara_data->motion.field_28 & 0x08) v19->field_0.field_274 = -((int16_t*)v35)[0]; else v19->field_0.field_274 = ((int16_t*)v35)[0]; } } break; case 51: { - if (a1->rob_chara_data->motion.field_28 & 8) + if (a1->rob_chara_data->motion.field_28 & 0x08) v19->field_0.field_2B8 = -((int16_t*)v35)[0]; else v19->field_0.field_2B8 = ((int16_t*)v35)[0]; @@ -3148,7 +3148,7 @@ static void mothead_apply2_inner(struc_380* a1, int32_t type, const mothead_data } break; case 64: { float_t v31 = ((float_t*)v35)[0]; - if (a1->rob_chara_data->motion.field_28 & 8) + if (a1->rob_chara_data->motion.field_28 & 0x08) v31 = -v31; v19->field_0.field_318.x = v31; v19->field_0.field_318.y = ((float_t*)v35)[1]; @@ -3337,7 +3337,7 @@ void rob_chara::load_motion(uint32_t motion_id, bool a3, float_t frame, data.motion.step_data.frame = data.motion.step_data.step; float_t step = data.motion.step; - if (data.motion.step < 0.0f) + if (step < 0.0f) step = data.motion.step_data.frame; item_equip->set_osage_step(step); @@ -4310,7 +4310,7 @@ void rob_chara::set_step_motion_step(float_t value) { rob_chara_bone_data_set_step(bone_data, data.motion.step_data.frame); float_t step = data.motion.step; - if (data.motion.step < 0.0f) + if (step < 0.0f) step = data.motion.step_data.frame; item_equip->set_osage_step(step); } @@ -5420,7 +5420,6 @@ static void bone_data_parent_load_rob_chara(bone_data_parent* bone) { bone->ik_bone_count = rob_bone_data->ik_bone_count; bone->chain_pos = rob_bone_data->chain_pos; bone->bones.clear(); - bone->bones.shrink_to_fit(); bone->bones.resize(rob_bone_data->motion_bone_count); bone->global_key_set_count = 6; bone->bone_key_set_count = (uint32_t)((bone->motion_bone_count + bone->ik_bone_count) * 3); @@ -5792,7 +5791,7 @@ static void mothead_func_2(mothead_func_data* func_data, void* data, const mothead_data* mhd_data, int32_t frame, const motion_database* mot_db) { func_data->rob_chr_data->field_1588.field_0.field_20.field_0 |= 0x100; rob_chara_data* rob_chr_data = func_data->rob_chr_data; - if (rob_chr_data->motion.field_28 & 8) + if (rob_chr_data->motion.field_28 & 0x08) rob_chr_data->field_1588.field_0.field_274 -= ((int16_t*)data)[0]; else rob_chr_data->field_1588.field_0.field_274 += ((int16_t*)data)[0]; @@ -6545,7 +6544,7 @@ static void mothead_func_62_rob_parts_adjust(mothead_func_data* func_data, v16.reset(); int8_t type = ((int8_t*)data)[5]; - if (type >= 0 && type <= 5) { + if (type >= 0 && type < 6) { float_t set_frame = (float_t)mhd_data->frame; v16.enable = true; v16.frame = rob_chr->data.motion.frame_data.frame - set_frame; @@ -6738,7 +6737,7 @@ static void mothead_func_75_rob_adjust_global(mothead_func_data* func_data, v14.reset(); int8_t type = ((int8_t*)data)[4]; - if (type >= 0 && type <= 5) { + if (type >= 0 && type < 6) { float_t set_frame = (float_t)mhd_data->frame; v14.enable = true; v14.frame = rob_chr->data.motion.frame_data.frame - set_frame; @@ -7530,7 +7529,7 @@ static void sub_1405145F0(rob_chara* rob_chr, const bone_database* bone_data, co return; float_t frame; - if (rob_chr->data.motion.field_28 >= 0) + if (!(rob_chr->data.motion.field_28 & 0x80)) frame = 0.0f; else frame = rob_chr->data.motion.frame_data.last_set_frame; @@ -7538,7 +7537,7 @@ static void sub_1405145F0(rob_chara* rob_chr, const bone_database* bone_data, co rob_chr->data.field_8.field_4.field_10, frame, MOTION_BLEND, bone_data, mot_db); rob_chara_bone_data_set_motion_duration(rob_chr->bone_data, 0.0f, 1.0f, 1.0f); rob_chr->set_motion_reset_data(rob_chr->data.field_8.field_4.motion_id, 0.0f); - rob_chr->data.field_8.field_0++; + rob_chr->data.field_8.field_0 = 1; } static void sub_1405144C0(rob_chara* rob_chr, const bone_database* bone_data, const motion_database* mot_db) { @@ -8147,7 +8146,7 @@ static void sub_140504AC0(rob_chara* rob_chr) { v4.y = rob_chr->data.field_8.field_B8.field_10.y - get_osage_gravity_const() * rob_chr->data.field_1588.field_0.field_200; } - else if (rob_chr->data.field_1 >= 0) { + else if (!(rob_chr->data.field_1 & 0x80)) { vec3 v20 = rob_chr->data.miku_rot.field_3C; v20.x += v4.x + rob_chr->data.field_8.field_B8.field_10.x; v20.z += v4.z + rob_chr->data.field_8.field_B8.field_10.z; @@ -10303,21 +10302,18 @@ static void rob_chara_bone_data_motion_blend_mot_list_init(rob_chara_bone_data* static void rob_chara_bone_data_reserve(rob_chara_bone_data* rob_bone_data) { rob_bone_data->mats.clear(); - rob_bone_data->mats.shrink_to_fit(); rob_bone_data->mats.resize(rob_bone_data->object_bone_count); for (mat4& i : rob_bone_data->mats) i = mat4_identity; rob_bone_data->mats2.clear(); - rob_bone_data->mats2.shrink_to_fit(); rob_bone_data->mats2.resize(rob_bone_data->total_bone_count - rob_bone_data->object_bone_count); for (mat4& i : rob_bone_data->mats2) i = mat4_identity; rob_bone_data->nodes.clear(); - rob_bone_data->nodes.shrink_to_fit(); rob_bone_data->nodes.resize(rob_bone_data->total_bone_count); } @@ -18667,7 +18663,7 @@ bool TaskRobBase::Ctrl() { rob_thread_handler->sub_14054E3F0(); for (rob_chara*& i : ctrl_chara) - if (i && i->data.field_3 >= 0) + if (i && !(i->data.field_3 & 0x80)) rob_base_rob_chara_ctrl(i); for (rob_chara*& i : free_chara) @@ -18730,7 +18726,7 @@ bool TaskRobCollision::Ctrl() { } /*for (rob_chara*& i : ctrl_chara) - if (i && i->data.field_3 >= 0) + if (i && !(i->data.field_3 & 0x80)) sub_14050EA90(v13);*/ } @@ -18777,11 +18773,11 @@ bool TaskRobDisp::Ctrl() { init_chara.clear(); for (rob_chara*& i : ctrl_chara) - if (i && i->data.field_3 >= 0) + if (i && !(i->data.field_3 & 0x80)) rob_disp_rob_chara_ctrl(i); for (rob_chara*& i : ctrl_chara) - if (i && i->data.field_3 >= 0) + if (i && !(i->data.field_3 & 0x80)) rob_thread_handler->AppendRobCharaFunc(i->chara_id, i, rob_disp_rob_chara_ctrl_thread_main); @@ -18826,7 +18822,7 @@ void TaskRobDisp::Disp() { if (pv_osage_manager_array_get_disp(&chara_id)) continue; - if (i->is_visible() && i->data.field_3 >= 0) + if (i->is_visible() && !(i->data.field_3 & 0x80)) rob_disp_rob_chara_disp(i); } } @@ -18857,7 +18853,7 @@ bool TaskRobInfo::Ctrl() { init_chara.clear(); for (rob_chara*& i : ctrl_chara) - if (i && i->data.field_3 >= 0) + if (i && !(i->data.field_3 & 0x80)) i->rob_info_ctrl(); free_chara.clear(); @@ -19585,6 +19581,72 @@ bool TaskRobMotionModifier::Init() { return true; } +static void sub_1405484A0(rob_chara* rob_chr) { + rob_chr->data.motion.step_data.field_4 = rob_chr->data.motion.step_data.frame; + + if (rob_chr->data.motion.step_data.step < 0.0f) + rob_chr->data.motion.step_data.frame = 1.0f; + else + rob_chr->data.motion.step_data.frame = rob_chr->data.motion.step_data.step; + + rob_chara_bone_data_set_step(rob_chr->bone_data, rob_chr->data.motion.step_data.frame); + + float_t step = rob_chr->data.motion.step; + if (step < 0.0f) + step = rob_chr->data.motion.step_data.frame; + rob_chr->item_equip->set_osage_step(step); + + if (!(rob_chr->data.motion.field_28 & 0x40)) { + if (rob_chr->data.field_8.field_B8.field_7C > 0.0f) + rob_chr->data.motion.step_data.frame = rob_chr->data.field_8.field_B8.field_80; + return; + } + + if (!rob_chr->data.field_1588.field_0.field_298) + return; + + if (!rob_chr->field_20 || rob_chr->data.motion.frame_data.frame >= rob_chr->data.field_1588.field_0.field_29C) { + rob_chr->data.motion.step_data.frame = 1.0f; + rob_chr->data.motion.field_28 &= ~0x40; + return; + } + + float_t v6 = 1.0f; + /*size_t v7 = rob_chr->field_20; + if (rob_chr->data.field_1588.field_0.field_298 & 0x200 + || (stru_140A2E410[*(int32_t*)(v7 + 6744)][rob_chr->data.field_1588.field_0.field_298 & 0xFF] + && *(int32_t*)(v7 + 6736) & 0x02)) { + float_t v11 = rob_chr->data.field_1588.field_0.field_2A4; + switch (rob_chr->data.field_1588.field_0.field_2A0) { + case 1: + v11 += *(float_t*)(v7 + 6608); + break; + case 2: + v11 += *(float_t*)(v7 + 6720); + break; + case 3: + v11 += *(float_t*)(v7 + 6724); + break; + case 4: + v11 += *(float_t*)(v7 + 6728); + break; + } + + float_t v12 = v11 - *(float_t*)(v7 + 1752); + if (v12 > 0.0f) + v6 = (rob_chr->data.field_1588.field_0.field_29C - rob_chr->data.motion.frame_data.frame) / v12; + }*/ + + if (v6 < rob_chr->data.field_1588.field_0.field_2A8) + v6 = rob_chr->data.field_1588.field_0.field_2A8; + + if (v6 <= rob_chr->data.field_1588.field_0.field_2AC) + rob_chr->data.motion.step_data.frame = v6; + else + rob_chr->data.motion.step_data.frame = rob_chr->data.field_1588.field_0.field_2AC; + return; +} + bool TaskRobMotionModifier::Ctrl() { if (pv_osage_manager_array_get_disp()) return false; @@ -19594,9 +19656,9 @@ bool TaskRobMotionModifier::Ctrl() { AppendCtrlCharaList(i); init_chara.clear(); - /*for (rob_chara*& i : ctrl_chara) + for (rob_chara*& i : ctrl_chara) if (i) - sub_1405484A0(i);*/ + sub_1405484A0(i); for (rob_chara*& i : ctrl_chara) if (i) @@ -19729,7 +19791,7 @@ static void sub_14053F300(RobPartialMotion* a1) { static void sub_140548660(rob_chara* rob_chr) { rob_chr->data.motion.frame_data.prev_frame = rob_chr->data.motion.frame_data.frame; rob_chr->bone_data->sub_14041DBA0(); - if (rob_chr->data.motion.field_28 < 0) + if (rob_chr->data.motion.field_28 & 0x80) rob_chr->bone_data->set_frame(rob_chr->data.motion.frame_data.last_set_frame); rob_chr->data.motion.frame_data.frame = rob_chr->bone_data->get_frame(); sub_14053F300(&rob_chr->data.motion.field_150.face); @@ -19763,9 +19825,9 @@ bool TaskRobPrepareControl::Ctrl() { AppendCtrlCharaList(i); init_chara.clear(); - /*for (rob_chara*& i : ctrl_chara) + for (rob_chara*& i : ctrl_chara) if (i) - sub_1405484A0(i);*/ + sub_1405484A0(i); for (rob_chara*& i : ctrl_chara) if (i) { diff --git a/src/CRE/rob/rob.hpp b/src/CRE/rob/rob.hpp index 7fbb9a20..07293236 100644 --- a/src/CRE/rob/rob.hpp +++ b/src/CRE/rob/rob.hpp @@ -2837,9 +2837,9 @@ struct rob_chara_motion { struc_406 step_data; float_t step; int32_t field_24; - int8_t field_28; - int8_t field_29; - int8_t field_2A; + uint8_t field_28; + uint8_t field_29; + uint8_t field_2A; int32_t loop_index; uint32_t field_30; int16_t field_34; diff --git a/src/CRE/sprite.cpp b/src/CRE/sprite.cpp index e16227f1..eb3158ec 100644 --- a/src/CRE/sprite.cpp +++ b/src/CRE/sprite.cpp @@ -732,12 +732,13 @@ namespace spr { int32_t x_max; int32_t y_max; if (index == 0 || index == 3) { - camera* cam = rctx->camera; - float_t sprite_half_width = (float_t)cam->sprite_width * 0.5f; - float_t sprite_half_height = (float_t)cam->sprite_height * 0.5f; + resolution_struct* res_wind = res_window_get(); - float_t aet_depth = cam->aet_depth; - float_t aet_depth_1 = 1.0f / cam->aet_depth; + float_t sprite_half_width = (float_t)res_wind->width * 0.5f; + float_t sprite_half_height = (float_t)res_wind->height * 0.5f; + + float_t aet_depth = rctx->camera->aet_depth; + float_t aet_depth_1 = 1.0f / aet_depth; float_t v15a = sprite_half_height * aspect[i] * 0.2f * aet_depth_1; float_t v15b = sprite_half_height * 0.2f * aet_depth_1; @@ -1513,6 +1514,9 @@ namespace spr { vertex_buffer.push_back(spr_vtx); } } break; + default: + draw_param_buffer.pop_back(); + return; } break; case 1: @@ -1679,8 +1683,7 @@ namespace spr { sprite_draw_param& draw_param_2 = draw_param_buffer.data()[draw_param_buffer.size() - 2]; sprite_draw_param& draw_param_1 = draw_param_buffer.data()[draw_param_buffer.size() - 1]; - if ((args.index == -1 || args.index == 0 || args.index == 3) - && draw_param_2.mode == draw_param_1.mode + if (draw_param_2.mode == draw_param_1.mode && draw_param_2.blend == draw_param_1.blend && draw_param_2.blend_src_rgb == draw_param_1.blend_src_rgb && draw_param_2.blend_src_alpha == draw_param_1.blend_src_alpha diff --git a/src/CRE/task_effect.cpp b/src/CRE/task_effect.cpp index aba43c0d..40ec3dc6 100644 --- a/src/CRE/task_effect.cpp +++ b/src/CRE/task_effect.cpp @@ -62,6 +62,13 @@ struct particle_data { float_t size; }; +struct particle_scene_shader_data { + vec4 g_transform[4]; + vec4 g_view_pos; + vec4 g_light_env_chara_diffuse; + vec4 g_light_env_chara_specular; +}; + struct particle_vertex_data { vec3 position; vec3 normal; @@ -256,6 +263,7 @@ static vec3 particle_wind; static particle_data* ptcl_data; static GLuint ptcl_vao; static GLuint ptcl_vbo; +static GL::UniformBuffer particle_scene_ubo; static const size_t ptcl_count = 0x400; static bool rain_particle_enable; @@ -2401,8 +2409,23 @@ void particle_draw() { if (!count) return; - gl_state_bind_vertex_array(ptcl_vao); + const light_data& light_chara = rctx_ptr->light_set[LIGHT_SET_MAIN].lights[LIGHT_CHARA]; + + particle_scene_shader_data shader_data = {}; + mat4 temp; + mat4_transpose(&rctx_ptr->vp_mat, &temp); + shader_data.g_transform[0] = temp.row0; + shader_data.g_transform[1] = temp.row1; + shader_data.g_transform[2] = temp.row2; + shader_data.g_transform[3] = temp.row3; + rctx_ptr->camera->get_view_point(shader_data.g_view_pos); + light_chara.get_diffuse(shader_data.g_light_env_chara_diffuse); + light_chara.get_specular(shader_data.g_light_env_chara_specular); + particle_scene_ubo.WriteMapMemory(shader_data); + shaders_ft.set(SHADER_FT_PARTICL); + particle_scene_ubo.Bind(0); + gl_state_bind_vertex_array(ptcl_vao); shaders_ft.draw_arrays(GL_TRIANGLES, 0, count); gl_state_bind_vertex_array(0); } @@ -3194,6 +3217,7 @@ static void leaf_particle_init(bool change_stage) { gl_state_bind_vertex_array(0); gl_state_bind_array_buffer(0); gl_state_bind_element_array_buffer(0); + leaf_particle_scene_ubo.Create(sizeof(leaf_particle_scene_shader_data)); } @@ -3461,6 +3485,8 @@ static void particle_init(vec3* offset) { gl_state_bind_vertex_array(0); gl_state_bind_array_buffer(0); + + particle_scene_ubo.Create(sizeof(particle_scene_shader_data)); } static void particle_ctrl() { @@ -3660,6 +3686,8 @@ static void particle_free() { glDeleteBuffers(1, &ptcl_vbo); ptcl_vbo = 0; } + + particle_scene_ubo.Destroy(); } static void rain_particle_init(bool change_stage) { diff --git a/src/KKdLib/mat.cpp b/src/KKdLib/mat.cpp index 755cc49c..7605f7cb 100644 --- a/src/KKdLib/mat.cpp +++ b/src/KKdLib/mat.cpp @@ -49,80 +49,57 @@ inline void mat3_mult(const mat3* x, const mat3* y, mat3* z) { __m128 t1; __m128 t2; __m128 yt; - __m128 zt; __m128 xt0; __m128 xt1; __m128 xt2; - *(vec3*)&xt0 = x->row0; - *(vec3*)&xt1 = x->row1; - *(vec3*)&xt2 = x->row2; - *(vec3*)&yt = y->row0; + xt0 = vec3::load_xmm(x->row0); + xt1 = vec3::load_xmm(x->row1); + xt2 = vec3::load_xmm(x->row2); + yt = vec3::load_xmm(y->row0); t0 = _mm_mul_ps(xt0, _mm_shuffle_ps(yt, yt, 0x00)); t1 = _mm_mul_ps(xt1, _mm_shuffle_ps(yt, yt, 0x55)); t2 = _mm_mul_ps(xt2, _mm_shuffle_ps(yt, yt, 0xAA)); - zt = _mm_add_ps(_mm_add_ps(t0, t1), t2); - z->row0 = *(vec3*)&zt; - *(vec3*)&yt = y->row1; + z->row0 = vec3::store_xmm(_mm_add_ps(_mm_add_ps(t0, t1), t2)); + yt = vec3::load_xmm(y->row1); t0 = _mm_mul_ps(xt0, _mm_shuffle_ps(yt, yt, 0x00)); t1 = _mm_mul_ps(xt1, _mm_shuffle_ps(yt, yt, 0x55)); t2 = _mm_mul_ps(xt2, _mm_shuffle_ps(yt, yt, 0xAA)); - zt = _mm_add_ps(_mm_add_ps(t0, t1), t2); - z->row1 = *(vec3*)&zt; - *(vec3*)&yt = y->row2; + z->row1 = vec3::store_xmm(_mm_add_ps(_mm_add_ps(t0, t1), t2)); + yt = vec3::load_xmm(y->row2); t0 = _mm_mul_ps(xt0, _mm_shuffle_ps(yt, yt, 0x00)); t1 = _mm_mul_ps(xt1, _mm_shuffle_ps(yt, yt, 0x55)); t2 = _mm_mul_ps(xt2, _mm_shuffle_ps(yt, yt, 0xAA)); - zt = _mm_add_ps(_mm_add_ps(t0, t1), t2); - z->row2 = *(vec3*)&zt; + z->row2 = vec3::store_xmm(_mm_add_ps(_mm_add_ps(t0, t1), t2)); } inline void mat3_mult_vec2(const mat3* x, const vec2* y, vec2* z) { - __m128 xt; __m128 yt; - __m128 zt; __m128 zt0; __m128 zt1; - *(vec2*)&yt = *y; - *(vec3*)&xt = x->row0; - zt0 = _mm_mul_ps(xt, _mm_shuffle_ps(yt, yt, 0x00)); - *(vec3*)&xt = x->row1; - zt1 = _mm_mul_ps(xt, _mm_shuffle_ps(yt, yt, 0x55)); - zt = _mm_add_ps(zt0, zt1); - *z = *(vec2*)&zt; + yt = vec2::load_xmm(*y); + zt0 = _mm_mul_ps(vec3::load_xmm(x->row0), _mm_shuffle_ps(yt, yt, 0x00)); + zt1 = _mm_mul_ps(vec3::load_xmm(x->row1), _mm_shuffle_ps(yt, yt, 0x55)); + *z = vec2::store_xmm(_mm_add_ps(zt0, zt1)); } inline void mat3_mult_vec(const mat3* x, const vec3* y, vec3* z) { - __m128 xt; __m128 yt; - __m128 zt; __m128 zt0; __m128 zt1; __m128 zt2; - *(vec3*)&yt = *y; - *(vec3*)&xt = x->row0; - zt0 = _mm_mul_ps(xt, _mm_shuffle_ps(yt, yt, 0x00)); - *(vec3*)&xt = x->row1; - zt1 = _mm_mul_ps(xt, _mm_shuffle_ps(yt, yt, 0x55)); - *(vec3*)&xt = x->row2; - zt2 = _mm_mul_ps(xt, _mm_shuffle_ps(yt, yt, 0xAA)); - zt = _mm_add_ps(_mm_add_ps(zt0, zt1), zt2); - *z = *(vec3*)&zt; + yt = vec3::load_xmm(*y); + zt0 = _mm_mul_ps(vec3::load_xmm(x->row0), _mm_shuffle_ps(yt, yt, 0x00)); + zt1 = _mm_mul_ps(vec3::load_xmm(x->row1), _mm_shuffle_ps(yt, yt, 0x55)); + zt2 = _mm_mul_ps(vec3::load_xmm(x->row2), _mm_shuffle_ps(yt, yt, 0xAA)); + *z = vec3::store_xmm(_mm_add_ps(_mm_add_ps(zt0, zt1), zt2)); } inline void mat3_mult_scalar(const mat3* x, float_t y, mat3* z) { - __m128 xt; __m128 yt; - __m128 zt; yt = vec4::load_xmm(y); - *(vec3*)&xt = x->row0; - zt = _mm_mul_ps(xt, yt); - z->row0 = *(vec3*)&zt; - *(vec3*)&xt = x->row1; - zt = _mm_mul_ps(xt, yt); - z->row1 = *(vec3*)&zt; - *(vec3*)&xt = x->row2; - zt = _mm_mul_ps(xt, yt); - z->row2 = *(vec3*)&zt; + z->row0 = vec3::store_xmm(_mm_mul_ps(vec3::load_xmm(x->row0), yt)); + z->row1 = vec3::store_xmm(_mm_mul_ps(vec3::load_xmm(x->row1), yt)); + z->row2 = vec3::store_xmm(_mm_mul_ps(vec3::load_xmm(x->row2), yt)); } inline void mat3_transpose(const mat3* x, mat3* z) { @@ -134,9 +111,6 @@ inline void mat3_transpose(const mat3* x, mat3* z) { __m128 yt1; __m128 yt2; __m128 yt3; - __m128 zt0; - __m128 zt1; - __m128 zt2; xt0 = vec3::load_xmm(x->row0); xt1 = vec3::load_xmm(x->row1); xt2 = vec3::load_xmm(x->row2); @@ -145,19 +119,15 @@ inline void mat3_transpose(const mat3* x, mat3* z) { yt1 = _mm_unpackhi_ps(xt0, xt1); yt2 = _mm_unpacklo_ps(xt2, xt3); yt3 = _mm_unpackhi_ps(xt2, xt3); - zt0 = _mm_movelh_ps(yt0, yt2); - zt1 = _mm_movehl_ps(yt2, yt0); - zt2 = _mm_movelh_ps(yt1, yt3); - z->row0 = *(vec3*)&zt0; - z->row1 = *(vec3*)&zt1; - z->row2 = *(vec3*)&zt2; + z->row0 = vec3::store_xmm(_mm_movelh_ps(yt0, yt2)); + z->row1 = vec3::store_xmm(_mm_movehl_ps(yt2, yt0)); + z->row2 = vec3::store_xmm(_mm_movelh_ps(yt1, yt3)); } void mat3_inverse(const mat3* x, mat3* z) { vec3 xt0; vec3 xt1; vec3 xt2; - __m128 yt; __m128 zt0; __m128 zt1; __m128 zt2; @@ -197,19 +167,15 @@ void mat3_inverse(const mat3* x, mat3* z) { ); wt = _mm_movelh_ps(_mm_unpacklo_ps(zt0, zt1), zt2); - yt = vec3::load_xmm(xt0); - wt = _mm_mul_ps(yt, wt); + wt = _mm_mul_ps(vec3::load_xmm(xt0), wt); wt = _mm_hadd_ps(wt, wt); wt = _mm_hadd_ps(wt, wt); if (_mm_cvtss_f32(wt) != 0.0f) wt = _mm_div_ss(_mm_set_ss(1.0f), wt); wt = _mm_shuffle_ps(wt, wt, 0); - yt = _mm_mul_ps(zt0, wt); - z->row0 = *(vec3*)&yt; - yt = _mm_mul_ps(zt1, wt); - z->row1 = *(vec3*)&yt; - yt = _mm_mul_ps(zt2, wt); - z->row2 = *(vec3*)&yt; + z->row0 = vec3::store_xmm(_mm_mul_ps(zt0, wt)); + z->row1 = vec3::store_xmm(_mm_mul_ps(zt1, wt)); + z->row2 = vec3::store_xmm(_mm_mul_ps(zt2, wt)); } inline void mat3_invtrans(const mat3* x, mat3* z) { @@ -224,23 +190,12 @@ inline void mat3_inverse_normalized(const mat3* x, mat3* z) { } inline void mat3_normalize(const mat3* x, mat3* z) { - __m128 det; - __m128 xt0; - __m128 xt1; - __m128 xt2; - det = _mm_set_ss(mat3_determinant(x)); - if (_mm_cvtss_f32(det) != 0.0f) - det = _mm_div_ss(_mm_set_ss(1.0f), det); - det = _mm_shuffle_ps(det, det, 0); - *(vec3*)&xt0 = x->row0; - *(vec3*)&xt1 = x->row1; - *(vec3*)&xt2 = x->row2; - xt0 = _mm_mul_ps(xt0, det); - xt1 = _mm_mul_ps(xt1, det); - xt2 = _mm_mul_ps(xt2, det); - z->row0 = *(vec3*)&xt0; - z->row1 = *(vec3*)&xt1; - z->row2 = *(vec3*)&xt2; + float_t det = mat3_determinant(x); + if (det != 0.0f) + det = 1.0f / det; + z->row0 = x->row0 * det; + z->row1 = x->row1 * det; + z->row2 = x->row2 * det; } inline void mat3_normalize_rotation(const mat3* x, mat3* z) { @@ -421,19 +376,16 @@ inline void mat3_rotate_x_mult_sin_cos(const mat3* x, float_t sin_val, float_t c __m128 y0; __m128 y1; __m128 y2; - __m128 zt; - *(vec3*)&y0 = x->row0; - *(vec3*)&y1 = x->row1; - *(vec3*)&y2 = x->row2; - z->row0 = *(vec3*)&y0; + y0 = vec3::load_xmm(x->row0); + y1 = vec3::load_xmm(x->row1); + y2 = vec3::load_xmm(x->row2); + z->row0 = vec3::store_xmm(y0); t1 = _mm_mul_ps(y1, vec4::load_xmm(cos_val)); t2 = _mm_mul_ps(y2, vec4::load_xmm(sin_val)); - zt = _mm_add_ps(t1, t2); - z->row1 = *(vec3*)&zt; + z->row1 = vec3::store_xmm(_mm_add_ps(t1, t2)); t1 = _mm_mul_ps(y1, vec4::load_xmm(-sin_val)); t2 = _mm_mul_ps(y2, vec4::load_xmm(cos_val)); - zt = _mm_add_ps(t1, t2); - z->row2 = *(vec3*)&zt; + z->row2 = vec3::store_xmm(_mm_add_ps(t1, t2)); } inline void mat3_rotate_y_mult_sin_cos(const mat3* x, float_t sin_val, float_t cos_val, mat3* z) { @@ -442,19 +394,16 @@ inline void mat3_rotate_y_mult_sin_cos(const mat3* x, float_t sin_val, float_t c __m128 y0; __m128 y1; __m128 y2; - __m128 zt; - *(vec3*)&y0 = x->row0; - *(vec3*)&y1 = x->row1; - *(vec3*)&y2 = x->row2; + y0 = vec3::load_xmm(x->row0); + y1 = vec3::load_xmm(x->row1); + y2 = vec3::load_xmm(x->row2); t0 = _mm_mul_ps(y0, vec4::load_xmm(cos_val)); t2 = _mm_mul_ps(y2, vec4::load_xmm(-sin_val)); - zt = _mm_add_ps(t0, t2); - z->row0 = *(vec3*)&zt; - z->row1 = *(vec3*)&y1; + z->row0 = vec3::store_xmm(_mm_add_ps(t0, t2)); + z->row1 = vec3::store_xmm(y1); t0 = _mm_mul_ps(y0, vec4::load_xmm(sin_val)); t2 = _mm_mul_ps(y2, vec4::load_xmm(cos_val)); - zt = _mm_add_ps(t0, t2); - z->row2 = *(vec3*)&zt; + z->row2 = vec3::store_xmm(_mm_add_ps(t0, t2)); } inline void mat3_rotate_z_mult_sin_cos(const mat3* x, float_t sin_val, float_t cos_val, mat3* z) { @@ -463,19 +412,16 @@ inline void mat3_rotate_z_mult_sin_cos(const mat3* x, float_t sin_val, float_t c __m128 y0; __m128 y1; __m128 y2; - __m128 zt; - *(vec3*)&y0 = x->row0; - *(vec3*)&y1 = x->row1; - *(vec3*)&y2 = x->row2; + y0 = vec3::load_xmm(x->row0); + y1 = vec3::load_xmm(x->row1); + y2 = vec3::load_xmm(x->row2); t0 = _mm_mul_ps(y0, vec4::load_xmm(cos_val)); t1 = _mm_mul_ps(y1, vec4::load_xmm(sin_val)); - zt = _mm_add_ps(t0, t1); - z->row0 = *(vec3*)&zt; + z->row0 = vec3::store_xmm(_mm_add_ps(t0, t1)); t0 = _mm_mul_ps(y0, vec4::load_xmm(-sin_val)); t1 = _mm_mul_ps(y1, vec4::load_xmm(cos_val)); - zt = _mm_add_ps(t0, t1); - z->row1 = *(vec3*)&zt; - z->row2 = *(vec3*)&y2; + z->row1 = vec3::store_xmm(_mm_add_ps(t0, t1)); + z->row2 = vec3::store_xmm(y2); } inline void mat3_rotate_x(float_t x, mat3* y) { @@ -592,21 +538,18 @@ inline void mat3_rotate_x_mult(const mat3* x, float_t y, mat3* z) { __m128 y0; __m128 y1; __m128 y2; - __m128 zt; float_t y_sin = sinf(y); float_t y_cos = cosf(y); - *(vec3*)&y0 = x->row0; - *(vec3*)&y1 = x->row1; - *(vec3*)&y2 = x->row2; - z->row0 = *(vec3*)&y0; + y0 = vec3::load_xmm(x->row0); + y1 = vec3::load_xmm(x->row1); + y2 = vec3::load_xmm(x->row2); + z->row0 = vec3::store_xmm(y0); t1 = _mm_mul_ps(y1, vec4::load_xmm(y_cos)); t2 = _mm_mul_ps(y2, vec4::load_xmm(y_sin)); - zt = _mm_add_ps(t1, t2); - z->row1 = *(vec3*)&zt; + z->row1 = vec3::store_xmm(_mm_add_ps(t1, t2)); t1 = _mm_mul_ps(y1, vec4::load_xmm(-y_sin)); t2 = _mm_mul_ps(y2, vec4::load_xmm(y_cos)); - zt = _mm_add_ps(t1, t2); - z->row2 = *(vec3*)&zt; + z->row2 = vec3::store_xmm(_mm_add_ps(t1, t2)); } inline void mat3_rotate_y_mult(const mat3* x, float_t y, mat3* z) { @@ -615,21 +558,18 @@ inline void mat3_rotate_y_mult(const mat3* x, float_t y, mat3* z) { __m128 y0; __m128 y1; __m128 y2; - __m128 zt; float_t y_sin = sinf(y); float_t y_cos = cosf(y); - *(vec3*)&y0 = x->row0; - *(vec3*)&y1 = x->row1; - *(vec3*)&y2 = x->row2; + y0 = vec3::load_xmm(x->row0); + y1 = vec3::load_xmm(x->row1); + y2 = vec3::load_xmm(x->row2); t0 = _mm_mul_ps(y0, vec4::load_xmm(y_cos)); t2 = _mm_mul_ps(y2, vec4::load_xmm(-y_sin)); - zt = _mm_add_ps(t0, t2); - z->row0 = *(vec3*)&zt; - z->row1 = *(vec3*)&y1; + z->row0 = vec3::store_xmm(_mm_add_ps(t0, t2)); + z->row1 = vec3::store_xmm(y1); t0 = _mm_mul_ps(y0, vec4::load_xmm(y_sin)); t2 = _mm_mul_ps(y2, vec4::load_xmm(y_cos)); - zt = _mm_add_ps(t0, t2); - z->row2 = *(vec3*)&zt; + z->row2 = vec3::store_xmm(_mm_add_ps(t0, t2)); } inline void mat3_rotate_z_mult(const mat3* x, float_t y, mat3* z) { @@ -638,21 +578,18 @@ inline void mat3_rotate_z_mult(const mat3* x, float_t y, mat3* z) { __m128 y0; __m128 y1; __m128 y2; - __m128 zt; float_t y_sin = sinf(y); float_t y_cos = cosf(y); - *(vec3*)&y0 = x->row0; - *(vec3*)&y1 = x->row1; - *(vec3*)&y2 = x->row2; + y0 = vec3::load_xmm(x->row0); + y1 = vec3::load_xmm(x->row1); + y2 = vec3::load_xmm(x->row2); t0 = _mm_mul_ps(y0, vec4::load_xmm(y_cos)); t1 = _mm_mul_ps(y1, vec4::load_xmm(y_sin)); - zt = _mm_add_ps(t0, t1); - z->row0 = *(vec3*)&zt; + z->row0 = vec3::store_xmm(_mm_add_ps(t0, t1)); t0 = _mm_mul_ps(y0, vec4::load_xmm(-y_sin)); t1 = _mm_mul_ps(y1, vec4::load_xmm(y_cos)); - zt = _mm_add_ps(t0, t1); - z->row1 = *(vec3*)&zt; - z->row2 = *(vec3*)&y2; + z->row1 = vec3::store_xmm(_mm_add_ps(t0, t1)); + z->row2 = vec3::store_xmm(y2); } inline void mat3_scale(float_t x, float_t y, float_t z, mat3* d) { @@ -946,42 +883,36 @@ inline void mat4_mult(const mat4* x, const mat4* y, mat4* z) { inline void mat4_mult_vec2(const mat4* x, const vec2* y, vec2* z) { __m128 yt; - __m128 zt; __m128 zt0; __m128 zt1; - *(vec2*)&yt = *y; + yt = vec2::load_xmm(*y); zt0 = _mm_mul_ps(vec4::load_xmm(x->row0), _mm_shuffle_ps(yt, yt, 0x00)); zt1 = _mm_mul_ps(vec4::load_xmm(x->row1), _mm_shuffle_ps(yt, yt, 0x55)); - zt = _mm_add_ps(zt0, zt1); - *z = *(vec2*)&zt; + *z = vec2::store_xmm(_mm_add_ps(zt0, zt1)); } inline void mat4_mult_vec2_trans(const mat4* x, const vec2* y, vec2* z) { __m128 yt; - __m128 zt; __m128 zt0; __m128 zt1; __m128 zt2; - *(vec2*)&yt = *y; + yt = vec2::load_xmm(*y); zt0 = _mm_mul_ps(vec4::load_xmm(x->row0), _mm_shuffle_ps(yt, yt, 0x00)); zt1 = _mm_mul_ps(vec4::load_xmm(x->row1), _mm_shuffle_ps(yt, yt, 0x55)); zt2 = vec4::load_xmm(x->row3); - zt = _mm_add_ps(_mm_add_ps(zt0, zt1), zt2); - *z = *(vec2*)&zt; + *z = vec2::store_xmm(_mm_add_ps(_mm_add_ps(zt0, zt1), zt2)); } inline void mat4_mult_vec3(const mat4* x, const vec3* y, vec3* z) { __m128 yt; - __m128 zt; __m128 zt0; __m128 zt1; __m128 zt2; - *(vec3*)&yt = *y; + yt = vec3::load_xmm(*y); zt0 = _mm_mul_ps(vec4::load_xmm(x->row0), _mm_shuffle_ps(yt, yt, 0x00)); zt1 = _mm_mul_ps(vec4::load_xmm(x->row1), _mm_shuffle_ps(yt, yt, 0x55)); zt2 = _mm_mul_ps(vec4::load_xmm(x->row2), _mm_shuffle_ps(yt, yt, 0xAA)); - zt = _mm_add_ps(_mm_add_ps(zt0, zt1), zt2); - *z = *(vec3*)&zt; + *z = vec3::store_xmm(_mm_add_ps(_mm_add_ps(zt0, zt1), zt2)); } inline void mat4_mult_vec3_inv(const mat4* x, const vec3* y, vec3* z) { @@ -1001,18 +932,16 @@ inline void mat4_mult_vec3_inv(const mat4* x, const vec3* y, vec3* z) { inline void mat4_mult_vec3_trans(const mat4* x, const vec3* y, vec3* z) { __m128 yt; - __m128 zt; __m128 zt0; __m128 zt1; __m128 zt2; __m128 zt3; - *(vec3*)&yt = *y; + yt = vec3::load_xmm(*y); zt0 = _mm_mul_ps(vec4::load_xmm(x->row0), _mm_shuffle_ps(yt, yt, 0x00)); zt1 = _mm_mul_ps(vec4::load_xmm(x->row1), _mm_shuffle_ps(yt, yt, 0x55)); zt2 = _mm_mul_ps(vec4::load_xmm(x->row2), _mm_shuffle_ps(yt, yt, 0xAA)); zt3 = vec4::load_xmm(x->row3); - zt = _mm_add_ps(_mm_add_ps(zt0, zt1), _mm_add_ps(zt2, zt3)); - *z = *(vec3*)&zt; + *z = vec3::store_xmm(_mm_add_ps(_mm_add_ps(zt0, zt1), _mm_add_ps(zt2, zt3))); } inline void mat4_mult_vec3_inv_trans(const mat4* x, const vec3* y, vec3* z) { diff --git a/src/ReDIVA/config.hpp b/src/ReDIVA/config.hpp index a78c8906..b6553bca 100644 --- a/src/ReDIVA/config.hpp +++ b/src/ReDIVA/config.hpp @@ -7,7 +7,7 @@ #define BAKE_PNG (0) #define BAKE_VIDEO (0) #define BAKE_PV826 (0) -#define PV_DEBUG (0) +#define PV_DEBUG (1) #define DATA_EDIT (0) #endif diff --git a/src/ReDIVA/data_initialize.cpp b/src/ReDIVA/data_initialize.cpp index cfbbb09d..9912b812 100644 --- a/src/ReDIVA/data_initialize.cpp +++ b/src/ReDIVA/data_initialize.cpp @@ -147,7 +147,7 @@ bool TaskDataInit::Ctrl() { && !hand_item_handler_data_load() && !rob_sleeve_handler_data_load()) { module_data_handler_data_add_all_modules(); - //sub_140234860()->sub_140234DE0(); + customize_item_data_handler_data_add_all_customize_items(); //sub_140392D10(); //sub_140226760()->sub_140226A80(); //sub_140374650(); diff --git a/src/ReDIVA/data_test/auth_2d_test.cpp b/src/ReDIVA/data_test/auth_2d_test.cpp index da85fee2..f8cd157d 100644 --- a/src/ReDIVA/data_test/auth_2d_test.cpp +++ b/src/ReDIVA/data_test/auth_2d_test.cpp @@ -15,7 +15,6 @@ #include "../../CRE/sprite.hpp" #include "../../CRE/stage.hpp" #include "../../CRE/task_effect.hpp" -#include "../imgui_helper.hpp" #include "../input.hpp" #include "../task_window.hpp" @@ -383,7 +382,7 @@ DtwAet::DtwAet() { this->set->AddItem(set->name); } - //set->list->sub_1402F9930(20); + set->SetMaxItems(20); set->SetItemIndex(dtm_aet->curr_set_index); set->list->AddSelectionListener(new dw::SelectionListenerOnHook(DtwAet::SetCallback)); @@ -391,7 +390,7 @@ DtwAet::DtwAet() { (new dw::Label(this))->SetText("ID"); id = new dw::ListBox(this); - //id->list->sub_1402F9930(20); + id->SetMaxItems(20); id->list->AddSelectionListener(new dw::SelectionListenerOnHook(DtwAet::IdCallback)); @@ -399,7 +398,7 @@ DtwAet::DtwAet() { layer = new dw::ListBox(this); layer->AddItem("ROOT"); - //layer->list->sub_1402F9930(20); + layer->SetMaxItems(20); layer->list->AddSelectionListener(new dw::SelectionListenerOnHook(DtwAet::LayerCallback)); @@ -407,7 +406,7 @@ DtwAet::DtwAet() { marker = new dw::ListBox(this); marker->AddItem("NOMARKER"); - //marker->list->sub_1402F9930(20); + marker->SetMaxItems(20); marker->list->AddSelectionListener(new dw::SelectionListenerOnHook(DtwAet::MarkerCallback)); @@ -426,8 +425,7 @@ DtwAet::DtwAet() { (new dw::Label(this))->SetText("FRAME"); - frame = dw::Slider::make(this, (dw::Flags)(dw::FLAG_800 | dw::HORIZONTAL), - 0.0f, 0.0f, 128.0f, 20.0f, "slider"); + frame = dw::Slider::make(this); frame->SetText("FRAME"); frame->format = "%4.0f"; diff --git a/src/ReDIVA/data_test/auth_3d_test.cpp b/src/ReDIVA/data_test/auth_3d_test.cpp index bbf35237..e678bca6 100644 --- a/src/ReDIVA/data_test/auth_3d_test.cpp +++ b/src/ReDIVA/data_test/auth_3d_test.cpp @@ -13,6 +13,7 @@ #include "../../CRE/render_context.hpp" #include "../../CRE/stage.hpp" #include "../../CRE/task_effect.hpp" +#include "../dw.hpp" #include "../imgui_helper.hpp" #include "../input.hpp" @@ -118,8 +119,10 @@ bool Auth3dTestTask::Ctrl() { if (field_1EC == 1 && !object_storage_load_obj_set_check_not_read(effcmn_obj_set)) field_1EC = 4; - if (field_1D4 == 1 && auth_3d_id.check_loaded()) + if (field_1D4 == 1 && auth_3d_id.check_loaded()) { + sub_140194880(2); field_1D4 = 2; + } if (field_1D4 == 2) { auth_3d_id.set_enable(true); diff --git a/src/ReDIVA/data_test/motion_test.cpp b/src/ReDIVA/data_test/motion_test.cpp index a2c9970d..657e3aec 100644 --- a/src/ReDIVA/data_test/motion_test.cpp +++ b/src/ReDIVA/data_test/motion_test.cpp @@ -1354,7 +1354,7 @@ DataTestFaceMotDw::Data DataTestFaceMotDw::GetData() { { 131, 0.0f }, }; - std::string face_mot = face->GetSelectedItem(); + std::string face_mot = face->GetSelectedItemStr(); auto elem_face = motion_id_mottbl_map.find(aft_mot_db->get_motion_id(face_mot.c_str())); if (elem_face != motion_id_mottbl_map.end()) data.face.mottbl_index = elem_face->second; @@ -1379,12 +1379,12 @@ DataTestFaceMotDw::Data DataTestFaceMotDw::GetData() { data.eyelid.mottbl_index = elem_eyelid->second; data.eyelid.frame = face_cl_frame->scroll_bar->value; - auto elem_eyes = motion_id_mottbl_map.find(aft_mot_db->get_motion_id(eyes->GetSelectedItem().c_str())); + auto elem_eyes = motion_id_mottbl_map.find(aft_mot_db->get_motion_id(eyes->GetSelectedItemStr().c_str())); if (elem_eyes != motion_id_mottbl_map.end()) data.eyes.mottbl_index = elem_eyes->second; data.eyes.frame = eyes_frame->scroll_bar->value; - auto elem_mouth = motion_id_mottbl_map.find(aft_mot_db->get_motion_id(mouth->GetSelectedItem().c_str())); + auto elem_mouth = motion_id_mottbl_map.find(aft_mot_db->get_motion_id(mouth->GetSelectedItemStr().c_str())); if (elem_mouth != motion_id_mottbl_map.end()) data.mouth.mottbl_index = elem_mouth->second; data.mouth.frame = mouth_frame->scroll_bar->value; @@ -1398,7 +1398,7 @@ bool DataTestFaceMotDw::GetEnable() { dw::ListBox* DataTestFaceMotDw::InitAddMottblMapMotions(dw::Composite* parent, int32_t type) { dw::ListBox* list_box = new dw::ListBox(parent); - //list_box->list->sub_1402F9930(20); + list_box->SetMaxItems(20); AddMottblMapMotions(list_box, type); return list_box; } @@ -1418,9 +1418,9 @@ DataTestMotDw::StepSliderProc::~StepSliderProc() { } -void DataTestMotDw::StepSliderProc::Callback(dw::Widget* data) { +void DataTestMotDw::StepSliderProc::Callback(dw::SelectionListener::CallbackData* data) { DataTestMot::Data* test_mot_data = data_test_mot_data_get(); - dw::Slider* slider = dynamic_cast(data); + dw::Slider* slider = dynamic_cast(data->widget); if (slider) test_mot_data->step[slider->callback_data.i32].array[index] = slider->scroll_bar->value; } @@ -1433,9 +1433,9 @@ DataTestMotDw::CharaListBoxProc::~CharaListBoxProc() { } -void DataTestMotDw::CharaListBoxProc::Callback(dw::Widget* data) { +void DataTestMotDw::CharaListBoxProc::Callback(dw::SelectionListener::CallbackData* data) { DataTestMot::Data* test_mot_data = data_test_mot_data_get(); - dw::ListBox* list_box = dynamic_cast(data); + dw::ListBox* list_box = dynamic_cast(data->widget); if (list_box) { int32_t chara_id = list_box->callback_data.i32; ::chara_index chara_index = (::chara_index)list_box->list->selected_item; @@ -1470,11 +1470,11 @@ DataTestMotDw::CTypeListBoxProc::~CTypeListBoxProc() { } -void DataTestMotDw::CTypeListBoxProc::Callback(dw::Widget* data) { +void DataTestMotDw::CTypeListBoxProc::Callback(dw::SelectionListener::CallbackData* data) { DataTestMot::Data* test_mot_data = data_test_mot_data_get(); - dw::ListBox* list_box = dynamic_cast(data); + dw::ListBox* list_box = dynamic_cast(data->widget); if (list_box) { - std::string str = list_box->GetSelectedItem(); + std::string str = list_box->GetSelectedItemStr(); size_t start = str.find('('); if (start != -1) { start += 4; @@ -1495,9 +1495,9 @@ DataTestMotDw::SetListBoxProc::~SetListBoxProc() { } -void DataTestMotDw::SetListBoxProc::Callback(dw::Widget* data) { +void DataTestMotDw::SetListBoxProc::Callback(dw::SelectionListener::CallbackData* data) { DataTestMot::Data* test_mot_data = data_test_mot_data_get(); - dw::ListBox* list_box = dynamic_cast(data); + dw::ListBox* list_box = dynamic_cast(data->widget); if (list_box) { int32_t chara_id = list_box->callback_data.i32; test_mot_data->motion_set_index[chara_id] = (int32_t)list_box->list->selected_item; @@ -1513,7 +1513,7 @@ DataTestMotDw::IdListBoxProc::~IdListBoxProc() { } -void DataTestMotDw::IdListBoxProc::Callback(dw::Widget* data) { +void DataTestMotDw::IdListBoxProc::Callback(dw::SelectionListener::CallbackData* data) { } @@ -1525,7 +1525,7 @@ DataTestMotDw::RotateSliderProc::~RotateSliderProc() { } -void DataTestMotDw::RotateSliderProc::Callback(dw::Widget* data) { +void DataTestMotDw::RotateSliderProc::Callback(dw::SelectionListener::CallbackData* data) { } @@ -1537,7 +1537,7 @@ DataTestMotDw::PositionSliderProc::~PositionSliderProc() { } -void DataTestMotDw::PositionSliderProc::Callback(dw::Widget* data) { +void DataTestMotDw::PositionSliderProc::Callback(dw::SelectionListener::CallbackData* data) { } @@ -1549,7 +1549,7 @@ DataTestMotDw::FrameSliderProc::~FrameSliderProc() { } -void DataTestMotDw::FrameSliderProc::Callback(dw::Widget* data) { +void DataTestMotDw::FrameSliderProc::Callback(dw::SelectionListener::CallbackData* data) { } @@ -1561,7 +1561,7 @@ DataTestMotDw::StartFrameSliderProc::~StartFrameSliderProc() { } -void DataTestMotDw::StartFrameSliderProc::Callback(dw::Widget* data) { +void DataTestMotDw::StartFrameSliderProc::Callback(dw::SelectionListener::CallbackData* data) { } @@ -1573,7 +1573,7 @@ DataTestMotDw::DispButtonProc::~DispButtonProc() { } -void DataTestMotDw::DispButtonProc::Callback(dw::Widget* data) { +void DataTestMotDw::DispButtonProc::Callback(dw::SelectionListener::CallbackData* data) { } @@ -1585,7 +1585,7 @@ DataTestMotDw::UseOpdButtonProc::~UseOpdButtonProc() { } -void DataTestMotDw::UseOpdButtonProc::Callback(dw::Widget* data) { +void DataTestMotDw::UseOpdButtonProc::Callback(dw::SelectionListener::CallbackData* data) { } @@ -1597,7 +1597,7 @@ DataTestMotDw::PartialMotButtonProc::~PartialMotButtonProc() { } -void DataTestMotDw::PartialMotButtonProc::Callback(dw::Widget* data) { +void DataTestMotDw::PartialMotButtonProc::Callback(dw::SelectionListener::CallbackData* data) { } @@ -1609,7 +1609,7 @@ DataTestMotDw::SaveOnlyStartFrameButtonProc::~SaveOnlyStartFrameButtonProc() { } -void DataTestMotDw::SaveOnlyStartFrameButtonProc::Callback(dw::Widget* data) { +void DataTestMotDw::SaveOnlyStartFrameButtonProc::Callback(dw::SelectionListener::CallbackData* data) { } @@ -1621,7 +1621,7 @@ DataTestMotDw::CreateFaceMotDwProc::~CreateFaceMotDwProc() { } -void DataTestMotDw::CreateFaceMotDwProc::Callback(dw::Widget* data) { +void DataTestMotDw::CreateFaceMotDwProc::Callback(dw::SelectionListener::CallbackData* data) { } @@ -1633,7 +1633,7 @@ DataTestMotDw::CreateEqDwProc::~CreateEqDwProc() { } -void DataTestMotDw::CreateEqDwProc::Callback(dw::Widget* data) { +void DataTestMotDw::CreateEqDwProc::Callback(dw::SelectionListener::CallbackData* data) { } @@ -1645,7 +1645,7 @@ DataTestMotDw::CreateDebugCamProc::~CreateDebugCamProc() { } -void DataTestMotDw::CreateDebugCamProc::Callback(dw::Widget* data) { +void DataTestMotDw::CreateDebugCamProc::Callback(dw::SelectionListener::CallbackData* data) { } @@ -1663,36 +1663,36 @@ DataTestMotDw::DataTestMotDw(int32_t chara_id, DtmMot* dtm_mot) { dw::Label* chara_label = new dw::Label(chara_comp); chara_label->SetText("CHARA "); - //chara_label->SetFont(&p_dw__font_type_6x12); + chara_label->SetFont(dw::p_font_type_6x12); dw::ListBox* chara = new dw::ListBox(chara_comp); - //chara->list->sub_1402F9930(20); + chara->SetMaxItems(20); for (int32_t i = CHARA_MIKU; i < CHARA_MAX; i++) chara->AddItem(chara_index_get_name((chara_index)i)); chara->callback_data.i32 = chara_id; chara->SetItemIndex(test_mot_data->chara_index[chara_id]); chara->AddSelectionListener(&chara_list_box_proc); - //chara->SetFont(&p_dw__font_type_6x12); + chara->SetFont(dw::p_font_type_6x12); dw::Composite* chara_list_box_comp = new dw::Composite(this); chara_list_box_comp->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); chara_list_box_proc.list_box = new dw::ListBox(chara_list_box_comp); - //chara_list_box_proc.list_box->list->sub_1402F9930(40); - //chara_list_box_proc.list_box->SetFont(&p_dw__font_type_6x12); + chara_list_box_proc.list_box->SetMaxItems(40); + chara_list_box_proc.list_box->SetFont(dw::p_font_type_6x12); AddModules(chara_id, chara_list_box_proc.list_box); chara_list_box_proc.list_box->callback_data.i32 = chara_id; chara_list_box_proc.list_box->SetItemIndex(test_mot_data->module_index[chara_id]); chara_list_box_proc.list_box->AddSelectionListener(&c_type_list_box_proc); - //chara_list_box_proc.list_box->SetFont(&p_dw__font_type_6x12); + chara_list_box_proc.list_box->SetFont(dw::p_font_type_6x12); dw::Composite* set_comp = new dw::Composite(this); set_comp->SetLayout( new dw::RowLayout(dw::HORIZONTAL)); dw::Label* set_label = new dw::Label(set_comp); set_label->SetText("SET "); - //set_label->SetFont(&p_dw__font_type_6x12); + set_label->SetFont(dw::p_font_type_6x12); data_struct* aft_data = &data_list[DATA_AFT]; motion_database* aft_mot_db = &aft_data->data_ft.mot_db; @@ -1700,25 +1700,25 @@ DataTestMotDw::DataTestMotDw(int32_t chara_id, DtmMot* dtm_mot) { c_type_list_box_proc.list_box = new dw::ListBox(set_comp); for (motion_set_info& i : aft_mot_db->motion_set) c_type_list_box_proc.list_box->AddItem(i.name); - //c_type_list_box_proc.list_box->list->sub_1402F9930(40); + c_type_list_box_proc.list_box->SetMaxItems(40); c_type_list_box_proc.list_box->callback_data.i32 = chara_id; c_type_list_box_proc.list_box->SetItemIndex(test_mot_data->motion_set_index[chara_id]); c_type_list_box_proc.list_box->AddSelectionListener(&set_list_box_proc); - //c_type_list_box_proc.list_box->SetFont(&p_dw__font_type_6x12); + c_type_list_box_proc.list_box->SetFont(dw::p_font_type_6x12); dw::Composite* id_comp = new dw::Composite(this); id_comp->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); dw::Label* id_label = new dw::Label(id_comp); id_label->SetText("ID "); - //id_label->SetFont(&p_dw__font_type_6x12); + id_label->SetFont(dw::p_font_type_6x12); set_list_box_proc.list_box = new dw::ListBox(id_comp); - //set_list_box_proc.list_box->list->sub_1402F9930(40); + set_list_box_proc.list_box->SetMaxItems(40); set_list_box_proc.list_box->callback_data.i32 = chara_id; set_list_box_proc.list_box->AddSelectionListener(&id_list_box_proc); - //set_list_box_proc.list_box->SetFont(&p_dw__font_type_6x12); + set_list_box_proc.list_box->SetFont(dw::p_font_type_6x12); id_list_box_proc.slider = dw::Slider::make(this); id_list_box_proc.slider->SetText("Y ROT"); @@ -1736,7 +1736,7 @@ DataTestMotDw::DataTestMotDw(int32_t chara_id, DtmMot* dtm_mot) { dw::Group* frame_group = new dw::Group(this); frame_group->SetText("FRAME"); - //frame_group->SetFont(&p_dw__font_type_6x12); + frame_group->SetFont(dw::p_font_type_6x12); for (int32_t i = 3; i < 4; i++) { step_slider = dw::Slider::make(frame_group); @@ -1800,29 +1800,29 @@ DataTestMotDw::DataTestMotDw(int32_t chara_id, DtmMot* dtm_mot) { dw::Group* ab_loop_group = new dw::Group(this); ab_loop_group->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); ab_loop_group->SetText("AB LOOP"); - //ab_loop_group->SetFont(&p_dw__font_type_6x12); + ab_loop_group->SetFont(dw::p_font_type_6x12); dw::Button* a_label = new dw::Button(ab_loop_group, dw::FLAG_8); a_label->SetText(" A "); a_label->callback_data.i64 = (int64_t)this; a_label->callback = DataTestMotDw::ACallback; - //a_label->SetFont(&p_dw__font_type_6x12); + a_label->SetFont(dw::p_font_type_6x12); dw::Button* b_label = new dw::Button(ab_loop_group, dw::FLAG_8); b_label->SetText(" B "); b_label->callback_data.i64 = (int64_t)this; b_label->callback = DataTestMotDw::BCallback; - //b_label->SetFont(&p_dw__font_type_6x12); + b_label->SetFont(dw::p_font_type_6x12); dw::Button* ab_toggle_button = new dw::Button(ab_loop_group, dw::CHECKBOX); ab_toggle_button->SetText(""); ab_toggle_button->callback_data.v64 = this; ab_toggle_button->callback = DataTestMotDw::ABToggleCallback; - //ab_toggle->SetFont(&p_dw__font_type_6x12); + ab_toggle_button->SetFont(dw::p_font_type_6x12); start_frame_slider_proc.button = ab_toggle_button; ab_loop = new dw::Label(ab_loop_group, dw::FLAG_8); - //ab_loop->SetFont(&p_dw__font_type_6x12); + ab_loop->SetFont(dw::p_font_type_6x12); ab_loop->SetText(" 00000:00000"); dw::Composite* rob_comp = new dw::Composite(this); @@ -1833,12 +1833,12 @@ DataTestMotDw::DataTestMotDw(int32_t chara_id, DtmMot* dtm_mot) { disp_button->SetValue(true); disp_button->AddSelectionListener(&disp_button_proc); disp_button->callback_data.i32 = chara_id; - //disp_button->SetFont(&p_dw__font_type_6x12); + disp_button->SetFont(dw::p_font_type_6x12); disp_button_proc.button = new dw::Button(rob_comp, dw::CHECKBOX); disp_button_proc.button->SetText("SET CHANGE "); disp_button_proc.button->SetValue(false); - //disp_button_proc.button->SetFont(&p_dw__font_type_6x12); + disp_button_proc.button->SetFont(dw::p_font_type_6x12); dw::Composite* var_comp = new dw::Composite(this); var_comp->Composite::SetLayout(new dw::RowLayout(dw::HORIZONTAL)); @@ -1847,24 +1847,24 @@ DataTestMotDw::DataTestMotDw(int32_t chara_id, DtmMot* dtm_mot) { reate_face_mot_dw->SetText(" FACE MOT "); reate_face_mot_dw->AddSelectionListener(&create_face_mot_dw_proc); reate_face_mot_dw->callback_data.i32 = chara_id; - //reate_face_mot_dw->SetFont(&p_dw__font_type_6x12); + reate_face_mot_dw->SetFont(dw::p_font_type_6x12); dw::Button* create_eq_dw = new dw::Button(var_comp, dw::FLAG_8); create_eq_dw->SetText(" EQUIP "); create_eq_dw->AddSelectionListener(&create_eq_dw_proc); - //create_eq_dw->SetFont(&p_dw__font_type_6x12); + create_eq_dw->SetFont(dw::p_font_type_6x12); dw::Button* create_debug_cam = new dw::Button(var_comp, dw::FLAG_8); create_debug_cam->SetText(" LOCK CAM "); create_debug_cam->AddSelectionListener(&create_debug_cam_proc); - //create_debug_cam->SetFont(&p_dw__font_type_6x12); + create_debug_cam->SetFont(dw::p_font_type_6x12); dw::Button* use_opd_button = new dw::Button(this, dw::CHECKBOX); use_opd_button->SetText("USE OSAGE PLAY DATA"); use_opd_button->SetValue(false); use_opd_button->AddSelectionListener(&use_opd_button_proc); use_opd_button->callback_data.i32 = chara_id; - //use_opd_button->SetFont(&p_dw__font_type_6x12); + use_opd_button->SetFont(dw::p_font_type_6x12); dtm_mot->SetPartialMot(false); @@ -1873,7 +1873,7 @@ DataTestMotDw::DataTestMotDw(int32_t chara_id, DtmMot* dtm_mot) { save_only_start_frame_button->SetValue(false); save_only_start_frame_button->AddSelectionListener(&save_only_start_frame_button_proc); save_only_start_frame_button->callback_data.i32 = chara_id; - //save_only_start_frame_button->SetFont(&p_dw__font_type_6x12); + save_only_start_frame_button->SetFont(dw::p_font_type_6x12); GetSetSize(); } @@ -2046,7 +2046,7 @@ void DataTestMotDw::StartCtrlLeftRightCallback(dw::Widget* data) { if (frame > set_motion.back().frame_stage_index.first) last = set_motion.back().frame_stage_index.first; - if (button->GetText().compare(" < ")) + if (button->GetText().compare(L" < ")) test_mot_dw->frame_slider_proc.slider->SetValue(last); else if (first > 0.0f) test_mot_dw->frame_slider_proc.slider->SetValue(first); @@ -2064,10 +2064,10 @@ DataTestMotA3dDw::PvListBoxProc::~PvListBoxProc() { } -void DataTestMotA3dDw::PvListBoxProc::Callback(dw::Widget* data) { - dw::ListBox* list_box = dynamic_cast(data); +void DataTestMotA3dDw::PvListBoxProc::Callback(dw::SelectionListener::CallbackData* data) { + dw::ListBox* list_box = dynamic_cast(data->widget); if (list_box) - data_test_mot_a3d_dw->SetPvId(atoi(list_box->GetSelectedItem().c_str())); + data_test_mot_a3d_dw->SetPvId(atoi(list_box->GetSelectedItemStr().c_str())); data_test_mot_a3d_dw->GetSetSize(); } @@ -2080,7 +2080,7 @@ DataTestMotA3dDw::A3dListBoxProc::~A3dListBoxProc() { } -void DataTestMotA3dDw::A3dListBoxProc::Callback(dw::Widget* data) { +void DataTestMotA3dDw::A3dListBoxProc::Callback(dw::SelectionListener::CallbackData* data) { } @@ -2092,9 +2092,9 @@ DataTestMotCtrlDw::TypeListBoxProc::~TypeListBoxProc() { } -void DataTestMotCtrlDw::TypeListBoxProc::Callback(dw::Widget* data) { +void DataTestMotCtrlDw::TypeListBoxProc::Callback(dw::SelectionListener::CallbackData* data) { DataTestMot::Data* test_mot_data = data_test_mot_data_get(); - dw::ListBox* list_box = dynamic_cast(data); + dw::ListBox* list_box = dynamic_cast(data->widget); if (list_box) test_mot_data->type = (int32_t)list_box->list->selected_item; } @@ -2107,9 +2107,9 @@ DataTestMotCtrlDw::SyncFrameButtonProc::~SyncFrameButtonProc() { } -void DataTestMotCtrlDw::SyncFrameButtonProc::Callback(dw::Widget* data) { +void DataTestMotCtrlDw::SyncFrameButtonProc::Callback(dw::SelectionListener::CallbackData* data) { DataTestMot::Data* test_mot_data = data_test_mot_data_get(); - dw::Button* button = dynamic_cast(data); + dw::Button* button = dynamic_cast(data->widget); if (button) test_mot_data->sync_frame = button->value; } @@ -2122,9 +2122,9 @@ DataTestMotCtrlDw::GameCameraButtonProc::~GameCameraButtonProc() { } -void DataTestMotCtrlDw::GameCameraButtonProc::Callback(dw::Widget* data) { +void DataTestMotCtrlDw::GameCameraButtonProc::Callback(dw::SelectionListener::CallbackData* data) { DataTestMot::Data* test_mot_data = data_test_mot_data_get(); - dw::Button* button = dynamic_cast(data); + dw::Button* button = dynamic_cast(data->widget); if (button) { test_mot_data->field_A8 = true; test_mot_data->field_A9 = button->value; @@ -2139,11 +2139,11 @@ DataTestMotA3dDw::DataTestMotA3dDw() { dw::Label* pv_label = new dw::Label(pv_comp); pv_label->SetText("PV"); - //pv_label->SetFont(&p_dw__font_type_6x12); + pv_label->SetFont(dw::p_font_type_6x12); pv = new dw::ListBox(pv_comp); - //pv->list->sub_1402F9930(20); - //pv->SetFont(&p_dw__font_type_6x12); + pv->SetMaxItems(20); + pv->SetFont(dw::p_font_type_6x12); for (int32_t i = 0; i < 1000; i++) { if (!task_pv_db_get_pv(i)) @@ -2161,15 +2161,15 @@ DataTestMotA3dDw::DataTestMotA3dDw() { dw::Label* a3d_label = new dw::Label(a3d_comp); a3d_label->SetText("A3d"); - //a3d_label->SetFont(&p_dw__font_type_6x12); + a3d_label->SetFont(dw::p_font_type_6x12); a3d = new dw::ListBox(a3d_comp); - //a3d->list->sub_1402F9930(20); + a3d->SetMaxItems(20); a3d->AddItem("PVを選択して下さい"); a3d->Reset(); a3d->AddSelectionListener(&a3d_list_box_proc); - //a3d->SetFont(&p_dw__font_type_6x12); + a3d->SetFont(dw::p_font_type_6x12); dw::Composite* button_comp = new dw::Composite(this); button_comp->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); @@ -2179,13 +2179,13 @@ DataTestMotA3dDw::DataTestMotA3dDw() { play_a3d->callback_data.v64 = this; play_a3d->callback = DataTestMotA3dDw::PlayA3dCallback; - //play_a3d->SetFont(&p_dw__font_type_6x12); + play_a3d->SetFont(dw::p_font_type_6x12); sync_1p_frame = new dw::Button(button_comp, dw::CHECKBOX); sync_1p_frame->SetText("SYNC 1P FRAME"); sync_1p_frame->callback_data.v64 = this; sync_1p_frame->callback = DataTestMotA3dDw::Sync1pFrameCallback; - //sync_1p_frame->SetFont(&p_dw__font_type_6x12); + sync_1p_frame->SetFont(dw::p_font_type_6x12); GetSetSize(); @@ -2239,7 +2239,7 @@ void DataTestMotA3dDw::SetPvId(int32_t pv_id) { } void DataTestMotA3dDw::PlayA3dCallback(dw::Widget* data) { - std::string auth_3d = data_test_mot_a3d_dw_get()->a3d->GetSelectedItem(); + std::string auth_3d = data_test_mot_a3d_dw_get()->a3d->GetSelectedItemStr(); data_test_mot_a3d_set_auth_3d(auth_3d); } @@ -2280,13 +2280,13 @@ DataTestMotCtrlDw::DataTestMotCtrlDw() { dw::Button* sync_frame_button = new dw::Button(this, dw::CHECKBOX); sync_frame_button->SetText("SYNC FRAME"); sync_frame_button->AddSelectionListener(&sync_frame_button_proc); - //sync_frame_button->SetFont(&p_dw__font_type_6x12); + sync_frame_button->SetFont(dw::p_font_type_6x12); running = new dw::Button(this, dw::CHECKBOX); running->SetText("RUNNING"); running->SetValue(false); running->callback = DataTestMotCtrlDw::RunningCallback; - //running->SetFont(&p_dw__font_type_6x12); + running->SetFont(dw::p_font_type_6x12); stage = new dw::Button(this, dw::FLAG_8); stage->SetText("STAGE"); diff --git a/src/ReDIVA/data_test/motion_test.hpp b/src/ReDIVA/data_test/motion_test.hpp index eb59a45d..7babd9f4 100644 --- a/src/ReDIVA/data_test/motion_test.hpp +++ b/src/ReDIVA/data_test/motion_test.hpp @@ -243,7 +243,7 @@ public: StepSliderProc(); virtual ~StepSliderProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; class CharaListBoxProc : public dw::SelectionAdapter { @@ -253,7 +253,7 @@ public: CharaListBoxProc(); virtual ~CharaListBoxProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; class CTypeListBoxProc : public dw::SelectionAdapter { @@ -263,7 +263,7 @@ public: CTypeListBoxProc(); virtual ~CTypeListBoxProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; class SetListBoxProc : public dw::SelectionAdapter { @@ -273,7 +273,7 @@ public: SetListBoxProc(); virtual ~SetListBoxProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; class IdListBoxProc : public dw::SelectionAdapter { @@ -283,7 +283,7 @@ public: IdListBoxProc(); virtual ~IdListBoxProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; class RotateSliderProc : public dw::SelectionAdapter { @@ -293,7 +293,7 @@ public: RotateSliderProc(); virtual ~RotateSliderProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; class PositionSliderProc : public dw::SelectionAdapter { @@ -301,7 +301,7 @@ public: PositionSliderProc(); virtual ~PositionSliderProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; class FrameSliderProc : public dw::SelectionAdapter { @@ -311,7 +311,7 @@ public: FrameSliderProc(); virtual ~FrameSliderProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; class StartFrameSliderProc : public dw::SelectionAdapter { @@ -321,7 +321,7 @@ public: StartFrameSliderProc(); virtual ~StartFrameSliderProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; class DispButtonProc : public dw::SelectionAdapter { @@ -331,7 +331,7 @@ public: DispButtonProc(); virtual ~DispButtonProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; class UseOpdButtonProc : public dw::SelectionAdapter { @@ -339,7 +339,7 @@ public: UseOpdButtonProc(); virtual ~UseOpdButtonProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; class PartialMotButtonProc : public dw::SelectionAdapter { @@ -347,7 +347,7 @@ public: PartialMotButtonProc(); virtual ~PartialMotButtonProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; class SaveOnlyStartFrameButtonProc : public dw::SelectionAdapter { @@ -355,7 +355,7 @@ public: SaveOnlyStartFrameButtonProc(); virtual ~SaveOnlyStartFrameButtonProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; class CreateFaceMotDwProc : public dw::SelectionAdapter { @@ -363,7 +363,7 @@ public: CreateFaceMotDwProc(); virtual ~CreateFaceMotDwProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; class CreateEqDwProc : public dw::SelectionAdapter { @@ -371,7 +371,7 @@ public: CreateEqDwProc(); virtual ~CreateEqDwProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; struct CreateDebugCamProc : public dw::SelectionAdapter { @@ -379,7 +379,7 @@ public: CreateDebugCamProc(); virtual ~CreateDebugCamProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; DtmMot* dtm_mot; @@ -439,7 +439,7 @@ public: PvListBoxProc(); virtual ~PvListBoxProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; class A3dListBoxProc : public dw::SelectionAdapter { @@ -447,7 +447,7 @@ public: A3dListBoxProc(); virtual ~A3dListBoxProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; dw::ListBox* pv; @@ -476,7 +476,7 @@ public: TypeListBoxProc(); virtual ~TypeListBoxProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; class SyncFrameButtonProc : public dw::SelectionAdapter { @@ -484,7 +484,7 @@ public: SyncFrameButtonProc(); virtual ~SyncFrameButtonProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; @@ -493,7 +493,7 @@ public: GameCameraButtonProc(); virtual ~GameCameraButtonProc() override; - virtual void Callback(dw::Widget* data) override; + virtual void Callback(dw::SelectionListener::CallbackData* data) override; }; dw::ListBox* type_list; diff --git a/src/ReDIVA/data_test/stage_test.cpp b/src/ReDIVA/data_test/stage_test.cpp index f309a115..c167c6aa 100644 --- a/src/ReDIVA/data_test/stage_test.cpp +++ b/src/ReDIVA/data_test/stage_test.cpp @@ -74,12 +74,12 @@ DtwStg::DtwStg() : Shell(0) { std::vector& stg_data = aft_stage_data->stage_data; - dw::Widget::SetText("STAGE TEST"); + dw::Widget::SetText(L"STAGE TEST"); dw::Composite* pv_comp = new dw::Composite(this); pv_comp->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); - (new dw::Label(pv_comp, dw::LABEL_SIZE))->SetText("PV:"); + (new dw::Label(pv_comp))->SetText(L"PV:"); pv_id = new dw::ListBox(pv_comp); @@ -88,14 +88,14 @@ DtwStg::DtwStg() : Shell(0) { dw::Composite* ns_comp = new dw::Composite(this); ns_comp->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); - (new dw::Label(ns_comp, dw::LABEL_SIZE))->SetText("NS:"); + (new dw::Label(ns_comp))->SetText(L"NS:"); ns = new dw::ListBox(ns_comp); dw::Composite* other_comp = new dw::Composite(this); other_comp->SetLayout(new dw::RowLayout(dw::HORIZONTAL)); - (new dw::Label(other_comp, dw::LABEL_SIZE))->SetText("Other:"); + (new dw::Label(other_comp))->SetText(L"Other:"); other = new dw::ListBox(other_comp); @@ -126,38 +126,38 @@ DtwStg::DtwStg() : Shell(0) { for (auto& i : pv_stage) pv_id->AddItem(i.first); - //dw::List::sub_1402F9930(this->pv_id->list, 30); + pv_id->SetMaxItems(30); pv_id->AddSelectionListener(new dw::SelectionListenerOnHook(DtwStg::PvIdCallback)); - //dw::List::sub_1402F9930(this->pv->list, 30); + pv->SetMaxItems(30); pv->AddSelectionListener(new dw::SelectionListenerOnHook(DtwStg::StageCallback)); - //dw::List::sub_1402F9930(this->ns->list, 30); + ns->SetMaxItems(30); ns->SetItemIndex(0); ns->AddSelectionListener(new dw::SelectionListenerOnHook(DtwStg::StageCallback)); - //dw::List::sub_1402F9930(this->stage->list, 30); + stage->SetMaxItems(30); stage->SetItemIndex(0); stage->AddSelectionListener(new dw::SelectionListenerOnHook(DtwStg::StageCallback)); stage_display = new dw::Button(this, dw::CHECKBOX); - stage_display->SetText("Stage display"); + stage_display->SetText(L"Stage display"); stage_display->SetValue(true); ring = new dw::Button(this, dw::CHECKBOX); - ring->SetText("[Ring]"); + ring->SetText(L"[Ring]"); ring->SetValue(true); ground = new dw::Button(this, dw::CHECKBOX); - ground->SetText("[Ground]"); + ground->SetText(L"[Ground]"); ground->SetValue(true); sky = new dw::Button(this, dw::CHECKBOX); - sky->SetText("[Sky]"); + sky->SetText(L"[Sky]"); sky->SetValue(true); effect_display = new dw::Button(this, dw::CHECKBOX); - effect_display->SetText("Effects display"); + effect_display->SetText(L"Effects display"); effect_display->SetValue(true); GetSetSize(); @@ -177,7 +177,7 @@ void DtwStg::PvIdCallback(dw::Widget* data) { data_struct* aft_data = &data_list[DATA_AFT]; stage_database* aft_stage_data = &aft_data->data_ft.stage_data; - std::string name = list_box->GetSelectedItem(); + std::string name = list_box->GetSelectedItemStr(); dw::ListBox* pv_list_box = dtw_stg->pv; pv_list_box->ClearItems(); @@ -196,7 +196,7 @@ void DtwStg::StageCallback(dw::Widget* data) { data_struct* aft_data = &data_list[DATA_AFT]; stage_database* aft_stage_data = &aft_data->data_ft.stage_data; - std::string name = list_box->GetSelectedItem(); + std::string name = list_box->GetSelectedItemStr(); dtm_stg->load_stage_index = aft_stage_data->get_stage_index(name.c_str()); } } diff --git a/src/ReDIVA/dw.cpp b/src/ReDIVA/dw.cpp index 3d3fd930..a2f8b36c 100644 --- a/src/ReDIVA/dw.cpp +++ b/src/ReDIVA/dw.cpp @@ -4,39 +4,143 @@ */ #include "dw.hpp" -#include "imgui_helper.hpp" +#include "print_work.hpp" + +class PrintWorkDebug : public PrintWork { +public: + PrintWorkDebug(); +}; + +namespace dw { + struct Print { + p_Font* font; + PrintWorkDebug* print_work; + color4u8 field_10; + color4u8 field_14; + rectangle field_18; + rectangle clip_data; + float_t field_38; + + Print(float_t width, float_t height); + ~Print(); + + void FillRectangle(rectangle rect); + vec2 GetTextSize(std::string& str); + vec2 GetTextSize(std::wstring& str); + vec2 GetTextSize(const wchar_t* str, size_t length); + void PrintText(std::string& str, float_t pos_x, float_t pos_y); + void PrintText(std::wstring& str, float_t pos_x, float_t pos_y); + void SetClipData(rectangle rect); + void SetFillColor(color4u8 value); + void SetFont(p_Font* value); + void SetColor(color4u8 value); + + void sub_140301390(rectangle rect, float_t a3); + void sub_140302800(); + + inline vec2 GetTextSize(std::string&& str) { + return GetTextSize(str); + } + + inline vec2 GetTextSize(std::wstring&& str) { + return GetTextSize(str); + } + + inline void PrintText(std::string&& str, float_t pos_x, float_t pos_y) { + PrintText(str, pos_x, pos_y); + } + + inline void PrintText(std::wstring&& str, float_t pos_x, float_t pos_y) { + PrintText(str, pos_x, pos_y); + } + }; + + struct Colors { + color4u8 background; + color4u8 foreground; + color4u8 selection_background; + color4u8 selection_foreground; + color4u8 selection_inactive_background; + color4u8 selection_inactive_foreground; + color4u8 disable_background; + color4u8 disable_foreground; + color4u8 title_background; + color4u8 title_foreground; + color4u8 title_inactive_background; + color4u8 title_inactive_foreground; + color4u8 active_border_color; + color4u8 inactive_border_color; + color4u8 focus_border_color; + color4u8 border_color; + color4u8 border_light_color; + color4u8 border_dark_color; + color4u8 popup_background; + color4u8 popup_foreground; + color4u8 popup_selection_background; + color4u8 popup_selection_foreground; + color4u8 menu_background; + color4u8 menu_foreground; + color4u8 menu_selection_background; + color4u8 menu_selection_foreground; + color4u8 button_background; + color4u8 button_foreground; + color4u8 button_disable_background; + color4u8 button_disable_foreground; + }; +} + +struct struc_751 { + vec2 field_0; + vec2 field_8; + int32_t field_10; + int32_t field_14; + uint16_t field_18; + int8_t field_1A; + int8_t field_1B; + int8_t field_1C; + int8_t field_1D; + int64_t field_20; + int8_t field_28; + int32_t field_2C; + int32_t field_30; + + struc_751(); +}; namespace dw_gui_detail { struct Display { - /*dw::Shell* field_8; + class RootKeySelection : public dw::KeyAdapter { + public: + RootKeySelection(); + virtual ~RootKeySelection() override; + + virtual void Field_8(dw::Widget::KeyCallbackData data) override; + }; + + dw::Shell* field_8; dw::Menu* field_10; dw::Widget* field_18; dw::Widget* field_20; dw::Widget* field_28; dw::Widget* field_30; dw::Shell* field_38; - char field_40; - char field_41;*/ + bool field_40; + bool field_41; std::vector shells; - /*std::vector menus; - struc_748 field_78; - struc_748 field_90;*/ + std::vector menus; + dw::Widget::MouseCallbackData mouse_callback_data; + dw::Widget::KeyCallbackData key_callback_data; std::vector free_widgets; - /*struc_751 field_C0; - int field_F4; - rectangle field_F8; - int field_108; - int field_10C; - int field_110; - int field_114; - __int64 field_118; + struc_751 field_C0; + dw::init_data init_data; + int64_t field_118; vec2 field_120; float_t field_128; - dw::DragBoundsControl* field_130; - std::string name; - dw_gui_detail::Display::RootKeySelection root_key_selection;*/ + //dw::DragBoundsControl* drag_bounds_control; + std::wstring name; + RootKeySelection root_key_selection; - Display(); + Display(dw::init_data& init_data); ~Display(); void AddShell(dw::Shell* value); @@ -48,85 +152,152 @@ namespace dw_gui_detail { }; } -struct dw_gui_colors { - color4u8 background; - color4u8 foreground; - color4u8 selection_background; - color4u8 selection_foreground; - color4u8 selection_inactive_background; - color4u8 selection_inactive_foreground; - color4u8 disable_background; - color4u8 disable_foreground; - color4u8 title_background; - color4u8 title_foreground; - color4u8 title_inactive_background; - color4u8 title_inactive_foreground; - color4u8 active_border_color; - color4u8 inactive_border_color; - color4u8 focus_border_color; - color4u8 border_color; - color4u8 border_light_color; - color4u8 border_dark_color; - color4u8 popup_background; - color4u8 popup_foreground; - color4u8 popup_selection_background; - color4u8 popup_selection_foreground; - color4u8 menu_background; - color4u8 menu_foreground; - color4u8 menu_selection_background; - color4u8 menu_selection_foreground; - color4u8 button_background; - color4u8 button_foreground; - color4u8 button_disable_background; - color4u8 button_disable_foreground; -}; - -static dw_gui_colors dw_gui_colors_default = { - { 0xFF, 0xFF, 0xFF, 0xFF }, - { 0x00, 0x00, 0x00, 0xFF }, - { 0x00, 0x00, 0x80, 0xFF }, - { 0xFF, 0xFF, 0xFF, 0xFF }, - { 0xC0, 0xC0, 0xC0, 0xFF }, - { 0xFF, 0xFF, 0xFF, 0xFF }, - { 0xC0, 0xC0, 0xC0, 0xFF }, - { 0x80, 0x80, 0x80, 0xFF }, - { 0x00, 0x00, 0x80, 0xFF }, - { 0xFF, 0xFF, 0xFF, 0xFF }, - { 0xC0, 0xC0, 0xC0, 0xFF }, - { 0x80, 0x80, 0x80, 0xFF }, - { 0xC0, 0xC0, 0xC0, 0xFF }, - { 0xC0, 0xC0, 0xC0, 0xFF }, - { 0xFF, 0x00, 0x00, 0xFF }, - { 0xC0, 0xC0, 0xC0, 0xFF }, - { 0xE0, 0xE0, 0xE0, 0xFF }, - { 0x80, 0x80, 0x80, 0xFF }, - { 0xFF, 0xFF, 0xFF, 0xFF }, - { 0x00, 0x00, 0x00, 0xFF }, - { 0x00, 0x00, 0x80, 0xFF }, - { 0xFF, 0xFF, 0xFF, 0xFF }, - { 0xC0, 0xC0, 0xC0, 0xFF }, - { 0x00, 0x00, 0x00, 0xFF }, - { 0x00, 0x00, 0x80, 0xFF }, - { 0xFF, 0xFF, 0xFF, 0xFF }, - { 0xC0, 0xC0, 0xC0, 0xFF }, - { 0x00, 0x00, 0x00, 0xFF }, - { 0xF0, 0xF0, 0xF0, 0xFF }, - { 0x80, 0x80, 0x80, 0xFF }, -}; - dw_gui_detail::Display* dw_gui_detail_display; +int32_t dword_140EDA6B8; + extern bool input_locked; static bool dw_gui_get_ctrl(); static bool dw_gui_get_disp(); +static void dw_gui_detail_display_sub_1402F8C90(dw::Widget* widget, bool set); + +static void sub_1402EE3C0(rectangle rect, float_t a2, int32_t type, color4u8* color); + namespace dw { + static const Colors colors_default = { + 0xFFFFFFFF, + 0xFF000000, + 0xFF800000, + 0xFFFFFFFF, + 0xFFC0C0C0, + 0xFFFFFFFF, + 0xFFC0C0C0, + 0xFF808080, + 0xFF800000, + 0xFFFFFFFF, + 0xFFC0C0C0, + 0xFF808080, + 0xFFC0C0C0, + 0xFFC0C0C0, + 0xFFC0C0C0, + 0xFFE0E0E0, + 0xFF808080, + 0xFFFFFFFF, + 0xFF000000, + 0xFF000000, + 0xFFFFFFFF, + 0xFFC0C0C0, + 0xFF000000, + 0xFF800000, + 0xFFFFFFFF, + 0xFFC0C0C0, + 0xFF000000, + 0xFFF0F0F0, + 0xFF808080, + }; + static RowLayout* row_layout_vertical = new RowLayout(VERTICAL); static DropDownListScrollBarSelectionListener drop_down_list_scroll_bar_selection_listener; static ScrollBarTestSelectionListener scroll_bar_test_Selection_listener; + std::wstring* text_buf; + + Print* print; + + dw::Colors colors_current; + + p_Font current_font; + + Font* font_type_6x12; + Font* font_type_8x12; + Font* font_type_8x16; + Font* font_type_10x16; + Font* font_type_10x20; + Font* font_type_12x24; + Font* font_type_scroll_bar; + + p_Font p_font_type_6x12; + p_Font p_font_type_8x12; + p_Font p_font_type_8x16; + p_Font p_font_type_10x16; + p_Font p_font_type_10x20; + p_Font p_font_type_12x24; + p_Font p_font_type_scroll_bar; + + std::map font_collection; + + Font::Font(int32_t font_handler_index, std::string& name, bool half_width) { + font = font_info(font_handler_index); + this->name.assign(name); + this->half_width = half_width; + } + + Font::Font(int32_t font_handler_index, std::string& name) { + font = font_info(font_handler_index); + this->name.assign(name); + this->half_width = 0; + } + + Font::~Font() { + + } + + float_t Font::GetFontGlyphHeight() { + return font.glyph.y; + } + + vec2 Font::GetFontGlyphSize() { + vec2 size; + size.x = GetFontGlyphWidth(); + size.y = GetFontGlyphHeight(); + return size; + } + + float_t Font::GetFontGlyphWidth() { + return font.glyph.x; + } + + std::string Font::GetName() { + return name; + } + + void Font::SetGlyphSize(float_t glyph_width, float_t glyph_height) { + if (half_width) + glyph_width *= 2.0f; + font.set_glyph_size(glyph_width, glyph_height); + } + + p_Font::p_Font() : ptr() { + + } + + p_Font::~p_Font() { + + } + + float_t p_Font::GetFontGlyphHeight() { + return ptr->GetFontGlyphHeight(); + } + + vec2 p_Font::GetFontGlyphSize() { + return ptr->GetFontGlyphSize(); + } + + float_t p_Font::GetFontGlyphWidth() { + return ptr->GetFontGlyphWidth(); + } + + std::string p_Font::GetName() { + return ptr->GetName(); + } + + void p_Font::SetGlyphSize(float_t glyph_width, float_t glyph_height) { + ptr->SetGlyphSize(glyph_width, glyph_height); + } + SelectionListener::SelectionListener() { } @@ -143,11 +314,11 @@ namespace dw { } - void SelectionAdapter::Callback(Widget* data) { + void SelectionAdapter::Callback(SelectionListener::CallbackData* data) { } - void SelectionAdapter::Field_10(Widget* data) { + void SelectionAdapter::Field_10(SelectionListener::CallbackData* data) { } @@ -155,7 +326,7 @@ namespace dw { } - SelectionListenerOnHook::SelectionListenerOnHook(Widget::Callback callback) { + SelectionListenerOnHook::SelectionListenerOnHook(SelectionListenerOnHook::CallbackFunc callback) { this->callback = callback; } @@ -163,37 +334,23 @@ namespace dw { } - void SelectionListenerOnHook::Callback(Widget* data) { - callback(data); + void SelectionListenerOnHook::Callback(SelectionListener::CallbackData* data) { + callback(data->widget); } - DropDownListScrollBarSelectionListener::DropDownListScrollBarSelectionListener() { - + Widget::KeyCallbackData::KeyCallbackData() : field_0(), + field_8(), field_C(), field_D(), field_10(), field_14() { } - DropDownListScrollBarSelectionListener::~DropDownListScrollBarSelectionListener() { - - } - - void DropDownListScrollBarSelectionListener::Callback(Widget* data) { - - } - - ScrollBarTestSelectionListener::ScrollBarTestSelectionListener() { - - } - - ScrollBarTestSelectionListener::~ScrollBarTestSelectionListener() { - - } - - void ScrollBarTestSelectionListener::Callback(Widget* data) { + Widget::MouseCallbackData::MouseCallbackData() : field_0(), field_10(), field_14() { } Widget::Widget(Widget* parent, Flags flags) : free(), callback_data(), free_callback(), parent() { + text.assign(L"NO_NAME"); this->flags = flags; + font = current_font; } Widget::~Widget() { @@ -208,26 +365,36 @@ namespace dw { text.clear(); } - std::string Widget::GetText() { + std::wstring Widget::GetText() { return text; } - void Widget::SetText(std::string& str) { + void Widget::SetText(std::wstring& str) { text.assign(str); - if (flags & LABEL_SIZE) { - ImVec2 size = ImGui::CalcTextSize(text.c_str(), 0, true); - rect.size = { size.x, size.y }; - } } void Widget::SetSize(vec2 value) { rect.size = value; } + int32_t Widget::KeyCallback(Widget::KeyCallbackData data) { + return 0; + } + + int32_t Widget::MouseCallback(Widget::MouseCallbackData data) { + return 0; + } + vec2 Widget::GetPos() { return rect.pos; } + bool Widget::CheckHitPos(vec2 hit_pos) { + rectangle rect = GetRectangle(); + return rect.pos.x <= hit_pos.x && hit_pos.x < rect.pos.x + rect.size.x + && rect.pos.y <= hit_pos.y && hit_pos.y < rect.size.y + rect.pos.y; + } + void Widget::Free() { if (free) return; @@ -243,21 +410,49 @@ namespace dw { dw_gui_detail_display->free_widgets.push_back(this); } + float_t Widget::GetFontGlyphHeight() { + return font.GetFontGlyphHeight(); + } + rectangle Widget::GetRectangle() { return { GetPos(), rect.size }; } - void Widget::SetText(std::string&& str) { - SetText(str); + void Widget::SetText(std::string& str) { + SetText(utf8_to_utf16(str)); } void Widget::UpdateDraw() { - //print->sub_140302800(); + print->sub_140302800(); Draw(); } + void Widget::sub_1402F3770(Widget* widget) { + if (!widget) + return; + + rectangle v10 = widget->GetRectangle(); + rectangle v11 = dw_gui_detail_display->init_data.field_0; + if (v11.pos.x > v10.pos.x || v10.pos.x + v10.size.x > v11.pos.x + v11.size.x + || v11.pos.y > v10.pos.y || v10.pos.y + v10.size.y > v11.pos.y + v11.size.y) { + float_t v7 = v10.pos.x; + float_t v8 = v10.pos.y; + if (v10.pos.y + v10.size.y >= v11.pos.y + v11.size.y) + v8 = v11.pos.y + v11.size.y - widget->rect.size.y; + if (v10.pos.y < v11.pos.y || v8 < 0.0f) + v8 = 0.0; + + if (v10.pos.x + v10.size.x >= v11.pos.x + v11.size.x) + v7 = v11.pos.x + v11.size.x - widget->rect.size.x; + if (v10.pos.x < v11.pos.x || v7 < 0.0f) + v7 = 0.0; + widget->rect.pos.x = v7; + widget->rect.pos.y = v8; + } + } + Control::Control(Composite* parent, Flags flags) : Widget(parent, flags), - parent_comp(), parent_shell()/*, parent_menu()*/ { + field_68(), parent_comp(), parent_shell(), parent_menu() { parent_comp = parent; if (parent) { parent->controls.push_back(this); @@ -278,6 +473,80 @@ namespace dw { Widget::Reset(); } + int32_t Control::KeyCallback(Widget::KeyCallbackData data) { + if (!Field_A0()) + return 0; + + /*if ((data.field_8 & 0x20000) && data.field_10 == 0x1000013) + if (parent_menu) + parent_menu->sub_1402F35E0();*/ + + if (data.field_10 || (data.field_14 & 0x40000000)) { + Widget::KeyCallbackData v8 = data; + v8.field_0 = parent; + for (KeyListener*& i : key_listener) + i->Field_8(v8); + } + return 0; + } + + int32_t Control::MouseCallback(Widget::MouseCallbackData data) { + if (!Field_A0()) + return 0; + + /*if (dw_gui_detail_display->field_C0.field_18 == 9 && (data.field_10 & 0x40) && !data.field_14) + if (parent_menu) + parent_menu->sub_1402F35E0();*/ + + if (!data.field_10) + return 0; + + if (data.field_10 & 0xF0) { + Widget::MouseCallbackData v19 = data; + v19.field_0 = parent; + v19.field_10 = data.field_10 & 0xF0; + + for (MouseListener* i : mouse_listener) + i->Field_10(v19); + } + + if (data.field_10 & 0xF000000) { + Widget::MouseCallbackData v19 = data; + v19.field_0 = parent; + v19.field_10 = data.field_10 & 0xF000000; + + for (MouseListener* i : mouse_listener) + i->Field_18(v19); + } + + if (data.field_10 & 0xF000) { + Widget::MouseCallbackData v19 = data; + v19.field_0 = parent; + v19.field_10 = data.field_10 & 0xF000; + + for (MouseListener* i : mouse_listener) + i->Field_8(v19); + } + + if (data.field_10 & 0xF00) { + Widget::MouseCallbackData v19 = data; + v19.field_0 = parent; + v19.field_10 = data.field_10 & 0xF00; + + for (MouseListener* i : mouse_listener) + i->Field_20(v19); + } + + if (data.field_10 & 0x40000000) { + Widget::MouseCallbackData v19 = data; + v19.field_0 = parent; + + for (MouseMoveListener* i : mouse_move_listener) + i->Field_8(v19); + } + return 0; + } + vec2 Control::GetPos() { vec2 pos = rect.pos; if (parent_comp) { @@ -297,168 +566,76 @@ namespace dw { return rect.size; } - Label::Label(Composite* parent, Flags flags) : Control(parent, flags) { - + bool Control::Field_58() { + return parent_comp->SetCurrentControl(this); } - Label::~Label() { - + bool Control::Field_60() { + return parent_comp->sub_1402F1E60(this); } - void Label::Draw() { - rectangle rect = GetRectangle(); - //print->SetFont(font); - //vec2 text_size = print->GetTextSize(name); - ImVec2 _text_size = ImGui::CalcTextSize(text.c_str()); - vec2 text_size(_text_size.x, _text_size.y); + void Control::SetFont(p_Font& value) { + font = value; + } - vec2 pos; - if (flags & FLAG_4000) - pos.x = rect.pos.x; - else if (flags & FLAG_20000) - pos.x = rect.pos.x + rect.size.x - text_size.x; + p_Font& Control::GetFont() { + return font; + } + + void Control::SetForegroundColor(color4u8 value) { + foreground_color = value; + } + + void Control::SetBackgroundColor(color4u8 value) { + background_color = value; + } + + color4u8 Control::GetForegroundColor() { + return foreground_color; + } + + color4u8 Control::GetBackgroundColor() { + return background_color; + } + + bool Control::Field_98() { + return !field_68; + } + + bool Control::Field_A0() { + if (parent_comp) + return parent_comp->Field_A0() && Field_98(); + return Field_98(); + } + + void Control::Field_A8(bool value) { + field_68 = !value; + } + + Widget* Control::GetHitWidget(vec2 hit_pos) { + if (CheckHitPos(hit_pos)) + return this; + return 0; + } + + void Control::SetParentMenu(Menu* menu) { + if (menu) { + //menu->Field_60(); + parent_menu = menu; + } else - pos.x = rect.pos.x + (rect.size.x - text_size.x) * 0.5f; - pos.y = rect.pos.y + (rect.size.y - text_size.y) * 0.5f; - - /*print->SetColor(Field_A0() - ? dw_gui_colors_current.foreground - : &dw_gui_colors_current.disable_foreground); - print->sub_1403027C0(rect); - print->SetFont(font); - print->PrintText(name, pos.x, pos.y);*/ - - mat4_mult_vec2(&mat4_identity, &pos, &pos); - - ImGui::PushID(this); - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + (pos.x - rect.pos.x)); - ImGui::Text(text.c_str()); - ImGui::PopID(); - } - - vec2 Label::GetSize() { - //sub_140302810(qword_1411900C8, &font); - //vec2 size = sub_140302A70(qword_1411900C8, text); - ImVec2 _size = ImGui::CalcTextSize(text.c_str(), 0, true); - vec2 size(_size.x, _size.y); - return size + 2.0f * 2.0f; - } - - ScrollBar::ScrollBar(Control* parent, Flags flags) : Widget(parent, flags), - value(), min(), field_A0(), field_A5(), field_A6() { - field_68 = parent; - max = 100.0f; - field_94 = 10.0f; - step = 1.0f; - step_fast = 10.0f; - round = true; - SetSize({ 8.0f, 8.0f }); - } - - ScrollBar::~ScrollBar() { - - } - - void ScrollBar::Draw() { - - } - - void ScrollBar::SetSize(vec2 size) { - if (flags & HORIZONTAL) { - rect.size.x = size.x; - //rect.size.y = font->GetFontGlyphHeight(); - rect.size.y = ImGui::CalcEmptyGlyphHeight(); - } - else { - //rect.size.x = font->GetFontGlyphWidth(); - rect.size.x = ImGui::CalcEmptyGlyphHeight(); - rect.size.y = size.y; - } - } - - void ScrollBar::SetParams(float_t value, float_t min, - float_t max, float_t a5, float_t step, float_t step_fast) { - this->value = value; - this->field_94 = a5; - this->min = min; - this->step_fast = step_fast; - this->max = max; - this->step = step; - } - - void ScrollBar::SetParams(float_t size, float_t step, size_t items_count) { - if (!items_count) - return; - - float_t v5 = (float_t)(int64_t)items_count; - if (v5 < 0.0f) - v5 += (float_t)UINT64_MAX; - - float_t v6 = v5 * step; - if (v6 > size) { - min = 0.0f; - max = v6 - size; - field_94 = (size / v6) * (v6 - size); - dw::ScrollBar::SetValue(value); - this->step = step; - - int64_t v8 = 0; - float_t v9 = size / step; - if (v9 >= INT64_MAX) { - v9 -= INT64_MAX; - if (v9 < INT64_MAX) - v8 = INT64_MIN; - } - - int64_t v10 = (int64_t)v9; - float_t v11 = (float_t)(v8 + v10); - if (v11 < 0.0f) - v11 += UINT64_MAX; - step_fast = v11 * step; - } - else { - min = 0.0f; - max = 0.0f; - field_94 = v6; - SetValue(value); - this->step = step; - step_fast = v6; - } - } - - void ScrollBar::SetValue(float_t value) { - value = clamp_def(value, min, max); - if (round) - this->value = roundf(value / step) * step; - else - this->value = value; - } - - void ScrollBar::SetWidth(float_t value) { - vec2 glyph_size = value;//font->GetFontGlyphSize(); - if (flags & HORIZONTAL) { - rect.size.x = value; - rect.size.y = glyph_size.y; - } - else { - rect.size.x = glyph_size.x; - rect.size.y = value; - } - } - - void ScrollBar::AddSelectionListener(SelectionListener* value) { - selection_listeners.push_back(value); + parent_menu = 0; } Scrollable::Scrollable(Composite* parent, Flags flags) : Control(parent, flags), h_bar(), v_bar() { if (flags & HORIZONTAL) { h_bar = new ScrollBar(parent, HORIZONTAL); - h_bar->SetText("h_bar"); + h_bar->SetText(L"h_bar"); } if (flags & VERTICAL) { v_bar = new ScrollBar(parent, VERTICAL); - v_bar->SetText("v_bar"); + v_bar->SetText(L"v_bar"); } } @@ -485,6 +662,17 @@ namespace dw { Control::Reset(); } + int32_t Scrollable::MouseCallback(Widget::MouseCallbackData data) { + if (!v_bar) + return Control::MouseCallback(data); + + bool v4 = v_bar->field_A6; + int32_t ret = v_bar->MouseCallback(data); + if (v4 != v_bar->field_A6) + dw_gui_detail_display_sub_1402F8C90(v_bar, v_bar->field_A6); + return ret; + } + void Scrollable::SetSize(vec2 value) { Widget::SetSize(value); @@ -500,6 +688,23 @@ namespace dw { } } + void Scrollable::SetFont(p_Font& value) { + font = value; + if (h_bar) + h_bar->SetFont(value); + if (v_bar) + v_bar->SetFont(value); + } + + Widget* Scrollable::GetHitWidget(vec2 hit_pos) { + if (!CheckHitPos(hit_pos)) + return 0; + + if (v_bar && v_bar->CheckHitPos(hit_pos)) + return v_bar; + return this; + } + rectangle Scrollable::GetBoundingBox() { rectangle rect; rect.size = this->rect.size; @@ -514,6 +719,468 @@ namespace dw { return rect; } + rectangle Scrollable::GetScrollableRectangle() { + vec2 pos = GetPos(); + rectangle rect = GetBoundingBox(); + rect.pos += pos; + return rect; + } + + Composite::Composite(Composite* parent, Flags flags) : Scrollable(parent, flags) { + layout = row_layout_vertical; + current_control = -1; + } + + Composite::~Composite() { + + } + + void Composite::Draw() { + rectangle rect = GetBoundingBox(); + rect.pos = 0.0f; + + if (v_bar) + rect.pos.y = v_bar->value; + + for (Control*& i : controls) + if ((i->rect.pos.x + i->rect.size.x) > rect.pos.x && (rect.pos.x + rect.size.x) > i->rect.pos.x + && (i->rect.pos.y + i->rect.size.y) > rect.pos.y && (rect.pos.y + rect.size.y) > i->rect.pos.y) + i->UpdateDraw(); + + Scrollable::Draw(); + } + + void Composite::Reset() { + for (Control*& i : controls) + i->Free(); + + controls.clear(); + + Scrollable::Reset(); + } + + int32_t Composite::KeyCallback(Widget::KeyCallbackData data) { + if (current_control != -1 && current_control < controls.size()) + return controls[current_control]->KeyCallback(data); + else + return 0; + } + + int32_t Composite::MouseCallback(Widget::MouseCallbackData data) { + for (Control*& i : controls) + if (i->CheckHitPos(data.pos)) + return i->MouseCallback(data); + + return Scrollable::MouseCallback(data); + } + + void Composite::SetSize(vec2 size) { + Scrollable::SetSize(size); + layout->SetSize(this); + } + + void Composite::GetSetSize() { + SetSize(GetSize()); + } + + vec2 Composite::GetSize() { + return layout->GetSize(this); + } + + bool Composite::Field_58() { + current_control = -1; + return Control::Field_58(); + } + + bool Composite::Field_60() { + return current_control == -1 && Field_C0(); + } + + Widget* Composite::GetHitWidget(vec2 hit_pos) { + if (!CheckHitPos(hit_pos)) + return Scrollable::GetHitWidget(hit_pos); + + for (Control*& i : controls) { + Widget* widget = i->GetHitWidget(hit_pos); + if (widget) + return widget; + } + + return this; + } + + bool Composite::Field_C0() { + return parent_comp->sub_1402F1E60(this); + } + + bool Composite::SetCurrentControl(Control* control) { + current_control = GetControlIndex(control); + return parent_comp->SetCurrentControl(this); + } + + size_t Composite::GetControlIndex(Control* control) { + for (Control*& i : controls) + if (i == control) + return &i - controls.data(); + return -1; + } + + void Composite::SetLayout(Layout* value) { + layout = value; + } + + bool Composite::sub_1402F1E60(Control* control) { + return GetControlIndex(control) == current_control && Field_C0(); + } + + Shell::Shell(Shell* parent, Flags flags) : Composite(parent, flags), disp(), disp_callback(), + hide_callback(), field_128(), destroy(), close_button(), field_170(), field_178() { + parent_shell = this; + + if (flags & CLOSE_BUTTON) { + close_button = new ShellCloseButton(this); + if (controls.size()) + controls.pop_back(); + } + + if (parent) { + parent_comp = parent; + parent->children.push_back(this); + } + + dw_gui_detail_display->shells.push_back(this); + } + + Shell::~Shell() { + + } + + void Shell::Draw() { + if (!GetDisp()) + return; + + rectangle v12 = GetRectangle(); + bool active = dw_gui_detail_display->field_8 == this; + + print->SetColor(active + ? colors_current.active_border_color + : colors_current.inactive_border_color); + print->sub_140301390(v12, 2.0f); + + if (flags & CHECKBOX) { + rectangle v11 = v12; + v11.size.y = current_font.GetFontGlyphHeight() + 2.0f + 2.0f; + print->sub_140301390(v11, 2.0f); + + rectangle v10; + v10.pos = v11.pos + 2.0f; + v10.size = v11.size - 2.0f * 2.0f; + + print->SetFillColor(active + ? colors_current.title_background + : colors_current.title_inactive_background); + print->FillRectangle(v10); + + print->SetColor(active + ? colors_current.title_foreground + : colors_current.title_inactive_foreground); + print->SetFont(¤t_font); + print->SetClipData(v10); + + print->PrintText(GetText(), v10.pos.x, v10.pos.y); + + print->sub_140302800(); + if (close_button) + close_button->UpdateDraw(); + } + + print->SetFillColor(colors_current.background); + print->FillRectangle(GetScrollableRectangle()); + print->SetColor(colors_current.foreground); + Composite::Draw(); + + if (field_178) { + field_170 = true; + field_178->UpdateDraw(); + field_170 = false; + } + } + + void Shell::Reset() { + std::vector vec; + vec.assign(children.begin(), children.end()); + children.clear(); + + for (Widget* i : vec) + i->Free(); + + for (Menu* i : menus) + ;//i->Free(); + menus.clear(); + + if (close_button) { + close_button->Free(); + close_button = 0; + } + + if (parent_comp) { + Shell* parent_shell = dynamic_cast(parent_comp); + if (parent_shell) { + auto i = parent_shell->children.begin(); + auto i_end = parent_shell->children.end(); + while (i != i_end) + if (*i == this) { + parent_shell->children.erase(i); + break; + } + } + } + + dw_gui_detail_display->RemoveShell(this); + + Composite::Reset(); + } + + int32_t Shell::KeyCallback(Widget::KeyCallbackData data) { + if (!GetDisp()) + return 0; + + if ((data.field_8 & 0x10000) && data.field_10 == 0x100000D || (data.field_14 & 0x2000)) { + Hide(); + return 0; + } + + return Composite::KeyCallback(data); + } + + int32_t Shell::MouseCallback(Widget::MouseCallbackData data) { + if (!GetDisp()) + return 0; + + if (data.field_10 & 0xF0) { + if (!sub_140192D00()) + return 0; + + dw_gui_detail_display->AddShell(this); + } + + if (dw_gui_detail_display->field_C0.field_18 >= 1 && dw_gui_detail_display->field_C0.field_18 <= 8) { + if (data.field_10 & 0x10) { + if (sub_140192D00()) { + dw_gui_detail_display->field_C0.field_1B |= 0x20; + dw_gui_detail_display->field_20 = dw_gui_detail_display->field_8; + } + return 0; + } + } + else if (dw_gui_detail_display->field_C0.field_18 == 10) { + if (close_button && close_button->CheckHitPos(data.pos)) + return close_button->MouseCallback(data); + + if (data.field_10 & 0x10) { + if (sub_140192D00()) { + dw_gui_detail_display->field_C0.field_1B |= 0x40; + dw_gui_detail_display->field_20 = dw_gui_detail_display->field_8; + } + return 0; + } + } + + return Composite::MouseCallback(data); + } + + void Shell::SetSize(vec2 size) { + Widget::SetSize(size); + if (flags & CHECKBOX) { + if (close_button) { + vec2 size = close_button->GetSize(); + close_button->rect.pos.x = rect.size.x - size.x + 2.0f; + close_button->rect.pos.y = 2.0f; + } + } + + rectangle bounding_box = GetBoundingBox(); + if (v_bar) { + v_bar->rect.pos.x = bounding_box.pos.x + bounding_box.size.x - v_bar->rect.size.x; + v_bar->rect.pos.y = bounding_box.pos.y; + v_bar->SetWidth(bounding_box.size.y); + } + + layout->SetSize(this); + } + + vec2 Shell::GetPos() { + return rect.pos; + } + + vec2 Shell::GetSize() { + vec2 size = Composite::GetSize() + 2.0f * 2.0f; + if (flags & CHECKBOX) + size.y += current_font.GetFontGlyphHeight() + 2.0f; + return size; + } + + bool Shell::Field_58() { + return this == dw_gui_detail_display->field_8 && GetDisp(); + } + + Widget* Shell::GetHitWidget(vec2 hit_pos) { + rectangle rect = GetRectangle(); + if (rect.pos.x > hit_pos.x || hit_pos.x >= rect.pos.x + rect.size.x + || rect.pos.y > hit_pos.y || hit_pos.y >= rect.size.y + rect.pos.y) + return 0; + + if (close_button && close_button->CheckHitPos(hit_pos)) + return close_button; + + Widget* widget = Composite::GetHitWidget(hit_pos); + if (widget) + return widget; + + return this; + } + + rectangle Shell::GetBoundingBox() { + rectangle rect; + rect.pos = 2.0f; + rect.size = this->rect.size - 2.0f * 2.0f; + + if (flags & CHECKBOX) { + rect.size.y -= current_font.GetFontGlyphHeight() + 2.0f; + rect.pos.y += current_font.GetFontGlyphHeight() + 2.0f; + } + + if (v_bar) + rect.size.x -= v_bar->rect.size.x; + return rect; + } + + bool Shell::Field_C0() { + return Field_58(); + } + + bool Shell::SetCurrentControl(Control* control) { + current_control = GetControlIndex(control); + return Field_58(); + } + + void Shell::Hide() { + destroy = true; + } + + void Shell::Disp() { + SetDisp(true); + dw_gui_detail_display->AddShell(this); + dw_gui_detail_display->field_38 = this; + dw_gui_detail_display->field_40 = true; + } + + bool Shell::GetDisp() { + return disp; + } + + void Shell::SetDisp(bool value) { + if (disp == value) + return; + + disp = value; + if (disp) { + dw_gui_detail_display->AddShell(this); + dw_gui_detail_display->field_38 = this; + dw_gui_detail_display->field_40 = true; + if (disp_callback) + disp_callback(this); + } + else { + dw_gui_detail_display->field_41 = true; + if (hide_callback) + hide_callback(this); + } + } + + void Shell::sub_1402E43C0(Widget* widget) { + if (!field_178) + field_178 = widget; + } + + void Shell::sub_1402E61F0(Widget* widget) { + if (field_178 && field_178 == widget) + field_178 = 0; + } + + void Shell::sub_1402F38B0() { + sub_1402F3770(this); + Disp(); + } + + KeyListener::KeyListener() { + + } + + KeyListener::~KeyListener() { + + } + + KeyAdapter::KeyAdapter() { + + } + + KeyAdapter::~KeyAdapter() { + + } + + void KeyAdapter::Field_8(Widget::KeyCallbackData data) { + + } + + void KeyAdapter::Field_10(Widget::KeyCallbackData data) { + + } + + void KeyAdapter::Field_18(Widget::KeyCallbackData data) { + + } + + MouseListener::MouseListener() { + + } + + MouseListener::~MouseListener() { + + } + + MouseAdapter::MouseAdapter() { + + } + + MouseAdapter::~MouseAdapter() { + + } + + void MouseAdapter::Field_8(Widget::MouseCallbackData data) { + + } + + void MouseAdapter::Field_10(Widget::MouseCallbackData data) { + + } + + void MouseAdapter::Field_18(Widget::MouseCallbackData data) { + + } + + void MouseAdapter::Field_20(Widget::MouseCallbackData data) { + + } + + MouseMoveListener::MouseMoveListener() { + + } + + MouseMoveListener::~MouseMoveListener() { + + } + Layout::Layout() { } @@ -586,18 +1253,6 @@ namespace dw { } } - void FillLayout::Begin() { - - } - - void FillLayout::Next() { - - } - - void FillLayout::End() { - - } - GraphLayout::GraphLayout(Flags flags) { this->flags = flags; } @@ -618,18 +1273,6 @@ namespace dw { } } - void GraphLayout::Begin() { - - } - - void GraphLayout::Next() { - - } - - void GraphLayout::End() { - - } - GridLayout::GridLayout(size_t columns) : rows() { this->columns = columns; spacing = 2.0f; @@ -720,20 +1363,7 @@ namespace dw { } } - void GridLayout::Begin() { - - } - - void GridLayout::Next() { - - } - - void GridLayout::End() { - - } - - RowLayout::RowLayout(Flags flags) : imgui_curr_line_size(), - imgui_curr_line_text_base_offset() { + RowLayout::RowLayout(Flags flags) { this->flags = flags; spacing = 2.0f; } @@ -805,90 +1435,6 @@ namespace dw { } } - void RowLayout::Begin() { - - } - - void RowLayout::Next() { - if (flags == HORIZONTAL) { - ImGuiWindow* window = GImGui->CurrentWindow; - if (!window->SkipItems && !window->DC.IsSameLine) { - imgui_cursor_pos.x = window->DC.CursorPos.x; - imgui_cursor_pos.y = window->DC.CursorPos.y; - imgui_curr_line_size.x = window->DC.CurrLineSize.x; - imgui_curr_line_size.y = window->DC.CurrLineSize.y; - imgui_curr_line_text_base_offset = window->DC.CurrLineTextBaseOffset; - } - - ImGui::SameLine(0.0f, spacing); - } - } - - void RowLayout::End() { - if (flags == HORIZONTAL) { - ImGuiWindow* window = GImGui->CurrentWindow; - if (!window->SkipItems) { - window->DC.CursorPos.x = imgui_cursor_pos.x; - window->DC.CursorPos.y = imgui_cursor_pos.y; - window->DC.CurrLineSize.x = imgui_curr_line_size.x; - window->DC.CurrLineSize.y = imgui_curr_line_size.y; - window->DC.CurrLineTextBaseOffset = imgui_curr_line_text_base_offset; - window->DC.IsSameLine = false; - } - } - } - - Composite::Composite(Composite* parent, Flags flags) : Scrollable(parent, flags) { - layout = row_layout_vertical; - } - - Composite::~Composite() { - - } - - void Composite::Draw() { - ImGui::PushID(this); - if (layout) - layout->Begin(); - - for (Control*& i : controls) { - if (i->rect.size != 0.0f) - ImGui::SetNextItemWidth(i->rect.size.x); - i->UpdateDraw(); - if (layout) - layout->Next(); - } - - if (layout) - layout->End(); - ImGui::PopID(); - } - - void Composite::Reset() { - for (Control*& i : controls) - i->Free(); - controls.clear(); - - Scrollable::Reset(); - } - - void Composite::SetSize(vec2 size) { - Scrollable::SetSize(size); - layout->SetSize(this); - } - - void Composite::GetSetSize() { - SetSize(GetSize()); - } - - vec2 Composite::GetSize() { - return layout->GetSize(this); - } - - void Composite::SetLayout(Layout* value) { - layout = value; - } - Group::Group(Composite* parent, Flags flag) : Composite(parent, (Flags)(flags & ~(VERTICAL | HORIZONTAL))) { } @@ -898,11 +1444,93 @@ namespace dw { } void Group::Draw() { + print->SetFont(&font); + + rectangle v14 = GetRectangle(); + + float_t v4 = (float_t)(int32_t)(font.GetFontGlyphHeight() * 0.5f); + v14.pos.y += v4; + v14.size.y += v4; + + print->SetColor(colors_current.border_color); + print->sub_140301390(v14, 2.0f); + + v14.size += -1.0f; + print->SetColor(color_black); + print->sub_140301390(v14, 1.0f); + + if (GetText().size()) { + rectangle v7 = GetRectangle(); + + rectangle v14; + v14.pos.x = v7.pos.x + 2.0f; + v14.pos.y = v7.pos.y; + v14.size.x = v7.size.x + 2.0f * -2.0f; + v14.size.y = font.GetFontGlyphHeight(); + + vec2 text_size = print->GetTextSize(GetText()); + v14.size.x = min_def(text_size.x, v14.size.x); + + print->SetFillColor(colors_current.background); + print->FillRectangle(v14); + + print->SetColor(colors_current.foreground); + print->SetClipData(v14); + print->PrintText(GetText(), v14.pos.x, v14.pos.y); + } + Composite::Draw(); } - Button::Button(Composite* parent, Flags flags) : Control(parent, flags), value(), callback() { - GetSetSize(); + rectangle Group::GetBoundingBox() { + float_t glyph_height = font.GetFontGlyphHeight(); + + rectangle rect = Scrollable::GetBoundingBox(); + rect.pos.x = rect.pos.x + 2.0f; + rect.pos.y = rect.pos.y + glyph_height; + rect.size.x = rect.size.x - (2.0f * 2.0f); + rect.size.y = rect.size.y - (glyph_height + 2.0f); + return rect; + } + + Label::Label(Composite* parent, Flags flags) : Control(parent, flags) { + + } + + Label::~Label() { + + } + + void Label::Draw() { + rectangle rect = GetRectangle(); + print->SetFont(&font); + vec2 text_size = print->GetTextSize(GetText()); + + float_t pos_x; + if (flags & FLAG_4000) + pos_x = rect.pos.x; + else if (flags & FLAG_20000) + pos_x = rect.pos.x + rect.size.x - text_size.x; + else + pos_x = rect.pos.x + (rect.size.x - text_size.x) * 0.5f; + float_t pos_y = rect.pos.y + (rect.size.y - text_size.y) * 0.5f; + + print->SetColor(Field_A0() + ? colors_current.foreground + : colors_current.disable_foreground); + print->SetClipData(rect); + print->SetFont(&font); + print->PrintText(GetText(), pos_x, pos_y); + } + + vec2 Label::GetSize() { + print->SetFont(&font); + return print->GetTextSize(text) + 2.0f * 2.0f; + } + + Button::Button(Composite* parent, Flags flags) : Control(parent, flags), value(), callback(), field_100() { + field_104 = 1; + SetSize(GetSize()); } Button::~Button() { @@ -910,36 +1538,139 @@ namespace dw { } void Button::Draw() { - ImGui::PushID(this); - if (flags & CHECKBOX) { - bool value = this->value; - if (ImGui::Checkbox(text.c_str(), &value)) { - SetValue(value); - if (callback) - callback(this); + print->SetFont(&this->font); + vec2 checkbox_size = print->GetTextSize(L"[X]"); + + rectangle v6 = GetRectangle(); + rectangle v8 = v6; + + if (flags & (FLAG_8 | MULTISELECT)) { + int32_t v3; + if ((field_100 & 0x01) && (field_100 & 0x02)) { + v3 = 4; + v8.pos.x += 2.0f; + v8.size.x += -2.0f; } + else + v3 = 2; + + sub_1402EE3C0(v6, 2.0f, v3, &colors_current.button_background); + + v8.pos += 2.0f; + v8.size -= 2.0f * 2.0f; + } + else if (flags & CHECKBOX) { + print->SetColor(colors_current.button_foreground); + print->SetClipData(v8); + print->PrintText(value ? L"[X]" : L"[ ]", v8.pos.x, v8.pos.y); + + v8.size.x -= checkbox_size.x; + v8.pos.x += checkbox_size.x; } else if (flags & RADIOBUTTON) { - if (ImGui::RadioButton(text.c_str(), value)) { - SetValue(value); - if (callback) - callback(this); + print->SetColor(colors_current.button_foreground); + print->SetClipData(v8); + print->PrintText(value ? L"(*)" : L"( )", v8.pos.x, v8.pos.y); + + v8.size.x -= checkbox_size.x; + v8.pos.x += checkbox_size.x; + } + + std::wstring text = GetText(); + + print->SetFont(&font); + vec2 text_size = print->GetTextSize(text); + + if (!(flags & (CHECKBOX | RADIOBUTTON))) { + float_t v5 = (v8.size.x - text_size.x) * 0.5f; + v8.pos.x = v8.pos.x + v5; + v8.size.x = v8.size.x + (v5 * -2.0f); + } + + if (Field_A0()) { + print->SetColor(colors_current.button_foreground); + print->SetClipData(v8); + print->PrintText(text, v8.pos.x, v8.pos.y); + if (Field_60()) { + print->SetColor(colors_current.focus_border_color); + print->sub_140301390(v8, 1.0); } } else { - if (ImGui::Button(text.c_str())) { - if (callback) - callback(this); - } + print->SetColor(colors_current.button_disable_foreground); + print->SetClipData(v8); + print->PrintText(text, v8.pos.x, v8.pos.y); } - ImGui::PopID(); + } + + int32_t Button::KeyCallback(Widget::KeyCallbackData data) { + if (!Field_A0()) + return 0; + + if (data.field_10 != 13 && data.field_10 != 32) + return Control::KeyCallback(data); + + if (flags & CHECKBOX) + SetValue(!value); + else if (flags & RADIOBUTTON) + SetValue(true); + + if (callback) + callback(this); + + SelectionListener::CallbackData callback_data = this; + for (SelectionListener*& i : selection_listeners) + i->Callback(&callback_data); + + field_100 &= ~0x102; + return Control::KeyCallback(data); + } + + int32_t Button::MouseCallback(Widget::MouseCallbackData data) { + if (!Field_A0()) + return 0; + + field_100 &= ~0x01; + if (CheckHitPos(data.pos)) + field_100 |= 0x01; + + if (field_100 & 0x01) { + if ((data.field_10 & 0xF0) && !Field_60()) + Field_58(); + + if (data.field_10 & 0x100) { + if (field_100 & 0x02) + field_100 = (field_100 & ~0x02) | 0x100; + } + else if (data.field_10 & 0x10) + field_100 |= 0x2; + } + + if (field_100 & 0x100) { + field_104--; + + if (flags & CHECKBOX) + SetValue(!value); + else if (flags & RADIOBUTTON) + SetValue(true); + + if (callback) + callback(this); + + SelectionListener::CallbackData callback_data = this; + for (SelectionListener*& i : selection_listeners) + i->Callback(&callback_data); + + field_100 &= ~0x102; + field_104 = 1; + } + + return Control::MouseCallback(data); } vec2 Button::GetSize() { - //print->SetFont(font); - //vec2 size = print->GetTextSize(text); - ImVec2 _size = ImGui::CalcTextSize(text.c_str(), 0, true); - vec2 size = vec2(_size.x, _size.y); + print->SetFont(&font); + vec2 size = print->GetTextSize(text); if (flags & FLAG_8) { size.x += 2.0f; @@ -947,26 +1678,12 @@ namespace dw { size.y += 2.0f * 2.0f; } else if (flags & RADIOBUTTON) { - /*print->SetFont(font); - std::string text("(X)"); - vec2 size = print->GetTextSize(text); - ImVec2 _size = ImGui::CalcTextSize(text.c_str(), 0, true); - vec2 radiobutton_size = vec2(_size.x, _size.y); - size.x += radiobutton_size.x*/ - - ImGuiStyle& style = ImGui::GetCurrentContext()->Style; - size.x += ImGui::GetFrameHeight() + style.ItemInnerSpacing.x; + print->SetFont(&font); + size.x += print->GetTextSize("(X)").x; } else if (flags & CHECKBOX) { - /*print->SetFont(font); - std::string text("[X]"); - vec2 size = print->GetTextSize(text); - ImVec2 _size = ImGui::CalcTextSize(text.c_str(), 0, true); - vec2 checkbox_size = vec2(_size.x, _size.y); - size.x += checkbox_size.x*/ - - ImGuiStyle& style = ImGui::GetCurrentContext()->Style; - size.x += ImGui::GetFrameHeight() + style.ItemInnerSpacing.x; + print->SetFont(&font); + size.x += print->GetTextSize("[X]").x; } return size; } @@ -987,12 +1704,1081 @@ namespace dw { } } + List::List(Composite* parent, Flags flags) : Scrollable(parent, flags), field_148() { + hovered_item = -1; + selected_item = -1; + + max_items = -1; + if (flags & VERTICAL) + max_items = 10; + } + + List::~List() { + + } + + void List::Draw() { + if (flags & FLAG_800) { + rectangle rect; + color4u8* v3; + if (Field_A0()) { + rect = GetRectangle(); + v3 = 0; + } + else { + rect = GetRectangle(); + v3 = &colors_current.disable_background; + } + sub_1402EE3C0(rect, 2.0f, 2, v3); + } + + Scrollable::Draw(); + + float_t glyph_height = GetFontGlyphHeight(); + + float_t pos_y = 0.0f; + if (v_bar) + pos_y = (float_t)(int32_t)v_bar->value; + print->SetFont(&font); + + rectangle v21 = Scrollable::GetRectangle(); + + pos_y = -pos_y; + print->SetClipData(v21); + + size_t items_count = items.size(); + for (size_t i = 0; i < items_count; i++, pos_y += glyph_height) { + rectangle v22; + v22.pos.x = v21.pos.x; + v22.pos.y = v21.pos.y + pos_y; + v22.size.x = v21.size.x; + v22.size.y = glyph_height; + if (v21.pos.x + v21.size.x <= v21.pos.x + || v21.pos.y + pos_y + glyph_height <= v21.pos.y + || v21.size.y + v21.pos.y <= v21.pos.y + pos_y) + continue; + + bool selected = false; + bool hovered = false; + + color4u8 color; + if (!field_148) { + if ((flags & MULTISELECT) && selected_item == i || (flags & FLAG_2) && selections[i]) + selected = true; + + if (Field_60()) + hovered = hovered_item == i; + + if (selected) { + print->SetFillColor(colors_current.selection_background); + print->FillRectangle(v22); + color = colors_current.selection_foreground; + } + else if (Field_A0()) + color = colors_current.foreground; + else + color = colors_current.disable_foreground; + } + else { + if (hovered_item == i) { + print->SetFillColor(colors_current.popup_selection_background); + print->FillRectangle(v22); + color = colors_current.popup_selection_foreground; + } + else if (field_148) + color = colors_current.popup_foreground; + else if (Field_A0()) + color = colors_current.foreground; + else + color = colors_current.disable_foreground; + } + + print->SetColor(color); + print->SetFont(&font); + print->PrintText(items[i], v21.pos.x, pos_y + v21.pos.y); + + if (hovered) { + print->SetColor(colors_current.focus_border_color); + print->sub_140301390(v22, 1.0f); + } + } + } + + void List::Reset() { + items.clear(); + items.shrink_to_fit(); + selections.clear(); + Scrollable::Reset(); + } + + int32_t List::KeyCallback(Widget::KeyCallbackData data) { + size_t items_count = items.size(); + if (!data.field_10 || !items_count) + return Control::KeyCallback(data); + + size_t hovered_item = this->hovered_item; + + SelectionListener::CallbackData v12 = v_bar; + + size_t max_items_visible = GetMaxItemsVisible(); + switch (data.field_10) { + case 0x1000001: + if (hovered_item == -1) + hovered_item = 0; + else if (hovered_item) + hovered_item--; + + if (sub_1402F1F20(hovered_item) && !sub_1402F1F20(hovered_item)) + v12.field_8 = data.field_10; + break; + case 0x1000002: + if (hovered_item == -1) + hovered_item = 0; + else if (hovered_item < items_count - 1) + hovered_item++; + + if (sub_1402F1F20(hovered_item) && !sub_1402F1F20(hovered_item)) + v12.field_8 = data.field_10; + break; + case 0x1000005: + if (hovered_item == -1 || hovered_item < max_items_visible) + hovered_item = 0; + else + hovered_item -= max_items_visible; + v12.field_8 = data.field_10; + break; + case 0x1000006: + if (hovered_item == -1) + hovered_item = 0; + else if (max_items_visible >= items_count + || hovered_item > items_count - max_items_visible - 1) + hovered_item = items_count - 1; + else + hovered_item += max_items_visible; + v12.field_8 = data.field_10; + break; + case 0x1000007: + hovered_item = 0; + v12.field_8 = data.field_10; + break; + case 0x1000008: + hovered_item = items_count - 1; + v12.field_8 = data.field_10; + break; + } + + if (hovered_item < items_count && hovered_item != -1 && this->hovered_item != hovered_item) { + SetItemIndex(hovered_item); + + SelectionListener::CallbackData callback_data = parent; + for (SelectionListener*& i : selection_listeners) + i->Callback(&callback_data); + + if (v12.field_8 && v_bar) + ScrollBar::sub_1402E6CC0(v12); + + sub_1402F9C90(hovered_item); + } + + return Control::KeyCallback(data); + } + + int32_t List::MouseCallback(Widget::MouseCallbackData data) { + if (!Field_A0() || !CheckHitPos(data.pos)) + return 0; + + if (!field_148 && (data.field_10 & 0xF0) && !Field_60()) + Field_58(); + + rectangle v27 = GetScrollableRectangle(); + if (v27.pos.x > data.pos.x || data.pos.x >= v27.size.x + v27.pos.x + || v27.pos.y > data.pos.y || data.pos.y >= v27.size.y + v27.pos.y) + return Scrollable::MouseCallback(data); + + size_t hovered_item = this->hovered_item; + if (field_148 && (data.field_10 & 0x40000000) || (data.field_10 & 0x10)) { + float_t glyph_height = GetFontGlyphHeight(); + float_t v10 = (float_t)sub_1402EF570(); + if (v10 < 0.0f) + v10 += (float_t)UINT64_MAX; + + size_t v11 = 0; + float_t v12 = (data.pos.y - (v27.pos.y - v10 * glyph_height)) / glyph_height; + + if (v12 >= (float_t)INT64_MAX) { + v12 -= (float_t)INT64_MAX; + if (v12 < (float_t)INT64_MAX) + v11 = 0x8000000000000000u; + } + + size_t hovered_item = v11 + (int64_t)v12; + if (hovered_item < items.size()) + this->hovered_item = hovered_item; + } + + if (hovered_item < this->items.size()) { + if (data.field_10 & 0x10) { + if (data.field_14 & 0x20000) { + ResetSelectedItem(); + size_t end = this->hovered_item; + size_t begin = hovered_item; + if (end < begin) { + begin = this->hovered_item; + end = hovered_item; + } + + SetSelectedItems(begin, end); + } + else if (data.field_14 & 0x40000) { + if (CheckItemSelected(hovered_item)) + UnsetSelectedItem(hovered_item); + else + SetSelectedItem(hovered_item); + } + else { + ResetSelectedItem(); + SetSelectedItem(this->hovered_item); + } + + SelectionListener::CallbackData v26 = parent; + for (SelectionListener*& i : selection_listeners) + i->Callback(&v26); + } + + if (data.field_10 & 0x1000) { + SelectionListener::CallbackData v26 = parent; + for (SelectionListener*& i : selection_listeners) + i->Field_10(&v26); + } + } + + if ((data.field_10 & 0x100000) || (data.field_10 & 0x200000)) + return Scrollable::MouseCallback(data); + return 0; + } + + void List::SetSize(vec2 size) { + Scrollable::SetSize(size); + SetScrollBarParams(); + } + + vec2 List::GetSize() { + print->SetFont(&font); + + float_t max_text_size = 0.0f; + for (std::wstring& i : items) { + vec2 text_size = print->GetTextSize(i); + max_text_size = max_def(text_size.x, max_text_size); + } + + size_t max_items_visible = GetMaxItemsVisible(); + size_t items_count = items.size(); + float_t glyph_height = font.GetFontGlyphHeight(); + + float_t v14 = (float_t)(int64_t)min_def(max_items_visible, items_count); + if (v14 < 0.0f) + v14 += (float_t)UINT64_MAX; + + vec2 size = { max_text_size, glyph_height * v14 }; + if (v_bar) + size.x += v_bar->rect.size.x; + + if (flags & FLAG_800) + size += 2.0f * 2.0f; + return size; + } + + void List::AddItem(const std::string& str) { + items.push_back(utf8_to_utf16(str)); + } + + void List::AddItem(const std::wstring& str) { + items.push_back(str); + } + + void List::AddSelectionListener(SelectionListener* value) { + selection_listeners.push_back(value); + } + + bool List::CheckItemSelected(size_t index) { + if (index >= items.size()) + return false; + else if (flags & MULTISELECT) + return index == selected_item; + return selections[index] != 0; + } + + void List::ClearItems() { + items.clear(); + hovered_item = -1; + selected_item = -1; + } + + std::string List::GetItemStr(size_t index) const { + return utf16_to_utf8(items[index]); + } + + std::wstring List::GetItem(size_t index) const { + return items[index]; + } + + size_t List::GetItemCount() { + return items.size(); + } + + size_t List::GetMaxItemsVisible() { + if (!v_bar) + return items.size(); + else if (max_items >= items.size()) + return items.size(); + return max_items; + } + + void List::ResetSelectedItem() { + if (flags & MULTISELECT) + selected_item = -1; + else + for (int32_t& i : selections) + i = 0; + } + + void List::SetMaxItems(size_t value) { + max_items = value; + } + + void List::SetScrollBarParams() { + rectangle bb = GetBoundingBox(); + if (v_bar) + v_bar->SetParams(bb.size.y, font.GetFontGlyphHeight(), items.size()); + } + + void List::SetSelectedItem(size_t index) { + if (index < items.size()) + if (flags & MULTISELECT) + selected_item = index; + else + selections[index] = 1; + } + + void List::SetSelectedItems(size_t begin, size_t end) { + if (end < begin || end >= items.size()) + return; + + if (flags & MULTISELECT) { + if (begin == end) + selected_item = begin; + } + else + for (size_t i = begin; i <= end; i++) + selections[i] = 1; + } + + void List::UnsetSelectedItem(size_t index) { + if (index < items.size()) + if (flags & MULTISELECT) + selected_item = -1; + else + selections[index] = 0; + } + + int64_t List::sub_1402EF570() { + float_t glyph_height = GetFontGlyphHeight(); + + float_t v4 = 0.0f; + if (v_bar) + v4 = (float_t)(int32_t)(v_bar->value / glyph_height); + + int64_t v6 = 0; + if (v4 >= (float_t)INT64_MAX) { + v4 -= (float_t)INT64_MAX; + if (v4 < (float_t)INT64_MAX) + v6 = 0x8000000000000000u; + } + return v6 + (int64_t)v4; + } + + bool List::sub_1402F1F20(size_t index) { + size_t max_items_visible = GetMaxItemsVisible(); + size_t v5 = sub_1402EF570(); + return max_items_visible >= items.size() + || v5 <= index && index < max_items_visible + v5; + } + + void List::sub_1402F9680(int64_t index) { + if (!v_bar) + return; + + float_t glyph_height = GetFontGlyphHeight(); + + size_t max_items_visible = GetMaxItemsVisible(); + size_t items_count = items.size(); + if (items_count <= max_items_visible) + return; + + float_t value = 0.0f; + if (index != -1) { + if (items_count - index >= max_items_visible) + value = (float_t)index; + else + value = (float_t)(items_count - max_items_visible); + + if (value < 0.0f) + value += (float_t)UINT64_MAX; + + value *= glyph_height; + } + + v_bar->SetValue(value); + } + + void List::sub_1402F9C90(size_t index) { + if (!sub_1402F1F20(index)) + sub_1402F9680(index); + } + + ListBox::ListBox(Composite* parent, Flags flags) : Composite(parent, flags), list(), field_118() { + list = new List(parent, flags); + list->field_148 = true; + list->SetText(L"ddl"); + list->parent = this; + + if (list->v_bar) { + list->v_bar->parent = this; + list->v_bar->AddSelectionListener(&drop_down_list_scroll_bar_selection_listener); + } + } + + ListBox::~ListBox() { + delete list; + } + + void ListBox::Draw() { + if (!parent_shell->field_170) { + rectangle v13 = GetRectangle(); + sub_1402EE3C0(v13, 2.0, 4, Field_A0() + ? &colors_current.disable_background + : &colors_current.background); + v13.pos = v13.pos + 2.0f; + v13.size = v13.size - 2.0f * 2.0f; + + rectangle v14 = v13; + + vec2 glyph_size = font.GetFontGlyphSize(); + + rectangle v15; + v15.pos = v13.pos + v13.size - glyph_size; + v15.size = glyph_size; + + print->SetFont(&font); + print->SetColor(colors_current.foreground); + print->sub_140301390(v15, 1.0f); + print->SetClipData(v15); + print->PrintText(L"v", v15.pos.x, v15.pos.y); + + v14.size.x -= glyph_size.x; + + if (Field_60()) { + print->SetColor(colors_current.focus_border_color); + print->sub_140301390(v14, 1.0f); + } + + if (list->selected_item < list->items.size()) { + print->SetFont(&font); + print->SetColor(Field_A0() + ? colors_current.disable_foreground + : colors_current.foreground); + print->SetClipData(v14); + print->PrintText(GetItem(list->selected_item), v14.pos.x, v14.pos.y); + } + } + + if (parent_shell->field_170 && field_118) { + rectangle rect = GetListRectangle(); + print->SetFillColor(colors_current.popup_background); + print->FillRectangle(rect); + list->UpdateDraw(); + print->SetColor(color_black); + print->sub_140301390(rect, 1.0f); + } + } + + void ListBox::Reset() { + Composite::Reset(); + } + + int32_t ListBox::KeyCallback(Widget::KeyCallbackData data) { + if (!Field_A0()) + return 0; + + list->KeyCallback(data); + if (field_118 && data.field_10 == 13) + sub_1402E4F40(); + return 0; + } + + int32_t ListBox::MouseCallback(Widget::MouseCallbackData data) { + if (!Field_A0()) + return 0; + + if ((data.field_10 & 0xF0) && !Field_60()) + Field_58(); + + if (field_118) { + list->MouseCallback(data); + + if ((data.field_10 & 0x10) + && (!list->CheckHitPos(data.pos) || ListBox::sub_1402EC8C0(list->GetRectangle(), data.pos))) { + sub_1402E4F40(); + return 0; + } + } + else if (CheckHitPos(data.pos) && (data.field_10 & 0x10)) + sub_1402E4F90(); + return 0; + } + + vec2 ListBox::GetSize() { + vec2 size = list->GetSize(); + size.x += font.GetFontGlyphWidth(); + size.y = font.GetFontGlyphHeight(); + return size + 2.0f * 2.0f; + } + + void ListBox::SetFont(p_Font& value) { + Scrollable::SetFont(value); + + if (list) + list->SetFont(value); + } + + rectangle ListBox::GetListRectangle() { + return list->GetRectangle(); + } + + void ListBox::sub_1402E4440() { + rectangle rect = GetRectangle(); + vec2 size = list->GetSize(); + + vec2 pos; + if (dw_gui_detail_display->init_data.field_0.pos.y + + dw_gui_detail_display->init_data.field_0.size.y > rect.pos.y + rect.size.y + size.y) + pos.y = rect.size.y; + else + pos.y = -size.y; + + list->rect.pos = pos; + list->SetSize({ max_def(rect.size.x, size.x), size.y }); + } + + void ListBox::sub_1402E4F40() { + parent_shell->sub_1402E61F0(this); + dw_gui_detail_display_sub_1402F8C90(this, false); + + list->hovered_item = list->selected_item; + field_118 = false; + } + + void ListBox::sub_1402E4F90() { + field_118 = true; + sub_1402E4440(); + + list->hovered_item = list->selected_item; + list->sub_1402F9C90(list->selected_item); + + dw_gui_detail_display_sub_1402F8C90(this, true); + parent_shell->sub_1402E43C0(this); + } + + bool ListBox::sub_1402EC8C0(rectangle rect, vec2 pos) { + return (rect.pos.x <= pos.x && pos.x < rect.pos.x + rect.size.x) + && (rect.pos.y <= pos.y && pos.y < rect.pos.y + rect.size.y); + } + + ScrollBar::ScrollBar(Control* parent, Flags flags) : Widget(parent, flags), + value(), min(), field_A0(), field_A5(), field_A6() { + parent_control = parent; + max = 100.0f; + field_94 = 10.0f; + step = 1.0f; + step_fast = 10.0f; + round = true; + font = p_font_type_scroll_bar; + SetSize({ 8.0f, 8.0f }); + } + + ScrollBar::~ScrollBar() { + + } + + void ScrollBar::Draw() { + rectangle v14 = GetRectangle(); + print->SetColor(colors_current.border_color); + print->sub_140301390(v14, 1.0f); + print->SetClipData(v14); + print->SetColor(Field_60() + ? colors_current.foreground + : colors_current.disable_foreground); + print->SetFont(&font); + + vec2 glyph_size = font.GetFontGlyphSize(); + rectangle v16; + v16.pos = v14.pos; + v16.size = glyph_size; + + if (flags & HORIZONTAL) { + print->sub_140301390(v16, 1.0f); + print->PrintText(L"<", v14.pos.x, v14.pos.y); + v16.pos.x = v14.size.x + v14.pos.x - glyph_size.x; + print->sub_140301390(v16, 1.0f); + print->PrintText(L">", v14.size.x + v14.pos.x - v16.size.x, v14.pos.y); + + rectangle v18 = v14; + v18.pos.x = v14.pos.x + glyph_size.x; + v18.size.x = v14.size.x - v16.size.x * 2.0f; + print->SetFillColor(color_grey); + print->FillRectangle(v18); + + vec2 v11 = sub_1402E4790(); + rectangle v17 = v18; + v17.pos.x = v11.x + v18.pos.x; + v17.size.x = v11.y; + print->SetFillColor(colors_current.background); + print->FillRectangle(v17); + print->sub_140301390(v17, 1.0f); + print->PrintText(L"#", v17.size.x * 0.5f + v17.pos.x - glyph_size.x * 0.5f, v17.pos.y); + } + else { + print->sub_140301390(v16, 1.0f); + print->PrintText(L"A", v14.pos.x, v14.pos.y); + + v16.pos.y = v14.size.y + v14.pos.y - glyph_size.y; + print->sub_140301390(v16, 1.0f); + print->PrintText(L"V", v14.pos.x, v14.size.y + v14.pos.y - v16.size.y); + + rectangle v18 = v14; + v18.pos.y = v14.pos.y + glyph_size.y; + v18.size.y = v14.size.y - v16.size.y * 2.0f; + print->SetFillColor(color_grey); + print->FillRectangle(v18); + + vec2 v11 = sub_1402E4790(); + rectangle v17 = v18; + v17.pos.y = v11.x + v18.pos.y; + v17.size.y = v11.y; + print->SetFillColor(colors_current.background); + print->FillRectangle(v17); + print->sub_140301390(v17, 1.0f); + print->PrintText(L"#", v17.pos.x, v17.size.y * 0.5f + v17.pos.y - glyph_size.y * 0.5f); + } + + } + + int32_t ScrollBar::KeyCallback(Widget::KeyCallbackData data) { + if (!Field_60()) + return 0; + + SelectionListener::CallbackData v6 = sub_1402E5140(data); + if (v6.widget) + for (SelectionListener*& i : selection_listeners) + i->Callback(&v6); + return 0; + } + + int32_t ScrollBar::MouseCallback(Widget::MouseCallbackData data) { + if (!Field_60()) + return 0; + + bool v4 = field_A6; + SelectionListener::CallbackData v8 = sub_1402E5380(data); + if (v4 != field_A6) + dw_gui_detail_display_sub_1402F8C90(this, field_A6); + + if (v8.widget) + for (SelectionListener*& i : selection_listeners) + i->Callback(&v8); + + return 0; + } + + void ScrollBar::SetSize(vec2 size) { + if (flags & HORIZONTAL) { + rect.size.x = size.x; + rect.size.y = font.GetFontGlyphHeight(); + } + else { + rect.size.x = font.GetFontGlyphWidth(); + rect.size.y = size.y; + } + } + + vec2 ScrollBar::GetPos() { + vec2 pos = rect.pos; + Control* control = GetParentControl(); + if (control) { + pos += control->GetPos(); + Scrollable* scrollable = dynamic_cast(control); + if (scrollable && scrollable->flags & FLAG_800) + pos += 2.0f; + } + return pos; + } + + Control* ScrollBar::GetParentControl() { + return parent_control; + } + + void ScrollBar::SetFont(p_Font& value) { + font = value; + } + + bool ScrollBar::Field_58() { + return !field_A5; + } + + bool ScrollBar::Field_60() { + return GetParentControl()->Field_A0() && Field_58(); + } + + void ScrollBar::Field_68(bool value) { + field_A5 = !value; + } + + void ScrollBar::SetParams(float_t value, float_t min, + float_t max, float_t a5, float_t step, float_t step_fast) { + this->value = value; + this->field_94 = a5; + this->min = min; + this->step_fast = step_fast; + this->max = max; + this->step = step; + } + + void ScrollBar::SetParams(float_t size, float_t step, size_t items_count) { + if (!items_count) + return; + + float_t v5 = (float_t)(int64_t)items_count; + if (v5 < 0.0f) + v5 += (float_t)UINT64_MAX; + + float_t v6 = v5 * step; + if (v6 > size) { + min = 0.0f; + max = v6 - size; + field_94 = (size / v6) * (v6 - size); + ScrollBar::SetValue(value); + this->step = step; + + size_t v8 = 0; + float_t v9 = size / step; + if (v9 >= (float_t)INT64_MAX) { + v9 -= (float_t)INT64_MAX; + if (v9 < (float_t)INT64_MAX) + v8 = INT64_MIN; + } + + float_t v11 = (float_t)(int64_t)(v8 + (int64_t)v9); + if (v11 < 0.0f) + v11 += (float_t)UINT64_MAX; + step_fast = v11 * step; + } + else { + min = 0.0f; + max = 0.0f; + field_94 = v6; + SetValue(value); + this->step = step; + step_fast = v6; + } + } + + void ScrollBar::SetValue(float_t value) { + value = clamp_def(value, min, max); + if (round) + this->value = roundf(value / step) * step; + else + this->value = value; + } + + void ScrollBar::SetWidth(float_t value) { + vec2 glyph_size = font.GetFontGlyphSize(); + if (flags & HORIZONTAL) { + rect.size.x = value; + rect.size.y = glyph_size.y; + } + else { + rect.size.x = glyph_size.x; + rect.size.y = value; + } + } + + void ScrollBar::AddSelectionListener(SelectionListener* value) { + selection_listeners.push_back(value); + } + + vec2 ScrollBar::sub_1402E4790() { + vec2 glyph_size = font.GetFontGlyphSize(); + + float_t _glyph_size; + float_t size; + if (flags & HORIZONTAL) { + _glyph_size = glyph_size.x; + size = rect.size.x; + } + else + { + _glyph_size = glyph_size.y; + size = rect.size.y; + } + + size -= _glyph_size * 2.0f; + float_t range = max - min; + if (range > 0.0) { + float_t v10 = (field_94 * (1.0f / range)) * size; + if (v10 < 20.0f) + v10 = 20.0f; + + float_t v11 = ((value - min) * (1.0f / range)) * (size - v10); + return { v10, v11 }; + } + + return { 0.0f, size }; + } + + SelectionListener::CallbackData ScrollBar::sub_1402E5140(Widget::KeyCallbackData key_callback_data) { + SelectionListener::CallbackData callback_data; + switch (key_callback_data.field_10) { + case 0x1000001: + case 0x1000002: + case 0x1000005: + case 0x1000006: + case 0x1000007: + case 0x1000008: + callback_data.field_8 = key_callback_data.field_10; + break; + case 0x1000003: + callback_data.field_8 = 0x1000001; + break; + case 0x1000004: + callback_data.field_8 = 0x1000002; + break; + default: + break; + } + + if (callback_data.field_8 != -1) { + callback_data.widget = this; + ScrollBar::sub_1402E6CC0(callback_data); + callback_data.widget = parent; + } + + return callback_data; + } + + SelectionListener::CallbackData ScrollBar::sub_1402E5380(Widget::MouseCallbackData mouse_callback_data) { + SelectionListener::CallbackData callback_data; + if (field_A6) { + if (mouse_callback_data.field_10 & 0x01) { + callback_data.field_8 = 1; + callback_data.field_10 = mouse_callback_data.pos; + } + else { + callback_data.field_8 = 0; + field_A6 = false; + } + + if (callback_data.field_8 != -1) { + callback_data.widget = this; + ScrollBar::sub_1402E6CC0(callback_data); + callback_data.widget = this->parent; + } + return callback_data; + } + + if (mouse_callback_data.field_10 & 0x100000) + callback_data.field_8 = 0x1000071; + else if (mouse_callback_data.field_10 & 0x200000) + callback_data.field_8 = 0x1000072; + + if (callback_data.field_8 == -1 && !CheckHitPos(mouse_callback_data.pos)) + return callback_data; + + vec2 v25 = font.GetFontGlyphSize(); + rectangle v24 = GetRectangle(); + + float_t v8; + float_t v9; + float_t v10; + float_t v11; + if (flags & HORIZONTAL) { + v8 = v25.x; + v9 = mouse_callback_data.pos.x; + v10 = v25.x + v24.pos.x; + v11 = v24.size.x + v24.pos.x; + } + else { + v8 = v25.y; + v9 = mouse_callback_data.pos.y; + v10 = v25.y + v24.pos.y; + v11 = v24.size.y + v24.pos.y; + } + + if (mouse_callback_data.field_10 & 0x1000000) { + if (v9 < v10) + callback_data.field_8 = 0x1000001; + else if (v11 - v8 < v9) + callback_data.field_8 = 0x1000002; + else { + vec2 v23 = sub_1402E4790(); + if (v9 < v23.x + v10) + callback_data.field_8 = 0x1000005; + else if (v23.x + v10 + v23.y < v9) + callback_data.field_8 = 0x1000006; + } + } + + if (callback_data.field_8 == -1 && (mouse_callback_data.field_10 & 0x01) + && (mouse_callback_data.field_10 & 0x40000000)) { + vec2 v23 = sub_1402E4790(); + rectangle v24 = GetRectangle(); + + float_t v14 = v24.pos.x; + float_t v15 = v24.pos.y; + float_t v17; + float_t v18; + if (flags & HORIZONTAL) { + v14 = v24.pos.x + v25.x + v23.x; + v17 = v23.y; + v18 = v24.size.y; + } + else { + v15 = v24.pos.y + v25.y + v23.x; + v18 = v23.y; + v17 = v24.size.x; + } + + if (v14 <= mouse_callback_data.pos.x && mouse_callback_data.pos.x < v17 + v14 + && v15 <= mouse_callback_data.pos.y && mouse_callback_data.pos.y < (v18 + v15)) { + field_A6 = true; + if (flags & HORIZONTAL) + field_A0 = mouse_callback_data.pos.x - (v17 * 0.5f + v14); + else + field_A0 = mouse_callback_data.pos.y - (v18 * 0.5f + v15); + + callback_data.field_8 = 1; + callback_data.field_10 = mouse_callback_data.pos; + } + } + + if (callback_data.field_8 != -1) { + callback_data.widget = this; + ScrollBar::sub_1402E6CC0(callback_data); + callback_data.widget = this->parent; + } + return callback_data; + } + + void ScrollBar::sub_1402E6CC0(SelectionListener::CallbackData data) { + if (!data.field_8) + return; + + ScrollBar* scroll_bar = dynamic_cast(data.widget); + if (!scroll_bar) + return; + + float_t value = scroll_bar->value; + switch (data.field_8) { + case 1: { + vec2 glyph_size = scroll_bar->font.GetFontGlyphSize(); + rectangle v14 = scroll_bar->GetRectangle(); + float_t v6; + float_t v7; + float_t v8; + float_t v9; + if (scroll_bar->flags & HORIZONTAL) { + v6 = glyph_size.x; + v7 = data.field_10.x; + v8 = v14.pos.x + glyph_size.x; + v9 = v14.pos.x + v14.size.x; + } + else { + v6 = glyph_size.y; + v7 = data.field_10.y; + v8 = v14.pos.y + glyph_size.y; + v9 = v14.pos.y + v14.size.y; + } + + float_t v10 = v7 - scroll_bar->field_A0; + vec2 size = scroll_bar->sub_1402E4790(); + float_t v11 = v9 - v6 - v8 - v14.pos.y; + float_t v12 = v8 + size.y * 0.5f; + if (v12 >= v10) + value = scroll_bar->min; + else if (v10 >= v12 + v11) + value = scroll_bar->max; + else + value = scroll_bar->min + (v10 - v8 - size.y * 0.5f) / v11 * (scroll_bar->max - scroll_bar->min); + } break; + case 0x1000001: + value -= scroll_bar->step; + break; + case 0x1000002: + value += scroll_bar->step; + break; + case 0x1000005: + value -= scroll_bar->step_fast; + break; + case 0x1000006: + value += scroll_bar->step_fast; + break; + case 0x1000007: + value = scroll_bar->min; + break; + case 0x1000008: + value = scroll_bar->max; + break; + case 0x1000071: + if (scroll_bar->flags & VERTICAL) + value += scroll_bar->step * -3.0f; + break; + case 0x1000072: + if (scroll_bar->flags & VERTICAL) + value += scroll_bar->step * 3.0f; + break; + } + scroll_bar->SetValue(value); + } + + DropDownListScrollBarSelectionListener::DropDownListScrollBarSelectionListener() { + + } + + DropDownListScrollBarSelectionListener::~DropDownListScrollBarSelectionListener() { + + } + + void DropDownListScrollBarSelectionListener::Callback(SelectionListener::CallbackData* data) { + + } + + ScrollBarTestSelectionListener::ScrollBarTestSelectionListener() { + + } + + ScrollBarTestSelectionListener::~ScrollBarTestSelectionListener() { + + } + + void ScrollBarTestSelectionListener::Callback(SelectionListener::CallbackData* data) { + + } + ShellCloseButton::ShellCloseButton(Shell* parent) : Button(parent) { SetSize({ 14.0f, 14.0f }); - SetText("Close Box"); + SetText(L"Close Box"); callback = Callback; - //field_100 = 0; - //field_104 = 4; + field_100 = 0; + field_104 = 4; } ShellCloseButton::~ShellCloseButton() { @@ -1009,364 +2795,6 @@ namespace dw { close_button->parent_shell->Hide(); } - Shell::Shell(Shell* parent, Flags flags) : Composite(parent, flags), - disp(), disp_callback(), hide_callback(), destroy(), close_button() { - parent_shell = this; - - if (flags & CLOSE_BUTTON) { - close_button = new ShellCloseButton(this); - if (controls.size()) - controls.pop_back(); - } - - if (parent) { - parent_comp = parent; - parent->children.push_back(this); - } - - dw_gui_detail_display->shells.push_back(this); - } - - Shell::~Shell() { - - } - - void Shell::Draw() { - if (!GetDisp()) - return; - - ImGui::SetNextWindowPos({ rect.pos.x, rect.pos.y }, ImGuiCond_Appearing); - if (rect.size != 0.0f) - ImGui::SetNextWindowSize({ rect.size.x, rect.size.y }, ImGuiCond_Appearing); - - bool open = true; - ImGui::PushID(this); - if (ImGui::Begin(text.c_str(), close_button ? &open : 0)) - Composite::Draw(); - input_locked |= ImGui::IsWindowFocused(); - ImGui::End(); - ImGui::PopID(); - - if (close_button && !open) - close_button->callback(close_button); - } - - void Shell::Reset() { - std::vector vec; - vec.assign(children.begin(), children.end()); - children.clear(); - - for (Widget* i : vec) - i->Free(); - - /*for (Menu* i : menus) - i->Free(); - menus.clear();*/ - - if (close_button) { - close_button->Free(); - close_button = 0; - } - - if (parent_comp) { - Shell* parent_shell = dynamic_cast(parent_comp); - if (parent_shell) { - auto i = parent_shell->children.begin(); - auto i_end = parent_shell->children.end(); - while (i != i_end) - if (*i == this) { - parent_shell->children.erase(i); - break; - } - } - } - - dw_gui_detail_display->RemoveShell(this); - - Composite::Reset(); - } - - void Shell::Hide() { - destroy = true; - } - - void Shell::SetSize(vec2 size) { - Widget::SetSize(size); - if (flags & CHECKBOX) { - if (close_button) { - vec2 size = close_button->GetSize(); - close_button->rect.pos.x = rect.size.x - size.x + 2.0f; - close_button->rect.pos.y = 2.0f; - } - } - - rectangle bounding_box = GetBoundingBox(); - if (v_bar) { - v_bar->rect.pos.x = bounding_box.pos.x + bounding_box.size.x - v_bar->rect.size.x; - v_bar->rect.pos.y = bounding_box.pos.y; - v_bar->SetWidth(bounding_box.size.y); - } - - layout->SetSize(this); - } - - vec2 Shell::GetPos() { - return rect.pos; - } - - vec2 Shell::GetSize() { - vec2 size = Composite::GetSize(); - size.x += 2.0f * 2.0f; - size.y += 2.0f * 2.0f; - /*if (flags & CHECKBOX) - size.y += p_dw__font_type_8x16_0_get_font_glyph_height() + 2.0f;*/ - return size; - } - - rectangle Shell::GetBoundingBox() { - rectangle rect; - rect.pos = 2.0f; - rect.size = this->rect.size - 2.0f * 2.0f; - - /*if (flags & CHECKBOX) { - rect.size.y -= p_dw__font_type_8x16_0_get_font_glyph_height() + 2.0f; - rect.pos.y += p_dw__font_type_8x16_0_get_font_glyph_height() + 2.0f; - }*/ - - if (v_bar) - rect.size.x -= v_bar->rect.size.x; - return rect; - } - - void Shell::Disp() { - SetDisp(true); - dw_gui_detail_display->AddShell(this); - //dw_gui_detail_display->field_38 = this; - //dw_gui_detail_display->field_40 = true; - } - - bool Shell::GetDisp() { - return disp; - } - - void Shell::SetDisp(bool value) { - if (disp == value) - return; - - disp = value; - if (disp) { - dw_gui_detail_display->AddShell(this); - //dw_gui_detail_display->field_38 = this; - //dw_gui_detail_display->field_40 = true; - if (disp_callback) - disp_callback(this); - } - else { - //dw_gui_detail_display->field_41 = true; - if (hide_callback) - hide_callback(this); - } - } - - void Shell::sub_1402F38B0() { - //sub_1402F3770(); - Disp(); - } - - List::List(Composite* parent, Flags flags) : Scrollable(parent, flags) { - hovered_item = -1; - selected_item = -1; - } - - List::~List() { - - } - - void List::Draw() { - - } - - void List::Reset() { - items.clear(); - Scrollable::Reset(); - } - - void List::SetSize(vec2 size) { - Scrollable::SetSize(size); - SetScrollBarParams(); - } - - vec2 List::GetSize() { - //print->SetFont(); - - float_t max_text_size = 0.0f; - for (std::string& i : items) { - //vec2 text_size = print->GetTextSize(i); - ImVec2 _text_size = ImGui::CalcTextSize(i.c_str()); - vec2 text_size(_text_size.x, _text_size.y); - max_text_size = max_def(text_size.x, max_text_size); - } - - size_t v7 = sub_1402EF620(); - size_t v8 = items.size(); - //float_t v12 = font->GetFontGlyphHeight(); - float_t v12 = ImGui::CalcEmptyGlyphHeight(); - float_t v14 = (float_t)(int64_t)min_def(v7, v8); - if (v14 < 0.0f) - v14 += (float_t)UINT64_MAX; - - vec2 size = { max_text_size, v12 * v14 }; - if (v_bar) - size.x += v_bar->rect.size.x; - - if (flags & FLAG_800) - size += 2.0f * 2.0f; - return size; - } - - void List::AddItem(const std::string& str) { - items.push_back(str); - } - - void List::AddItem(const std::string&& str) { - items.push_back(str); - } - - void List::AddSelectionListener(SelectionListener* value) { - selection_listeners.push_back(value); - } - - void List::ClearItems() { - items.clear(); - hovered_item = -1; - selected_item = -1; - } - - std::string List::GetItem(size_t index) const { - return items[index]; - } - - size_t List::GetItemCount() { - return items.size(); - } - - void List::ResetSelectedItem() { - if (flags & MULTISELECT) - selected_item = -1; - else - for (int32_t& i : selections) - i = 0; - } - - void List::ResetSetSelectedItem(size_t index) { - ResetSelectedItem(); - SetSelectedItem(index); - } - - void List::SetItemIndex(size_t index) { - hovered_item = index; - ResetSetSelectedItem(index); - } - - void List::SetScrollBarParams() { - rectangle bb = GetBoundingBox(); - if (v_bar) - //v_bar->SetParams(bb.size.y, font->GetFontGlyphHeight(), items.size()); - v_bar->SetParams(bb.size.y, ImGui::CalcEmptyGlyphHeight(), items.size()); - } - - void List::SetSelectedItem(size_t index) { - if (index < items.size()) - if (flags & MULTISELECT) - selected_item = index; - else - selections[index] = 1; - } - - size_t List::sub_1402EF620() { - if (!v_bar) - return items.size(); - /*else if (field_140 >= this->items.size()) - return items.size(); - return field_140;*/ - return 0; - } - - ListBox::ListBox(Composite* parent, Flags flags) : Composite(parent, flags), list() { - list = new List(parent, flags); - list->SetText("ddl"); - list->parent = this; - - if (list->v_bar) { - list->v_bar->parent = this; - list->v_bar->AddSelectionListener(&drop_down_list_scroll_bar_selection_listener); - } - } - - ListBox::~ListBox() { - delete list; - } - - void ListBox::Draw() { - bool window_focus = false; - - std::vector& items = list->items; - size_t hovered_item = list->selected_item; - size_t selected_item = list->selected_item; - ImGui::SetNextItemWidth(rect.size.x); - ImGui::PushID(this); - if (ImGui::BeginCombo("##", selected_item != -1 - && items.size() ? items[selected_item].c_str() : "", 0)) { - for (std::string& i : items) { - size_t item = &i - items.data(); - - ImGui::PushID(&i); - if (ImGui::Selectable(i.c_str(), selected_item == item) - || ImGui::ItemKeyPressed(ImGuiKey_Enter) - || (ImGui::IsItemFocused() && selected_item != item)) { - selected_item = item; - list->selected_item = -1; - } - - if (ImGui::IsItemHovered()) - hovered_item = item; - ImGui::PopID(); - - if (selected_item == item) - ImGui::SetItemDefaultFocus(); - } - - window_focus |= true; - ImGui::EndCombo(); - } - ImGui::PopID(); - - if (list->hovered_item != hovered_item) - list->hovered_item = hovered_item; - - if (list->selected_item != selected_item) { - list->selected_item = selected_item; - for (SelectionListener*& i : list->selection_listeners) - i->Callback(this); - } - - input_locked |= window_focus; - } - - void ListBox::Reset() { - Composite::Reset(); - } - - vec2 ListBox::GetSize() { - vec2 size = list->GetSize(); - //size.x += font->GetFontGlyphWidth(); - //size.y = font->GetFontGlyphHeight(); - ImVec2 _size = ImGui::CalcEmptyGlyphSize(); - size.x += _size.x; - size.y = _size.y; - return size + 2.0f * 2.0f; - } - Slider::Slider(Composite* parent, Flags flags) : Control(parent, flags) { format = "%f"; scroll_bar = new ScrollBar(this, (Flags)(flags & (HORIZONTAL | VERTICAL))); @@ -1378,14 +2806,33 @@ namespace dw { } void Slider::Draw() { - ScrollBar* scroll_bar = this->scroll_bar; - ImGui::PushID(this); - bool ret = ImGui::ColumnSliderFloatButton(text.c_str(), &scroll_bar->value, - scroll_bar->step, scroll_bar->min, scroll_bar->max, scroll_bar->step_fast, format, 0); - ImGui::PopID(); - if (ret) - for (SelectionListener*& i : selection_listeners) - i->Callback(this); + rectangle rect = GetRectangle(); + print->SetClipData(rect); + + float_t pos_x = 0.0f; + if (GetText().size()) { + print->SetFont(&font); + print->SetColor(Field_A0() + ? colors_current.foreground + : colors_current.disable_foreground); + print->PrintText(GetText(), rect.pos.x, rect.pos.y); + pos_x = font.GetFontGlyphWidth() + print->GetTextSize(GetText()).x; + } + + print->SetFont(&font); + print->SetColor(Field_A0() + ? colors_current.foreground + : colors_current.disable_foreground); + + char buf[256]; + sprintf_s(buf, sizeof(buf), format, scroll_bar->value); + print->PrintText(buf, rect.pos.x + pos_x, rect.pos.y); + + scroll_bar->UpdateDraw(); + if (Field_A0() && Field_60()) { + print->SetColor(colors_current.focus_border_color); + print->sub_140301390(GetRectangle(), 1.0f); + } } void Slider::Reset() { @@ -1412,50 +2859,141 @@ namespace dw { Slider* slider = new Slider(parent, flags); ScrollBar* scroll_bar = slider->scroll_bar; slider->SetText(text); - scroll_bar->SetText("slider's bar"); + scroll_bar->SetText(L"slider's bar"); scroll_bar->SetSize({ width, height }); - //print->SetFont(font); + print->SetFont(&slider->font); vec2 size; if (flags & HORIZONTAL) { - //vec2 v21 = print->GetTextSize(slider->text); - //vec2 v22 = print->GetTextSize("0000"); - ImVec2 _v21 = ImGui::CalcTextSize(slider->text.c_str()); - ImVec2 _v22 = ImGui::CalcTextSize("0000"); - vec2 v21 = { _v21.x, _v21.y }; - vec2 v22 = { _v22.x, _v22.y }; + vec2 v21 = print->GetTextSize(slider->text); + vec2 v22 = print->GetTextSize(L"0000"); scroll_bar->rect.pos.x = v21.x + v22.x; scroll_bar->rect.pos.y = 0.0f; size.x = v21.x + v22.x + scroll_bar->rect.size.x; - //size.y = p_dw__Font::GetFontGlyphHeight(&slider->font); - size.y = ImGui::CalcEmptyGlyphHeight(); + size.y = slider->font.GetFontGlyphHeight(); } else { - //vec2 v21 = print->GetTextSize(slider->text); - //vec2 v22 = print->GetTextSize("0000"); - ImVec2 _v21 = ImGui::CalcTextSize(slider->text.c_str()); - ImVec2 _v22 = ImGui::CalcTextSize("0000"); - vec2 v21 = { _v21.x, _v21.y }; - vec2 v22 = { _v22.x, _v22.y }; - //size.x = p_dw__Font::GetFontGlyphWidth(&slider->font); - size.x = ImGui::CalcEmptyGlyphHeight(); + vec2 v21 = print->GetTextSize(slider->text); + vec2 v22 = print->GetTextSize(L"0000"); + size.x = slider->font.GetFontGlyphWidth(); size.y = v21.x + v22.x + scroll_bar->rect.size.y; } slider->rect.pos = { pos_x, pos_y }; slider->SetSize(size); return slider; } + + init_data::init_data() { + + } + + void font_init() { + font_type_6x12 = new Font(16, "FONT_TYPE_6x12", true); + font_type_6x12->SetGlyphSize(6.0f, 12.0f); + + font_type_8x12 = new Font(16, "FONT_TYPE_8x12", true); + font_type_8x12->SetGlyphSize(8.0f, 12.0f); + + font_type_8x16 = new Font(16, "FONT_TYPE_8x16", true); + font_type_8x16->SetGlyphSize(8.0f, 16.0f); + + font_type_10x16 = new Font(0, "FONT_TYPE_10x16"); + font_type_10x16->SetGlyphSize(10.0f, 16.0f); + + font_type_10x20 = new Font(16, "FONT_TYPE_10x20", true); + font_type_10x20->SetGlyphSize(10.0, 20.0); + + font_type_12x24 = new Font(16, "FONT_TYPE_12x24", true); + font_type_12x24->SetGlyphSize(12.0f, 24.0f); + + p_font_type_6x12 = font_type_6x12; + p_font_type_8x12 = font_type_8x12; + p_font_type_8x16 = font_type_8x16; + p_font_type_10x16 = font_type_10x16; + p_font_type_10x20 = font_type_10x20; + p_font_type_12x24 = font_type_12x24; + current_font = font_type_8x16; + + font_type_scroll_bar = new Font(font_type_8x16->font.font_handler_index, + "FONT_TYPE_SCROLL_BAR", font_type_8x16->half_width); + font_type_scroll_bar->SetGlyphSize( + font_type_8x16->GetFontGlyphWidth() * 2.0f, + font_type_8x16->GetFontGlyphHeight()); + p_font_type_scroll_bar = font_type_scroll_bar; + + font_collection.insert_or_assign(0, &p_font_type_10x16); + font_collection.insert_or_assign(1, &p_font_type_8x12); + font_collection.insert_or_assign(2, &p_font_type_8x16); + font_collection.insert_or_assign(3, &p_font_type_10x20); + font_collection.insert_or_assign(4, &p_font_type_12x24); + font_collection.insert_or_assign(5, &p_font_type_6x12); + } + + int32_t font_get_index(std::string& name) { + for (auto& i : font_collection) + if (!i.second->GetName().compare(name)) { + current_font = *i.second; + return i.first; + } + + return -1; + } + + void font_free() { + delete font_type_scroll_bar; + delete font_type_12x24; + delete font_type_10x20; + delete font_type_10x16; + delete font_type_8x16; + delete font_type_8x12; + delete font_type_6x12; + } } -void dw_gui_detail_display_init() { +void dw_init() { + dw::init_data init_data; + resolution_struct* res_wind = res_window_get(); + init_data.field_10.size.x = (float_t)res_wind->width; + init_data.field_10.size.y = (float_t)res_wind->height; + init_data.field_0.size = init_data.field_10.size; + dw_init(init_data); +} + +void dw_init(dw::init_data& init_data) { + dw::colors_current = dw::colors_default; + + //dw::set_color_list(&dw::colors_current); + dw::font_init(); + + if (!dw::print) + dw::print = new dw::Print(init_data.field_0.size.x, init_data.field_0.size.y); + + dw::print->SetColor(dw::colors_current.foreground); + dw::print->SetFillColor(dw::colors_current.background); + if (!dw_gui_detail_display) - dw_gui_detail_display = new dw_gui_detail::Display; + dw_gui_detail_display = new dw_gui_detail::Display(init_data); + + if (!dw::text_buf) + dw::text_buf = new std::wstring; } -void dw_gui_detail_display_free() { +void dw_free() { if (dw_gui_detail_display) { delete dw_gui_detail_display; dw_gui_detail_display = 0; } + + if (dw::text_buf) { + delete dw::text_buf; + dw::text_buf = 0; + } + + if (dw::print) { + delete dw::print; + dw::print = 0; + } + + dw::font_free(); } void dw_gui_ctrl_disp() { @@ -1465,8 +3003,148 @@ void dw_gui_ctrl_disp() { dw_gui_detail_display->Draw(); }; -dw_gui_detail::Display::Display() { +int32_t sub_140192D00() { + //return dword_140EDA6B8; + return 1; +} +void sub_140194880(int32_t a1) { + if (a1 > 2) + a1 = 0; + dword_140EDA6B8 = a1; +} + +PrintWorkDebug::PrintWorkDebug() { + prio = spr::SPR_PRIO_29; + SetResolutionMode(RESOLUTION_MODE_MAX); +} + +namespace dw { + Print::Print(float_t width, float_t height) { + font = ¤t_font; + print_work = new PrintWorkDebug; + field_10 = color_black; + field_14 = color_white; + field_18 = { 0.0f, 0.0f, width, height }; + clip_data = field_18; + field_38 = 1.0f; + } + + Print::~Print() { + delete print_work; + } + + void Print::FillRectangle(rectangle rect) { + if (rect.size.x > 0.0f && rect.size.y > 0.0f) + print_work->FillRectangle(rect); + } + + vec2 Print::GetTextSize(std::string& str) { + return GetTextSize(utf8_to_utf16(str)); + } + + vec2 Print::GetTextSize(std::wstring& str) { + return print_work->GetTextSize(str.c_str(), str.c_str() + str.size()); + } + + vec2 Print::GetTextSize(const wchar_t* str, size_t length) { + return print_work->GetTextSize(str, str + length); + } + + void Print::PrintText(std::string& str, float_t pos_x, float_t pos_y) { + PrintText(utf8_to_utf16(str), pos_x, pos_y); + } + + void Print::PrintText(std::wstring& str, float_t pos_x, float_t pos_y) { + PrintWorkDebug* print_work = this->print_work; + print_work->line_origin_loc = { pos_x, pos_y }; + print_work->text_current_loc = print_work->line_origin_loc; + print_work->PrintText(app::TEXT_FLAG_ALIGN_FLAG_LEFT, str.c_str(), str.c_str() + str.size()); + } + + void Print::SetColor(color4u8 value) { + print_work->color = value; + } + + void Print::SetFillColor(color4u8 value) { + print_work->fill_color = value; + } + + void Print::SetClipData(rectangle rect) { + clip_data = rect; + print_work->clip = true; + print_work->clip_data = clip_data; + } + + void Print::SetFont(p_Font* value) { + this->font = value; + print_work->SetFont(&value->ptr->font); + } + + void Print::sub_140301390(rectangle rect, float_t a3) { + print_work->fill_color = print_work->color; + + rectangle v10; + v10.pos.x = rect.pos.x; + v10.pos.y = rect.pos.y; + v10.size.x = a3; + v10.size.y = rect.size.y; + FillRectangle(v10); + + v10.pos.x = rect.size.x + rect.pos.x - a3; + FillRectangle(v10); + + v10.pos.x = a3 + rect.pos.x; + v10.pos.y = rect.pos.y; + v10.size.x = rect.size.x - a3 - a3; + v10.size.y = a3; + FillRectangle(v10); + + v10.pos.y = rect.size.y + rect.pos.y - a3; + FillRectangle(v10); + + print_work->fill_color = field_14; + } + + void Print::sub_140302800() { + SetClipData(field_18); + } +} + +struc_751::struc_751() : field_10(), field_14(), field_18(), field_1A(), field_1B(), +field_1C(), field_1D(), field_20(), field_28(), field_2C(), field_30() { + +} + +dw_gui_detail::Display::RootKeySelection::RootKeySelection() { + +} + +dw_gui_detail::Display::RootKeySelection::~RootKeySelection() { + +} + +void dw_gui_detail::Display::RootKeySelection::Field_8(dw::Widget::KeyCallbackData data) { + +} + +dw_gui_detail::Display::Display(dw::init_data& init_data) : field_8(), field_10(), +field_18(), field_20(), field_28(), field_30(), field_38(), field_41(), field_118() { + field_40 = true; + init_data = init_data; + field_128 = 1.0f; + field_120 = (1.0f / field_128) * init_data.field_10.size; + name.assign(L"Display"); + + /*drag_bounds_control = new dw::DragBoundsControl; + drag_bounds_control->rect.pos = this->init_data.field_0.pos; + drag_bounds_control->SetSize(this->init_data.field_0.size); + drag_bounds_control->AddKeyListener(&root_key_selection); + + v10 = new dw::Menu(drag_bounds_control); + v10->SetText(L"RootMenu"); + v10->sub_140306E90(); + drag_bounds_control->>SetParentMenu(v10);*/ } dw_gui_detail::Display::~Display() { @@ -1494,29 +3172,51 @@ void dw_gui_detail::Display::CheckShells() { if (vec.size()) { for (dw::Shell* i : vec) i->Free(); - //field_41 = true; + field_41 = true; } } void dw_gui_detail::Display::Ctrl() { + //field_C0.sub_140300A10(); + mouse_callback_data.pos = field_C0.field_0; + mouse_callback_data.field_10 = field_C0.field_10; + mouse_callback_data.field_14 = field_C0.field_14; + key_callback_data.field_8 = field_C0.field_14; + key_callback_data.field_D = field_C0.field_28; + key_callback_data.field_10 = field_C0.field_2C; + key_callback_data.field_14 = field_C0.field_30; + + /*if (sub_1402E51F0()) + sub_1402E5630();*/ + CheckShells(); FreeWidgets(); } void dw_gui_detail::Display::Draw() { - for (dw::Shell* i : shells) + dw::print->SetColor(dw::colors_current.foreground); + //drag_bounds_control->UpdateDraw(); + + for (dw::Shell*& i : shells) if (i->GetDisp()) i->UpdateDraw(); + + /*for (dw::Menu*& i : menus) + i->UpdateDraw();*/ + dw::print->SetColor(dw::colors_current.foreground); + //field_C0.sub_1403011A0(); } void dw_gui_detail::Display::FreeWidgets() { for (auto& i : free_widgets) { delete i; - /*if (field_28 == i) + + if (field_28 == i) field_28 = 0; if (field_30 == i) - field_30 = 0;*/ + field_30 = 0; } + free_widgets.clear(); } @@ -1529,7 +3229,7 @@ void dw_gui_detail::Display::RemoveShell(dw::Shell* value) { break; } - /*if (field_8 == value) { + if (field_8 == value) { field_8 = 0; field_41 = true; } @@ -1538,7 +3238,7 @@ void dw_gui_detail::Display::RemoveShell(dw::Shell* value) { field_18 = 0; if (field_20 == value) - field_20 = 0;*/ + field_20 = 0; } static bool dw_gui_get_ctrl() { @@ -1550,3 +3250,57 @@ static bool dw_gui_get_disp() { //return false; return true; } + +static void dw_gui_detail_display_sub_1402F8C90(dw::Widget* widget, bool set) { + dw_gui_detail_display->field_30 = set ? widget : 0; +} + +static void sub_1402EE3C0(rectangle rect, float_t a2, int32_t type, color4u8* color) { + if (type != 2 && type != 4) + return; + + color4u8 v26 = type == 2 ? dw::colors_current.border_light_color : dw::colors_current.border_dark_color; + color4u8 v25 = type == 2 ? dw::colors_current.border_dark_color : dw::colors_current.border_light_color; + + rectangle v24a; + v24a.pos.x = rect.pos.x; + v24a.pos.y = rect.pos.y; + v24a.size.x = rect.size.x; + v24a.size.y = a2; + dw::print->SetFillColor(v26); + dw::print->FillRectangle(v24a); + + rectangle v24b; + v24b.pos.x = rect.pos.x; + v24b.pos.y = rect.pos.y + a2; + v24b.size.x = a2; + v24b.size.y = rect.size.y - a2; + dw::print->SetFillColor(v26); + dw::print->FillRectangle(v24b); + + rectangle v24c; + v24c.pos.x = rect.pos.x + rect.size.x - a2; + v24c.pos.y = rect.pos.y + a2; + v24c.size.x = a2; + v24c.size.y = rect.size.y - a2; + dw::print->SetFillColor(v25); + dw::print->FillRectangle(v24c); + + rectangle v24d; + v24d.pos.x = rect.pos.x + a2; + v24d.pos.y = rect.pos.y + rect.size.y - a2; + v24d.size.x = rect.size.x - a2; + v24d.size.y = a2; + dw::print->SetFillColor(v25); + dw::print->FillRectangle(v24d); + + if (color) { + rectangle v24; + v24.pos.x = a2 + rect.pos.x; + v24.pos.y = a2 + rect.pos.y; + v24.size.x = rect.size.x - a2 - a2; + v24.size.y = rect.size.y - a2 - a2; + dw::print->SetFillColor(*color); + dw::print->FillRectangle(v24); + } +} diff --git a/src/ReDIVA/dw.hpp b/src/ReDIVA/dw.hpp index 72ea9632..d915d136 100644 --- a/src/ReDIVA/dw.hpp +++ b/src/ReDIVA/dw.hpp @@ -8,6 +8,7 @@ #include "../KKdLib/default.hpp" #include "../KKdLib/vec.hpp" #include "../CRE/sprite.hpp" +#include "font_info.hpp" #include namespace dw { @@ -30,14 +31,128 @@ namespace dw { FLAG_8000 = 0x08000, FLAG_10000 = 0x10000, FLAG_20000 = 0x20000, + }; - // Added - LABEL_SIZE = 0x80000, + struct Font { + font_info font; + std::string name; + bool half_width; + + Font(int32_t font_handler_index, std::string& name); + Font(int32_t font_handler_index, std::string& name, bool half_width); + + inline Font(int32_t font_handler_index, std::string&& name) + : Font(font_handler_index, name) { + + } + + inline Font(int32_t font_handler_index, std::string&& name, bool half_width) + : Font(font_handler_index, name, half_width) { + + } + + ~Font(); + + float_t GetFontGlyphHeight(); + vec2 GetFontGlyphSize(); + float_t GetFontGlyphWidth(); + std::string GetName(); + void SetGlyphSize(float_t glyph_width, float_t glyph_height); + }; + + struct p_Font { + Font* ptr; + + p_Font(); + + inline p_Font(Font* ptr) { + this->ptr = ptr; + } + + ~p_Font(); + + float_t GetFontGlyphHeight(); + vec2 GetFontGlyphSize(); + float_t GetFontGlyphWidth(); + std::string GetName(); + void SetGlyphSize(float_t glyph_width, float_t glyph_height); + }; + + class Widget; + + class SelectionListener { + public: + struct CallbackData { + int64_t field_0; + int32_t field_8; + int8_t field_C; + vec2 field_10; + int32_t field_18; + Widget* widget; + + inline CallbackData() : field_0(), field_8(), field_C(), field_18(), widget() { + field_8 = -1; + } + + inline CallbackData(Widget* widget) : field_0(), field_8(), field_C(), field_18() { + this->widget = widget; + } + }; + + typedef void(*CallbackFunc)(SelectionListener::CallbackData* data); + + SelectionListener(); + virtual ~SelectionListener(); + + virtual void Callback(CallbackData* data) = 0; + virtual void Field_10(CallbackData* data) = 0; + }; + + class SelectionAdapter : public SelectionListener { + public: + SelectionAdapter(); + virtual ~SelectionAdapter() override; + + virtual void Callback(SelectionListener::CallbackData* data) override; + virtual void Field_10(SelectionListener::CallbackData* data) override; + }; + + class SelectionListenerOnHook : public SelectionAdapter { + public: + typedef void(*CallbackFunc)(Widget* widget); + + CallbackFunc callback; + + SelectionListenerOnHook(); + SelectionListenerOnHook(SelectionListenerOnHook::CallbackFunc callback); + virtual ~SelectionListenerOnHook() override; + + virtual void Callback(SelectionListener::CallbackData* data) override; }; class Widget { public: - typedef void(*Callback)(Widget* data); + typedef void(*Callback)(Widget* widget); + + struct KeyCallbackData { + Widget* field_0; + int32_t field_8; + int8_t field_C; + int8_t field_D; + int32_t field_10; + int32_t field_14; + + KeyCallbackData(); + }; + + struct MouseCallbackData { + Widget* field_0; + vec2 pos; + int32_t field_10; + int32_t field_14; + + MouseCallbackData(); + }; bool free; @@ -54,90 +169,306 @@ namespace dw { } callback_data; Callback free_callback; - std::string text; + std::wstring text; rectangle rect; Widget* parent; Flags flags; + p_Font font; Widget(Widget* parent = 0, Flags flags = (Flags)0); virtual ~Widget(); virtual void Draw(); virtual void Reset(); - virtual std::string GetText(); - virtual void SetText(std::string& str); + virtual std::wstring GetText(); + virtual void SetText(std::wstring& str); virtual void SetSize(vec2 value); + virtual int32_t KeyCallback(Widget::KeyCallbackData data); + virtual int32_t MouseCallback(Widget::MouseCallbackData data); virtual vec2 GetPos(); + bool CheckHitPos(vec2 hit_pos); void Free(); + float_t GetFontGlyphHeight(); rectangle GetRectangle(); - void SetText(std::string&& str); + void SetText(std::string& str); void UpdateDraw(); + + inline void SetText(std::wstring&& str) { + SetText(str); + } + + inline void SetText(std::string&& str) { + SetText(str); + } + + static void sub_1402F3770(Widget* widget); }; - class SelectionListener { - public: - SelectionListener(); - virtual ~SelectionListener(); - - virtual void Callback(Widget* data) = 0; - virtual void Field_10(Widget* data) = 0; - }; - - class SelectionAdapter : public SelectionListener { - public: - SelectionAdapter(); - virtual ~SelectionAdapter() override; - - virtual void Callback(Widget* data) override; - virtual void Field_10(Widget* data) override; - }; - - class SelectionListenerOnHook : public SelectionAdapter { - public: - Widget::Callback callback; - - SelectionListenerOnHook(); - SelectionListenerOnHook(Widget::Callback callback); - virtual ~SelectionListenerOnHook() override; - - virtual void Callback(Widget* data) override; - }; - - class DropDownListScrollBarSelectionListener : public SelectionAdapter { - public: - DropDownListScrollBarSelectionListener(); - virtual ~DropDownListScrollBarSelectionListener() override; - - virtual void Callback(Widget* data) override; - }; - - class ScrollBarTestSelectionListener : public SelectionAdapter { - public: - ScrollBarTestSelectionListener(); - virtual ~ScrollBarTestSelectionListener() override; - - virtual void Callback(Widget* data) override; - }; - + class KeyListener; + class MouseListener; + class MouseMoveListener; class Composite; class Shell; + class Menu; class Control : public Widget { public: + bool field_68; + color4u8 foreground_color; + color4u8 background_color; + std::vector key_listener; + std::vector mouse_listener; + std::vector mouse_move_listener; Composite* parent_comp; Shell* parent_shell; - //Menu* parent_menu; + Menu* parent_menu; Control(Composite* parent = 0, Flags flags = (Flags)0); virtual ~Control() override; virtual void Draw() override; virtual void Reset() override; + virtual int32_t KeyCallback(Widget::KeyCallbackData data) override; + virtual int32_t MouseCallback(Widget::MouseCallbackData data) override; virtual vec2 GetPos() override; virtual void GetSetSize(); virtual vec2 GetSize(); + virtual bool Field_58(); + virtual bool Field_60(); + virtual void SetFont(p_Font& font); + virtual p_Font& GetFont(); + virtual void SetForegroundColor(color4u8 value); + virtual void SetBackgroundColor(color4u8 value); + virtual color4u8 GetForegroundColor(); + virtual color4u8 GetBackgroundColor(); + virtual bool Field_98(); + virtual bool Field_A0(); + virtual void Field_A8(bool value); + virtual Widget* GetHitWidget(vec2 hit_pos); + + void SetParentMenu(Menu* menu); + }; + + class ScrollBar; + + class Scrollable : public Control { + public: + ScrollBar* h_bar; + ScrollBar* v_bar; + + Scrollable(Composite* parent = 0, Flags flags = (Flags)0); + virtual ~Scrollable() override; + + virtual void Draw() override; + virtual void Reset() override; + virtual int32_t MouseCallback(Widget::MouseCallbackData data) override; + virtual void SetSize(vec2 value) override; + virtual void SetFont(p_Font& font) override; + virtual Widget* GetHitWidget(vec2 hit_pos) override; + + virtual rectangle GetBoundingBox(); + + rectangle GetScrollableRectangle(); + }; + + class Layout; + + class Composite : public Scrollable { + public: + size_t current_control; + Layout* layout; + std::vector controls; + + Composite(Composite* parent = 0, Flags flags = (Flags)0); + virtual ~Composite() override; + + virtual void Draw() override; + virtual void Reset() override; + virtual int32_t KeyCallback(Widget::KeyCallbackData data) override; + virtual int32_t MouseCallback(Widget::MouseCallbackData data) override; + virtual void SetSize(vec2 size) override; + + virtual void GetSetSize() override; + virtual vec2 GetSize() override; + virtual bool Field_58() override; + virtual bool Field_60() override; + virtual Widget* GetHitWidget(vec2 hit_pos) override; + + virtual bool Field_C0(); + virtual bool SetCurrentControl(Control* control); + + size_t GetControlIndex(Control* control); + void SetLayout(Layout* value); + + bool sub_1402F1E60(Control* control); + }; + + class ShellCloseButton; + + class Shell : public Composite { + public: + typedef void(*Callback)(Shell* data); + + bool disp; + Callback disp_callback; + Callback hide_callback; + int64_t field_128; + bool destroy; + ShellCloseButton* close_button; + std::vector children; + std::vector menus; + bool field_170; + Widget* field_178; + + Shell(Shell* parent = 0, Flags flags + = (Flags)(FLAG_400 | FLAG_80 | CLOSE_BUTTON | CHECKBOX | RADIOBUTTON)); + virtual ~Shell() override; + + virtual void Draw() override; + virtual void Reset() override; + virtual int32_t KeyCallback(Widget::KeyCallbackData data) override; + virtual int32_t MouseCallback(Widget::MouseCallbackData data) override; + virtual void SetSize(vec2 size) override; + virtual vec2 GetPos() override; + + virtual vec2 GetSize() override; + virtual bool Field_58() override; + virtual Widget* GetHitWidget(vec2 hit_pos) override; + + virtual rectangle GetBoundingBox() override; + + virtual bool Field_C0() override; + virtual bool SetCurrentControl(Control* control) override; + + virtual void Hide(); + + void Disp(); + bool GetDisp(); + void SetDisp(bool value); + + void sub_1402E43C0(Widget* widget); + void sub_1402E61F0(Widget* widget); + void sub_1402F38B0(); + }; + + class KeyListener { + public: + KeyListener(); + virtual ~KeyListener(); + + virtual void Field_8(Widget::KeyCallbackData data) = 0; + virtual void Field_10(Widget::KeyCallbackData data) = 0; + virtual void Field_18(Widget::KeyCallbackData data) = 0; + }; + + class KeyAdapter : public KeyListener { + public: + KeyAdapter(); + virtual ~KeyAdapter() override; + + virtual void Field_8(Widget::KeyCallbackData data) override; + virtual void Field_10(Widget::KeyCallbackData data) override; + virtual void Field_18(Widget::KeyCallbackData data) override; + }; + + class MouseListener { + public: + MouseListener(); + virtual ~MouseListener(); + + virtual void Field_8(Widget::MouseCallbackData data) = 0; + virtual void Field_10(Widget::MouseCallbackData data) = 0; + virtual void Field_18(Widget::MouseCallbackData data) = 0; + virtual void Field_20(Widget::MouseCallbackData data) = 0; + }; + + class MouseAdapter : public MouseListener { + public: + MouseAdapter(); + virtual ~MouseAdapter() override; + + virtual void Field_8(Widget::MouseCallbackData data) override; + virtual void Field_10(Widget::MouseCallbackData data) override; + virtual void Field_18(Widget::MouseCallbackData data) override; + virtual void Field_20(Widget::MouseCallbackData data) override; + }; + + class MouseMoveListener { + public: + MouseMoveListener(); + virtual ~MouseMoveListener(); + + virtual void Field_8(Widget::MouseCallbackData data) = 0; + }; + + class Layout { + public: + Layout(); + virtual ~Layout(); + + virtual vec2 GetSize(Composite* comp) = 0; + virtual void SetSize(Composite* comp) = 0; + }; + + class FillLayout : public Layout { + public: + Flags flags; + + FillLayout(Flags flags = VERTICAL); + virtual ~FillLayout() override; + + virtual vec2 GetSize(Composite* comp) override; + virtual void SetSize(Composite* comp) override; + }; + + class GraphLayout : public Layout { + public: + Flags flags; + + GraphLayout(Flags flags = VERTICAL); + virtual ~GraphLayout() override; + + virtual vec2 GetSize(Composite* comp) override; + virtual void SetSize(Composite* comp) override; + }; + + class GridLayout : public Layout { + public: + size_t rows; + std::vector column_size; + std::vector row_size; + size_t columns; + vec2 spacing; + + GridLayout(size_t columns = 2); + virtual ~GridLayout() override; + + virtual vec2 GetSize(Composite* comp) override; + virtual void SetSize(Composite* comp) override; + }; + + class RowLayout : public Layout { + public: + Flags flags; + float_t spacing; + + RowLayout(Flags flags = VERTICAL); + virtual ~RowLayout() override; + + virtual vec2 GetSize(Composite* comp) override; + virtual void SetSize(Composite* comp) override; + }; + + class Group : public Composite { + public: + Group(Composite* parent = 0, Flags flags = (Flags)0); + virtual ~Group() override; + + virtual void Draw() override; + + virtual rectangle GetBoundingBox() override; }; class Label : public Control { @@ -149,9 +480,204 @@ namespace dw { virtual vec2 GetSize() override; }; + class Button : public Control { + public: + bool value; + std::vector selection_listeners; + Widget::Callback callback; + int32_t field_100; + int32_t field_104; + + Button(Composite* parent = 0, Flags flags = (Flags)0); + virtual ~Button() override; + + virtual void Draw() override; + virtual int32_t KeyCallback(Widget::KeyCallbackData data) override; + virtual int32_t MouseCallback(Widget::MouseCallbackData data) override; + + virtual vec2 GetSize() override; + + void AddSelectionListener(SelectionListener* value); + void SetValue(bool value); + }; + + class List : public Scrollable { + public: + std::vector items; + std::vector selections; + size_t hovered_item; + size_t selected_item; + std::vector selection_listeners; + size_t max_items; + bool field_148; + + List(Composite* parent = 0, Flags flags = (Flags)0); + virtual ~List() override; + + virtual void Draw() override; + virtual void Reset() override; + virtual int32_t KeyCallback(Widget::KeyCallbackData data) override; + virtual int32_t MouseCallback(Widget::MouseCallbackData data) override; + virtual void SetSize(vec2 size) override; + + virtual vec2 GetSize() override; + + void AddItem(const std::string& str); + void AddItem(const std::wstring& str); + void AddSelectionListener(SelectionListener* value); + bool CheckItemSelected(size_t index); + void ClearItems(); + std::string GetItemStr(size_t index) const; + std::wstring GetItem(size_t index) const; + size_t GetItemCount(); + size_t GetMaxItemsVisible(); + void ResetSelectedItem(); + void SetMaxItems(size_t value); + void SetScrollBarParams(); + void SetSelectedItem(size_t index); + void SetSelectedItems(size_t begin, size_t end); + void UnsetSelectedItem(size_t index); + + inline void AddItem(const std::string&& str) { + AddItem(str); + } + + inline void AddItem(const std::wstring&& str) { + AddItem(str); + } + + inline std::string GetHoveredItemStr() { + return GetItemStr(hovered_item); + } + + inline std::wstring GetHoveredItem() { + return GetItem(hovered_item); + } + + inline std::string GetSelectedItemStr() { + return GetItemStr(selected_item); + } + + inline std::wstring GetSelectedItem() { + return GetItem(selected_item); + } + + inline void ResetSetSelectedItem(size_t index) { + ResetSelectedItem(); + SetSelectedItem(index); + } + + inline void SetItemIndex(size_t index) { + hovered_item = index; + ResetSetSelectedItem(index); + } + + int64_t sub_1402EF570(); + bool sub_1402F1F20(size_t index); + void sub_1402F9680(int64_t index); + void sub_1402F9C90(size_t index); + }; + + class ListBox : public Composite { + public: + List* list; + bool field_118; + + ListBox(Composite* parent = 0, Flags flags = (Flags)(VERTICAL | MULTISELECT)); + virtual ~ListBox() override; + + virtual void Draw() override; + virtual void Reset() override; + virtual int32_t KeyCallback(Widget::KeyCallbackData data) override; + virtual int32_t MouseCallback(Widget::MouseCallbackData data) override; + + virtual vec2 GetSize() override; + virtual void SetFont(p_Font& value) override; + + rectangle GetListRectangle(); + + inline void AddItem(const std::string& str) { + if (list) + list->AddItem(str); + } + + inline void AddItem(const std::string&& str) { + if (list) + list->AddItem(str); + } + + inline void AddSelectionListener(SelectionListener* value) { + if (list) + list->AddSelectionListener(value); + } + + inline void ClearItems() { + if (list) + list->ClearItems(); + } + + inline std::string GetItemStr(size_t index) { + if (list) + return list->GetItemStr(index); + return {}; + } + + inline std::wstring GetItem(size_t index) { + if (list) + return list->GetItem(index); + return {}; + } + + inline size_t GetItemCount() { + if (list) + return list->GetItemCount(); + return 0; + } + + inline std::string GetHoveredItemStr() { + if (list) + return list->GetHoveredItemStr(); + return {}; + } + + inline std::wstring GetHoveredItem() { + if (list) + return list->GetHoveredItem(); + return {}; + } + + inline std::string GetSelectedItemStr() { + if (list) + return list->GetSelectedItemStr(); + return {}; + } + + inline std::wstring GetSelectedItem() { + if (list) + return list->GetSelectedItem(); + return {}; + } + + inline void SetItemIndex(size_t index) { + if (list) + list->SetItemIndex(index); + } + + inline void SetMaxItems(size_t value) { + if (list) + list->SetMaxItems(value); + } + + void sub_1402E4440(); + void sub_1402E4F40(); + void sub_1402E4F90(); + + static bool sub_1402EC8C0(rectangle rect, vec2 pos); + }; + class ScrollBar : public Widget { public: - Control* field_68; + Control* parent_control; std::vector selection_listeners; float_t value; float_t min; @@ -161,8 +687,8 @@ namespace dw { float_t step_fast; float_t field_A0; bool round; - char field_A5; - char field_A6; + bool field_A5; + bool field_A6; __int64 field_A8; __int64 field_B0; __int64 field_B8; @@ -192,7 +718,16 @@ namespace dw { virtual ~ScrollBar() override; virtual void Draw() override; + virtual int32_t KeyCallback(Widget::KeyCallbackData data) override; + virtual int32_t MouseCallback(Widget::MouseCallbackData data) override; virtual void SetSize(vec2 value) override; + virtual vec2 GetPos() override; + + virtual Control* GetParentControl(); + virtual void SetFont(p_Font& value); + virtual bool Field_58(); + virtual bool Field_60(); + virtual void Field_68(bool value); void SetParams(float_t value, float_t min, float_t max, float_t a5, float_t step, float_t step_fast); @@ -201,297 +736,22 @@ namespace dw { void SetWidth(float_t value); void AddSelectionListener(SelectionListener* value); - }; - class Scrollable : public Control { - public: - ScrollBar* h_bar; - ScrollBar* v_bar; + vec2 sub_1402E4790(); + SelectionListener::CallbackData sub_1402E5140(Widget::KeyCallbackData key_callback_data); + SelectionListener::CallbackData sub_1402E5380(Widget::MouseCallbackData mouse_callback_data); - Scrollable(Composite* parent = 0, Flags flags = (Flags)0); - virtual ~Scrollable() override; - - virtual void Draw() override; - virtual void Reset() override; - virtual void SetSize(vec2 value) override; - - virtual rectangle GetBoundingBox(); - }; - - class Layout { - public: - Layout(); - virtual ~Layout(); - - virtual vec2 GetSize(Composite* comp) = 0; - virtual void SetSize(Composite* comp) = 0; - - // Added - virtual void Begin() = 0; - virtual void Next() = 0; - virtual void End() = 0; - }; - - class FillLayout : public Layout { - public: - Flags flags; - - FillLayout(Flags flags = VERTICAL); - virtual ~FillLayout() override; - - virtual vec2 GetSize(Composite* comp) override; - virtual void SetSize(Composite* comp) override; - - // Added - virtual void Begin() override; - virtual void Next() override; - virtual void End() override; - }; - - class GraphLayout : public Layout { - public: - Flags flags; - - GraphLayout(Flags flags = VERTICAL); - virtual ~GraphLayout() override; - - virtual vec2 GetSize(Composite* comp) override; - virtual void SetSize(Composite* comp) override; - - // Added - virtual void Begin() override; - virtual void Next() override; - virtual void End() override; - }; - - class GridLayout : public Layout { - public: - size_t rows; - std::vector column_size; - std::vector row_size; - size_t columns; - vec2 spacing; - - GridLayout(size_t columns = 2); - virtual ~GridLayout() override; - - virtual vec2 GetSize(Composite* comp) override; - virtual void SetSize(Composite* comp) override; - - // Added - virtual void Begin() override; - virtual void Next() override; - virtual void End() override; - }; - - class RowLayout : public Layout { - public: - Flags flags; - float_t spacing; - - // Added - vec2 imgui_cursor_pos; - vec2 imgui_curr_line_size; - float_t imgui_curr_line_text_base_offset; - - RowLayout(Flags flags = VERTICAL); - virtual ~RowLayout() override; - - virtual vec2 GetSize(Composite* comp) override; - virtual void SetSize(Composite* comp) override; - - // Added - virtual void Begin() override; - virtual void Next() override; - virtual void End() override; - }; - - class Composite : public Scrollable { - public: - Layout* layout; - std::vector controls; - - Composite(Composite* parent = 0, Flags flags = (Flags)0); - virtual ~Composite() override; - - virtual void Draw() override; - virtual void Reset() override; - virtual void SetSize(vec2 size) override; - - virtual void GetSetSize() override; - virtual vec2 GetSize() override; - - void SetLayout(Layout* value); - }; - - class Group : public Composite { - public: - Group(Composite* parent = 0, Flags flags = (Flags)0); - virtual ~Group() override; - - virtual void Draw() override; - }; - - class Button : public Control { - public: - bool value; - std::vector selection_listeners; - Widget::Callback callback; - - Button(Composite* parent = 0, Flags flags = (Flags)0); - virtual ~Button() override; - - virtual void Draw() override; - virtual vec2 GetSize() override; - - void AddSelectionListener(SelectionListener* value); - void SetValue(bool value); + static void sub_1402E6CC0(SelectionListener::CallbackData callback_data); }; class ShellCloseButton : public Button { public: - ShellCloseButton(dw::Shell* parent); + ShellCloseButton(Shell* parent); virtual ~ShellCloseButton() override; virtual void Draw() override; - static void Callback(dw::Widget* data); - }; - - class Shell : public Composite { - public: - typedef void(*Callback)(Shell* data); - - bool disp; - Callback disp_callback; - Callback hide_callback; - bool destroy; - ShellCloseButton* close_button; - std::vector children; - //std::vector menus; - - Shell(Shell* parent = 0, Flags flags - = (Flags)(FLAG_400 | FLAG_80 | CLOSE_BUTTON | CHECKBOX | RADIOBUTTON)); - virtual ~Shell() override; - - virtual void Draw() override; - virtual void Reset() override; - virtual void SetSize(vec2 size) override; - virtual vec2 GetPos() override; - - virtual vec2 GetSize() override; - - virtual rectangle GetBoundingBox() override; - - virtual void Hide(); - - void Disp(); - bool GetDisp(); - void SetDisp(bool value); - - void sub_1402F38B0(); - }; - - class List : public Scrollable { - public: - std::vector items; - std::vector selections; - size_t hovered_item; - size_t selected_item; - std::vector selection_listeners; - - List(Composite* parent = 0, Flags flags = (Flags)0); - virtual ~List() override; - - virtual void Draw() override; - virtual void Reset() override; - virtual void SetSize(vec2 size) override; - - virtual vec2 GetSize() override; - - void AddItem(const std::string& str); - void AddItem(const std::string&& str); - void AddSelectionListener(SelectionListener* value); - void ClearItems(); - std::string GetItem(size_t index) const; - size_t GetItemCount(); - void ResetSelectedItem(); - void ResetSetSelectedItem(size_t index); - void SetItemIndex(size_t index); - void SetScrollBarParams(); - void SetSelectedItem(size_t index); - - inline std::string GetHoveredItem() { - return GetItem(hovered_item); - } - - inline std::string GetSelectedItem() { - return GetItem(selected_item); - } - - size_t sub_1402EF620(); - }; - - class ListBox : public Composite { - public: - List* list; - - ListBox(Composite* parent = 0, Flags flags = (Flags)(VERTICAL | MULTISELECT)); - virtual ~ListBox() override; - - virtual void Draw() override; - virtual void Reset() override; - - virtual vec2 GetSize() override; - - inline void AddItem(const std::string& str) { - if (list) - list->AddItem(str); - } - - inline void AddItem(const std::string&& str) { - if (list) - list->AddItem(str); - } - - inline void AddSelectionListener(SelectionListener* value) { - if (list) - list->AddSelectionListener(value); - } - - inline void ClearItems() { - if (list) - list->ClearItems(); - } - - inline std::string GetItem(size_t index) { - if (list) - return list->GetItem(index); - return {}; - } - - inline size_t GetItemCount() { - if (list) - return list->GetItemCount(); - return 0; - } - - inline std::string GetHoveredItem() { - if (list) - return list->GetHoveredItem(); - return {}; - } - - inline std::string GetSelectedItem() { - if (list) - return list->GetSelectedItem(); - return {}; - } - - inline void SetItemIndex(size_t index) { - if (list) - list->SetItemIndex(index); - } + static void Callback(Widget* data); }; class Slider : public Control { @@ -510,7 +770,7 @@ namespace dw { void AddSelectionListener(SelectionListener* value); static Slider* make(Composite* parent = 0, - Flags flags = (dw::Flags)(dw::FLAG_800 | dw::HORIZONTAL), + Flags flags = (Flags)(FLAG_800 | HORIZONTAL), float_t pos_x = 0.0f, float_t pos_y = 0.0f, float_t width = 128.0f, float_t height = 20.0f, const char* text = "slider"); @@ -523,9 +783,50 @@ namespace dw { scroll_bar->SetValue(value); } }; + + struct init_data { + rectangle field_0; + rectangle field_10; + + init_data(); + }; + + class DropDownListScrollBarSelectionListener : public SelectionAdapter { + public: + DropDownListScrollBarSelectionListener(); + virtual ~DropDownListScrollBarSelectionListener() override; + + virtual void Callback(SelectionListener::CallbackData* data) override; + }; + + class ScrollBarTestSelectionListener : public SelectionAdapter { + public: + ScrollBarTestSelectionListener(); + virtual ~ScrollBarTestSelectionListener() override; + + virtual void Callback(SelectionListener::CallbackData* data) override; + }; + + extern p_Font current_font; + + extern p_Font p_font_type_6x12; + extern p_Font p_font_type_8x12; + extern p_Font p_font_type_8x16; + extern p_Font p_font_type_10x16; + extern p_Font p_font_type_10x20; + extern p_Font p_font_type_12x24; + extern p_Font p_font_type_scroll_bar; + + extern void font_init(); + extern int32_t font_get_index(std::string& name); + extern void font_free(); } -extern void dw_gui_detail_display_init(); -extern void dw_gui_detail_display_free(); +extern void dw_init(); +extern void dw_init(dw::init_data& init_data); +extern void dw_free(); extern void dw_gui_ctrl_disp(); + +extern int32_t sub_140192D00(); +extern void sub_140194880(int32_t a1); diff --git a/src/ReDIVA/game_state.cpp b/src/ReDIVA/game_state.cpp index ebb9fced..263e7d33 100644 --- a/src/ReDIVA/game_state.cpp +++ b/src/ReDIVA/game_state.cpp @@ -1178,8 +1178,8 @@ bool SubGameState::Selector::Ctrl() { for (int32_t i = 0; i < ROB_CHARA_COUNT; i++) { v2->field_2C.field_4C[i] = sel->modules[i]; v2->field_2C.field_64[i] = sel->modules[i]; - for (int32_t j = 0; j < 4; j++) - v2->field_2C.field_7C[i].arr[j] = false; + v2->field_2C.field_7C[i] = {}; + v2->field_2C.field_DC[i] = {}; } v0->field_0.no_fail = true; diff --git a/src/ReDIVA/print_work.cpp b/src/ReDIVA/print_work.cpp index e58b2019..2e4196d8 100644 --- a/src/ReDIVA/print_work.cpp +++ b/src/ReDIVA/print_work.cpp @@ -154,7 +154,7 @@ PrintWork::PrintWork() : clip(), layer(), field_28(), line_length() { prio = spr::SPR_PRIO_DEFAULT; resolution_mode = RESOLUTION_MODE_HD; font = font_info_default_get(); - empty_char = '\x25\xA1'; + empty_char = L'\x25A1'; } void PrintWork::DrawLine(vec2 pos[2]) { diff --git a/src/ReDIVA/print_work.hpp b/src/ReDIVA/print_work.hpp index cb89d0e0..7c94862d 100644 --- a/src/ReDIVA/print_work.hpp +++ b/src/ReDIVA/print_work.hpp @@ -48,7 +48,8 @@ struct sprite_text_mesh { rectangle pos, rectangle uv, color4u8 color); }; -struct PrintWork { +class PrintWork { +public: color4u8 color; color4u8 fill_color; bool clip; diff --git a/src/ReDIVA/pv_game/game_2d.cpp b/src/ReDIVA/pv_game/game_2d.cpp index dd085a8d..7de404ad 100644 --- a/src/ReDIVA/pv_game/game_2d.cpp +++ b/src/ReDIVA/pv_game/game_2d.cpp @@ -25,7 +25,7 @@ const int32_t spr_p_life_safe_num_spr[] = { 2867, 2868, 2869, 2870, 2871, 2872, 2873, 2874, 2875, 2876 }; -TaskGame2d* task_game_2d; +TaskGame2d task_game_2d; Game2dEnergyUnit::Game2dEnergyUnit() : field_1B8(), field_1CC(), field_1D1(), no_fail(), field_1D4(), max_value(), life_gauge_prev(), life_gauge_stable(), life_gauge_decrease(), life_gauge_increase(), @@ -493,30 +493,21 @@ void TaskGame2d::Disp() { } bool task_game_2d_add_task() { - if (!task_game_2d) - task_game_2d = new TaskGame2d; - - return app::TaskWork::AddTask(task_game_2d, 0, "GAME_2D", 0); + return app::TaskWork::AddTask(&task_game_2d, 0, "GAME_2D", 0); } void task_game_2d_set_energy_unit_no_fail(bool value) { - task_game_2d->energy_unit.no_fail = value; + task_game_2d.energy_unit.no_fail = value; } void task_game_2d_sub_140372670(bool value) { - task_game_2d->energy_unit.field_1D1 = value; + task_game_2d.energy_unit.field_1D1 = value; } void task_game_2d_sub_1403726D0(int32_t value) { - task_game_2d->energy_unit.field_1D4 = value; + task_game_2d.energy_unit.field_1D4 = value; } bool task_game_2d_del_task() { - if (!task_game_2d) - return true; - - bool ret = task_game_2d->DelTask(); - delete task_game_2d; - task_game_2d = 0; - return ret; + return task_game_2d.DelTask(); } diff --git a/src/ReDIVA/pv_game/game_2d.hpp b/src/ReDIVA/pv_game/game_2d.hpp index 79a364c2..f532f6d1 100644 --- a/src/ReDIVA/pv_game/game_2d.hpp +++ b/src/ReDIVA/pv_game/game_2d.hpp @@ -62,8 +62,8 @@ public: virtual void Disp() override; }; -bool task_game_2d_add_task(); -void task_game_2d_set_energy_unit_no_fail(bool value); -void task_game_2d_sub_140372670(bool value); -void task_game_2d_sub_1403726D0(int32_t value); -bool task_game_2d_del_task(); +extern bool task_game_2d_add_task(); +extern void task_game_2d_set_energy_unit_no_fail(bool value); +extern void task_game_2d_sub_140372670(bool value); +extern void task_game_2d_sub_1403726D0(int32_t value); +extern bool task_game_2d_del_task(); diff --git a/src/ReDIVA/pv_game/pv_game.cpp b/src/ReDIVA/pv_game/pv_game.cpp index b165e0f8..02bcf51c 100644 --- a/src/ReDIVA/pv_game/pv_game.cpp +++ b/src/ReDIVA/pv_game/pv_game.cpp @@ -8,6 +8,7 @@ #include "../../CRE/Glitter/glitter.hpp" #include "../../CRE/rob/motion.hpp" #include "../../CRE/rob/skin_param.hpp" +#include "../../CRE/customize_item_table.hpp" #include "../../CRE/hand_item.hpp" #include "../../CRE/random.hpp" #include "../../CRE/pv_expression.hpp" @@ -262,13 +263,13 @@ hit_border(), field_2D05D(), field_2D05E(), start_fade(), title_image_init(), mu ex_stage(), play_success(), has_auth_3d_frame(), has_light_frame(), has_aet_frame(), has_aet_list(), field_index(), edit_effect_index(), slidertouch_counter(), change_field_branch_success_counter(), field_2D080(), field_2D084(), life_gauge_bonus(), life_gauge_total_bonus(), field_2D090(), no_clear(), -field_2D092(), field_2D093(), field_2D094(), field_2D095(), field_2D096(), success(), title_image_state(), +disp_lyrics_now(), field_2D093(), field_2D094(), field_2D095(), field_2D096(), success(), title_image_state(), field_2D09C(), use_osage_play_data(), pv_end_fadeout(), rival_percentage(), field_2D0A8(), field_2D0AC(), field_2D0B0(), field_2D0BC(), next_stage(), has_frame_texture(), field_2D0BF(), field_2D0C0(), field_2D0C4(), field_2D7E8(), field_2D7EC(), field_2D808(), field_2D80C(), edit_effect(), camera_auth_3d_uid(), se_index(), task_effect_init(), field_2D87C(), current_field(), field_2D8A0(), field_2D8A4(), campv_index(), field_2D954(), field_2DAC8(), field_2DACC(), height_adjust(), field_2DB2C(), field_2DB34() { - field_2D00E = true; + disp_lyrics = true; } pv_game_data::~pv_game_data() { @@ -774,6 +775,13 @@ PROCESS_TARGET: } #pragma warning(pop) +pv_game_item::pv_game_item() { + arr[0] = -1; + arr[1] = -1; + arr[2] = -1; + arr[3] = -1; +} + pv_game_item_mask::pv_game_item_mask() { arr[0] = true; arr[1] = true; @@ -1426,7 +1434,7 @@ void pv_game::change_field(size_t field, ssize_t dsc_time, ssize_t curr_time) { } for (uint64_t& i : curr_field_data.stop_eff_list) - Glitter::glt_particle_manager->FreeSceneEffect(0, i); + Glitter::glt_particle_manager->FreeSceneEffect(hash_fnv1a64m_empty, i); for (uint64_t& i : next_field_data.play_eff_list) Glitter::glt_particle_manager->LoadScene(hash_fnv1a64m_empty, i); @@ -1572,7 +1580,7 @@ int32_t pv_game::ctrl(float_t delta_time, int64_t curr_time) { if (!sub_14013C8C0()->sub_1400E7920()) { /*TaskLampCtrl* task_lamp_ctrl = task_lamp_ctrl_get(); task_lamp_ctrl->field_74 = 2; - task_lamp_ctrl->field_78 = { 0xFF, 0xFF, 0xFF, 0xFF }; + task_lamp_ctrl->field_78 = 0xFFFFFFFF; task_lamp_ctrl->field_7C = 0; task_slider_control_get()->sub_140618980(3);*/ @@ -1739,10 +1747,15 @@ void pv_game::data_itmpv_disable() { } void pv_game::disp() { - //sub_1400FC6F0(); + sub_1400FC6F0(); //sub_14013C8F0()->sub_14012A4E0(); } +void pv_game::disp_song_name() { + if (!sub_14013C8C0()->sub_1400E7920()) + data.play_data.disp_song_name(data.play_data.song_name.c_str()); +} + void pv_game::edit_effect_ctrl(float_t delta_time) { if (data.edit_effect.data.index < 0) return; @@ -3726,7 +3739,7 @@ bool pv_game::load() { case 24: { data.reset(); data.play_data.sub_140137BE0(); - set_lyric(-1, { 0xFF, 0xFF, 0xFF, 0xFF }); + set_lyric(-1, 0xFFFFFFFF); for (pv_game_chara& i : data.chara) { if (!i.check_chara()) @@ -3969,7 +3982,7 @@ void pv_game::reset() { data.reference_score_no_flag_life_bonus = 0; data.target_reference_score.clear(); data.field_2CFE0 = 0; - data.field_2D092 = data.field_2D00E; + data.disp_lyrics_now = data.disp_lyrics; data.notes_passed = 0; data.field_2CFF0 = 0; data.song_energy = 0.0f; @@ -4365,14 +4378,16 @@ void pv_game::title_image_ctrl(bool dont_wait) { if (data.current_time_float - diff->title_image.time < 0.0f) break; - if (diff->title_image.aet_name.size()) { + if (!diff->title_image.aet_name.size()) { state = 3; break; } data.play_data.init_aet_title_image(diff->title_image.aet_name.c_str()); - if (diff->title_image.end_time >= 0.0) + if (diff->title_image.end_time >= 0.0f) state = 2; + else + state = 3; break; case 2: if (diff->title_image.end_time <= data.current_time_float) { @@ -4669,6 +4684,15 @@ void pv_game::sub_1400FC500() { data.next_stage = true;*/ } +void pv_game::sub_1400FC6F0() { + disp_song_name(); + + if (!data.play_data.field_64C && sub_14013C8C0()->sub_1400E7910() != 3 && data.play_data.lyric_set && data.disp_lyrics_now) { + bool h_center = sub_14013C8C0()->sub_1400E7910() == 2 || sub_14013C8C0()->sub_1400E7910() == 5; + data.play_data.disp_lyric(data.play_data.lyric, h_center, this->data.play_data.lyric_color); + } +} + int32_t pv_game::sub_1400FC780(float_t delta_time) { data.play_data.field_65C += delta_time; data.play_data.skin_danger_ctrl(); @@ -4803,10 +4827,10 @@ void pv_game::sub_140106640() { //sub_14013C8F0()->sub_14012BDA0(); - data.field_2D092 = data.field_2D00E; + data.disp_lyrics_now = data.disp_lyrics; data.play_data.sub_140137BE0(); - set_lyric(-1, { 0xFF, 0xFF, 0xFF, 0xFF }); + set_lyric(-1, 0xFFFFFFFF); data.reset(); data.title_image_state = 0; reset_appear(); @@ -5069,6 +5093,13 @@ void struc_14::sub_1400E79E0(int32_t value) { type = value; } +struc_775::struc_775() : pv_id(), field_4(), difficulty(), edition(), field_10(), field_14(), +field_18(), field_1C(), score_percentage_clear(), life_gauge_safety_time(), life_gauge_border(), +field_2C(), field_30(), field_34(), field_38(), field_3C(), ex_stage(), another_song_index(), +field_44(), field_48(), field_49(), field_4C(), field_64(), field_F4(), field_F8() { + +} + struc_660::struc_660() : field_0(), field_4(), field_20(), field_24(), field_48(), field_4C() { } @@ -5133,7 +5164,7 @@ struc_717::~struc_717() { } TaskPvGame::Args::Args() : init_data(), field_190(), watch(), no_fail(), -field_193(), field_194(), mute(), ex_stage(), success(), test_pv(), option() { +disp_lyrics(), field_194(), mute(), ex_stage(), success(), test_pv(), option() { Reset(); } @@ -5157,7 +5188,7 @@ void TaskPvGame::Args::Reset() { field_190 = false; watch = true; no_fail = false; - field_193 = true; + disp_lyrics = true; field_194 = false; mute = false; ex_stage = false; @@ -5167,7 +5198,7 @@ void TaskPvGame::Args::Reset() { } TaskPvGame::Data::Data() : type(), init_data(), field_190(), music_play(), -no_fail(), field_193(), mute(), ex_stage(), success(), option() { +no_fail(), disp_lyrics(), mute(), ex_stage(), success(), option() { Reset(); } @@ -5192,7 +5223,7 @@ void TaskPvGame::Data::Reset() { field_190 = false; music_play = true; no_fail = false; - field_193 = true; + disp_lyrics = true; mute = false; ex_stage = false; success = false; @@ -5231,6 +5262,9 @@ bool TaskPvGame::Dest() { if (!Unload()) return false; + extern float_t frame_speed; + frame_speed = 1.0f; + //touch_util::touch_reaction_set_enable(true); return true; } @@ -5385,7 +5419,7 @@ void TaskPvGame::Load(TaskPvGame::Data& data) { pv_game_ptr->data.music_play = data.music_play; pv_game_ptr->data.no_fail = data.no_fail; - pv_game_ptr->data.field_2D00E = data.field_193; + pv_game_ptr->data.disp_lyrics = data.disp_lyrics; pv_game_ptr->data.song_energy_base = (float_t)data.init_data.score_percentage_clear; pv_game_ptr->data.life_gauge_safety_time = data.init_data.life_gauge_safety_time; pv_game_ptr->data.life_gauge_border = data.init_data.life_gauge_border; @@ -5437,18 +5471,23 @@ PVGameSelector::PVGameSelector() : charas(), modules(), start(), exit() { edition = 0; success = true; - difficulty = PV_DIFFICULTY_HARD; - 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); - for (int32_t i = 0; i < ROB_CHARA_COUNT; i++) + for (int32_t i = 0; i < ROB_CHARA_COUNT; i++) { + charas[i] = pv->get_performer_chara(i); + this->modules[i] = 0; + module_names[i].clear(); + + int32_t cos = pv->get_performer_pv_costume(i, difficulty); for (const auto& j : modules_data[charas[i]]) - if (this->modules[i] == j->cos) { + if (cos == j->cos) { + this->modules[i] = j->id; module_names[i].assign(j->name); break; } + } } PVGameSelector::~PVGameSelector() { @@ -5497,7 +5536,7 @@ void PVGameSelector::Window() { window_focus = false; bool open = true; - if (!ImGui::Begin("X PV Game Selector", &open, window_flags)) { + if (!ImGui::Begin("PV Game Selector", &open, window_flags)) { ImGui::End(); return; } @@ -5528,6 +5567,20 @@ void PVGameSelector::Window() { difficulty = PV_DIFFICULTY_HARD; edition = 0; success = true; + + for (int32_t j = 0; j < ROB_CHARA_COUNT; j++) { + charas[j] = pv->get_performer_chara(j); + this->modules[j] = 0; + module_names[j].clear(); + + int32_t cos = pv->get_performer_pv_costume(j, difficulty); + for (const auto& k : modules_data[charas[j]]) + if (cos == k->cos) { + modules[j] = k->id; + module_names[j].assign(k->name); + break; + } + } } ImGui::PopID(); @@ -5554,6 +5607,20 @@ void PVGameSelector::Window() { difficulty = (pv_difficulty)i; edition = 0; success = true; + + for (int32_t j = 0; j < ROB_CHARA_COUNT; j++) { + charas[j] = pv->get_performer_chara(j); + this->modules[j] = 0; + module_names[j].clear(); + + int32_t cos = pv->get_performer_pv_costume(j, difficulty); + for (const auto& k : modules_data[charas[j]]) + if (cos == k->cos) { + modules[j] = k->id; + module_names[j].assign(k->name); + break; + } + } } if (difficulty == i) @@ -5578,6 +5645,20 @@ void PVGameSelector::Window() { || (ImGui::IsItemFocused() && edition != i.edition)) { edition = i.edition; success = true; + + for (int32_t j = 0; j < ROB_CHARA_COUNT; j++) { + charas[j] = pv->get_performer_chara(j); + this->modules[j] = 0; + module_names[j].clear(); + + int32_t cos = pv->get_performer_pv_costume(j, difficulty); + for (const auto& k : modules_data[charas[j]]) + if (cos == k->cos) { + modules[j] = k->id; + module_names[j].assign(k->name); + break; + } + } } ImGui::PopID(); @@ -5607,7 +5688,8 @@ void PVGameSelector::Window() { module_names[i].clear(); for (const auto& j : modules_data[charas[i]]) - if (modules[i] == j->id) { + if (modules[i] == j->cos) { + modules[i] = j->id; module_names[i].assign(j->name); break; } @@ -5706,10 +5788,10 @@ bool task_pv_game_add_task(TaskPvGame::Args& args) { task_pv_game->data.no_fail = args.no_fail; if (args.watch) { task_pv_game->data.type = 2; - task_pv_game->data.field_193 = args.field_193; + task_pv_game->data.disp_lyrics = args.disp_lyrics; } else - task_pv_game->data.field_193 = true; + task_pv_game->data.disp_lyrics = true; task_pv_game->data.mute = args.mute; task_pv_game->data.ex_stage = args.ex_stage; task_pv_game->data.success = args.success; @@ -5764,14 +5846,15 @@ void task_pv_game_init_pv() { args.init_data.modules[i] = v2->field_2C.field_4C[i]; for (int32_t j = 0; j < 4; j++) { int32_t item_no = 0; - /*if (v2->field_2C.field_64[i] >= 0) - item_no = sub_140234860->sub_140234490(v2->field_2C.field_64[i]);*/ + if (v2->field_2C.field_7C[i].arr[j] >= 0) + item_no = customize_item_data_handler_data_get_customize_item_obj_id( + v2->field_2C.field_7C[i].arr[j]); args.init_data.items[i].arr[j] = item_no; - args.init_data.items_mask[i].arr[j] = v2->field_2C.field_7C[i].arr[j]; + args.init_data.items_mask[i].arr[j] = v2->field_2C.field_DC[i].arr[j]; } } - args.field_193 = true; + args.disp_lyrics = true; args.field_194 = false; /*if (player_data->btn_se_equip >= 0) { @@ -5859,7 +5942,7 @@ bool task_pv_game_init_demo_pv(int32_t pv_id, pv_difficulty difficulty, bool mus task_pv_game->data.field_190 = false; task_pv_game->data.music_play = music_play; task_pv_game->data.no_fail = false; - task_pv_game->data.field_193 = true; + task_pv_game->data.disp_lyrics = true; task_pv_game->data.success = false; task_pv_game->data.se_name.assign(""); @@ -5890,7 +5973,7 @@ void task_pv_game_init_test_pv() { args.field_190 = false; args.watch = false; args.no_fail = false; - args.field_193 = true; + args.disp_lyrics = true; args.field_194 = true; args.mute = true; task_pv_game_add_task(args); diff --git a/src/ReDIVA/pv_game/pv_game.hpp b/src/ReDIVA/pv_game/pv_game.hpp index 60af0b7b..10c344f0 100644 --- a/src/ReDIVA/pv_game/pv_game.hpp +++ b/src/ReDIVA/pv_game/pv_game.hpp @@ -189,7 +189,7 @@ struct pv_game_data { int32_t stage_index; bool music_play; bool no_fail; - bool field_2D00E; + bool disp_lyrics; bool changed_field; int64_t challenge_time_start; int64_t challenge_time_end; @@ -228,7 +228,7 @@ struct pv_game_data { int32_t life_gauge_total_bonus; bool field_2D090; bool no_clear; - bool field_2D092; + bool disp_lyrics_now; bool field_2D093; bool field_2D094; bool field_2D095; @@ -314,6 +314,18 @@ struct pv_game_data { int32_t* slide_chain_no_end_count, bool* has_slide_chain, int64_t target_flying_time_hist); }; +union pv_game_item { + struct { + int32_t head; + int32_t face; + int32_t chest; + int32_t back; + }; + int32_t arr[4]; + + pv_game_item(); +}; + struct pv_game_item_mask { bool arr[4]; @@ -357,6 +369,7 @@ struct pv_game { int32_t ctrl(float_t delta_time, int64_t curr_time); void data_itmpv_disable(); void disp(); + void disp_song_name(); void edit_effect_ctrl(float_t delta_time); void edit_effect_set(int32_t index, float_t frame_speed, float_t delta_time); void end(bool a2, bool set_fade); @@ -437,6 +450,7 @@ struct pv_game { bool unload(); void sub_1400FC500(); + void sub_1400FC6F0(); int32_t sub_1400FC780(float_t delta_time); float_t sub_1400FCEB0(); int32_t sub_1400FDD80(); @@ -536,15 +550,14 @@ struct struc_775 { int32_t field_44; int8_t field_48; int8_t field_49; - int32_t field_4C[6]; - int32_t field_64[6]; - rob_chara_pv_data_item field_7C[6]; - bool field_DC[6]; - int32_t field_E4; - int32_t field_E8; - int32_t field_EC; - int32_t field_F0; + int32_t field_4C[ROB_CHARA_COUNT]; + int32_t field_64[ROB_CHARA_COUNT]; + pv_game_item field_7C[ROB_CHARA_COUNT]; + pv_game_item_mask field_DC[ROB_CHARA_COUNT]; int32_t field_F4; + int32_t field_F8; + + struc_775(); }; struct struc_663 { @@ -770,7 +783,7 @@ public: bool field_190; bool watch; bool no_fail; - bool field_193; + bool disp_lyrics; bool field_194; bool mute; bool ex_stage; @@ -798,7 +811,7 @@ public: bool field_190; bool music_play; bool no_fail; - bool field_193; + bool disp_lyrics; bool mute; bool ex_stage; bool success; diff --git a/src/ReDIVA/pv_game/pv_game_play_data.cpp b/src/ReDIVA/pv_game/pv_game_play_data.cpp index db37cf56..bc393ae4 100644 --- a/src/ReDIVA/pv_game/pv_game_play_data.cpp +++ b/src/ReDIVA/pv_game/pv_game_play_data.cpp @@ -4,6 +4,7 @@ */ #include "pv_game_play_data.hpp" +#include "../print_work.hpp" #include "game_2d.hpp" #include "player_data.hpp" #include "pv_game.hpp" @@ -384,6 +385,9 @@ const char* spr_white_fade[] = { "white_fade", }; +static void sub_14013AAE0(float_t pos_x, float_t pos_y, spr::SprPrio prio, + const char* str, bool h_center, color4u8 color, rectangle* clip_rect = 0); + pv_disp2d::pv_disp2d() : pv_id(), title_start_2d_field(), title_end_2d_field(), title_start_2d_low_field(), title_end_2d_low_field(), title_start_3d_field(), title_end_3d_field(), target_shadow_type(), pv_spr_set_id(), pv_aet_set_id(), pv_aet_id() { @@ -656,6 +660,11 @@ void pv_game_play_data::disp_combo() { spr_p_combo_num_spr, spr::SPR_PRIO_14, &pos, false, aft_spr_db); } +void pv_game_play_data::disp_lyric(const char* str, bool h_center, color4u8 color) { + if (loaded && str) + sub_14013AAE0(song_txt[0].position.x, song_txt[0].position.y, spr::SPR_PRIO_17, str, h_center, color); +} + void pv_game_play_data::disp_max_slide_point() { if (!aet_ids[PV_GAME_AET_MAX_SLIDE_POINT]) return; @@ -807,6 +816,27 @@ void pv_game_play_data::disp_song_energy() { spr::SPR_PRIO_16, &pos, spr_p_energy_num_0_layout, aft_spr_db); } +void pv_game_play_data::disp_song_name(const char* str) { + if (!loaded || !str || !frame_disp[0]) + return; + + PrintWork print_work; + font_info font(16); + print_work.SetFont(&font); + + bool clip = print_work.GetTextSize(str, str + utf8_length(str)).x > 768.0f; + + vec2 pos; + pos.x = song_txt[1].position.x; + pos.y = song_txt[1].position.y - song_info_pos; + + rectangle clip_rect; + clip_rect.pos = pos; + clip_rect.size = { 768.0f, font.glyph.y }; + + sub_14013AAE0(pos.y, pos.y, spr::SPR_PRIO_16, str, 0, 0xFFFFFFFF, clip ? &clip_rect : 0); +} + void pv_game_play_data::disp_spr_set_back() { if (!loaded || spr_set_back_id == -1) return; @@ -2170,3 +2200,32 @@ float_t get_percentage_clear_excellent() { float_t get_percentage_clear_great() { return percentage_clear_great[sub_14013C8C0()->difficulty]; } + +static void sub_14013AAE0(float_t pos_x, float_t pos_y, spr::SprPrio prio, + const char* str, bool h_center, color4u8 color, rectangle* clip_rect) { + if (!str) + return; + + font_info font(16); + font.set_glyph_size(24.0f, 24.0f); + + PrintWork print_work; + print_work.SetFont(&font); + print_work.line_origin_loc = { pos_x, pos_y }; + print_work.text_current_loc = { pos_x, pos_y }; + print_work.SetResolutionMode(RESOLUTION_MODE_HD); + print_work.prio = prio; + print_work.color = color; + + app::text_flags flags = (app::text_flags)((h_center + ? app::TEXT_FLAG_ALIGN_FLAG_H_CENTER + : app::TEXT_FLAG_ALIGN_FLAG_LEFT) + | app::TEXT_FLAG_FONT); + + if (clip_rect) { + print_work.clip = true; + print_work.clip_data = *clip_rect; + } + + print_work.PrintText(flags, str); +} diff --git a/src/ReDIVA/pv_game/pv_game_play_data.hpp b/src/ReDIVA/pv_game/pv_game_play_data.hpp index 8226c1bb..6e1b60f3 100644 --- a/src/ReDIVA/pv_game/pv_game_play_data.hpp +++ b/src/ReDIVA/pv_game/pv_game_play_data.hpp @@ -235,11 +235,13 @@ struct pv_game_play_data { void disp_chance_points(int32_t chance_points, float_t pos_x, float_t pos_y); void disp_chance_txt(); void disp_combo(); + void disp_lyric(const char* str, bool h_center, color4u8 color); void disp_max_slide_point(); void disp_score(); void disp_slide_point(); void disp_slide_points(int32_t max_slide_point, float_t pos_x, float_t pos_y, bool max_slide); void disp_song_energy(); + void disp_song_name(const char* str); void disp_spr_set_back(); void fade_begin_ctrl(); bool fade_end_ctrl(); diff --git a/src/ReDIVA/pv_game/pv_game_pv_data.cpp b/src/ReDIVA/pv_game/pv_game_pv_data.cpp index 0949f8fc..fb40de1b 100644 --- a/src/ReDIVA/pv_game/pv_game_pv_data.cpp +++ b/src/ReDIVA/pv_game/pv_game_pv_data.cpp @@ -395,7 +395,7 @@ void pv_game_pv_data::dsc_buffer_set(const void* data, uint32_t size) { bool pv_game_pv_data::dsc_ctrl(float_t delta_time, int64_t curr_time, float_t* dsc_time_offset, bool* music_play, bool a6, bool ignore_targets) { if (sub_14013C8C0()->sub_1400E7910() >= 4 && field_2BF68 <= curr_time) - pv_game->set_lyric(-1, { 0xFF, 0xFF, 0xFF, 0xFF }); + pv_game->set_lyric(-1, 0xFFFFFFFF); int32_t func = dsc_data_ptr->func; uint32_t* data = dsc.get_func_data(dsc_data_ptr); @@ -1200,7 +1200,7 @@ bool pv_game_pv_data::dsc_ctrl(float_t delta_time, int64_t curr_time, case DSC_FT_EDIT_LYRIC: { int32_t lyric_index = (int32_t)data[0] - 1; field_2BF68 = curr_time + 1000000LL * (int32_t)data[1]; - pv_game->set_lyric(lyric_index, { 0xFF, 0xFF, 0xFF, 0xFF }); + pv_game->set_lyric(lyric_index, 0xFFFFFFFF); } break; case DSC_FT_EDIT_TARGET: { } break; @@ -2124,7 +2124,7 @@ void pv_game_pv_data::find_data_camera() { ::dsc_data* i = dsc.data.data(); ::dsc_data* i_end = dsc.data.data() + dsc.data.size(); - while (i = find_func(DSC_FT_CHANGE_FIELD, &time, &pv_branch_mode, i, i_end)) { + while (i = find_func(DSC_FT_DATA_CAMERA, &time, &pv_branch_mode, i, i_end)) { if (time < 0) { time = prev_time; if (prev_time < 0) diff --git a/src/ReDIVA/render.cpp b/src/ReDIVA/render.cpp index 6c186e63..119b281d 100644 --- a/src/ReDIVA/render.cpp +++ b/src/ReDIVA/render.cpp @@ -579,7 +579,7 @@ static render_context* render_context_load() { task_pv_db_init(); Glitter::glt_particle_manager_init(); - dw_gui_detail_display_init(); + dw_init(); auth_3d_test_window_init(); dtm_aet_init(); @@ -851,9 +851,7 @@ 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); + rctx->camera->initialize(aspect); render_resize_fb(rctx, true); @@ -872,6 +870,7 @@ static render_context* render_context_load() { module_table_handler_data_init(); module_data_handler_data_init(); customize_item_table_handler_data_init(); + customize_item_data_handler_data_init(); aet_manager_add_aet_sets(aft_aet_db); sprite_manager_add_spr_sets(aft_spr_db); @@ -929,6 +928,7 @@ static render_context* render_context_load() { builder.BuildRanges(&ranges); imgui_font_arial = io.Fonts->AddFontFromFileTTF(font_file, 14.0f, 0, ranges.Data); + io.Fonts->Build(); ImGui::StyleColorsDark(); ImGui_ImplGlfw_InitForOpenGL(window, true); @@ -987,17 +987,12 @@ static void render_context_ctrl(render_context* rctx) { global_context_menu = true; lock_lock(imgui_context_lock); ImGui::SetCurrentContext(imgui_context); - dw_gui_ctrl_disp(); app::TaskWork_Window(); classes_process_imgui(classes, classes_count); lock_unlock(imgui_context_lock); - if (old_width != width || old_height != height || old_scale_index != scale_index) { + if (old_width != width || old_height != height || old_scale_index != scale_index) render_resize_fb(rctx, true); - resolution_struct* res_wind = res_window_get(); - cam->set_res(internal_3d_res.x, internal_3d_res.y, - res_wind->width, res_wind->height); - } old_width = width; old_height = height; old_scale_index = scale_index; @@ -1192,6 +1187,7 @@ static void render_context_dispose(render_context* rctx) { sprite_manager_remove_spr_sets(aft_spr_db); aet_manager_remove_aet_sets(aft_aet_db); + customize_item_data_handler_data_free(); customize_item_table_handler_data_free(); module_data_handler_data_free(); module_table_handler_data_free(); @@ -1219,7 +1215,7 @@ static void render_context_dispose(render_context* rctx) { dtm_aet_free(); auth_3d_test_window_free(); - dw_gui_detail_display_free(); + dw_free(); Glitter::glt_particle_manager_free(); task_pv_db_free(); @@ -1343,16 +1339,16 @@ static void render_resize_fb(render_context* rctx, bool change_fb) { internal_res.y = (int32_t)res_height; #if BAKE_PNG || BAKE_VIDEO - internal_2d_res.x = clamp_def(internal_res.x * 2, 1, sv_max_texture_size); - internal_2d_res.y = clamp_def(internal_res.y * 2, 1, sv_max_texture_size); + internal_2d_res = vec2i::clamp(internal_res * 2, 1, sv_max_texture_size); internal_3d_res.x = (int32_t)roundf((float_t)(internal_res.x * 2)); internal_3d_res.y = (int32_t)roundf((float_t)(internal_res.y * 2)); + internal_3d_res = vec2i::clamp(internal_3d_res, 1, sv_max_texture_size); #else internal_2d_res = vec2i::clamp(internal_res, 1, sv_max_texture_size); internal_3d_res.x = (int32_t)roundf((float_t)(internal_res.x * render_scale_table[scale_index])); internal_3d_res.y = (int32_t)roundf((float_t)(internal_res.y * render_scale_table[scale_index])); -#endif internal_3d_res = vec2i::clamp(internal_3d_res, 1, sv_max_texture_size); +#endif bool fb_changed = old_internal_2d_res.x != internal_2d_res.x || old_internal_2d_res.y != internal_2d_res.y