40 Commits
Author SHA1 Message Date
florianessl 51e022ccec Refactored debug views related to in-game variable display:
- Extended & refactored window_varlist to support displaying data over multiple lines
  This is neccessary to have proper space for extended information on some special data types
  (for now StringVars; -> and at a later time also ScopedVars, which need more lines too)
- Removed the unneccessary copying of in-game strings
- Refactored part of the Range_Window setup code to be able to display more digits when viewing Switch/Variable ranges above 9999
- Maniacs 241028: Implemented the display for StringVar names
- Added a special function for button "Shift" in the debug scene:
  Pressing this button changes display modes for the current window
  (Currently only implemented for strings, to toggle between the old single-line display & the newer detailed one, that also included the name)
- Some other minor refactoring & moving of code parts
2025-05-24 15:32:29 +02:00
Ghabry 5dfc479a8b String Variables: Do not return views to local variables
The return values are not used by our code so this was actually harmless.
Return for ExPatch fixed to return a valid string_view.
Return type for ToFile changed to bool as string_view made no sense here in signalling an error.

Reported by clang on macOS.
2025-03-25 16:33:35 +01:00
Ghabry 22f028e842 Migrate to std::string_view 2025-03-02 19:38:55 +01:00
Gabriel 82806c2b1f Merge pull request #3341 from EasyRPG-NewFeatures/JSON-UPDATES
PROCESS JSON COMMAND - New Features
2025-03-04 16:08:12 +01:00
Erich Newey f92e6c4e25 StringVar: address popLine edge case behavior to match maniacs 2025-02-20 01:26:03 -07:00
Mauro Junior 31f9cac3b7 remove automatic alphabetical reorder by changing nlohmann::json to nlohmann::ordered_json
this can break for loops, and it's a weird extra step when processing json data
2025-01-30 21:42:26 -03:00
Ghabry 713db9dd8f String Var: Handle edge cases
Support left-adjust for PrependMin
Support indexing from the back with negative values

Fix #3305
2024-11-25 10:17:06 +01:00
Ghabry 0697a61633 String Variables: Work with codepoints instead of bytes
This matches the Maniac Patch behaviour better and is actually much better than using bytes.

For e.g. Latin1 (Western European) MP works with 1 Byte per char and for shift-jis (Japanese) MP works with multi-byte characters (2 bytes per character).

When using Unicode both cases map to 1 codepoint so we are very lucky here: It just works.

Fix #3298
2024-11-24 22:59:24 +01:00
Ghabry 842c2a422f ProcessJson: Cache parsed JSON to make accessing significantly faster
The cache is invalidated when the string is set
2024-11-21 22:37:42 +01:00
Ghabry 1e423d9b86 String Variables: Remove the UTF-8 byte order mask when reading in a file with Unicode encoding
Maniac Patch appears to do something similiar
2024-11-08 21:31:50 +01:00
Ghabry f26d9c312d String Variables: Fix off-by-one error in Split when counting the elements 2024-11-08 21:31:50 +01:00
Ghabry dd068009bd Fix warnings 2024-05-27 11:09:31 +02:00
Ghabry 533651143f Guard more extensions behind the flag 2024-05-09 23:47:37 +02:00
Mauro Junior d51633607e String Variable's ToFile - Relax File extension and path
When saving a file, maniacs forces the File in Text/ folder with .txt extension.
Through this PR, if '*' is at the end of filename, the file extension is relaxed.

It also better handles the creation of nested directories.
2024-05-09 22:44:24 +02:00
Ghabry aa5ac75c78 Strings: Support splitting when the delimiter is empty.
This operates on UTF-8 codepoints to ensure it works in most cases.

It will break for grapheme clusters but most programming languages will fail here.

Fix #3162
2023-11-30 00:16:37 +01:00
fdelapena e614030d8f Merge pull request #3141 from Ghabry/maniac/stringvars
Refactor String Vars
2023-11-17 13:19:46 -06:00
Ghabry f50c10b662 String Var: Explicitly pass in Game_Variables
Makes writing Unit tests easier later.
2023-11-02 01:02:53 +01:00
Ghabry fc56095985 String Var: Use StringView where possible instead of copying 2023-11-02 01:02:53 +01:00
Ghabry 797157d8d7 String Var: Use std::unordered_map instead of std::vector
Uses less memory when the string variables are sparse.
2023-11-02 01:02:53 +01:00
Ghabry 6576df186e String Var: Swap Decode and Encode
Encode converts to UTF-8 and Decode from UTF-8.

These functions in liblcf need a better name or a documentation comment.
2023-10-25 23:25:16 +02:00
Erich Newey 7221769f8d StringVars: remove debug statements 2023-10-22 12:15:51 -06:00
Ghabry 64802138a0 String Var: Fetch the text file for emscripten 2023-10-22 17:03:20 +02:00
Ghabry e20c316e14 String Var: Use correct extraction logic for \t[]
In Messages commands in \t[] are evaluated once.
In StringPics and Extract they are not.
2023-10-22 15:57:05 +02:00
Ghabry 069828e993 String Var: Move Maniac Command Inserters to Game_Strings 2023-10-22 14:26:05 +02:00
Ghabry 2bbf64de8f StringVar: Support files with Ansi encoding
Fix crash when older string var commands are used.
2023-10-22 14:16:44 +02:00
Erich Newey 5a9ef06443 StringVar: use Utils ReadLine instead of std getline 2023-10-12 16:56:54 -06:00
Erich Newey 0ec5f0ce6e StringVar: refactor from DBString to std string
also includes safe checks around nullptr when retrieving names and descriptions
2023-10-12 12:15:39 -06:00
Erich Newey ab783c8619 StringVar: fix split function
i guess i never actually tested it????
2023-10-12 12:15:08 -06:00
Erich Newey 88c8934090 StringVar: more hex support in string functions 2023-10-12 12:15:08 -06:00
Erich Newey ad3ebdcac2 StringVar: add support for hex conversion in extract operators 2023-10-12 12:15:03 -06:00
Erich Newey fac88cad71 StringVar: first pass at file writing support 2023-10-12 10:38:34 -06:00
Erich Newey 77e304a62c StringVar: first pass at extract functionality 2023-10-12 10:38:23 -06:00
Erich Newey c8fcc85abd StringVar: add regex find and replace functions 2023-10-12 10:34:32 -06:00
Erich Newey fb1af42e61 StringVar: add popline function 2023-10-12 10:34:32 -06:00
Erich Newey 17dab1830d StringVar: more refactors and add split function 2023-10-12 10:34:32 -06:00
Erich Newey 6de91d44b3 StringVar: add getLen and inStr functions 2023-10-12 10:34:31 -06:00
Erich Newey e1613c3340 StringVar: add some string name assigns 2023-10-12 10:34:31 -06:00
Erich Newey f95ee789ab StringVar: add num asg & cat 2023-10-12 10:34:31 -06:00
Erich Newey 87ae11192d StringVar: add min and range support for string asg and cat 2023-10-12 10:34:31 -06:00
Jorge Augusto 86d64076fe StringVar: Basic implementation
-Simple assign and concatenation operations already work
-Added the escape \t[x] for messages
-Complete documentation of the inner workings of the command made by BingShan
2023-10-12 10:34:31 -06:00