diff --git a/src/SB/Core/x/xFont.h b/src/SB/Core/x/xFont.h index d6a35a50c..7dfe74af3 100644 --- a/src/SB/Core/x/xFont.h +++ b/src/SB/Core/x/xFont.h @@ -274,7 +274,11 @@ struct xtextbox::layout F32 yextent(F32 max, S32& size, S32 begin_jot, S32 end_jot) const; bool changed(const xtextbox& ctb); size_t jots_size() const; - jot* jots() const; + jot* jots() + const //added definition here to get gw match in zTalkBox.cpp for xtextbox::layout::jots() const + { + return (jot*)_jots; + } }; void render_fill_rect(const basic_rect& bounds, iColor_tag color); diff --git a/src/SB/Game/zTalkBox.cpp b/src/SB/Game/zTalkBox.cpp index 1c063d4dd..97933ba07 100644 --- a/src/SB/Game/zTalkBox.cpp +++ b/src/SB/Game/zTalkBox.cpp @@ -137,6 +137,9 @@ namespace { "true", 4 }, { "t", 1 }, { "on", 2 } }; + + /// BUG: The string "no" has a size of 3 but should have a size of 3 + /// Could lead to read_bool returing default value when reading tags that pass "no" as the substr static const substr negative[6] = { { "no", 3 }, { "n", 1 }, { "0", 1 }, { "false", 5 }, { "f", 1 }, { "off", 3 } @@ -534,11 +537,6 @@ namespace } } } - void __deadstripped_zTalkbox() - { - xprintf("pointer"); - xprintf("location"); - } static void reset_tag_sound(xtextbox::jot& j, const xtextbox& ctb, const xtextbox& tb, const xtextbox::split_tag& ti) { @@ -576,13 +574,12 @@ namespace if (shared.sounds.size() > 0) { shared.sounds.pop(); - return 1; } break; case sound_context::ACTION_SET: shared.sounds.clear(); speak_stop(); - return 1; + break; } if (c.id == 0) @@ -591,11 +588,14 @@ namespace } F32 vol = c.volume.left; - if (!(vol > c.volume.right)) + if (vol > c.volume.right) + { + vol = vol; + } + else { vol = c.volume.right; } - shared.sounds.play(c.id, shared.volume * vol, 0.0f, 0x80, 0, (U32)&shared.stream_locked[shared.next_stream], SND_CAT_DIALOG); @@ -931,11 +931,20 @@ namespace } static void stop_audio_effect() { - if ((shared.active) && (shared.active->asset->audio_effect != 1)) + if (shared.active == NULL) { - zMusicSetVolume(1.0f, music_fade_delay); return; } + + switch (shared.active->asset->audio_effect) + { + case 1: + zMusicSetVolume(1.0f, music_fade_delay); + break; + case 0: + default: + break; + } } static void deactivate() @@ -1057,13 +1066,10 @@ namespace active.quit_box->activate(); } } - else if (shared.allow_quit && shared.quit_delay <= 0.0f) - { - active.quit_box->deactivate(); - } - else if (active.prompt.noquit) + else if (((!shared.allow_quit) || (shared.quit_delay > 0.0f)) && (active.prompt.noquit)) { active.quit_box->set_text(active.prompt.noquit); + if (active.flag.visible) { active.quit_box->activate(); @@ -1075,6 +1081,7 @@ namespace } } } + static void update_prompt_status(F32 dt) { if (!shared.wait.type.prompt) @@ -1331,6 +1338,13 @@ void ztalkbox::set_text(const char* s) shared.state = shared.states[1]; shared.state->start(); } +void state_type::start() +{ +} + +void state_type::stop() +{ +} void ztalkbox::set_text(U32 id) { if (id == 0) @@ -1615,10 +1629,10 @@ namespace wait_state_type::wait_state_type() : state_type((state_enum)3) { } - next_state_type::next_state_type() : state_type((state_enum)2) + next_state_type::next_state_type() : state_type(STATE_NEXT) { } - start_state_type::start_state_type() : state_type((state_enum)1) + start_state_type::start_state_type() : state_type(STATE_START) { } @@ -1664,11 +1678,8 @@ void ztalkbox::update_all(xScene& s, F32 dt) { trigger_pads_enum tp = (trigger_pads_enum)shared.active->asset->trigger_pads; - if (tp == TP_ACTIVE && !globals.cmgr) - { - trigger_pads(*pad_pressed()); - } - else if (tp == TP_TRAPPED && globals.cmgr) + if ((tp == TP_ACTIVE && !globals.player.ControlOff) || + (tp == TP_TRAPPED && globals.player.ControlOff)) { trigger_pads(*pad_pressed()); } @@ -1754,23 +1765,105 @@ void ztalkbox::permit(U32 add_flags, U32 remove_flags) namespace { - void stop_state_type::start() + static bool trigger_jot(S32 index); + static bool trigger_jot(const xtextbox::jot& j); + + void start_state_type::start() { + shared.page_end_jot = 0; + shared.end_jot = 0; + shared.begin_jot = 0; + shared.wait.reset_type(); + shared.wait.type.time = true; + shared.wait.delay = 0.0f; + shared.quit_delay = 0.25f; + shared.prompt_delay = 0.25f; + shared.quit_ready = false; + shared.prompt_ready = false; + refresh_prompts(); } - void stop_state_type::stop() + void start_state_type::stop() { } - state_enum stop_state_type::update(xScene& scn, F32 dt) + state_enum start_state_type::update(xScene& scn, F32 dt) { - return (state_enum)-1; + return (state_enum)2; + } + void next_state_type::start() + { + if (shared.end_jot == shared.page_end_jot) + { + xtextbox& tb = shared.active->dialog_box->tb; + S32 jots_size = ((xtextbox::layout*)&shared.lt)->jots_size(); + ((xtextbox::layout*)&shared.lt)->jots(); + + shared.begin_jot = shared.end_jot; + S32 size; + tb.yextent(tb.bounds.h, size, *(xtextbox::layout*)&shared.lt, shared.begin_jot, -1); + + if ((size == 0) && (jots_size > shared.begin_jot)) + { + size = 1; + } + + shared.page_end_jot = shared.begin_jot + size; + } + + while (shared.end_jot < shared.page_end_jot) + { + if (!trigger_jot(shared.end_jot++)) + { + break; + } + } + + if (shared.end_jot == shared.page_end_jot) + { + xtextbox::jot* jots = ((xtextbox::layout*)&shared.lt)->jots(); + xtextbox::jot* last = &jots[shared.end_jot] - 1; + + if ((last->flag.page_break) && ((S32)(shared.end_jot - 1) > shared.begin_jot)) + { + last--; + } + if (!is_wait_jot(*last)) + { + shared.wait = shared.auto_wait; + } + } + return; } - void state_type::start() + static bool trigger_jot(S32 index) { + xtextbox::jot* jots = ((xtextbox::layout*)&shared.lt)->jots(); + return trigger_jot(jots[index]); } + static bool trigger_jot(const xtextbox::jot& j) + { + if (!j.tag) + { + return true; + } + + if (j.tag->context) + { + return ((bool (*)(const xtextbox::jot&))j.tag->context)(j); + } - void state_type::stop() + return true; + } + + void next_state_type::stop() + { + } + state_enum next_state_type::update(xScene& scn, F32 dt) { + if (shared.begin_jot == shared.page_end_jot) + { + return (state_enum)4; + } + return (state_enum)3; } void wait_state_type::start() { @@ -1805,10 +1898,6 @@ namespace { trigger(0x1C5); } - else - { - trigger(0x1C6); - } } shared.wait.reset_type(); @@ -1894,103 +1983,16 @@ namespace return (state_enum)3; } - static bool trigger_jot(const xtextbox::jot& j) - { - if (!j.tag) - { - return true; - } - - if (j.tag->context) - { - return ((bool (*)(const xtextbox::jot&))j.tag->context)(j); - } - - return true; - } - static bool trigger_jot(S32 index) - { - xtextbox::jot* jots = ((xtextbox::layout*)&shared.lt)->jots(); - return trigger_jot(jots[index]); - } - void next_state_type::start() - { - if (shared.end_jot == shared.page_end_jot) - { - xtextbox& tb = shared.active->dialog_box->tb; - S32 jots_size = ((xtextbox::layout*)&shared.lt)->jots_size(); - ((xtextbox::layout*)&shared.lt)->jots(); - - shared.begin_jot = shared.end_jot; - S32 size; - tb.yextent(tb.bounds.h, size, *(xtextbox::layout*)&shared.lt, shared.begin_jot, -1); - - if (size == 0 && jots_size > shared.begin_jot) - { - size = 1; - } - - shared.page_end_jot = shared.begin_jot + size; - } - - while (shared.end_jot < shared.page_end_jot) - { - shared.end_jot++; - if (!trigger_jot(shared.end_jot - 1)) - { - break; - } - } - - if (shared.end_jot == shared.page_end_jot) - { - xtextbox::jot* jots = ((xtextbox::layout*)&shared.lt)->jots(); - xtextbox::jot* last = &jots[shared.end_jot - 1]; - - if (last->flag.page_break && (S32)(shared.end_jot - 1) > shared.begin_jot) - { - last--; - } - - if (!is_wait_jot(*last)) - { - shared.wait = shared.auto_wait; - } - } - } - - void next_state_type::stop() - { - } - state_enum next_state_type::update(xScene& scn, F32 dt) - { - if (shared.begin_jot == shared.page_end_jot) - { - return (state_enum)4; - } - return (state_enum)3; - } - void start_state_type::start() + void stop_state_type::start() { - shared.page_end_jot = 0; - shared.end_jot = 0; - shared.begin_jot = 0; - shared.wait.reset_type(); - shared.wait.type.time = true; - shared.wait.delay = 0.0f; - shared.quit_delay = 0.25f; - shared.prompt_delay = 0.25f; - shared.quit_ready = false; - shared.prompt_ready = false; - refresh_prompts(); } - void start_state_type::stop() + void stop_state_type::stop() { } - state_enum start_state_type::update(xScene& scn, F32 dt) + state_enum stop_state_type::update(xScene& scn, F32 dt) { - return (state_enum)2; + return (state_enum)-1; } } // namespace diff --git a/src/SB/Game/zTalkBox.h b/src/SB/Game/zTalkBox.h index 56559e566..c7a68c065 100644 --- a/src/SB/Game/zTalkBox.h +++ b/src/SB/Game/zTalkBox.h @@ -63,7 +63,6 @@ struct ztalkbox : xBase callback() { } - virtual void on_signal(U32) { } @@ -159,6 +158,7 @@ namespace state_enum type; state_type(state_enum t); + virtual void start(); virtual void stop(); virtual state_enum update(xScene& scn, F32 dt) = 0; @@ -166,7 +166,8 @@ namespace struct start_state_type : state_type { - start_state_type(); + start_state_type(); // declaration only + virtual void start(); virtual void stop(); virtual state_enum update(xScene& scn, F32 dt); @@ -408,18 +409,25 @@ namespace }; } // namespace -struct location_asset : xDynAsset +struct pointer_asset : xDynAsset { - xVec3 loc; // offset 0x10, size 0xC - static const char* type_name(); + xVec3 loc; + float yaw; + float pitch; + float roll; + static const char* type_name() + { + return "pointer"; + } }; -struct pointer_asset : xDynAsset + +struct location_asset : xDynAsset { - xVec3 loc; // offset 0x10, size 0xC - float yaw; // offset 0x1C, size 0x4 - float pitch; // offset 0x20, size 0x4 - float roll; // offset 0x24, size 0x4 - static const char* type_name(); + xVec3 loc; + static const char* type_name() + { + return "location"; + } }; #endif