diff --git a/src/CRE/auth_3d.cpp b/src/CRE/auth_3d.cpp index 19fc164d..80a38c5a 100644 --- a/src/CRE/auth_3d.cpp +++ b/src/CRE/auth_3d.cpp @@ -230,12 +230,14 @@ static size_t auth_3d_time_event_radix_index_func_frame(auth_3d_time_event* data auth_3d_data_struct* auth_3d_data; auth_3d_detail::TaskAuth3d* task_auth_3d; +bool auth_3d_chara_visible = true; + static int16_t auth_3d_load_counter; static auth_3d_detail::FrameRateTimeStop frame_rate_time_stop; extern render_context* rctx_ptr; -auth_3d::auth_3d() : uid(), id(), mat(), enable(), camera_root_update(), visible(), repeat(), ended(), +auth_3d::auth_3d() : uid(), id(), mat(), enable(), camera_root_update(), visible(), repeat(), field_C(), ended(), left_right_reverse(), once(), alpha(), chara_id(), chara_item(), shadow(), reflect(), pos(), frame_rate(), frame(), req_frame(), max_frame(), frame_changed(), frame_offset(), last_frame(), paused(), event_time_next() { hash = hash_murmurhash_empty; @@ -249,58 +251,7 @@ auth_3d::~auth_3d() { } void auth_3d::ctrl(render_context* rctx) { - if (state == 1) - if (hash == hash_murmurhash_empty) { - data_struct* aft_data = &data_list[DATA_AFT]; - auth_3d_database* aft_auth_3d_db = &aft_data->data_ft.auth_3d_db; - object_database* aft_obj_db = &aft_data->data_ft.obj_db; - texture_database* aft_tex_db = &aft_data->data_ft.tex_db; - - auth_3d_database_uid* db_uid = &aft_auth_3d_db->uid[uid]; - if (db_uid->enabled) { - auth_3d_uid_file* uid_file = &auth_3d_data->uid_files[uid]; - if (uid_file->uid == uid && uid_file->state == 1 && uid_file->farc->state == 2) { - state = 2; - farc_file* ff = uid_file->farc->farc->read_file(uid_file->file_name.c_str()); - if (ff) { - a3da a; - a.read(ff->data, ff->size); - load(&a, aft_obj_db, aft_tex_db); - frame = 0.0f; - } - } - } - } - else { - auto elem = auth_3d_data->uid_files_modern.find(hash); - if (elem == auth_3d_data->uid_files_modern.end()) - return; - - auth_3d_uid_file_modern* uid_file = &elem->second; - if (uid_file->hash == hash && uid_file->state == 1 && uid_file->farc->state == 2) { - state = 2; - farc_file* ff = uid_file->farc->farc->read_file(uid_file->hash); - if (ff) { - a3da a; - a.read(ff->data, ff->size); - - a3da_msgpack_read("patch\\AFT\\auth_3d", a._file_name.c_str(), &a); - - const char* l_str = ff->name.c_str(); - const char* t = strrchr(l_str, '.'); - size_t l_len = ff->name.size(); - if (t) - l_len = t - l_str; - - uid_file->name.assign(ff->name.c_str(), l_len); - uid_file->file_name.assign(ff->name); - file_name.assign(ff->name); - load(&a, uid_file->obj_db, uid_file->tex_db); - hash = uid_file->hash; - frame = 0.0f; - } - } - } + parse(); if (state != 2 || !enable) return; @@ -308,6 +259,7 @@ void auth_3d::ctrl(render_context* rctx) { int32_t event_flags = 0; bool set = false; while (true) { + bool v40 = this->field_C; if (frame_changed) { frame_changed = false; if (req_frame < frame) { @@ -317,6 +269,7 @@ void auth_3d::ctrl(render_context* rctx) { else event_flags |= 0x04; frame = req_frame; + field_C = true; ended = false; if (max_frame >= 0.0f && frame >= max_frame) max_frame = -1.0f; @@ -432,19 +385,40 @@ void auth_3d::ctrl(render_context* rctx) { dof.interpolate(frame); auth_3d_dof_set(&dof, rctx); + if (field_C && v40 != field_C) + for (a3d::EventAdapter*& i : event_adapter) { + auth_3d_id id = get_id(); + i->Field_10(id); + } + if (set || !repeat || last_frame > frame) break; + for (a3d::EventAdapter*& i : event_adapter) { + auth_3d_id id = get_id(); + i->Field_28(id); + } + req_frame = frame - last_frame + frame_offset; frame_changed = true; set = true; } + for (a3d::EventAdapter*& i : event_adapter) { + auth_3d_id id = get_id(); + i->Field_20(id); + } + bool ended = play_control.size <= frame; if (ended && this->ended != ended) { paused = true; if (once) enable = false; + + for (a3d::EventAdapter*& i : event_adapter) { + auth_3d_id id = get_id(); + i->Field_18(id); + } } this->ended = ended; } @@ -484,6 +458,10 @@ void auth_3d::disp(render_context* rctx) { rctx->disp_manager->set_material_list(); } +auth_3d_id auth_3d::get_id() { + return auth_3d_id(id); +} + void auth_3d::load(a3da* auth_file, object_database* obj_db, texture_database* tex_db) { if (!auth_file) @@ -741,6 +719,82 @@ void auth_3d::load_from_farc(farc* f, const char* file, load(&a, obj_db, tex_db); } +void auth_3d::parse() { + if (state != 1) + return; + + if (hash == hash_murmurhash_empty) { + data_struct* aft_data = &data_list[DATA_AFT]; + auth_3d_database* aft_auth_3d_db = &aft_data->data_ft.auth_3d_db; + object_database* aft_obj_db = &aft_data->data_ft.obj_db; + texture_database* aft_tex_db = &aft_data->data_ft.tex_db; + + auth_3d_database_uid* db_uid = &aft_auth_3d_db->uid[uid]; + if (db_uid->enabled) { + auth_3d_uid_file* uid_file = &auth_3d_data->uid_files[uid]; + if (uid_file->uid == uid && uid_file->state == 1 && uid_file->farc->state == 2) { + state = 2; + farc_file* ff = uid_file->farc->farc->read_file(uid_file->file_name.c_str()); + if (ff) { + a3da a; + a.read(ff->data, ff->size); + + time_struct time; + load(&a, aft_obj_db, aft_tex_db); + time.calc_time(); + + for (a3d::EventAdapter*& i : event_adapter) { + auth_3d_id id = get_id(); + i->Field_8(id); + } + + frame = 0.0f; + } + } + } + } + else { + auto elem = auth_3d_data->uid_files_modern.find(hash); + if (elem == auth_3d_data->uid_files_modern.end()) + return; + + auth_3d_uid_file_modern* uid_file = &elem->second; + if (uid_file->hash == hash && uid_file->state == 1 && uid_file->farc->state == 2) { + state = 2; + farc_file* ff = uid_file->farc->farc->read_file(uid_file->hash); + if (ff) { + a3da a; + a.read(ff->data, ff->size); + + a3da_msgpack_read("patch\\AFT\\auth_3d", a._file_name.c_str(), &a); + + const char* l_str = ff->name.c_str(); + const char* t = strrchr(l_str, '.'); + size_t l_len = ff->name.size(); + if (t) + l_len = t - l_str; + + uid_file->name.assign(ff->name.c_str(), l_len); + uid_file->file_name.assign(ff->name); + file_name.assign(ff->name); + + time_struct time; + load(&a, uid_file->obj_db, uid_file->tex_db); + time.calc_time(); + + hash = uid_file->hash; + + for (a3d::EventAdapter*& i : event_adapter) { + auth_3d_id id = get_id(); + i->Field_8(id); + } + + frame = 0.0f; + } + } + } +} + void auth_3d::reset() { uid = -1; id = -1; @@ -749,6 +803,7 @@ void auth_3d::reset() { camera_root_update = true; visible = true; repeat = false; + field_C = false; ended = false; left_right_reverse = false; once = false; @@ -816,6 +871,9 @@ void auth_3d::reset() { point.clear(); point.shrink_to_fit(); post_process.reset(); + state = 0; + event_adapter.clear(); + event_adapter.shrink_to_fit(); hash = hash_murmurhash_empty; } @@ -978,6 +1036,44 @@ void auth_3d::unload(render_context* rctx) { reset(); } +namespace a3d { + EventListener::EventListener() { + + } + + EventListener::~EventListener() { + + } + + EventAdapter::EventAdapter() { + + } + + EventAdapter::~EventAdapter() { + + } + + void EventAdapter::Field_8(::auth_3d_id& id) { + + } + + void EventAdapter::Field_10(::auth_3d_id& id) { + + } + + void EventAdapter::Field_18(::auth_3d_id& id) { + + } + + void EventAdapter::Field_20(::auth_3d_id& id) { + + } + + void EventAdapter::Field_28(::auth_3d_id& id) { + + } +} + namespace auth_3d_detail { Event::Event(a3da_event* e) { active = false; @@ -1028,6 +1124,31 @@ namespace auth_3d_detail { } + void EventA2d::Aet::Free() { + if (id != -1) + aet_manager_free_aet_object(id); + id = -1; + } + + void EventA2d::Aet::Init() { + data_struct* aft_data = &data_list[DATA_AFT]; + aet_database* aft_aet_db = &aft_data->data_ft.aet_db; + + if (args.id.id < 0) + id = -1; + else { + id = aet_manager_init_aet_object(args, aft_aet_db); + if (id != -1) + aet_manager_set_obj_play(id, 1); + } + } + + EventA2d::Aet& EventA2d::Aet::SetArgs(const AetArgs& value) { + Free(); + args = value; + return *this; + } + EventA2d::EventA2d(a3da_event* e) : Event(e) { } @@ -2441,6 +2562,14 @@ auth_3d_id::auth_3d_id(int32_t uid, auth_3d_database* auth_3d_db) { this->id = id; } +void auth_3d_id::add_event_adapter(a3d::EventAdapter* value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + auth->event_adapter.push_back(value); + } +} + bool auth_3d_id::check_not_empty() { if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; @@ -2477,15 +2606,6 @@ auth_3d* auth_3d_id::get_auth_3d() { return 0; } -int32_t auth_3d_id::get_chara_id() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth->chara_id; - } - return -1; -} - const mat4* auth_3d_id::get_auth_3d_object_mat(size_t index, bool hrc) { if (id < 0 || (id & 0x7FFF) >= AUTH_3D_DATA_COUNT) return 0; @@ -2499,6 +2619,34 @@ const mat4* auth_3d_id::get_auth_3d_object_mat(size_t index, bool hrc) { return auth_3d_get_auth_3d_object_mat(auth, index); } +auth_3d_chara* auth_3d_id::get_chara(size_t auth_chara_id) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + if (auth_chara_id < auth->chara.size()) + return &auth->chara[auth_chara_id]; + } + return 0; +} + +size_t auth_3d_id::get_chara_count() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->chara.size(); + } + return -1; +} + +int32_t auth_3d_id::get_chara_id() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->chara_id; + } + return -1; +} + bool auth_3d_id::get_enable() { if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; @@ -2640,6 +2788,15 @@ void auth_3d_id::set_chara_id(int32_t value) { } } +void auth_3d_id::set_chara_index(size_t auth_chara_id, int32_t index) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + if (auth_chara_id < auth->chara.size()) + auth->chara[auth_chara_id].index = index; + } +} + void auth_3d_id::set_chara_item(bool value) { if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; @@ -3043,6 +3200,18 @@ void auth_3d_data_free() { } } +void auth_3d_check_chara_visible(int32_t chara_id, const struct rob_chara_pv_data* pv_data) { + data_struct* aft_data = &data_list[DATA_AFT]; + bone_database* aft_bone_data = &aft_data->data_ft.bone_data; + motion_database* aft_mot_db = &aft_data->data_ft.mot_db; + + rob_chara_array_get(chara_id)->reset_data(pv_data, aft_bone_data, aft_mot_db); + if (rob_chara_array_check_visibility(0) || rob_chara_array_check_visibility(1)) + auth_3d_chara_visible = true; + else + auth_3d_chara_visible = false; +} + void task_auth_3d_init() { if (!task_auth_3d) task_auth_3d = new auth_3d_detail::TaskAuth3d; diff --git a/src/CRE/auth_3d.hpp b/src/CRE/auth_3d.hpp index 8fa782b3..90ebf9d3 100644 --- a/src/CRE/auth_3d.hpp +++ b/src/CRE/auth_3d.hpp @@ -14,6 +14,7 @@ #include "../KKdLib/a3da.hpp" #include "../KKdLib/farc.hpp" #include "../KKdLib/kf.hpp" +#include "auth_2d.hpp" #include "frame_rate_control.hpp" #include "render_context.hpp" @@ -170,6 +171,33 @@ struct auth_3d_point; struct auth_3d_post_process; struct auth_3d_rgba; struct auth_3d_vec3; +struct auth_3d_id; + +namespace a3d { + class EventListener { + public: + EventListener(); + virtual ~EventListener(); + + virtual void Field_8(auth_3d_id& id) = 0; + virtual void Field_10(auth_3d_id& id) = 0; + virtual void Field_18(auth_3d_id& id) = 0; + virtual void Field_20(auth_3d_id& id) = 0; + virtual void Field_28(auth_3d_id& id) = 0; + }; + + class EventAdapter : public EventListener { + public: + EventAdapter(); + virtual ~EventAdapter() override; + + virtual void Field_8(auth_3d_id& id) override; + virtual void Field_10(auth_3d_id& id) override; + virtual void Field_18(auth_3d_id& id) override; + virtual void Field_20(auth_3d_id& id) override; + virtual void Field_28(auth_3d_id& id) override; + }; +} namespace auth_3d_detail { class Event { @@ -204,7 +232,20 @@ namespace auth_3d_detail { struct EventA2d : public Event { public: - //std::pair aet_init_data; + struct Aet { + AetArgs args; + int32_t id; + + inline Aet() { + id = -1; + } + + void Free(); + void Init(); + EventA2d::Aet& SetArgs(const AetArgs& value); + }; + + Aet aet_args; EventA2d(a3da_event* e); virtual ~EventA2d() override; @@ -810,11 +851,14 @@ struct auth_3d_id { auth_3d_id(uint32_t hash, void* data, object_database* obj_db, texture_database* tex_db); auth_3d_id(int32_t uid, auth_3d_database* auth_3d_db); + void add_event_adapter(a3d::EventAdapter* value); bool check_not_empty(); bool check_loading(); bool check_loaded(); auth_3d* get_auth_3d(); const mat4* get_auth_3d_object_mat(size_t index, bool hrc); + auth_3d_chara* get_chara(size_t auth_chara_id); + size_t get_chara_count(); int32_t get_chara_id(); bool get_enable(); bool get_ended(); @@ -832,6 +876,7 @@ struct auth_3d_id { void set_alpha_obj_flags(float_t alpha, mdl::ObjFlags obj_flags); void set_camera_root_update(bool value); void set_chara_id(int32_t value); + void set_chara_index(size_t auth_chara_id, int32_t index); void set_chara_item(bool value); void set_enable(bool value); void set_frame_rate(FrameRateControl* value); @@ -881,6 +926,7 @@ struct auth_3d { bool camera_root_update; bool visible; bool repeat; + bool field_C; bool ended; bool left_right_reverse; bool once; @@ -911,6 +957,7 @@ struct auth_3d { std::vector curve; auth_3d_dof dof; std::vector event; + std::vector event_adapter; std::vector event_time; auth_3d_time_event* event_time_next; std::vector fog; @@ -938,10 +985,12 @@ struct auth_3d { void ctrl(render_context* rctx); void disp(render_context* rctx); + auth_3d_id get_id(); void load(a3da* auth_file, object_database* obj_db, texture_database* tex_db); void load_from_farc(farc* f, const char* file, object_database* obj_db, texture_database* tex_db); + void parse(); void reset(); void store(a3da* auth_file); void unload(render_context* rctx); @@ -1025,6 +1074,8 @@ extern void auth_3d_data_unload_category(const char* category_name); extern void auth_3d_data_unload_category(uint32_t category_hash); extern void auth_3d_data_free(); +extern void auth_3d_check_chara_visible(int32_t chara_id, const struct rob_chara_pv_data* pv_data); + extern void task_auth_3d_init(); extern bool task_auth_3d_add_task(); extern bool task_auth_3d_check_task_ready(); diff --git a/src/ReDIVA/data_test/auth_3d_test.cpp b/src/ReDIVA/data_test/auth_3d_test.cpp index 044a07a3..08ffb84e 100644 --- a/src/ReDIVA/data_test/auth_3d_test.cpp +++ b/src/ReDIVA/data_test/auth_3d_test.cpp @@ -5,6 +5,7 @@ #include "auth_3d_test.hpp" #include "../../CRE/rob/rob.hpp" +#include "../../CRE/rob/motion.hpp" #include "../../CRE/app_system_detail.hpp" #include "../../CRE/clear_color.hpp" #include "../../CRE/data.hpp" @@ -303,6 +304,7 @@ public: }; extern render_context* rctx_ptr; +extern bool auth_3d_chara_visible; Auth3dTestTask* auth_3d_test_task; Auth3dTestWindow* auth_3d_test_window; @@ -314,6 +316,215 @@ static bool snap_shot; static void auth_3d_test_window_init(); static const char* get_dev_ram_ss_dir(); +Auth3dTestTask::DataEventListener::Data::Data() : state(), field_C(), field_D(), +load_chara_index(), chara_index(), prev_chara_index(), load_cos_id(), cos_id(), chara_visible() { + +} + +Auth3dTestTask::DataEventListener::Data::~Data() { + +} + + +void Auth3dTestTask::DataEventListener::Data::ctrl() { + if ((state == 0 || state == 1 || state == 4) && field_C) { + if (chara_index[0] == CHARA_MAX && chara_index[1] == CHARA_MAX) + field_C = false; + else { + for (int32_t i = 0; i < 2; i++) { + if (chara_index[i] != CHARA_MAX) { + ::chara_index v5 = chara_index[i]; + ::chara_index v6 = load_chara_index[i]; + chara_index[i] = CHARA_MAX; + load_chara_index[i] = v5; + prev_chara_index[i] = v6; + cos_id[i] = load_cos_id[i]; + } + + if (load_chara_index[i] == CHARA_MAX) + load_chara_index[i] = CHARA_MIKU; + } + + if (field_D) { + free_all_chara(); + field_D = false; + } + + state = 3; + } + } + + if (state == 3 && !task_rob_manager_get_free_chara_list_empty()) + sub_140244E20(); + + if (state == 1) { + bool wait_load_chara_1p = false; + bool wait_load_chara_2p = false; + if (load_chara_index[0] < CHARA_MAX) { + const chara_init_data* chara_init_data = chara_init_data_get(load_chara_index[0]); + wait_load_chara_1p = motion_storage_check_mot_file_not_ready(chara_init_data->field_820) + || mothead_storage_check_mhd_file_not_ready(chara_init_data->field_820); + } + + if (load_chara_index[1] < CHARA_MAX) { + const chara_init_data* chara_init_data = chara_init_data_get(load_chara_index[1]); + wait_load_chara_2p = motion_storage_check_mot_file_not_ready(chara_init_data->field_820) + || mothead_storage_check_mhd_file_not_ready(chara_init_data->field_820); + } + + if (!task_rob_manager_get_free_chara_list_empty() && !wait_load_chara_1p && !wait_load_chara_2p) + state = 2; + } + + if (state == 2) { + state = 4; + + dtm_eq_vs[0].SetCharaIndexCosId(load_chara_index[0], load_cos_id[0]); + dtm_eq_vs[1].SetCharaIndexCosId(load_chara_index[1], load_cos_id[1]); + + if (state == 4) + { + rob_chara_array_set_visibility(0, false); + if (state == 4) + rob_chara_array_set_visibility(1, false); + } + } +} + +void Auth3dTestTask::DataEventListener::Data::dest() { + dtm_eq_vs[0].del_task(); + dtm_eq_vs[1].del_task(); + + auth_3d_chara_visible = chara_visible; + + free_all_chara(); +} + +inline void Auth3dTestTask::DataEventListener::Data::free_all_chara() { + task_rob_manager_free_all_chara(); + + if (prev_chara_index[0] < CHARA_MAX) { + const chara_init_data* chara_init_data = chara_init_data_get(prev_chara_index[0]); + motion_set_unload_motion(chara_init_data->field_820); + motion_set_unload_mothead(chara_init_data->field_820); + prev_chara_index[0] = CHARA_MAX; + } + + if (prev_chara_index[1] < CHARA_MAX) { + const chara_init_data* chara_init_data = chara_init_data_get(prev_chara_index[1]); + motion_set_unload_motion(chara_init_data->field_820); + motion_set_unload_mothead(chara_init_data->field_820); + prev_chara_index[1] = CHARA_MAX; + } +} + +void Auth3dTestTask::DataEventListener::Data::init() { + chara_visible = auth_3d_chara_visible; + auth_3d_chara_visible = false; + + field_C = false; + field_D = false; + state = 0; + + load_chara_index[0] = CHARA_MAX; + load_chara_index[1] = CHARA_MAX; + chara_index[0] = CHARA_MAX; + chara_index[1] = CHARA_MAX; + + prev_chara_index[0] = CHARA_MAX; + prev_chara_index[1] = CHARA_MAX; + + load_cos_id[0] = 0; + load_cos_id[1] = 0; + + cos_id[0] = 0; + cos_id[1] = 0; + + dtm_eq_vs[0].add_task(0, CHARA_MIKU); + dtm_eq_vs[1].add_task(1, CHARA_MIKU); + + chara_index[0] = CHARA_MIKU; + field_C = true; +} + +void Auth3dTestTask::DataEventListener::Data::sub_140244E20() { + data_struct* aft_data = &data_list[DATA_AFT]; + motion_database* aft_mot_db = &aft_data->data_ft.mot_db; + + rob_chara_pv_data pv_data; + pv_data.field_4 = false; + rob_chara_array_init_chara_index(load_chara_index[0], pv_data, load_cos_id[0], true); + rob_chara_array_init_chara_index(load_chara_index[1], pv_data, load_cos_id[1], true); + + if (load_chara_index[0] < CHARA_MAX) { + const chara_init_data* chara_init_data = chara_init_data_get(load_chara_index[0]); + motion_set_load_motion(chara_init_data->field_820, "", aft_mot_db); + motion_set_load_mothead(chara_init_data->field_820, "", aft_mot_db); + } + + if (load_chara_index[1] < CHARA_MAX) { + const chara_init_data* chara_init_data = chara_init_data_get(load_chara_index[1]); + motion_set_load_motion(chara_init_data->field_820, "", aft_mot_db); + motion_set_load_mothead(chara_init_data->field_820, "", aft_mot_db); + } + + field_C = false; + field_D = true; + state = 1; +} + +void Auth3dTestTask::DataEventListener::Data::sub_140249A40(bool other_chara) { + if (state != 4) + return; + + rob_chara_pv_data pv_data; + pv_data.field_4 = false; + auth_3d_check_chara_visible(other_chara, &pv_data); +} + +Auth3dTestTask::DataEventListener::DataEventListener() { + +} + +Auth3dTestTask::DataEventListener::~DataEventListener() { + +} + +void Auth3dTestTask::DataEventListener::Field_8(::auth_3d_id& id) { + size_t chara_count = id.get_chara_count(); + if (chara_count) + { + chara_count = min_def(chara_count, 2); + for (size_t i = 0; i < chara_count; i++) { + auth_3d_chara* chara = id.get_chara(i); + if (chara) { + ::chara_index chara_index = chara_index_get_from_chara_name(chara->name.c_str()); + if (chara_index != CHARA_MAX) { + auth_3d_test_task->data_event_listener.data.chara_index[i ? 1 : 0] = chara_index; + auth_3d_test_task->data_event_listener.data.field_C = true; + id.set_chara_index(i, i ? 1 : 0); + auth_3d_test_window->rob_window->chara_list[i]->SetItemIndex(chara_index); + auth_3d_test_task->DispAuth3dChara(id); + } + } + } + } + + auth_3d_test_task->black_mask = 0; + auth_3d_test_window->black_mask->SetValue(false); + //auth_3d_test_task->LoadTransValue(); + //auth_3d_test_task->LoadRotYValue(); + auth_3d_test_window->frame_slider->SetValue(0.0f); + auth_3d_test_window->SetMaxFrame(id.get_play_control_size()); +} + +void Auth3dTestTask::DataEventListener::Field_20(::auth_3d_id& id) { + if (auth_3d_test_task->aet.id != -1) { + auth_3d_test_task->aet.Free(); + auth_3d_test_task->aet.Init(); + } +} + Auth3dTestTask::Auth3dTestTask::Window::Window() { stage_link_change = true; obj_link = true; @@ -334,6 +545,7 @@ Auth3dTestTask::Auth3dTestTask() { snap_shot = false; snap_shot_state = 0; aet_index = false; + aet_id = -1; auth_2d = false; black_mask = false; stage_link_change = true; @@ -376,6 +588,8 @@ bool Auth3dTestTask::init() { effcmn_obj_set_state = 1; effcmn_obj_set = aft_obj_db->get_object_set_id("EFFCMN"); aet_state = 1; + aet_id = -1; + aet.Free(); plane_above_floor = false; stg_auth_display = true; stg_display = true; @@ -399,6 +613,8 @@ bool Auth3dTestTask::init() { if (auth_3d_test_window) auth_3d_test_window->snap_shot->SetEnabled(false/*sub_140192E20()*/); + data_event_listener.data.init(); + task_stage_add_task("A3D_STAGE"); objset_info_storage_load_set(aft_data, aft_obj_db, effcmn_obj_set); return true; @@ -413,7 +629,7 @@ bool Auth3dTestTask::ctrl() { SetStage(); SetAuth3dId(); - //event_listener.data.sub_140247B60(); + data_event_listener.data.ctrl(); if (effcmn_obj_set_state == 1 && !objset_info_storage_load_obj_set_check_not_read(effcmn_obj_set)) effcmn_obj_set_state = 4; @@ -421,7 +637,7 @@ bool Auth3dTestTask::ctrl() { if (state == 1 && auth_3d_id.check_loaded()) state = 2; - if (state == 2/* && event_listener.data.field_8 == 4 && !event_listener.data.field_C*/) { + if (state == 2 && data_event_listener.data.state == 4 && !data_event_listener.data.field_C) { auth_3d_id.set_enable(true); auth_3d_id.set_paused(false); auth_3d_id.set_repeat(auth_3d_test_task->repeat); @@ -477,9 +693,11 @@ bool Auth3dTestTask::ctrl() { } bool Auth3dTestTask::dest() { + aet.Free(); auth_3d_id.unload(rctx_ptr); objset_info_storage_unload_set(effcmn_obj_set); task_stage_del_task(); + data_event_listener.data.dest(); auth_3d_test_window->Hide(); clear_color = color_black; shadow_ptr_get()->self_shadow = true; @@ -569,10 +787,14 @@ void Auth3dTestTask::SetAuth3dId() { data_struct* aft_data = &data_list[DATA_AFT]; auth_3d_database* aft_auth_3d_db = &aft_data->data_ft.auth_3d_db; + data_event_listener.data.sub_140249A40(false); + data_event_listener.data.sub_140249A40(true); + auth_3d_id.unload(rctx_ptr); auth_3d_id = ::auth_3d_id(auth_3d_uid, aft_auth_3d_db); if (auth_3d_id.check_not_empty()) { auth_3d_id.set_enable(false); + auth_3d_id.add_event_adapter(&data_event_listener); auth_3d_id.read_file(aft_auth_3d_db); state = 1; } @@ -713,9 +935,9 @@ void Auth3dTestRobWindow::SelectionListRob::Callback(dw::SelectionListener::Call ::chara_index chara_index = (::chara_index)list_box->list->selected_item; int32_t chara_id = list_box->callback_data.i64 ? 1 : 0; - //auth_3d_test_task->event_listener.data - // .chara_index[list_box->callback_data.i64 != 0] = chara_index; - //auth_3d_test_task->event_listener.data.field_C = true; + auth_3d_test_task->data_event_listener.data + .chara_index[list_box->callback_data.i64 != 0] = chara_index; + auth_3d_test_task->data_event_listener.data.field_C = true; Auth3dTestRobWindow* rob_window = dynamic_cast(list_box->parent_comp); if (rob_window) @@ -741,12 +963,12 @@ void Auth3dTestRobWindow::SelectionListDispStyle::Callback(dw::SelectionListener Auth3dTestRobWindow* rob_window = dynamic_cast(list_box->parent_comp); if (rob_window) { ::chara_index chara_index = (::chara_index)rob_window->chara_list[chara_id]->list->selected_item; - //auth_3d_test_task->event_listener.data.chara_index[v6] = chara_index; - //auth_3d_test_task->event_listener.data.field_C = true; + auth_3d_test_task->data_event_listener.data.chara_index[chara_id] = chara_index; + auth_3d_test_task->data_event_listener.data.field_C = true; rob_window->GetCharaCos(chara_index, chara_id, rob_window->costume_list[chara_id]); list_box->SetItemIndex(selected_item); } - //auth_3d_test_task->event_listener.data.cos[chara_id] = cos; + auth_3d_test_task->data_event_listener.data.cos_id[chara_id] = cos; int32_t uid = auth_3d_test_task->auth_3d_id.get_uid(); auth_3d_test_task->auth_3d_id.unload(rctx_ptr); diff --git a/src/ReDIVA/data_test/auth_3d_test.hpp b/src/ReDIVA/data_test/auth_3d_test.hpp index abac701e..99f44096 100644 --- a/src/ReDIVA/data_test/auth_3d_test.hpp +++ b/src/ReDIVA/data_test/auth_3d_test.hpp @@ -10,9 +10,45 @@ #include "../../KKdLib/database/item_table.hpp" #include "../../CRE/auth_3d.hpp" #include "../../CRE/task.hpp" +#include "equip_test.hpp" class Auth3dTestTask : public app::Task { public: + class DataEventListener : public a3d::EventAdapter { + public: + struct Data { + int32_t state; + bool field_C; + bool field_D; + ::chara_index load_chara_index[2]; + ::chara_index chara_index[2]; + ::chara_index prev_chara_index[2]; + int32_t load_cos_id[2]; + int32_t cos_id[2]; + DtmEqVs dtm_eq_vs[2]; + bool chara_visible; + + Data(); + ~Data(); + + void ctrl(); + void dest(); + void free_all_chara(); + void init(); + + void sub_140244E20(); + void sub_140249A40(bool other_chara); + }; + + Data data; + + DataEventListener(); + virtual ~DataEventListener() override; + + virtual void Field_8(::auth_3d_id& id) override; + virtual void Field_20(::auth_3d_id& id) override; + } data_event_listener; + int32_t field_1C0; int32_t field_1C4; int32_t field_1C8; @@ -33,7 +69,8 @@ public: int32_t effcmn_obj_set_state; uint32_t effcmn_obj_set; int32_t aet_state; - //int32_t aet_id; + int32_t aet_id; + auth_3d_detail::EventA2d::Aet aet; bool plane_above_floor; bool stg_auth_display; bool stg_display;