コード例 #1
0
 private void StopServer()
 {
     if (ServerList.FocusedItem != null)
     {
         ArkServerListViewItem ASLVI = (ArkServerListViewItem)ServerList.FocusedItem;
         ASLVI.GetServerData().StopServer();
         ASLVI.UpdateStatus();
         Registry.SaveRegConfig(this);
         Log(ASLVI.GetServerData().AltSaveDirectory + " Stopped!");
     }
 }
コード例 #2
0
 private void EditServer()
 {
     if (ServerList.FocusedItem != null)
     {
         ArkServerListViewItem ASLVI  = ((ArkServerListViewItem)ServerList.FocusedItem);
         AddServer             AddSrv = new AddServer(ASLVI.GetServerData(), ServerPath);
         if (AddSrv.ShowDialog() == DialogResult.OK)
         {
             ASLVI.SetServerData(AddSrv.ServerData);
         }
         Log(ASLVI.GetServerData().AltSaveDirectory + " Edited!");
         AddSrv.Dispose();
     }
 }
コード例 #3
0
 private void stopToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (ServerList.FocusedItem != null)
     {
         ArkServerListViewItem ASLVI = (ArkServerListViewItem)ServerList.FocusedItem;
         ASLVI.GetServerData().StopServer();
         ASLVI.UpdateStatus();
     }
 }
コード例 #4
0
 private void startToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (ServerList.FocusedItem != null)
     {
         ArkServerListViewItem SelectedServer = ((ArkServerListViewItem)ServerList.FocusedItem);
         if (SelectedServer.GetServerData().FinalServerPath == string.Empty)
         {
             SelectedServer.GetServerData().InitStartServer(this);
         }
         bool IsServerRunning = false;
         foreach (ArkServerListViewItem ASD in ServerList.Items)
         {
             if (ASD.GetServerData().IsRunning())
             {
                 IsServerRunning = true;
             }
         }
         //Check For Updates
         SelectedServer.GetServerData().StartServer();
     }
 }
コード例 #5
0
 private void editSettingsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (ServerList.FocusedItem != null)
     {
         ArkServerListViewItem ASLVI  = ((ArkServerListViewItem)ServerList.FocusedItem);
         AddServer             AddSrv = new AddServer(ASLVI.GetServerData(), ServerPath);
         if (AddSrv.ShowDialog() == DialogResult.OK)
         {
             ASLVI.SetServerData(AddSrv.ServerData);
         }
         AddSrv.Dispose();
     }
 }
コード例 #6
0
 private void RemoveServer()
 {
     if (ServerList.FocusedItem != null && MessageBox.Show("Are you sure you want to delete ServerX:" + ((ArkServerListViewItem)ServerList.FocusedItem).GetServerData().ServerX + ", ServerY: " + ((ArkServerListViewItem)ServerList.FocusedItem).GetServerData().ServerY + ", Port: " + ((ArkServerListViewItem)ServerList.FocusedItem).GetServerData().ServerPort + "?\n Press 'Yes' To Delete!", "Delete ServerX:" + ((ArkServerListViewItem)ServerList.FocusedItem).GetServerData().ServerX + ", ServerY: " + ((ArkServerListViewItem)ServerList.FocusedItem).GetServerData().ServerY + ", Port: " + ((ArkServerListViewItem)ServerList.FocusedItem).GetServerData().ServerPort + "?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         ArkServerListViewItem ASLVI = ((ArkServerListViewItem)ServerList.FocusedItem);
         Log(ASLVI.GetServerData().AltSaveDirectory + " Removed!");
         Registry.DeleteServer(ServerList.FocusedItem.Index);
         ServerList.Items.RemoveAt(ServerList.FocusedItem.Index);
         if (ServerList.Items.Count == 0)
         {
             Worker.StopUpdating();
         }
     }
 }
コード例 #7
0
        private void SetupCallbacks()
        {
            BackupButton.Click += (e, a) => Backup.BackupConfigs(this);

            FormClosing += (e, a) =>
            {
                Worker.DestroyAll();
                Registry.SaveRegConfig(this);
            };

            checkAutoServerUpdate.CheckedChanged += (e, a) =>
            {
                if (!checkAutoServerUpdate.Checked)
                {
                    ServerUpdater.Updating = false;
                }
            };

            ServerList.MouseDoubleClick     += (e, a) => EditServer();
            ServerList.SelectedIndexChanged += (e, a) =>
            {
                if (ServerList.FocusedItem != null)
                {
                    ArkServerListViewItem ASLVI = (ArkServerListViewItem)ServerList.FocusedItem;
                    StartButton.Enabled = true;
                    if (ASLVI.GetServerData().IsRunning())
                    {
                        StartButton.BackColor = System.Drawing.Color.Red;
                        StartButton.ForeColor = System.Drawing.Color.White;
                        StartButton.Text      = "Stop";
                    }
                    else
                    {
                        StartButton.BackColor = System.Drawing.Color.Green;
                        StartButton.ForeColor = System.Drawing.Color.White;
                        StartButton.Text      = "Start";
                    }
                }
                else
                {
                    StartButton.BackColor = System.Drawing.Color.DarkGray;
                    StartButton.ForeColor = System.Drawing.Color.DimGray;
                    StartButton.Enabled   = false;
                }
            };

            StartButton.Click += (e, a) =>
            {
                if (ServerList.FocusedItem != null)
                {
                    ArkServerListViewItem ASLVI = (ArkServerListViewItem)ServerList.FocusedItem;
                    if (StartButton.Text == "Start")
                    {
                        ASLVI.GetServerData().StartServer();
                    }
                    else
                    {
                        ASLVI.GetServerData().StopServer();
                    }
                    ASLVI.UpdateStatus();
                }
            };

            addToolStripMenuItem.Click          += (e, a) => AddServer();
            removeToolStripMenuItem.Click       += (e, a) => RemoveServer();
            editSettingsToolStripMenuItem.Click += (e, a) => EditServer();

            addToolStripMenuItem1.Click          += (e, a) => AddServer();
            removeToolStripMenuItem1.Click       += (e, a) => RemoveServer();
            editSettingsToolStripMenuItem1.Click += (e, a) => EditServer();

            startToolStripMenuItem.Click += (e, a) => StartServer();
            stopToolStripMenuItem.Click  += (e, a) => StopServer();

            startToolStripMenuItem1.Click += (e, a) => StartServer();
            stopToolStripMenuItem1.Click  += (e, a) => StopServer();

            button1.Click += (e, a) =>
            {
                if (ServerUpdater.Updating)
                {
                    MessageBox.Show("Already Updating", "Update in progress", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                Log("[Atlas] Forcing Update");
                ServerUpdater.ForcedUpdate = true;
                Worker.ForceUpdaterRestart(this);
            };

            ClearConfigButton.Click += (e, a) =>
            {
                if (MessageBox.Show("Are you sure you want to erase all your configurations?", "Configuration Reset", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Registry.ClearAll();
                    ServerList.Clear();
                }
            };

            broadcastToolStripMenuItem.Click      += (e, a) => RconBroadcast(false);
            saveWorldToolStripMenuItem.Click      += (e, a) => RconSaveWorld(false);
            closeSaveWorldToolStripMenuItem.Click += (e, a) => RconCloseSaveWorld(false);
            customCommandToolStripMenuItem.Click  += (e, a) => RconCustomCommand(false);
            loadPluginToolStripMenuItem.Click     += (e, a) => RconPlugin(false, true);
            unloadPluginToolStripMenuItem.Click   += (e, a) => RconPlugin(false, false);

            broadcastToolStripMenuItem1.Click      += (e, a) => RconBroadcast(true);
            saveWorldToolStripMenuItem1.Click      += (e, a) => RconSaveWorld(true);
            closeSaveWorldToolStripMenuItem1.Click += (e, a) => RconCloseSaveWorld(true);
            customCommandToolStripMenuItem1.Click  += (e, a) => RconCustomCommand(true);
            loadPluginToolStripMenuItem1.Click     += (e, a) => RconPlugin(true, true);
            unloadPluginToolStripMenuItem1.Click   += (e, a) => RconPlugin(true, false);


            broadcastToolStripMenuItem2.Click      += (e, a) => RconBroadcast(false);
            saveWorldToolStripMenuItem2.Click      += (e, a) => RconSaveWorld(false);
            closeSaveWorldToolStripMenuItem2.Click += (e, a) => RconCloseSaveWorld(false);
            customCommandToolStripMenuItem2.Click  += (e, a) => RconCustomCommand(false);
            loadPluginToolStripMenuItem2.Click     += (e, a) => RconPlugin(false, true);
            unloadPluginToolStripMenuItem2.Click   += (e, a) => RconPlugin(false, false);

            broadcastToolStripMenuItem3.Click      += (e, a) => RconBroadcast(true);
            saveWorldToolStripMenuItem3.Click      += (e, a) => RconSaveWorld(true);
            closeSaveWorldToolStripMenuItem3.Click += (e, a) => RconCloseSaveWorld(true);
            customCommandToolStripMenuItem3.Click  += (e, a) => RconCustomCommand(true);
            loadPluginToolStripMenuItem3.Click     += (e, a) => RconPlugin(true, true);
            unloadPluginToolStripMenuItem3.Click   += (e, a) => RconPlugin(true, false);
        }
コード例 #8
0
 private void RconPlugin(bool AllServers, bool Load)
 {
     if (AllServers || ServerList.FocusedItem != null)
     {
         ArkServerListViewItem ASLVI = AllServers ? null : (ArkServerListViewItem)ServerList.FocusedItem;
         inputDialog.Text            = (Load ? "Load" : "Unload") + " Plugin to " + (AllServers ? "All" : ASLVI.GetServerData().AltSaveDirectory);
         inputDialog.SendButton.Text = (Load ? "Load" : "Unload") + " Plugin";
         if (inputDialog.ShowDialog() == DialogResult.OK)
         {
             if (AllServers)
             {
                 SourceRconTools.SendCommandToAll("plugins." + (Load ? "load " : "unload ") + inputDialog.InputText.Text);
             }
             else
             {
                 SourceRconTools.SendCommand("plugins." + (Load ? "load " : "unload ") + inputDialog.InputText.Text, ASLVI);
             }
             Log("Plugin " + (Load ? "Loaded" : "Unloaded") + ": " + inputDialog.InputText.Text);
         }
     }
 }
コード例 #9
0
 private void RconCustomCommand(bool AllServers)
 {
     if (AllServers || ServerList.FocusedItem != null)
     {
         ArkServerListViewItem ASLVI = AllServers ? null : (ArkServerListViewItem)ServerList.FocusedItem;
         inputDialog.Text            = "Send Custom Command to " + (AllServers ? "All" : ASLVI.GetServerData().AltSaveDirectory);
         inputDialog.SendButton.Text = "Send Command";
         if (inputDialog.ShowDialog() == DialogResult.OK)
         {
             if (AllServers)
             {
                 SourceRconTools.SendCommandToAll(inputDialog.InputText.Text);
             }
             else
             {
                 SourceRconTools.SendCommand(inputDialog.InputText.Text, ASLVI);
             }
             Log("Custom Command Executed: " + inputDialog.InputText.Text);
         }
     }
 }