-
Notifications
You must be signed in to change notification settings - Fork 39
zTalkBox Updates #716
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
Merged
+236
−16
Merged
zTalkBox Updates #716
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b79fc69
Matched 10 small functions
AARJL 1c48385
ztalkbox load and state_type update
AARJL 9ef4f04
Made suggested changes for primative types and updated variables. als…
AARJL bd48ce3
Merge branch 'bfbbdecomp:main' into main
AARJL 30db20c
Merge remote-tracking branch 'upstream/main'
AARJL 634562c
Merge branch 'main' of https://github.com/AARJL/bfbb
AARJL da22f62
Update
AARJL 9785b64
Made suggested updates
AARJL ae0fe8a
Reverted read_bool back to the state it was at
AARJL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| #include "xstransvc.h" | ||
| #include "zTalkBox.h" | ||
|
|
||
| #include "xDebug.h" | ||
| #include "zEntPlayer.h" | ||
| #include <types.h> | ||
|
|
||
| namespace | ||
|
|
@@ -105,10 +106,6 @@ namespace | |
| { | ||
| } | ||
|
|
||
| void reset_auto_wait() | ||
| { | ||
| } | ||
|
|
||
| void deactivate() | ||
| { | ||
| stop_audio_effect(); | ||
|
|
@@ -366,33 +363,205 @@ void ztalkbox::permit(U32 add_flags, U32 remove_flags) | |
| shared.permit |= add_flags; | ||
| } | ||
|
|
||
| void ztalkbox::load(xBase& data, xDynAsset& asset, unsigned long) | ||
| void ztalkbox::load(xBase& data, xDynAsset& asset, u32) | ||
| { | ||
| ((ztalkbox&)data).load((const ztalkbox::asset_type&)asset); | ||
| } | ||
|
|
||
| void ztalkbox::load_settings(xIniFile& ini) | ||
| { | ||
| shared.volume = xIniGetFloat(&ini, "talk_box.volume", 2.0f); | ||
| xDebugAddTweak("Talk Box|\01GlobalsGlobals|volume", &shared.volume, 0.1f, 10.0f, NULL, NULL, 0); | ||
| } | ||
|
|
||
| namespace | ||
| { | ||
| static U8 read_bool(const substr& s, bool def) | ||
| { | ||
| extern const substr negative[6]; | ||
| extern const substr positive[6]; | ||
| if (def) | ||
| { | ||
| for (U32 i = 0; i < 6; ++i) | ||
| { | ||
| if (icompare(s, negative[i]) == 0) | ||
| return 0; | ||
| } | ||
| return 1; | ||
| } | ||
| else | ||
| { | ||
| for (U32 i = 0; i < 6; ++i) | ||
| { | ||
| if (icompare(s, positive[i]) == 0) | ||
| return 1; | ||
| } | ||
| } | ||
| return 0; | ||
| } | ||
| static void parse_tag_pause(xtextbox::jot&, const xtextbox&, const xtextbox&, | ||
| const xtextbox::split_tag&) | ||
| { | ||
| } | ||
|
|
||
| static void parse_tag_trap(xtextbox::jot& j, const xtextbox&, const xtextbox&, | ||
|
Collaborator
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. Please remove the TODO in line with the other review comments. |
||
| const xtextbox::split_tag& ti) | ||
| { | ||
| bool c = 0; | ||
|
|
||
| if (ti.action.size == 1 && ti.action.text[0] == '=') | ||
| { | ||
| if (read_bool(ti.value, 1) != 0) | ||
| { | ||
| c = 1; | ||
| } | ||
| } | ||
|
|
||
| *(bool*)&j.context = c; | ||
| } | ||
|
|
||
| static void reset_tag_pause(xtextbox::jot&, const xtextbox&, const xtextbox&, | ||
| const xtextbox::split_tag&) | ||
| { | ||
| } | ||
| static void reset_tag_sound(xtextbox::jot& j, const xtextbox&, const xtextbox& tb, | ||
| const xtextbox::split_tag&) | ||
| { | ||
| if (!shared.active) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| if (&shared.active->dialog_box->tb != &tb) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| sound_context& c = *(sound_context*)j.context; | ||
|
|
||
| j.context_size = 24; | ||
|
|
||
| c.id = 0; | ||
| c.action = sound_context::ACTION_SET; | ||
| } | ||
| static void reset_tag_trap(xtextbox::jot& j, const xtextbox&, const xtextbox& ctb, | ||
| const xtextbox::split_tag&) | ||
| { | ||
| if (!shared.active) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| if (&shared.active->dialog_box->tb != &ctb) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| *(bool*)&j.context = (shared.active->asset->trap != 0); | ||
| } | ||
|
|
||
| static void reset_tag_allow_quit(xtextbox::jot& j, const xtextbox&, const xtextbox& ctb, | ||
| const xtextbox::split_tag&) | ||
| { | ||
| if (!shared.active) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| if (&shared.active->dialog_box->tb != &ctb) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| *(bool*)&j.context = (shared.active->asset->allow_quit != 0); | ||
| } | ||
|
|
||
| U8 trigger_pause(const xtextbox::jot&) | ||
| { | ||
| return 1; | ||
| } | ||
|
|
||
| U8 trigger_allow_quit(const xtextbox::jot& j) | ||
| { | ||
| shared.allow_quit = (j.context != NULL); | ||
|
|
||
| return 1; | ||
| } | ||
| U8 trigger_auto_wait(const xtextbox::jot& j) | ||
| { | ||
| shared.auto_wait = *(const wait_context*)j.context; | ||
|
|
||
| return 1; | ||
| } | ||
| state_type::state_type(state_enum t) | ||
| { | ||
| type = t; | ||
| } | ||
|
|
||
| wait_context& wait_context::operator=(const wait_context& rhs) //FIXME | ||
| { | ||
| type = rhs.type; | ||
| need = rhs.need; | ||
| delay = rhs.delay; | ||
| event_mask = rhs.event_mask; | ||
| query = rhs.query; | ||
| return *this; | ||
| } | ||
|
|
||
| void stop_audio_effect() | ||
| { | ||
| if (!shared.active) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| if (shared.active->asset == 0) | ||
| { | ||
| return; | ||
| } | ||
| } | ||
| static void reset_auto_wait() | ||
| { | ||
| const ztalkbox::asset_type* a = shared.active->asset; | ||
|
|
||
| shared.auto_wait.type.time = a->auto_wait.type.time; | ||
| shared.auto_wait.type.prompt = a->auto_wait.type.prompt; | ||
| shared.auto_wait.type.sound = a->auto_wait.type.sound; | ||
| shared.auto_wait.type.event = a->auto_wait.type.event; | ||
|
|
||
| shared.auto_wait.delay = a->auto_wait.delay; | ||
|
|
||
| shared.auto_wait.need = 0; | ||
|
|
||
| if (a->auto_wait.which_event <= 0 || a->auto_wait.which_event >= 32) | ||
| { | ||
| shared.auto_wait.event_mask = -1; | ||
| } | ||
| else | ||
| { | ||
| shared.auto_wait.event_mask = 1u << a->auto_wait.which_event; | ||
| } | ||
|
|
||
| shared.auto_wait.query = Q_SKIP; | ||
| } | ||
| static void reset_tag_auto_wait(xtextbox::jot& j, const xtextbox&, const xtextbox& ctb, | ||
| const xtextbox::split_tag&) | ||
| { | ||
| if (!shared.active) | ||
| { | ||
| return; | ||
| } | ||
| if (&shared.active->dialog_box->tb != &ctb) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| wait_context& c = *(wait_context*)j.context; | ||
| j.context_size = sizeof(wait_context); | ||
| reset_auto_wait(); | ||
| c = shared.auto_wait; | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| void start_state_type::stop() | ||
|
|
@@ -425,3 +594,16 @@ void wait_context::reset_type() | |
| { | ||
| *(U16*)&this->type = 0; | ||
| } | ||
|
|
||
| static U8 trigger_trap(const xtextbox::jot& j) | ||
| { | ||
| if (j.context != 0) | ||
| { | ||
| zEntPlayerControlOff(CONTROL_OWNER_TALK_BOX); | ||
| } | ||
| else | ||
| { | ||
| zEntPlayerControlOn(CONTROL_OWNER_TALK_BOX); | ||
| } | ||
| return 1; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Minor style comment to keep this in line with the rest of the project - add enclosing brackets instead of relying on the indentation here.
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.
Got it. I must have overlooked that one.