2012-06-26 08:54:25 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
using CodeImp.DoomBuilder.Plugins;
|
|
|
|
|
using CodeImp.DoomBuilder.Actions;
|
|
|
|
|
using CodeImp.DoomBuilder.Windows;
|
|
|
|
|
using CodeImp.DoomBuilder.VisualModes;
|
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.UDMFControls
|
|
|
|
|
{
|
2012-07-05 00:03:40 +00:00
|
|
|
|
public sealed class BuilderPlug: Plug {
|
2012-06-26 08:54:25 +00:00
|
|
|
|
private static BuilderPlug me;
|
|
|
|
|
public static BuilderPlug Me { get { return me; } }
|
|
|
|
|
|
|
|
|
|
public override string Name { get { return "UDMF Controls"; } }
|
|
|
|
|
|
2012-07-28 20:36:28 +00:00
|
|
|
|
//settings
|
|
|
|
|
private int scaleReange;
|
|
|
|
|
public int ScaleReange { get { return scaleReange; } }
|
2012-06-26 08:54:25 +00:00
|
|
|
|
|
2012-07-28 20:36:28 +00:00
|
|
|
|
private UDMFControlsForm form;
|
2012-06-26 08:54:25 +00:00
|
|
|
|
private Point formLocation; //used to keep form's location constant
|
|
|
|
|
|
|
|
|
|
public override void OnInitialize() {
|
2012-07-10 10:20:45 +00:00
|
|
|
|
if (GZBuilder.GZGeneral.Version < 1.11f) {
|
|
|
|
|
General.ErrorLogger.Add(ErrorType.Error, "UDMFControls plugin: GZDoomBuilder 1.11 or later required!");
|
2012-06-26 08:54:25 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
base.OnInitialize();
|
|
|
|
|
me = this;
|
|
|
|
|
|
|
|
|
|
General.Actions.BindMethods(this);
|
|
|
|
|
|
2012-07-28 20:36:28 +00:00
|
|
|
|
scaleReange = General.Settings.ReadPluginSetting("scalerange", 2);
|
|
|
|
|
if (scaleReange < 1) scaleReange = 2;
|
|
|
|
|
General.Settings.WritePluginSetting("scalerange", scaleReange); //not working when called from Dispose()...
|
2012-06-26 08:54:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Dispose() {
|
|
|
|
|
base.Dispose();
|
|
|
|
|
General.Actions.UnbindMethods(this);
|
|
|
|
|
|
|
|
|
|
if (form != null) form.Close();
|
|
|
|
|
form = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BeginAction("openudmfcontrols")]
|
|
|
|
|
private void openControls() {
|
|
|
|
|
if (General.Editing.Mode == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-07-10 10:20:45 +00:00
|
|
|
|
if (!General.Map.UDMF) {
|
2012-06-26 08:54:25 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Map in UDMF format required!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-28 20:27:48 +00:00
|
|
|
|
List<VisualGeometry> selectedSurfaces;
|
|
|
|
|
|
2012-06-26 08:54:25 +00:00
|
|
|
|
if (General.Editing.Mode.GetType().Name == "BaseVisualMode") {
|
2012-06-28 20:27:48 +00:00
|
|
|
|
selectedSurfaces = ((VisualMode)General.Editing.Mode).GetSelectedSurfaces();
|
|
|
|
|
if (selectedSurfaces.Count == 0) {
|
2012-06-26 08:54:25 +00:00
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Select some surfaces first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {//wrong mode
|
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Switch to Visual Mode first!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//show form
|
|
|
|
|
form = new UDMFControlsForm();
|
|
|
|
|
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);
|
2012-06-28 20:27:48 +00:00
|
|
|
|
form.Setup(selectedSurfaces);
|
2012-06-26 08:54:25 +00:00
|
|
|
|
form.ShowDialog(Form.ActiveForm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void form_FormClosed(object sender, FormClosedEventArgs e) {
|
|
|
|
|
formLocation = form.Location;
|
|
|
|
|
form.Dispose();
|
|
|
|
|
form = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-10 10:20:45 +00:00
|
|
|
|
}
|