Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports DigitalRune.Windows.TextEditor.Highlighting
- Imports DigitalRune.Windows.TextEditor.Completion
- Public Class Form1
- Public Shared versionNum As String = "2.52"
- Public Shared currentOpenFFextracted As String = ""
- Public Shared openedMW2 As Boolean = True
- Public Shared changedGSC As Boolean = False
- Public Shared ffBytes As Byte()
- Public Shared openFileCompressed As Boolean = False
- Public Shared openFileStart As Integer = 0
- Public Shared openFileEnd As Integer = 0
- Public Shared cancelCurrentOp As Boolean = False
- Public Shared dragDropFFname As String = ""
- Public Shared optionsData As ArrayList
- Public Shared clickNodeRawFiles As TreeNode
- Public Shared MW2Version As Integer = 269
- Public Shared MW2VersionPC As Integer = 276
- Public Shared COD4Version As Integer = 256
- Public Shared WaWVersion As Integer = 387
- Function ShowSplashScreen(ByVal IMG As String)
- Dim i As Image = Image.FromFile(IMG)
- Dim BVgI As Integer = 1
- If BVgI = 0 Then
- 'Do Nothing....;)
- Else
- SplashScreen1.Show()
- End If
- End Function
- Public Sub CreateRAW()
- Eprv.Text = "Creating RAW Backup......."
- Dim path As String = application.startuppath & "\Raw Backup.txt"
- Using sWrite As New io.streamwriter(path)
- sWrite.Write(CodeBox.Text)
- End Using
- If Eprv.Text = "RAW Backup Created!" Then
- Eprv.Text = "Compiled as *.gsc Script:: 0 Errors, 0 Up-to-dated, 1 Compiled. ENJOY! :=)"
- Else
- Eprv.Text = "RAW Backup Created!"
- End If
- End Sub
- Public Sub ErrorCheck()
- Dim i As Integer = 1
- Dim openStasheCount As Integer = 0
- Dim closeStasheCount As Integer = 0
- Dim startLineSearchBracket As Integer = -1
- Dim currentSearchBracket As Integer = -1
- Dim totalLines As String() = CodeBox.Text.Split(vbCrLf)
- Dim functions(450) As String
- Dim includes(25) As String ' it actually stores the included files :O
- Dim functionCount As Integer = 0
- Dim includeCount As Integer = 0
- ' Go line by line, counting up the amounts of things like curly braces
- For Each line As String In totalLines
- Dim commentChar As Integer = line.Length
- If (line.LastIndexOf("//") <> -1) Then
- commentChar = line.IndexOf("//")
- End If
- Dim beforeComment As String = line.Substring(0, commentChar)
- openStasheCount += CharCount(beforeComment, "{")
- closeStasheCount += CharCount(beforeComment, "}")
- If (openStasheCount = closeStasheCount And line.IndexOf("}") And line.IndexOf("#include") = -1) Then ' if the line isn't in a function....
- If (line.IndexOf("(") = -1) Then
- 'functions(functionCount) = line.Substring(0, line.Length)
- ' tbh, it should not even do this :S
- Else
- functions(functionCount) = line.Substring(0, line.IndexOf("("))
- functionCount += 1
- End If
- End If
- If (line.IndexOf("#include") <> -1) Then
- includes(includeCount) = line.Substring(line.IndexOf("#include") + 8)
- includeCount += 1
- End If
- i += 1
- Next
- ' So, we have all of the functions. Now see if anything is called that ins't a function!
- Dim allFunctions As String = "" ' a CSV function table
- Dim allIncludes As String = "" ' a CSV includes table
- For k As Integer = 0 To functions.Length - 1
- allFunctions += functions(k) + ","
- Next
- ReDim functions(1) ' delete to save some ram
- For k As Integer = 0 To includes.Length - 1
- allIncludes += includes(k) + ","
- Next
- ReDim functions(1) ' delete to save some ram
- i = 1
- For Each line As String In totalLines
- If (line.IndexOf("self thread ") <> -1) Then
- ' here is a function called...
- Dim endOffset As Integer = line.IndexOfAny(New Char() {"(", " "}, line.IndexOf(" thread ") + 8) - line.IndexOf(" thread ") - 8
- Dim called As String = line.Substring(line.IndexOf(" thread ") + 8, endOffset)
- If (allFunctions.IndexOf(called + ",") = -1) Then
- ' the function was NOT found! Check the includes...
- If (called.IndexOf("\") = -1) Then
- ' there was also no file reference, so it is an unknown function.
- Eprv.Text = "Script compile error: Unknown function """ + called + """"
- End If
- End If
- End If
- i += 1
- Next
- If (openStasheCount < closeStasheCount) Then
- Eprv.Text = "Syntax error: Too many close braces }"
- End If
- If (openStasheCount > closeStasheCount) Then
- Eprv.Text = "Syntax error: Too many open braces {"
- End If
- End Sub
- Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SvgTXT.Click
- Try
- Dim dlg As New SaveFileDialog
- dlg.Title = "Save Text As..."
- dlg.Filter = "Text File *.txt|*.txt"
- dlg.ShowDialog()
- Dim i As New System.IO.StreamWriter(dlg.FileName.ToString())
- i.Write(CodeBox.Text)
- i.Close()
- Catch ex As Exception
- End Try
- End Sub
- Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EX.Click
- Close()
- End Sub
- Private Sub GSCToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cgsc.Click
- Dim Activate As Boolean
- Activate = False
- If Activate = False Then
- Dim dlg As New SaveFileDialog
- dlg.Title = "Save Script As..."
- dlg.Filter = "GSC File *.gsc|*.gsc"
- dlg.ShowDialog()
- Dim i As New System.IO.StreamWriter(dlg.FileName.ToString())
- i.Write(CodeBox.Text)
- i.Close()
- Eprv.Text = "Compiled as *.gsc Script:: 0 Errors, 0 Up-to-dated, 1 Compiled. ENJOY! :=)"
- Else
- Eprv.Text = "Can't Compile as *.gsc! :("
- End If
- End Sub
- Private Sub RAWToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Craw.Click
- Dim dlg As New SaveFileDialog
- dlg.Title = "Save RAW As..."
- dlg.Filter = "RAW File *.*|*.*"
- dlg.ShowDialog()
- Dim i As New System.IO.StreamWriter(dlg.FileName.ToString())
- i.Write(CodeBox.Text)
- i.Close()
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- SplashScreen1.Show()
- MsgBox("Program Was Successfully Load :D")
- MsgBox("..And It's By Ace....")
- MsgBox("..not only me :D")
- SplashScreen1.Close()
- HighlightingStrategyFactory.CreateHighlightingStrategy("GSC_SCRIPT_ENGINE")
- Tools1.Start()
- CodeBox.EnableAutoDragDrop = True
- CodeBox.IntellisenseTree.CollapseAll()
- End Sub
- Private Sub ManualErrorCheckToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MEC.Click
- ErrorCheck()
- End Sub
- Private Sub Tools_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tools1.Tick
- Try
- If CodeBox.Text = "" Then
- 'Do Nothing()
- Else
- CreateRAW()
- End If
- ErrorCheck()
- Catch ex As Exception
- End Try
- End Sub
- Private Sub Tools2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tools2.Tick
- ErrorCheck()
- End Sub
- Private Sub SettingsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles STT.Click
- Form2.Show()
- End Sub
- Private Sub MakeAListToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MAL.Click
- Dim path As String = Application.StartupPath.ToString() + "\" + "Build In Features.txt"
- Dim sWrite As New System.IO.StreamWriter(path)
- sWrite.WriteLine("" + "" + "" + "" + "Copyright (C) Ace, 2010.")
- sWrite.WriteLine("")
- sWrite.WriteLine("")
- sWrite.WriteLine("")
- sWrite.WriteLine("Current Features:")
- sWrite.WriteLine("- GSC Script Editor.")
- sWrite.WriteLine("- Customisable League & Settings ;).")
- sWrite.WriteLine("- Variables Sender.")
- sWrite.WriteLine("- Script HightLight + Auto Completition. :D")
- sWrite.WriteLine("- Humans Error Check. ;) Thanks to the .FF Viewer GUYS!")
- sWrite.WriteLine("- Auto Backup of the script :D")
- sWrite.WriteLine("")
- sWrite.WriteLine("")
- sWrite.WriteLine("")
- sWrite.WriteLine("" + "" + "" + "" + "THANKS!, HTTP://MW2TOOLS.TK")
- sWrite.Close()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement