-
Notifications
You must be signed in to change notification settings - Fork 45
Some cleanup of zTalkBox before I moved on #785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b79fc69
1c48385
9ef4f04
bd48ce3
30db20c
634562c
da22f62
9785b64
ae0fe8a
eca2e2e
443c4c5
9fff40b
228625b
355d401
c0e6eaf
b3479ba
3c2802d
4c71f8c
58da531
c89d0cc
c3b4245
cc95af0
c8a17a8
4a73a9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we return the enum value here? ( |
||
| } | ||
| 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; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we return the enum value here? |
||
| } | ||
| return (state_enum)3; | ||
|
Comment on lines
+1864
to
+1866
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we return the enum value here? |
||
| } | ||
| 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; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we return the enum value here? |
||
| } | ||
| 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; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we return the enum value here? |
||
| } | ||
|
|
||
| } // namespace | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we return the enum value here?