mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-16 17:11:28 +00:00
@ Added Image Drawing Example plugin to repository
This commit is contained in:
parent
578259fe67
commit
0ab176fb87
9 changed files with 402 additions and 0 deletions
|
@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Statistics", "Source\Plugin
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CopyPasteSectorProperties", "Source\Plugins\CopyPasteSectorProps\CopyPasteSectorProperties.csproj", "{A5F93B70-18D9-4F3C-9B72-BC8B5B13998E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageDrawingExample", "Source\Plugins\ImageDrawingExample\ImageDrawingExample.csproj", "{CBD14608-D467-458A-97B3-CA767CA85203}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
|
@ -27,6 +29,8 @@ Global
|
|||
{FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Release|x86.ActiveCfg = Release|x86
|
||||
{A5F93B70-18D9-4F3C-9B72-BC8B5B13998E}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{A5F93B70-18D9-4F3C-9B72-BC8B5B13998E}.Release|x86.ActiveCfg = Release|x86
|
||||
{CBD14608-D467-458A-97B3-CA767CA85203}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{CBD14608-D467-458A-97B3-CA767CA85203}.Release|x86.ActiveCfg = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
BIN
Resources/Icons/Image.png
Normal file
BIN
Resources/Icons/Image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 764 B |
33
Source/Plugins/ImageDrawingExample/Actions.cfg
Normal file
33
Source/Plugins/ImageDrawingExample/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.
|
||||
//
|
||||
|
||||
imageexamplemode
|
||||
{
|
||||
title = "Image Example";
|
||||
category = "tools";
|
||||
description = "Switches to the image example mode.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
}
|
||||
|
83
Source/Plugins/ImageDrawingExample/BuilderPlug.cs
Normal file
83
Source/Plugins/ImageDrawingExample/BuilderPlug.cs
Normal file
|
@ -0,0 +1,83 @@
|
|||
|
||||
#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.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.Plugins.ImageDrawingExample
|
||||
{
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
// In this example we don't really do anything interesting here. This is the bare
|
||||
// minimum you need for a Plug class. You may as well ignore this whole file.
|
||||
|
||||
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; } }
|
||||
|
||||
// Override this property if you want to give your plugin a name other
|
||||
// than the filename without extention.
|
||||
public override string Name { get { return "Image Drawing Example"; } }
|
||||
|
||||
// This event is called when the plugin is initialized
|
||||
public override void OnInitialize()
|
||||
{
|
||||
base.OnInitialize();
|
||||
|
||||
// Keep a static reference
|
||||
me = this;
|
||||
}
|
||||
|
||||
// This is called when the plugin is terminated
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
<?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>{CBD14608-D467-458A-97B3-CA767CA85203}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CodeImp.DoomBuilder.Plugins.ImageDrawingExample</RootNamespace>
|
||||
<AssemblyName>ImageDrawingExample</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>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BuilderPlug.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ImageExampleMode.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Core\Builder.csproj">
|
||||
<Project>{818B3D10-F791-4C3F-9AF5-BB2D0079B63C}</Project>
|
||||
<Name>Builder</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="ImageIcon.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="exampleimage.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Actions.cfg" />
|
||||
</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>
|
||||
-->
|
||||
</Project>
|
177
Source/Plugins/ImageDrawingExample/ImageExampleMode.cs
Normal file
177
Source/Plugins/ImageDrawingExample/ImageExampleMode.cs
Normal file
|
@ -0,0 +1,177 @@
|
|||
|
||||
#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.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
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 = "Image Example",
|
||||
SwitchAction = "imageexamplemode",
|
||||
ButtonImage = "ImageIcon.png",
|
||||
ButtonOrder = 300,
|
||||
ButtonGroup = "002_tools",
|
||||
UseByDefault = true)]
|
||||
|
||||
public class ImageExampleMode : ClassicMode
|
||||
{
|
||||
// This is the image we want to display. We keep it here, because we don't want to load/unload
|
||||
// it all the time when it needs to be drawn. You may even want to consider placing this in a
|
||||
// class of program scope such as the Plug and load the image only once when the plugin is loaded.
|
||||
private ImageData exampleimage;
|
||||
|
||||
//
|
||||
// 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();
|
||||
|
||||
// Here we load our image. The image is loaded from resource that is embedded
|
||||
// in this project. This is done by simply adding the PNG file to the project
|
||||
// and set the Build Action property of the image to "Embedded Resource".
|
||||
// Embedded means that the image will be compiled into your plugin .DLL file so
|
||||
// you don't have to distribute this image separately.
|
||||
exampleimage = new ResourceImage("CodeImp.DoomBuilder.Plugins.ImageDrawingExample.exampleimage.png");
|
||||
|
||||
// The image is not always directly loaded. Call this to ensure that the image is loaded immediately.
|
||||
exampleimage.LoadImage();
|
||||
if(exampleimage.LoadFailed) throw new Exception("Unable to load the exampleimage.png resource!");
|
||||
|
||||
// After loading, the image is usable by the GDI (GetBitmap() function) but we want to use
|
||||
// it for rendering in the working area. We must call CreateTexture to tranfer the image to
|
||||
// the vido memory as texture.
|
||||
exampleimage.CreateTexture();
|
||||
|
||||
// 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. Here I make a special presentation
|
||||
// that includes only the layer we need: the Overlay layer.
|
||||
CustomPresentation p = new CustomPresentation();
|
||||
p.AddLayer(new PresentLayer(RendererLayer.Overlay, BlendingMode.None, 1.0f, false));
|
||||
renderer.SetPresentation(p);
|
||||
}
|
||||
|
||||
// This function is called when this editing mode is disengaged
|
||||
public override void OnDisengage()
|
||||
{
|
||||
// We no longer need the image, make sure it is removed from memory!
|
||||
exampleimage.Dispose();
|
||||
|
||||
base.OnDisengage();
|
||||
}
|
||||
|
||||
// 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
|
||||
// In this example, we're not going to draw the map at all, but the example image instead.
|
||||
public override void OnRedrawDisplay()
|
||||
{
|
||||
base.OnRedrawDisplay();
|
||||
|
||||
// We don't have to clear the other layers or anything, because they are not used
|
||||
// anyway (see how the presentation above is configured to show only the Overlay layer)
|
||||
|
||||
// Clear the overlay and begin rendering to it.
|
||||
if(renderer.StartOverlay(true))
|
||||
{
|
||||
// Rectangle of coordinates where to draw the image.
|
||||
// We use untranslated coordinates: this means the coordinates here
|
||||
// are already in screen space.
|
||||
RectangleF r = new RectangleF(20.0f, 20.0f, 428.0f, 332.0f);
|
||||
|
||||
// Show the picture!
|
||||
renderer.RenderRectangleFilled(r, PixelColor.FromColor(Color.White), false, exampleimage);
|
||||
|
||||
// Finish our rendering to this layer.
|
||||
renderer.Finish();
|
||||
}
|
||||
|
||||
// We now present it to the user on the display,
|
||||
// with the previously defined presentation settings.
|
||||
renderer.Present();
|
||||
}
|
||||
}
|
||||
}
|
BIN
Source/Plugins/ImageDrawingExample/ImageIcon.png
Normal file
BIN
Source/Plugins/ImageDrawingExample/ImageIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 764 B |
|
@ -0,0 +1,36 @@
|
|||
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("Image Drawing Example")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[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("9395d421-9750-4956-ad27-b3bcd4ee3ffc")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
BIN
Source/Plugins/ImageDrawingExample/exampleimage.png
Normal file
BIN
Source/Plugins/ImageDrawingExample/exampleimage.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 200 KiB |
Loading…
Reference in a new issue