2008-05-18 07:31:33 +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-18 07:31:33 +00:00
|
|
|
using CodeImp.DoomBuilder.IO;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
using CodeImp.DoomBuilder.Editing;
|
|
|
|
using System.Drawing;
|
2008-05-29 11:34:01 +00:00
|
|
|
using CodeImp.DoomBuilder.Actions;
|
2008-05-18 11:43:28 +00:00
|
|
|
using CodeImp.DoomBuilder.Data;
|
2008-05-18 07:31:33 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
|
|
|
{
|
2008-06-11 05:02:48 +00:00
|
|
|
[EditMode(DisplayName = "Sector Brightness",
|
|
|
|
SwitchAction = "brightnessmode",
|
2008-05-18 07:31:33 +00:00
|
|
|
ButtonDesc = "Brightness Mode",
|
|
|
|
ButtonImage = "BrightnessMode.png",
|
2008-06-11 05:02:48 +00:00
|
|
|
ButtonOrder = int.MinValue + 201)]
|
2008-05-18 07:31:33 +00:00
|
|
|
|
2008-05-26 10:36:41 +00:00
|
|
|
public class BrightnessMode : SectorsMode
|
2008-05-18 07:31:33 +00:00
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
public BrightnessMode()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disposer
|
|
|
|
public override void Dispose()
|
|
|
|
{
|
|
|
|
// Not already disposed?
|
|
|
|
if(!isdisposed)
|
|
|
|
{
|
|
|
|
// Dispose base
|
|
|
|
base.Dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
// Mode engages
|
|
|
|
public override void OnEngage()
|
|
|
|
{
|
|
|
|
base.OnEngage();
|
|
|
|
|
|
|
|
// Make customized presentation
|
|
|
|
CustomPresentation p = new CustomPresentation();
|
|
|
|
p.AddLayer(new PresentLayer(RendererLayer.Background, BlendingMode.Mask));
|
|
|
|
p.AddLayer(new PresentLayer(RendererLayer.Grid, BlendingMode.Mask));
|
|
|
|
p.AddLayer(new PresentLayer(RendererLayer.Overlay, BlendingMode.Alpha, 1f, true));
|
2008-06-11 05:02:48 +00:00
|
|
|
p.AddLayer(new PresentLayer(RendererLayer.Things, BlendingMode.Alpha, Presentation.THINGS_BACK_ALPHA, false));
|
2008-05-18 07:31:33 +00:00
|
|
|
p.AddLayer(new PresentLayer(RendererLayer.Geometry, BlendingMode.Alpha, 1f, true));
|
|
|
|
renderer.SetPresentation(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This redraws the display
|
|
|
|
public override void OnRedrawDisplay()
|
|
|
|
{
|
|
|
|
// Render lines and vertices
|
|
|
|
if(renderer.StartPlotter(true))
|
|
|
|
{
|
|
|
|
renderer.PlotLinedefSet(General.Map.Map.Linedefs);
|
|
|
|
renderer.PlotVerticesSet(General.Map.Map.Vertices);
|
|
|
|
if((highlighted != null) && !highlighted.IsDisposed)
|
|
|
|
renderer.PlotSector(highlighted, General.Colors.Highlight);
|
|
|
|
renderer.Finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Render things
|
|
|
|
if(renderer.StartThings(true))
|
|
|
|
{
|
2008-05-26 20:06:15 +00:00
|
|
|
renderer.RenderThingSet(General.Map.ThingsFilter.HiddenThings, Presentation.THINGS_HIDDEN_ALPHA);
|
|
|
|
renderer.RenderThingSet(General.Map.ThingsFilter.VisibleThings, 1.0f);
|
2008-05-18 07:31:33 +00:00
|
|
|
renderer.Finish();
|
|
|
|
}
|
|
|
|
|
2008-05-18 11:43:28 +00:00
|
|
|
// Render overlay
|
|
|
|
UpdateOverlay();
|
|
|
|
|
|
|
|
renderer.Present();
|
|
|
|
}
|
|
|
|
|
|
|
|
// This updates the overlay
|
|
|
|
private void UpdateOverlay()
|
|
|
|
{
|
2008-05-18 07:31:33 +00:00
|
|
|
if(renderer.StartOverlay(true))
|
|
|
|
{
|
2008-05-18 11:43:28 +00:00
|
|
|
// Go for all sectors
|
2008-05-18 07:31:33 +00:00
|
|
|
foreach(Sector s in General.Map.Map.Sectors)
|
|
|
|
{
|
2008-05-18 11:43:28 +00:00
|
|
|
// Determine color by brightness
|
|
|
|
PixelColor brightnesscolor = new PixelColor(255, (byte)s.Brightness, (byte)s.Brightness, (byte)s.Brightness);
|
|
|
|
int brightnessint = brightnesscolor.ToInt();
|
|
|
|
|
2008-05-26 10:36:41 +00:00
|
|
|
/*
|
2008-05-18 11:43:28 +00:00
|
|
|
// Load texture image
|
|
|
|
ImageData texture = General.Map.Data.GetFlatImage(s.LongFloorTexture);
|
|
|
|
if(!texture.IsLoaded) texture.LoadImage();
|
|
|
|
|
|
|
|
// Make vertices
|
|
|
|
FlatVertex[] verts = new FlatVertex[s.Vertices.Length];
|
|
|
|
s.Vertices.CopyTo(verts, 0);
|
|
|
|
for(int i = 0; i < verts.Length; i++)
|
2008-05-18 07:31:33 +00:00
|
|
|
{
|
2008-05-18 11:43:28 +00:00
|
|
|
verts[i].u = verts[i].x / texture.ScaledWidth;
|
|
|
|
verts[i].v = verts[i].y / texture.ScaledHeight;
|
2008-05-18 07:31:33 +00:00
|
|
|
}
|
2008-05-18 11:43:28 +00:00
|
|
|
|
|
|
|
// Render the geometry
|
|
|
|
renderer.RenderGeometry(verts, texture, true);
|
2008-05-26 10:36:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
// Render the geometry
|
2008-10-07 05:50:39 +00:00
|
|
|
renderer.RenderGeometry(s.FlatVertices, null, true);
|
2008-05-18 07:31:33 +00:00
|
|
|
}
|
2008-05-18 11:43:28 +00:00
|
|
|
|
2008-05-18 07:31:33 +00:00
|
|
|
if(selecting) RenderMultiSelection();
|
2008-05-18 11:43:28 +00:00
|
|
|
|
2008-05-18 07:31:33 +00:00
|
|
|
renderer.Finish();
|
|
|
|
}
|
|
|
|
}
|
2008-05-18 11:43:28 +00:00
|
|
|
|
2008-05-18 07:31:33 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Actions
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|