2012-05-11 12:28:20 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
using CodeImp.DoomBuilder;
|
|
|
|
|
using CodeImp.DoomBuilder.Editing;
|
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
|
using CodeImp.DoomBuilder.Windows;
|
|
|
|
|
using CodeImp.DoomBuilder.Plugins;
|
|
|
|
|
using CodeImp.DoomBuilder.Actions;
|
|
|
|
|
using CodeImp.DoomBuilder.VisualModes;
|
|
|
|
|
|
|
|
|
|
using CodeImp.DoomBuilder.ColorPicker.Windows;
|
|
|
|
|
|
2012-07-10 14:14:53 +00:00
|
|
|
|
[assembly: CLSCompliant(true)]
|
2012-05-11 12:28:20 +00:00
|
|
|
|
namespace CodeImp.DoomBuilder.ColorPicker
|
|
|
|
|
{
|
|
|
|
|
public class BuilderPlug : Plug
|
|
|
|
|
{
|
|
|
|
|
private static BuilderPlug me;
|
|
|
|
|
public static BuilderPlug Me { get { return me; } }
|
|
|
|
|
|
|
|
|
|
public override string Name { get { return "Color Picker"; } }
|
|
|
|
|
|
|
|
|
|
private IColorPicker form;
|
|
|
|
|
private ToolsForm toolsform;
|
|
|
|
|
|
2012-06-26 08:54:25 +00:00
|
|
|
|
private Point formLocation; //used to keep form's location constant
|
2012-05-11 12:28:20 +00:00
|
|
|
|
|
|
|
|
|
public override void OnInitialize() {
|
2012-07-10 10:20:45 +00:00
|
|
|
|
if (GZBuilder.GZGeneral.Version < 1.11f) {
|
|
|
|
|
General.ErrorLogger.Add(ErrorType.Error, "ColorPicker plugin: GZDoomBuilder 1.11 or later required!");
|
2012-05-11 12:28:20 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
base.OnInitialize();
|
|
|
|
|
me = this;
|
|
|
|
|
|
|
|
|
|
General.Actions.BindMethods(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnMapOpenEnd() {
|
|
|
|
|
if (toolsform == null)
|
|
|
|
|
toolsform = new ToolsForm();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnMapNewEnd() {
|
|
|
|
|
OnMapOpenEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Dispose() {
|
|
|
|
|
base.Dispose();
|
|
|
|
|
General.Actions.UnbindMethods(this);
|
|
|
|
|
|
|
|
|
|
if (form != null) form.Close();
|
|
|
|
|
form = null;
|
|
|
|
|
|
|
|
|
|
if (toolsform != null) toolsform.Dispose();
|
|
|
|
|
toolsform = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BeginAction("togglelightpannel")]
|
|
|
|
|
private void toggleLightPannel() {
|
|
|
|
|
if (General.Editing.Mode == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-06-26 08:54:25 +00:00
|
|
|
|
string currentModeName = General.Editing.Mode.GetType().Name;
|
2012-05-11 12:28:20 +00:00
|
|
|
|
|
|
|
|
|
//display one of colorPickers or tell the user why we can't do that
|
|
|
|
|
if (currentModeName == "ThingsMode") {
|
|
|
|
|
if(General.Map.Map.SelectedThingsCount == 0){
|
2012-06-03 15:13:22 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Select some lights first!");
|
2012-05-11 12:28:20 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
form = new LightColorPicker();
|
|
|
|
|
|
|
|
|
|
} else if (currentModeName == "SectorsMode") {
|
2012-07-10 10:20:45 +00:00
|
|
|
|
if (General.Map.UDMF) {
|
2012-05-11 12:28:20 +00:00
|
|
|
|
if (General.Map.Map.SelectedSectorsCount == 0) {
|
2012-06-03 15:13:22 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Select some sectors first!");
|
2012-05-11 12:28:20 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
form = new SectorColorPicker();
|
|
|
|
|
} else {
|
2012-06-03 15:13:22 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Sector colors can only be set if map is in UDMF format!");
|
2012-05-11 12:28:20 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (currentModeName == "BaseVisualMode") {
|
|
|
|
|
//nothing selected in visual mode?
|
2012-05-20 00:56:59 +00:00
|
|
|
|
if ( ((VisualMode)General.Editing.Mode).GetSelectedVisualThings(true).Count == 0 ) {
|
2012-05-11 12:28:20 +00:00
|
|
|
|
//check sectors
|
2012-05-20 00:56:59 +00:00
|
|
|
|
int selectedSectorsCount = ((VisualMode)General.Editing.Mode).GetSelectedVisualSectors(true).Count;
|
2012-07-10 10:20:45 +00:00
|
|
|
|
if (General.Map.UDMF && (selectedSectorsCount > 0 || General.Map.Map.SelectedSectorsCount > 0)) {
|
2012-05-11 12:28:20 +00:00
|
|
|
|
form = new SectorColorPicker();
|
|
|
|
|
} else {
|
2012-07-10 10:20:45 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Select some lights " + (General.Map.UDMF ? ", sectors or surfaces " : "") + "first!");
|
2012-05-11 12:28:20 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
form = new LightColorPicker();
|
|
|
|
|
}
|
|
|
|
|
} else { //wrong mode
|
2012-07-10 10:20:45 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Switch to" + (General.Map.UDMF ? " Sectors," : "") + " Things or GZDoom Visual Mode first!");
|
2012-05-11 12:28:20 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (form.Setup(currentModeName)) {
|
|
|
|
|
if (formLocation.X == 0 && formLocation.Y == 0) {
|
|
|
|
|
Size displaySize = Plug.DisplaySize;
|
|
|
|
|
Point displayLocation = Plug.DisplayLocationAbs;
|
|
|
|
|
formLocation = new Point(displayLocation.X + displaySize.Width - form.Width - 16, displayLocation.Y + 32);
|
|
|
|
|
}
|
|
|
|
|
form.Location = formLocation;
|
|
|
|
|
form.FormClosed += new FormClosedEventHandler(form_FormClosed);
|
|
|
|
|
form.ShowDialog(Form.ActiveForm);
|
|
|
|
|
} else {
|
|
|
|
|
form.Dispose();
|
|
|
|
|
form = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void form_FormClosed(object sender, FormClosedEventArgs e) {
|
|
|
|
|
formLocation = form.Location;
|
|
|
|
|
form.Dispose();
|
|
|
|
|
form = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-05-20 00:56:59 +00:00
|
|
|
|
}
|