diff --git a/SoFii/MainWindow.Designer.cs b/SoFii/MainWindow.Designer.cs index eff5954..f55277f 100644 --- a/SoFii/MainWindow.Designer.cs +++ b/SoFii/MainWindow.Designer.cs @@ -31,6 +31,7 @@ namespace SoFii { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow)); this.serverBox = new System.Windows.Forms.GroupBox(); + this.serverUseCustom = new System.Windows.Forms.CheckBox(); this.serverAddressLabel = new System.Windows.Forms.Label(); this.serverAddressInput = new System.Windows.Forms.TextBox(); this.serverResetButton = new System.Windows.Forms.Button(); @@ -41,28 +42,27 @@ namespace SoFii this.gameBrowseButton = new System.Windows.Forms.Button(); this.mainTabs = new System.Windows.Forms.TabControl(); this.locationsTabPage = new System.Windows.Forms.TabPage(); - this.versionLabel = new System.Windows.Forms.Label(); - this.mainOpenFileDiag = new System.Windows.Forms.OpenFileDialog(); - this.serverUseCustom = new System.Windows.Forms.CheckBox(); this.playerTabPage = new System.Windows.Forms.TabPage(); - this.playerNameBox = new System.Windows.Forms.GroupBox(); - this.playerNameLabel = new System.Windows.Forms.Label(); - this.playerNameInput = new System.Windows.Forms.TextBox(); - this.playerNameColoursBox = new System.Windows.Forms.GroupBox(); - this.playerNameColourButton = new System.Windows.Forms.Button(); - this.playerNamePreview = new System.Windows.Forms.Panel(); this.gfxBox = new System.Windows.Forms.GroupBox(); - this.gfxFullscreen = new System.Windows.Forms.CheckBox(); this.gfxResolutionLabel = new System.Windows.Forms.Label(); this.gfxResolutionSelect = new System.Windows.Forms.ComboBox(); + this.gfxFullscreen = new System.Windows.Forms.CheckBox(); + this.playerNameBox = new System.Windows.Forms.GroupBox(); + this.playerNamePreview = new System.Windows.Forms.Panel(); + this.playerNameColoursBox = new System.Windows.Forms.GroupBox(); + this.playerNameColourButton = new System.Windows.Forms.Button(); + this.playerNameLabel = new System.Windows.Forms.Label(); + this.playerNameInput = new System.Windows.Forms.TextBox(); + this.versionLabel = new System.Windows.Forms.Label(); + this.mainOpenFileDiag = new System.Windows.Forms.OpenFileDialog(); this.serverBox.SuspendLayout(); this.gameBox.SuspendLayout(); this.mainTabs.SuspendLayout(); this.locationsTabPage.SuspendLayout(); this.playerTabPage.SuspendLayout(); + this.gfxBox.SuspendLayout(); this.playerNameBox.SuspendLayout(); this.playerNameColoursBox.SuspendLayout(); - this.gfxBox.SuspendLayout(); this.SuspendLayout(); // // serverBox @@ -80,6 +80,17 @@ namespace SoFii this.serverBox.TabStop = false; this.serverBox.Text = "Server"; // + // serverUseCustom + // + this.serverUseCustom.AutoSize = true; + this.serverUseCustom.Location = new System.Drawing.Point(87, 47); + this.serverUseCustom.Name = "serverUseCustom"; + this.serverUseCustom.Size = new System.Drawing.Size(154, 17); + this.serverUseCustom.TabIndex = 304; + this.serverUseCustom.Text = "Use custom server address"; + this.serverUseCustom.UseVisualStyleBackColor = true; + this.serverUseCustom.CheckedChanged += new System.EventHandler(this.serverUseCustom_CheckedChanged); + // // serverAddressLabel // this.serverAddressLabel.AutoSize = true; @@ -181,6 +192,7 @@ namespace SoFii // // locationsTabPage // + this.locationsTabPage.AutoScroll = true; this.locationsTabPage.Controls.Add(this.gameBox); this.locationsTabPage.Controls.Add(this.serverBox); this.locationsTabPage.Location = new System.Drawing.Point(4, 22); @@ -191,36 +203,9 @@ namespace SoFii this.locationsTabPage.Text = "Locations"; this.locationsTabPage.UseVisualStyleBackColor = true; // - // versionLabel - // - this.versionLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.versionLabel.AutoSize = true; - this.versionLabel.ForeColor = System.Drawing.SystemColors.GrayText; - this.versionLabel.Location = new System.Drawing.Point(13, 533); - this.versionLabel.Name = "versionLabel"; - this.versionLabel.Size = new System.Drawing.Size(117, 13); - this.versionLabel.TabIndex = 13; - this.versionLabel.Text = "SoFii version goes here"; - // - // mainOpenFileDiag - // - this.mainOpenFileDiag.DefaultExt = "exe"; - this.mainOpenFileDiag.Filter = "SoF2 Multiplayer Executable|SoF2MP.exe"; - this.mainOpenFileDiag.RestoreDirectory = true; - // - // serverUseCustom - // - this.serverUseCustom.AutoSize = true; - this.serverUseCustom.Location = new System.Drawing.Point(87, 47); - this.serverUseCustom.Name = "serverUseCustom"; - this.serverUseCustom.Size = new System.Drawing.Size(154, 17); - this.serverUseCustom.TabIndex = 304; - this.serverUseCustom.Text = "Use custom server address"; - this.serverUseCustom.UseVisualStyleBackColor = true; - this.serverUseCustom.CheckedChanged += new System.EventHandler(this.serverUseCustom_CheckedChanged); - // // playerTabPage // + this.playerTabPage.AutoScroll = true; this.playerTabPage.Controls.Add(this.gfxBox); this.playerTabPage.Controls.Add(this.playerNameBox); this.playerTabPage.Location = new System.Drawing.Point(4, 22); @@ -231,6 +216,50 @@ namespace SoFii this.playerTabPage.Text = "Settings"; this.playerTabPage.UseVisualStyleBackColor = true; // + // gfxBox + // + this.gfxBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.gfxBox.Controls.Add(this.gfxResolutionLabel); + this.gfxBox.Controls.Add(this.gfxResolutionSelect); + this.gfxBox.Controls.Add(this.gfxFullscreen); + this.gfxBox.Location = new System.Drawing.Point(6, 372); + this.gfxBox.Name = "gfxBox"; + this.gfxBox.Size = new System.Drawing.Size(540, 72); + this.gfxBox.TabIndex = 500; + this.gfxBox.TabStop = false; + this.gfxBox.Text = "Graphics"; + // + // gfxResolutionLabel + // + this.gfxResolutionLabel.AutoSize = true; + this.gfxResolutionLabel.Location = new System.Drawing.Point(24, 22); + this.gfxResolutionLabel.Name = "gfxResolutionLabel"; + this.gfxResolutionLabel.Size = new System.Drawing.Size(57, 13); + this.gfxResolutionLabel.TabIndex = 502; + this.gfxResolutionLabel.Text = "Resolution"; + // + // gfxResolutionSelect + // + this.gfxResolutionSelect.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.gfxResolutionSelect.FormattingEnabled = true; + this.gfxResolutionSelect.Location = new System.Drawing.Point(87, 19); + this.gfxResolutionSelect.Name = "gfxResolutionSelect"; + this.gfxResolutionSelect.Size = new System.Drawing.Size(360, 21); + this.gfxResolutionSelect.TabIndex = 503; + this.gfxResolutionSelect.SelectedIndexChanged += new System.EventHandler(this.gfxResolutionSelect_SelectedIndexChanged); + // + // gfxFullscreen + // + this.gfxFullscreen.AutoSize = true; + this.gfxFullscreen.Location = new System.Drawing.Point(87, 46); + this.gfxFullscreen.Name = "gfxFullscreen"; + this.gfxFullscreen.Size = new System.Drawing.Size(74, 17); + this.gfxFullscreen.TabIndex = 501; + this.gfxFullscreen.Text = "Fullscreen"; + this.gfxFullscreen.UseVisualStyleBackColor = true; + this.gfxFullscreen.CheckedChanged += new System.EventHandler(this.gfxFullscreen_CheckedChanged); + // // playerNameBox // this.playerNameBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -246,24 +275,13 @@ namespace SoFii this.playerNameBox.TabStop = false; this.playerNameBox.Text = "Player Name"; // - // playerNameLabel + // playerNamePreview // - this.playerNameLabel.AutoSize = true; - this.playerNameLabel.Location = new System.Drawing.Point(46, 23); - this.playerNameLabel.Name = "playerNameLabel"; - this.playerNameLabel.Size = new System.Drawing.Size(35, 13); - this.playerNameLabel.TabIndex = 401; - this.playerNameLabel.Text = "Name"; - // - // playerNameInput - // - this.playerNameInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.playerNameInput.Location = new System.Drawing.Point(87, 20); - this.playerNameInput.Name = "playerNameInput"; - this.playerNameInput.Size = new System.Drawing.Size(360, 20); - this.playerNameInput.TabIndex = 402; - this.playerNameInput.TextChanged += new System.EventHandler(this.playerNameInput_TextChanged); + this.playerNamePreview.Location = new System.Drawing.Point(87, 46); + this.playerNamePreview.Name = "playerNamePreview"; + this.playerNamePreview.Size = new System.Drawing.Size(360, 18); + this.playerNamePreview.TabIndex = 410; + this.playerNamePreview.Paint += new System.Windows.Forms.PaintEventHandler(this.playerNamePreview_Paint); // // playerNameColoursBox // @@ -288,56 +306,41 @@ namespace SoFii this.playerNameColourButton.TextAlign = System.Drawing.ContentAlignment.BottomRight; this.playerNameColourButton.UseVisualStyleBackColor = true; // - // playerNamePreview + // playerNameLabel // - this.playerNamePreview.Location = new System.Drawing.Point(87, 46); - this.playerNamePreview.Name = "playerNamePreview"; - this.playerNamePreview.Size = new System.Drawing.Size(360, 18); - this.playerNamePreview.TabIndex = 410; + this.playerNameLabel.AutoSize = true; + this.playerNameLabel.Location = new System.Drawing.Point(46, 23); + this.playerNameLabel.Name = "playerNameLabel"; + this.playerNameLabel.Size = new System.Drawing.Size(35, 13); + this.playerNameLabel.TabIndex = 401; + this.playerNameLabel.Text = "Name"; // - // gfxBox + // playerNameInput // - this.gfxBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.playerNameInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.gfxBox.Controls.Add(this.gfxResolutionLabel); - this.gfxBox.Controls.Add(this.gfxResolutionSelect); - this.gfxBox.Controls.Add(this.gfxFullscreen); - this.gfxBox.Location = new System.Drawing.Point(6, 372); - this.gfxBox.Name = "gfxBox"; - this.gfxBox.Size = new System.Drawing.Size(540, 72); - this.gfxBox.TabIndex = 500; - this.gfxBox.TabStop = false; - this.gfxBox.Text = "Graphics"; + this.playerNameInput.Location = new System.Drawing.Point(87, 20); + this.playerNameInput.Name = "playerNameInput"; + this.playerNameInput.Size = new System.Drawing.Size(360, 20); + this.playerNameInput.TabIndex = 402; + this.playerNameInput.TextChanged += new System.EventHandler(this.playerNameInput_TextChanged); // - // gfxFullscreen + // versionLabel // - this.gfxFullscreen.AutoSize = true; - this.gfxFullscreen.Location = new System.Drawing.Point(87, 46); - this.gfxFullscreen.Name = "gfxFullscreen"; - this.gfxFullscreen.Size = new System.Drawing.Size(74, 17); - this.gfxFullscreen.TabIndex = 501; - this.gfxFullscreen.Text = "Fullscreen"; - this.gfxFullscreen.UseVisualStyleBackColor = true; - this.gfxFullscreen.CheckedChanged += new System.EventHandler(this.gfxFullscreen_CheckedChanged); + this.versionLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.versionLabel.AutoSize = true; + this.versionLabel.ForeColor = System.Drawing.SystemColors.GrayText; + this.versionLabel.Location = new System.Drawing.Point(13, 533); + this.versionLabel.Name = "versionLabel"; + this.versionLabel.Size = new System.Drawing.Size(117, 13); + this.versionLabel.TabIndex = 13; + this.versionLabel.Text = "SoFii version goes here"; // - // gfxResolutionLabel + // mainOpenFileDiag // - this.gfxResolutionLabel.AutoSize = true; - this.gfxResolutionLabel.Location = new System.Drawing.Point(24, 22); - this.gfxResolutionLabel.Name = "gfxResolutionLabel"; - this.gfxResolutionLabel.Size = new System.Drawing.Size(57, 13); - this.gfxResolutionLabel.TabIndex = 502; - this.gfxResolutionLabel.Text = "Resolution"; - // - // gfxResolutionSelect - // - this.gfxResolutionSelect.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.gfxResolutionSelect.FormattingEnabled = true; - this.gfxResolutionSelect.Location = new System.Drawing.Point(87, 19); - this.gfxResolutionSelect.Name = "gfxResolutionSelect"; - this.gfxResolutionSelect.Size = new System.Drawing.Size(360, 21); - this.gfxResolutionSelect.TabIndex = 503; - this.gfxResolutionSelect.SelectedIndexChanged += new System.EventHandler(this.gfxResolutionSelect_SelectedIndexChanged); + this.mainOpenFileDiag.DefaultExt = "exe"; + this.mainOpenFileDiag.Filter = "SoF2 Multiplayer Executable|SoF2MP.exe"; + this.mainOpenFileDiag.RestoreDirectory = true; // // MainWindow // @@ -360,11 +363,11 @@ namespace SoFii this.mainTabs.ResumeLayout(false); this.locationsTabPage.ResumeLayout(false); this.playerTabPage.ResumeLayout(false); + this.gfxBox.ResumeLayout(false); + this.gfxBox.PerformLayout(); this.playerNameBox.ResumeLayout(false); this.playerNameBox.PerformLayout(); this.playerNameColoursBox.ResumeLayout(false); - this.gfxBox.ResumeLayout(false); - this.gfxBox.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/SoFii/MainWindow.cs b/SoFii/MainWindow.cs index 7540ffd..2adf65e 100644 --- a/SoFii/MainWindow.cs +++ b/SoFii/MainWindow.cs @@ -39,7 +39,6 @@ namespace SoFii { DrawPlayerNameColourButtons(); playerNameInput.Text = Settings.PlayerName; - DrawPlayerNamePreview(); gfxResolutionSelect.Items.AddRange(new object[] { string.Empty, @@ -392,7 +391,11 @@ namespace SoFii { ResizeToFit(); } - public void DrawPlayerNamePreview() { + private void playerNamePreview_Paint(object sender, PaintEventArgs e) { + DrawPlayerNamePreview(e.Graphics); + } + + public void DrawPlayerNamePreview(Graphics gfx) { string userName = playerNameInput.Text; bool nextIsColourChar = false; Color colour = SystemColors.ControlText; @@ -402,56 +405,54 @@ namespace SoFii { float offset = 0; StringBuilder sb = new StringBuilder(); - using(Graphics gfx = playerNamePreview.CreateGraphics()) { - gfx.Clear(SystemColors.ControlLightLight); + gfx.Clear(SystemColors.ControlLightLight); - float spaceWidth = gfx.MeasureString(" ", font).Width + .1f; + float spaceWidth = gfx.MeasureString("_", font).Width; - void drawBuffer() { - if(sb.Length < 1) - return; + void drawBuffer() { + if(sb.Length < 1) + return; - string str = sb.ToString(); - sb.Length = 0; + string str = sb.ToString(); + sb.Length = 0; - gfx.DrawString(str, font, brush, offset, 0); - offset += gfx.MeasureString(str, font).Width - spaceWidth; - }; + gfx.DrawString(str, font, brush, offset, 0); + offset += gfx.MeasureString(str.Replace(' ', '_'), font).Width - spaceWidth; + }; - foreach(char chr in userName) { - if(nextIsColourChar) { - foreach(ColourCharInfo cci in Colours) - if(cci.Char == chr) { - if(cci.Colour != colour) { - colour = cci.Colour; - brush.Dispose(); - brush = new SolidBrush(colour); - } - break; + foreach(char chr in userName) { + if(nextIsColourChar) { + foreach(ColourCharInfo cci in Colours) + if(cci.Char == chr) { + if(cci.Colour != colour) { + colour = cci.Colour; + brush.Dispose(); + brush = new SolidBrush(colour); } + break; + } - nextIsColourChar = false; - continue; - } - - if(chr == '^') { - nextIsColourChar = true; - drawBuffer(); - continue; - } - - sb.Append(chr); + nextIsColourChar = false; + continue; } - drawBuffer(); + if(chr == '^') { + nextIsColourChar = true; + drawBuffer(); + continue; + } + + sb.Append(chr); } + drawBuffer(); + brush.Dispose(); } private void playerNameInput_TextChanged(object sender, EventArgs e) { Settings.PlayerName = playerNameInput.Text; - DrawPlayerNamePreview(); + playerNamePreview.Invalidate(); } private void gfxFullscreen_CheckedChanged(object sender, EventArgs e) {