icons updated, moved configuration classes and create GameConfiguration class

This commit is contained in:
codeimp 2007-10-21 18:06:10 +00:00
parent 7feaf0a904
commit 4af61009c1
24 changed files with 229 additions and 70 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 291 B

After

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 B

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

After

Width:  |  Height:  |  Size: 212 B

View file

@ -44,6 +44,9 @@
</Target>
-->
<ItemGroup>
<Compile Include="Config\GameConfiguration.cs" />
<Compile Include="Config\ThingCategory.cs" />
<Compile Include="Config\ThingTypeInfo.cs" />
<Compile Include="Controls\ActionAttribute.cs" />
<Compile Include="Controls\KeyControl.cs" />
<Compile Include="Data\DirectoryReader.cs" />
@ -62,12 +65,11 @@
<Compile Include="Controls\ActionDelegate.cs" />
<Compile Include="Controls\Action.cs" />
<Compile Include="Controls\ActionManager.cs" />
<Compile Include="General\CompilerInfo.cs" />
<Compile Include="General\ConfigurationInfo.cs" />
<Compile Include="General\GameConfigurationCache.cs" />
<Compile Include="Config\CompilerInfo.cs" />
<Compile Include="Config\ConfigurationInfo.cs" />
<Compile Include="General\MapManager.cs" />
<Compile Include="Controls\SpecialKeys.cs" />
<Compile Include="General\NodebuilderInfo.cs" />
<Compile Include="Config\NodebuilderInfo.cs" />
<Compile Include="Geometry\Angle2D.cs" />
<Compile Include="Geometry\Line2D.cs" />
<Compile Include="Geometry\Vector2D.cs" />
@ -215,9 +217,9 @@
</ItemGroup>
<ItemGroup>
<Content Include="Resources\Builder.ico" />
<None Include="Resources\VerticesMode.png" />
<None Include="Resources\SectorsMode.png" />
<None Include="Resources\LinesMode.png" />
<None Include="Resources\VerticesMode.png" />
<None Include="Resources\ColorPick.png" />
<None Include="Resources\Zoom.png" />
<None Include="Resources\Properties.png" />

View file

@ -28,7 +28,7 @@ using System.Diagnostics;
#endregion
namespace CodeImp.DoomBuilder
namespace CodeImp.DoomBuilder.Config
{
internal class CompilerInfo
{

View file

@ -27,7 +27,7 @@ using System.IO;
#endregion
namespace CodeImp.DoomBuilder
namespace CodeImp.DoomBuilder.Config
{
internal class ConfigurationInfo : IComparable<ConfigurationInfo>
{

View file

@ -0,0 +1,100 @@
#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 CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Data;
using System.IO;
using System.Diagnostics;
using System.Windows.Forms;
#endregion
namespace CodeImp.DoomBuilder.Config
{
internal class GameConfiguration
{
#region ================== Constants
#endregion
#region ================== Variables
// Original configuration
private Configuration cfg;
// General settings
private float defaulttexturescale;
private float defaultflatscale;
private string formatinterface;
private IDictionary maplumpnames;
private int soundlinedefflags;
#endregion
#region ================== Properties
// General settings
public float DefaultTextureScale { get { return defaulttexturescale; } }
public float DefaultFlatScale { get { return defaultflatscale; } }
public string FormatInterface { get { return formatinterface; } }
public IDictionary MapLumpNames { get { return maplumpnames; } }
public int SoundLinedefFlags { get { return soundlinedefflags; } }
#endregion
#region ================== Constructor / Disposer
// Constructor
public GameConfiguration(Configuration cfg)
{
// Keep reference
this.cfg = cfg;
// Read general settings
defaulttexturescale = cfg.ReadSetting("defaulttexturescale", 1f);
defaultflatscale = cfg.ReadSetting("defaultflatscale", 1f);
formatinterface = cfg.ReadSetting("formatinterface", "");
maplumpnames = cfg.ReadSetting("maplumpnames", new Hashtable());
soundlinedefflags = cfg.ReadSetting("soundlinedefflags", 0);
// We have no destructor
GC.SuppressFinalize(this);
}
#endregion
#region ================== Methods
// ReadSetting
public string ReadSetting(string setting, string defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
public int ReadSetting(string setting, int defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
public float ReadSetting(string setting, float defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
public short ReadSetting(string setting, short defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
public long ReadSetting(string setting, long defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
public bool ReadSetting(string setting, bool defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
public byte ReadSetting(string setting, byte defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
public IDictionary ReadSetting(string setting, IDictionary defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
#endregion
}
}

View file

@ -29,7 +29,7 @@ using System.Windows.Forms;
#endregion
namespace CodeImp.DoomBuilder
namespace CodeImp.DoomBuilder.Config
{
internal class NodebuilderInfo : IComparable<NodebuilderInfo>
{

View file

@ -21,16 +21,17 @@ 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.IO;
using CodeImp.DoomBuilder.Data;
using System.IO;
using System.Diagnostics;
using System.Windows.Forms;
#endregion
namespace CodeImp.DoomBuilder
namespace CodeImp.DoomBuilder.Config
{
internal class GameConfigurationCache
internal class ThingCategory
{
#region ================== Constants
@ -38,24 +39,19 @@ namespace CodeImp.DoomBuilder
#region ================== Variables
private int soundlinedefflags;
#endregion
#region ================== Properties
public int SoundLinedefFlags { get { return soundlinedefflags; } }
#endregion
#region ================== Constructor / Disposer
// Constructor
public GameConfigurationCache(Configuration cfg)
public ThingCategory()
{
// Initialize
soundlinedefflags = cfg.ReadSetting("soundlinedefflags", 0);
// We have no destructor
GC.SuppressFinalize(this);
}

View file

@ -0,0 +1,65 @@
#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 CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Data;
using System.IO;
using System.Diagnostics;
using System.Windows.Forms;
#endregion
namespace CodeImp.DoomBuilder.Config
{
internal class ThingTypeInfo
{
#region ================== Constants
#endregion
#region ================== Variables
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Disposer
// Constructor
public ThingTypeInfo()
{
// Initialize
// We have no destructor
GC.SuppressFinalize(this);
}
#endregion
#region ================== Methods
#endregion
}
}

View file

@ -154,7 +154,7 @@ namespace CodeImp.DoomBuilder.Data
bool strifedata;
// Determine default scale
defaultscale = General.Map.Configuration.ReadSetting("defaulttexturescale", 1.0f);
defaultscale = General.Map.Configuration.DefaultTextureScale;
// Get number of textures
texturedata.Seek(0, SeekOrigin.Begin);

View file

@ -32,6 +32,7 @@ using System.Runtime.InteropServices;
using CodeImp.DoomBuilder.Controls;
using System.Diagnostics;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Config;
#endregion

View file

@ -32,6 +32,7 @@ using System.Diagnostics;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.Controls;
using CodeImp.DoomBuilder.Config;
#endregion
@ -67,8 +68,7 @@ namespace CodeImp.DoomBuilder
private MapSetIO io;
private MapOptions options;
private ConfigurationInfo configinfo;
private Configuration config;
private GameConfigurationCache configsettings;
private GameConfiguration config;
private DataManager data;
private EditMode mode;
private D3DGraphics graphics;
@ -92,8 +92,7 @@ namespace CodeImp.DoomBuilder
public bool IsChanged { get { return changed; } set { changed |= value; } }
public bool IsDisposed { get { return isdisposed; } }
public D3DGraphics Graphics { get { return graphics; } }
public Configuration Configuration { get { return config; } }
public GameConfigurationCache Settings { get { return configsettings; } }
public GameConfiguration Configuration { get { return config; } }
public MapSelection Selection { get { return selection; } }
#endregion
@ -159,7 +158,6 @@ namespace CodeImp.DoomBuilder
public bool InitializeNewMap(MapOptions options)
{
string tempfile;
string iointerface;
// Apply settings
this.filetitle = "unnamed.wad";
@ -182,9 +180,8 @@ namespace CodeImp.DoomBuilder
// Load game configuration
General.WriteLogLine("Loading game configuration...");
configinfo = General.GetConfigurationInfo(options.ConfigFile);
config = General.LoadGameConfiguration(options.ConfigFile);
configsettings = new GameConfigurationCache(config);
config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile));
// Create map data
map = new MapSet();
@ -194,9 +191,8 @@ namespace CodeImp.DoomBuilder
tempwad = new WAD(tempfile);
// Read the map from temp file
iointerface = config.ReadSetting("formatinterface", "");
General.WriteLogLine("Initializing map format interface " + iointerface + "...");
io = MapSetIO.Create(iointerface, tempwad, this);
General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");
io = MapSetIO.Create(config.FormatInterface, tempwad, this);
// Create required lumps
General.WriteLogLine("Creating map data structures...");
@ -225,7 +221,6 @@ namespace CodeImp.DoomBuilder
{
WAD mapwad;
string tempfile;
string iointerface;
DataLocation maplocation;
// Apply settings
@ -249,8 +244,7 @@ namespace CodeImp.DoomBuilder
// Load game configuration
General.WriteLogLine("Loading game configuration...");
configinfo = General.GetConfigurationInfo(options.ConfigFile);
config = General.LoadGameConfiguration(options.ConfigFile);
configsettings = new GameConfigurationCache(config);
config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile));
// Create map data
map = new MapSet();
@ -273,9 +267,8 @@ namespace CodeImp.DoomBuilder
mapwad.Dispose();
// Read the map from temp file
iointerface = config.ReadSetting("formatinterface", "");
General.WriteLogLine("Initializing map format interface " + iointerface + "...");
io = MapSetIO.Create(iointerface, tempwad, this);
General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");
io = MapSetIO.Create(config.FormatInterface, tempwad, this);
General.WriteLogLine("Reading map data structures from file...");
map = io.Read(map, TEMP_MAP_HEADER);
@ -489,7 +482,6 @@ namespace CodeImp.DoomBuilder
NodebuilderInfo nodebuilder;
string tempfile1, tempfile2;
bool lumpnodebuild, lumpallowempty, lumpscomplete;
IDictionary maplumps;
WAD buildwad;
int srcindex;
@ -540,8 +532,7 @@ namespace CodeImp.DoomBuilder
{
// Go for all the map lump names
lumpscomplete = true;
maplumps = config.ReadSetting("maplumpnames", new Hashtable());
foreach(DictionaryEntry ml in maplumps)
foreach(DictionaryEntry ml in config.MapLumpNames)
{
// Read lump settings from map config
lumpnodebuild = config.ReadSetting("maplumpnames." + ml.Key + ".nodebuild", false);
@ -551,7 +542,7 @@ namespace CodeImp.DoomBuilder
if(lumpnodebuild && !lumpallowempty)
{
// Find the lump in the source
if(buildwad.FindLump(ml.Key.ToString(), srcindex, srcindex + maplumps.Count + 2) == null)
if(buildwad.FindLump(ml.Key.ToString(), srcindex, srcindex + config.MapLumpNames.Count + 2) == null)
{
// Missing a lump!
lumpscomplete = false;
@ -612,7 +603,6 @@ namespace CodeImp.DoomBuilder
int headerindex, insertindex, targetindex;
string lumpname;
bool lumprequired;
IDictionary maplumps;
// Find the map header in target
headerindex = target.FindLumpIndex(mapname);
@ -627,8 +617,7 @@ namespace CodeImp.DoomBuilder
insertindex = headerindex;
// Go for all the map lump names
maplumps = config.ReadSetting("maplumpnames", new Hashtable());
foreach(DictionaryEntry ml in maplumps)
foreach(DictionaryEntry ml in config.MapLumpNames)
{
// Read lump settings from map config
lumprequired = config.ReadSetting("maplumpnames." + ml.Key + ".required", false);
@ -641,7 +630,7 @@ namespace CodeImp.DoomBuilder
if(lumpname == CONFIG_MAP_HEADER) lumpname = mapname;
// Check if the lump is missing at the target
targetindex = FindSpecificLump(target, lumpname, headerindex, mapname, maplumps);
targetindex = FindSpecificLump(target, lumpname, headerindex, mapname, config.MapLumpNames);
if(targetindex == -1)
{
// Determine target index
@ -670,7 +659,6 @@ namespace CodeImp.DoomBuilder
bool lumprequired, lumpblindcopy, lumpnodebuild;
string lumpscript, srclumpname, tgtlumpname;
int srcheaderindex, tgtheaderindex, targetindex, sourceindex, lumpindex;
IDictionary maplumps;
Lump lump, newlump;
// Find the map header in target
@ -694,8 +682,7 @@ namespace CodeImp.DoomBuilder
//source.Lumps[srcindex].CopyTo(newlump);
// Go for all the map lump names
maplumps = config.ReadSetting("maplumpnames", new Hashtable());
foreach(DictionaryEntry ml in maplumps)
foreach(DictionaryEntry ml in config.MapLumpNames)
{
// Read lump settings from map config
lumprequired = config.ReadSetting("maplumpnames." + ml.Key + ".required", false);
@ -714,11 +701,11 @@ namespace CodeImp.DoomBuilder
if(tgtlumpname == CONFIG_MAP_HEADER) tgtlumpname = targetmapname;
// Find the lump in the source
sourceindex = FindSpecificLump(source, srclumpname, srcheaderindex, sourcemapname, maplumps);
sourceindex = FindSpecificLump(source, srclumpname, srcheaderindex, sourcemapname, config.MapLumpNames);
if(sourceindex > -1)
{
// Remove lump at target
lumpindex = RemoveSpecificLump(target, tgtlumpname, tgtheaderindex, targetmapname, maplumps);
lumpindex = RemoveSpecificLump(target, tgtlumpname, tgtheaderindex, targetmapname, config.MapLumpNames);
// Determine target index
// When original lump was found and removed then insert at that position
@ -887,8 +874,7 @@ namespace CodeImp.DoomBuilder
// Reload game configuration
General.WriteLogLine("Reloading game configuration...");
configinfo = General.GetConfigurationInfo(options.ConfigFile);
config = General.LoadGameConfiguration(options.ConfigFile);
configsettings = new GameConfigurationCache(config);
config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile));
// Reload data resources
General.WriteLogLine("Reloading data resources...");

View file

@ -32,6 +32,7 @@ namespace CodeImp.DoomBuilder.Geometry
public const float PI = (float)Math.PI;
public const float PI2 = (float)Math.PI * 2f;
public const float PIDEG = 57.295779513082320876798154814105f;
#endregion

View file

@ -105,7 +105,7 @@ namespace CodeImp.DoomBuilder.IO
// Read properties from stream
x = reader.ReadInt16();
y = reader.ReadInt16();
angle = reader.ReadInt16(); // TODO: Fix this!
angle = (float)(reader.ReadInt16() + 90) / Angle2D.PIDEG;
type = reader.ReadUInt16();
flags = reader.ReadUInt16();
@ -306,23 +306,19 @@ namespace CodeImp.DoomBuilder.IO
Dictionary<Vertex, int> vertexids = new Dictionary<Vertex,int>();
Dictionary<Sidedef, int> sidedefids = new Dictionary<Sidedef,int>();
Dictionary<Sector, int> sectorids = new Dictionary<Sector,int>();
IDictionary maplumps;
// First index everything
foreach(Vertex v in map.Vertices) vertexids.Add(v, vertexids.Count);
foreach(Sidedef sd in map.Sidedefs) sidedefids.Add(sd, sidedefids.Count);
foreach(Sector s in map.Sectors) sectorids.Add(s, sectorids.Count);
// Read map lumps
maplumps = manager.Configuration.ReadSetting("maplumpnames", new Hashtable());
// Write lumps to wad (note the backwards order because they
// are all inserted at position+1 when not found)
WriteSectors(map, position, maplumps);
WriteVertices(map, position, maplumps);
WriteSidedefs(map, position, maplumps, sectorids);
WriteLinedefs(map, position, maplumps, sidedefids, vertexids);
WriteThings(map, position, maplumps);
WriteSectors(map, position, manager.Configuration.MapLumpNames);
WriteVertices(map, position, manager.Configuration.MapLumpNames);
WriteSidedefs(map, position, manager.Configuration.MapLumpNames, sectorids);
WriteLinedefs(map, position, manager.Configuration.MapLumpNames, sidedefids, vertexids);
WriteThings(map, position, manager.Configuration.MapLumpNames);
}
// This writes the THINGS to WAD file
@ -343,7 +339,7 @@ namespace CodeImp.DoomBuilder.IO
// Write properties to stream
writer.Write((Int16)t.Position.x);
writer.Write((Int16)t.Position.y);
writer.Write((Int16)t.Angle); // TODO: Fix this!
writer.Write((Int16)((t.Angle * Angle2D.PIDEG) - 90));
writer.Write((UInt16)t.Type);
writer.Write((UInt16)t.Flags);
}

View file

@ -26,6 +26,7 @@ using Microsoft.Win32;
using System.Diagnostics;
using CodeImp.DoomBuilder.Controls;
using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.Config;
#endregion

View file

@ -26,6 +26,7 @@ using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.IO;
using System.IO;
using CodeImp.DoomBuilder.Config;
#endregion
@ -75,7 +76,6 @@ namespace CodeImp.DoomBuilder.Interface
private void apply_Click(object sender, EventArgs e)
{
Configuration newcfg;
string oldio, newio;
WAD sourcewad;
bool conflictingname;
@ -125,9 +125,7 @@ namespace CodeImp.DoomBuilder.Interface
if(newcfg == null) return;
// Check if the config uses a different IO interface
oldio = General.Map.Configuration.ReadSetting("formatinterface", "");
newio = newcfg.ReadSetting("formatinterface", "");
if(oldio != newio)
if(newcfg.ReadSetting("formatinterface", "") != General.Map.Configuration.FormatInterface)
{
// Warn the user about IO interface change
if(General.ShowWarningMessage("The game configuration you selected uses a different file format than your current map. Because your map was not designed for this format it may cause the map to work incorrectly in the game. Do you want to continue?", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2) == DialogResult.No)

View file

@ -28,6 +28,7 @@ using System.IO;
using System.Collections;
using System.Diagnostics;
using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.Config;
#endregion

View file

@ -22,6 +22,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Text;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Rendering;
#endregion
@ -56,6 +57,10 @@ namespace CodeImp.DoomBuilder.Map
private int action;
private byte[] args;
// Configuration
private float size;
private PixelColor color;
// Selections
private int selected;
@ -211,6 +216,12 @@ namespace CodeImp.DoomBuilder.Map
this.args = args;
}
// This updates the settings from configuration
public void UpdateConfiguration()
{
// Lookup settings
}
#endregion
}
}

View file

@ -505,7 +505,7 @@ namespace CodeImp.DoomBuilder.Rendering
// Determine color
if(l.Selected > 0) return General.Colors.Selection;
else if(l.Action != 0) return General.Colors.Actions.WithAlpha(DOUBLESIDED_LINE_ALPHA);
else if((l.Flags & General.Map.Settings.SoundLinedefFlags) != 0) return General.Colors.Sounds.WithAlpha(DOUBLESIDED_LINE_ALPHA);
else if((l.Flags & General.Map.Configuration.SoundLinedefFlags) != 0) return General.Colors.Sounds.WithAlpha(DOUBLESIDED_LINE_ALPHA);
else return General.Colors.Linedefs.WithAlpha(DOUBLESIDED_LINE_ALPHA);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 291 B

After

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 B

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

After

Width:  |  Height:  |  Size: 212 B

View file

@ -58,7 +58,8 @@ float4 ps_main(PixelData pd) : COLOR
n = addcolor(n, tex2D(texture1samp, float2(pd.uv.x, pd.uv.y - settings.y)));
// If any pixels nearby where found, return a blend, otherwise return nothing
if(n.a > 0.1f) return float4(n.rgb, n.a * settings.z); else return (float4)0;
//if(n.a > 0.1f) return float4(n.rgb, n.a * settings.z); else return (float4)0;
return float4(n.rgb, n.a * settings.z);
}
else return c;
}