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;
|
|
|
|
using CodeImp.DoomBuilder.Interface;
|
|
|
|
using CodeImp.DoomBuilder.IO;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
using CodeImp.DoomBuilder.Editing;
|
|
|
|
using System.Drawing;
|
|
|
|
using CodeImp.DoomBuilder.Controls;
|
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
|
|
|
|
{
|
|
|
|
[EditMode(SwitchAction = "brightnessmode",
|
|
|
|
ButtonDesc = "Brightness Mode",
|
|
|
|
ButtonImage = "BrightnessMode.png",
|
|
|
|
ButtonOrder = int.MinValue + 3)]
|
|
|
|
|
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-05-18 11:43:28 +00:00
|
|
|
p.AddLayer(new PresentLayer(RendererLayer.Things, BlendingMode.Alpha, 0.3f, 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
|
|
|
|
renderer.RenderGeometry(s.Vertices, 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
|
|
|
|
}
|
|
|
|
}
|