UltimateZoneBuilder/Source/Plugins/CommentsPanel/BuilderPlug.cs

125 lines
3.3 KiB
C#
Raw Normal View History


#region ================== Copyright (c) 2010 Pascal vd Heiden
/*
* Copyright (c) 2010 Pascal vd Heiden
* 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
2010-08-20 06:07:56 +00:00
using CodeImp.DoomBuilder.Controls;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.Plugins;
using CodeImp.DoomBuilder.Config;
#endregion
2010-08-20 06:07:56 +00:00
namespace CodeImp.DoomBuilder.CommentsPanel
{
//
// 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;
2010-08-20 15:04:08 +00:00
2010-08-20 06:07:56 +00:00
// Docker
private CommentsDocker dockerpanel;
private Docker commentsdocker;
2010-08-20 15:04:08 +00:00
// Static property to access the BuilderPlug
public static BuilderPlug Me { get { return me; } }
2010-08-20 15:04:08 +00:00
// This event is called when the plugin is initialized
public override void OnInitialize()
{
base.OnInitialize();
// Keep a static reference
me = this;
}
2010-08-20 19:15:50 +00:00
// When a map is created
public override void OnMapNewEnd()
{
OnMapOpenEnd();
}
2010-08-20 15:04:08 +00:00
2010-08-20 06:07:56 +00:00
// This is called after a map has been successfully opened
public override void OnMapOpenEnd()
{
// If we just opened a UDMF format map, we want to create the Comments panel!
2010-08-20 19:15:50 +00:00
if(General.Map.Config.FormatInterface == "UniversalMapSetIO")
2010-08-20 06:07:56 +00:00
{
dockerpanel = new CommentsDocker();
commentsdocker = new Docker("commentsdockerpanel", "Comments", dockerpanel);
General.Interface.AddDocker(commentsdocker);
dockerpanel.Setup();
2010-08-20 15:04:08 +00:00
dockerpanel.UpdateListSoon();
2010-08-20 06:07:56 +00:00
}
}
// Occurs before the map is closed
public override void OnMapCloseBegin()
2010-08-20 06:07:56 +00:00
{
// If we have a Comments panel, remove it
if(dockerpanel != null)
{
dockerpanel.Terminate();
General.Interface.RemoveDocker(commentsdocker);
commentsdocker = null;
dockerpanel.Dispose();
dockerpanel = null;
}
}
// Geometry pasted
public override void OnPasteEnd(PasteOptions options)
{
if(dockerpanel != null)
2010-08-20 15:04:08 +00:00
dockerpanel.UpdateListSoon();
2010-08-20 06:07:56 +00:00
}
// Undo performed
public override void OnUndoEnd()
{
if(dockerpanel != null)
2010-08-20 15:04:08 +00:00
dockerpanel.UpdateListSoon();
2010-08-20 06:07:56 +00:00
}
// Redo performed
public override void OnRedoEnd()
{
if(dockerpanel != null)
2010-08-20 15:04:08 +00:00
dockerpanel.UpdateListSoon();
}
// Mode changes
public override bool OnModeChange(EditMode oldmode, EditMode newmode)
{
if(dockerpanel != null)
dockerpanel.UpdateListSoon();
return base.OnModeChange(oldmode, newmode);
2010-08-20 06:07:56 +00:00
}
}
}