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 00000000..acff16ce Binary files /dev/null and b/Source/Plugins/Statistics/StatisticsIcon.png differ diff --git a/Source/Plugins/Statistics/StatisticsMode.cs b/Source/Plugins/Statistics/StatisticsMode.cs new file mode 100644 index 00000000..92786372 --- /dev/null +++ b/Source/Plugins/Statistics/StatisticsMode.cs @@ -0,0 +1,184 @@ + +#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 CodeImp.DoomBuilder.Editing; +using CodeImp.DoomBuilder.Actions; +using CodeImp.DoomBuilder.Types; +using CodeImp.DoomBuilder.Config; + +#endregion + +namespace CodeImp.DoomBuilder.Statistics +{ + // + // This class defines an classic editing mode. You can also inherit from VisualMode for a + // visual editing mode or inherit from EditMode if you feel creative. The ClassicMode + // provides basic 2D editing mode features such as zooming in/out and panning the view as + // well as a bunch of usefull events. + // + + // + // This EditMode attribute allows you to link the editing mode into Doom Builder. The core + // only sees your editing mode with this attribute and uses the settings to register it. + // + // DisplayName: This is the name you want to display to the user for this mode. + // + // SwitchAction: This is the action (see Actions.cfg) that engages this mode. + // + // ButtonImage: If set, creates a button on the toolbar for this mode and uses this image. + // Note that the image is included in this project as "Embedded Resource". + // + // ButtonOrder: Ordering number for the position of the button on the toolbar. + // + // ButtonGroup: Group in which to put the button on the toolbar. + // (Groups are buttons that are grouped together between separators) + // + // UseByDefault: THIS OPTION MAY BE INTRUSIVE TO THE USER, USE WITH GREAT CARE! + // Set this to enable this editing mode for use in all game configurations + // by default. This only applies the first time a plugin is loaded and can + // still be changed by the user. But it may not be desired and may conflict + // with other editing modes. + // + // Volatile: Set this to make this mode a volatile mode. When volatile, the mode is + // automatically cancelled when certain major actions are performed (such as + // when the map is saved) + // + + [EditMode(DisplayName = "Statistics", + SwitchAction = "statisticsmode", + ButtonImage = "StatisticsIcon.png", + ButtonOrder = 300, + ButtonGroup = "002_tools", + UseByDefault = true, + Volatile = true)] + + public class StatisticsMode : ClassicMode + { + + // + // Order in which events occur when switching editing modes: + // + // - Constructor of new mode is called + // - OnDisengage() of old mode is called + // ----- Mode switches ----- + // - OnEngage() of new mode is called + // - Dispose() of old mode is called + // + // This function is called when this editing mode is engaged + public override void OnEngage() + { + base.OnEngage(); + + // This tells the renderer how to display the map. + // The renderer works with several different layers, each with its own purpose + // and features. A "presentation" defines how to combine these layers when + // presented to the user on the display. You can make your own presentation + // using the CustomPresentation class, but the standard one is good enough for + // what we need here. + renderer.SetPresentation(Presentation.Standard); + + // We now want to show our interface window. + // General.Interface is the main Doom Builder window. We want to use + // it as "owner" so that our window stays on top of the main window. + BuilderPlug.Me.StatsForm.ShowWindow((Form)General.Interface); + } + + // This function is called when this editing mode is disengaged + public override void OnDisengage() + { + base.OnDisengage(); + + // Hide the window + BuilderPlug.Me.StatsForm.Hide(); + } + + // Event called when the user (or the core) wants to cancel this editing mode + public override void OnCancel() + { + base.OnCancel(); + + // Return to previous stable mode + General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name); + } + + // MANDATORY: You must override this event and handle it to draw the map + public override void OnRedrawDisplay() + { + base.OnRedrawDisplay(); + + // This redraws the surface layer of a presentation. Depending on the + // chosen view mode, it contains the floor or ceiling textures of the + // sectors, or the light levels of the sectors. If your presentation + // does not include the Suface layer, you do not need to call this. + // Calling renderer.Finish() is never needed for this. + renderer.RedrawSurface(); + + // Here we begin drawing on the Geometry layer (which can only draw lines + // and dots, hence why the renderer is called a 'plotter') + // StartPlotter() returns true when drawing is possible. + if(renderer.StartPlotter(true)) + { + // We simply draw all the linedefs and then we draw all the vertices on top. + renderer.PlotLinedefSet(General.Map.Map.Linedefs); + renderer.PlotVerticesSet(General.Map.Map.Vertices); + + // This must be called to finish the rendering. + renderer.Finish(); + } + + // Here we begin drawing on the Things layer (which can only display things) + // StartThings returns true when drawing is possible. + if(renderer.StartThings(true)) + { + // We draw the "visible" things opaque and the "invisible" things with the default translucency. + // Visible and invisible things are controlled by the Things Filter in the core. + renderer.RenderThingSet(General.Map.ThingsFilter.HiddenThings, Presentation.THINGS_HIDDEN_ALPHA); + renderer.RenderThingSet(General.Map.ThingsFilter.VisibleThings, 1.0f); + + // This must be called to finish the rendering. + renderer.Finish(); + } + + // We don't need the overlay at all, so we just clear it here. An optimisation + // could be to write a custom presentation that excludes the Overlay layer so + // we don't need to clear it, but let's keep it simple for now. + if(renderer.StartOverlay(true)) + { + // You know this must be called to finish the rendering, right? + renderer.Finish(); + } + + // All layers we need have been updated. We now present it to the user + // on the display, with the previously defined presentation settings. + renderer.Present(); + } + } +}