SemlerPDX icon

AVCS QCC Insert New Action After and Increment All Macro Step Actions

SemlerPDX | PRO | 08/14/20 06:09:54 AM UTC (Edited) | 0 ⭐ | 752 👁️ | Never ⏰ | []
VB.NET |

5.78 KB

|

None

|

0 👍

/

0 👎

' Quick Command Creator Inline-Function for VoiceAttack -  Increment All Actions following Insert Step Choice
'  by SemlerPDX Jun2020
'  VETERANS-GAMING.COM
 
 
Imports Microsoft.VisualBasic
Imports System
Imports System.Text
Imports System.Collections
Imports System.Collections.Generic
Imports System.Data
Imports System.Drawing
Imports System.Diagnostics
Imports System.Windows.Forms
Imports System.Linq
Imports System.Xml.Linq
Imports System.Threading.Tasks
 
Public Class VAInline
    dim stepIndex as Int32 = 1
    dim nextIndex as Int32 = 1
    dim moveIndex as Int32 = 1
    dim stepCount as Int32 = 1
    dim allSteps as string = ""
    dim lastStep as string
    dim lastSteps() as string
    dim macroSteps() as string
    dim macroData() as string
    dim thisStep() as string
    dim thisFormat as string
    dim thisAction as string    
    dim thisFunc as string
    dim debugCheck as boolean
    dim debugCount as integer = 0
    dim debugColor as integer = 3
    dim debugText as string = ""
    
    Public Sub Main()
        
        if (VA.GetBoolean("AVCS_Debug_ON") IsNot nothing)
            debugCheck = VA.GetBoolean("AVCS_Debug_ON")
        end if
        
        if (VA.GetInt("~avcs_qcc_adv_step_move") IsNot nothing)
            moveIndex = VA.GetInt("~avcs_qcc_adv_step_move")' + 1 'By disabling this, it should copy everything including MoveIndex step up one
            stepCount = moveIndex
        end if
        
        while ((VA.GetText("~avcs_qcc_action_step_" + stepCount.ToString())) IsNot nothing)
            stepCount += 1
        end while
        stepCount -= 1
        
        for stepIndex = stepCount to moveIndex step -1
            if ((VA.GetText("~avcs_qcc_action_step_" + stepIndex.ToString()))  IsNot nothing)
                lastSteps = (VA.GetText("~avcs_qcc_action_step_" + stepIndex.ToString()).Replace("[(2)]", "→")).Split("→")
                nextIndex = stepIndex + 1
                lastStep = nextIndex.ToString() + "[(2)]" + lastSteps(1).ToString()
                
                VA.SetText("~avcs_qcc_action_step_" + nextIndex.ToString(), lastStep.ToString())
                
                if (debugCheck)
                    debugText = "IncrementSteps LOOP " + stepIndex.ToString() + ": " + lastStep.ToString()
                    debugCount += 1
                    debugColor = 10
                    VA.SetText("~avcs_qcc_debug_" + debugCount.ToString(), debugText)
                    VA.SetInt("~avcs_qcc_debug_wclr_" + debugCount.ToString(), debugColor)
                end if
            
            end if
        next
        
        stepCount = 1
        while ((VA.GetText("~avcs_qcc_action_step_" + stepCount.ToString())) IsNot nothing)
            stepCount += 1
        end while
        stepCount -= 1
        
        if (moveIndex > 1)
            stepIndex = moveIndex - 1
        else
            stepIndex = 0
        end if
        
        VA.SetInt("~avcs_qcc_step_count", stepCount.ToString())
        VA.SetInt("~avcs_qcc_adv_step", moveIndex.ToString())
        VA.SetInt("~avcs_qcc_lst_step", stepIndex.ToString())
        
        for stepIndex = 1 to stepCount
            if ((VA.GetText("~avcs_qcc_action_step_" + stepIndex.ToString()))  IsNot nothing)
                lastStep = VA.GetText("~avcs_qcc_action_step_" + stepIndex.ToString())
                
                if not (lastStep.EndsWith("[(3)]"))
                    allSteps = allSteps + lastStep + "[(3)]"
                else
                    allSteps = allSteps + lastStep
                end if
                
                if (debugCheck)
                    debugText = "INSERT STEP - " + lastStep.ToString()
                    debugCount += 1
                    debugColor = 3
                    VA.SetText("~avcs_qcc_debug_" + debugCount.ToString(), debugText)
                    VA.SetInt("~avcs_qcc_debug_wclr_" + debugCount.ToString(), debugColor)
                end if
            
            end if
        next
        
        if (debugCheck)
            debugText = "STEPS FINAL - " + allSteps.ToString()
            debugCount += 1
            debugColor = 2
            VA.SetText("~avcs_qcc_debug_" + debugCount.ToString(), debugText)
            VA.SetInt("~avcs_qcc_debug_wclr_" + debugCount.ToString(), debugColor)
        end if
        
        if not (allSteps = "")
            
            VA.SetText("~avcs_qcc_allsteps", allSteps.ToString())
            
            macroSteps = (allSteps.Replace("[(1)]", "↑").Replace("[(2)]", "→").Replace("[(3)]", "↓").Replace("[(4)]", "←")).Split("↓")
            
            if (macroSteps) IsNot nothing
                for each macroStep as string in macroSteps
                    if not (macroStep = "")
                        macroData = macroStep.Split("←")
                        thisStep = macroData(0).Split("→")
                        stepIndex = Convert.ToInt32(thisStep(0))
                        thisAction = thisStep(1)
                        thisFunc = macroData(1)
                        thisFormat = macroStep.Replace("→", "[(2)]").Replace("←", "[(4)]")
                        if not (thisFormat.EndsWith("[(3)]"))
                            thisFormat = thisFormat + "[(3)]"
                        end if
                        VA.SetText("~avcs_qcc_step_type_" + stepIndex.ToString(), thisAction.ToString())
                        VA.SetText("~avcs_qcc_step_func_" + stepIndex.ToString(), thisFunc.ToString())
                        VA.SetText("~avcs_qcc_action_step_" + stepIndex.ToString(), thisFormat.ToString())
                        
                        if (debugCheck)
                            debugText = "STEP INDEX - " + stepIndex.ToString()
                            debugCount += 1
                            debugColor = 4
                            VA.SetText("~avcs_qcc_debug_" + debugCount.ToString(), debugText)
                            VA.SetInt("~avcs_qcc_debug_wclr_" + debugCount.ToString(), debugColor)
                            debugText = "THIS ACTION - " + thisAction.ToString()
                            debugCount += 1
                            debugColor = 7
                            VA.SetText("~avcs_qcc_debug_" + debugCount.ToString(), debugText)
                            VA.SetInt("~avcs_qcc_debug_wclr_" + debugCount.ToString(), debugColor)
                            debugText = "THIS FUNCTION - " + thisFunc.ToString()
                            debugCount += 1
                            debugColor = 3
                            VA.SetText("~avcs_qcc_debug_" + debugCount.ToString(), debugText)
                            VA.SetInt("~avcs_qcc_debug_wclr_" + debugCount.ToString(), debugColor)
                            debugText = "THIS FORMAT - " + thisFormat.ToString()
                            debugCount += 1
                            debugColor = 2
                            VA.SetText("~avcs_qcc_debug_" + debugCount.ToString(), debugText)
                            VA.SetInt("~avcs_qcc_debug_wclr_" + debugCount.ToString(), debugColor)
                        end if
                    
                    end if
                next
            
            end if
        end if
        
        if (debugCount > 0)
            VA.SetInt("~avcs_qcc_debug_count", debugCount)
        end if
        
    End Sub
 
End Class

Comments