Skip to content

Commit

Permalink
TSA: Remove TL notes on ANM/STD loads, spell cards, and new text boxe…
Browse files Browse the repository at this point in the history
…s. [V]

Yeah, I've started disliking that they were on-screen for longer than
the box they apply to. Shouldn't draw too much attention to them.

Funded by zorg.
  • Loading branch information
nmlgc committed Mar 17, 2019
1 parent df24dc9 commit 71e32f6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions thcrap_tsa/src/spells.cpp
Expand Up @@ -8,6 +8,8 @@
*/

#include <thcrap.h>
// (TL notes should be removed before every spell card declaration)
#include <tlnote.hpp>
#include "thcrap_tsa.h"

// Lookup cache
Expand Down Expand Up @@ -49,6 +51,8 @@ int BP_spell_name(x86_reg_t *regs, json_t *bp_info)
BP_spell_id(regs, bp_info);
// -----------------

tlnote_remove();

if(spell_name && cache_spell_id_real >= cache_spell_id) {
const char *new_name = NULL;
int i = cache_spell_id_real;
Expand Down
12 changes: 12 additions & 0 deletions thcrap_tsa/src/th06_msg.cpp
Expand Up @@ -178,6 +178,7 @@ struct patch_msg_state_t {
th128_bubble_pos_t *bubble_pos;
const th06_msg_t *last_line_cmd;
const op_info_t *last_line_op;
const json_t *last_lines_with_tlnote;

// Indices
size_t cur_line;
Expand Down Expand Up @@ -211,6 +212,13 @@ patch_line_t patch_msg_state_t::diff_line_cur(int extra_param_len)
if(tln.tlnote) {
tli = tlnote_prerender(tln.tlnote);
line = tln.regular;
last_lines_with_tlnote = diff_lines;
} else if(
last_lines_with_tlnote != nullptr
&& diff_lines != last_lines_with_tlnote
) {
tli = tlnote_removal_index();
last_lines_with_tlnote = nullptr;
}
// Trim the line to the last full codepoint that would still fit
// into the original opcode after including the terminating '\0'
Expand Down Expand Up @@ -646,6 +654,10 @@ int patch_msg(void *file_inout, size_t size_out, size_t size_in, json_t *patch,
}
entry_new = 0;
state.time = -1;
// Use the occasion to remove any TL notes from spell
// cards that might still be on screen... Yeah, kinda
// ugly to set a *lines* variable to an *entry*, but eh.
state.last_lines_with_tlnote = state.diff_entry;
}

if(state.cmd_in->time != state.time) {
Expand Down
13 changes: 12 additions & 1 deletion thcrap_tsa/src/thcrap_tsa.cpp
Expand Up @@ -8,6 +8,8 @@
*/

#include <thcrap.h>
// (for TL note removal hooks)
#include <tlnote.hpp>
#include <commctrl.h>
#include "thcrap_tsa.h"
#include "layout.h"
Expand Down Expand Up @@ -115,6 +117,13 @@ extern "C" __declspec(dllexport) const char* steam_appid(void)
}
}

size_t tlnote_remove_size_hook(const char *fn, json_t *patch, size_t patch_size)
{
// We want these gone as early as possible
tlnote_remove();
return 0;
}

int __stdcall thcrap_plugin_init()
{
if(stack_remove_if_unneeded("base_tsa")) {
Expand All @@ -131,7 +140,9 @@ int __stdcall thcrap_plugin_init()
patchhook_register("msg*.msg", patch_msg_dlg, NULL); // th143
patchhook_register("e*.msg", patch_msg_end, NULL); // th10+ endings

patchhook_register("*.anm", patch_anm, NULL);
patchhook_register("*.anm", patch_anm, tlnote_remove_size_hook);
// Remove TL notes when retrying a stage
patchhook_register("*.std", nullptr, tlnote_remove_size_hook);
return 0;
}

Expand Down

0 comments on commit 71e32f6

Please sign in to comment.