Advertisement
Guest User

-DefaulT

a guest
Aug 10th, 2011
3,721
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'AionHeaven Launcher Coded by -DefaulT
  2. 'Copyright (C) 2011  -DefaulT
  3.  
  4. 'Distributed By d.faultx@gmail.com
  5.  
  6. 'This program is free software; you can redistribute it and/or
  7. 'modify it under the terms of the GNU General Public License
  8. 'as published by the Free Software Foundation; either version 2
  9. 'of the License, or (at your option) any later version.
  10.  
  11. 'This program is distributed in the hope that it will be useful,
  12. 'but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. 'GNU General Public License for more details.
  15.  
  16. 'You should have received a copy of the GNU General Public License
  17. 'along with this program; if not, write to the Free Software
  18. 'Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  19.  
  20.  
  21. '----------------------------
  22. '       Importing           |
  23. Imports System.Net.Sockets '|
  24. Imports Nini.Config        '|
  25. Imports Ionic.Zip          '|
  26. Imports System.IO          '|
  27. '----------------------------
  28.  
  29. Public Class Form1
  30.  
  31.     ' Dragging form w/o borders :D
  32. #Region " ClientAreaMove Handling "
  33.     Const WM_NCHITTEST As Integer = &H84
  34.     Const HTCLIENT As Integer = &H1
  35.     Const HTCAPTION As Integer = &H2
  36.     Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
  37.         Select Case m.Msg
  38.             Case WM_NCHITTEST
  39.                 MyBase.WndProc(m)
  40.                 If m.Result = HTCLIENT Then m.Result = HTCAPTION
  41.             Case Else
  42.                 MyBase.WndProc(m)
  43.         End Select
  44.     End Sub
  45. #End Region
  46.  
  47.     ' Load the config settings globally.
  48.    Dim launcher As New IniConfigSource("launcher.ini")
  49.  
  50.     ' Connection information
  51.    Dim ip As String = launcher.Configs("Connection").Get("IP")
  52.     Dim login As String = launcher.Configs("Connection").Get("LoginPort")
  53.     Dim world As String = launcher.Configs("Connection").Get("WorldPort")
  54.  
  55.     ' Shell information
  56.    Dim startgame As String = launcher.Configs("Play").Get("Shell")
  57.  
  58.     ' Update information
  59.    Dim bin As String = launcher.Configs("Patch").Get("Bin")
  60.  
  61.     ' URL information
  62.    Dim url As String = launcher.Configs("Misc").Get("URL")
  63.  
  64.     ' Loading the Launcher
  65.    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  66.  
  67.         ' Load webbrowser
  68.        WebBrowser1.Navigate(url)
  69.  
  70.         ' Timer setup
  71.        Timer1.Interval = "500"
  72.         Timer2.Interval = "1000"
  73.         Timer3.Interval = "500"
  74.         Timer4.Interval = "1000"
  75.         Timer5.Interval = "500"
  76.         ' 500 = 0.5 sec
  77.        ' Interval is set in ms, so 1000 ms = 1 sec.
  78.  
  79.         ' Status Check
  80.        CheckLogin()
  81.         CheckWorld()
  82.  
  83.         ' Load version information
  84.        Dim version As New IniConfigSource("version.ini")
  85.         Dim current As String = version.Configs("Settings").Get("Version")
  86.  
  87.         ' Check if we need to download files
  88.        If current <> "2.5.0.5" Then
  89.  
  90.             ' Notify the user
  91.            MsgBox("You do not have the correct client version. We will update it for you.")
  92.  
  93.             'Start the timer
  94.            Timer1.Start()
  95.  
  96.             ' Update status text
  97.            Label1.Text = "Patching Files..."
  98.  
  99.         Else
  100.             ' Update Progress Bars etc.
  101.            ProgressBar1.Value = "100"
  102.             ProgressBar2.Value = "100"
  103.             Label1.Text = "Your Client is Current..."
  104.         End If
  105.  
  106.     End Sub
  107.  
  108.     ' Start the game
  109.    Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
  110.  
  111.         ' Starting the game
  112.        Shell(startgame)
  113.  
  114.         ' Exit the launcher after starting game
  115.        Me.Close()
  116.  
  117.     End Sub
  118.  
  119.     ' Play button rollover
  120.    Private Sub PictureBox2_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseHover
  121.         PictureBox2.Image = My.Resources.play2
  122.     End Sub
  123.  
  124.     ' Play button rollover
  125.    Private Sub PictureBox2_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.MouseLeave
  126.         PictureBox2.Image = My.Resources.play1
  127.     End Sub
  128.  
  129.     ' About button
  130.    Private Sub PictureBox7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox7.Click
  131.  
  132.         ' Show what it's about
  133.        MsgBox("Aion Launcher coded by -DefaulT. d.faultx@gmail.com")
  134.  
  135.     End Sub
  136.  
  137.     ' About rollover
  138.    Private Sub PictureBox7_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox7.MouseHover
  139.         PictureBox7.Image = My.Resources.about2_2
  140.     End Sub
  141.  
  142.     ' About rollover
  143.    Private Sub PictureBox7_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox7.MouseLeave
  144.         PictureBox7.Image = My.Resources.about1_2
  145.     End Sub
  146.  
  147.     ' Check login status
  148.    Public Function CheckLogin()
  149.  
  150.         Dim LoginServer As New TcpClient
  151.         Try
  152.  
  153.             ' Ip and Port
  154.            LoginServer.Connect(ip, login)
  155.  
  156.             ' Server Online
  157.            PictureBox4.BackgroundImage = My.Resources.login_on
  158.  
  159.         Catch Excep As Exception
  160.  
  161.             ' Server Offline
  162.            PictureBox4.BackgroundImage = My.Resources.login_off
  163.  
  164.             ' Message the user
  165.            MsgBox("Login Server is currently offline, please check the forums.")
  166.  
  167.         End Try
  168.  
  169.     End Function
  170.  
  171.     ' Check world status
  172.    Public Function CheckWorld()
  173.  
  174.         Dim WorldServer As New TcpClient
  175.         Try
  176.  
  177.             ' IP and Port
  178.            WorldServer.Connect(ip, world)
  179.  
  180.             ' World is Online
  181.            PictureBox5.BackgroundImage = My.Resources.world_on
  182.  
  183.         Catch Excep As Exception
  184.  
  185.             ' World is Offline
  186.            PictureBox5.BackgroundImage = My.Resources.world_off
  187.  
  188.             ' Notify the user
  189.            MsgBox("World Server is currently offline, please check the forums.")
  190.  
  191.         End Try
  192.  
  193.     End Function
  194.  
  195.     ' Close the launcher
  196.    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
  197.  
  198.         ' Closing
  199.        Me.Close()
  200.  
  201.     End Sub
  202.  
  203.     ' Timer for updates
  204.    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  205.  
  206.         ' New
  207.  
  208.         ' Label change
  209.        Label1.Text = "Updating INI..."
  210.  
  211.         ' Get configs
  212.        Dim version As New IniConfigSource("version.ini")
  213.         version.Configs("Settings").Set("Version", "2.5.0.5")
  214.  
  215.         ' Instead of downloading a new file, we just rewrite the INI
  216.  
  217.         ' Progress bar update
  218.        ProgressBar1.Value = "100"
  219.         ProgressBar2.Value = "25"
  220.  
  221.         ' Pause Timer
  222.        Timer1.Stop()
  223.         Timer2.Start()
  224.  
  225.         '---------------------------------------------------------------------------------------------------
  226.        ' Old way we did it
  227.  
  228.         ' Label change
  229.        ' Label1.Text = "Deleting Old Files..."
  230.  
  231.         ' Download correct version file
  232.        ' If System.IO.File.Exists(My.Computer.FileSystem.CurrentDirectory + "/" + "version.ini") = True Then
  233.        ' System.IO.File.Delete(My.Computer.FileSystem.CurrentDirectory + "/" + "version.ini")
  234.        ' End If
  235.  
  236.         ' Progress bar update
  237.        ' ProgressBar1.Value = "100"
  238.        ' ProgressBar2.Value = "25"
  239.  
  240.         ' Pause Timer
  241.        ' Timer1.Stop()
  242.        ' Timer2.Start()
  243.        '---------------------------------------------------------------------------------------------------
  244.  
  245.     End Sub
  246.  
  247.     ' Timer 2 for updates
  248.    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
  249.  
  250.         ' New
  251.  
  252.         ' Since there is no need for this timer, just update the progressbar etc.
  253.  
  254.         ' Label change
  255.        Label1.Text = "Re-Configuring Files..."
  256.  
  257.         ' Progress bar update
  258.        ProgressBar1.Value = "0"
  259.         ProgressBar1.Value = "100"
  260.         ProgressBar2.Value = "45"
  261.  
  262.         ' Pause Timer
  263.        Timer2.Stop()
  264.         Timer3.Start()
  265.  
  266.  
  267.         '---------------------------------------------------------------------------------------------------
  268.        ' Old way we did it
  269.  
  270.         ' Label change
  271.        ' Label1.Text = "Downloading version.ini..."
  272.  
  273.         ' Download the file
  274.        ' My.Computer.Network.DownloadFile _
  275.         '        ("http://aionheaven.com/downloads/version.ini", _
  276.         '     My.Computer.FileSystem.CurrentDirectory + "/" + "version.ini")
  277.  
  278.         ' Progress bar update
  279.        ' ProgressBar1.Value = "0"
  280.        ' ProgressBar1.Value = "100"
  281.        ' ProgressBar2.Value = "45"
  282.  
  283.         ' Pause Timer
  284.        ' Timer2.Stop()
  285.        ' Timer3.Start()
  286.        '---------------------------------------------------------------------------------------------------
  287.    End Sub
  288.  
  289.     ' Timer 3 for updates
  290.    Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
  291.  
  292.         ' Label change
  293.        Label1.Text = "Deleting Old Files..."
  294.  
  295.         ' Download update
  296.        If System.IO.File.Exists(My.Computer.FileSystem.CurrentDirectory + "/" + "bin32.zip") = True Then
  297.             System.IO.File.Delete(My.Computer.FileSystem.CurrentDirectory + "/" + "bin32.zip")
  298.         End If
  299.  
  300.         ' Progress bar update
  301.        ProgressBar1.Value = "0"
  302.         ProgressBar1.Value = "100"
  303.         ProgressBar2.Value = "55"
  304.  
  305.         ' Pause Timer
  306.        Timer3.Stop()
  307.         Timer4.Start()
  308.  
  309.     End Sub
  310.  
  311.     ' Timer 4 for updates
  312.    Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
  313.  
  314.         ' Label change
  315.        Label1.Text = "Downloading bin32.zip..."
  316.  
  317.         ' Download Files
  318.        My.Computer.Network.DownloadFile _
  319.                 (bin, _
  320.              My.Computer.FileSystem.CurrentDirectory + "/" + "bin32.zip")
  321.  
  322.         ' Progress bar update
  323.        ProgressBar1.Value = "0"
  324.         ProgressBar1.Value = "100"
  325.         ProgressBar2.Value = "85"
  326.  
  327.         ' Pause Timer
  328.        Timer4.Stop()
  329.         Timer5.Start()
  330.  
  331.     End Sub
  332.  
  333.     ' Timer 5 for updates
  334.    Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick
  335.  
  336.         ' Label change
  337.        Label1.Text = "Unzipping bin32.zip..."
  338.  
  339.         ' Unzipping
  340.        Dim ZipToUnpack As String = "bin32.zip"
  341.         Dim TargetDir As String = My.Computer.FileSystem.CurrentDirectory
  342.         Console.WriteLine("Extracting file {0} to {1}", ZipToUnpack, TargetDir)
  343.         Using zip As ZipFile = ZipFile.Read("bin32.zip")
  344.             Dim s1 As String
  345.             For Each s1 In zip.EntryFileNames
  346.                 zip(s1).Extract(TargetDir, ExtractExistingFileAction.OverwriteSilently)
  347.             Next
  348.         End Using
  349.  
  350.         ' Progress bar update
  351.        ProgressBar1.Value = "0"
  352.         ProgressBar1.Value = "100"
  353.         ProgressBar2.Value = "100"
  354.  
  355.         Label1.Text = "Update Complete..."
  356.  
  357.         ' Pause Timer
  358.        Timer5.Stop()
  359.  
  360.     End Sub
  361.  
  362. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement