mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
ACS parser: fixed several cases when #include and #import directives were processed incorrectly.
Internal: joined declaration and assignment of some variables.
This commit is contained in:
parent
f86bc370d9
commit
f6f277065f
42 changed files with 367 additions and 525 deletions
|
@ -114,11 +114,6 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
// This loads all actions from an assembly
|
||||
internal void LoadActions(Assembly asm)
|
||||
{
|
||||
Stream actionsdata;
|
||||
StreamReader actionsreader;
|
||||
Configuration cfg;
|
||||
string name, shortname;
|
||||
bool debugonly;
|
||||
AssemblyName asmname = asm.GetName();
|
||||
|
||||
// Find a resource named Actions.cfg
|
||||
|
@ -129,11 +124,11 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
if(rn.EndsWith(ACTIONS_RESOURCE, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
// Get a stream from the resource
|
||||
actionsdata = asm.GetManifestResourceStream(rn);
|
||||
actionsreader = new StreamReader(actionsdata, Encoding.ASCII);
|
||||
Stream actionsdata = asm.GetManifestResourceStream(rn);
|
||||
StreamReader actionsreader = new StreamReader(actionsdata, Encoding.ASCII);
|
||||
|
||||
// Load configuration from stream
|
||||
cfg = new Configuration();
|
||||
Configuration cfg = new Configuration();
|
||||
cfg.InputConfiguration(actionsreader.ReadToEnd());
|
||||
if(cfg.ErrorResult)
|
||||
{
|
||||
|
@ -158,9 +153,9 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
foreach(DictionaryEntry a in cfg.Root)
|
||||
{
|
||||
// Get action properties
|
||||
shortname = a.Key.ToString();
|
||||
name = asmname.Name.ToLowerInvariant() + "_" + shortname;
|
||||
debugonly = cfg.ReadSetting(a.Key + ".debugonly", false);
|
||||
string shortname = a.Key.ToString();
|
||||
string name = asmname.Name.ToLowerInvariant() + "_" + shortname;
|
||||
bool debugonly = cfg.ReadSetting(a.Key + ".debugonly", false);
|
||||
|
||||
// Not the categories structure?
|
||||
if(shortname.ToLowerInvariant() != "categories")
|
||||
|
@ -219,31 +214,26 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
// This binds all methods marked with this attribute
|
||||
private void BindMethods(object obj, Type type)
|
||||
{
|
||||
MethodInfo[] methods;
|
||||
ActionAttribute[] attrs;
|
||||
ActionDelegate del;
|
||||
string actionname;
|
||||
|
||||
if(obj == null)
|
||||
General.WriteLogLine("Binding static action methods for class " + type.Name + "...");
|
||||
else
|
||||
General.WriteLogLine("Binding action methods for " + type.Name + " object...");
|
||||
|
||||
// Go for all methods on obj
|
||||
methods = type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
|
||||
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
|
||||
foreach(MethodInfo m in methods)
|
||||
{
|
||||
// Check if the method has this attribute
|
||||
attrs = (ActionAttribute[])m.GetCustomAttributes(typeof(BeginActionAttribute), true);
|
||||
ActionAttribute[] attrs = (ActionAttribute[])m.GetCustomAttributes(typeof(BeginActionAttribute), true);
|
||||
|
||||
// Go for all attributes
|
||||
foreach(ActionAttribute a in attrs)
|
||||
{
|
||||
// Create a delegate for this method
|
||||
del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
|
||||
ActionDelegate del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
|
||||
|
||||
// Make proper name
|
||||
actionname = a.GetFullActionName(type.Assembly);
|
||||
string actionname = a.GetFullActionName(type.Assembly);
|
||||
|
||||
// Bind method to action
|
||||
if(Exists(actionname))
|
||||
|
@ -259,10 +249,10 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
foreach(ActionAttribute a in attrs)
|
||||
{
|
||||
// Create a delegate for this method
|
||||
del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
|
||||
ActionDelegate del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
|
||||
|
||||
// Make proper name
|
||||
actionname = a.GetFullActionName(type.Assembly);
|
||||
string actionname = a.GetFullActionName(type.Assembly);
|
||||
|
||||
// Bind method to action
|
||||
if(Exists(actionname))
|
||||
|
@ -316,31 +306,26 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
// This unbinds all methods marked with this attribute
|
||||
private void UnbindMethods(object obj, Type type)
|
||||
{
|
||||
MethodInfo[] methods;
|
||||
ActionAttribute[] attrs;
|
||||
ActionDelegate del;
|
||||
string actionname;
|
||||
|
||||
if(obj == null)
|
||||
General.WriteLogLine("Unbinding static action methods for class " + type.Name + "...");
|
||||
else
|
||||
General.WriteLogLine("Unbinding action methods for " + type.Name + " object...");
|
||||
|
||||
// Go for all methods on obj
|
||||
methods = type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
|
||||
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
|
||||
foreach(MethodInfo m in methods)
|
||||
{
|
||||
// Check if the method has this attribute
|
||||
attrs = (ActionAttribute[])m.GetCustomAttributes(typeof(BeginActionAttribute), true);
|
||||
ActionAttribute[] attrs = (ActionAttribute[])m.GetCustomAttributes(typeof(BeginActionAttribute), true);
|
||||
|
||||
// Go for all attributes
|
||||
foreach(ActionAttribute a in attrs)
|
||||
{
|
||||
// Create a delegate for this method
|
||||
del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
|
||||
ActionDelegate del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
|
||||
|
||||
// Make proper name
|
||||
actionname = a.GetFullActionName(type.Assembly);
|
||||
string actionname = a.GetFullActionName(type.Assembly);
|
||||
|
||||
// Unbind method from action
|
||||
actions[actionname].UnbindBegin(del);
|
||||
|
@ -353,10 +338,10 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
foreach(ActionAttribute a in attrs)
|
||||
{
|
||||
// Create a delegate for this method
|
||||
del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
|
||||
ActionDelegate del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
|
||||
|
||||
// Make proper name
|
||||
actionname = a.GetFullActionName(type.Assembly);
|
||||
string actionname = a.GetFullActionName(type.Assembly);
|
||||
|
||||
// Unbind method from action
|
||||
actions[actionname].UnbindEnd(del);
|
||||
|
@ -423,12 +408,9 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
actions[actionname].Invoke();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Shortcut Keys
|
||||
|
@ -682,17 +664,11 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
/// </summary>
|
||||
public bool RequestExclusiveInvokation()
|
||||
{
|
||||
if(exclusiverequested)
|
||||
{
|
||||
// Already given out
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Success
|
||||
exclusiverequested = true;
|
||||
return true;
|
||||
}
|
||||
if(exclusiverequested) return false; // Already given out
|
||||
|
||||
// Success
|
||||
exclusiverequested = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -68,7 +68,6 @@ namespace CodeImp.DoomBuilder.Compilers
|
|||
public override bool Run()
|
||||
{
|
||||
Process process;
|
||||
TimeSpan deltatime;
|
||||
int line = 0;
|
||||
string sourcedir = Path.GetDirectoryName(sourcefile);
|
||||
|
||||
|
@ -141,7 +140,7 @@ namespace CodeImp.DoomBuilder.Compilers
|
|||
|
||||
// Wait for compiler to complete
|
||||
process.WaitForExit();
|
||||
deltatime = TimeSpan.FromTicks(process.ExitTime.Ticks - process.StartTime.Ticks);
|
||||
TimeSpan deltatime = TimeSpan.FromTicks(process.ExitTime.Ticks - process.StartTime.Ticks);
|
||||
General.WriteLogLine("Compiler process has finished.");
|
||||
General.WriteLogLine("Compile time: " + deltatime.TotalSeconds.ToString("########0.00") + " seconds");
|
||||
|
||||
|
|
|
@ -71,17 +71,13 @@ namespace CodeImp.DoomBuilder.Compilers
|
|||
// This runs the compiler with a file as input.
|
||||
public override bool Run()
|
||||
{
|
||||
ProcessStartInfo processinfo;
|
||||
Process process;
|
||||
TimeSpan deltatime;
|
||||
|
||||
// Create parameters
|
||||
string args = this.parameters;
|
||||
args = args.Replace("%FI", inputfile);
|
||||
args = args.Replace("%FO", outputfile);
|
||||
|
||||
// Setup process info
|
||||
processinfo = new ProcessStartInfo();
|
||||
ProcessStartInfo processinfo = new ProcessStartInfo();
|
||||
processinfo.Arguments = args;
|
||||
//processinfo.FileName = Path.Combine(this.tempdir.FullName, info.ProgramFile);
|
||||
processinfo.FileName = Path.Combine(info.Path, info.ProgramFile); //mxd
|
||||
|
@ -99,7 +95,9 @@ namespace CodeImp.DoomBuilder.Compilers
|
|||
General.WriteLogLine("Running compiler...");
|
||||
General.WriteLogLine("Program: " + processinfo.FileName);
|
||||
General.WriteLogLine("Arguments: " + processinfo.Arguments);
|
||||
|
||||
|
||||
Process process;
|
||||
|
||||
try
|
||||
{
|
||||
// Start the compiler
|
||||
|
@ -124,19 +122,19 @@ namespace CodeImp.DoomBuilder.Compilers
|
|||
//zdbsp actually writes building process here, not error info
|
||||
bool errorsInErrorOutput = (outErr.Length > 0 && outErr.ToLowerInvariant().IndexOf("error") != -1);
|
||||
|
||||
deltatime = TimeSpan.FromTicks(process.ExitTime.Ticks - process.StartTime.Ticks);
|
||||
TimeSpan deltatime = TimeSpan.FromTicks(process.ExitTime.Ticks - process.StartTime.Ticks);
|
||||
General.WriteLogLine("Compiler process has finished" + (errorsInNormalOurput || errorsInErrorOutput ? " with errors." : ".")); //mxd
|
||||
General.WriteLogLine("Compile time: " + deltatime.TotalSeconds.ToString("########0.00") + " seconds");
|
||||
|
||||
//mxd
|
||||
if (process.ExitCode > 0 || errorsInNormalOurput || errorsInErrorOutput)
|
||||
if(process.ExitCode > 0 || errorsInNormalOurput || errorsInErrorOutput)
|
||||
{
|
||||
if (errorsInNormalOurput)
|
||||
if(errorsInNormalOurput)
|
||||
{
|
||||
ReportError(new CompilerError(outMsg));
|
||||
General.WriteLogLine("Normal output: " + outMsg);
|
||||
}
|
||||
if (errorsInErrorOutput)
|
||||
if(errorsInErrorOutput)
|
||||
{
|
||||
ReportError(new CompilerError(outErr));
|
||||
General.WriteLogLine("Error output: " + outErr);
|
||||
|
|
|
@ -63,10 +63,8 @@ namespace CodeImp.DoomBuilder.Config
|
|||
// This writes the texture set to configuration
|
||||
internal void WriteToConfig(Configuration cfg, string path)
|
||||
{
|
||||
IDictionary dic;
|
||||
|
||||
// Fill structure
|
||||
dic = new ListDictionary();
|
||||
IDictionary dic = new ListDictionary();
|
||||
|
||||
// Add name
|
||||
dic.Add("name", name);
|
||||
|
|
|
@ -433,6 +433,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
foreach(ThingCategory tc in thingcategories) tc.Dispose();
|
||||
foreach(LinedefActionCategory ac in actioncategories) ac.Dispose();
|
||||
foreach(ThingsFilter tf in thingfilters) tf.Dispose(); //mxd
|
||||
foreach(GeneralizedCategory gc in genactioncategories) gc.Dispose(); //mxd
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -42,8 +42,6 @@ namespace CodeImp.DoomBuilder.Config
|
|||
// Constructor
|
||||
internal GeneralizedCategory(string structure, string name, Configuration cfg)
|
||||
{
|
||||
IDictionary opts;
|
||||
|
||||
// Initialize
|
||||
this.options = new List<GeneralizedOption>();
|
||||
|
||||
|
@ -53,7 +51,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
this.length = cfg.ReadSetting(structure + "." + name + ".length", 0);
|
||||
|
||||
// Read the options
|
||||
opts = cfg.ReadSetting(structure + "." + name, new Hashtable());
|
||||
IDictionary opts = cfg.ReadSetting(structure + "." + name, new Hashtable());
|
||||
foreach(DictionaryEntry de in opts)
|
||||
{
|
||||
// Is this an option and not just some value?
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
#region ================== Variables
|
||||
|
||||
// List of items
|
||||
private List<ListViewItem> dragitems;
|
||||
private readonly List<ListViewItem> dragitems;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -63,10 +63,6 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
// When items are dropped
|
||||
protected override void OnDragDrop(DragEventArgs e)
|
||||
{
|
||||
int dropindex, i;
|
||||
ListViewItem insertatitem;
|
||||
Point cp;
|
||||
|
||||
// Pass on to base
|
||||
base.OnDragDrop(e);
|
||||
|
||||
|
@ -74,8 +70,8 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
if(dragitems.Count == 0) return;
|
||||
|
||||
// Determine where to insert
|
||||
cp = base.PointToClient(new Point(e.X, e.Y));
|
||||
insertatitem = base.GetItemAt(cp.X, cp.Y);
|
||||
Point cp = base.PointToClient(new Point(e.X, e.Y));
|
||||
ListViewItem insertatitem = base.GetItemAt(cp.X, cp.Y);
|
||||
|
||||
// Leave when nowhere to insert or same as selected item
|
||||
if((insertatitem == null) || (dragitems.Contains(insertatitem))) return;
|
||||
|
@ -87,14 +83,14 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
base.BeginUpdate();
|
||||
|
||||
// Determine index where to insert
|
||||
dropindex = insertatitem.Index;
|
||||
int dropindex = insertatitem.Index;
|
||||
if(dropindex > dragitems[0].Index) dropindex++;
|
||||
|
||||
// Deselect items
|
||||
DeselectAll();
|
||||
|
||||
// Insert items
|
||||
for(i = dragitems.Count - 1; i >= 0; i--)
|
||||
for(int i = dragitems.Count - 1; i >= 0; i--)
|
||||
{
|
||||
// Insert a copy of the item here
|
||||
base.Items.Insert(dropindex, (ListViewItem)dragitems[i].Clone());
|
||||
|
@ -116,10 +112,6 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
// When items are dragged over
|
||||
protected override void OnDragOver(DragEventArgs e)
|
||||
{
|
||||
int dropindex, i;
|
||||
ListViewItem insertatitem;
|
||||
Point cp;
|
||||
|
||||
//mxd. Check if valid extenal data is present
|
||||
if(e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
{
|
||||
|
@ -136,11 +128,11 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
|
||||
// Check if the data matches our data
|
||||
String text = (String)e.Data.GetData(DRAG_TYPE.GetType());
|
||||
if(text.CompareTo(DRAG_TYPE + this.Name) == 0)
|
||||
if(String.Compare(text, DRAG_TYPE + this.Name, StringComparison.Ordinal) == 0)
|
||||
{
|
||||
// Determine where to insert
|
||||
cp = base.PointToClient(new Point(e.X, e.Y));
|
||||
insertatitem = base.GetItemAt(cp.X, cp.Y);
|
||||
Point cp = base.PointToClient(new Point(e.X, e.Y));
|
||||
ListViewItem insertatitem = base.GetItemAt(cp.X, cp.Y);
|
||||
if(insertatitem == null)
|
||||
{
|
||||
// Cannot insert here
|
||||
|
@ -174,7 +166,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
insertatitem.EnsureVisible();
|
||||
|
||||
// Determine index where to insert
|
||||
dropindex = insertatitem.Index;
|
||||
int dropindex = insertatitem.Index;
|
||||
if(dropindex > dragitems[0].Index) dropindex++;
|
||||
|
||||
// Begin updating
|
||||
|
@ -184,7 +176,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
DeselectAll();
|
||||
|
||||
// Insert items
|
||||
for(i = dragitems.Count - 1; i >= 0; i--)
|
||||
for(int i = dragitems.Count - 1; i >= 0; i--)
|
||||
{
|
||||
// Insert a copy of the item here
|
||||
base.Items.Insert(dropindex, (ListViewItem)dragitems[i].Clone());
|
||||
|
|
|
@ -172,10 +172,10 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
}
|
||||
|
||||
// Preprocess the file
|
||||
AcsParserSE parser = new AcsParserSE { OnInclude = (se, path) => se.Parse(General.Map.Data.LoadFile(path), path, true, true, false) };
|
||||
AcsParserSE parser = new AcsParserSE { OnInclude = (se, path, includetype) => se.Parse(General.Map.Data.LoadFile(path), path, true, includetype, false) };
|
||||
using(FileStream stream = File.OpenRead(filepathname))
|
||||
{
|
||||
if(!parser.Parse(stream, filepathname, scriptconfig.Compiler.Files, true, false, false))
|
||||
if(!parser.Parse(stream, filepathname, scriptconfig.Compiler.Files, true, AcsParserSE.IncludeType.NONE, false))
|
||||
{
|
||||
// Check for errors
|
||||
if(parser.HasError)
|
||||
|
|
|
@ -50,9 +50,6 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
// This shows the info
|
||||
public void ShowInfo(Thing t)
|
||||
{
|
||||
string actioninfo;
|
||||
string zinfo;
|
||||
|
||||
// Show/hide stuff depending on format
|
||||
bool hasArgs = General.Map.FormatInterface.HasActionArgs;
|
||||
arglbl1.Visible = hasArgs;
|
||||
|
@ -83,10 +80,11 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
if(General.Map.Config.LinedefActions.ContainsKey(t.Action)) act = General.Map.Config.LinedefActions[t.Action];
|
||||
else if(t.Action == 0) act = new LinedefActionInfo(0, "None", true, false);
|
||||
else act = new LinedefActionInfo(t.Action, "Unknown", false, false);
|
||||
actioninfo = act.ToString();
|
||||
string actioninfo = act.ToString();
|
||||
|
||||
// Determine z info to show
|
||||
t.DetermineSector();
|
||||
string zinfo;
|
||||
if(ti.AbsoluteZ || t.Sector == null)
|
||||
{
|
||||
zinfo = t.Position.z.ToString(CultureInfo.InvariantCulture) + " (abs.)"; //mxd
|
||||
|
|
|
@ -45,19 +45,16 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This creates a list from a configuration structure
|
||||
internal DataLocationList(Configuration cfg, string path)
|
||||
{
|
||||
IDictionary resinfo, rlinfo;
|
||||
DataLocation res;
|
||||
|
||||
// Go for all items in the map info
|
||||
resinfo = cfg.ReadSetting(path, new ListDictionary());
|
||||
IDictionary resinfo = cfg.ReadSetting(path, new ListDictionary());
|
||||
foreach(DictionaryEntry rl in resinfo)
|
||||
{
|
||||
// Item is a structure?
|
||||
if(rl.Value is IDictionary)
|
||||
{
|
||||
// Create resource location
|
||||
rlinfo = (IDictionary)rl.Value;
|
||||
res = new DataLocation();
|
||||
IDictionary rlinfo = (IDictionary)rl.Value;
|
||||
DataLocation res = new DataLocation();
|
||||
|
||||
// Copy information from Configuration to ResourceLocation
|
||||
if(rlinfo.Contains("type") && (rlinfo["type"] is int)) res.type = (int)rlinfo["type"];
|
||||
|
@ -88,14 +85,12 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This writes the list to configuration
|
||||
internal void WriteToConfig(Configuration cfg, string path)
|
||||
{
|
||||
IDictionary resinfo, rlinfo;
|
||||
|
||||
// Fill structure
|
||||
resinfo = new ListDictionary();
|
||||
IDictionary resinfo = new ListDictionary();
|
||||
for(int i = 0; i < this.Count; i++)
|
||||
{
|
||||
// Create structure for resource
|
||||
rlinfo = new ListDictionary();
|
||||
IDictionary rlinfo = new ListDictionary();
|
||||
rlinfo.Add("type", this[i].type);
|
||||
rlinfo.Add("location", this[i].location);
|
||||
rlinfo.Add("option1", General.Bool2Int(this[i].option1));
|
||||
|
@ -113,7 +108,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
//mxd
|
||||
public bool IsValid()
|
||||
{
|
||||
foreach (DataLocation location in this) if (!location.IsValid()) return false;
|
||||
foreach(DataLocation location in this) if (!location.IsValid()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -264,12 +264,10 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This loads all data resources
|
||||
internal void Load(DataLocationList locations)
|
||||
{
|
||||
int texcount, flatcount, spritecount, thingcount, colormapcount;
|
||||
Dictionary<long, ImageData> texturesonly = new Dictionary<long, ImageData>();
|
||||
Dictionary<long, ImageData> colormapsonly = new Dictionary<long, ImageData>();
|
||||
Dictionary<long, ImageData> flatsonly = new Dictionary<long, ImageData>();
|
||||
DataReader c;
|
||||
|
||||
|
||||
// Create collections
|
||||
containers = new List<DataReader>();
|
||||
textures = new Dictionary<long, ImageData>();
|
||||
|
@ -303,7 +301,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
foreach(DataLocation dl in locations)
|
||||
{
|
||||
// Nothing chosen yet
|
||||
c = null;
|
||||
DataReader c = null;
|
||||
|
||||
// TODO: Make this work more elegant using reflection.
|
||||
// Make DataLocation.type of type Type and assign the
|
||||
|
@ -348,9 +346,9 @@ namespace CodeImp.DoomBuilder.Data
|
|||
|
||||
// Load stuff
|
||||
LoadPalette();
|
||||
texcount = LoadTextures(texturesonly, texturenamesshorttofull);
|
||||
flatcount = LoadFlats(flatsonly, flatnamesshorttofull);
|
||||
colormapcount = LoadColormaps(colormapsonly);
|
||||
int texcount = LoadTextures(texturesonly, texturenamesshorttofull);
|
||||
int flatcount = LoadFlats(flatsonly, flatnamesshorttofull);
|
||||
int colormapcount = LoadColormaps(colormapsonly);
|
||||
LoadSprites();
|
||||
|
||||
//mxd. Load MAPINFO. Should happen before parisng DECORATE
|
||||
|
@ -358,8 +356,8 @@ namespace CodeImp.DoomBuilder.Data
|
|||
Dictionary<int, string> doomednums;
|
||||
LoadMapInfo(out spawnnums, out doomednums);
|
||||
|
||||
thingcount = LoadDecorateThings(spawnnums, doomednums);
|
||||
spritecount = LoadThingSprites();
|
||||
int thingcount = LoadDecorateThings(spawnnums, doomednums);
|
||||
int spritecount = LoadThingSprites();
|
||||
LoadInternalSprites();
|
||||
|
||||
//mxd. Load more stuff
|
||||
|
|
|
@ -55,11 +55,10 @@ namespace CodeImp.DoomBuilder.Data
|
|||
public PatchNames(Stream stream)
|
||||
{
|
||||
BinaryReader reader = new BinaryReader(stream);
|
||||
uint length;
|
||||
|
||||
|
||||
// Read length of array
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
length = reader.ReadUInt32();
|
||||
uint length = reader.ReadUInt32();
|
||||
|
||||
// Create array
|
||||
pnames = new string[length];
|
||||
|
|
|
@ -278,15 +278,12 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This loads a range of colormaps
|
||||
private void LoadColormapsRange(string startlump, string endlump, ref List<ImageData> images)
|
||||
{
|
||||
int startindex, endindex;
|
||||
ColormapImage image;
|
||||
|
||||
// Continue until no more start can be found
|
||||
startindex = file.FindLumpIndex(startlump);
|
||||
int startindex = file.FindLumpIndex(startlump);
|
||||
while(startindex > -1)
|
||||
{
|
||||
// Find end index
|
||||
endindex = file.FindLumpIndex(endlump, startindex + 1);
|
||||
int endindex = file.FindLumpIndex(endlump, startindex + 1);
|
||||
if(endindex > -1)
|
||||
{
|
||||
// Go for all lumps between start and end exclusive
|
||||
|
@ -296,7 +293,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
if(file.Lumps[i].Length > 0)
|
||||
{
|
||||
// Make the image object
|
||||
image = new ColormapImage(file.Lumps[i].Name);
|
||||
ColormapImage image = new ColormapImage(file.Lumps[i].Name);
|
||||
|
||||
// Add image to collection
|
||||
images.Add(image);
|
||||
|
@ -315,22 +312,20 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// Error when suspended
|
||||
if(issuspended) throw new Exception("Data reader is suspended");
|
||||
|
||||
Lump lump;
|
||||
|
||||
// Strictly read patches only between C_START and C_END?
|
||||
if(strictpatches)
|
||||
{
|
||||
// Find the lump in ranges
|
||||
foreach(LumpRange range in colormapranges)
|
||||
{
|
||||
lump = file.FindLump(pname, range.start, range.end);
|
||||
Lump lump = file.FindLump(pname, range.start, range.end);
|
||||
if(lump != null) return lump.Stream;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find the lump anywhere
|
||||
lump = file.FindLump(pname);
|
||||
Lump lump = file.FindLump(pname);
|
||||
if(lump != null) return lump.Stream;
|
||||
}
|
||||
|
||||
|
@ -422,23 +417,15 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// This loads a set of textures
|
||||
public static void LoadTextureSet(string sourcename, Stream texturedata, ref List<ImageData> images, PatchNames pnames)
|
||||
{
|
||||
BinaryReader reader = new BinaryReader(texturedata);
|
||||
int flags, width, height, patches, px, py, pi;
|
||||
uint numtextures;
|
||||
byte scalebytex, scalebytey;
|
||||
float scalex, scaley, defaultscale;
|
||||
byte[] namebytes;
|
||||
TextureImage image = null;
|
||||
bool strifedata;
|
||||
|
||||
if(texturedata.Length == 0) return;
|
||||
BinaryReader reader = new BinaryReader(texturedata);
|
||||
|
||||
// Determine default scale
|
||||
defaultscale = General.Map.Config.DefaultTextureScale;
|
||||
float defaultscale = General.Map.Config.DefaultTextureScale;
|
||||
|
||||
// Get number of textures
|
||||
texturedata.Seek(0, SeekOrigin.Begin);
|
||||
numtextures = reader.ReadUInt32();
|
||||
uint numtextures = reader.ReadUInt32();
|
||||
|
||||
// Skip offset bytes (we will read all textures sequentially)
|
||||
texturedata.Seek(4 * numtextures, SeekOrigin.Current);
|
||||
|
@ -447,15 +434,16 @@ namespace CodeImp.DoomBuilder.Data
|
|||
for(uint i = 0; i < numtextures; i++)
|
||||
{
|
||||
// Read texture properties
|
||||
namebytes = reader.ReadBytes(8);
|
||||
flags = reader.ReadUInt16();
|
||||
scalebytex = reader.ReadByte();
|
||||
scalebytey = reader.ReadByte();
|
||||
width = reader.ReadInt16();
|
||||
height = reader.ReadInt16();
|
||||
patches = reader.ReadInt16();
|
||||
byte[] namebytes = reader.ReadBytes(8);
|
||||
int flags = reader.ReadUInt16();
|
||||
byte scalebytex = reader.ReadByte();
|
||||
byte scalebytey = reader.ReadByte();
|
||||
int width = reader.ReadInt16();
|
||||
int height = reader.ReadInt16();
|
||||
int patches = reader.ReadInt16();
|
||||
|
||||
// Check for doom or strife data format
|
||||
bool strifedata;
|
||||
if(patches == 0)
|
||||
{
|
||||
// Ignore 2 bytes and then read number of patches
|
||||
|
@ -470,14 +458,14 @@ namespace CodeImp.DoomBuilder.Data
|
|||
}
|
||||
|
||||
// Determine actual scales
|
||||
if(scalebytex == 0) scalex = defaultscale; else scalex = 1f / (scalebytex / 8f);
|
||||
if(scalebytey == 0) scaley = defaultscale; else scaley = 1f / (scalebytey / 8f);
|
||||
float scalex = (scalebytex == 0 ? defaultscale : 1f / (scalebytex / 8f));
|
||||
float scaley = (scalebytey == 0 ? defaultscale : 1f / (scalebytey / 8f));
|
||||
|
||||
// Validate data
|
||||
if((width > 0) && (height > 0) && (patches > 0) &&
|
||||
(scalex != 0) || (scaley != 0))
|
||||
if((width > 0) && (height > 0) && (patches > 0) && (scalex != 0) || (scaley != 0))
|
||||
{
|
||||
string texname = Lump.MakeNormalName(namebytes, WAD.ENCODING);
|
||||
TextureImage image = null;
|
||||
if(texname.Length > 0)
|
||||
{
|
||||
// Make the image object
|
||||
|
@ -494,9 +482,9 @@ namespace CodeImp.DoomBuilder.Data
|
|||
for(int p = 0; p < patches; p++)
|
||||
{
|
||||
// Read patch properties
|
||||
px = reader.ReadInt16();
|
||||
py = reader.ReadInt16();
|
||||
pi = reader.ReadUInt16();
|
||||
int px = reader.ReadInt16();
|
||||
int py = reader.ReadInt16();
|
||||
int pi = reader.ReadUInt16();
|
||||
if(!strifedata) texturedata.Seek(4, SeekOrigin.Current);
|
||||
|
||||
// Validate data
|
||||
|
|
|
@ -378,15 +378,13 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
// This zooms and moves to view the given area
|
||||
public void CenterOnArea(RectangleF area, float padding)
|
||||
{
|
||||
float scalew, scaleh, scale;
|
||||
|
||||
// Add size to the area for better overview
|
||||
area.Inflate(area.Width * padding, area.Height * padding);
|
||||
|
||||
// Calculate scale to view map at
|
||||
scalew = General.Map.Graphics.RenderTarget.ClientSize.Width / area.Width;
|
||||
scaleh = General.Map.Graphics.RenderTarget.ClientSize.Height / area.Height;
|
||||
scale = scalew < scaleh ? scalew : scaleh;
|
||||
float scalew = General.Map.Graphics.RenderTarget.ClientSize.Width / area.Width;
|
||||
float scaleh = General.Map.Graphics.RenderTarget.ClientSize.Height / area.Height;
|
||||
float scale = scalew < scaleh ? scalew : scaleh;
|
||||
|
||||
//mxd. Change the view to see the whole map
|
||||
CenterOnCoordinates(new Vector2D(area.Left + area.Width * 0.5f, area.Top + area.Height * 0.5f), scale);
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
{
|
||||
internal sealed class AcsParserSE : ZDTextParser
|
||||
{
|
||||
internal delegate void IncludeDelegate(AcsParserSE parser, string includefile);
|
||||
internal delegate void IncludeDelegate(AcsParserSE parser, string includefile, IncludeType includetype);
|
||||
internal IncludeDelegate OnInclude;
|
||||
|
||||
private readonly HashSet<string> parsedlumps;
|
||||
|
@ -32,6 +32,13 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
internal bool AddArgumentsToScriptNames;
|
||||
internal bool IsMapScriptsLump;
|
||||
|
||||
internal enum IncludeType
|
||||
{
|
||||
NONE,
|
||||
INCLUDE,
|
||||
LIBRARY
|
||||
}
|
||||
|
||||
internal AcsParserSE()
|
||||
{
|
||||
namedscripts = new List<ScriptItem>();
|
||||
|
@ -45,15 +52,15 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
|
||||
public override bool Parse(Stream stream, string sourcefilename, bool clearerrors)
|
||||
{
|
||||
return Parse(stream, sourcefilename, new HashSet<string>(), false, false, clearerrors);
|
||||
return Parse(stream, sourcefilename, new HashSet<string>(), false, IncludeType.NONE, clearerrors);
|
||||
}
|
||||
|
||||
public bool Parse(Stream stream, string sourcefilename, bool processincludes, bool isinclude, bool clearerrors)
|
||||
public bool Parse(Stream stream, string sourcefilename, bool processincludes, IncludeType includetype, bool clearerrors)
|
||||
{
|
||||
return Parse(stream, sourcefilename, includestoskip, processincludes, isinclude, clearerrors);
|
||||
return Parse(stream, sourcefilename, includestoskip, processincludes, includetype, clearerrors);
|
||||
}
|
||||
|
||||
public bool Parse(Stream stream, string sourcefilename, HashSet<string> configincludes, bool processincludes, bool isinclude, bool clearerrors)
|
||||
public bool Parse(Stream stream, string sourcefilename, HashSet<string> configincludes, bool processincludes, IncludeType includetype, bool clearerrors)
|
||||
{
|
||||
string source = sourcefilename.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
||||
|
||||
|
@ -109,7 +116,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
if(AddArgumentsToScriptNames) scriptname += " " + GetArgumentNames(args);
|
||||
|
||||
// Add to collection
|
||||
namedscripts.Add(new ScriptItem(scriptname, argnames, startpos, isinclude));
|
||||
namedscripts.Add(new ScriptItem(scriptname, argnames, startpos, includetype != IncludeType.NONE));
|
||||
}
|
||||
else //should be numbered script
|
||||
{
|
||||
|
@ -150,7 +157,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
if(AddArgumentsToScriptNames) name += " " + GetArgumentNames(args);
|
||||
|
||||
// Add to collection
|
||||
numberedscripts.Add(new ScriptItem(n, name, argnames, startpos, isinclude, customname));
|
||||
numberedscripts.Add(new ScriptItem(n, name, argnames, startpos, includetype != IncludeType.NONE, customname));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +180,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
if(AddArgumentsToScriptNames) funcname += GetArgumentNames(args);
|
||||
|
||||
// Add to collection
|
||||
functions.Add(new ScriptItem(funcname, argnames, startpos, isinclude));
|
||||
functions.Add(new ScriptItem(funcname, argnames, startpos, includetype != IncludeType.NONE));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -185,22 +192,29 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
}
|
||||
|
||||
SkipWhitespace(true);
|
||||
libraryname = ReadToken(false); // Don't skip newline
|
||||
string libname = ReadToken(false); // Don't skip newline
|
||||
|
||||
if(!libraryname.StartsWith("\"") || !libraryname.EndsWith("\""))
|
||||
if(!libname.StartsWith("\"") || !libname.EndsWith("\""))
|
||||
{
|
||||
ReportError("#library name should be quoted");
|
||||
return false;
|
||||
}
|
||||
|
||||
libraryname = StripTokenQuotes(libraryname);
|
||||
libname = StripTokenQuotes(libname);
|
||||
|
||||
if(string.IsNullOrEmpty(libraryname))
|
||||
if(string.IsNullOrEmpty(libname))
|
||||
{
|
||||
ReportError("Expected library name");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store only when the script compiling was executed for is library
|
||||
if(includetype == IncludeType.NONE)
|
||||
{
|
||||
libraryname = libname;
|
||||
includetype = IncludeType.LIBRARY;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -210,6 +224,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
//and can use forward and backward slashes ("acs\map01/script.acs")
|
||||
//also include paths must be quoted
|
||||
//long filenames are supported
|
||||
bool islibrary = (token == "#import" || includetype == IncludeType.LIBRARY);
|
||||
SkipWhitespace(true);
|
||||
string includelump = ReadToken(false); // Don't skip newline
|
||||
|
||||
|
@ -232,7 +247,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
// Compiler files?
|
||||
if(includestoskip.Contains(includelump)) continue;
|
||||
|
||||
// Already parsed this?
|
||||
// Convert to a path we can use
|
||||
string includelumppath = GetRootedPath(source, includelump);
|
||||
|
||||
// Rooting succeeded?
|
||||
|
@ -241,25 +256,34 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
// Already parsed?
|
||||
if(includes.Contains(includelumppath))
|
||||
{
|
||||
ReportError("Already parsed '" + includelump + "'. Check your " + token + " directives");
|
||||
return false;
|
||||
//INFO: files included or imported inside a library are not visible to the code outside it
|
||||
//and must be included/imported separately
|
||||
if(!islibrary)
|
||||
{
|
||||
ReportError("Already parsed '" + includelump + "'. Check your " + token + " directives");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add to collections
|
||||
includes.Add(includelumppath);
|
||||
|
||||
// Add to collections
|
||||
includes.Add(includelumppath);
|
||||
|
||||
// Callback to parse this file
|
||||
if(OnInclude != null) OnInclude(this, includelumppath);
|
||||
// Callback to parse this file
|
||||
if(OnInclude != null)
|
||||
{
|
||||
OnInclude(this, includelumppath, islibrary ? IncludeType.LIBRARY : IncludeType.INCLUDE);
|
||||
}
|
||||
|
||||
// Bail out on error
|
||||
if(this.HasError) return false;
|
||||
// Bail out on error
|
||||
if(this.HasError) return false;
|
||||
|
||||
// Set our buffers back to continue parsing
|
||||
datastream = localstream;
|
||||
datareader = localreader;
|
||||
sourcename = localsourcename;
|
||||
// Set our buffers back to continue parsing
|
||||
datastream = localstream;
|
||||
datareader = localreader;
|
||||
sourcename = localsourcename;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -408,9 +408,6 @@ namespace CodeImp.DoomBuilder
|
|||
// This loads all script configurations
|
||||
private static void LoadAllScriptConfigurations()
|
||||
{
|
||||
Configuration cfg;
|
||||
string[] filenames;
|
||||
|
||||
// Display status
|
||||
mainwindow.DisplayStatus(StatusType.Busy, "Loading script configurations...");
|
||||
|
||||
|
@ -419,14 +416,14 @@ namespace CodeImp.DoomBuilder
|
|||
compiledscriptconfigs = new Dictionary<string, ScriptConfiguration>(StringComparer.Ordinal); //mxd
|
||||
|
||||
// Go for all cfg files in the scripts directory
|
||||
filenames = Directory.GetFiles(scriptspath, "*.cfg", SearchOption.TopDirectoryOnly);
|
||||
string[] filenames = Directory.GetFiles(scriptspath, "*.cfg", SearchOption.TopDirectoryOnly);
|
||||
foreach(string filepath in filenames)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Try loading the configuration
|
||||
cfg = new Configuration(filepath, true);
|
||||
|
||||
Configuration cfg = new Configuration(filepath, true);
|
||||
|
||||
// Check for erors
|
||||
if(cfg.ErrorResult)
|
||||
{
|
||||
|
@ -466,10 +463,7 @@ namespace CodeImp.DoomBuilder
|
|||
// This loads all compiler configurations
|
||||
private static void LoadAllCompilerConfigurations()
|
||||
{
|
||||
Configuration cfg;
|
||||
Dictionary<string, CompilerInfo> addedcompilers = new Dictionary<string, CompilerInfo>(StringComparer.Ordinal);
|
||||
IDictionary compilerslist;
|
||||
string[] filenames;
|
||||
|
||||
// Display status
|
||||
mainwindow.DisplayStatus(StatusType.Busy, "Loading compiler configurations...");
|
||||
|
@ -478,13 +472,13 @@ namespace CodeImp.DoomBuilder
|
|||
compilers = new List<CompilerInfo>();
|
||||
|
||||
// Go for all cfg files in the compilers directory
|
||||
filenames = Directory.GetFiles(compilerspath, "*.cfg", SearchOption.AllDirectories);
|
||||
string[] filenames = Directory.GetFiles(compilerspath, "*.cfg", SearchOption.AllDirectories);
|
||||
foreach(string filepath in filenames)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Try loading the configuration
|
||||
cfg = new Configuration(filepath, true);
|
||||
Configuration cfg = new Configuration(filepath, true);
|
||||
|
||||
// Check for erors
|
||||
if(cfg.ErrorResult)
|
||||
|
@ -496,7 +490,7 @@ namespace CodeImp.DoomBuilder
|
|||
else
|
||||
{
|
||||
// Get structures
|
||||
compilerslist = cfg.ReadSetting("compilers", new Hashtable());
|
||||
IDictionary compilerslist = cfg.ReadSetting("compilers", new Hashtable());
|
||||
foreach(DictionaryEntry de in compilerslist)
|
||||
{
|
||||
// Check if this is a structure
|
||||
|
|
|
@ -342,7 +342,6 @@ namespace CodeImp.DoomBuilder
|
|||
internal bool InitializeOpenMap(string filepathname, MapOptions options)
|
||||
{
|
||||
WAD mapwad;
|
||||
string tempfile;
|
||||
|
||||
#if DEBUG
|
||||
DebugConsole.Clear();
|
||||
|
@ -378,7 +377,7 @@ namespace CodeImp.DoomBuilder
|
|||
map = new MapSet();
|
||||
|
||||
// Create temp wadfile
|
||||
tempfile = General.MakeTempFilename(temppath);
|
||||
string tempfile = General.MakeTempFilename(temppath);
|
||||
General.WriteLogLine("Creating temporary file: " + tempfile);
|
||||
#if DEBUG
|
||||
tempwad = new WAD(tempfile);
|
||||
|
@ -1928,10 +1927,10 @@ namespace CodeImp.DoomBuilder
|
|||
if(stream != null && stream.Length > 0 && scriptconfig != null && scriptconfig.Compiler != null)
|
||||
{
|
||||
// Get script names
|
||||
AcsParserSE parser = new AcsParserSE { OnInclude = (se, path) => se.Parse(General.Map.Data.LoadFile(path), path, true, true, false) };
|
||||
AcsParserSE parser = new AcsParserSE { OnInclude = (se, path, includetype) => se.Parse(General.Map.Data.LoadFile(path), path, true, includetype, false) };
|
||||
|
||||
//INFO: CompileLump() prepends lumpname with "?" to distinguish between temporary files and files compiled in place
|
||||
if(parser.Parse(stream, "?SCRIPTS", scriptconfig.Compiler.Files, true, false, false))
|
||||
if(parser.Parse(stream, "?SCRIPTS", scriptconfig.Compiler.Files, true, AcsParserSE.IncludeType.NONE, false))
|
||||
{
|
||||
// Add them to arrays
|
||||
namedscriptslist.AddRange(parser.NamedScripts);
|
||||
|
|
|
@ -71,10 +71,8 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
// This returns the difference between two angles
|
||||
public static float Difference(float a, float b)
|
||||
{
|
||||
float d;
|
||||
|
||||
// Calculate delta angle
|
||||
d = Normalized(a) - Normalized(b);
|
||||
float d = Normalized(a) - Normalized(b);
|
||||
|
||||
// Make corrections for zero barrier
|
||||
if(d < 0f) d += PI2;
|
||||
|
|
|
@ -27,9 +27,9 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
public sealed class LinedefAngleSorter : IComparer<Linedef>
|
||||
{
|
||||
// Variables
|
||||
private Linedef baseline;
|
||||
private bool front;
|
||||
private Vertex basevertex;
|
||||
private readonly Linedef baseline;
|
||||
private readonly bool front;
|
||||
private readonly Vertex basevertex;
|
||||
|
||||
// Constructor
|
||||
public LinedefAngleSorter(Linedef baseline, bool front, Vertex fromvertex)
|
||||
|
@ -48,22 +48,19 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
// This calculates the relative angle between two lines
|
||||
private float CalculateRelativeAngle(Linedef a, Linedef b)
|
||||
{
|
||||
float s, n, ana, anb;
|
||||
Vector2D va, vb;
|
||||
|
||||
// Determine angles
|
||||
ana = a.Angle; if(a.End == basevertex) ana += Angle2D.PI;
|
||||
anb = b.Angle; if(b.End == basevertex) anb += Angle2D.PI;
|
||||
float ana = a.Angle; if(a.End == basevertex) ana += Angle2D.PI;
|
||||
float anb = b.Angle; if(b.End == basevertex) anb += Angle2D.PI;
|
||||
|
||||
// Take the difference from angles
|
||||
n = Angle2D.Difference(ana, anb);
|
||||
float n = Angle2D.Difference(ana, anb);
|
||||
|
||||
// Get line end vertices a and b that are not connected to basevertex
|
||||
if(a.Start == basevertex) va = a.End.Position; else va = a.Start.Position;
|
||||
if(b.Start == basevertex) vb = b.End.Position; else vb = b.Start.Position;
|
||||
Vector2D va = (a.Start == basevertex ? a.End.Position : a.Start.Position);
|
||||
Vector2D vb = (b.Start == basevertex ? b.End.Position : b.Start.Position);
|
||||
|
||||
// Check to which side the angle goes and adjust angle as needed
|
||||
s = Line2D.GetSideOfLine(va, vb, basevertex.Position);
|
||||
float s = Line2D.GetSideOfLine(va, vb, basevertex.Position);
|
||||
if(((s < 0) && front) || ((s > 0) && !front)) n = Angle2D.PI2 - n;
|
||||
|
||||
// Return result
|
||||
|
@ -73,11 +70,9 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
// Comparer
|
||||
public int Compare(Linedef x, Linedef y)
|
||||
{
|
||||
float ax, ay;
|
||||
|
||||
// Calculate angles
|
||||
ax = CalculateRelativeAngle(baseline, x);
|
||||
ay = CalculateRelativeAngle(baseline, y);
|
||||
float ax = CalculateRelativeAngle(baseline, x);
|
||||
float ay = CalculateRelativeAngle(baseline, y);
|
||||
|
||||
// Compare results
|
||||
/*
|
||||
|
|
|
@ -44,27 +44,23 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
// This calculates the relative angle between two sides
|
||||
private float CalculateRelativeAngle(Sidedef a, Sidedef b)
|
||||
{
|
||||
float s, n, ana, anb;
|
||||
Vector2D va, vb;
|
||||
bool dir;
|
||||
|
||||
// Determine angles
|
||||
ana = a.Line.Angle; if(a.Line.End == basevertex) ana += Angle2D.PI;
|
||||
anb = b.Line.Angle; if(b.Line.End == basevertex) anb += Angle2D.PI;
|
||||
float ana = a.Line.Angle; if(a.Line.End == basevertex) ana += Angle2D.PI;
|
||||
float anb = b.Line.Angle; if(b.Line.End == basevertex) anb += Angle2D.PI;
|
||||
|
||||
// Take the difference from angles
|
||||
n = Angle2D.Difference(ana, anb);
|
||||
float n = Angle2D.Difference(ana, anb);
|
||||
|
||||
// Get line end vertices a and b that are not connected to basevertex
|
||||
if(a.Line.Start == basevertex) va = a.Line.End.Position; else va = a.Line.Start.Position;
|
||||
if(b.Line.Start == basevertex) vb = b.Line.End.Position; else vb = b.Line.Start.Position;
|
||||
Vector2D va = (a.Line.Start == basevertex ? a.Line.End.Position : a.Line.Start.Position);
|
||||
Vector2D vb = (b.Line.Start == basevertex ? b.Line.End.Position : b.Line.Start.Position);
|
||||
|
||||
// Determine rotation direction
|
||||
dir = baseside.IsFront;
|
||||
bool dir = baseside.IsFront;
|
||||
if(baseside.Line.End == basevertex) dir = !dir;
|
||||
|
||||
// Check to which side the angle goes and adjust angle as needed
|
||||
s = Line2D.GetSideOfLine(va, vb, basevertex.Position);
|
||||
float s = Line2D.GetSideOfLine(va, vb, basevertex.Position);
|
||||
if((s < 0) && dir) n = Angle2D.PI2 - n;
|
||||
if((s > 0) && !dir) n = Angle2D.PI2 - n;
|
||||
|
||||
|
@ -77,8 +73,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
{
|
||||
// Somehow, in a release build without debugger attached,
|
||||
// the code above is not always the same when x == y... don't ask.
|
||||
if(x == y)
|
||||
return 0;
|
||||
if(x == y) return 0;
|
||||
|
||||
// Calculate angles
|
||||
float ax = CalculateRelativeAngle(baseside, x);
|
||||
|
|
|
@ -1148,8 +1148,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
{
|
||||
foreach(LinedefSide endp in endpoints)
|
||||
{
|
||||
List<LinedefSide> p;
|
||||
p = Tools.FindClosestPath(startp.Line, startp.Front, endp.Line, endp.Front, true);
|
||||
List<LinedefSide> p = Tools.FindClosestPath(startp.Line, startp.Front, endp.Line, endp.Front, true);
|
||||
if((p != null) && ((shortestpath == null) || (p.Count < shortestpath.Count))) shortestpath = p;
|
||||
p = Tools.FindClosestPath(endp.Line, endp.Front, startp.Line, startp.Front, true);
|
||||
if((p != null) && ((shortestpath == null) || (p.Count < shortestpath.Count))) shortestpath = p;
|
||||
|
|
|
@ -94,16 +94,15 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
// Constructor
|
||||
public Triangulation()
|
||||
{
|
||||
islandvertices = Array.AsReadOnly<int>(new int[0]);
|
||||
vertices = Array.AsReadOnly<Vector2D>(new Vector2D[0]);
|
||||
sidedefs = Array.AsReadOnly<Sidedef>(new Sidedef[0]);
|
||||
islandvertices = Array.AsReadOnly(new int[0]);
|
||||
vertices = Array.AsReadOnly(new Vector2D[0]);
|
||||
sidedefs = Array.AsReadOnly(new Sidedef[0]);
|
||||
}
|
||||
|
||||
// This performs the triangulation
|
||||
public void Triangulate(Sector s)
|
||||
{
|
||||
// Initialize
|
||||
List<EarClipPolygon> polys;
|
||||
List<int> islandslist = new List<int>();
|
||||
List<Vector2D> verticeslist = new List<Vector2D>();
|
||||
List<Sidedef> sidedefslist = new List<Sidedef>();
|
||||
|
@ -126,7 +125,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
*/
|
||||
|
||||
// TRACING
|
||||
polys = DoTrace(s);
|
||||
List<EarClipPolygon> polys = DoTrace(s);
|
||||
|
||||
// CUTTING
|
||||
DoCutting(polys);
|
||||
|
@ -136,9 +135,9 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
islandslist.Add(DoEarClip(p, verticeslist, sidedefslist));
|
||||
|
||||
// Make arrays
|
||||
islandvertices = Array.AsReadOnly<int>(islandslist.ToArray());
|
||||
vertices = Array.AsReadOnly<Vector2D>(verticeslist.ToArray());
|
||||
sidedefs = Array.AsReadOnly<Sidedef>(sidedefslist.ToArray());
|
||||
islandvertices = Array.AsReadOnly(islandslist.ToArray());
|
||||
vertices = Array.AsReadOnly(verticeslist.ToArray());
|
||||
sidedefs = Array.AsReadOnly(sidedefslist.ToArray());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -172,12 +171,12 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
s.rInt(out c);
|
||||
int[] islandverticeslist = new int[c];
|
||||
for(int i = 0; i < c; i++) s.rInt(out islandverticeslist[i]);
|
||||
islandvertices = Array.AsReadOnly<int>(islandverticeslist);
|
||||
islandvertices = Array.AsReadOnly(islandverticeslist);
|
||||
|
||||
s.rInt(out c);
|
||||
Vector2D[] verticeslist = new Vector2D[c];
|
||||
for(int i = 0; i < c; i++) s.rVector2D(out verticeslist[i]);
|
||||
vertices = Array.AsReadOnly<Vector2D>(verticeslist);
|
||||
vertices = Array.AsReadOnly(verticeslist);
|
||||
|
||||
s.rInt(out c);
|
||||
sidedefindices = new int[c];
|
||||
|
@ -202,7 +201,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
sidedefindices = null;
|
||||
|
||||
// Keep readonly array
|
||||
sidedefs = Array.AsReadOnly<Sidedef>(sides.ToArray());
|
||||
sidedefs = Array.AsReadOnly(sides.ToArray());
|
||||
}
|
||||
|
||||
|
||||
|
@ -216,10 +215,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
Dictionary<Sidedef, bool> todosides = new Dictionary<Sidedef, bool>(s.Sidedefs.Count);
|
||||
Dictionary<Vertex, Vertex> ignores = new Dictionary<Vertex,Vertex>();
|
||||
List<EarClipPolygon> root = new List<EarClipPolygon>();
|
||||
SidedefsTracePath path;
|
||||
EarClipPolygon newpoly;
|
||||
Vertex start;
|
||||
|
||||
|
||||
// Fill the dictionary
|
||||
// The bool value is used to indicate lines which has been visited in the trace
|
||||
foreach(Sidedef sd in s.Sidedefs) todosides.Add(sd, false);
|
||||
|
@ -236,14 +232,14 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
// Find the right-most vertex to start a trace with.
|
||||
// This guarantees that we start out with an outer polygon and we just
|
||||
// have to check if it is inside a previously found polygon.
|
||||
start = FindRightMostVertex(todosides, ignores);
|
||||
Vertex start = FindRightMostVertex(todosides, ignores);
|
||||
|
||||
// No more possible start vertex found?
|
||||
// Then leave with what we have up till now.
|
||||
if(start == null) break;
|
||||
|
||||
// Trace to find a polygon
|
||||
path = DoTracePath(new SidedefsTracePath(), start, null, s, todosides);
|
||||
SidedefsTracePath path = DoTracePath(new SidedefsTracePath(), start, null, s, todosides);
|
||||
|
||||
// If tracing is not possible (sector not closed?)
|
||||
// then add the start to the ignore list and try again later
|
||||
|
@ -258,7 +254,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
foreach(Sidedef sd in path) todosides.Remove(sd);
|
||||
|
||||
// Create the polygon
|
||||
newpoly = path.MakePolygon();
|
||||
EarClipPolygon newpoly = path.MakePolygon();
|
||||
|
||||
// Determine where this polygon goes in our tree
|
||||
foreach(EarClipPolygon p in root)
|
||||
|
@ -291,11 +287,6 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
// or returns null when no path found.
|
||||
private static SidedefsTracePath DoTracePath(SidedefsTracePath history, Vertex fromhere, Vertex findme, Sector sector, Dictionary<Sidedef, bool> sides)
|
||||
{
|
||||
SidedefsTracePath nextpath;
|
||||
SidedefsTracePath result;
|
||||
Vertex nextvertex;
|
||||
List<Sidedef> allsides;
|
||||
|
||||
// Found the vertex we are tracing to?
|
||||
if(fromhere == findme) return history;
|
||||
|
||||
|
@ -304,7 +295,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
if(findme == null) findme = fromhere;
|
||||
|
||||
// Make a list of sides referring to the same sector
|
||||
allsides = new List<Sidedef>(fromhere.Linedefs.Count * 2);
|
||||
List<Sidedef> allsides = new List<Sidedef>(fromhere.Linedefs.Count * 2);
|
||||
foreach(Linedef l in fromhere.Linedefs)
|
||||
{
|
||||
// Should we go along the front or back side?
|
||||
|
@ -345,10 +336,10 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
{
|
||||
// Mark sidedef as visited and move to next vertex
|
||||
sides[s] = true;
|
||||
nextpath = new SidedefsTracePath(history, s);
|
||||
if(s.Line.Start == fromhere) nextvertex = s.Line.End; else nextvertex = s.Line.Start;
|
||||
SidedefsTracePath nextpath = new SidedefsTracePath(history, s);
|
||||
Vertex nextvertex = (s.Line.Start == fromhere ? s.Line.End : s.Line.Start);
|
||||
|
||||
result = DoTracePath(nextpath, nextvertex, findme, sector, sides);
|
||||
SidedefsTracePath result = DoTracePath(nextpath, nextvertex, findme, sector, sides);
|
||||
if(result != null) return result;
|
||||
}
|
||||
|
||||
|
@ -499,12 +490,10 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
// This finds the cut coordinates and splits the other poly with inner vertices
|
||||
private static void SplitOuterWithInner(LinkedListNode<EarClipVertex> start, EarClipPolygon p)
|
||||
{
|
||||
LinkedListNode<EarClipVertex> v1, v2;
|
||||
LinkedListNode<EarClipVertex> insertbefore = null;
|
||||
float u, ul, bonus, foundu = float.MaxValue;
|
||||
float u, ul, foundu = float.MaxValue;
|
||||
Vector2D foundpos = new Vector2D();
|
||||
EarClipVertex split;
|
||||
|
||||
|
||||
// Create a line from start that goes beyond the right most vertex of p
|
||||
LinkedListNode<EarClipVertex> pr = FindRightMostVertex(p);
|
||||
float startx = start.Value.Position.x;
|
||||
|
@ -512,18 +501,16 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
Line2D starttoright = new Line2D(start.Value.Position, new Vector2D(endx, start.Value.Position.y));
|
||||
|
||||
// Calculate a small bonus (0.1 mappixel)
|
||||
bonus = starttoright.GetNearestOnLine(new Vector2D(start.Value.Position.x + 0.1f, start.Value.Position.y));
|
||||
float bonus = starttoright.GetNearestOnLine(new Vector2D(start.Value.Position.x + 0.1f, start.Value.Position.y));
|
||||
|
||||
// Go for all lines in the outer polygon
|
||||
v1 = p.Last;
|
||||
v2 = p.First;
|
||||
LinkedListNode<EarClipVertex> v1 = p.Last;
|
||||
LinkedListNode<EarClipVertex> v2 = p.First;
|
||||
while(v2 != null)
|
||||
{
|
||||
// Check if the line goes between startx and endx
|
||||
if(((v1.Value.Position.x > startx) ||
|
||||
(v2.Value.Position.x > startx)) &&
|
||||
((v1.Value.Position.x < endx) ||
|
||||
(v2.Value.Position.x < endx)))
|
||||
if((v1.Value.Position.x > startx || v2.Value.Position.x > startx) &&
|
||||
(v1.Value.Position.x < endx || v2.Value.Position.x < endx))
|
||||
{
|
||||
// Find intersection
|
||||
Line2D pl = new Line2D(v1.Value.Position, v2.Value.Position);
|
||||
|
@ -615,7 +602,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
Sidedef sd = (insertbefore.Previous == null) ? insertbefore.List.Last.Value.Sidedef : insertbefore.Previous.Value.Sidedef;
|
||||
|
||||
// Find the position where we have to split the outer polygon
|
||||
split = new EarClipVertex(foundpos, null);
|
||||
EarClipVertex split = new EarClipVertex(foundpos, null);
|
||||
|
||||
// Insert manual split vertices
|
||||
p.AddBefore(insertbefore, new EarClipVertex(split, sd));
|
||||
|
@ -626,9 +613,8 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
{
|
||||
// Insert inner polygon vertex
|
||||
p.AddBefore(insertbefore, new EarClipVertex(v1.Value));
|
||||
if(v1.Next != null) v1 = v1.Next; else v1 = v1.List.First;
|
||||
}
|
||||
while(v1 != start);
|
||||
v1 = (v1.Next ?? v1.List.First);
|
||||
} while(v1 != start);
|
||||
|
||||
// Insert manual split vertices
|
||||
p.AddBefore(insertbefore, new EarClipVertex(start.Value, sd));
|
||||
|
@ -650,7 +636,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
List<EarClipVertex> convexes = new List<EarClipVertex>(poly.Count);
|
||||
LinkedList<EarClipVertex> reflexes = new LinkedList<EarClipVertex>();
|
||||
LinkedList<EarClipVertex> eartips = new LinkedList<EarClipVertex>();
|
||||
LinkedListNode<EarClipVertex> n1, n2;
|
||||
LinkedListNode<EarClipVertex> n2;
|
||||
EarClipVertex v, v1, v2;
|
||||
EarClipVertex[] t, t1, t2;
|
||||
int countvertices = 0;
|
||||
|
@ -660,7 +646,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
vec.SetVertsLink(verts.AddLast(vec));
|
||||
|
||||
// Remove any zero-length lines, these will give problems
|
||||
n1 = verts.First;
|
||||
LinkedListNode<EarClipVertex> n1 = verts.First;
|
||||
do
|
||||
{
|
||||
// Continue until adjacent zero-length lines are removed
|
||||
|
|
|
@ -79,22 +79,19 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// Returns null on failure
|
||||
public Bitmap ReadAsBitmap(Stream stream)
|
||||
{
|
||||
BitmapData bitmapdata;
|
||||
PixelColorBlock pixeldata;
|
||||
PixelColor* targetdata;
|
||||
int width, height;
|
||||
Bitmap bmp;
|
||||
|
||||
// Read pixel data
|
||||
pixeldata = ReadAsPixelData(stream, out width, out height);
|
||||
PixelColorBlock pixeldata = ReadAsPixelData(stream, out width, out height);
|
||||
if(pixeldata != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Create bitmap and lock pixels
|
||||
bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);
|
||||
bitmapdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
targetdata = (PixelColor*)bitmapdata.Scan0.ToPointer();
|
||||
BitmapData bitmapdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
PixelColor* targetdata = (PixelColor*)bitmapdata.Scan0.ToPointer();
|
||||
|
||||
// Copy the pixels
|
||||
General.CopyMemory(targetdata, pixeldata.Pointer, (uint)(width * height * sizeof(PixelColor)));
|
||||
|
@ -123,32 +120,26 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// Throws exception on failure
|
||||
public void DrawToPixelData(Stream stream, PixelColor* target, int targetwidth, int targetheight, int x, int y)
|
||||
{
|
||||
Bitmap bmp;
|
||||
BitmapData bmpdata;
|
||||
PixelColor* pixels;
|
||||
int ox, oy, tx, ty;
|
||||
int width, height;
|
||||
|
||||
// Get bitmap
|
||||
bmp = ReadAsBitmap(stream);
|
||||
width = bmp.Size.Width;
|
||||
height = bmp.Size.Height;
|
||||
Bitmap bmp = ReadAsBitmap(stream);
|
||||
int width = bmp.Size.Width;
|
||||
int height = bmp.Size.Height;
|
||||
|
||||
// Lock bitmap pixels
|
||||
bmpdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||
pixels = (PixelColor*)bmpdata.Scan0.ToPointer();
|
||||
BitmapData bmpdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||
PixelColor* pixels = (PixelColor*)bmpdata.Scan0.ToPointer();
|
||||
|
||||
// Go for all pixels in the original image
|
||||
for(ox = 0; ox < width; ox++)
|
||||
for(int ox = 0; ox < width; ox++)
|
||||
{
|
||||
for(oy = 0; oy < height; oy++)
|
||||
for(int oy = 0; oy < height; oy++)
|
||||
{
|
||||
// Copy this pixel?
|
||||
if(pixels[oy * width + ox].a > 0.5f)
|
||||
{
|
||||
// Calculate target pixel and copy when within bounds
|
||||
tx = x + ox;
|
||||
ty = y + oy;
|
||||
int tx = x + ox;
|
||||
int ty = y + oy;
|
||||
if((tx >= 0) && (tx < targetwidth) && (ty >= 0) && (ty < targetheight))
|
||||
target[ty * targetwidth + tx] = pixels[oy * width + ox];
|
||||
}
|
||||
|
@ -164,13 +155,8 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// Returns null on failure
|
||||
private PixelColorBlock ReadAsPixelData(Stream stream, out int width, out int height)
|
||||
{
|
||||
//new BinaryReader(stream);
|
||||
PixelColorBlock pixeldata;
|
||||
float sqrlength;
|
||||
byte[] bytes;
|
||||
|
||||
// Check if the flat is square
|
||||
sqrlength = (float)Math.Sqrt(stream.Length);
|
||||
float sqrlength = (float)Math.Sqrt(stream.Length);
|
||||
if(sqrlength == (float)Math.Truncate(sqrlength))
|
||||
{
|
||||
// Calculate image size
|
||||
|
@ -201,11 +187,11 @@ namespace CodeImp.DoomBuilder.IO
|
|||
if((width <= 0) || (height <= 0)) return null;
|
||||
|
||||
// Allocate memory
|
||||
pixeldata = new PixelColorBlock(width, height);
|
||||
PixelColorBlock pixeldata = new PixelColorBlock(width, height);
|
||||
pixeldata.Clear();
|
||||
|
||||
// Read flat bytes from stream
|
||||
bytes = new byte[width * height];
|
||||
byte[] bytes = new byte[width * height];
|
||||
stream.Read(bytes, 0, width * height);
|
||||
|
||||
// Convert bytes with palette
|
||||
|
|
|
@ -56,19 +56,16 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public bool Validate(Stream stream)
|
||||
{
|
||||
BinaryReader reader = new BinaryReader(stream);
|
||||
int width, height;
|
||||
int datalength;
|
||||
int columnaddr;
|
||||
|
||||
|
||||
// Initialize
|
||||
datalength = (int)stream.Length - (int)stream.Position;
|
||||
int datalength = (int)stream.Length - (int)stream.Position;
|
||||
|
||||
// Need at least 4 bytes
|
||||
if(datalength < 4) return false;
|
||||
|
||||
// Read size and offset
|
||||
width = reader.ReadInt16();
|
||||
height = reader.ReadInt16();
|
||||
int width = reader.ReadInt16();
|
||||
int height = reader.ReadInt16();
|
||||
reader.ReadInt16();
|
||||
reader.ReadInt16();
|
||||
|
||||
|
@ -79,8 +76,8 @@ namespace CodeImp.DoomBuilder.IO
|
|||
for(int x = 0; x < width; x++)
|
||||
{
|
||||
// Get column address
|
||||
columnaddr = reader.ReadInt32();
|
||||
|
||||
int columnaddr = reader.ReadInt32();
|
||||
|
||||
// Check if address is outside valid range
|
||||
if((columnaddr < (8 + width * 4)) || (columnaddr >= datalength)) return false;
|
||||
}
|
||||
|
@ -101,22 +98,19 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// Returns null on failure
|
||||
public Bitmap ReadAsBitmap(Stream stream, out int offsetx, out int offsety)
|
||||
{
|
||||
BitmapData bitmapdata;
|
||||
PixelColorBlock pixeldata;
|
||||
PixelColor* targetdata;
|
||||
int width, height;
|
||||
Bitmap bmp;
|
||||
|
||||
// Read pixel data
|
||||
pixeldata = ReadAsPixelData(stream, out width, out height, out offsetx, out offsety);
|
||||
PixelColorBlock pixeldata = ReadAsPixelData(stream, out width, out height, out offsetx, out offsety);
|
||||
if(pixeldata != null)
|
||||
{
|
||||
// Create bitmap and lock pixels
|
||||
try
|
||||
{
|
||||
bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);
|
||||
bitmapdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
targetdata = (PixelColor*)bitmapdata.Scan0.ToPointer();
|
||||
BitmapData bitmapdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
PixelColor* targetdata = (PixelColor*)bitmapdata.Scan0.ToPointer();
|
||||
|
||||
// Copy the pixels
|
||||
General.CopyMemory(targetdata, pixeldata.Pointer, (uint)(width * height * sizeof(PixelColor)));
|
||||
|
@ -145,11 +139,10 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// Throws exception on failure
|
||||
public void DrawToPixelData(Stream stream, PixelColor* target, int targetwidth, int targetheight, int x, int y)
|
||||
{
|
||||
PixelColorBlock pixeldata;
|
||||
int width, height, ox, oy, tx, ty;
|
||||
int width, height, ox, oy;
|
||||
|
||||
// Read pixel data
|
||||
pixeldata = ReadAsPixelData(stream, out width, out height, out ox, out oy);
|
||||
PixelColorBlock pixeldata = ReadAsPixelData(stream, out width, out height, out ox, out oy);
|
||||
if(pixeldata != null)
|
||||
{
|
||||
// Go for all source pixels
|
||||
|
@ -162,8 +155,8 @@ namespace CodeImp.DoomBuilder.IO
|
|||
if(pixeldata.Pointer[oy * width + ox].a > 0.5f)
|
||||
{
|
||||
// Calculate target pixel and copy when within bounds
|
||||
tx = x + ox;
|
||||
ty = y + oy;
|
||||
int tx = x + ox;
|
||||
int ty = y + oy;
|
||||
if((tx >= 0) && (tx < targetwidth) && (ty >= 0) && (ty < targetheight))
|
||||
target[ty * targetwidth + tx] = pixeldata.Pointer[oy * width + ox];
|
||||
}
|
||||
|
@ -177,17 +170,13 @@ namespace CodeImp.DoomBuilder.IO
|
|||
private PixelColorBlock ReadAsPixelData(Stream stream, out int width, out int height, out int offsetx, out int offsety)
|
||||
{
|
||||
BinaryReader reader = new BinaryReader(stream);
|
||||
PixelColorBlock pixeldata;
|
||||
int y, read_y, count, p;
|
||||
int[] columns;
|
||||
int dataoffset;
|
||||
|
||||
|
||||
// Initialize
|
||||
width = 0;
|
||||
height = 0;
|
||||
offsetx = 0;
|
||||
offsety = 0;
|
||||
dataoffset = (int)stream.Position;
|
||||
int dataoffset = (int)stream.Position;
|
||||
|
||||
// Need at least 4 bytes
|
||||
if((stream.Length - stream.Position) < 4) return null;
|
||||
|
@ -207,11 +196,11 @@ namespace CodeImp.DoomBuilder.IO
|
|||
if((width <= 0) || (height <= 0)) return null;
|
||||
|
||||
// Read the column addresses
|
||||
columns = new int[width];
|
||||
int[] columns = new int[width];
|
||||
for(int x = 0; x < width; x++) columns[x] = reader.ReadInt32();
|
||||
|
||||
// Allocate memory
|
||||
pixeldata = new PixelColorBlock(width, height);
|
||||
PixelColorBlock pixeldata = new PixelColorBlock(width, height);
|
||||
pixeldata.Clear();
|
||||
|
||||
// Go for all columns
|
||||
|
@ -221,14 +210,14 @@ namespace CodeImp.DoomBuilder.IO
|
|||
stream.Seek(dataoffset + columns[x], SeekOrigin.Begin);
|
||||
|
||||
// Read first post start
|
||||
y = reader.ReadByte();
|
||||
read_y = y;
|
||||
int y = reader.ReadByte();
|
||||
int read_y = y;
|
||||
|
||||
// Continue while not end of column reached
|
||||
while(read_y < 255)
|
||||
{
|
||||
// Read number of pixels in post
|
||||
count = reader.ReadByte();
|
||||
int count = reader.ReadByte();
|
||||
|
||||
// Skip unused pixel
|
||||
stream.Seek(1, SeekOrigin.Current);
|
||||
|
@ -237,12 +226,12 @@ namespace CodeImp.DoomBuilder.IO
|
|||
for(int yo = 0; yo < count; yo++)
|
||||
{
|
||||
// Read pixel color index
|
||||
p = reader.ReadByte();
|
||||
int p = reader.ReadByte();
|
||||
|
||||
// Draw pixel
|
||||
pixeldata.Pointer[(y + yo) * width + x] = palette[p];
|
||||
}
|
||||
|
||||
|
||||
// Skip unused pixel
|
||||
stream.Seek(1, SeekOrigin.Current);
|
||||
|
||||
|
|
|
@ -469,34 +469,28 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// Throws exception on failure
|
||||
public void DrawToPixelData(Stream stream, PixelColor* target, int targetwidth, int targetheight, int x, int y)
|
||||
{
|
||||
Bitmap bmp;
|
||||
BitmapData bmpdata;
|
||||
PixelColor* pixels;
|
||||
int ox, oy, tx, ty;
|
||||
int width, height;
|
||||
|
||||
// Get bitmap
|
||||
bmp = ReadAsBitmap(stream);
|
||||
Bitmap bmp = ReadAsBitmap(stream);
|
||||
if(bmp != null)
|
||||
{
|
||||
width = bmp.Size.Width;
|
||||
height = bmp.Size.Height;
|
||||
int width = bmp.Size.Width;
|
||||
int height = bmp.Size.Height;
|
||||
|
||||
// Lock bitmap pixels
|
||||
bmpdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||
pixels = (PixelColor*)bmpdata.Scan0.ToPointer();
|
||||
BitmapData bmpdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||
PixelColor* pixels = (PixelColor*)bmpdata.Scan0.ToPointer();
|
||||
|
||||
// Go for all pixels in the original image
|
||||
for(ox = 0; ox < width; ox++)
|
||||
for(int ox = 0; ox < width; ox++)
|
||||
{
|
||||
for(oy = 0; oy < height; oy++)
|
||||
for(int oy = 0; oy < height; oy++)
|
||||
{
|
||||
// Copy this pixel?
|
||||
if(pixels[oy * width + ox].a > 0.5f)
|
||||
{
|
||||
// Calculate target pixel and copy when within bounds
|
||||
tx = x + ox;
|
||||
ty = y + oy;
|
||||
int tx = x + ox;
|
||||
int ty = y + oy;
|
||||
if((tx >= 0) && (tx < targetwidth) && (ty >= 0) && (ty < targetheight))
|
||||
target[ty * targetwidth + tx] = pixels[oy * width + ox];
|
||||
}
|
||||
|
|
|
@ -57,41 +57,35 @@ namespace CodeImp.DoomBuilder.IO
|
|||
}
|
||||
|
||||
// This reads the image and returns a Bitmap
|
||||
public static Bitmap ReadAsBitmap()
|
||||
/*public static Bitmap ReadAsBitmap() //mxd. Never used
|
||||
{
|
||||
return new Bitmap(Properties.Resources.Failed);
|
||||
}
|
||||
}*/
|
||||
|
||||
// This draws the picture to the given pixel color data
|
||||
// Throws exception on failure
|
||||
public unsafe void DrawToPixelData(Stream stream, PixelColor* target, int targetwidth, int targetheight, int x, int y)
|
||||
{
|
||||
Bitmap bmp;
|
||||
BitmapData bmpdata;
|
||||
PixelColor* pixels;
|
||||
int ox, oy, tx, ty;
|
||||
int width, height;
|
||||
|
||||
// Get bitmap
|
||||
bmp = ReadAsBitmap(stream);
|
||||
width = bmp.Size.Width;
|
||||
height = bmp.Size.Height;
|
||||
Bitmap bmp = ReadAsBitmap(stream);
|
||||
int width = bmp.Size.Width;
|
||||
int height = bmp.Size.Height;
|
||||
|
||||
// Lock bitmap pixels
|
||||
bmpdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||
pixels = (PixelColor*)bmpdata.Scan0.ToPointer();
|
||||
BitmapData bmpdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||
PixelColor* pixels = (PixelColor*)bmpdata.Scan0.ToPointer();
|
||||
|
||||
// Go for all pixels in the original image
|
||||
for(ox = 0; ox < width; ox++)
|
||||
for(int ox = 0; ox < width; ox++)
|
||||
{
|
||||
for(oy = 0; oy < height; oy++)
|
||||
for(int oy = 0; oy < height; oy++)
|
||||
{
|
||||
// Copy this pixel?
|
||||
if(pixels[oy * width + ox].a > 0.5f)
|
||||
{
|
||||
// Calculate target pixel and copy when within bounds
|
||||
tx = x + ox;
|
||||
ty = y + oy;
|
||||
int tx = x + ox;
|
||||
int ty = y + oy;
|
||||
if((tx >= 0) && (tx < targetwidth) && (ty >= 0) && (ty < targetheight))
|
||||
target[ty * targetwidth + tx] = pixels[oy * width + ox];
|
||||
}
|
||||
|
|
|
@ -199,9 +199,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// This returns all blocks along the given line
|
||||
public virtual List<BE> GetLineBlocks(Vector2D v1, Vector2D v2)
|
||||
{
|
||||
float deltax, deltay;
|
||||
float posx, posy;
|
||||
Point pos, end;
|
||||
int dirx, diry;
|
||||
|
||||
// Estimate number of blocks we will go through and create list
|
||||
|
@ -209,8 +206,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
List<BE> entries = new List<BE>(entriescount);
|
||||
|
||||
// Find start and end block
|
||||
pos = GetBlockCoordinates(v1);
|
||||
end = GetBlockCoordinates(v2);
|
||||
Point pos = GetBlockCoordinates(v1);
|
||||
Point end = GetBlockCoordinates(v2);
|
||||
v1 -= rangelefttop;
|
||||
v2 -= rangelefttop;
|
||||
|
||||
|
@ -271,6 +268,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
diry = Math.Sign(v2.y - v1.y);
|
||||
|
||||
// Calculate offset and delta movement over x
|
||||
float posx, deltax;
|
||||
if(dirx >= 0)
|
||||
{
|
||||
posx = (cr - v1.x) / (v2.x - v1.x);
|
||||
|
@ -284,6 +282,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
|
||||
// Calculate offset and delta movement over y
|
||||
float posy, deltay;
|
||||
if(diry >= 0)
|
||||
{
|
||||
posy = (cb - v1.y) / (v2.y - v1.y);
|
||||
|
@ -379,19 +378,15 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// This puts a single linedef in all blocks it crosses
|
||||
public virtual void AddLinedef(Linedef line)
|
||||
{
|
||||
Vector2D v1, v2;
|
||||
float deltax, deltay;
|
||||
float posx, posy;
|
||||
Point pos, end;
|
||||
int dirx, diry;
|
||||
|
||||
// Get coordinates
|
||||
v1 = line.Start.Position;
|
||||
v2 = line.End.Position;
|
||||
Vector2D v1 = line.Start.Position;
|
||||
Vector2D v2 = line.End.Position;
|
||||
|
||||
// Find start and end block
|
||||
pos = GetBlockCoordinates(v1);
|
||||
end = GetBlockCoordinates(v2);
|
||||
Point pos = GetBlockCoordinates(v1);
|
||||
Point end = GetBlockCoordinates(v2);
|
||||
v1 -= rangelefttop;
|
||||
v2 -= rangelefttop;
|
||||
|
||||
|
@ -452,6 +447,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
diry = Math.Sign(v2.y - v1.y);
|
||||
|
||||
// Calculate offset and delta movement over x
|
||||
float posx, deltax;
|
||||
if(dirx == 0)
|
||||
{
|
||||
posx = float.MaxValue;
|
||||
|
@ -470,6 +466,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
|
||||
// Calculate offset and delta movement over y
|
||||
float posy, deltay;
|
||||
if(diry == 0)
|
||||
{
|
||||
posy = float.MaxValue;
|
||||
|
|
|
@ -888,7 +888,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
{
|
||||
List<Vector2D> coords = new List<Vector2D>();
|
||||
Vector2D v = new Vector2D();
|
||||
float gx, gy, minx, maxx, miny, maxy;
|
||||
float minx, maxx, miny, maxy;
|
||||
bool reversex, reversey;
|
||||
|
||||
if(start.Position.x > end.Position.x)
|
||||
|
@ -918,7 +918,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
|
||||
// Go for all vertical grid lines in between line start and end
|
||||
gx = General.Map.Grid.GetHigher(minx) + gridoffset.x;
|
||||
float gx = General.Map.Grid.GetHigher(minx) + gridoffset.x;
|
||||
if(gx < maxx)
|
||||
{
|
||||
for(; gx < maxx; gx += General.Map.Grid.GridSizeF)
|
||||
|
@ -933,7 +933,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
|
||||
// Go for all horizontal grid lines in between line start and end
|
||||
gy = General.Map.Grid.GetHigher(miny) + gridoffset.y;
|
||||
float gy = General.Map.Grid.GetHigher(miny) + gridoffset.y;
|
||||
if(gy < maxy)
|
||||
{
|
||||
for(; gy < maxy; gy += General.Map.Grid.GridSizeF)
|
||||
|
|
|
@ -1067,9 +1067,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// Note that this function uses the markings to convert the selection.</summary>
|
||||
public void ConvertSelection(SelectionType source, SelectionType target)
|
||||
{
|
||||
ICollection<Linedef> lines;
|
||||
ICollection<Vertex> verts;
|
||||
|
||||
ClearAllMarks(false);
|
||||
|
||||
switch(target)
|
||||
|
@ -1078,7 +1075,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
case SelectionType.Vertices:
|
||||
if(InSelectionType(source, SelectionType.Linedefs)) MarkSelectedLinedefs(true, true);
|
||||
if(InSelectionType(source, SelectionType.Sectors)) General.Map.Map.MarkSelectedSectors(true, true);
|
||||
verts = General.Map.Map.GetVerticesFromLinesMarks(true);
|
||||
ICollection<Vertex> verts = General.Map.Map.GetVerticesFromLinesMarks(true);
|
||||
foreach(Vertex v in verts) v.Selected = true;
|
||||
verts = General.Map.Map.GetVerticesFromSectorsMarks(true);
|
||||
foreach(Vertex v in verts) v.Selected = true;
|
||||
|
@ -1090,7 +1087,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
case SelectionType.Linedefs:
|
||||
if(InSelectionType(source, SelectionType.Vertices)) MarkSelectedVertices(true, true);
|
||||
if(!InSelectionType(source, SelectionType.Linedefs)) ClearSelectedLinedefs();
|
||||
lines = General.Map.Map.LinedefsFromMarkedVertices(false, true, false);
|
||||
ICollection<Linedef> lines = General.Map.Map.LinedefsFromMarkedVertices(false, true, false);
|
||||
foreach(Linedef l in lines) l.Selected = true;
|
||||
if(InSelectionType(source, SelectionType.Sectors))
|
||||
{
|
||||
|
@ -2059,31 +2056,24 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// </summary>
|
||||
public bool StitchGeometry()
|
||||
{
|
||||
ICollection<Linedef> movinglines;
|
||||
ICollection<Linedef> fixedlines;
|
||||
ICollection<Vertex> nearbyfixedverts;
|
||||
ICollection<Vertex> movingverts;
|
||||
ICollection<Vertex> fixedverts;
|
||||
RectangleF editarea;
|
||||
|
||||
// Find vertices
|
||||
movingverts = General.Map.Map.GetMarkedVertices(true);
|
||||
fixedverts = General.Map.Map.GetMarkedVertices(false);
|
||||
ICollection<Vertex> movingverts = General.Map.Map.GetMarkedVertices(true);
|
||||
ICollection<Vertex> fixedverts = General.Map.Map.GetMarkedVertices(false);
|
||||
|
||||
// Find lines that moved during the drag
|
||||
movinglines = LinedefsFromMarkedVertices(false, true, true);
|
||||
ICollection<Linedef> movinglines = LinedefsFromMarkedVertices(false, true, true);
|
||||
|
||||
// Find all non-moving lines
|
||||
fixedlines = LinedefsFromMarkedVertices(true, false, false);
|
||||
ICollection<Linedef> fixedlines = LinedefsFromMarkedVertices(true, false, false);
|
||||
|
||||
// Determine area in which we are editing
|
||||
editarea = MapSet.CreateArea(movinglines);
|
||||
editarea = MapSet.IncreaseArea(editarea, movingverts);
|
||||
RectangleF editarea = CreateArea(movinglines);
|
||||
editarea = IncreaseArea(editarea, movingverts);
|
||||
editarea.Inflate(1.0f, 1.0f);
|
||||
|
||||
// Join nearby vertices
|
||||
BeginAddRemove();
|
||||
MapSet.JoinVertices(fixedverts, movingverts, true, MapSet.STITCH_DISTANCE);
|
||||
JoinVertices(fixedverts, movingverts, true, STITCH_DISTANCE);
|
||||
EndAddRemove();
|
||||
|
||||
// Update cached values of lines because we need their length/angle
|
||||
|
@ -2092,20 +2082,20 @@ namespace CodeImp.DoomBuilder.Map
|
|||
BeginAddRemove();
|
||||
|
||||
// Split moving lines with unselected vertices
|
||||
nearbyfixedverts = MapSet.FilterByArea(fixedverts, ref editarea);
|
||||
if(!MapSet.SplitLinesByVertices(movinglines, nearbyfixedverts, MapSet.STITCH_DISTANCE, movinglines))
|
||||
ICollection<Vertex> nearbyfixedverts = FilterByArea(fixedverts, ref editarea);
|
||||
if(!SplitLinesByVertices(movinglines, nearbyfixedverts, STITCH_DISTANCE, movinglines))
|
||||
return false;
|
||||
|
||||
// Split non-moving lines with selected vertices
|
||||
fixedlines = MapSet.FilterByArea(fixedlines, ref editarea);
|
||||
if(!MapSet.SplitLinesByVertices(fixedlines, movingverts, MapSet.STITCH_DISTANCE, movinglines))
|
||||
fixedlines = FilterByArea(fixedlines, ref editarea);
|
||||
if(!SplitLinesByVertices(fixedlines, movingverts, STITCH_DISTANCE, movinglines))
|
||||
return false;
|
||||
|
||||
// Remove looped linedefs
|
||||
MapSet.RemoveLoopedLinedefs(movinglines);
|
||||
RemoveLoopedLinedefs(movinglines);
|
||||
|
||||
// Join overlapping lines
|
||||
if(!MapSet.JoinOverlappingLines(movinglines))
|
||||
if(!JoinOverlappingLines(movinglines))
|
||||
return false;
|
||||
|
||||
EndAddRemove();
|
||||
|
|
|
@ -355,7 +355,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
updateneeded = true;
|
||||
|
||||
// Make label positions
|
||||
labels = Array.AsReadOnly<LabelPositionInfo>(Tools.FindLabelPositions(this).ToArray());
|
||||
labels = Array.AsReadOnly(Tools.FindLabelPositions(this).ToArray());
|
||||
|
||||
// Number of vertices changed?
|
||||
if(triangles.Vertices.Count != surfaceentries.totalvertices)
|
||||
|
|
|
@ -101,19 +101,13 @@ namespace CodeImp.DoomBuilder.Plugins
|
|||
// This loads all plugins
|
||||
public void LoadAllPlugins()
|
||||
{
|
||||
List<string> filenames;
|
||||
//Type[] editclasses;
|
||||
//EditModeAttribute[] emattrs;
|
||||
//EditModeInfo editmodeinfo;
|
||||
Configuration cfg;
|
||||
IDictionary loadorderfiles = new ListDictionary();
|
||||
Plugin p;
|
||||
|
||||
try
|
||||
{
|
||||
// Load the load order cfg
|
||||
cfg = new Configuration(Path.Combine(General.PluginsPath, "Loadorder.cfg"), true);
|
||||
|
||||
Configuration cfg = new Configuration(Path.Combine(General.PluginsPath, "Loadorder.cfg"), true);
|
||||
|
||||
// Check for erors
|
||||
if(cfg.ErrorResult)
|
||||
{
|
||||
|
@ -134,7 +128,7 @@ namespace CodeImp.DoomBuilder.Plugins
|
|||
}
|
||||
|
||||
// Find all .dll files
|
||||
filenames = new List<string>(Directory.GetFiles(General.PluginsPath, "*.dll", SearchOption.TopDirectoryOnly));
|
||||
List<string> filenames = new List<string>(Directory.GetFiles(General.PluginsPath, "*.dll", SearchOption.TopDirectoryOnly));
|
||||
|
||||
// Load the ones in order as specified by the load order cfg
|
||||
foreach(DictionaryEntry de in loadorderfiles)
|
||||
|
@ -150,6 +144,7 @@ namespace CodeImp.DoomBuilder.Plugins
|
|||
if(filenameindex > -1)
|
||||
{
|
||||
// Load plugin from this file
|
||||
Plugin p;
|
||||
try
|
||||
{
|
||||
p = new Plugin(filenames[filenameindex]);
|
||||
|
@ -184,6 +179,7 @@ namespace CodeImp.DoomBuilder.Plugins
|
|||
foreach(string fn in filenames)
|
||||
{
|
||||
// Load plugin from this file
|
||||
Plugin p;
|
||||
try
|
||||
{
|
||||
p = new Plugin(fn);
|
||||
|
|
|
@ -69,14 +69,12 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
// Constructor
|
||||
public FlatQuad(PrimitiveType type, float left, float top, float right, float bottom, float twidth, float theight)
|
||||
{
|
||||
float twd, thd;
|
||||
|
||||
// Initialize
|
||||
Initialize(type);
|
||||
|
||||
// Determine texture size dividers
|
||||
twd = 1f / twidth;
|
||||
thd = 1f / theight;
|
||||
float twd = 1f / twidth;
|
||||
float thd = 1f / theight;
|
||||
|
||||
// Set coordinates
|
||||
switch (type)
|
||||
|
@ -261,7 +259,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
public void Render(D3DDevice device)
|
||||
{
|
||||
// Render the quad
|
||||
device.Device.DrawUserPrimitives<FlatVertex>(type, 0, 2, vertices);
|
||||
device.Device.DrawUserPrimitives(type, 0, 2, vertices);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -148,9 +148,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
public PixelColor Blend(PixelColor a, PixelColor b)
|
||||
{
|
||||
PixelColor c = new PixelColor();
|
||||
float ba;
|
||||
|
||||
ba = a.a * BYTE_TO_FLOAT;
|
||||
|
||||
float ba = a.a * BYTE_TO_FLOAT;
|
||||
c.r = (byte)(a.r * (1f - ba) + b.r * ba);
|
||||
c.g = (byte)(a.g * (1f - ba) + b.g * ba);
|
||||
c.b = (byte)(a.b * (1f - ba) + b.b * ba);
|
||||
|
|
|
@ -255,7 +255,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.Shaders.Display2D.Texture1 = General.Map.Grid.Background.Texture;
|
||||
graphics.Shaders.Display2D.SetSettings(1f / windowsize.Width, 1f / windowsize.Height, FSAA_FACTOR, layer.alpha, false);
|
||||
graphics.Shaders.Display2D.BeginPass(aapass);
|
||||
graphics.Device.DrawUserPrimitives<FlatVertex>(PrimitiveType.TriangleStrip, 0, 2, backimageverts);
|
||||
graphics.Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 0, 2, backimageverts);
|
||||
graphics.Shaders.Display2D.EndPass();
|
||||
graphics.Device.SetStreamSource(0, screenverts, 0, sizeof(FlatVertex));
|
||||
break;
|
||||
|
@ -803,7 +803,6 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
// Only if a background image is set
|
||||
if((General.Map.Grid.Background != null) && !(General.Map.Grid.Background is UnknownImage))
|
||||
{
|
||||
Vector2D ltpos, rbpos;
|
||||
Vector2D backoffset = new Vector2D(General.Map.Grid.BackgroundX, General.Map.Grid.BackgroundY);
|
||||
Vector2D backimagesize = new Vector2D(General.Map.Grid.Background.ScaledWidth, General.Map.Grid.Background.ScaledHeight);
|
||||
Vector2D backimagescale = new Vector2D(General.Map.Grid.BackgroundScaleX, General.Map.Grid.BackgroundScaleY);
|
||||
|
@ -815,8 +814,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
backimageverts = CreateScreenVerts(windowsize);
|
||||
|
||||
// Determine map coordinates for view window
|
||||
ltpos = DisplayToMap(new Vector2D(0f, 0f));
|
||||
rbpos = DisplayToMap(new Vector2D(windowsize.Width, windowsize.Height));
|
||||
Vector2D ltpos = DisplayToMap(new Vector2D(0f, 0f));
|
||||
Vector2D rbpos = DisplayToMap(new Vector2D(windowsize.Width, windowsize.Height));
|
||||
|
||||
// Offset by given background offset
|
||||
ltpos -= backoffset;
|
||||
|
@ -895,12 +894,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
// This renders the grid
|
||||
private void RenderGrid(float size, PixelColor c, Plotter gridplotter)
|
||||
{
|
||||
Vector2D ltpos, rbpos;
|
||||
Vector2D tlb, rbb;
|
||||
Vector2D pos = new Vector2D();
|
||||
float ystart, yend;
|
||||
float xstart, xend;
|
||||
float from, to;
|
||||
|
||||
//mxd. Increase rendered grid size if needed
|
||||
if(!General.Settings.DynamicGridSize && size * scale <= 6f)
|
||||
|
@ -908,28 +902,28 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
float sizeinv = 1f / size;
|
||||
|
||||
// Determine map coordinates for view window
|
||||
ltpos = DisplayToMap(new Vector2D(0, 0));
|
||||
rbpos = DisplayToMap(new Vector2D(windowsize.Width, windowsize.Height));
|
||||
Vector2D ltpos = DisplayToMap(new Vector2D(0, 0));
|
||||
Vector2D rbpos = DisplayToMap(new Vector2D(windowsize.Width, windowsize.Height));
|
||||
|
||||
// Clip to nearest grid
|
||||
ltpos = GridSetup.SnappedToGrid(ltpos, size, sizeinv);
|
||||
rbpos = GridSetup.SnappedToGrid(rbpos, size, sizeinv);
|
||||
|
||||
// Translate top left boundary and right bottom boundary of map to screen coords
|
||||
tlb = new Vector2D(General.Map.Config.LeftBoundary, General.Map.Config.TopBoundary).GetTransformed(translatex, translatey, scale, -scale);
|
||||
rbb = new Vector2D(General.Map.Config.RightBoundary, General.Map.Config.BottomBoundary).GetTransformed(translatex, translatey, scale, -scale);
|
||||
Vector2D tlb = new Vector2D(General.Map.Config.LeftBoundary, General.Map.Config.TopBoundary).GetTransformed(translatex, translatey, scale, -scale);
|
||||
Vector2D rbb = new Vector2D(General.Map.Config.RightBoundary, General.Map.Config.BottomBoundary).GetTransformed(translatex, translatey, scale, -scale);
|
||||
|
||||
// Draw all horizontal grid lines
|
||||
ystart = rbpos.y > General.Map.Config.BottomBoundary ? rbpos.y : General.Map.Config.BottomBoundary;
|
||||
yend = ltpos.y < General.Map.Config.TopBoundary ? ltpos.y : General.Map.Config.TopBoundary;
|
||||
float ystart = rbpos.y > General.Map.Config.BottomBoundary ? rbpos.y : General.Map.Config.BottomBoundary;
|
||||
float yend = ltpos.y < General.Map.Config.TopBoundary ? ltpos.y : General.Map.Config.TopBoundary;
|
||||
|
||||
for(float y = ystart; y < yend + size; y += size)
|
||||
{
|
||||
if(y > General.Map.Config.TopBoundary) y = General.Map.Config.TopBoundary;
|
||||
else if(y < General.Map.Config.BottomBoundary) y = General.Map.Config.BottomBoundary;
|
||||
|
||||
from = tlb.x < 0 ? 0 : tlb.x;
|
||||
to = rbb.x > windowsize.Width ? windowsize.Width : rbb.x;
|
||||
float from = tlb.x < 0 ? 0 : tlb.x;
|
||||
float to = rbb.x > windowsize.Width ? windowsize.Width : rbb.x;
|
||||
|
||||
pos.y = y;
|
||||
pos = pos.GetTransformed(translatex, translatey, scale, -scale);
|
||||
|
@ -939,16 +933,16 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
}
|
||||
|
||||
// Draw all vertical grid lines
|
||||
xstart = ltpos.x > General.Map.Config.LeftBoundary ? ltpos.x : General.Map.Config.LeftBoundary;
|
||||
xend = rbpos.x < General.Map.Config.RightBoundary ? rbpos.x : General.Map.Config.RightBoundary;
|
||||
float xstart = ltpos.x > General.Map.Config.LeftBoundary ? ltpos.x : General.Map.Config.LeftBoundary;
|
||||
float xend = rbpos.x < General.Map.Config.RightBoundary ? rbpos.x : General.Map.Config.RightBoundary;
|
||||
|
||||
for(float x = xstart; x < xend + size; x += size)
|
||||
{
|
||||
if(x > General.Map.Config.RightBoundary) x = General.Map.Config.RightBoundary;
|
||||
else if(x < General.Map.Config.LeftBoundary) x = General.Map.Config.LeftBoundary;
|
||||
|
||||
from = tlb.y < 0 ? 0 : tlb.y;
|
||||
to = rbb.y > windowsize.Height ? windowsize.Height : rbb.y;
|
||||
float from = tlb.y < 0 ? 0 : tlb.y;
|
||||
float to = rbb.y > windowsize.Height ? windowsize.Height : rbb.y;
|
||||
|
||||
pos.x = x;
|
||||
pos = pos.GetTransformed(translatex, translatey, scale, -scale);
|
||||
|
|
|
@ -78,27 +78,22 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
// Constructor
|
||||
internal TextFont()
|
||||
{
|
||||
Configuration cfg;
|
||||
Stream fontdata;
|
||||
StreamReader fontreader;
|
||||
string[] resnames;
|
||||
|
||||
// Initialize
|
||||
characters = new FontCharacter[256];
|
||||
|
||||
// Make chars configuration
|
||||
cfg = new Configuration();
|
||||
Configuration cfg = new Configuration();
|
||||
|
||||
// Find a resource named Font.cfg
|
||||
resnames = General.ThisAssembly.GetManifestResourceNames();
|
||||
string[] resnames = General.ThisAssembly.GetManifestResourceNames();
|
||||
foreach(string rn in resnames)
|
||||
{
|
||||
// Found it?
|
||||
if(rn.EndsWith(FONT_RESOURCE, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
// Get a stream from the resource
|
||||
fontdata = General.ThisAssembly.GetManifestResourceStream(rn);
|
||||
fontreader = new StreamReader(fontdata, Encoding.ASCII);
|
||||
Stream fontdata = General.ThisAssembly.GetManifestResourceStream(rn);
|
||||
StreamReader fontreader = new StreamReader(fontdata, Encoding.ASCII);
|
||||
|
||||
// Load configuration from stream
|
||||
cfg.InputConfiguration(fontreader.ReadToEnd());
|
||||
|
@ -155,12 +150,10 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
ref float textx, float texty, float textheight, float offsetv)
|
||||
{
|
||||
FlatVertex vert = new FlatVertex();
|
||||
FontCharacter cinfo;
|
||||
float cwidth;
|
||||
|
||||
|
||||
// Get the character information
|
||||
cinfo = characters[c];
|
||||
cwidth = cinfo.width * scale;
|
||||
FontCharacter cinfo = characters[c];
|
||||
float cwidth = cinfo.width * scale;
|
||||
|
||||
// Create lefttop vertex
|
||||
vert.c = color;
|
||||
|
@ -168,7 +161,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
vert.v = cinfo.v1 * 0.5f + offsetv;
|
||||
vert.x = textx;
|
||||
vert.y = texty;
|
||||
stream.Write<FlatVertex>(vert);
|
||||
stream.Write(vert);
|
||||
|
||||
// Create leftbottom vertex
|
||||
vert.c = color;
|
||||
|
@ -176,7 +169,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
vert.v = cinfo.v2 * 0.5f + offsetv;
|
||||
vert.x = textx;
|
||||
vert.y = texty + textheight;
|
||||
stream.Write<FlatVertex>(vert);
|
||||
stream.Write(vert);
|
||||
|
||||
// Create righttop vertex
|
||||
vert.c = color;
|
||||
|
@ -184,7 +177,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
vert.v = cinfo.v1 * 0.5f + offsetv;
|
||||
vert.x = textx + cwidth;
|
||||
vert.y = texty;
|
||||
stream.Write<FlatVertex>(vert);
|
||||
stream.Write(vert);
|
||||
|
||||
// Create leftbottom vertex
|
||||
vert.c = color;
|
||||
|
@ -192,7 +185,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
vert.v = cinfo.v2 * 0.5f + offsetv;
|
||||
vert.x = textx;
|
||||
vert.y = texty + textheight;
|
||||
stream.Write<FlatVertex>(vert);
|
||||
stream.Write(vert);
|
||||
|
||||
// Create righttop vertex
|
||||
vert.c = color;
|
||||
|
@ -200,7 +193,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
vert.v = cinfo.v1 * 0.5f + offsetv;
|
||||
vert.x = textx + cwidth;
|
||||
vert.y = texty;
|
||||
stream.Write<FlatVertex>(vert);
|
||||
stream.Write(vert);
|
||||
|
||||
// Create rightbottom vertex
|
||||
vert.c = color;
|
||||
|
@ -208,7 +201,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
vert.v = cinfo.v2 * 0.5f + offsetv;
|
||||
vert.x = textx + cwidth;
|
||||
vert.y = texty + textheight;
|
||||
stream.Write<FlatVertex>(vert);
|
||||
stream.Write(vert);
|
||||
|
||||
textx += (cwidth + (ADJUST_SPACING * scale));
|
||||
}
|
||||
|
|
|
@ -179,18 +179,13 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
// This returns all blocks along the given line
|
||||
public List<VisualBlockEntry> GetLineBlocks(Vector2D v1, Vector2D v2)
|
||||
{
|
||||
float deltax, deltay;
|
||||
float posx, posy;
|
||||
Point pos, end;
|
||||
int dirx, diry;
|
||||
|
||||
// Estimate number of blocks we will go through and create list
|
||||
int entriescount = (int)(Vector2D.ManhattanDistance(v1, v2) * 2.0f) / BLOCK_SIZE;
|
||||
List<VisualBlockEntry> entries = new List<VisualBlockEntry>(entriescount);
|
||||
|
||||
// Find start and end block
|
||||
pos = GetBlockCoordinates(v1);
|
||||
end = GetBlockCoordinates(v2);
|
||||
Point pos = GetBlockCoordinates(v1);
|
||||
Point end = GetBlockCoordinates(v2);
|
||||
|
||||
// Add this block
|
||||
entries.Add(GetBlock(pos));
|
||||
|
@ -205,10 +200,11 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
float cb = (pos.Y + 1) * BLOCK_SIZE;
|
||||
|
||||
// Line directions
|
||||
dirx = Math.Sign(v2.x - v1.x);
|
||||
diry = Math.Sign(v2.y - v1.y);
|
||||
int dirx = Math.Sign(v2.x - v1.x);
|
||||
int diry = Math.Sign(v2.y - v1.y);
|
||||
|
||||
// Calculate offset and delta movement over x
|
||||
float posx, deltax;
|
||||
if(dirx >= 0)
|
||||
{
|
||||
posx = (cr - v1.x) / (v2.x - v1.x);
|
||||
|
@ -222,6 +218,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
}
|
||||
|
||||
// Calculate offset and delta movement over y
|
||||
float posy, deltay;
|
||||
if(diry >= 0)
|
||||
{
|
||||
posy = (cb - v1.y) / (v2.y - v1.y);
|
||||
|
@ -311,25 +308,19 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
// This puts a single linedef in all blocks it crosses
|
||||
public void AddLinedef(Linedef line)
|
||||
{
|
||||
Vector2D v1, v2;
|
||||
float deltax, deltay;
|
||||
float posx, posy;
|
||||
Point pos, end;
|
||||
int dirx, diry;
|
||||
|
||||
// Get coordinates
|
||||
v1 = line.Start.Position;
|
||||
v2 = line.End.Position;
|
||||
Vector2D v1 = line.Start.Position;
|
||||
Vector2D v2 = line.End.Position;
|
||||
|
||||
// Find start and end block
|
||||
pos = GetBlockCoordinates(v1);
|
||||
end = GetBlockCoordinates(v2);
|
||||
Point pos = GetBlockCoordinates(v1);
|
||||
Point end = GetBlockCoordinates(v2);
|
||||
|
||||
// Horizontal straight line?
|
||||
if(pos.Y == end.Y)
|
||||
{
|
||||
// Simple loop
|
||||
dirx = Math.Sign(v2.x - v1.x);
|
||||
int dirx = Math.Sign(v2.x - v1.x);
|
||||
for(int x = pos.X; x != end.X; x += dirx)
|
||||
{
|
||||
GetBlock(new Point(x, pos.Y)).Lines.Add(line);
|
||||
|
@ -340,7 +331,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
else if(pos.X == end.X)
|
||||
{
|
||||
// Simple loop
|
||||
diry = Math.Sign(v2.y - v1.y);
|
||||
int diry = Math.Sign(v2.y - v1.y);
|
||||
for(int y = pos.Y; y != end.Y; y += diry)
|
||||
{
|
||||
GetBlock(new Point(pos.X, y)).Lines.Add(line);
|
||||
|
@ -362,10 +353,11 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
float cb = (pos.Y + 1) * BLOCK_SIZE;
|
||||
|
||||
// Line directions
|
||||
dirx = Math.Sign(v2.x - v1.x);
|
||||
diry = Math.Sign(v2.y - v1.y);
|
||||
int dirx = Math.Sign(v2.x - v1.x);
|
||||
int diry = Math.Sign(v2.y - v1.y);
|
||||
|
||||
// Calculate offset and delta movement over x
|
||||
float posx, deltax;
|
||||
if(dirx == 0)
|
||||
{
|
||||
posx = float.MaxValue;
|
||||
|
@ -384,6 +376,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
}
|
||||
|
||||
// Calculate offset and delta movement over y
|
||||
float posy, deltay;
|
||||
if(diry == 0)
|
||||
{
|
||||
posy = float.MaxValue;
|
||||
|
|
|
@ -44,10 +44,9 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// This shows the dialog, returns false when cancelled
|
||||
public static bool ShowDialog(IWin32Window owner, string title, string elementname, ICollection<MapElement> elements, List<UniversalFieldInfo> fixedfields)
|
||||
{
|
||||
bool result;
|
||||
CustomFieldsForm f = new CustomFieldsForm();
|
||||
f.Setup(title, elementname, elements, fixedfields);
|
||||
result = (f.ShowDialog(owner) == DialogResult.OK);
|
||||
bool result = (f.ShowDialog(owner) == DialogResult.OK);
|
||||
f.Dispose();
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ using CodeImp.DoomBuilder.Actions;
|
|||
using System.Globalization;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
using System.IO;
|
||||
using Action = CodeImp.DoomBuilder.Actions.Action;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -55,9 +56,6 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// Constructor
|
||||
public PreferencesForm()
|
||||
{
|
||||
Actions.Action[] actions;
|
||||
ListViewItem item;
|
||||
|
||||
// Initialize
|
||||
InitializeComponent();
|
||||
|
||||
|
@ -139,14 +137,14 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
listactions.Groups.Add(c.Key, c.Value);
|
||||
|
||||
// Fill list of actions
|
||||
actions = General.Actions.GetAllActions();
|
||||
Action[] actions = General.Actions.GetAllActions();
|
||||
actionListItems = new List<ListViewItem>(); //mxd
|
||||
actionListItemsGroupIndices = new List<int>(); //mxd
|
||||
foreach(Actions.Action a in actions)
|
||||
foreach(Action a in actions)
|
||||
{
|
||||
// Create item
|
||||
item = listactions.Items.Add(a.Name, a.Title, 0);
|
||||
item.SubItems.Add(Actions.Action.GetShortcutKeyDesc(a.ShortcutKey));
|
||||
ListViewItem item = listactions.Items.Add(a.Name, a.Title, 0);
|
||||
item.SubItems.Add(Action.GetShortcutKeyDesc(a.ShortcutKey));
|
||||
item.SubItems[1].Tag = a.ShortcutKey;
|
||||
|
||||
// Put in category, if the category exists
|
||||
|
|
|
@ -486,7 +486,6 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
private void filteraction_ValueChanges(object sender, EventArgs e)
|
||||
{
|
||||
int showaction = 0;
|
||||
ArgumentInfo[] arginfo;
|
||||
|
||||
// Anything selected?
|
||||
if(listfilters.SelectedItems.Count > 0)
|
||||
|
@ -503,7 +502,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
|
||||
// Only when line type is known, otherwise use the thing arguments
|
||||
if(General.Map.Config.LinedefActions.ContainsKey(filteraction.Value)) showaction = filteraction.Value;
|
||||
arginfo = General.Map.Config.LinedefActions[showaction].Args;
|
||||
ArgumentInfo[] arginfo = General.Map.Config.LinedefActions[showaction].Args;
|
||||
|
||||
// Change the argument descriptions
|
||||
arg0label.Text = arginfo[0].Title + ":";
|
||||
|
@ -516,11 +515,11 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
arg2label.Enabled = arginfo[2].Used;
|
||||
arg3label.Enabled = arginfo[3].Used;
|
||||
arg4label.Enabled = arginfo[4].Used;
|
||||
if(arg0label.Enabled) arg0.ForeColor = SystemColors.WindowText; else arg0.ForeColor = SystemColors.GrayText;
|
||||
if(arg1label.Enabled) arg1.ForeColor = SystemColors.WindowText; else arg1.ForeColor = SystemColors.GrayText;
|
||||
if(arg2label.Enabled) arg2.ForeColor = SystemColors.WindowText; else arg2.ForeColor = SystemColors.GrayText;
|
||||
if(arg3label.Enabled) arg3.ForeColor = SystemColors.WindowText; else arg3.ForeColor = SystemColors.GrayText;
|
||||
if(arg4label.Enabled) arg4.ForeColor = SystemColors.WindowText; else arg4.ForeColor = SystemColors.GrayText;
|
||||
arg0.ForeColor = (arg0label.Enabled ? SystemColors.WindowText : SystemColors.GrayText);
|
||||
arg1.ForeColor = (arg1label.Enabled ? SystemColors.WindowText : SystemColors.GrayText);
|
||||
arg2.ForeColor = (arg2label.Enabled ? SystemColors.WindowText : SystemColors.GrayText);
|
||||
arg3.ForeColor = (arg3label.Enabled ? SystemColors.WindowText : SystemColors.GrayText);
|
||||
arg4.ForeColor = (arg4label.Enabled ? SystemColors.WindowText : SystemColors.GrayText);
|
||||
arg0.Setup(arginfo[0]);
|
||||
arg1.Setup(arginfo[1]);
|
||||
arg2.Setup(arginfo[2]);
|
||||
|
|
|
@ -227,16 +227,16 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
Vector2D tl, br;
|
||||
|
||||
// don't move if the offset contains invalid data
|
||||
if (!offset.IsFinite()) return false;
|
||||
if(!offset.IsFinite()) return false;
|
||||
|
||||
// Find the outmost vertices
|
||||
tl = br = oldpositions[0];
|
||||
for (int i = 0; i < oldpositions.Count; i++)
|
||||
for(int i = 0; i < oldpositions.Count; i++)
|
||||
{
|
||||
if (oldpositions[i].x < tl.x) tl.x = (int)oldpositions[i].x;
|
||||
if (oldpositions[i].x > br.x) br.x = (int)oldpositions[i].x;
|
||||
if (oldpositions[i].y > tl.y) tl.y = (int)oldpositions[i].y;
|
||||
if (oldpositions[i].y < br.y) br.y = (int)oldpositions[i].y;
|
||||
if(oldpositions[i].x < tl.x) tl.x = (int)oldpositions[i].x;
|
||||
if(oldpositions[i].x > br.x) br.x = (int)oldpositions[i].x;
|
||||
if(oldpositions[i].y > tl.y) tl.y = (int)oldpositions[i].y;
|
||||
if(oldpositions[i].y < br.y) br.y = (int)oldpositions[i].y;
|
||||
}
|
||||
|
||||
// Snap to nearest?
|
||||
|
|
|
@ -184,11 +184,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Fix both sides
|
||||
public override bool Button2Click(bool batchMode)
|
||||
{
|
||||
Sidedef newside;
|
||||
if(!batchMode) General.Map.UndoRedo.CreateUndo("Create sidedefs");
|
||||
|
||||
// Front
|
||||
newside = General.Map.Map.CreateSidedef(line, true, copysidedeffront.Sector);
|
||||
Sidedef newside = General.Map.Map.CreateSidedef(line, true, copysidedeffront.Sector);
|
||||
if(newside == null) return false;
|
||||
copysidedeffront.CopyPropertiesTo(newside);
|
||||
|
||||
|
|
|
@ -520,11 +520,8 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
|
|||
// If the vertices were created in counter-clockwise order turn them into clockwise order
|
||||
if (!clockwise)
|
||||
{
|
||||
List<Vector2D> tmpvertices;
|
||||
int tmpmultiplier;
|
||||
|
||||
tmpvertices = innervertices;
|
||||
tmpmultiplier = innervertexmultiplier;
|
||||
List<Vector2D> tmpvertices = innervertices;
|
||||
int tmpmultiplier = innervertexmultiplier;
|
||||
|
||||
innervertices = outervertices;
|
||||
outervertices = tmpvertices;
|
||||
|
@ -968,10 +965,9 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
|
|||
private List<Vector2D> GenerateCatmullRom(CatmullRomSplineData crsd, int numverts)
|
||||
{
|
||||
List<Vector2D> vertices = new List<Vector2D>();
|
||||
int sections = crsd.controlpoints.Count - 1;
|
||||
//int sections = crsd.controlpoints.Count - 1;
|
||||
//double hop = (double)sections / numverts;
|
||||
float distance = 0.0f;
|
||||
float unithop;
|
||||
List<float> cpdistance = new List<float>();
|
||||
|
||||
// Compute the length of the whole spline and the length of the parts on the
|
||||
|
@ -1004,7 +1000,7 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
|
|||
exactsplines.Add(dc);
|
||||
}
|
||||
|
||||
unithop = distance / numverts;
|
||||
float unithop = distance / numverts;
|
||||
|
||||
for (int i = 0; i <= numverts; i++)
|
||||
{
|
||||
|
@ -1277,7 +1273,7 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
|
|||
foreach (List<Vector2D> lv in si.sectors)
|
||||
{
|
||||
List<Sector> oldsectors = new List<Sector>(General.Map.Map.Sectors);
|
||||
List<Sector> newsectors = new List<Sector>();
|
||||
//List<Sector> newsectors = new List<Sector>();
|
||||
List<DrawnVertex> vertices = new List<DrawnVertex>();
|
||||
|
||||
for (int i = 0; i < lv.Count; i++)
|
||||
|
|
Loading…
Reference in a new issue