@ work on (G)ZDoom Editing plugin

This commit is contained in:
codeimp 2010-09-02 20:42:38 +00:00
parent 72d7f6f54e
commit ff0fbdad91
7 changed files with 151 additions and 0 deletions

View file

@ -55,6 +55,9 @@
<Compile Include="VisualModes\BaseVisualThing.cs" />
<Compile Include="VisualModes\IVisualEventReceiver.cs" />
<Compile Include="VisualModes\NullVisualEventReceiver.cs" />
<Compile Include="VisualModes\SectorData.cs" />
<Compile Include="VisualModes\SectorLevel.cs" />
<Compile Include="VisualModes\SectorLevelType.cs" />
<Compile Include="VisualModes\VisualActionResult.cs" />
<Compile Include="VisualModes\VisualCeiling.cs" />
<Compile Include="VisualModes\VisualFloor.cs" />

View file

@ -103,6 +103,10 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// Keep a static reference
me = this;
// Settings
showvisualthings = 2;
usegravity = false;
usehighlight = true;
LoadSettings();
}

View file

@ -69,6 +69,9 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
private double lastpicktime;
private bool locktarget;
// This keeps extra sector info
private Dictionary<Sector, SectorData> sectordata;
// This is true when a selection was made because the action is performed
// on an object that was not selected. In this case the previous selection
// is cleared and the targeted object is temporarely selected to perform
@ -132,6 +135,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// Initialize
this.gravity = new Vector3D(0.0f, 0.0f, 0.0f);
this.selectedobjects = new List<IVisualEventReceiver>();
this.sectordata = new Dictionary<Sector, SectorData>(General.Map.Map.Sectors.Count);
// We have no destructor
GC.SuppressFinalize(this);
@ -154,6 +158,20 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
#region ================== Methods
// This requests a sector's extra data
internal SectorData GetSectorData(Sector s)
{
if(sectordata.ContainsKey(s))
{
return sectordata[s];
}
else
{
// TODO: Build the sector data now?
return new SectorData(this, s);
}
}
// This calculates brightness level
internal int CalculateBrightness(int level)
{
@ -544,6 +562,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
protected override void ResourcesReloaded()
{
base.ResourcesReloaded();
sectordata = new Dictionary<Sector, SectorData>(General.Map.Map.Sectors.Count);
PickTarget();
}

View file

@ -0,0 +1,81 @@
#region === Copyright (c) 2010 Pascal van der Heiden ===
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
#endregion
namespace CodeImp.DoomBuilder.GZDoomEditing
{
internal class SectorData
{
#region ================== Variables
// Sector for which this data is
private Sector sector;
// First level is the sector's absolute ceiling
// Last level is the sector's absolute floor
private List<SectorLevel> levels;
#endregion
#region ================== Properties
public Sector Sector { get { return sector; } }
public List<SectorLevel> Levels { get { return levels; } }
#endregion
#region ================== Constructor / Destructor
// Constructor
public SectorData(BaseVisualMode mode, Sector s)
{
int color = -1, light = s.Brightness;
bool absolute = true;
// Initialize
this.sector = s;
this.levels = new List<SectorLevel>(2);
// Create floor
SectorLevel fl = new SectorLevel();
fl.type = SectorLevelType.Floor;
fl.plane = new Plane(new Vector3D(0, 0, 1), s.FloorHeight);
fl.color = -1;
this.levels.Add(fl);
// Create ceiling
SectorLevel cl = new SectorLevel();
cl.type = SectorLevelType.Ceiling;
cl.plane = new Plane(new Vector3D(0, 0, -1), s.CeilHeight);
try
{
// Fetch ZDoom fields
color = s.Fields.ContainsKey("lightcolor") ? (int)s.Fields["lightcolor"].Value : -1;
light = s.Fields.ContainsKey("lightfloor") ? (int)s.Fields["lightfloor"].Value : 0;
absolute = s.Fields.ContainsKey("lightfloorabsolute") ? (bool)s.Fields["lightfloorabsolute"].Value : false;
}
catch(Exception) { }
if(!absolute) light = s.Brightness + light;
PixelColor lightcolor = PixelColor.FromInt(color);
PixelColor brightness = PixelColor.FromInt(mode.CalculateBrightness(light));
PixelColor finalcolor = PixelColor.Modulate(lightcolor, brightness);
cl.color = finalcolor.WithAlpha(255).ToInt();
this.levels.Add(cl);
}
#endregion
#region ================== Public Methods
#endregion
}
}

View file

@ -0,0 +1,25 @@
#region === Copyright (c) 2010 Pascal van der Heiden ===
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using CodeImp.DoomBuilder.Geometry;
#endregion
namespace CodeImp.DoomBuilder.GZDoomEditing
{
internal struct SectorLevel
{
// Type of level
public SectorLevelType type;
// Plane in the sector
public Plane plane;
// Color below the plane (includes brightness)
public int color;
}
}

View file

@ -0,0 +1,19 @@
#region === Copyright (c) 2010 Pascal van der Heiden ===
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
#endregion
namespace CodeImp.DoomBuilder.GZDoomEditing
{
internal enum SectorLevelType
{
Light,
Floor,
Ceiling
}
}

Binary file not shown.