Ejemplo n.º 1
0
 private void BtnStart_Click(object sender, EventArgs e)
 {
     btnStart.Enabled = false;
     rtbOutput.AppendText(@"Starting ASF..." + Environment.NewLine);
     if (Properties.Settings.Default.IsLocal)
     {
         _asf = new ASFProcess(rtbOutput);
         _asf.Start();
     }
     btnStop.Enabled       = true;
     btnClear.Enabled      = true;
     cbBotList.Enabled     = true;
     rtbOutput.Enabled     = true;
     btnReloadBots.Enabled = true;
     btnReloadBots.Focus();
     _asfRunning = true;
     btnASFuiSettings.Enabled = false;
     Task.Delay(1500).ContinueWith(b => GetBotList());
     tsslCommandOutput.Text = @"Started ASF server.";
 }
Ejemplo n.º 2
0
        private void BtnStart_Click(object sender, EventArgs e)
        {
            if (Properties.Settings.Default.IsLocal)
            {
                try {
                    string binary = Settings.Default.ASFBinary;
                    int    index  = binary.LastIndexOf('/');
                    if (index == -1)
                    {
                        index = binary.LastIndexOf('\\');
                    }
                    if (index != -1)
                    {
                        string message = "The following Parameter will be changed automatically. Abort to change them manually." + Environment.NewLine;
                        // not sure about if I should use \\ or /
                        string  asfJson   = binary.Substring(0, index) + "\\config\\ASF.json";
                        dynamic asfConfig = JsonConvert.DeserializeObject(File.ReadAllText(asfJson));
                        string  culture   = asfConfig.CurrentCulture;
                        bool    msg       = false;
                        if (!"en".Equals(culture))
                        {
                            message = message + "Language (CurrentCulture): is: " + asfConfig.CurrentCulture + ", will be: \"en\"" + Environment.NewLine;
                            asfConfig.CurrentCulture = "en";
                            msg = true;
                        }
                        if (asfConfig.AutoRestart == null || asfConfig.AutoRestart.Value)
                        {
                            message = message + "AutoRestart (ASFui always restart ASF): is: " + asfConfig.AutoRestart + ", will be: false" + Environment.NewLine;
                            asfConfig.AutoRestart = false;
                            msg = true;
                        }
                        if (asfConfig.SteamOwnerID == null || 0 == asfConfig.SteamOwnerID.Value)
                        {
                            // this is not yet confirmed by archi to be allowed, otherwise message here "change manually" and exit.
                            message = message + "SteamOwnerID (CHANGE THIS TO YOUR MAIN ACCOUNT ASAP!): is: " + asfConfig.SteamOwnerID + ", will be: " + ulong.MaxValue + Environment.NewLine;
                            asfConfig.SteamOwnerID = ulong.MaxValue;
                            msg = true;
                        }
                        if (msg)
                        {
                            var result = MessageBox.Show(message, @"Config needs to be changed.", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                            if (result == System.Windows.Forms.DialogResult.OK)
                            {
                                try {
                                    File.WriteAllText(asfJson, JsonConvert.SerializeObject(asfConfig, Formatting.Indented));
                                } catch (Exception ex) {
                                    MessageBox.Show("Error writing changes. Change manually and restart." + Environment.NewLine + "Exiting....");
                                    Application.Exit();
                                    return;
                                }
                            }
                            else
                            {
                                Application.Exit();
                                return;
                            }
                        }
                    }
                } catch { /*ignore */ }

                _asf = new ASFProcess(this, rtbOutput);
                _asf.Start();
            }
            else
            {
                if (!Util.CheckUrl(Properties.Settings.Default.RemoteURL))
                {
                    rtbOutput.AppendText(@"Cannot connect to remote URL " + Properties.Settings.Default.RemoteURL +
                                         @". Please check your config or run ASF in local." + Environment.NewLine);
                    return;
                }
                GetBotList();
            }
            GetFileBotList();
            btnStart.Enabled = false;
            rtbOutput.AppendText(@"Starting ASF..." + Environment.NewLine);
            btnStop.Enabled          = true;
            btnClear.Enabled         = true;
            cbBotList.Enabled        = true;
            rtbOutput.Enabled        = true;
            btnReloadBots.Enabled    = true;
            _asfRunning              = true;
            btnASFuiSettings.Enabled = false;
            Logging.Info("Server started successfully.");
        }