Advertisement
SemlerPDX

Check Edited Phrase For Existing Phrases

Aug 14th, 2020
1,003
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.03 KB | None | 0 0
  1. ' Quick Command Creator Inline-Function for VoiceAttack -  Check Edited Command for Existing Phrases already in use
  2. '  by SemlerPDX Jun2020
  3. '  VETERANS-GAMING.COM
  4.  
  5.  
  6. Imports Microsoft.VisualBasic
  7. Imports System
  8. Imports System.Collections
  9. Imports System.Collections.Generic
  10. Imports System.Data
  11. Imports System.Drawing
  12. Imports System.Diagnostics
  13. Imports System.Windows.Forms
  14. Imports System.Linq
  15. Imports System.Xml.Linq
  16. Imports System.Threading.Tasks
  17.  
  18. Public Class VAInline
  19.     dim saveFile as string = ""
  20.     dim phrase as string
  21.     dim phrases as string
  22.     dim commands as string = ""
  23.     dim phraseArray() as string
  24.     dim errorCount as integer = 0
  25.     dim errorsFinal as new list(of string) ()
  26.     dim phrasesLast as new list(of string) ()
  27.     dim phrasesUnique as new list(of string) ()
  28.    
  29.     Public Sub Main()
  30.        
  31.         if (VA.GetText("~save_file") IsNot nothing)
  32.             saveFile = VA.GetText("~save_file")
  33.         end if
  34.        
  35.         if (VA.GetText("~avcs_qcc_phrase_last") IsNot nothing)
  36.             phrases = (VA.GetText("~avcs_qcc_phrase_last"))
  37.             phraseArray = vaProxy.Utility.ExtractPhrases(phrases, true, true)
  38.             for each phrase in phraseArray
  39.                 if ((not(phrase = "")) and (not(phrasesLast.Contains(phrase))))
  40.                     phrasesLast.Add(phrase)
  41.                 end if
  42.             next
  43.         end if
  44.        
  45.         phrases = nothing
  46.         phraseArray = nothing
  47.        
  48.         if (VA.GetText("AVCS_QCC_COMMANDS") IsNot nothing)
  49.             commands = VA.GetText("AVCS_QCC_COMMANDS")
  50.         end if
  51.        
  52.         if (VA.GetText("AVCS_QCC_MACROS") IsNot nothing)
  53.             commands = VA.GetText("AVCS_QCC_MACROS") + ";" + commands
  54.         end if
  55.        
  56.         if (VA.GetText("AVCS_QCC_LISTEN") IsNot nothing)
  57.             commands = VA.GetText("AVCS_QCC_LISTEN") + ";" + commands
  58.         end if
  59.        
  60.         if (VA.GetText("AVCS_QCC_LISTEN_TOGGLE") IsNot nothing)
  61.             commands = VA.GetText("AVCS_QCC_LISTEN_TOGGLE") + ";" + commands
  62.         end if
  63.        
  64.         if (VA.GetText("~avcs_qcc_phrase") IsNot nothing)
  65.            
  66.             phrases = (VA.GetText("~avcs_qcc_phrase"))
  67.             phraseArray = vaProxy.Utility.ExtractPhrases(phrases, true, true)
  68.            
  69.             for each phrase in phraseArray
  70.                 'Check only NEW phrases added to this command phrase
  71.                 if ((not(phrase = "")) and (not(errorsFinal.Contains(phrase))) and (not(phrasesLast.Contains(phrase))))
  72.                     'If this new phrase is not already in the loaded QCC list of commands/macros phrases
  73.                     if (not(commands.Contains(phrase)))
  74.                         if ((saveFile.Contains(phrase)) or (vaProxy.Command.Exists(phrase)))
  75.                             errorsFinal.Add(phrase)
  76.                             errorCount = errorCount + 1
  77.                             VA.SetText("~avcs_qcc_error_" + errorCount.ToString(), phrase)
  78.                         end if
  79.                     'Else add this new phrase to a new list to identify any duplicate phrase variants
  80.                     else if (commands.Contains(phrase))
  81.                         if (phrasesUnique.Contains(phrase))
  82.                             errorsFinal.Add(phrase)
  83.                             errorCount = errorCount + 1
  84.                             VA.SetText("~avcs_qcc_error_" + errorCount.ToString(), phrase)
  85.                         else
  86.                             phrasesUnique.Add(phrase)
  87.                         end if
  88.                     end if
  89.                 end if
  90.             next
  91.         end if
  92.        
  93.         if(errorCount > 0)
  94.             VA.SetInt("~avcs_qcc_error_count", errorCount)
  95.         end if
  96.        
  97.     End Sub
  98. End Class
  99.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement