working on visual mode

This commit is contained in:
codeimp 2008-12-27 00:22:31 +00:00
parent 97735e5764
commit 79676b312e
18 changed files with 306 additions and 43 deletions

View file

@ -3,12 +3,14 @@ quality over quantity. It is done when it's done.
The order and included items may also change any time.
=========================================================
- Make 3D Mode (config specific!)
- Make texture alignment features
- Make Prefabs support
- Make Directory Resources support
- Make PK3 Resources support
=========================================================
BETA TESTING STARTS HERE
OFFICIAL MANUAL WRITING STARTS HERE

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -129,39 +129,49 @@ namespace CodeImp.DoomBuilder.Actions
// Load configuration from stream
cfg = new Configuration();
cfg.InputConfiguration(actionsreader.ReadToEnd());
// Done with the resource
actionsreader.Dispose();
actionsdata.Dispose();
// Read the categories structure
IDictionary cats = cfg.ReadSetting("categories", new Hashtable());
foreach(DictionaryEntry c in cats)
if(cfg.ErrorResult != 0)
{
// Make the category if not already added
if(!categories.ContainsKey(c.Key.ToString()))
categories.Add(c.Key.ToString(), c.Value.ToString());
string errordesc = "Error in Actions configuration on line " + cfg.ErrorLine + ": " + cfg.ErrorDescription;
General.CancelAutoMapLoad();
General.WriteLogLine("ERROR: Unable to read Actions configuration from assembly " + Path.GetFileName(asm.Location) + "!");
General.WriteLogLine(errordesc);
General.ShowErrorMessage("Unable to read Actions configuration from assembly " + Path.GetFileName(asm.Location) + "!\n" + errordesc, MessageBoxButtons.OK);
}
// Go for all objects in the configuration
foreach(DictionaryEntry a in cfg.Root)
else
{
// Get action properties
shortname = a.Key.ToString();
name = asmname.Name.ToLowerInvariant() + "_" + shortname;
debugonly = cfg.ReadSetting(a.Key + ".debugonly", false);
// Not the categories structure?
if(shortname.ToLowerInvariant() != "categories")
// Read the categories structure
IDictionary cats = cfg.ReadSetting("categories", new Hashtable());
foreach(DictionaryEntry c in cats)
{
// Check if action should be included
if(General.DebugBuild || !debugonly)
// Make the category if not already added
if(!categories.ContainsKey(c.Key.ToString()))
categories.Add(c.Key.ToString(), c.Value.ToString());
}
// Go for all objects in the configuration
foreach(DictionaryEntry a in cfg.Root)
{
// Get action properties
shortname = a.Key.ToString();
name = asmname.Name.ToLowerInvariant() + "_" + shortname;
debugonly = cfg.ReadSetting(a.Key + ".debugonly", false);
// Not the categories structure?
if(shortname.ToLowerInvariant() != "categories")
{
// Create an action
CreateAction(cfg, name, shortname);
// Check if action should be included
if(General.DebugBuild || !debugonly)
{
// Create an action
CreateAction(cfg, name, shortname);
}
}
}
}
// Done with the resource
actionsreader.Dispose();
actionsdata.Dispose();
}
}
}

View file

@ -386,3 +386,33 @@ movetexturedown
allowscroll = true;
repeat = true;
}
textureselect
{
title = "Texture Select";
category = "visual";
description = "Opens the texture browser to select a texture for the targeted or selected walls, floors or ceilings.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
}
texturecopy
{
title = "Texture Copy";
category = "visual";
description = "Copies the targeted texture or flat for pasting.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
}
texturepaste
{
title = "Texture Paste";
category = "visual";
description = "Pastes the copied texture onto the targeted or selected walls, floors or ceilings.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
}

View file

@ -79,14 +79,43 @@ namespace CodeImp.DoomBuilder.BuilderModes
public virtual void OnEditBegin() { }
public virtual void OnMouseMove(MouseEventArgs e) { }
public virtual void OnChangeTextureOffset(int horizontal, int vertical) { }
protected virtual void SetTexture(string texturename) { }
// Select texture
public virtual void OnSelectTexture()
{
string oldtexture = GetTextureName();
string newtexture = General.Interface.BrowseFlat(General.Interface, oldtexture);
if(newtexture != oldtexture)
{
General.Map.UndoRedo.CreateUndo("Change flat " + newtexture);
SetTexture(newtexture);
}
}
// Copy texture
public virtual void OnCopyTexture()
{
mode.CopiedFlat = GetTextureName();
if(General.Map.Config.MixTexturesFlats) mode.CopiedTexture = GetTextureName();
}
public virtual void OnPasteTexture() { }
// Return texture name
public virtual string GetTextureName() { return ""; }
// Edit button released
public virtual void OnEditEnd()
{
List<Sector> sectors = new List<Sector>();
sectors.Add(this.Sector.Sector);
DialogResult result = General.Interface.ShowEditSectors(sectors);
if(result == DialogResult.OK) (this.Sector as BaseVisualSector).Rebuild();
// Not using any modifier buttons
if(!General.Interface.ShiftState && !General.Interface.CtrlState && !General.Interface.AltState)
{
List<Sector> sectors = new List<Sector>();
sectors.Add(this.Sector.Sector);
DialogResult result = General.Interface.ShowEditSectors(sectors);
if(result == DialogResult.OK) (this.Sector as BaseVisualSector).Rebuild();
}
}
// Sector height change

View file

@ -111,6 +111,36 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Unused
public virtual void OnEditBegin() { }
public virtual void OnChangeTargetHeight(int amount) { }
protected virtual void SetTexture(string texturename) { }
// Select texture
public virtual void OnSelectTexture()
{
string oldtexture = GetTextureName();
string newtexture = General.Interface.BrowseTexture(General.Interface, oldtexture);
if(newtexture != oldtexture)
{
General.Map.UndoRedo.CreateUndo("Change texture " + newtexture);
SetTexture(newtexture);
}
}
// Paste texture
public virtual void OnPasteTexture()
{
General.Map.UndoRedo.CreateUndo("Paste texture " + mode.CopiedTexture);
SetTexture(mode.CopiedTexture);
}
// Copy texture
public virtual void OnCopyTexture()
{
mode.CopiedTexture = GetTextureName();
if(General.Map.Config.MixTexturesFlats) mode.CopiedFlat = GetTextureName();
}
// Return texture name
public virtual string GetTextureName() { return ""; }
// Select button pressed
public virtual void OnSelectBegin()
@ -141,10 +171,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Edit button released
public virtual void OnEditEnd()
{
List<Linedef> lines = new List<Linedef>();
lines.Add(this.Sidedef.Line);
DialogResult result = General.Interface.ShowEditLinedefs(lines);
if(result == DialogResult.OK) (this.Sector as BaseVisualSector).Rebuild();
// Not using any modifier buttons
if(!General.Interface.ShiftState && !General.Interface.CtrlState && !General.Interface.AltState)
{
List<Linedef> lines = new List<Linedef>();
lines.Add(this.Sidedef.Line);
DialogResult result = General.Interface.ShowEditLinedefs(lines);
if(result == DialogResult.OK) (this.Sector as BaseVisualSector).Rebuild();
}
}
// Mouse moves

View file

@ -60,10 +60,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
private double lastpicktime;
private bool locktarget;
// Texture copying
private string copiedtexture;
private string copiedflat;
#endregion
#region ================== Properties
public string CopiedTexture { get { return copiedtexture; } set { copiedtexture = value; } }
public string CopiedFlat { get { return copiedflat; } set { copiedflat = value; } }
#endregion
#region ================== Constructor / Disposer
@ -371,6 +378,30 @@ namespace CodeImp.DoomBuilder.BuilderModes
PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnChangeTextureOffset(0, 1);
}
[BeginAction("textureselect")]
public void TextureSelect()
{
PickTargetUnlocked();
renderer.SetCrosshairBusy(true);
General.Interface.RedrawDisplay();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnSelectTexture();
renderer.SetCrosshairBusy(false);
}
[BeginAction("texturecopy")]
public void TextureCopy()
{
PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnCopyTexture();
}
[BeginAction("texturepaste")]
public void TexturePaste()
{
PickTargetUnlocked();
if(target.picked != null) (target.picked as IVisualEventReceiver).OnPasteTexture();
}
#endregion
}

View file

@ -338,14 +338,24 @@ namespace CodeImp.DoomBuilder.BuilderModes
public virtual void OnMouseMove(MouseEventArgs e) { }
public virtual void OnChangeTargetBrightness(int amount) { }
public virtual void OnChangeTextureOffset(int horizontal, int vertical) { }
public virtual void OnSelectTexture() { }
public virtual void OnCopyTexture() { }
public virtual void OnPasteTexture() { }
// Return texture name
public virtual string GetTextureName() { return ""; }
// Edit button released
public virtual void OnEditEnd()
{
List<Thing> things = new List<Thing>();
things.Add(this.Thing);
DialogResult result = General.Interface.ShowEditThings(things);
if(result == DialogResult.OK) this.Rebuild();
// Not using any modifier buttons
if(!General.Interface.ShiftState && !General.Interface.CtrlState && !General.Interface.AltState)
{
List<Thing> things = new List<Thing>();
things.Add(this.Thing);
DialogResult result = General.Interface.ShowEditThings(things);
if(result == DialogResult.OK) this.Rebuild();
}
}
// Raise/lower thing

View file

@ -47,5 +47,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
void OnChangeTargetHeight(int amount);
void OnChangeTargetBrightness(int amount);
void OnChangeTextureOffset(int horizontal, int vertical);
void OnSelectTexture();
void OnCopyTexture();
void OnPasteTexture();
// Other methods
string GetTextureName();
}
}

View file

@ -123,6 +123,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods
// Paste texture
public override void OnPasteTexture()
{
General.Map.UndoRedo.CreateUndo("Paste ceiling " + mode.CopiedFlat);
SetTexture(mode.CopiedFlat);
this.Setup();
}
// This changes the height
protected override void ChangeHeight(int amount)
{
@ -164,6 +172,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
float side = sd.Line.SideOfLine(pickintersect);
return (((side <= 0.0f) && sd.IsFront) || ((side > 0.0f) && !sd.IsFront));
}
// Return texture name
public override string GetTextureName()
{
return this.Sector.Sector.CeilTexture;
}
// This changes the texture
protected override void SetTexture(string texturename)
{
this.Sector.Sector.SetCeilTexture(texturename);
General.Map.Data.UpdateUsedTextures();
this.Setup();
}
#endregion
}

View file

@ -110,6 +110,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods
// Paste texture
public override void OnPasteTexture()
{
General.Map.UndoRedo.CreateUndo("Paste floor " + mode.CopiedFlat);
SetTexture(mode.CopiedFlat);
this.Setup();
}
// This changes the height
protected override void ChangeHeight(int amount)
{
@ -151,6 +159,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
float side = sd.Line.SideOfLine(pickintersect);
return (((side <= 0.0f) && sd.IsFront) || ((side > 0.0f) && !sd.IsFront));
}
// Return texture name
public override string GetTextureName()
{
return this.Sector.Sector.FloorTexture;
}
// This changes the texture
protected override void SetTexture(string texturename)
{
this.Sector.Sector.SetFloorTexture(texturename);
General.Map.Data.UpdateUsedTextures();
this.Setup();
}
#endregion
}

View file

@ -154,6 +154,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
#endregion
#region ================== Methods
// Return texture name
public override string GetTextureName()
{
return this.Sidedef.LowTexture;
}
// This changes the texture
protected override void SetTexture(string texturename)
{
this.Sidedef.SetTextureLow(texturename);
General.Map.Data.UpdateUsedTextures();
this.Setup();
}
#endregion
}

View file

@ -165,6 +165,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
#endregion
#region ================== Methods
// Return texture name
public override string GetTextureName()
{
return this.Sidedef.MiddleTexture;
}
// This changes the texture
protected override void SetTexture(string texturename)
{
this.Sidedef.SetTextureMid(texturename);
General.Map.Data.UpdateUsedTextures();
this.Setup();
}
#endregion
}

View file

@ -154,6 +154,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
#endregion
#region ================== Methods
// Return texture name
public override string GetTextureName()
{
return this.Sidedef.MiddleTexture;
}
// This changes the texture
protected override void SetTexture(string texturename)
{
this.Sidedef.SetTextureMid(texturename);
General.Map.Data.UpdateUsedTextures();
this.Setup();
}
#endregion
}

View file

@ -154,6 +154,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
#endregion
#region ================== Methods
// Return texture name
public override string GetTextureName()
{
return this.Sidedef.HighTexture;
}
// This changes the texture
protected override void SetTexture(string texturename)
{
this.Sidedef.SetTextureHigh(texturename);
General.Map.Data.UpdateUsedTextures();
this.Setup();
}
#endregion
}

View file

@ -674,7 +674,7 @@ namespace CodeImp.DoomBuilder
// Cancel loading map from command-line parameters, if any.
// This causes problems, because when the window is shown, the map will
// be loaded and DirectX is initialized (which we seem to be missing)
autoloadfile = null;
CancelAutoMapLoad();
// Ask the user to download DirectX
if(MessageBox.Show("This application requires the latest version of Microsoft DirectX installed on your computer." + Environment.NewLine +
@ -746,6 +746,12 @@ namespace CodeImp.DoomBuilder
}
}
// This cancels automatic map loading
internal static void CancelAutoMapLoad()
{
autoloadfile = null;
}
#endregion
#region ================== Terminate
@ -1334,7 +1340,9 @@ namespace CodeImp.DoomBuilder
Cursor.Current = Cursors.Default;
// Show message
result = MessageBox.Show(Form.ActiveForm, message, Application.ProductName, buttons, MessageBoxIcon.Error);
IWin32Window window = null;
if((Form.ActiveForm != null) && Form.ActiveForm.Visible) window = Form.ActiveForm;
result = MessageBox.Show(window, message, Application.ProductName, buttons, MessageBoxIcon.Error);
// Restore old cursor
Cursor.Current = oldcursor;
@ -1363,7 +1371,9 @@ namespace CodeImp.DoomBuilder
Cursor.Current = Cursors.Default;
// Show message
result = MessageBox.Show(Form.ActiveForm, message, Application.ProductName, buttons, MessageBoxIcon.Warning, defaultbutton);
IWin32Window window = null;
if((Form.ActiveForm != null) && Form.ActiveForm.Visible) window = Form.ActiveForm;
result = MessageBox.Show(window, message, Application.ProductName, buttons, MessageBoxIcon.Warning, defaultbutton);
// Restore old cursor
Cursor.Current = oldcursor;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -382,6 +382,7 @@ namespace CodeImp.DoomBuilder.Windows
//
// apply
//
this.apply.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.apply.Location = new System.Drawing.Point(379, 428);
this.apply.Name = "apply";
this.apply.Size = new System.Drawing.Size(112, 25);
@ -1003,7 +1004,7 @@ namespace CodeImp.DoomBuilder.Windows
//
this.AcceptButton = this.apply;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.CancelButton = this.cancel;
this.CancelButton = this.apply;
this.ClientSize = new System.Drawing.Size(619, 464);
this.Controls.Add(this.cancel);
this.Controls.Add(this.apply);