working on visual mode

This commit is contained in:
codeimp 2008-11-20 21:32:23 +00:00
parent eee46b13f2
commit a3e9e54b74
10 changed files with 279 additions and 701 deletions

View file

@ -106,7 +106,6 @@
<Compile Include="VisualModes\BaseVisualSector.cs" />
<Compile Include="ClassicModes\DragVerticesMode.cs" />
<Compile Include="ClassicModes\LinedefsMode.cs" />
<Compile Include="VisualModes\Clipper.cs" />
<Compile Include="VisualModes\VisualCeiling.cs" />
<Compile Include="VisualModes\VisualFloor.cs" />
<Compile Include="VisualModes\VisualLower.cs" />

View file

@ -56,9 +56,6 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
// List of visible sectors
private Dictionary<Sector, BaseVisualSector> visiblesectors;
// Visual view range ^ 2
private float visualviewrange2;
#endregion
#region ================== Properties
@ -73,7 +70,6 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
// Initialize
allsectors = new Dictionary<Sector, BaseVisualSector>(General.Map.Map.Sectors.Count);
visiblesectors = new Dictionary<Sector, BaseVisualSector>();
visualviewrange2 = General.Settings.VisualViewRange * General.Settings.VisualViewRange;
// We have no destructor
GC.SuppressFinalize(this);
@ -137,80 +133,46 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
}
// This recursively finds and adds visible sectors
private void ProcessVisibleSectors(Sector start, Vector2D campos, Clipper clipper)
private void ProcessVisibleSectors(Sector start, Vector2D campos)
{
// Add the start sector
AddVisibleSector(start);
// Get a range of blocks
List<VisualBlockEntry> blocks = blockmap.GetSquareRange(campos, General.Settings.ViewDistance);
foreach(VisualBlockEntry b in blocks)
{
// Go for all the linedefs in this block
foreach(Linedef ld in b.Lines)
{
// Add sectors from both sides of the line
if(ld.Front != null) AddVisibleSector(ld.Front.Sector);
if(ld.Back != null) AddVisibleSector(ld.Back.Sector);
}
}
}
// This adds (and creates if needed) the BaseVisualSector for
// the given sector to the visible sectors list
private void AddVisibleSector(Sector s)
{
BaseVisualSector vs;
Clipper newclip;
Sector os;
float side;
// Find the basesector and make it if needed
if(allsectors.ContainsKey(start))
if(allsectors.ContainsKey(s))
{
// Take existing visualsector
vs = allsectors[start];
vs = allsectors[s];
}
else
{
// Make new visualsector
vs = new BaseVisualSector(start);
allsectors.Add(start, vs);
vs = new BaseVisualSector(s);
allsectors.Add(s, vs);
}
// Add sector to visibility list
visiblesectors.Add(start, vs);
// Go for all sidedefs in the sector
foreach(Sidedef sd in start.Sidedefs)
{
// Camera on the front of this side?
side = sd.Line.SideOfLine(campos);
if(((side > 0) && sd.IsFront) ||
((side < 0) && !sd.IsFront))
{
// Sidedef blocking the view?
if((sd.Other == null) ||
(sd.Other.Sector.FloorHeight >= (sd.Sector.CeilHeight - 0.0001f)) ||
(sd.Other.Sector.CeilHeight <= (sd.Sector.FloorHeight + 0.0001f)) ||
(sd.Other.Sector.FloorHeight >= (sd.Other.Sector.CeilHeight - 0.0001f)))
{
// This blocks the view
//clipper.InsertRange(sd.Line.Start.Position, sd.Line.End.Position);
}
}
}
// Go for all sidedefs in the sector
foreach(Sidedef sd in start.Sidedefs)
{
// Doublesided and not referring to same sector?
if((sd.Other != null) && (sd.Other.Sector != sd.Sector))
{
// Get the other sector
os = sd.Other.Sector;
// Sector not yet added?
if(!visiblesectors.ContainsKey(os))
{
// Within view range?
if(sd.Line.DistanceToSq(campos, true) < visualviewrange2)
{
// Check if the sector can be seen
//if(clipper.TestRange(sd.Line.Start.Position, sd.Line.End.Position))
{
// Make a copy of the visibility clipper
newclip = new Clipper(clipper);
// Process this sector as well
ProcessVisibleSectors(os, campos, newclip);
// Done with this clipper
newclip.Dispose();
}
}
}
}
}
visiblesectors[s] = vs;
}
#endregion
@ -262,7 +224,6 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
public override void OnProcess()
{
Vector2D campos;
Clipper clipper;
// Process base class first
base.OnProcess();
@ -270,17 +231,11 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
// Get the 2D camera position
campos = new Vector2D(base.CameraPosition.x, base.CameraPosition.y);
// Make visibility clipper
clipper = new Clipper((Vector2D)base.CameraPosition);
// Make new visibility list
visiblesectors = new Dictionary<Sector, BaseVisualSector>(General.Map.Map.Sectors.Count);
// Process all visible sectors starting with the nearest
ProcessVisibleSectors(FindStartSector(campos), campos, clipper);
// Clean up
clipper.Dispose();
ProcessVisibleSectors(FindStartSector(campos), campos);
}
#endregion

View file

@ -1,269 +0,0 @@
#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.Windows;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Editing;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class Clipper
{
#region ================== Constants
private const float MULTIPLIER = 10000f;
private const int MAXRANGE = (int)(Angle2D.PI2 * MULTIPLIER);
private const int HALFRANGE = (int)(Angle2D.PI * MULTIPLIER);
private const int MINRANGE = 0;
#endregion
#region ================== ClipRange struct
// ClipRange structure
private struct ClipRange
{
// Variables
public int low;
public int high;
// Constructor
public ClipRange(int low, int high)
{
this.low = low;
this.high = high;
}
}
#endregion
#region ================== Variables
// Position where we are viewing from
private Vector2D position;
// Clipping ranges
private LinkedList<ClipRange> ranges;
#endregion
#region ================== Constructor / Disposer
// Constructor
public Clipper(Vector2D pos)
{
// Initialize
this.position = pos;
this.ranges = new LinkedList<ClipRange>();
}
// Constructor
public Clipper(Clipper copy)
{
// Initialize
this.position = copy.position;
this.ranges = new LinkedList<ClipRange>(copy.ranges);
}
// Disposer
public void Dispose()
{
this.ranges.Clear();
}
#endregion
#region ================== Testing methods
// This tests a range to see if it is at least partially visible
public bool TestRange(Vector2D a, Vector2D b)
{
int i1, i2, c1, c2, m;
float a1, a2;
// Get angles
a1 = Angle2D.Normalized(Vector2D.GetAngle(position, a));
a2 = Angle2D.Normalized(Vector2D.GetAngle(position, b));
// Convert angles to ranges
i1 = (int)(a1 * MULTIPLIER);
i2 = (int)(a2 * MULTIPLIER);
c1 = Math.Min(i1, i2);
c2 = Math.Max(i1, i2);
// Determine rotation direction
m = c2 - c1;
if(m < MINRANGE) m += MAXRANGE;
if(m < HALFRANGE)
{
// Check if the range goes through zero point
if(c2 < c1)
{
// Test two ranges
return RangeVisible(new ClipRange(c1, MAXRANGE)) ||
RangeVisible(new ClipRange(MINRANGE, c2));
}
else
{
// Test a single range
return RangeVisible(new ClipRange(c1, c2));
}
}
else
{
// Check if the range goes through zero point
if(c2 > c1)
{
// Test two ranges
return RangeVisible(new ClipRange(MINRANGE, c1)) ||
RangeVisible(new ClipRange(c2, MAXRANGE));
}
else
{
// Test a single range
return RangeVisible(new ClipRange(c2, c1));
}
}
}
// This tests a single range for visibility
private bool RangeVisible(ClipRange r)
{
// Go for all clipped ranges
foreach(ClipRange c in ranges)
{
// Does clipped range completely hide the given range?
if((c.low <= r.low) && (c.high >= r.high))
{
// No further testing needed, range is clipped
return false;
}
}
// Not completely clipped
return true;
}
#endregion
#region ================== Clipping methods
// This tests a range to see if it is at least partially visible
public bool InsertRange(Vector2D a, Vector2D b)
{
int i1, i2, c1, c2, m;
float a1, a2;
// Get angles
a1 = Angle2D.Normalized(Vector2D.GetAngle(position, a));
a2 = Angle2D.Normalized(Vector2D.GetAngle(position, b));
// Convert angles to ranges
i1 = (int)(a1 * MULTIPLIER);
i2 = (int)(a2 * MULTIPLIER);
c1 = Math.Min(i1, i2);
c2 = Math.Max(i1, i2);
// Determine rotation direction
m = c2 - c1;
if(m < MINRANGE) m += MAXRANGE;
if(m < HALFRANGE)
{
// Check if the range goes through zero point
if(c2 < c1)
{
// Add two ranges
return AddRange(new ClipRange(c1, MAXRANGE)) ||
AddRange(new ClipRange(MINRANGE, c2));
}
else
{
// Add a single range
return AddRange(new ClipRange(c1, c2));
}
}
else
{
// Check if the range goes through zero point
if(c2 > c1)
{
// Add two ranges
return AddRange(new ClipRange(MINRANGE, c1)) ||
AddRange(new ClipRange(c2, MAXRANGE));
}
else
{
// Add a single range
return AddRange(new ClipRange(c2, c1));
}
}
}
// This tests a single range for visibility
// Returns true when the entire range has been clipped
private bool AddRange(ClipRange r)
{
LinkedListNode<ClipRange> current, next;
ClipRange c;
// Go for all ranges to find overlappings
current = ranges.First;
while(current != null)
{
// Keep reference to the next
next = current.Next;
c = current.Value;
// Check if ranges overlap
if((c.low <= (r.high + 1)) && (c.high >= (r.low - 1)))
{
// Remove old range from list
ranges.Remove(current);
// Extend range with overlapping range
if(c.low < r.low) r.low = c.low;
if(c.high > r.high) r.high = c.high;
}
// Move to the next
current = next;
}
// Insert the new range
ranges.AddLast(r);
// Return true when entire range is now clipped
return (r.low == MINRANGE) && (r.high == MAXRANGE);
}
#endregion
}
}

View file

@ -53,7 +53,6 @@ namespace CodeImp.DoomBuilder.Config
private int visualfov;
private float visualmousesensx;
private float visualmousesensy;
private float visualviewrange;
private int imagebrightness;
private float doublesidedalpha;
private float backgroundalpha;
@ -95,7 +94,6 @@ namespace CodeImp.DoomBuilder.Config
public float BackgroundAlpha { get { return backgroundalpha; } internal set { backgroundalpha = value; } }
public float VisualMouseSensX { get { return visualmousesensx; } internal set { visualmousesensx = value; } }
public float VisualMouseSensY { get { return visualmousesensy; } internal set { visualmousesensy = value; } }
public float VisualViewRange { get { return visualviewrange; } internal set { visualviewrange = value; } }
public bool QualityDisplay { get { return qualitydisplay; } internal set { qualitydisplay = value; } }
public bool SquareThings { get { return squarethings; } internal set { squarethings = value; } }
public bool TestMonsters { get { return testmonsters; } internal set { testmonsters = value; } }
@ -147,7 +145,6 @@ namespace CodeImp.DoomBuilder.Config
visualfov = cfg.ReadSetting("visualfov", 80);
visualmousesensx = cfg.ReadSetting("visualmousesensx", 40f);
visualmousesensy = cfg.ReadSetting("visualmousesensy", 40f);
visualviewrange = cfg.ReadSetting("visualviewrange", 1000f);
imagebrightness = cfg.ReadSetting("imagebrightness", 3);
doublesidedalpha = cfg.ReadSetting("doublesidedalpha", 0.4f);
backgroundalpha = cfg.ReadSetting("backgroundalpha", 1.0f);
@ -185,7 +182,6 @@ namespace CodeImp.DoomBuilder.Config
cfg.WriteSetting("visualfov", visualfov);
cfg.WriteSetting("visualmousesensx", visualmousesensx);
cfg.WriteSetting("visualmousesensy", visualmousesensy);
cfg.WriteSetting("visualviewrange", visualviewrange);
cfg.WriteSetting("imagebrightness", imagebrightness);
cfg.WriteSetting("qualitydisplay", qualitydisplay);
cfg.WriteSetting("squarethings", squarethings);

View file

@ -41,7 +41,7 @@ namespace CodeImp.DoomBuilder.Rendering
#region ================== Constants
private const float PROJ_NEAR_PLANE = 1f;
private const float PROJ_FAR_PLANE = 2000f;
private const float PROJ_FAR_PLANE = 5000f;
#endregion

View file

@ -42,8 +42,8 @@ namespace CodeImp.DoomBuilder.VisualModes
{
#region ================== Constants
public const int BLOCK_SIZE_SHIFT = 6;
public const int BLOCK_SIZE = 2 << BLOCK_SIZE_SHIFT;
public const int BLOCK_SIZE_SHIFT = 7;
public const int BLOCK_SIZE = 1 << BLOCK_SIZE_SHIFT;
#endregion
@ -124,10 +124,32 @@ namespace CodeImp.DoomBuilder.VisualModes
blockmap = new Dictionary<ulong,VisualBlockEntry>();
}
// This returns a range of blocks in a square
public List<VisualBlockEntry> GetSquareRange(Vector2D pos, float radius)
{
// Calculate block coordinates
Point lt = GetBlockCoordinates(pos - radius);
Point rb = GetBlockCoordinates(pos + radius);
// Go through the range to make a list
int entriescount = (rb.X - lt.X) * (rb.Y - lt.Y);
List<VisualBlockEntry> entries = new List<VisualBlockEntry>(entriescount);
for(int x = lt.X; x <= rb.X; x++)
{
for(int y = lt.Y; y <= rb.Y; y++)
{
entries.Add(GetBlock(new Point(x, y)));
}
}
// Return list
return entries;
}
#endregion
#region ================== Advanced Methods
// This puts a whole set of linedefs in the blocks they cross
public void AddLinedefsSet(ICollection<Linedef> lines)
{

View file

@ -72,6 +72,9 @@ namespace CodeImp.DoomBuilder.VisualModes
private bool keyleft;
private bool keyright;
// Map
protected VisualBlockMap blockmap;
#endregion
#region ================== Properties
@ -93,6 +96,7 @@ namespace CodeImp.DoomBuilder.VisualModes
this.renderer3d = (Renderer3D)General.Map.Renderer3D;
this.campos = new Vector3D(0.0f, 0.0f, 96.0f);
this.camanglez = Angle2D.PI;
this.blockmap = new VisualBlockMap();
}
// Disposer
@ -102,7 +106,8 @@ namespace CodeImp.DoomBuilder.VisualModes
if(!isdisposed)
{
// Clean up
blockmap.Dispose();
// Done
base.Dispose();
}
@ -117,6 +122,9 @@ namespace CodeImp.DoomBuilder.VisualModes
{
base.OnEngage();
// Fill the blockmap
FillBlockMap();
// Find a 3D Mode thing
foreach(Thing t in General.Map.Map.Things)
if(t.Type == General.Map.Config.Start3DModeThingType) modething = t;
@ -156,6 +164,23 @@ namespace CodeImp.DoomBuilder.VisualModes
#endregion
#region ================== Events
public override void OnUndoEnd()
{
base.OnUndoEnd();
// Make new blockmap
if(blockmap != null)
{
blockmap.Dispose();
blockmap = new VisualBlockMap();
FillBlockMap();
}
}
#endregion
#region ================== Input
// Mouse input
@ -230,6 +255,12 @@ namespace CodeImp.DoomBuilder.VisualModes
#region ================== Processing
// This fills the blockmap
protected virtual void FillBlockMap()
{
blockmap.AddLinedefsSet(General.Map.Map.Linedefs);
}
// Processing
public override void OnProcess()
{

View file

@ -552,9 +552,9 @@ namespace CodeImp.DoomBuilder.Windows
this.viewdistancelabel.AutoSize = true;
this.viewdistancelabel.Location = new System.Drawing.Point(259, 208);
this.viewdistancelabel.Name = "viewdistancelabel";
this.viewdistancelabel.Size = new System.Drawing.Size(48, 14);
this.viewdistancelabel.Size = new System.Drawing.Size(42, 14);
this.viewdistancelabel.TabIndex = 30;
this.viewdistancelabel.Text = "1000 mp";
this.viewdistancelabel.Text = "200 mp";
//
// viewdistance
//

View file

@ -62,7 +62,7 @@ namespace CodeImp.DoomBuilder.Windows
fieldofview.Value = General.Settings.VisualFOV / 10;
mousespeed.Value = General.Settings.MouseSpeed / 100;
movespeed.Value = General.Settings.MoveSpeed / 100;
viewdistance.Value = (int)(General.Settings.ViewDistance / 1000.0f);
viewdistance.Value = (int)(General.Settings.ViewDistance / 200.0f);
invertyaxis.Checked = General.Settings.InvertYAxis;
fixedaspect.Checked = General.Settings.FixedAspect;
scriptfontbold.Checked = General.Settings.ScriptFontBold;
@ -160,6 +160,178 @@ namespace CodeImp.DoomBuilder.Windows
allowapplycontrol = true;
}
#endregion
#region ================== OK / Cancel
// OK clicked
private void apply_Click(object sender, EventArgs e)
{
// Apply interface
General.Settings.ImageBrightness = imagebrightness.Value;
General.Settings.QualityDisplay = qualitydisplay.Checked;
General.Settings.SquareThings = squarethings.Checked;
General.Settings.DoubleSidedAlpha = 1.0f - (float)(doublesidedalpha.Value * 0.1f);
General.Settings.DefaultViewMode = defaultviewmode.SelectedIndex;
General.Settings.ClassicBilinear = classicbilinear.Checked;
General.Settings.VisualBilinear = visualbilinear.Checked;
General.Settings.VisualFOV = fieldofview.Value * 10;
General.Settings.MouseSpeed = mousespeed.Value * 100;
General.Settings.MoveSpeed = movespeed.Value * 100;
General.Settings.ViewDistance = (float)viewdistance.Value * 200.0f;
General.Settings.InvertYAxis = invertyaxis.Checked;
General.Settings.FixedAspect = fixedaspect.Checked;
General.Settings.ScriptFontBold = scriptfontbold.Checked;
General.Settings.ScriptFontName = scriptfontname.Text;
// Script font size
int fontsize = 8;
int.TryParse(scriptfontsize.Text, out fontsize);
General.Settings.ScriptFontSize = fontsize;
// Apply control keys to actions
foreach(ListViewItem item in listactions.Items)
General.Actions[item.Name].SetShortcutKey((int)item.SubItems[1].Tag);
// Apply the colors
// TODO: Make this automated by using the collection
General.Colors.Background = colorbackcolor.Color;
General.Colors.Vertices = colorvertices.Color;
General.Colors.Linedefs = colorlinedefs.Color;
General.Colors.Actions = colorspeciallinedefs.Color;
General.Colors.Sounds = colorsoundlinedefs.Color;
General.Colors.Highlight = colorhighlight.Color;
General.Colors.Selection = colorselection.Color;
General.Colors.Indication = colorindication.Color;
General.Colors.Grid = colorgrid.Color;
General.Colors.Grid64 = colorgrid64.Color;
General.Colors.ScriptBackground = colorscriptbackground.Color;
General.Colors.LineNumbers = colorlinenumbers.Color;
General.Colors.PlainText = colorplaintext.Color;
General.Colors.Comments = colorcomments.Color;
General.Colors.Keywords = colorkeywords.Color;
General.Colors.Literals = colorliterals.Color;
General.Colors.Constants = colorconstants.Color;
General.Colors.CreateAssistColors();
General.Settings.BlackBrowsers = blackbrowsers.Checked;
// Close
this.DialogResult = DialogResult.OK;
this.Close();
}
// Cancel clicked
private void cancel_Click(object sender, EventArgs e)
{
// Close
this.DialogResult = DialogResult.Cancel;
this.Close();
}
#endregion
#region ================== Tabs
// Tab changes
private void tabs_SelectedIndexChanged(object sender, EventArgs e)
{
// Enable/disable stuff with tabs
if(tabs.SelectedTab != tabkeys) this.AcceptButton = apply; else this.AcceptButton = null;
if(tabs.SelectedTab != tabkeys) this.CancelButton = cancel; else this.CancelButton = null;
colorsgroup1.Visible = (tabs.SelectedTab == tabcolors);
//colorsgroup2.Visible = (tabs.SelectedTab == tabcolors);
colorsgroup3.Visible = (tabs.SelectedTab == tabcolors);
}
#endregion
#region ================== Interface Panel
private void fieldofview_ValueChanged(object sender, EventArgs e)
{
int value = fieldofview.Value * 10;
fieldofviewlabel.Text = value.ToString() + (char)176;
}
private void mousespeed_ValueChanged(object sender, EventArgs e)
{
int value = mousespeed.Value * 100;
mousespeedlabel.Text = value.ToString();
}
private void movespeed_ValueChanged(object sender, EventArgs e)
{
int value = movespeed.Value * 100;
movespeedlabel.Text = value.ToString();
}
private void viewdistance_ValueChanged(object sender, EventArgs e)
{
int value = viewdistance.Value * 200;
viewdistancelabel.Text = value.ToString() + " mp";
}
private void scriptfontname_SelectedIndexChanged(object sender, EventArgs e)
{
UpdateScriptFontPreview();
}
private void scriptfontsize_SelectedIndexChanged(object sender, EventArgs e)
{
UpdateScriptFontPreview();
}
private void scriptfontbold_CheckedChanged(object sender, EventArgs e)
{
UpdateScriptFontPreview();
}
// This updates the script font preview label
private void UpdateScriptFontPreview()
{
if((scriptfontname.SelectedIndex > -1) &&
(scriptfontsize.SelectedIndex > -1))
{
scriptfontlabel.Text = scriptfontname.Text;
scriptfontlabel.BackColor = General.Colors.ScriptBackground.ToColor();
scriptfontlabel.ForeColor = General.Colors.PlainText.ToColor();
FontFamily ff = new FontFamily(scriptfontname.Text);
FontStyle style = FontStyle.Regular;
if(scriptfontbold.Checked)
{
// Prefer bold over regular
if(ff.IsStyleAvailable(FontStyle.Bold))
style = FontStyle.Bold;
else if(ff.IsStyleAvailable(FontStyle.Regular))
style = FontStyle.Regular;
else if(ff.IsStyleAvailable(FontStyle.Italic))
style = FontStyle.Italic;
else if(ff.IsStyleAvailable(FontStyle.Underline))
style = FontStyle.Underline;
else if(ff.IsStyleAvailable(FontStyle.Strikeout))
style = FontStyle.Strikeout;
}
else
{
// Prefer regular over bold
if(ff.IsStyleAvailable(FontStyle.Regular))
style = FontStyle.Regular;
else if(ff.IsStyleAvailable(FontStyle.Bold))
style = FontStyle.Bold;
else if(ff.IsStyleAvailable(FontStyle.Italic))
style = FontStyle.Italic;
else if(ff.IsStyleAvailable(FontStyle.Underline))
style = FontStyle.Underline;
else if(ff.IsStyleAvailable(FontStyle.Strikeout))
style = FontStyle.Strikeout;
}
int fontsize = 8;
int.TryParse(scriptfontsize.Text, out fontsize);
if(ff.IsStyleAvailable(style))
scriptfontlabel.Font = new Font(scriptfontname.Text, (float)fontsize, style);
}
}
#endregion
#region ================== Controls Panel
@ -323,89 +495,6 @@ namespace CodeImp.DoomBuilder.Windows
#endregion
#region ================== OK / Cancel
// OK clicked
private void apply_Click(object sender, EventArgs e)
{
// Apply interface
General.Settings.ImageBrightness = imagebrightness.Value;
General.Settings.QualityDisplay = qualitydisplay.Checked;
General.Settings.SquareThings = squarethings.Checked;
General.Settings.DoubleSidedAlpha = 1.0f - (float)(doublesidedalpha.Value * 0.1f);
General.Settings.DefaultViewMode = defaultviewmode.SelectedIndex;
General.Settings.ClassicBilinear = classicbilinear.Checked;
General.Settings.VisualBilinear = visualbilinear.Checked;
General.Settings.VisualFOV = fieldofview.Value * 10;
General.Settings.MouseSpeed = mousespeed.Value * 100;
General.Settings.MoveSpeed = movespeed.Value * 100;
General.Settings.ViewDistance = (float)viewdistance.Value * 1000.0f;
General.Settings.InvertYAxis = invertyaxis.Checked;
General.Settings.FixedAspect = fixedaspect.Checked;
General.Settings.ScriptFontBold = scriptfontbold.Checked;
General.Settings.ScriptFontName = scriptfontname.Text;
// Script font size
int fontsize = 8;
int.TryParse(scriptfontsize.Text, out fontsize);
General.Settings.ScriptFontSize = fontsize;
// Apply control keys to actions
foreach(ListViewItem item in listactions.Items)
General.Actions[item.Name].SetShortcutKey((int)item.SubItems[1].Tag);
// Apply the colors
// TODO: Make this automated by using the collection
General.Colors.Background = colorbackcolor.Color;
General.Colors.Vertices = colorvertices.Color;
General.Colors.Linedefs = colorlinedefs.Color;
General.Colors.Actions = colorspeciallinedefs.Color;
General.Colors.Sounds = colorsoundlinedefs.Color;
General.Colors.Highlight = colorhighlight.Color;
General.Colors.Selection = colorselection.Color;
General.Colors.Indication = colorindication.Color;
General.Colors.Grid = colorgrid.Color;
General.Colors.Grid64 = colorgrid64.Color;
General.Colors.ScriptBackground = colorscriptbackground.Color;
General.Colors.LineNumbers = colorlinenumbers.Color;
General.Colors.PlainText = colorplaintext.Color;
General.Colors.Comments = colorcomments.Color;
General.Colors.Keywords = colorkeywords.Color;
General.Colors.Literals = colorliterals.Color;
General.Colors.Constants = colorconstants.Color;
General.Colors.CreateAssistColors();
General.Settings.BlackBrowsers = blackbrowsers.Checked;
// Close
this.DialogResult = DialogResult.OK;
this.Close();
}
// Cancel clicked
private void cancel_Click(object sender, EventArgs e)
{
// Close
this.DialogResult = DialogResult.Cancel;
this.Close();
}
#endregion
#region ================== Tabs
// Tab changes
private void tabs_SelectedIndexChanged(object sender, EventArgs e)
{
// Enable/disable stuff with tabs
if(tabs.SelectedTab != tabkeys) this.AcceptButton = apply; else this.AcceptButton = null;
if(tabs.SelectedTab != tabkeys) this.CancelButton = cancel; else this.CancelButton = null;
colorsgroup1.Visible = (tabs.SelectedTab == tabcolors);
//colorsgroup2.Visible = (tabs.SelectedTab == tabcolors);
colorsgroup3.Visible = (tabs.SelectedTab == tabcolors);
}
#endregion
#region ================== Colors Panel
private void imagebrightness_ValueChanged(object sender, EventArgs e)
@ -420,94 +509,5 @@ namespace CodeImp.DoomBuilder.Windows
}
#endregion
#region ================== Interface Panel
private void fieldofview_ValueChanged(object sender, EventArgs e)
{
int value = fieldofview.Value * 10;
fieldofviewlabel.Text = value.ToString() + (char)176;
}
private void mousespeed_ValueChanged(object sender, EventArgs e)
{
int value = mousespeed.Value * 100;
mousespeedlabel.Text = value.ToString();
}
private void movespeed_ValueChanged(object sender, EventArgs e)
{
int value = movespeed.Value * 100;
movespeedlabel.Text = value.ToString();
}
private void viewdistance_ValueChanged(object sender, EventArgs e)
{
int value = viewdistance.Value * 1000;
viewdistancelabel.Text = value.ToString() + " mp";
}
private void scriptfontname_SelectedIndexChanged(object sender, EventArgs e)
{
UpdateScriptFontPreview();
}
private void scriptfontsize_SelectedIndexChanged(object sender, EventArgs e)
{
UpdateScriptFontPreview();
}
private void scriptfontbold_CheckedChanged(object sender, EventArgs e)
{
UpdateScriptFontPreview();
}
// This updates the script font preview label
private void UpdateScriptFontPreview()
{
if((scriptfontname.SelectedIndex > -1) &&
(scriptfontsize.SelectedIndex > -1))
{
scriptfontlabel.Text = scriptfontname.Text;
scriptfontlabel.BackColor = General.Colors.ScriptBackground.ToColor();
scriptfontlabel.ForeColor = General.Colors.PlainText.ToColor();
FontFamily ff = new FontFamily(scriptfontname.Text);
FontStyle style = FontStyle.Regular;
if(scriptfontbold.Checked)
{
// Prefer bold over regular
if(ff.IsStyleAvailable(FontStyle.Bold))
style = FontStyle.Bold;
else if(ff.IsStyleAvailable(FontStyle.Regular))
style = FontStyle.Regular;
else if(ff.IsStyleAvailable(FontStyle.Italic))
style = FontStyle.Italic;
else if(ff.IsStyleAvailable(FontStyle.Underline))
style = FontStyle.Underline;
else if(ff.IsStyleAvailable(FontStyle.Strikeout))
style = FontStyle.Strikeout;
}
else
{
// Prefer regular over bold
if(ff.IsStyleAvailable(FontStyle.Regular))
style = FontStyle.Regular;
else if(ff.IsStyleAvailable(FontStyle.Bold))
style = FontStyle.Bold;
else if(ff.IsStyleAvailable(FontStyle.Italic))
style = FontStyle.Italic;
else if(ff.IsStyleAvailable(FontStyle.Underline))
style = FontStyle.Underline;
else if(ff.IsStyleAvailable(FontStyle.Strikeout))
style = FontStyle.Strikeout;
}
int fontsize = 8;
int.TryParse(scriptfontsize.Text, out fontsize);
if(ff.IsStyleAvailable(style))
scriptfontlabel.Font = new Font(scriptfontname.Text, (float)fontsize, style);
}
}
#endregion
}
}

View file

@ -156,21 +156,6 @@
<metadata name="qualitydisplay.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label14.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="defaultviewmode.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="classicbilinear.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="squarethings.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="qualitydisplay.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -210,36 +195,6 @@
<metadata name="colorlinedefs.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorgrid64.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorgrid.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorindication.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorsoundlinedefs.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorspeciallinedefs.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorbackcolor.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorselection.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorvertices.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorhighlight.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorlinedefs.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="cancel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -333,6 +288,21 @@
<metadata name="actioncontrolpanel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="actioncontrol.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="actiontitle.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="actioncontrolclear.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="actionkey.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="actiondescription.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="tabcolors.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -357,132 +327,6 @@
<metadata name="colorsgroup3.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="scriptfontlabel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="viewdistancelabel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="viewdistance.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label13.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="fixedaspect.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="invertyaxis.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="movespeedlabel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="movespeed.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label11.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="mousespeedlabel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="mousespeed.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label9.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="fieldofviewlabel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="fieldofview.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label4.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="visualbilinear.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="listactions.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="actioncontrolpanel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="actioncontrol.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="actiontitle.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="actioncontrolclear.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="actionkey.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="actiondescription.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="actioncontrol.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="actiontitle.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="actioncontrolclear.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="actionkey.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="actiondescription.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="imagebrightnesslabel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="imagebrightness.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="doublesidedalphalabel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="doublesidedalpha.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label2.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="blackbrowsers.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorsgroup3.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorconstants.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorliterals.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorscriptbackground.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorkeywords.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorlinenumbers.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorcomments.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorplaintext.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorconstants.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>