Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' Save File System Inline-Function for VoiceAttack - Load Any/All Variables from File/List to Profile
- ' by SemlerPDX Mar2020 (updated Dec2020)
- ' VETERANS-GAMING.COM
- ' --Loads Variables from Text List Format into VA Variables of Appropriate Data Type (INT/DEC/TXT/BOOL)--
- Imports Microsoft.VisualBasic
- Imports System
- Imports System.Collections
- Imports System.Collections.Generic
- Imports System.Data
- Imports System.Drawing
- Imports System.Diagnostics
- Imports System.Globalization
- Imports System.Windows.Forms
- Imports System.Linq
- Imports System.Xml.Linq
- Imports System.Threading.Tasks
- Public Class VAInline
- dim decimalSeparator as string = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator
- dim cmdIndex as Int32
- dim cmdMax as Int32 = 255
- dim level as Int32
- dim phrase as string
- dim phrases as string
- dim phraseDataCheck as string
- dim phraseArray() as string
- dim phrasesList() as string
- dim phrasesUnique as string = ""
- dim macrosUnique as string = ""
- dim listenUnique as string = ""
- dim toggleUnique as string = ""
- dim phrasesFinal as new list(of string) ()
- dim clearVariable as boolean
- dim saveVariable as boolean
- dim variableIndex as integer
- dim commandRID as integer = 0
- dim countD as integer
- dim countC as integer
- dim contents() as string
- dim entry() as string
- dim debugCheck as boolean
- dim debugCount as integer = 0
- dim debugColor as integer = 3
- dim debugText as string = ""
- Public Sub Main()
- 'Get Live Debugging Return ID from VA
- if ((VA.GetInt("AVCS_CMD_RID")) IsNot nothing)
- commandRID = VA.GetInt("AVCS_CMD_RID")
- end if
- if ((VA.GetText("~save_file")) IsNot nothing)
- 'Clear all QCC Commands & Data variables
- if ((VA.GetInt("AVCS_QCC_COMMAND_MAX")) IsNot nothing)
- cmdMax = Convert.ToInt32(VA.GetInt("AVCS_QCC_COMMAND_MAX"))
- end if
- for cmdIndex = 1 to cmdMax
- VA.SetText("AVCS_QCC_DATA_MACROS_" + cmdIndex.ToString(), nothing)
- VA.SetText("AVCS_QCC_COMMAND_" + cmdIndex.ToString(), nothing)
- next
- for i as integer = 1 to 6
- VA.SetText("AVCS_" + vaProxy.ParseTokens("{TXT:AVCS_ACTIVE_PROFILE:CORE}").ToString() + "_PTTBUTTON_" + i.ToString(),nothing)
- next
- VA.SetInt("AVCS_CORE_PTT_MODE", nothing)
- 'Clear all QCC Variable 'When I say' phrases
- VA.SetText("AVCS_QCC_WAKE", nothing)
- VA.SetText("AVCS_QCC_COMMANDS", nothing)
- VA.SetText("AVCS_QCC_MACROS", nothing)
- VA.SetText("AVCS_QCC_LISTEN", nothing)
- VA.SetText("AVCS_QCC_LISTEN_TOGGLE", nothing)
- 'Clear all VAS Passphrase Command variables
- for level = 1 to 10
- VA.SetText("AVCS_VAS_PASSWORDS_LEVEL_" + level.ToString(), nothing)
- next
- 'Check and Set Clear/Save Parameter Variables
- if ((VA.GetBoolean("AVCS_SFS_LOAD_clear")) IsNot nothing)
- clearVariable = VA.GetBoolean("AVCS_SFS_LOAD_clear")
- end if
- if ((VA.GetBoolean("AVCS_SFS_LOAD_save")) IsNot nothing)
- saveVariable = VA.GetBoolean("AVCS_SFS_LOAD_save")
- end if
- 'Split contents of save file into single lines separated by the newline or (/n)
- if (VA.GetText("~save_file").Contains(vbNewLine))
- contents = VA.GetText("~save_file").Split(new string() {Environment.NewLine},StringSplitOptions.None)
- else
- contents = VA.GetText("~save_file").Split(new string() {"(/n)"},StringSplitOptions.None)
- end if
- 'In each line, isolate Var Name/Val via '=' and Eval entry value for data type
- for each line as string in contents
- if not(line = "")
- entry = line.Split("=")
- if (entry(1).Contains("."))
- countD = entry(1).Split(".").Length -1
- else
- countD = 0
- end if
- if (entry(1).Contains(","))
- countC = entry(1).Split(",").Length -1
- else
- countC = 0
- end if
- 'Use Comma and Decimal Count to check data type for casting as Int or Dec
- if ((IsNumeric(entry(1))) and (((countD <= 1) and (countC = 0)) or ((countC <= 1) and (countD = 0))))
- if ((entry(1).Contains (".")) or (entry(1).Contains (",")))
- ' Attempt to Handle International Decimal Separator
- if (decimalSeparator <> ".")
- if (entry(1).Contains("."))
- entry(1) = Replace(entry(1), ".", decimalSeparator)
- end if
- end if
- ' Entry is a DECIMAL Type
- if ((clearVariable) and (saveVariable))
- ' Prepare Decimal Var for SaveToProfile command, clearing from Profile completely
- variableIndex = variableIndex + 1
- VA.SetText("~~varType" + variableIndex.ToString(), "DEC")
- VA.SetText("~~varName" + variableIndex.ToString(), entry(0))
- elseif (saveVariable)
- ' Prepare Decimal Var for SaveToProfile command
- variableIndex = variableIndex + 1
- VA.SetText("~~varType" + variableIndex.ToString(), "DEC")
- VA.SetText("~~varName" + variableIndex.ToString(), entry(0))
- VA.SetText("~~varValue" + variableIndex.ToString(), entry(1))
- elseif (clearVariable)
- ' Clear Decimal Var directly from Profile
- VA.SetDecimal(entry(0), nothing)
- else
- ' Load Decimal Var directly to Profile
- VA.SetDecimal(entry(0), entry(1))
- end if
- else
- ' Entry is an INTEGER Type
- if ((clearVariable) and (saveVariable))
- ' Prepare Integer Var for SaveToProfile command, clearing from Profile completely
- variableIndex = variableIndex + 1
- VA.SetText("~~varType" + variableIndex.ToString(), "INT")
- VA.SetText("~~varName" + variableIndex.ToString(), entry(0))
- elseif (saveVariable)
- ' Prepare Integer Var for SaveToProfile command
- variableIndex = variableIndex + 1
- VA.SetText("~~varType" + variableIndex.ToString(), "INT")
- VA.SetText("~~varName" + variableIndex.ToString(), entry(0))
- VA.SetText("~~varValue" + variableIndex.ToString(), entry(1))
- elseif (clearVariable)
- ' Clear Integer Var directly from Profile
- VA.SetInt(entry(0), nothing)
- else
- ' Load Integer Var directly to Profile
- VA.SetInt(entry(0), entry(1))
- end if
- end if
- 'if entry(1) is NOT Numeric--------------------------
- elseif ((LCase(entry(1)) = "true") or (LCase(entry(1)) = "false"))
- ' Entry is a BOOLEAN Type
- if ((clearVariable) and (saveVariable))
- ' Prepare Boolean Var for SaveToProfile command, clearing from Profile completely
- variableIndex = variableIndex + 1
- VA.SetText("~~varType" + variableIndex.ToString(), "BOOL")
- VA.SetText("~~varName" + variableIndex.ToString(), entry(0))
- elseif (saveVariable)
- ' Prepare Boolean Var for SaveToProfile command
- variableIndex = variableIndex + 1
- VA.SetText("~~varType" + variableIndex.ToString(), "BOOL")
- VA.SetText("~~varName" + variableIndex.ToString(), entry(0))
- VA.SetText("~~varValue" + variableIndex.ToString(), entry(1))
- elseif (clearVariable)
- ' Clear Boolean Var directly from Profile
- VA.SetBoolean(entry(0), nothing)
- else
- ' Load Boolean Var directly to Profile
- VA.SetBoolean(entry(0), entry(1))
- end if
- else
- ' Entry is a TEXT Type
- if ((clearVariable) and (saveVariable))
- ' Prepare Text Var for SaveToProfile command, clearing from Profile completely
- variableIndex = variableIndex + 1
- VA.SetText("~~varType" + variableIndex.ToString(), "TXT")
- VA.SetText("~~varName" + variableIndex.ToString(), entry(0))
- elseif (saveVariable)
- ' Prepare Text Var for SaveToProfile command
- variableIndex = variableIndex + 1
- VA.SetText("~~varType" + variableIndex.ToString(), "TXT")
- VA.SetText("~~varName" + variableIndex.ToString(), entry(0))
- VA.SetText("~~varValue" + variableIndex.ToString(), entry(1))
- elseif (clearVariable)
- ' Clear Text Var directly from Profile
- VA.SetText(entry(0), nothing)
- else
- ' Load Text Var directly to Profile
- VA.SetText(entry(0), entry(1))
- end if
- end if
- end if
- next 'loop around to the next entry value
- if (variableIndex > 0)
- ' Set Max Count of Vars prepared for SaveToProfile command func, execute as sub-command, wait for completion
- VA.SetInt("~~varIndex", variableIndex.ToString())
- vaProxy.Command.Execute ("f_sfs_to_profile", true, true)
- end if
- 'Load all QCC Commands to main phrase(s) variable ----------CHECK IS THIS NEEDED _ DOUBLE CALL HERE AND ABOVE?! -----
- if ((VA.GetInt("AVCS_QCC_COMMAND_MAX")) IsNot nothing)
- cmdMax = Convert.ToInt32(VA.GetInt("AVCS_QCC_COMMAND_MAX"))
- end if
- for cmdIndex = 1 to cmdMax
- if (((VA.GetText("AVCS_QCC_COMMAND_" + cmdIndex.ToString())) IsNot nothing) and ((VA.GetText("AVCS_QCC_DATA_COMMAND_" + cmdIndex.ToString())) IsNot nothing))
- phrases = (VA.GetText("AVCS_QCC_COMMAND_" + cmdIndex.ToString()))
- phraseArray = vaProxy.Utility.ExtractPhrases(phrases, true, true)
- for each phrase in phraseArray
- if ((not(phrase = "")) and (not(phrasesFinal.Contains(phrase))))
- phrasesFinal.Add(phrase)
- phrasesUnique = phrasesUnique + phrase + ";"
- VA.SetText(phrase, cmdIndex.ToString())
- end if
- next
- end if
- if (((VA.GetText("AVCS_QCC_MACROS_" + cmdIndex.ToString())) IsNot nothing) and ((VA.GetText("AVCS_QCC_DATA_MACROS_" + cmdIndex.ToString())) IsNot nothing))
- phraseDataCheck = VA.GetText("AVCS_QCC_DATA_MACROS_" + cmdIndex.ToString())
- phrases = (VA.GetText("AVCS_QCC_MACROS_" + cmdIndex.ToString()))
- phraseArray = vaProxy.Utility.ExtractPhrases(phrases, true, true)
- for each phrase in phraseArray
- if ((not(phrase = "")) and (not(phrasesFinal.Contains(phrase))))
- phrasesFinal.Add(phrase)
- 'Check for commands with Start/Toggle VoiceAttack listening
- if ((not(phraseDataCheck.Contains("1[(2)]VALB"))) and (not(phraseDataCheck.Contains("1[(2)]VALT"))))
- macrosUnique = macrosUnique + phrase + ";"
- else
- if (phraseDataCheck.Contains("1[(2)]VALB"))
- listenUnique = listenUnique + phrase + ";"
- elseif (phraseDataCheck.Contains("1[(2)]VALT"))
- toggleUnique = toggleUnique + phrase + ";"
- end if
- end if
- 'Set Key Data Variable Name to Variable Name including each Quick Command Phrase
- VA.SetText(phrase, cmdIndex.ToString())
- end if
- next
- end if
- next
- end if
- 'Create Variable 'When I Say' Tokens containing all QCC phrases
- if not (phrasesUnique = "")
- VA.SetText("AVCS_QCC_COMMANDS", phrasesUnique)
- else
- VA.SetText("AVCS_QCC_COMMANDS", nothing)
- end if
- if not (macrosUnique = "")
- VA.SetText("AVCS_QCC_MACROS", macrosUnique)
- else
- VA.SetText("AVCS_QCC_MACROS", nothing)
- end if
- if not (listenUnique = "")
- VA.SetText("AVCS_QCC_LISTEN", listenUnique)
- else
- VA.SetText("AVCS_QCC_LISTEN", nothing)
- end if
- if not (toggleUnique = "")
- VA.SetText("AVCS_QCC_LISTEN_TOGGLE", toggleUnique)
- else
- VA.SetText("AVCS_QCC_LISTEN_TOGGLE", nothing)
- end if
- 'Load all VAS Passphrase Commands to main phrase variables
- for level = 1 to 10
- VA.SetText("AVCS_VAS_PASSWORDS_LV_" + level.ToString(), nothing)
- next
- for level = 1 to 10
- phrase = ""
- phrases = ""
- phrasesUnique = ""
- phrasesList = nothing
- if ((VA.GetText("AVCS_VAS_PASSWORDS_LEVEL_" + level.ToString())) IsNot nothing)
- phrases = (VA.GetText("AVCS_VAS_PASSWORDS_LEVEL_" + level.ToString()))
- if (phrases.Contains("[(1)]"))
- phrasesList = (VA.GetText("AVCS_VAS_PASSWORDS_LEVEL_" + level.ToString()).Replace("[(1)]", "↑")).Split("↑")
- if (not(phrasesList.ToString() = ""))
- for each phrases as string in phrasesList
- if (not(phrases = ""))
- phraseArray = vaProxy.Utility.ExtractPhrases(phrases, true, true)
- for each phrase in phraseArray
- if ((not(phrase = "")) and (not(phrasesFinal.Contains(phrase))))
- phrasesFinal.Add(phrase)
- phrasesUnique = phrasesUnique + phrase + ";"
- elseif ((not(phrase = "")) and ((phrasesFinal.Contains(phrase))))
- 'Log Debug Error - Duplicate Passphrase Detected - note level number of base variable
- if (debugCheck)
- debugText = "DUPLICATE PASSPHRASE DETECTED inside Level " + level.ToString()
- debugCount += 1
- debugColor = 2
- VA.SetText("~avcs_vas_debug_" + debugCount.ToString(), debugText)
- VA.SetInt("~avcs_vas_debug_wclr_" + debugCount.ToString(), debugColor)
- end if
- end if
- next
- end if
- next
- end if
- else
- phraseArray = vaProxy.Utility.ExtractPhrases(phrases, true, true)
- for each phrase in phraseArray
- if ((not(phrase = "")) and (not(phrasesFinal.Contains(phrase))))
- phrasesFinal.Add(phrase)
- phrasesUnique = phrasesUnique + phrase + ";"
- elseif ((not(phrase = "")) and ((phrasesFinal.Contains(phrase))))
- 'Log Debug Error - Duplicate Passphrase Detected - note level number of base variable
- if (debugCheck)
- debugText = "DUPLICATE PASSPHRASE DETECTED inside Level " + level.ToString()
- debugCount += 1
- debugColor = 2
- VA.SetText("~avcs_vas_debug_" + debugCount.ToString(), debugText)
- VA.SetInt("~avcs_vas_debug_wclr_" + debugCount.ToString(), debugColor)
- end if
- end if
- next
- end if
- if (not(phrasesUnique = ""))
- 'Create Level Based Variables for 'When I Say' Tokens containing all VAS phrases
- VA.SetText("AVCS_VAS_PASSWORDS_LV_" + level.ToString(), phrasesUnique)
- end if
- end if
- next
- 'Increment and Return Live Debugging RID to VA
- if (commandRID > 0)
- commandRID = commandRID + 234
- VA.SetInt("AVCS_CMD_RID", commandRID)
- end if
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement