Imports UpdateVB
Public Class Form1
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        My.Settings.ranksettings = True
        If My.Computer.FileSystem.FileExists(My.Application.Info.DirectoryPath + "/map.ini") Then
            My.Computer.FileSystem.DeleteFile(My.Application.Info.DirectoryPath + "/map.ini")
        End If
        updatesettings()

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        My.Settings.oilsettings = True

        If My.Computer.FileSystem.FileExists(My.Application.Info.DirectoryPath + "/map.ini") Then
            My.Computer.FileSystem.DeleteFile(My.Application.Info.DirectoryPath + "/map.ini")
        End If
        updatesettings()

    End Sub
    Public updater As New UpdateVB.UpdateVB
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        updater.checkinternet()
        updater.checkversion("http://h1.ripway.com/Deadforlife/NewVersion", "2.0.1.2")
        If updater.updateavailable = False Then
            MsgBox("You have the latest version")
        End If
        If updater.updateavailable = True Then
            MsgBox("The program is now downloading the update, it will load automaticly.", MsgBoxStyle.Information, )
            updater.downloadupdate("http://h1.ripway.com/Deadforlife/Map.ini-Creator-Setup.exe")
            If updater.downloadsuccess Then
                updater.runupdate()
            Else
                MsgBox("░Program isn't able to run, or the download failed.░", MsgBoxStyle.Critical, "Run Error")
            End If
        End If


    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        My.Settings.oilsettings = False
        My.Settings.ranksettings = False
    End Sub
    Sub updatesettings()
        If My.Settings.oilsettings = True Then
            If My.Settings.ranksettings = True Then
                'BOTH
                Dim writer As New System.IO.StreamWriter(My.Application.Info.DirectoryPath + "/map.ini", True)
                writer.Write("Rank 1" + vbNewLine + vbTab + "RankName                      = INI:RankLevel1" + vbNewLine + vbTab + "SkillPointsNeeded             = " & Rank11.Text + vbNewLine + vbTab + "SciencesGranted               = SCIENCE_Rank1" + vbNewLine + vbTab + "SciencePurchasePointsGranted  = " + Rank1.Text + vbNewLine + vbTab + "End" + vbNewLine + vbNewLine + "Rank 2" + vbNewLine + vbTab + "RankName                      = INI:RankLevel2" + vbNewLine + vbTab + "SkillPointsNeeded             = " & Rank22.Text + vbNewLine + vbTab + "SciencesGranted               = SCIENCE_Rank2" + vbNewLine + vbTab + "SciencePurchasePointsGranted  = " + Rank2.Text + vbNewLine + vbTab + "End" + vbNewLine + vbNewLine + "Rank 3" + vbNewLine + vbTab + "RankName                      = INI:RankLevel3" + vbNewLine + vbTab + "SkillPointsNeeded             = " & Rank33.Text + vbNewLine + vbTab + "SciencesGranted               = SCIENCE_Rank3" + vbNewLine + vbTab + "SciencePurchasePointsGranted  = " + Rank3.Text + vbNewLine + vbTab + "End" + vbNewLine + vbNewLine + "Rank 4" + vbNewLine + vbTab + "RankName                      = INI:RankLevel4" + vbNewLine + vbTab + "SkillPointsNeeded             = " & Rank44.Text + vbNewLine + vbTab + "SciencesGranted               = SCIENCE_Rank4" + vbNewLine + vbTab + "SciencePurchasePointsGranted  = " + Rank4.Text + vbNewLine + vbTab + "End" + vbNewLine + vbNewLine + "Rank 5" + vbNewLine + vbTab + "RankName                      = INI:RankLevel5" + vbNewLine + vbTab + "SkillPointsNeeded             = " & Rank55.Text + vbNewLine + vbTab + "SciencesGranted               = SCIENCE_Rank5" + vbNewLine + vbTab + "SciencePurchasePointsGranted  = " + Rank5.Text + vbNewLine + vbTab + "End" + vbNewLine + vbNewLine)
                writer.Write("Object TechOilDerrick" + vbNewLine + "ReplaceModule ModuleTag_04" + vbNewLine + "Behavior = AutoDepositUpdate ModuleTag_04_Override" + vbNewLine + "DepositTiming = " & time.Text + "000" + vbNewLine + "DepositAmount = " + normalbonus.Text + vbNewLine + "InitialCaptureBonus = " + capturebonus.Text + vbNewLine + "End" + vbNewLine + "End" + vbNewLine + "End")
                writer.Close()
                MsgBox("Saved!", MsgBoxStyle.Information, "")
            Else
                If My.Settings.ranksettings = False Then
                    'JUST OIL SETTINGS
                    Dim writer As New System.IO.StreamWriter(My.Application.Info.DirectoryPath + "/map.ini", True)
                    writer.Write("Object TechOilDerrick" + vbNewLine + "ReplaceModule ModuleTag_04" + vbNewLine + "Behavior = AutoDepositUpdate ModuleTag_04_Override" + vbNewLine + "DepositTiming = " & time.Text + "000" + vbNewLine + "DepositAmount = " + normalbonus.Text + vbNewLine + "InitialCaptureBonus = " + capturebonus.Text + vbNewLine + "End" + vbNewLine + "End" + vbNewLine + "End")
                    writer.Close()
                    MsgBox("Saved!", MsgBoxStyle.Information, "")
                End If
            End If
        Else
            If My.Settings.oilsettings = False Then
                If My.Settings.ranksettings = True Then
                    'JUST RANK SETTINGS
                    Dim writer As New System.IO.StreamWriter(My.Application.Info.DirectoryPath + "/map.ini", True)
                    writer.Write("Rank 1" + vbNewLine + vbTab + "RankName                      = INI:RankLevel1" + vbNewLine + vbTab + "SkillPointsNeeded             = " & Rank11.Text + vbNewLine + vbTab + "SciencesGranted               = SCIENCE_Rank1" + vbNewLine + vbTab + "SciencePurchasePointsGranted  = " + Rank1.Text + vbNewLine + vbTab + "End" + vbNewLine + vbNewLine + "Rank 2" + vbNewLine + vbTab + "RankName                      = INI:RankLevel2" + vbNewLine + vbTab + "SkillPointsNeeded             = " & Rank22.Text + vbNewLine + vbTab + "SciencesGranted               = SCIENCE_Rank2" + vbNewLine + vbTab + "SciencePurchasePointsGranted  = " + Rank2.Text + vbNewLine + vbTab + "End" + vbNewLine + vbNewLine + "Rank 3" + vbNewLine + vbTab + "RankName                      = INI:RankLevel3" + vbNewLine + vbTab + "SkillPointsNeeded             = " & Rank33.Text + vbNewLine + vbTab + "SciencesGranted               = SCIENCE_Rank3" + vbNewLine + vbTab + "SciencePurchasePointsGranted  = " + Rank3.Text + vbNewLine + vbTab + "End" + vbNewLine + vbNewLine + "Rank 4" + vbNewLine + vbTab + "RankName                      = INI:RankLevel4" + vbNewLine + vbTab + "SkillPointsNeeded             = " & Rank44.Text + vbNewLine + vbTab + "SciencesGranted               = SCIENCE_Rank4" + vbNewLine + vbTab + "SciencePurchasePointsGranted  = " + Rank4.Text + vbNewLine + vbTab + "End" + vbNewLine + vbNewLine + "Rank 5" + vbNewLine + vbTab + "RankName                      = INI:RankLevel5" + vbNewLine + vbTab + "SkillPointsNeeded             = " & Rank55.Text + vbNewLine + vbTab + "SciencesGranted               = SCIENCE_Rank5" + vbNewLine + vbTab + "SciencePurchasePointsGranted  = " + Rank5.Text + vbNewLine + vbTab + "End" + vbNewLine + vbNewLine)
                    writer.Close()
                    MsgBox("Saved!", MsgBoxStyle.Information, "")
                Else
                    If My.Settings.ranksettings = False Then
                        'NONE - DO NOTHING
                    End If
                End If
            End If
        End If
    End Sub
End Class


