fix(rpgmaker): update default codes and fix regex pattern
- Adjust regex pattern in dazedwrap.py for better compatibility with escape characters.
This commit is contained in:
parent
68e07adeb3
commit
289699d6cd
3 changed files with 39 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
32
tests/test_dazedwrap.py
Normal file
32
tests/test_dazedwrap.py
Normal file
|
|
@ -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()
|
||||
|
|
@ -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\[[^\]]*\]|"
|
||||
|
|
|
|||
Loading…
Reference in a new issue