' Ready Or Not - Key Binds File Parsing System v4
' by SemlerPDX Dec2021
' VETERANS-GAMING.COM
' --Loads Keys from user input game settings file into VoiceAttack Global Keypress Variables
Imports Microsoft.VisualBasic
Imports System
Imports System.Linq
Imports System.Collections
Imports System.Collections.Generic
Public Class VAInline
dim NumbersArray() as string = {
"Zero",
"One",
"Two",
"Three",
"Four",
"Five",
"Six",
"Seven",
"Eight",
"Nine"
}
dim NumPadArray() as string = {
"NumPadZero",
"NumPadOne",
"NumPadTwo",
"NumPadThree",
"NumPadFour",
"NumPadFive",
"NumPadSix",
"NumPadSeven",
"NumPadEight",
"NumPadNine"
}
dim FunctionKeysArray() as string = {
"F1",
"F2",
"F3",
"F4",
"F5",
"F6",
"F7",
"F8",
"F9",
"F10",
"F11",
"F12"
}
dim keyID as string = ""
dim keyLabel as string = ""
dim keyData() as string
dim contents() as string
dim actionMapping() as string
dim setMouse as boolean = false
dim labelsFinal as new list(of string) ()
Private Function ProcessKeyboardKey(ByVal thisKey as string, ByVal thisLabel as string)
if not(thisKey.Contains("Gamepad"))
select case thisKey
case "SpaceBar"
thisKey = "[SPACE]"
case "Decimal"
thisKey = "[NUM.]"
case "Subtract"
thisKey = "[NUM-]"
case "Add"
thisKey = "[NUM+]"
case "Multiply"
thisKey = "[NUM*]"
case "Divide"
thisKey = "[NUM/]"
case "Up"
thisKey = "[ARROWU]"
case "Down"
thisKey = "[ARROWD]"
case "Left"
thisKey = "[ARROWL]"
case "Right"
thisKey = "[ARROWR]"
case "LeftShift"
thisKey = "[LSHIFT]"
case "RightShift"
thisKey = "[RSHIFT]"
case "LeftControl"
thisKey = "[LCTRL]"
case "RightControl"
thisKey = "[RCTRL]"
case "LeftCommand"
thisKey = "[LWIN]"
case "RightCommand"
thisKey = "[RWIN]"
case "Tilde"
thisKey = "`"
case "Comma"
thisKey = ","
case "Period"
thisKey = "."
case "Slash"
thisKey = "/"
case "Semicolon"
thisKey = ";"
case "Apostrophe"
thisKey = "'"
case "Backslash"
thisKey = "\"
case "Pause"
thisKey = "[BREAK]"
case else
if (NumbersArray.Contains(thisKey))
for i as integer = 0 to 9
if (NumbersArray(i) = thisKey)
thisKey = i.ToString()
end if
next
else if (NumPadArray.Contains(thisKey))
for i as integer = 0 to 9
if (NumPadArray(i) = thisKey)
thisKey = "[NUM" + i.ToString() + "]"
end if
next
else if (FunctionKeysArray.Contains(thisKey))
for i as integer = 0 to 11
if (FunctionKeysArray(i) = thisKey)
thisKey = "[" + FunctionKeysArray(i) + "]"
end if
next
else if (thisKey.Contains("Mouse"))
setMouse = false
select case thisLabel
case "Fire"
if (thisKey = "LeftMouseButton")
setMouse = true
end if
case "ToggleADS"
if (thisKey = "RightMouseButton")
setMouse = true
end if
case "OpenSwatCommand"
if (thisKey = "MiddleMouseButton")
setMouse = true
end if
case "CycleSwatElementNext"
if (thisKey = "MouseScrollUp")
setMouse = true
end if
case "CycleSwatElementPrevious"
if (thisKey = "MouseScrollDown")
setMouse = true
end if
case else
setMouse = false
end select
thisKey = "NONE"
if (setMouse)
VA.SetBoolean("AVCS_RON_Mouse_" + thisLabel, true)
end if
else
thisKey = "[" + thisKey.ToUpper() + "]"
end if
end select
else
thisKey = "NONE"
end if
return thisKey
end function
Public Sub Main()
if (VA.GetText("~key_file") isNot nothing)
contents = VA.GetText("~key_file").Split(new string() {Environment.NewLine},StringSplitOptions.None)
for each line as string in contents
if (line <> "")
'Example:
'ActionMappings=(ActionName="DrawSting",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=NumPadZero)
if (line.StartsWith("ActionMappings"))
actionMapping = line.Split("(")
keyData = actionMapping(1).Split(",")
keyLabel = keyData(0).Substring(12).TrimEnd("""")
keyID = keyData(5).Substring(4).TrimEnd(")")
if not((keyLabel = "") or (labelsFinal.Contains(keyLabel)))
keyID = ProcessKeyboardKey(keyID, keyLabel)
if (keyID <> "NONE")
labelsFinal.Add(keyLabel)
VA.SetText("AVCS_RON_KEY_" + keyLabel, keyID)
end if
end if
end if
end if
next
VA.WriteToLog("AVCS4 RoN - Keyboard Settings File loaded into Keypress Variables", "gray")
end if
End Sub
End Class
Comments