Skip to content
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

1.2.0.0+ #107

Merged
merged 38 commits into from
Jul 11, 2024
Merged

1.2.0.0+ #107

merged 38 commits into from
Jul 11, 2024

Conversation

MnFeN
Copy link
Contributor

@MnFeN MnFeN commented Apr 28, 2024

The details have been added to the descriptions of each commit.

Split the RichTextboxHelper class definition from ActionForm class to create a new custom control. Also added a ReadonlyRichTextbox base class to allow scripts to display formatted text without using WndProc (safety API needed).
Change the "Error has been encountered" message on the UI to display the specific number of errors encountered since the last opening of the error page.

Fix an issue where the error info would never display after being opened once despite subsequent errors.

Additionally, refactored the logging system from a single Queue<InternalLog> to a dictionary keyed by DebugLevelEnum. This allows a cap of 30000 logs per type instead of a shared cap of 100000, preventing general logs like Info and Verbose from overshadowing older Error/Warning logs.
In script actions, named callback actions and main UI, change error message logging from ex.Message to ex.ToString() to provide more detailed stack trace information. Otherwise the ex.Message usually only contains a useless sentence.
…tting local triggers to Readonly

Some triggers need the users to manually fire them for self-testing. This is better not considered as "developer" level of usage. There are many people asking about "why I cannot fire the trigger" in Discord, which also shows this point.
…ion files

Improve the exception handling mechanism within the translation function to provide better feedback and fallback options when a FormatException occurs.

This FormatException usually happens when the translation string has more `{n}` fields then the original English string, either by mistake, or because of the original string was updated and less fields were required, such as the previous 1.1.7.x change from "Execute {C#/VB} script" to the plain text "Execute C# script".
String functions:
· tofullwidth / tohalfwidth: "H1" ↔ "H1"
· toxivchar(combineDigits=false): convert the alphanumeric characters to the corresponding XIV-defined black box character. If combineDigits, numbers between 10 and 31 would be converted to a single black box character.
· chr(separator=","): convert a string to a sequence of charcodes.
· ord(joiner=","): the reverse of chr.

Expressions:
· _triggerpath: the full path of the fired trigger.

Also cleaned up some argument descriptions in the autofill.
ISymbol.ContainingNamespace and ISymbol.ContainingAssembly could all be null (https://learn.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.ipropertysymbol?view=roslyn-dotnet-4.7.0).

This caused NullReferenceException when validating some properties.
@MnFeN MnFeN mentioned this pull request May 15, 2024
MnFeN added 15 commits May 18, 2024 06:09
Added functions to calculate L1-distance and L∞-distance :

· L1-distance:
  `l1d(...)` or `manhattandistance(...)`
· L∞-distance:
  `l∞d(...)` or `chebyshevdistance(...)`

L1-distance could be used to judge if 2 coordinations are close to each other, without calculating the squares and square-roots in the L2-distance.
The original code assumed the clicked grid is boolean type (checkbox), while the grids in the first column are actually namespaces.
Also added a "Copy as CSV" button to copy the CSV data.
Refactored the ActionType property to address compatibility issues when importing triggers from higher-version datasets.

The updated property now uses a more comprehensive setter: using `Enum.TryParse` to ensure robust handling of new, unknown action types. If the value is unrecognized, it will provide more information in the exception.
…ipboard exceptions

- The original code did not use control.Invoke to interact with the TreeView in the ui. This caused exceptions when autofiring some actions (such as enabling a trigger) when saving the trigger.

- ClipBoard.SetText(string text) does not accept empty string and caused exceptions in the original code.

Also:
- Changed `ctx.plug` to `RealPlugin.plug` to avoid null reference.
- Fixed the typo:
  paissaheavyindustries#93 (comment)
Contains:
- Start/End ACT Encounter
- Enable/disable "Use Deucalion"
- Enable/disable "Log All Network Data"

- The original `End Encounter` was automatically converted into this `End ACT Encounter`
- Tle old list action `PopLast` was also automatically converted to `Pop` with the given index `-1`.
- Check the characteristics of the beginning of the imported data to determine which type of imported data it is, instead of trying every single type.

- Providing more information based on the determined type.

- Added the plugin version in TriggernometryExport, and show the source version when importing the data.
- Registrant
- Registration time
- Last Invoked

The registrant could be set by the updated function:

RegisterNamedCallback(string name, CustomCallbackDelegate callback, object o, string registrant)

or automatically checked if using the original function without providing a registrant name.
(and other small changes)
The original code incorrectly updates repos set to "manually update" and then loads local files, causing duplicate folders to be added to the repo upon startup.
…tables and dicts

`\r\n` is considered as a single char.

e.g. using the expression below to build a dictionary (the second char is a linebreak):
```
=
a=1
b=2
c=3
```
- Double-click:
  · Clicking on all types of brackets / $ / ¤:
    Select the full expression with enclosed brackets, which could be very useful when writing long expressions and you cannot find where is the paired bracket;
  · Clicking on spaces:
    Select the adjacent spaces in the same line
  · Clicking on other characters:
    Select the current "word" (the splitting is better than original)

- Triple-click:
  · Single-line: Select all text
  · Multi-line: Select current line
@MnFeN
Copy link
Contributor Author

MnFeN commented May 27, 2024

Update Log

2024/5/27

Expressions

  • String functions

    • tofullwidth / tohalfwidth

      ${func:tofullwidth:H1} = H1
      ${func:tohalfwidth:H1} = H1

    • toxivchar(combineDigits=false)

      Convert the alphanumeric characters to the corresponding XIV-defined black box characters.
      If combineDigits, numbers between 10 and 31 would be converted to a single black box character.

    • ord(separator=",")

      Convert a string to a sequence of charcodes.
      ${func:ord:Test 1} = 84,101,115,116,32,49
      ${func:ord(-):Test 1} = 84-101-115-116-32-49

    • chr(joiner=",")

      The reverse of ord.
      ${func:chr:84,101,115,116,32,49} = Test 1

  • Normal expressions

    • _triggerpath
      The full path of the fired trigger.
  • Math functions

    • L1 and L∞ distance functions

      Definition of Ln-distance:

      • distance = (|x - x0| ^ n + |y - y0| ^ n + ...) ^ (1 / n)

      L2-distance: The normal distance (Euclidean distance)
      L1-distance: Manhattan distance
      L∞-distance: Chebyshev distance

      The expressions could be written as:

      l1d(...) / manhattandistance(...)
      l∞d(...) / chebyshevdistance(...)

      parameters: same as distance()

      • e.g. l1d(x0, y0, x1, y1) l1d(x0, y0, z0, x1, y1, z1)

      If you need to check if 2 locations are close to each other very frequently, l1d is better than distance (less calculation).

Actions

  • New action type: ACT Interaction

    Contains:

    • Start/End ACT Encounter (The original End Encounter is moved here and auto-converted)

    • Enable/disable "Use Deucalion" (injection)

    • Enable/disable "Log All Network Data"

    This feature could be very useful when SE suddenly uses some packets as the only way to figure out a mechanism, while that packet has not been parsed as log lines.

    You can control this option during certain time and use 252 = 0xFC network packet log lines to fire your trigger.

UI / Improve User Experience

  • Allow to sort a folder in descending order

    Related discussion: https://discord.com/channels/374517624228544512/1237066801876041783

  • Allow firing triggers outside developer mode

    Some triggers need the users to manually fire them for self-testing.

    This is better not considered as "developer" level of usage.

    There are many people asking about "why I cannot fire the trigger" in Discord, which also shows this point.

  • Display error log count on the main UI

    Change the "Error has been encountered" message on the UI to display the specific number of errors encountered since the last opening of the error page.

    Also fix an issue where the error info would never display after being opened once despite subsequent errors.

    Additionally, refactored the logging system from a single Queue to a dictionary keyed by DebugLevelEnum.
    This allows a cap of 30000 logs per type instead of a shared cap of 100000, preventing general logs like Info and Verbose from overshadowing older Error/Warning logs.

  • Enhanced double/triple-clicking selection in expression textboxes

    • Double-click:

      • Clicking on all types of brackets / $ / ¤:

        Select the full expression with enclosed brackets, which could be very useful when writing long nested expressions and you cannot find where the paired bracket is;

      • Clicking on spaces:

        Select the adjacent spaces in the same line;

      • Clicking on other characters:

        Select the current "word" (the splitting is better than original).

    • Triple-click:

      • Single-line: Select all text

      • Multi-line: Select current line

  • Show more information of named callbacks in the state form

    • Registrant

    • Registration time

    • Last Invoked

Codes / Scripts

  • Register Named Callbacks

    The registrant argument has been added:

    RegisterNamedCallback(string name, CustomCallbackDelegate callback, object o, string registrant) 

    The original function could still be used, and the registrant name would be detected automatically.

  • Added a ReadonlyRichTextbox class to display text with customized format

    public class Triggernometry.CustomControls.ReadonlyRichTextbox : RichTextbox

    This rich textbox has a "transparent" background, and do not allow any kind of mouse interaction (just like a label).

  • Provide more information during import

    • When the import fails, show more detailed reason

    • Show the plugin version of the imported xml

Bug Fixes

Check each commit for details.

Notice: Changed Behaviour

  • Line breaks

    is considered the same as a linebreak (considered as whitespace characters). So it should be trimmed when splitting arguments, unless it is surrounded by quotation marks.

    • e.g. listvar.join("⏎") should be used instead of listvar.join(⏎).

    Also, line breaks could also be used in actions and considered as a single character:

    • e.g. using the expression below to build a list 1, 2, 3
      (the first char is a linebreak, which is used as the separator of the following text when building a list in the action):

      
      1
      2
      3
      

      This allows multiline input and makes it easier to read when using a large amount of data to build a variable.

· Ctrl + Shift + 4: ${}
· Ctrl + Shift + V/L/T/D: ${v/l/t/d:};
· Ctrl + Shift + P, V/L/T/D: ${pv/pl/pt/pd:};
· Ctrl + Shift + N: ${n:}
· Ctrl + Shift + F: ${f::}
· Ctrl + Shift + E: ${_entity[].}
· Ctrl + Shift + M: ${_me.id}
· Ctrl + Shift + A: Select the next outer layer of brackets

Corresponding new configuration options:
· Enable shortcuts
· Use abbreviation
· Wrap selected text
@MnFeN MnFeN changed the title Feature Enhancements and Refactoring: UI Updates, Error Handling, and New String Functions 1.2.0.0+ Jun 1, 2024
MnFeN added 4 commits June 2, 2024 08:05
…sion):srcVersion}

For self-test triggers to determine if the user is using an old version of triggers / an old plugin.
The environment variables are defined in the folder form "Environment" tabpage.

e.g.

- folder1 (key1 = 1, key2 = 0)
  - folder2 (key2 = 2)
    - trigger

Parsing the expression `${env:key1} ${env:key2}` in the trigger would get `1 2`.
`_triggername` `_triggerpath` `_triggerid` etc.
Previously these expressions would give an empty string.
· `${_offset[1B]}`
  The headmarker offset (positive) in the current instance

· ${_targetmarker2id[type]} / ${_tm2id[type]}
  The hex ID of the current entity who has a specific marker.
  type: id (0, 1, ...) or description (attack1, attack2, ...)
MnFeN and others added 11 commits June 7, 2024 11:23
- dir2rad(direction, ±n)
  The reverse function of `roundir`.

  e.g.
    - `dir2rad(x, 360)` = `deg2rad(x)`.
    - `dir2rad(1, 4)` = -1.57...

- ispointinray(srcX, srcY, θ, width, tgtX, tgtY)
  Calculate if the point (tgt) is in the range of a ray AoE (src).
  It is actually a combination of `projdistance` and `projheight`.
since the full-width parentheses are widely used in CJK regions.
The separator has been changed from "," to linebreaks, which is easier to write and read.

Also added "//" for comments

e.g.

// Set the file path below:
path = C:\...

then use ${env:path} to use the value.
@paissaheavyindustries paissaheavyindustries merged commit 968da53 into paissaheavyindustries:master Jul 11, 2024
1 check was pending
@MnFeN MnFeN deleted the 1.2.0.0+ branch July 18, 2024 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants