From d7340f040b4070a332f673078a2599aaa299cef9 Mon Sep 17 00:00:00 2001 From: codeimp Date: Sun, 19 Apr 2009 21:45:56 +0000 Subject: [PATCH] Added source code for Map Statistics plugin. Most simple plugin ever, see this source code to learn the very basics of making a Doom Builder 2 plugin. Lot of comments in the source code to explain why things are needed. --- Builder.sln | 41 ++++ Source/Plugins/Statistics/Actions.cfg | 33 +++ Source/Plugins/Statistics/BuilderPlug.cs | 96 +++++++++ .../Statistics/Properties/AssemblyInfo.cs | 32 +++ Source/Plugins/Statistics/Statistics.csproj | 91 ++++++++ .../Statistics/StatisticsForm.Designer.cs | 196 ++++++++++++++++++ Source/Plugins/Statistics/StatisticsForm.cs | 88 ++++++++ Source/Plugins/Statistics/StatisticsForm.resx | 156 ++++++++++++++ Source/Plugins/Statistics/StatisticsIcon.png | Bin 0 -> 280 bytes Source/Plugins/Statistics/StatisticsMode.cs | 184 ++++++++++++++++ 10 files changed, 917 insertions(+) create mode 100644 Source/Plugins/Statistics/Actions.cfg create mode 100644 Source/Plugins/Statistics/BuilderPlug.cs create mode 100644 Source/Plugins/Statistics/Properties/AssemblyInfo.cs create mode 100644 Source/Plugins/Statistics/Statistics.csproj create mode 100644 Source/Plugins/Statistics/StatisticsForm.Designer.cs create mode 100644 Source/Plugins/Statistics/StatisticsForm.cs create mode 100644 Source/Plugins/Statistics/StatisticsForm.resx create mode 100644 Source/Plugins/Statistics/StatisticsIcon.png create mode 100644 Source/Plugins/Statistics/StatisticsMode.cs diff --git a/Builder.sln b/Builder.sln index 2be7c547..0d5ea3d9 100644 --- a/Builder.sln +++ b/Builder.sln @@ -5,25 +5,66 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Builder", "Source\Core\Buil EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuilderModes", "Source\Plugins\BuilderModes\BuilderModes.csproj", "{B42D5AA0-F9A6-4234-9C4B-A05B11A64851}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Statistics", "Source\Plugins\Statistics\Statistics.csproj", "{FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug with revision lookup|Any CPU = Debug with revision lookup|Any CPU + Debug with revision lookup|Mixed Platforms = Debug with revision lookup|Mixed Platforms Debug with revision lookup|x86 = Debug with revision lookup|x86 + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Debug with revision lookup|Any CPU.ActiveCfg = Debug with revision lookup|x86 + {818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Debug with revision lookup|Mixed Platforms.ActiveCfg = Debug with revision lookup|x86 + {818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Debug with revision lookup|Mixed Platforms.Build.0 = Debug with revision lookup|x86 {818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Debug with revision lookup|x86.ActiveCfg = Debug with revision lookup|x86 {818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Debug with revision lookup|x86.Build.0 = Debug with revision lookup|x86 + {818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Debug|Any CPU.ActiveCfg = Debug|x86 + {818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Debug|Mixed Platforms.Build.0 = Debug|x86 {818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Debug|x86.ActiveCfg = Debug|x86 {818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Debug|x86.Build.0 = Debug|x86 + {818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Release|Any CPU.ActiveCfg = Release|x86 + {818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Release|Mixed Platforms.Build.0 = Release|x86 {818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Release|x86.ActiveCfg = Release|x86 {818B3D10-F791-4C3F-9AF5-BB2D0079B63C}.Release|x86.Build.0 = Release|x86 + {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Debug with revision lookup|Any CPU.ActiveCfg = Debug with revision lookup|x86 + {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Debug with revision lookup|Mixed Platforms.ActiveCfg = Debug with revision lookup|x86 + {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Debug with revision lookup|Mixed Platforms.Build.0 = Debug with revision lookup|x86 {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Debug with revision lookup|x86.ActiveCfg = Debug with revision lookup|x86 {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Debug with revision lookup|x86.Build.0 = Debug with revision lookup|x86 + {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Debug|Any CPU.ActiveCfg = Debug|x86 + {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Debug|Mixed Platforms.Build.0 = Debug|x86 {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Debug|x86.ActiveCfg = Debug|x86 {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Debug|x86.Build.0 = Debug|x86 + {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Release|Any CPU.ActiveCfg = Release|x86 + {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Release|Mixed Platforms.Build.0 = Release|x86 {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Release|x86.ActiveCfg = Release|x86 {B42D5AA0-F9A6-4234-9C4B-A05B11A64851}.Release|x86.Build.0 = Release|x86 + {FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Debug with revision lookup|Any CPU.ActiveCfg = Debug with revision lookup|x86 + {FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Debug with revision lookup|Mixed Platforms.ActiveCfg = Debug with revision lookup|x86 + {FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Debug with revision lookup|Mixed Platforms.Build.0 = Debug with revision lookup|x86 + {FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Debug with revision lookup|x86.ActiveCfg = Debug with revision lookup|x86 + {FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Debug with revision lookup|x86.Build.0 = Debug with revision lookup|x86 + {FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Debug|Any CPU.ActiveCfg = Debug|x86 + {FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Debug|x86.ActiveCfg = Debug|x86 + {FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Debug|x86.Build.0 = Debug|x86 + {FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Release|Any CPU.ActiveCfg = Release|x86 + {FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Release|Mixed Platforms.Build.0 = Release|x86 + {FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Release|x86.ActiveCfg = Release|x86 + {FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Source/Plugins/Statistics/Actions.cfg b/Source/Plugins/Statistics/Actions.cfg new file mode 100644 index 00000000..4230d0a9 --- /dev/null +++ b/Source/Plugins/Statistics/Actions.cfg @@ -0,0 +1,33 @@ + +// +// This file defines which actions there are, what description they have and +// some behaviour options. The Doom Builder core will bind to these actions +// with delegates (function pointers) where you use the BeginAction and +// EndAction attributes. This file must be named Actions.cfg and must be +// included in the plugin project as "Embedded Resource". +// + +// +// Options: +// +// allowkeys: Allows the user to bind standard keys to this action. +// allowmouse: Allows the user to bind mouse buttons to this action. +// allowscroll: Allows the user to bind the scrollwheel to this action. +// disregardshift: This action will trigger regardless if Shift or Control is used. +// repeat: BeginAction will be called for automatic key repetition. +// default: Default key is only used when the action is loaded for the first +// time and the default key is not used by any other action. +// +// allowkeys and allowmouse are true by default, the others are false by default. +// + +statisticsmode +{ + title = "Statistics"; + category = "tools"; + description = "Switches to the map statistics display."; + allowkeys = true; + allowmouse = true; + allowscroll = true; +} + diff --git a/Source/Plugins/Statistics/BuilderPlug.cs b/Source/Plugins/Statistics/BuilderPlug.cs new file mode 100644 index 00000000..7b22cffa --- /dev/null +++ b/Source/Plugins/Statistics/BuilderPlug.cs @@ -0,0 +1,96 @@ + +#region ================== Copyright (c) 2009 Pascal vd Heiden + +/* + * Copyright (c) 2009 Pascal vd Heiden, www.codeimp.com + * This program is released under GNU General Public License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#endregion + +#region ================== Namespaces + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Windows.Forms; +using System.IO; +using System.Reflection; +using CodeImp.DoomBuilder.Windows; +using CodeImp.DoomBuilder.IO; +using CodeImp.DoomBuilder.Map; +using CodeImp.DoomBuilder.Rendering; +using CodeImp.DoomBuilder.Geometry; +using System.Drawing; +using CodeImp.DoomBuilder.Editing; +using CodeImp.DoomBuilder.Plugins; +using CodeImp.DoomBuilder.Types; +using CodeImp.DoomBuilder.Config; +using CodeImp.DoomBuilder.Data; + +#endregion + +namespace CodeImp.DoomBuilder.Statistics +{ + // + // MANDATORY: The plug! + // This is an important class to the Doom Builder core. Every plugin must + // have exactly 1 class that inherits from Plug. When the plugin is loaded, + // this class is instantiated and used to receive events from the core. + // Make sure the class is public, because only public classes can be seen + // by the core. + // + + public class BuilderPlug : Plug + { + // Static instance. We can't use a real static class, because BuilderPlug must + // be instantiated by the core, so we keep a static reference. (this technique + // should be familiar to object-oriented programmers) + private static BuilderPlug me; + + // Static property to access the BuilderPlug + public static BuilderPlug Me { get { return me; } } + + // We keep the statistics window loaded so that it retains its position and settings + // and everything even if the statistics mode is not active. + private StatisticsForm statsform; + + // I don't like publicly visible members in a class, so I make this property to access + // this form from the statistics editing mode. + public StatisticsForm StatsForm { get { return statsform; } } + + // Override this property if you want to give your plugin a name other + // than the filename without extention. + public override string Name { get { return "Statistics Plugin"; } } + + // This event is called when the plugin is initialized + public override void OnInitialize() + { + base.OnInitialize(); + + // Keep a static reference + me = this; + + // Load our statistics form + statsform = new StatisticsForm(); + } + + // This is called when the plugin is terminated + public override void Dispose() + { + base.Dispose(); + + // Time to clean everything up + statsform.Dispose(); + statsform = null; + } + } +} diff --git a/Source/Plugins/Statistics/Properties/AssemblyInfo.cs b/Source/Plugins/Statistics/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..2de45aff --- /dev/null +++ b/Source/Plugins/Statistics/Properties/AssemblyInfo.cs @@ -0,0 +1,32 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Statistics")] +[assembly: AssemblyDescription("Doom Builder Map Statistics")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("CodeImp")] +[assembly: AssemblyProduct("Doom Builder")] +[assembly: AssemblyCopyright("Copyright © 2009")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("cb6d7713-9c4f-4777-92f3-36cb4c452ff6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("2.0.0.0")] diff --git a/Source/Plugins/Statistics/Statistics.csproj b/Source/Plugins/Statistics/Statistics.csproj new file mode 100644 index 00000000..b2283516 --- /dev/null +++ b/Source/Plugins/Statistics/Statistics.csproj @@ -0,0 +1,91 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F} + Library + Properties + CodeImp.DoomBuilder.Statistics + Statistics + v3.5 + 512 + + + true + ..\..\..\Build\Plugins\ + DEBUG;TRACE + true + full + x86 + prompt + + + ..\..\..\Build\Plugins\ + true + true + pdbonly + x86 + prompt + + + true + ..\..\..\Build\Plugins\ + DEBUG;TRACE + true + full + x86 + prompt + + + + + 3.5 + + + + + + + + + Form + + + StatisticsForm.cs + + + + + + {818B3D10-F791-4C3F-9AF5-BB2D0079B63C} + Builder + + + + + + + + + StatisticsForm.cs + + + + + + "$(SolutionDir)VersionFromSVN.exe" "$(ProjectDir)Properties\AssemblyInfo.cs" -F 0 -M "Debug" "$(ConfigurationName)" +"$(SolutionDir)VersionFromSVN.exe" "$(ProjectDir)Properties\AssemblyInfo.cs" -M "Release" "$(ConfigurationName)" +"$(SolutionDir)VersionFromSVN.exe" "$(ProjectDir)Properties\AssemblyInfo.cs" -M "Debug with revision lookup" "$(ConfigurationName)" + "$(SolutionDir)VersionFromSVN.exe" -R "$(ProjectDir)Properties\AssemblyInfo.cs" -M "Release" "$(ConfigurationName)" +"$(SolutionDir)VersionFromSVN.exe" -R "$(ProjectDir)Properties\AssemblyInfo.cs" -M "Debug with revision lookup" "$(ConfigurationName)" + + \ No newline at end of file diff --git a/Source/Plugins/Statistics/StatisticsForm.Designer.cs b/Source/Plugins/Statistics/StatisticsForm.Designer.cs new file mode 100644 index 00000000..38694b19 --- /dev/null +++ b/Source/Plugins/Statistics/StatisticsForm.Designer.cs @@ -0,0 +1,196 @@ +namespace CodeImp.DoomBuilder.Statistics +{ + partial class StatisticsForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if(disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.verticescount = new System.Windows.Forms.Label(); + this.linedefscount = new System.Windows.Forms.Label(); + this.sidedefscount = new System.Windows.Forms.Label(); + this.sectorscount = new System.Windows.Forms.Label(); + this.thingscount = new System.Windows.Forms.Label(); + this.closebutton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(33, 25); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(51, 14); + this.label1.TabIndex = 0; + this.label1.Text = "Vertices:"; + this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(32, 47); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(52, 14); + this.label2.TabIndex = 1; + this.label2.Text = "Linedefs:"; + this.label2.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(31, 69); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(53, 14); + this.label3.TabIndex = 2; + this.label3.Text = "Sidedefs:"; + this.label3.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(36, 91); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(48, 14); + this.label4.TabIndex = 3; + this.label4.Text = "Sectors:"; + this.label4.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(42, 113); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(42, 14); + this.label5.TabIndex = 4; + this.label5.Text = "Things:"; + this.label5.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // verticescount + // + this.verticescount.AutoSize = true; + this.verticescount.Location = new System.Drawing.Point(101, 25); + this.verticescount.Name = "verticescount"; + this.verticescount.Size = new System.Drawing.Size(49, 14); + this.verticescount.TabIndex = 5; + this.verticescount.Text = "0000000"; + // + // linedefscount + // + this.linedefscount.AutoSize = true; + this.linedefscount.Location = new System.Drawing.Point(101, 47); + this.linedefscount.Name = "linedefscount"; + this.linedefscount.Size = new System.Drawing.Size(49, 14); + this.linedefscount.TabIndex = 6; + this.linedefscount.Text = "0000000"; + // + // sidedefscount + // + this.sidedefscount.AutoSize = true; + this.sidedefscount.Location = new System.Drawing.Point(101, 69); + this.sidedefscount.Name = "sidedefscount"; + this.sidedefscount.Size = new System.Drawing.Size(49, 14); + this.sidedefscount.TabIndex = 7; + this.sidedefscount.Text = "0000000"; + // + // sectorscount + // + this.sectorscount.AutoSize = true; + this.sectorscount.Location = new System.Drawing.Point(101, 91); + this.sectorscount.Name = "sectorscount"; + this.sectorscount.Size = new System.Drawing.Size(49, 14); + this.sectorscount.TabIndex = 8; + this.sectorscount.Text = "0000000"; + // + // thingscount + // + this.thingscount.AutoSize = true; + this.thingscount.Location = new System.Drawing.Point(101, 113); + this.thingscount.Name = "thingscount"; + this.thingscount.Size = new System.Drawing.Size(49, 14); + this.thingscount.TabIndex = 9; + this.thingscount.Text = "0000000"; + // + // closebutton + // + this.closebutton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.closebutton.Location = new System.Drawing.Point(34, 166); + this.closebutton.Name = "closebutton"; + this.closebutton.Size = new System.Drawing.Size(116, 26); + this.closebutton.TabIndex = 10; + this.closebutton.Text = "Close"; + this.closebutton.UseVisualStyleBackColor = true; + this.closebutton.Click += new System.EventHandler(this.closebutton_Click); + // + // StatisticsForm + // + this.AcceptButton = this.closebutton; + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.CancelButton = this.closebutton; + this.ClientSize = new System.Drawing.Size(184, 209); + this.Controls.Add(this.closebutton); + this.Controls.Add(this.thingscount); + this.Controls.Add(this.sectorscount); + this.Controls.Add(this.sidedefscount); + this.Controls.Add(this.linedefscount); + this.Controls.Add(this.verticescount); + this.Controls.Add(this.label5); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.DoubleBuffered = true; + this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "StatisticsForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; + this.Text = "Statistics"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.StatisticsForm_FormClosing); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label verticescount; + private System.Windows.Forms.Label linedefscount; + private System.Windows.Forms.Label sidedefscount; + private System.Windows.Forms.Label sectorscount; + private System.Windows.Forms.Label thingscount; + private System.Windows.Forms.Button closebutton; + } +} \ No newline at end of file diff --git a/Source/Plugins/Statistics/StatisticsForm.cs b/Source/Plugins/Statistics/StatisticsForm.cs new file mode 100644 index 00000000..18e33370 --- /dev/null +++ b/Source/Plugins/Statistics/StatisticsForm.cs @@ -0,0 +1,88 @@ + +#region ================== Copyright (c) 2009 Pascal vd Heiden + +/* + * Copyright (c) 2009 Pascal vd Heiden, www.codeimp.com + * This program is released under GNU General Public License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#endregion + +#region ================== Namespaces + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +#endregion + +namespace CodeImp.DoomBuilder.Statistics +{ + public partial class StatisticsForm : Form + { + // Constructor + public StatisticsForm() + { + InitializeComponent(); + } + + // We're going to use this to show the form + public void ShowWindow(Form owner) + { + // Position this window in the left-top corner of owner + this.Location = new Point(owner.Location.X + 20, owner.Location.Y + 90); + + // Update statistics + UpdateStats(); + + // Show it + base.Show(owner); + } + + // Form is closing event + private void StatisticsForm_FormClosing(object sender, FormClosingEventArgs e) + { + // When the user is closing the window we want to cancel this, because it + // would also unload (dispose) the form. We only want to hide the window + // so that it can be re-used next time when this editing mode is activated. + if(e.CloseReason == CloseReason.UserClosing) + { + // Just cancel the editing mode. This will automatically call + // OnCancel() which will switch to the previous mode and in turn + // calls OnDisengage() which hides this window. + General.Editing.CancelMode(); + e.Cancel = true; + } + } + + // This function updates all statistics on the form + public void UpdateStats() + { + // You can access the Doom Builder core through the static General class. + // General.Map gives you access the manager of the map that is being edited. + // General.Map.Map gives you access to the low level map structure. + + verticescount.Text = General.Map.Map.Vertices.Count.ToString(); + linedefscount.Text = General.Map.Map.Linedefs.Count.ToString(); + sidedefscount.Text = General.Map.Map.Sidedefs.Count.ToString(); + sectorscount.Text = General.Map.Map.Sectors.Count.ToString(); + thingscount.Text = General.Map.Map.Things.Count.ToString(); + } + + // Close button clicked + private void closebutton_Click(object sender, EventArgs e) + { + General.Editing.CancelMode(); + } + } +} diff --git a/Source/Plugins/Statistics/StatisticsForm.resx b/Source/Plugins/Statistics/StatisticsForm.resx new file mode 100644 index 00000000..a3de9fc9 --- /dev/null +++ b/Source/Plugins/Statistics/StatisticsForm.resx @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/Source/Plugins/Statistics/StatisticsIcon.png b/Source/Plugins/Statistics/StatisticsIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..acff16ce155a10e7fa172c53b22b09abee4be07b GIT binary patch literal 280 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6I14-?iy0WWg+Q3`(%rg0Ai)yX zh!W@g+}zZ>5(b7&tzI^e22U5qkcv6UKh8JE3r%R#&hW|j6aRhxulk?=AN~LNfAhcP ze~ue0eD{Cf|J488dQam{?U-Dn`AxR1$*cd}f8l@6RU9f3XQ=&2*SKN+zy8*L7EYT! zpP%->>z{Dha3!g`{Nbrx$*zN{}q=sxSam~{{MXsOXBPVE2E00`}O=AHn3ip z`RfH&lTFRP-T%w)q;Ed|XV%5~z5k