Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'AionHeaven Launcher Coded by -DefaulT
- 'Copyright (C) 2011 -DefaulT
- 'Distributed By d.faultx@gmail.com
- 'This program is free software; you can redistribute it and/or
- 'modify it under the terms of the GNU General Public License
- 'as published by the Free Software Foundation; either version 2
- 'of the License, or (at your option) any later version.
- 'This program is distributed in the hope that it will be useful,
- 'but WITHOUT ANY WARRANTY; without even the implied warranty of
- 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- 'GNU General Public License for more details.
- 'You should have received a copy of the GNU General Public License
- 'along with this program; if not, write to the Free Software
- 'Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- '----------------------------
- ' Importing |
- Imports System.Net.Sockets '|
- Imports Nini.Config '|
- Imports Ionic.Zip '|
- Imports System.IO '|
- '----------------------------
- Public Class Form1
- ' Dragging form w/o borders :D
- #Region " ClientAreaMove Handling "
- Const WM_NCHITTEST As Integer = &H84
- Const HTCLIENT As Integer = &H1
- Const HTCAPTION As Integer = &H2
- Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
- Select Case m.Msg
- Case WM_NCHITTEST
- MyBase.WndProc(m)
- If m.Result = HTCLIENT Then m.Result = HTCAPTION
- Case Else
- MyBase.WndProc(m)
- End Select
- End Sub
- #End Region
- ' Load the config settings globally.
- Dim launcher As New IniConfigSource("launcher.ini")
- ' Connection information
- Dim ip As String = launcher.Configs("Connection").Get("IP")
- Dim login As String = launcher.Configs("Connection").Get("LoginPort")
- Dim world As String = launcher.Configs("Connection").Get("WorldPort")
- ' Shell information
- Dim startgame As String = launcher.Configs("Play").Get("Shell")
- ' Update information
- Dim bin As String = launcher.Configs("Patch").Get("Bin")
- ' URL information
- Dim url As String = launcher.Configs("Misc").Get("URL")
- ' Loading the Launcher
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- ' Load webbrowser
- WebBrowser1.Navigate(url)
- ' Timer setup
- Timer1.Interval = "500"
- Timer2.Interval = "1000"
- Timer3.Interval = "500"
- Timer4.Interval = "1000"
- Timer5.Interval = "500"
- ' 500 = 0.5 sec
- ' Interval is set in ms, so 1000 ms = 1 sec.
- ' Status Check
- CheckLogin()
- CheckWorld()
- ' Load version information
- Dim version As New IniConfigSource("version.ini")
- Dim current As String = version.Configs("Settings").Get("Version")
- ' Check if we need to download files
- If current <> "2.5.0.5" Then
- ' Notify the user
- MsgBox("You do not have the correct client version. We will update it for you.")
- 'Start the timer
- Timer1.Start()
- ' Update status text
- Label1.Text = "Patching Files..."
- Else
- ' Update Progress Bars etc.
- ProgressBar1.Value = "100"
- ProgressBar2.Value = "100"
- Label1.Text = "Your Client is Current..."
- End If
- End Sub
- ' Start the game
- Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
- ' Starting the game
- Shell(startgame)
- ' Exit the launcher after starting game
- Me.Close()
- End Sub
- ' Play button rollover
- Private Sub PictureBox2_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseHover
- PictureBox2.Image = My.Resources.play2
- End Sub
- ' Play button rollover
- Private Sub PictureBox2_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseLeave
- PictureBox2.Image = My.Resources.play1
- End Sub
- ' About button
- Private Sub PictureBox7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox7.Click
- ' Show what it's about
- MsgBox("Aion Launcher coded by -DefaulT. d.faultx@gmail.com")
- End Sub
- ' About rollover
- Private Sub PictureBox7_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox7.MouseHover
- PictureBox7.Image = My.Resources.about2_2
- End Sub
- ' About rollover
- Private Sub PictureBox7_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox7.MouseLeave
- PictureBox7.Image = My.Resources.about1_2
- End Sub
- ' Check login status
- Public Function CheckLogin()
- Dim LoginServer As New TcpClient
- Try
- ' Ip and Port
- LoginServer.Connect(ip, login)
- ' Server Online
- PictureBox4.BackgroundImage = My.Resources.login_on
- Catch Excep As Exception
- ' Server Offline
- PictureBox4.BackgroundImage = My.Resources.login_off
- ' Message the user
- MsgBox("Login Server is currently offline, please check the forums.")
- End Try
- End Function
- ' Check world status
- Public Function CheckWorld()
- Dim WorldServer As New TcpClient
- Try
- ' IP and Port
- WorldServer.Connect(ip, world)
- ' World is Online
- PictureBox5.BackgroundImage = My.Resources.world_on
- Catch Excep As Exception
- ' World is Offline
- PictureBox5.BackgroundImage = My.Resources.world_off
- ' Notify the user
- MsgBox("World Server is currently offline, please check the forums.")
- End Try
- End Function
- ' Close the launcher
- Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
- ' Closing
- Me.Close()
- End Sub
- ' Timer for updates
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- ' New
- ' Label change
- Label1.Text = "Updating INI..."
- ' Get configs
- Dim version As New IniConfigSource("version.ini")
- version.Configs("Settings").Set("Version", "2.5.0.5")
- ' Instead of downloading a new file, we just rewrite the INI
- ' Progress bar update
- ProgressBar1.Value = "100"
- ProgressBar2.Value = "25"
- ' Pause Timer
- Timer1.Stop()
- Timer2.Start()
- '---------------------------------------------------------------------------------------------------
- ' Old way we did it
- ' Label change
- ' Label1.Text = "Deleting Old Files..."
- ' Download correct version file
- ' If System.IO.File.Exists(My.Computer.FileSystem.CurrentDirectory + "/" + "version.ini") = True Then
- ' System.IO.File.Delete(My.Computer.FileSystem.CurrentDirectory + "/" + "version.ini")
- ' End If
- ' Progress bar update
- ' ProgressBar1.Value = "100"
- ' ProgressBar2.Value = "25"
- ' Pause Timer
- ' Timer1.Stop()
- ' Timer2.Start()
- '---------------------------------------------------------------------------------------------------
- End Sub
- ' Timer 2 for updates
- Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
- ' New
- ' Since there is no need for this timer, just update the progressbar etc.
- ' Label change
- Label1.Text = "Re-Configuring Files..."
- ' Progress bar update
- ProgressBar1.Value = "0"
- ProgressBar1.Value = "100"
- ProgressBar2.Value = "45"
- ' Pause Timer
- Timer2.Stop()
- Timer3.Start()
- '---------------------------------------------------------------------------------------------------
- ' Old way we did it
- ' Label change
- ' Label1.Text = "Downloading version.ini..."
- ' Download the file
- ' My.Computer.Network.DownloadFile _
- ' ("http://aionheaven.com/downloads/version.ini", _
- ' My.Computer.FileSystem.CurrentDirectory + "/" + "version.ini")
- ' Progress bar update
- ' ProgressBar1.Value = "0"
- ' ProgressBar1.Value = "100"
- ' ProgressBar2.Value = "45"
- ' Pause Timer
- ' Timer2.Stop()
- ' Timer3.Start()
- '---------------------------------------------------------------------------------------------------
- End Sub
- ' Timer 3 for updates
- Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
- ' Label change
- Label1.Text = "Deleting Old Files..."
- ' Download update
- If System.IO.File.Exists(My.Computer.FileSystem.CurrentDirectory + "/" + "bin32.zip") = True Then
- System.IO.File.Delete(My.Computer.FileSystem.CurrentDirectory + "/" + "bin32.zip")
- End If
- ' Progress bar update
- ProgressBar1.Value = "0"
- ProgressBar1.Value = "100"
- ProgressBar2.Value = "55"
- ' Pause Timer
- Timer3.Stop()
- Timer4.Start()
- End Sub
- ' Timer 4 for updates
- Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
- ' Label change
- Label1.Text = "Downloading bin32.zip..."
- ' Download Files
- My.Computer.Network.DownloadFile _
- (bin, _
- My.Computer.FileSystem.CurrentDirectory + "/" + "bin32.zip")
- ' Progress bar update
- ProgressBar1.Value = "0"
- ProgressBar1.Value = "100"
- ProgressBar2.Value = "85"
- ' Pause Timer
- Timer4.Stop()
- Timer5.Start()
- End Sub
- ' Timer 5 for updates
- Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick
- ' Label change
- Label1.Text = "Unzipping bin32.zip..."
- ' Unzipping
- Dim ZipToUnpack As String = "bin32.zip"
- Dim TargetDir As String = My.Computer.FileSystem.CurrentDirectory
- Console.WriteLine("Extracting file {0} to {1}", ZipToUnpack, TargetDir)
- Using zip As ZipFile = ZipFile.Read("bin32.zip")
- Dim s1 As String
- For Each s1 In zip.EntryFileNames
- zip(s1).Extract(TargetDir, ExtractExistingFileAction.OverwriteSilently)
- Next
- End Using
- ' Progress bar update
- ProgressBar1.Value = "0"
- ProgressBar1.Value = "100"
- ProgressBar2.Value = "100"
- Label1.Text = "Update Complete..."
- ' Pause Timer
- Timer5.Stop()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement