2008-05-14 21:48:36 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 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;
|
2008-05-29 11:54:45 +00:00
|
|
|
using CodeImp.DoomBuilder.Windows;
|
2008-05-14 21:48:36 +00:00
|
|
|
using CodeImp.DoomBuilder.IO;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
using System.Drawing;
|
|
|
|
using CodeImp.DoomBuilder.Editing;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
|
|
|
{
|
|
|
|
public partial class MenusForm : Form
|
|
|
|
{
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
// Menus list
|
|
|
|
private ToolStripItem[] menus;
|
2008-05-26 12:14:48 +00:00
|
|
|
|
|
|
|
// Buttons list
|
|
|
|
private ToolStripItem[] buttons;
|
|
|
|
|
2008-05-14 21:48:36 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
public ToolStripMenuItem LinedefsMenu { get { return linedefsmenu; } }
|
|
|
|
public ToolStripMenuItem SectorsMenu { get { return sectorsmenu; } }
|
|
|
|
public ToolStripMenuItem ThingsMenu { get { return thingsmenu; } }
|
2008-10-08 05:45:24 +00:00
|
|
|
public ToolStripButton MakeGradientBrightness { get { return buttonbrightnessgradient; } }
|
2008-05-14 21:48:36 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
public MenusForm()
|
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
// List all menus
|
|
|
|
menus = new ToolStripItem[menustrip.Items.Count];
|
|
|
|
for(int i = 0; i < menustrip.Items.Count; i++) menus[i] = menustrip.Items[i];
|
2008-05-26 12:14:48 +00:00
|
|
|
|
|
|
|
// List all buttons
|
2008-10-08 05:45:24 +00:00
|
|
|
buttons = new ToolStripItem[globalstrip.Items.Count];
|
|
|
|
for(int i = 0; i < globalstrip.Items.Count; i++) buttons[i] = globalstrip.Items[i];
|
2008-05-14 21:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
// This registers with the core
|
|
|
|
public void Register()
|
|
|
|
{
|
|
|
|
// Add the menus to the core
|
|
|
|
foreach(ToolStripMenuItem m in menus)
|
|
|
|
General.Interface.AddMenu(m);
|
2008-05-26 12:14:48 +00:00
|
|
|
|
|
|
|
// Add the buttons to the core
|
|
|
|
foreach(ToolStripItem b in buttons)
|
|
|
|
General.Interface.AddButton(b);
|
2008-05-14 21:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This unregisters from the core
|
|
|
|
public void Unregister()
|
|
|
|
{
|
|
|
|
// Remove the menus from the core
|
|
|
|
foreach(ToolStripMenuItem m in menus)
|
|
|
|
General.Interface.RemoveMenu(m);
|
2008-05-26 12:14:48 +00:00
|
|
|
|
|
|
|
// Remove the buttons from the core
|
|
|
|
foreach(ToolStripItem b in buttons)
|
|
|
|
General.Interface.RemoveButton(b);
|
2008-05-14 21:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This hides all menus
|
|
|
|
public void HideAllMenus()
|
|
|
|
{
|
|
|
|
foreach(ToolStripMenuItem m in menus) m.Visible = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This hides all except one menu
|
|
|
|
public void HideAllMenusExcept(ToolStripMenuItem showthis)
|
|
|
|
{
|
|
|
|
HideAllMenus();
|
|
|
|
showthis.Visible = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This shows the menu for the current editing mode
|
|
|
|
public void ShowEditingModeMenu(EditMode mode)
|
|
|
|
{
|
2008-09-22 18:27:50 +00:00
|
|
|
Type sourcemode = typeof(object);
|
|
|
|
if(mode != null) sourcemode = mode.GetType();
|
|
|
|
|
2008-05-14 21:48:36 +00:00
|
|
|
// When these modes are active, then test against the base mode they will return to
|
2008-09-22 18:27:50 +00:00
|
|
|
if((mode is DragGeometryMode) || (mode is DragThingsMode) ||
|
|
|
|
(mode is DrawGeometryMode) || (mode is CurveLinedefsMode))
|
2008-11-27 11:59:17 +00:00
|
|
|
sourcemode = General.Editing.PreviousStableMode;
|
2008-05-14 21:48:36 +00:00
|
|
|
|
|
|
|
// Final decision
|
2008-09-22 18:27:50 +00:00
|
|
|
if(sourcemode == typeof(LinedefsMode)) HideAllMenusExcept(linedefsmenu);
|
|
|
|
else if(sourcemode == typeof(SectorsMode)) HideAllMenusExcept(sectorsmenu);
|
|
|
|
else if(sourcemode == typeof(ThingsMode)) HideAllMenusExcept(thingsmenu);
|
2008-05-14 21:48:36 +00:00
|
|
|
else HideAllMenus();
|
|
|
|
}
|
2008-05-15 12:36:55 +00:00
|
|
|
|
|
|
|
// This invokes an action from control event
|
|
|
|
private void InvokeTaggedAction(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
General.Interface.InvokeTaggedAction(sender, e);
|
|
|
|
}
|
2008-05-14 21:48:36 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|