From 289699d6cd083e7904550a621a12878cbb0a9e1f Mon Sep 17 00:00:00 2001 From: DazedAnon Date: Mon, 27 Jul 2026 21:02:11 -0500 Subject: [PATCH] fix(rpgmaker): update default codes and fix regex pattern - Adjust regex pattern in dazedwrap.py for better compatibility with escape characters. --- modules/rpgmakermvmz.py | 12 ++++++------ tests/test_dazedwrap.py | 32 ++++++++++++++++++++++++++++++++ util/dazedwrap.py | 2 +- 3 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 tests/test_dazedwrap.py diff --git a/modules/rpgmakermvmz.py b/modules/rpgmakermvmz.py index db97af7..eb852c8 100644 --- a/modules/rpgmakermvmz.py +++ b/modules/rpgmakermvmz.py @@ -142,13 +142,13 @@ TLSYSTEMSWITCHES = False JOIN408 = False # Dialogue / Scroll / Choices (Main Codes) -CODE101 = False -CODE401 = False -CODE405 = False -CODE102 = False +CODE101 = True +CODE401 = True +CODE405 = True +CODE102 = True # Optional -CODE408 = False +CODE408 = True # Variables CODE122 = False @@ -157,7 +157,7 @@ CODE122_VAR_MAX = 2000 # Plugins / Scripts CODE355655 = False -CODE357 = True +CODE357 = False CODE657 = False CODE356 = False CODE320 = False diff --git a/tests/test_dazedwrap.py b/tests/test_dazedwrap.py new file mode 100644 index 0000000..0ba4614 --- /dev/null +++ b/tests/test_dazedwrap.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +"""Regression tests for shared DazedWrap control-code handling.""" + +from __future__ import annotations + +import os +import sys +import unittest +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +os.chdir(ROOT) +sys.path.insert(0, str(ROOT)) + +import util.dazedwrap as dazedwrap # noqa: E402 + + +class TestDazedWrapControlCodes(unittest.TestCase): + def test_shadow_codes_do_not_count_toward_visible_width(self): + self.assertEqual(dazedwrap._get_visible_length(r"\SHADOW[3]alpha"), 5) + self.assertEqual(dazedwrap._get_visible_length(r"\\SHADOW[3]alpha"), 5) + + def test_doubled_shadow_code_does_not_hide_first_visible_character(self): + text = r"\\SHADOW[3]alpha beta" + + wrapped = dazedwrap.wrapText(text, width=9) + + self.assertEqual(wrapped, "\\\\SHADOW[3]alpha\nbeta") + + +if __name__ == "__main__": + unittest.main() diff --git a/util/dazedwrap.py b/util/dazedwrap.py index 01f0b0c..ffb2ed5 100644 --- a/util/dazedwrap.py +++ b/util/dazedwrap.py @@ -2,7 +2,7 @@ import re # Wolf / RPG Maker inline codes that do not occupy visible box width. _WOLF_INLINE_VISIBLE_STRIP = re.compile( - r"\\(?:" + r"[\\]+(?:" r"r\[[^\]]*\]|" r"c(?:self)?\[[^\]]*\]|" r"f\[[^\]]*\]|"