mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
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.
This commit is contained in:
parent
7e7f24e965
commit
d7340f040b
10 changed files with 917 additions and 0 deletions
41
Builder.sln
41
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
|
||||
|
|
33
Source/Plugins/Statistics/Actions.cfg
Normal file
33
Source/Plugins/Statistics/Actions.cfg
Normal file
|
@ -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;
|
||||
}
|
||||
|
96
Source/Plugins/Statistics/BuilderPlug.cs
Normal file
96
Source/Plugins/Statistics/BuilderPlug.cs
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
32
Source/Plugins/Statistics/Properties/AssemblyInfo.cs
Normal file
32
Source/Plugins/Statistics/Properties/AssemblyInfo.cs
Normal file
|
@ -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")]
|
91
Source/Plugins/Statistics/Statistics.csproj
Normal file
91
Source/Plugins/Statistics/Statistics.csproj
Normal file
|
@ -0,0 +1,91 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CodeImp.DoomBuilder.Statistics</RootNamespace>
|
||||
<AssemblyName>Statistics</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\..\Build\Plugins\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>..\..\..\Build\Plugins\</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug with revision lookup|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\..\Build\Plugins\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BuilderPlug.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="StatisticsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="StatisticsForm.Designer.cs">
|
||||
<DependentUpon>StatisticsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="StatisticsMode.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Core\Builder.csproj">
|
||||
<Project>{818B3D10-F791-4C3F-9AF5-BB2D0079B63C}</Project>
|
||||
<Name>Builder</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="StatisticsIcon.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Actions.cfg" />
|
||||
<EmbeddedResource Include="StatisticsForm.resx">
|
||||
<DependentUpon>StatisticsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>"$(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)"</PreBuildEvent>
|
||||
<PostBuildEvent>"$(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)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
196
Source/Plugins/Statistics/StatisticsForm.Designer.cs
generated
Normal file
196
Source/Plugins/Statistics/StatisticsForm.Designer.cs
generated
Normal file
|
@ -0,0 +1,196 @@
|
|||
namespace CodeImp.DoomBuilder.Statistics
|
||||
{
|
||||
partial class StatisticsForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if(disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
88
Source/Plugins/Statistics/StatisticsForm.cs
Normal file
88
Source/Plugins/Statistics/StatisticsForm.cs
Normal file
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
156
Source/Plugins/Statistics/StatisticsForm.resx
Normal file
156
Source/Plugins/Statistics/StatisticsForm.resx
Normal file
|
@ -0,0 +1,156 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="label1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="label2.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="label3.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="label4.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="label5.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="verticescount.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="linedefscount.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="sidedefscount.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="sectorscount.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="thingscount.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="closebutton.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
BIN
Source/Plugins/Statistics/StatisticsIcon.png
Normal file
BIN
Source/Plugins/Statistics/StatisticsIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 280 B |
184
Source/Plugins/Statistics/StatisticsMode.cs
Normal file
184
Source/Plugins/Statistics/StatisticsMode.cs
Normal file
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue