Made <system.token(str_tokenname)> and <system.button(str_buttonname)> constructs

This commit is contained in:
JappaWakka 2021-10-19 23:55:26 +02:00
parent 32dba7e878
commit 39aaed5577
3 changed files with 64 additions and 79 deletions
P3D
Dialogues
HelperClasses
World/ActionScript/V2/ScriptConstructs

View File

@ -99,20 +99,6 @@
End Sub
Private Sub FormatText()
Dim tokenSearchBuffer As String() = Me.Text.Split(CChar("<token."))
Dim tokenEndIdx As Integer = 0
Dim validToken As String = ""
Dim token As Token = Nothing
For Each possibleToken As String In tokenSearchBuffer
tokenEndIdx = possibleToken.IndexOf(">")
If Not tokenEndIdx = -1 Then
validToken = possibleToken.Substring(0, tokenEndIdx)
If Localization.LocalizationTokens.ContainsKey(validToken) = True Then
Me.Text = Me.Text.Replace("<token." & validToken & ">", Localization.GetString(validToken, validToken))
End If
End If
Next
Me.Text = Me.Text.Replace("<playername>", Core.Player.Name)
Me.Text = Me.Text.Replace("<player.name>", Core.Player.Name)

View File

@ -116,71 +116,6 @@
result = result.Replace("<rivalname>", Core.Player.RivalName)
result = result.Replace("<player.name>", Core.Player.RivalName)
End If
Dim tokenSearchBuffer As String() = result.Split("<button.")
Dim tokenEndIdx As Integer = 0
Dim validToken As String = ""
For Each possibleToken As String In tokenSearchBuffer
tokenEndIdx = possibleToken.IndexOf(">")
If Not tokenEndIdx = -1 Then
Dim key As Keys
validToken = possibleToken.Substring(0, tokenEndIdx)
Select Case validToken.ToLower()
Case "moveforward"
key = KeyBindings.ForwardMoveKey
Case "moveleft"
key = KeyBindings.LeftMoveKey
Case "movebackward"
key = KeyBindings.BackwardMoveKey
Case "moveright"
key = KeyBindings.RightMoveKey
Case "openmenu"
key = KeyBindings.OpenInventoryKey
Case "chat"
key = KeyBindings.ChatKey
Case "special", "phone"
key = KeyBindings.SpecialKey
Case "muteaudio"
key = KeyBindings.MuteAudioKey
Case "cameraleft"
key = KeyBindings.LeftKey
Case "cameraright"
key = KeyBindings.RightKey
Case "cameraup"
key = KeyBindings.UpKey
Case "cameradown"
key = KeyBindings.DownKey
Case "cameralock"
key = KeyBindings.CameraLockKey
Case "guicontrol"
key = KeyBindings.GUIControlKey
Case "screenshot"
key = KeyBindings.ScreenshotKey
Case "debugcontrol"
key = KeyBindings.DebugKey
Case "perspectiveswitch"
key = KeyBindings.PerspectiveSwitchKey
Case "fullscreen"
key = KeyBindings.FullScreenKey
Case "enter1"
key = KeyBindings.EnterKey1
Case "enter2"
key = KeyBindings.EnterKey2
Case "back1"
key = KeyBindings.BackKey1
Case "back2"
key = KeyBindings.BackKey2
Case "escape", "esc"
key = KeyBindings.EscapeKey
Case "onlinestatus"
key = KeyBindings.OnlineStatusKey
Case "lighting"
key = KeyBindings.LightKey
End Select
result = result.Replace("<button." & validToken & ">", KeyBindings.GetKeyName(key))
End If
Next
Return result
End If
Else

View File

@ -11,6 +11,70 @@
Dim argument As String = GetSubClassArgumentPair(subClass).Argument
Select Case command.ToLower()
Case "token"
Dim tokenName As String = Localization.GetString(argument)
Return tokenName
Case "button"
Dim key As Keys = Nothing
Dim buttonName As String = argument
Select Case buttonName.ToLower()
Case "moveforward"
key = KeyBindings.ForwardMoveKey
Case "moveleft"
key = KeyBindings.LeftMoveKey
Case "movebackward"
key = KeyBindings.BackwardMoveKey
Case "moveright"
key = KeyBindings.RightMoveKey
Case "openmenu"
key = KeyBindings.OpenInventoryKey
Case "chat"
key = KeyBindings.ChatKey
Case "special", "phone"
key = KeyBindings.SpecialKey
Case "muteaudio"
key = KeyBindings.MuteAudioKey
Case "cameraleft"
key = KeyBindings.LeftKey
Case "cameraright"
key = KeyBindings.RightKey
Case "cameraup"
key = KeyBindings.UpKey
Case "cameradown"
key = KeyBindings.DownKey
Case "cameralock"
key = KeyBindings.CameraLockKey
Case "guicontrol"
key = KeyBindings.GUIControlKey
Case "screenshot"
key = KeyBindings.ScreenshotKey
Case "debugcontrol"
key = KeyBindings.DebugKey
Case "perspectiveswitch"
key = KeyBindings.PerspectiveSwitchKey
Case "fullscreen"
key = KeyBindings.FullScreenKey
Case "enter1"
key = KeyBindings.EnterKey1
Case "enter2"
key = KeyBindings.EnterKey2
Case "back1"
key = KeyBindings.BackKey1
Case "back2"
key = KeyBindings.BackKey2
Case "escape", "esc"
key = KeyBindings.EscapeKey
Case "onlinestatus"
key = KeyBindings.OnlineStatusKey
Case "lighting"
key = KeyBindings.LightKey
Case "hidegui"
key = KeyBindings.GUIControlKey
End Select
If key <> Nothing Then
buttonName = KeyBindings.GetKeyName(key)
End If
Return buttonName
Case "random"
Dim minRange As Integer = 1
Dim maxRange As Integer = 2