Updated 21 March 2010

Game.vb

Public Class Game
    Public Shared game_process As New Process()

    Shared Function GameIsRunning() As Boolean
        GameIsRunning = False
        Try
            If game_process.Responding = True Then Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Shared Sub SelectGameFile()
        Dim o As New OpenFileDialog
        o.Filter = "Gameserver|Gameserver.bat;startGameServer.bat;*.bat"
        If o.ShowDialog = Windows.Forms.DialogResult.OK Then
            SaveSetting("L2Commander", "Settings", "GameFile", o.FileName)
        End If
    End Sub

    Shared Function GameFile() As String
        Return GetSetting("L2Commander", "Settings", "GameFile")
    End Function

    Shared Function GameFileExists() As Boolean
        Return False
        If GetSetting("L2Commander", "Settings", "GameFile").ToString.Length > 0 Then Return True
    End Function

    Shared Sub StartGame()
        If GameIsRunning() = True Then
            MsgBox("You have to stop the gameserver before starting it again!", MsgBoxStyle.Exclamation)
        Else
            If GameFileExists() = True Then
                game_process.StartInfo.FileName = GameFile()
            Else
                SelectGameFile()
                game_process.StartInfo.FileName = GameFile()
            End If

            If GetSetting("L2Commander", "Settings", "GameMaximized").ToString.Length > 0 Then
                If GetSetting("L2Commander", "Settings", "GameMaximized") = True Then game_process.StartInfo.WindowStyle = ProcessWindowStyle.Maximized
            ElseIf GetSetting("L2Commander", "Settings", "GameNormal").ToString.Length > 0 Then
                If GetSetting("L2Commander", "Settings", "GameNormal") = True Then game_process.StartInfo.WindowStyle = ProcessWindowStyle.Normal
            ElseIf GetSetting("L2Commander", "Settings", "GameMinimized").ToString.Length > 0 Then
                If GetSetting("L2Commander", "Settings", "GameNormal") = True Then game_process.StartInfo.WindowStyle = ProcessWindowStyle.Minimized
            ElseIf GetSetting("L2Commander", "Settings", "GameHidden").ToString.Length > 0 Then
                If GetSetting("L2Commander", "Settings", "GameNormal") = True Then game_process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
            End If
            Try
                game_process.Start()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End If
    End Sub

    Shared Sub StopGame()
        If GameIsRunning() = True Then
            game_process.CloseMainWindow()
        Else
            MsgBox("The gameserver is not running!", MsgBoxStyle.Exclamation)
        End If
    End Sub
End Class

Login.vb

Public Class Login
    Public Shared login_process As New Process()

    Shared Function LoginIsRunning() As Boolean
        LoginIsRunning = False
        Try
            If login_process.Responding = True Then Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Shared Sub SelectLoginFile()
        Dim o As New OpenFileDialog
        o.Filter = "Loginserver|Loginserver.bat;startLoginServer.bat;*.bat"
        If o.ShowDialog = Windows.Forms.DialogResult.OK Then
            SaveSetting("L2Commander", "Settings", "LoginFile", o.FileName)
        End If
    End Sub

    Shared Function LoginFile() As String
        Return GetSetting("L2Commander", "Settings", "LoginFile")
    End Function

    Shared Function LoginFileExists() As Boolean
        Return False
        If GetSetting("L2Commander", "Settings", "LoginFile").ToString.Length > 0 Then Return True
    End Function

    Shared Sub StartLogin()
        If LoginIsRunning() = True Then
            MsgBox("You have to stop the loginserver before starting it again!", MsgBoxStyle.Exclamation)
        Else
            If LoginFileExists() = True Then
                login_process.StartInfo.FileName = LoginFile()
            Else
                SelectLoginFile()
                login_process.StartInfo.FileName = LoginFile()
            End If
            If GetSetting("L2Commander", "Settings", "LoginMaximized").ToString.Length > 0 Then
                If GetSetting("L2Commander", "Settings", "LoginMaximized") = True Then login_process.StartInfo.WindowStyle = ProcessWindowStyle.Maximized
            ElseIf GetSetting("L2Commander", "Settings", "LoginNormal").ToString.Length > 0 Then
                If GetSetting("L2Commander", "Settings", "LoginNormal") = True Then login_process.StartInfo.WindowStyle = ProcessWindowStyle.Normal
            ElseIf GetSetting("L2Commander", "Settings", "LoginMinimized").ToString.Length > 0 Then
                If GetSetting("L2Commander", "Settings", "LoginNormal") = True Then login_process.StartInfo.WindowStyle = ProcessWindowStyle.Minimized
            ElseIf GetSetting("L2Commander", "Settings", "LoginHidden").ToString.Length > 0 Then
                If GetSetting("L2Commander", "Settings", "LoginNormal") = True Then login_process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
            End If
            Try
                login_process.Start()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End If
    End Sub

    Shared Sub StopLogin()
        If LoginIsRunning() = True Then
            login_process.CloseMainWindow()
        Else
            MsgBox("The loginserver is not running!", MsgBoxStyle.Exclamation)
        End If
    End Sub
End Class

Last edited Mar 21, 2010 at 10:55 AM by Stealth21, version 2

Comments

No comments yet.