Advertisement
Guest User

Untitled

a guest
Sep 19th, 2010
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 9.25 KB | None | 0 0
  1. Imports DigitalRune.Windows.TextEditor.Highlighting
  2. Imports DigitalRune.Windows.TextEditor.Completion
  3.  
  4. Public Class Form1
  5.     Public Shared versionNum As String = "2.52"
  6.     Public Shared currentOpenFFextracted As String = ""
  7.     Public Shared openedMW2 As Boolean = True
  8.  
  9.     Public Shared changedGSC As Boolean = False
  10.  
  11.     Public Shared ffBytes As Byte()
  12.  
  13.     Public Shared openFileCompressed As Boolean = False
  14.     Public Shared openFileStart As Integer = 0
  15.     Public Shared openFileEnd As Integer = 0
  16.  
  17.     Public Shared cancelCurrentOp As Boolean = False
  18.     Public Shared dragDropFFname As String = ""
  19.  
  20.     Public Shared optionsData As ArrayList
  21.  
  22.     Public Shared clickNodeRawFiles As TreeNode
  23.  
  24.     Public Shared MW2Version As Integer = 269
  25.     Public Shared MW2VersionPC As Integer = 276
  26.     Public Shared COD4Version As Integer = 256
  27.     Public Shared WaWVersion As Integer = 387
  28.     Function ShowSplashScreen(ByVal IMG As String)
  29.         Dim i As Image = Image.FromFile(IMG)
  30.         Dim BVgI As Integer = 1
  31.  
  32.         If BVgI = 0 Then
  33.             'Do Nothing....;)
  34.         Else
  35.             SplashScreen1.Show()
  36.         End If
  37.     End Function
  38.     Public Sub CreateRAW()
  39.         Eprv.Text = "Creating RAW Backup......."
  40.         Dim path As String = application.startuppath & "\Raw Backup.txt"
  41.  
  42.         Using sWrite As New io.streamwriter(path)
  43.             sWrite.Write(CodeBox.Text)
  44.         End Using
  45.         If Eprv.Text = "RAW Backup Created!" Then
  46.             Eprv.Text = "Compiled as *.gsc Script:: 0 Errors, 0 Up-to-dated, 1 Compiled. ENJOY! :=)"
  47.         Else
  48.             Eprv.Text = "RAW Backup Created!"
  49.         End If
  50.     End Sub
  51.  
  52.     Public Sub ErrorCheck()
  53.  
  54.         Dim i As Integer = 1
  55.  
  56.         Dim openStasheCount As Integer = 0
  57.         Dim closeStasheCount As Integer = 0
  58.  
  59.         Dim startLineSearchBracket As Integer = -1
  60.         Dim currentSearchBracket As Integer = -1
  61.  
  62.         Dim totalLines As String() = CodeBox.Text.Split(vbCrLf)
  63.         Dim functions(450) As String
  64.         Dim includes(25) As String ' it actually stores the included files :O
  65.  
  66.         Dim functionCount As Integer = 0
  67.         Dim includeCount As Integer = 0
  68.  
  69.         ' Go line by line, counting up the amounts of things like curly braces
  70.         For Each line As String In totalLines
  71.             Dim commentChar As Integer = line.Length
  72.             If (line.LastIndexOf("//") <> -1) Then
  73.                 commentChar = line.IndexOf("//")
  74.             End If
  75.             Dim beforeComment As String = line.Substring(0, commentChar)
  76.  
  77.             openStasheCount += CharCount(beforeComment, "{")
  78.             closeStasheCount += CharCount(beforeComment, "}")
  79.  
  80.             If (openStasheCount = closeStasheCount And line.IndexOf("}") And line.IndexOf("#include") = -1) Then ' if the line isn't in a function....
  81.                 If (line.IndexOf("(") = -1) Then
  82.                     'functions(functionCount) = line.Substring(0, line.Length)
  83.                     ' tbh, it should not even do this :S
  84.                 Else
  85.                     functions(functionCount) = line.Substring(0, line.IndexOf("("))
  86.                     functionCount += 1
  87.                 End If
  88.  
  89.  
  90.             End If
  91.             If (line.IndexOf("#include") <> -1) Then
  92.                 includes(includeCount) = line.Substring(line.IndexOf("#include") + 8)
  93.                 includeCount += 1
  94.             End If
  95.             i += 1
  96.         Next
  97.         ' So, we have all of the functions. Now see if anything is called that ins't a function!
  98.         Dim allFunctions As String = "" ' a CSV function table
  99.         Dim allIncludes As String = "" ' a CSV includes table
  100.         For k As Integer = 0 To functions.Length - 1
  101.             allFunctions += functions(k) + ","
  102.         Next
  103.         ReDim functions(1) ' delete to save some ram
  104.         For k As Integer = 0 To includes.Length - 1
  105.             allIncludes += includes(k) + ","
  106.         Next
  107.         ReDim functions(1) ' delete to save some ram
  108.         i = 1
  109.         For Each line As String In totalLines
  110.             If (line.IndexOf("self thread ") <> -1) Then
  111.                 ' here is a function called...
  112.                 Dim endOffset As Integer = line.IndexOfAny(New Char() {"(", " "}, line.IndexOf(" thread ") + 8) - line.IndexOf(" thread ") - 8
  113.                 Dim called As String = line.Substring(line.IndexOf(" thread ") + 8, endOffset)
  114.  
  115.                 If (allFunctions.IndexOf(called + ",") = -1) Then
  116.                     ' the function was NOT found! Check the includes...
  117.                     If (called.IndexOf("\") = -1) Then
  118.                         ' there was also no file reference, so it is an unknown function.
  119.                         Eprv.Text = "Script compile error: Unknown function """ + called + """"
  120.                     End If
  121.  
  122.                 End If
  123.             End If
  124.             i += 1
  125.         Next
  126.  
  127.         If (openStasheCount < closeStasheCount) Then
  128.             Eprv.Text = "Syntax error: Too many close braces }"
  129.         End If
  130.         If (openStasheCount > closeStasheCount) Then
  131.             Eprv.Text = "Syntax error: Too many open braces {"
  132.         End If
  133.     End Sub
  134.  
  135.     Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SvgTXT.Click
  136.         Try
  137.             Dim dlg As New SaveFileDialog
  138.             dlg.Title = "Save Text As..."
  139.             dlg.Filter = "Text File *.txt|*.txt"
  140.             dlg.ShowDialog()
  141.             Dim i As New System.IO.StreamWriter(dlg.FileName.ToString())
  142.             i.Write(CodeBox.Text)
  143.             i.Close()
  144.         Catch ex As Exception
  145.  
  146.         End Try
  147.     End Sub
  148.  
  149.     Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EX.Click
  150.         Close()
  151.     End Sub
  152.  
  153.     Private Sub GSCToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cgsc.Click
  154.         Dim Activate As Boolean
  155.         Activate = False
  156.         If Activate = False Then
  157.             Dim dlg As New SaveFileDialog
  158.             dlg.Title = "Save Script As..."
  159.             dlg.Filter = "GSC File *.gsc|*.gsc"
  160.             dlg.ShowDialog()
  161.             Dim i As New System.IO.StreamWriter(dlg.FileName.ToString())
  162.             i.Write(CodeBox.Text)
  163.             i.Close()
  164.             Eprv.Text = "Compiled as *.gsc Script:: 0 Errors, 0 Up-to-dated, 1 Compiled. ENJOY! :=)"
  165.         Else
  166.             Eprv.Text = "Can't Compile as *.gsc! :("
  167.         End If
  168.     End Sub
  169.  
  170.     Private Sub RAWToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Craw.Click
  171.         Dim dlg As New SaveFileDialog
  172.         dlg.Title = "Save RAW As..."
  173.         dlg.Filter = "RAW File *.*|*.*"
  174.         dlg.ShowDialog()
  175.         Dim i As New System.IO.StreamWriter(dlg.FileName.ToString())
  176.         i.Write(CodeBox.Text)
  177.         i.Close()
  178.     End Sub
  179.  
  180.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  181.         SplashScreen1.Show()
  182.         MsgBox("Program Was Successfully Load :D")
  183.         MsgBox("..And It's By Ace....")
  184.         MsgBox("..not only me :D")
  185.         SplashScreen1.Close()
  186.         HighlightingStrategyFactory.CreateHighlightingStrategy("GSC_SCRIPT_ENGINE")
  187.         Tools1.Start()
  188.         CodeBox.EnableAutoDragDrop = True
  189.         CodeBox.IntellisenseTree.CollapseAll()
  190.     End Sub
  191.  
  192.     Private Sub ManualErrorCheckToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MEC.Click
  193.         ErrorCheck()
  194.     End Sub
  195.  
  196.     Private Sub Tools_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tools1.Tick
  197.         Try
  198.             If CodeBox.Text = "" Then
  199.  
  200.                 'Do Nothing()
  201.  
  202.             Else
  203.  
  204.                 CreateRAW()
  205.  
  206.             End If
  207.  
  208.             ErrorCheck()
  209.  
  210.         Catch ex As Exception
  211.  
  212.         End Try
  213.  
  214.     End Sub
  215.  
  216.     Private Sub Tools2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tools2.Tick
  217.         ErrorCheck()
  218.     End Sub
  219.  
  220.     Private Sub SettingsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles STT.Click
  221.         Form2.Show()
  222.     End Sub
  223.  
  224.     Private Sub MakeAListToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MAL.Click
  225.         Dim path As String = Application.StartupPath.ToString() + "\" + "Build In Features.txt"
  226.         Dim sWrite As New System.IO.StreamWriter(path)
  227.  
  228.         sWrite.WriteLine("" + "" + "" + "" + "Copyright (C) Ace, 2010.")
  229.         sWrite.WriteLine("")
  230.         sWrite.WriteLine("")
  231.         sWrite.WriteLine("")
  232.         sWrite.WriteLine("Current Features:")
  233.         sWrite.WriteLine("- GSC Script Editor.")
  234.         sWrite.WriteLine("- Customisable League & Settings ;).")
  235.         sWrite.WriteLine("- Variables Sender.")
  236.         sWrite.WriteLine("- Script HightLight + Auto Completition. :D")
  237.         sWrite.WriteLine("- Humans Error Check. ;) Thanks to the .FF Viewer GUYS!")
  238.         sWrite.WriteLine("- Auto Backup of the script :D")
  239.         sWrite.WriteLine("")
  240.         sWrite.WriteLine("")
  241.         sWrite.WriteLine("")
  242.         sWrite.WriteLine("" + "" + "" + "" + "THANKS!, HTTP://MW2TOOLS.TK")
  243.         sWrite.Close()
  244.     End Sub
  245. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement