Files
TeslaSuite/Console/TeslaConsole.RedPlanet/RPDefaultsDialog.cs
T
CydandClaude Fable 5 80ee1d26ea Console: move DOSBox IP shift from game pages into game defaults
The per-page "DOSBox IPs (+100)" checkbox becomes a single machine-level
setting per game, edited in Settings > Change <game> Defaults (a "DOSBox
Build" row below Autotranslocate Delay) and persisted in the game's
defaults file (RPDefaults.rpd / BTDefaults.btd) as a top-level
DosBoxAddressShift element.

The game pages no longer carry the checkbox; each RPGame/BTGame reads the
stored default once at construction into a readonly field and applies it
when enabling a pod (MungaGame.DosBoxAddressShift) and when building the
mission egg (MissionAddress). Since it is read at construction, an
already-open game page keeps its shift until reopened -- consistent with
how every other game default behaves.

Verified against vPOD: enabling the DOSBox default drives a freshly
opened game page's pod connection to 127.0.0.101 and the egg to
pilot=127.0.0.101 with no per-page control; unchecking round-trips to
False in the defaults file. All 103 diff tests pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 15:33:44 -05:00

647 lines
29 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using TeslaConsole.Properties;
namespace TeslaConsole.RedPlanet;
public class RPDefaultsDialog : Form
{
private IContainer components;
private TableLayoutPanel mMainTable;
private Label label2;
private Label label3;
private Label label4;
private Label label5;
private Label label6;
private Label label7;
private Label label8;
private Label label9;
private Label label1;
private Label label10;
private ComboBox mDeathRaceScoreCompression;
private ComboBox mFootballScoreCompression;
private ComboBox mFootballPosition;
private ComboBox mDeathRaceBadge;
private ComboBox mFootballTeam;
private ComboBox mDeathRaceColor;
private ComboBox mFootballWeather;
private ComboBox mDeathRaceWeather;
private ComboBox mFootballTimeOfDay;
private ComboBox mDeathRaceTimeOfDay;
private ComboBox mDeathRaceMap;
private ComboBox mFootballMap;
private ComboBox mDeathRaceVehicle;
private ComboBox mFootballVehicle;
private TableLayoutPanel mButtonsTable;
private Button mCancel;
private Button mOK;
private MaskedTextBox mDeathRaceMissionLength;
private MaskedTextBox mFootballMissionLength;
private Label label11;
private NumericUpDown mDeathraceLaunchDelay;
private NumericUpDown mFootballLaunchDelay;
private Label mDosBoxLabel;
private CheckBox mDosBoxShift;
private static RPDefaultsDialog mSingletonDialog;
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.mMainTable = new System.Windows.Forms.TableLayoutPanel();
this.mFootballPosition = new System.Windows.Forms.ComboBox();
this.mDeathRaceBadge = new System.Windows.Forms.ComboBox();
this.mFootballTeam = new System.Windows.Forms.ComboBox();
this.mDeathRaceColor = new System.Windows.Forms.ComboBox();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.mButtonsTable = new System.Windows.Forms.TableLayoutPanel();
this.mCancel = new System.Windows.Forms.Button();
this.mOK = new System.Windows.Forms.Button();
this.label5 = new System.Windows.Forms.Label();
this.mDeathRaceVehicle = new System.Windows.Forms.ComboBox();
this.mFootballVehicle = new System.Windows.Forms.ComboBox();
this.label4 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.mDeathRaceMap = new System.Windows.Forms.ComboBox();
this.mDeathRaceTimeOfDay = new System.Windows.Forms.ComboBox();
this.mDeathRaceScoreCompression = new System.Windows.Forms.ComboBox();
this.mDeathRaceWeather = new System.Windows.Forms.ComboBox();
this.mDeathRaceMissionLength = new System.Windows.Forms.MaskedTextBox();
this.mFootballMap = new System.Windows.Forms.ComboBox();
this.mFootballTimeOfDay = new System.Windows.Forms.ComboBox();
this.mFootballScoreCompression = new System.Windows.Forms.ComboBox();
this.mFootballMissionLength = new System.Windows.Forms.MaskedTextBox();
this.mFootballWeather = new System.Windows.Forms.ComboBox();
this.label11 = new System.Windows.Forms.Label();
this.mDeathraceLaunchDelay = new System.Windows.Forms.NumericUpDown();
this.mFootballLaunchDelay = new System.Windows.Forms.NumericUpDown();
this.mDosBoxLabel = new System.Windows.Forms.Label();
this.mDosBoxShift = new System.Windows.Forms.CheckBox();
this.mMainTable.SuspendLayout();
this.mButtonsTable.SuspendLayout();
((System.ComponentModel.ISupportInitialize)this.mDeathraceLaunchDelay).BeginInit();
((System.ComponentModel.ISupportInitialize)this.mFootballLaunchDelay).BeginInit();
base.SuspendLayout();
this.mMainTable.ColumnCount = 3;
this.mMainTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.mMainTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50f));
this.mMainTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50f));
this.mMainTable.Controls.Add(this.mFootballLaunchDelay, 2, 9);
this.mMainTable.Controls.Add(this.mFootballPosition, 2, 8);
this.mMainTable.Controls.Add(this.mDeathRaceBadge, 1, 8);
this.mMainTable.Controls.Add(this.mFootballTeam, 2, 7);
this.mMainTable.Controls.Add(this.mDeathRaceColor, 1, 7);
this.mMainTable.Controls.Add(this.label8, 0, 7);
this.mMainTable.Controls.Add(this.label9, 0, 8);
this.mMainTable.Controls.Add(this.label1, 1, 0);
this.mMainTable.Controls.Add(this.label10, 2, 0);
this.mMainTable.Controls.Add(this.mButtonsTable, 0, 11);
this.mMainTable.Controls.Add(this.label5, 0, 6);
this.mMainTable.Controls.Add(this.mDeathRaceVehicle, 1, 6);
this.mMainTable.Controls.Add(this.mFootballVehicle, 2, 6);
this.mMainTable.Controls.Add(this.label4, 0, 1);
this.mMainTable.Controls.Add(this.label7, 0, 2);
this.mMainTable.Controls.Add(this.label2, 0, 4);
this.mMainTable.Controls.Add(this.label6, 0, 3);
this.mMainTable.Controls.Add(this.label3, 0, 5);
this.mMainTable.Controls.Add(this.mDeathRaceMap, 1, 1);
this.mMainTable.Controls.Add(this.mDeathRaceTimeOfDay, 1, 3);
this.mMainTable.Controls.Add(this.mDeathRaceScoreCompression, 1, 4);
this.mMainTable.Controls.Add(this.mDeathRaceWeather, 1, 2);
this.mMainTable.Controls.Add(this.mDeathRaceMissionLength, 1, 5);
this.mMainTable.Controls.Add(this.mFootballMap, 2, 1);
this.mMainTable.Controls.Add(this.mFootballTimeOfDay, 2, 3);
this.mMainTable.Controls.Add(this.mFootballScoreCompression, 2, 4);
this.mMainTable.Controls.Add(this.mFootballMissionLength, 2, 5);
this.mMainTable.Controls.Add(this.mFootballWeather, 2, 2);
this.mMainTable.Controls.Add(this.label11, 0, 9);
this.mMainTable.Controls.Add(this.mDeathraceLaunchDelay, 1, 9);
this.mMainTable.Controls.Add(this.mDosBoxLabel, 0, 10);
this.mMainTable.Controls.Add(this.mDosBoxShift, 1, 10);
this.mMainTable.Dock = System.Windows.Forms.DockStyle.Fill;
this.mMainTable.Location = new System.Drawing.Point(3, 3);
this.mMainTable.Name = "mMainTable";
this.mMainTable.RowCount = 12;
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100f));
this.mMainTable.Size = new System.Drawing.Size(478, 328);
this.mMainTable.TabIndex = 0;
this.mFootballPosition.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.mFootballPosition.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.mFootballPosition.FormattingEnabled = true;
this.mFootballPosition.Location = new System.Drawing.Point(302, 204);
this.mFootballPosition.Name = "mFootballPosition";
this.mFootballPosition.Size = new System.Drawing.Size(173, 21);
this.mFootballPosition.TabIndex = 15;
this.mDeathRaceBadge.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.mDeathRaceBadge.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.mDeathRaceBadge.FormattingEnabled = true;
this.mDeathRaceBadge.Location = new System.Drawing.Point(123, 204);
this.mDeathRaceBadge.Name = "mDeathRaceBadge";
this.mDeathRaceBadge.Size = new System.Drawing.Size(173, 21);
this.mDeathRaceBadge.TabIndex = 14;
this.mFootballTeam.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.mFootballTeam.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.mFootballTeam.FormattingEnabled = true;
this.mFootballTeam.Location = new System.Drawing.Point(302, 177);
this.mFootballTeam.Name = "mFootballTeam";
this.mFootballTeam.Size = new System.Drawing.Size(173, 21);
this.mFootballTeam.TabIndex = 13;
this.mDeathRaceColor.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.mDeathRaceColor.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.mDeathRaceColor.FormattingEnabled = true;
this.mDeathRaceColor.Location = new System.Drawing.Point(123, 177);
this.mDeathRaceColor.Name = "mDeathRaceColor";
this.mDeathRaceColor.Size = new System.Drawing.Size(173, 21);
this.mDeathRaceColor.TabIndex = 12;
this.label8.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(51, 181);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(66, 13);
this.label8.TabIndex = 7;
this.label8.Text = "Color/Team:";
this.label9.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(34, 208);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(83, 13);
this.label9.TabIndex = 8;
this.label9.Text = "Badge/Position:";
this.label1.Anchor = System.Windows.Forms.AnchorStyles.None;
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(177, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(65, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Death Race";
this.label10.Anchor = System.Windows.Forms.AnchorStyles.None;
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(366, 0);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(44, 13);
this.label10.TabIndex = 9;
this.label10.Text = "Football";
this.mButtonsTable.ColumnCount = 2;
this.mMainTable.SetColumnSpan(this.mButtonsTable, 3);
this.mButtonsTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100f));
this.mButtonsTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.mButtonsTable.Controls.Add(this.mCancel, 1, 0);
this.mButtonsTable.Controls.Add(this.mOK, 0, 0);
this.mButtonsTable.Dock = System.Windows.Forms.DockStyle.Fill;
this.mButtonsTable.Location = new System.Drawing.Point(0, 254);
this.mButtonsTable.Margin = new System.Windows.Forms.Padding(0);
this.mButtonsTable.Name = "mButtonsTable";
this.mButtonsTable.RowCount = 1;
this.mButtonsTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100f));
this.mButtonsTable.Size = new System.Drawing.Size(478, 44);
this.mButtonsTable.TabIndex = 27;
this.mCancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
this.mCancel.Location = new System.Drawing.Point(400, 19);
this.mCancel.Name = "mCancel";
this.mCancel.Size = new System.Drawing.Size(75, 22);
this.mCancel.TabIndex = 1;
this.mCancel.Text = "&Cancel";
this.mCancel.UseVisualStyleBackColor = true;
this.mCancel.Click += new System.EventHandler(mCancel_Click);
this.mOK.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
this.mOK.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.mOK.Location = new System.Drawing.Point(319, 19);
this.mOK.Name = "mOK";
this.mOK.Size = new System.Drawing.Size(75, 22);
this.mOK.TabIndex = 0;
this.mOK.Text = "&OK";
this.mOK.UseVisualStyleBackColor = true;
this.mOK.Click += new System.EventHandler(mOK_Click);
this.label5.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(72, 154);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(45, 13);
this.label5.TabIndex = 4;
this.label5.Text = "Vehicle:";
this.mDeathRaceVehicle.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.mDeathRaceVehicle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.mDeathRaceVehicle.FormattingEnabled = true;
this.mDeathRaceVehicle.Location = new System.Drawing.Point(123, 150);
this.mDeathRaceVehicle.Name = "mDeathRaceVehicle";
this.mDeathRaceVehicle.Size = new System.Drawing.Size(173, 21);
this.mDeathRaceVehicle.TabIndex = 10;
this.mFootballVehicle.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.mFootballVehicle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.mFootballVehicle.FormattingEnabled = true;
this.mFootballVehicle.Location = new System.Drawing.Point(302, 150);
this.mFootballVehicle.Name = "mFootballVehicle";
this.mFootballVehicle.Size = new System.Drawing.Size(173, 21);
this.mFootballVehicle.TabIndex = 11;
this.label4.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(86, 20);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(31, 13);
this.label4.TabIndex = 3;
this.label4.Text = "Map:";
this.label7.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(66, 47);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(51, 13);
this.label7.TabIndex = 6;
this.label7.Text = "Weather:";
this.label2.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(16, 101);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(101, 13);
this.label2.TabIndex = 1;
this.label2.Text = "Score Compression:";
this.label6.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(48, 74);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(69, 13);
this.label6.TabIndex = 5;
this.label6.Text = "Time Of Day:";
this.label3.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(36, 127);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(81, 13);
this.label3.TabIndex = 2;
this.label3.Text = "Mission Length:";
this.mDeathRaceMap.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.mDeathRaceMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.mDeathRaceMap.FormattingEnabled = true;
this.mDeathRaceMap.Location = new System.Drawing.Point(123, 16);
this.mDeathRaceMap.Name = "mDeathRaceMap";
this.mDeathRaceMap.Size = new System.Drawing.Size(173, 21);
this.mDeathRaceMap.TabIndex = 0;
this.mDeathRaceTimeOfDay.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.mDeathRaceTimeOfDay.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.mDeathRaceTimeOfDay.FormattingEnabled = true;
this.mDeathRaceTimeOfDay.Location = new System.Drawing.Point(123, 70);
this.mDeathRaceTimeOfDay.Name = "mDeathRaceTimeOfDay";
this.mDeathRaceTimeOfDay.Size = new System.Drawing.Size(173, 21);
this.mDeathRaceTimeOfDay.TabIndex = 4;
this.mDeathRaceScoreCompression.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.mDeathRaceScoreCompression.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.mDeathRaceScoreCompression.FormattingEnabled = true;
this.mDeathRaceScoreCompression.Location = new System.Drawing.Point(123, 97);
this.mDeathRaceScoreCompression.Name = "mDeathRaceScoreCompression";
this.mDeathRaceScoreCompression.Size = new System.Drawing.Size(173, 21);
this.mDeathRaceScoreCompression.TabIndex = 6;
this.mDeathRaceWeather.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.mDeathRaceWeather.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.mDeathRaceWeather.FormattingEnabled = true;
this.mDeathRaceWeather.Location = new System.Drawing.Point(123, 43);
this.mDeathRaceWeather.Name = "mDeathRaceWeather";
this.mDeathRaceWeather.Size = new System.Drawing.Size(173, 21);
this.mDeathRaceWeather.TabIndex = 2;
this.mDeathRaceMissionLength.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.mDeathRaceMissionLength.Location = new System.Drawing.Point(123, 124);
this.mDeathRaceMissionLength.Name = "mDeathRaceMissionLength";
this.mDeathRaceMissionLength.Size = new System.Drawing.Size(173, 20);
this.mDeathRaceMissionLength.TabIndex = 8;
this.mFootballMap.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.mFootballMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.mFootballMap.FormattingEnabled = true;
this.mFootballMap.Location = new System.Drawing.Point(302, 16);
this.mFootballMap.Name = "mFootballMap";
this.mFootballMap.Size = new System.Drawing.Size(173, 21);
this.mFootballMap.TabIndex = 1;
this.mFootballTimeOfDay.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.mFootballTimeOfDay.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.mFootballTimeOfDay.FormattingEnabled = true;
this.mFootballTimeOfDay.Location = new System.Drawing.Point(302, 70);
this.mFootballTimeOfDay.Name = "mFootballTimeOfDay";
this.mFootballTimeOfDay.Size = new System.Drawing.Size(173, 21);
this.mFootballTimeOfDay.TabIndex = 5;
this.mFootballScoreCompression.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.mFootballScoreCompression.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.mFootballScoreCompression.FormattingEnabled = true;
this.mFootballScoreCompression.Location = new System.Drawing.Point(302, 97);
this.mFootballScoreCompression.Name = "mFootballScoreCompression";
this.mFootballScoreCompression.Size = new System.Drawing.Size(173, 21);
this.mFootballScoreCompression.TabIndex = 7;
this.mFootballMissionLength.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.mFootballMissionLength.Location = new System.Drawing.Point(302, 124);
this.mFootballMissionLength.Name = "mFootballMissionLength";
this.mFootballMissionLength.Size = new System.Drawing.Size(173, 20);
this.mFootballMissionLength.TabIndex = 9;
this.mFootballWeather.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.mFootballWeather.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.mFootballWeather.FormattingEnabled = true;
this.mFootballWeather.Location = new System.Drawing.Point(302, 43);
this.mFootballWeather.Name = "mFootballWeather";
this.mFootballWeather.Size = new System.Drawing.Size(173, 21);
this.mFootballWeather.TabIndex = 3;
this.label11.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(3, 228);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(114, 26);
this.label11.TabIndex = 28;
this.label11.Text = "Autotranslocate Delay:";
this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.mDeathraceLaunchDelay.Dock = System.Windows.Forms.DockStyle.Fill;
this.mDeathraceLaunchDelay.Location = new System.Drawing.Point(123, 231);
this.mDeathraceLaunchDelay.Name = "mDeathraceLaunchDelay";
this.mDeathraceLaunchDelay.Size = new System.Drawing.Size(173, 20);
this.mDeathraceLaunchDelay.TabIndex = 31;
this.mFootballLaunchDelay.Dock = System.Windows.Forms.DockStyle.Fill;
this.mFootballLaunchDelay.Location = new System.Drawing.Point(302, 231);
this.mFootballLaunchDelay.Name = "mFootballLaunchDelay";
this.mFootballLaunchDelay.Size = new System.Drawing.Size(173, 20);
this.mFootballLaunchDelay.TabIndex = 32;
this.mDosBoxLabel.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.mDosBoxLabel.AutoSize = true;
this.mDosBoxLabel.Location = new System.Drawing.Point(35, 258);
this.mDosBoxLabel.Name = "mDosBoxLabel";
this.mDosBoxLabel.Size = new System.Drawing.Size(82, 13);
this.mDosBoxLabel.TabIndex = 29;
this.mDosBoxLabel.Text = "DOSBox Build:";
this.mMainTable.SetColumnSpan(this.mDosBoxShift, 2);
this.mDosBoxShift.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.mDosBoxShift.AutoSize = true;
this.mDosBoxShift.Location = new System.Drawing.Point(123, 256);
this.mDosBoxShift.Name = "mDosBoxShift";
this.mDosBoxShift.Size = new System.Drawing.Size(268, 17);
this.mDosBoxShift.TabIndex = 33;
this.mDosBoxShift.Text = "Shift all pod IPs +100 (DOSBox-X preservation build)";
this.mDosBoxShift.UseVisualStyleBackColor = true;
base.AcceptButton = this.mOK;
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
base.ClientSize = new System.Drawing.Size(484, 334);
base.Controls.Add(this.mMainTable);
base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
base.MaximizeBox = false;
base.Name = "RPDefaultsDialog";
base.Padding = new System.Windows.Forms.Padding(3);
this.Text = "Red Planet Defaults";
this.mMainTable.ResumeLayout(false);
this.mMainTable.PerformLayout();
this.mButtonsTable.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)this.mDeathraceLaunchDelay).EndInit();
((System.ComponentModel.ISupportInitialize)this.mFootballLaunchDelay).EndInit();
base.ResumeLayout(false);
}
public static void ShowSingleton()
{
if (mSingletonDialog == null || mSingletonDialog.IsDisposed)
{
mSingletonDialog = new RPDefaultsDialog();
}
mSingletonDialog.Show();
mSingletonDialog.Focus();
mSingletonDialog.WindowState = FormWindowState.Normal;
}
private RPDefaultsDialog()
{
InitializeComponent();
base.Icon = Resources.swirl;
BuildScoreCompressionOptions(mDeathRaceScoreCompression, RPDefaults.DeathRace.ScoreCompression);
BuildScoreCompressionOptions(mFootballScoreCompression, RPDefaults.Football.ScoreCompression);
BuildMissionLengthControl(mDeathRaceMissionLength, RPDefaults.DeathRace.MissionLength);
BuildMissionLengthControl(mFootballMissionLength, RPDefaults.Football.MissionLength);
BuildMapOption(mDeathRaceMap, RPConfig.DeathRace.Maps, RPDefaults.DeathRace.MapKey);
BuildMapOption(mFootballMap, RPConfig.Football.Maps, RPDefaults.Football.MapKey);
BuildGenericOption(mDeathRaceTimeOfDay, RPConfig.DeathRace.TimesOfDay, RPDefaults.DeathRace.TimeOfDayKey);
BuildGenericOption(mFootballTimeOfDay, RPConfig.Football.TimesOfDay, RPDefaults.Football.TimeOfDayKey);
BuildGenericOption(mDeathRaceWeather, RPConfig.DeathRace.Weather, RPDefaults.DeathRace.WeatherKey);
BuildGenericOption(mFootballWeather, RPConfig.Football.Weather, RPDefaults.Football.WeatherKey);
BuildVehicleOption(mDeathRaceVehicle, RPConfig.DeathRace.Vehicles, RPDefaults.DeathRace.VehicleKey);
BuildVehicleOption(mFootballVehicle, RPConfig.Football.Vehicles, RPDefaults.Football.VehicleKey);
BuildGenericOption(mDeathRaceColor, RPConfig.DeathRace.Colors, RPDefaults.DeathRace.ColorKey);
BuildTeamOption(mFootballTeam, RPConfig.Football.Teams, RPDefaults.Football.TeamKey);
BuildGenericOption(mDeathRaceBadge, RPConfig.DeathRace.Badges, RPDefaults.DeathRace.BadgeKey);
BuildGenericOption(mFootballPosition, RPConfig.Football.Positions, RPDefaults.Football.PositionKey);
BuildDelayControl(mDeathraceLaunchDelay, RPDefaults.DeathRace.LaunchDelay);
BuildDelayControl(mFootballLaunchDelay, RPDefaults.Football.LaunchDelay);
mDosBoxShift.Checked = RPDefaults.DosBoxAddressShift;
}
private static void BuildScoreCompressionOptions(ComboBox comboBox, bool defaultValue)
{
comboBox.DisplayMember = "Value";
comboBox.ValueMember = "Key";
comboBox.Items.Add(new KeyValuePair<bool, string>(key: false, "Off"));
comboBox.Items.Add(new KeyValuePair<bool, string>(key: true, "On"));
comboBox.SelectedIndex = (defaultValue ? 1 : 0);
}
private static void BuildMissionLengthControl(MaskedTextBox maskedTextBox, TimeSpan defaultValue)
{
maskedTextBox.Mask = "00:00:00";
maskedTextBox.ValidatingType = typeof(TimeSpan);
maskedTextBox.Text = defaultValue.ToString();
}
private static void BuildDelayControl(NumericUpDown maskedTextBox, int defaultValue)
{
maskedTextBox.Value = defaultValue;
}
private static void BuildMapOption(ComboBox comboBox, IEnumerable<KeyValuePair<string, RPMap>> options, string defaultKey)
{
int selectedIndex = 0;
int num = 0;
comboBox.DisplayMember = "Name";
comboBox.ValueMember = "Key";
foreach (KeyValuePair<string, RPMap> option in options)
{
comboBox.Items.Add(option.Value);
if (option.Key == defaultKey)
{
selectedIndex = num;
}
num++;
}
comboBox.SelectedIndex = selectedIndex;
}
private static void BuildVehicleOption(ComboBox comboBox, IEnumerable<KeyValuePair<string, RPVehicle>> options, string defaultKey)
{
int selectedIndex = 0;
int num = 0;
comboBox.DisplayMember = "Name";
comboBox.ValueMember = "Key";
foreach (KeyValuePair<string, RPVehicle> option in options)
{
comboBox.Items.Add(option.Value);
if (option.Key == defaultKey)
{
selectedIndex = num;
}
num++;
}
comboBox.SelectedIndex = selectedIndex;
}
private static void BuildTeamOption(ComboBox comboBox, IEnumerable<KeyValuePair<string, RPTeam>> options, string defaultKey)
{
int selectedIndex = 0;
int num = 0;
comboBox.DisplayMember = "Name";
comboBox.ValueMember = "Key";
foreach (KeyValuePair<string, RPTeam> option in options)
{
comboBox.Items.Add(option.Value);
if (option.Key == defaultKey)
{
selectedIndex = num;
}
num++;
}
comboBox.SelectedIndex = selectedIndex;
}
private static void BuildGenericOption(ComboBox comboBox, IEnumerable<KeyValuePair<string, string>> options, string defaultKey)
{
int selectedIndex = 0;
int num = 0;
comboBox.DisplayMember = "Value";
comboBox.ValueMember = "Key";
foreach (KeyValuePair<string, string> option in options)
{
comboBox.Items.Add(option);
if (option.Key == defaultKey)
{
selectedIndex = num;
}
num++;
}
comboBox.SelectedIndex = selectedIndex;
}
private void mCancel_Click(object sender, EventArgs e)
{
Close();
}
private void mOK_Click(object sender, EventArgs e)
{
RPDefaults.DeathRace.ScoreCompression = ExtractSelectedKey<bool>(mDeathRaceScoreCompression);
RPDefaults.Football.ScoreCompression = ExtractSelectedKey<bool>(mFootballScoreCompression);
RPDefaults.DeathRace.MissionLength = (TimeSpan)mDeathRaceMissionLength.ValidateText();
RPDefaults.Football.MissionLength = (TimeSpan)mFootballMissionLength.ValidateText();
RPDefaults.DeathRace.MapKey = ExtractSelectedMapKey(mDeathRaceMap);
RPDefaults.Football.MapKey = ExtractSelectedMapKey(mFootballMap);
RPDefaults.DeathRace.TimeOfDayKey = ExtractSelectedKey<string>(mDeathRaceTimeOfDay);
RPDefaults.Football.TimeOfDayKey = ExtractSelectedKey<string>(mFootballTimeOfDay);
RPDefaults.DeathRace.WeatherKey = ExtractSelectedKey<string>(mDeathRaceWeather);
RPDefaults.Football.WeatherKey = ExtractSelectedKey<string>(mFootballWeather);
RPDefaults.DeathRace.VehicleKey = ExtractVehicleKey(mDeathRaceVehicle);
RPDefaults.Football.VehicleKey = ExtractVehicleKey(mFootballVehicle);
RPDefaults.DeathRace.ColorKey = ExtractSelectedKey<string>(mDeathRaceColor);
RPDefaults.Football.TeamKey = ExtractTeamKey(mFootballTeam);
RPDefaults.DeathRace.BadgeKey = ExtractSelectedKey<string>(mDeathRaceBadge);
RPDefaults.Football.PositionKey = ExtractSelectedKey<string>(mFootballPosition);
RPDefaults.DeathRace.LaunchDelay = (int)mDeathraceLaunchDelay.Value;
RPDefaults.Football.LaunchDelay = (int)mFootballLaunchDelay.Value;
RPDefaults.DosBoxAddressShift = mDosBoxShift.Checked;
RPDefaults.Save();
Hide();
}
private static T ExtractSelectedKey<T>(ComboBox comboBox)
{
if (comboBox.SelectedItem is KeyValuePair<T, string>)
{
return ((KeyValuePair<T, string>)comboBox.SelectedItem).Key;
}
return (T)comboBox.SelectedItem;
}
private static string ExtractSelectedMapKey(ComboBox comboBox)
{
if (comboBox.SelectedItem is RPMap)
{
return ((RPMap)comboBox.SelectedItem).Key;
}
return (string)comboBox.SelectedItem;
}
private static string ExtractVehicleKey(ComboBox comboBox)
{
if (comboBox.SelectedItem is RPVehicle)
{
return ((RPVehicle)comboBox.SelectedItem).Key;
}
return (string)comboBox.SelectedItem;
}
private static string ExtractTeamKey(ComboBox comboBox)
{
if (comboBox.SelectedItem is RPTeam)
{
return ((RPTeam)comboBox.SelectedItem).Key;
}
return (string)comboBox.SelectedItem;
}
}