Hints panel was improperly resized in some cases.

Info panel was not updated after leaving Visual mode.
Moved hints logic to ClassicMode, so hints can be displayed by any plugin.
Visual mode: dynamic light animation was not working.
Minor performance improvements in Actor, Configuration, UDMF and TEXTURES parsers.
This commit is contained in:
MaxED 2013-12-18 09:11:04 +00:00
parent b1b3dda28b
commit ae56aad3b7
15 changed files with 432 additions and 446 deletions

View file

@ -17,7 +17,6 @@
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using CodeImp.DoomBuilder.IO;

View file

@ -79,6 +79,10 @@ namespace CodeImp.DoomBuilder.Editing
//mxd. used in "Play From Here" Action
private Thing playerStart;
private Vector3D playerStartPosition;
//mxd. Hints
protected string[] hints;
protected string[] multiselectionHints;
#endregion
@ -137,6 +141,8 @@ namespace CodeImp.DoomBuilder.Editing
Vector2D campos = new Vector2D(General.Map.VisualCamera.Position.x, General.Map.VisualCamera.Position.y);
renderer2d.PositionView(campos.x, campos.y);
}
SetupHints(); //mxd
}
// Disposer
@ -591,6 +597,10 @@ namespace CodeImp.DoomBuilder.Editing
/// </summary>
public override void OnEngage()
{
//mxd. Update hints
General.Interface.HideInfo();
General.Interface.ShowEditModeHints(hints);
// Clear display overlay
renderer.StartOverlay(true);
renderer.Finish();
@ -711,6 +721,7 @@ namespace CodeImp.DoomBuilder.Editing
protected virtual void OnEndMultiSelection()
{
selecting = false;
General.Interface.ShowEditModeHints(hints); //mxd
}
/// <summary>
@ -721,6 +732,10 @@ namespace CodeImp.DoomBuilder.Editing
selecting = true;
selectstart = mousemappos;
selectionrect = new RectangleF(selectstart.x, selectstart.y, 0, 0);
//mxd
General.Interface.HideInfo();
General.Interface.ShowEditModeHints(multiselectionHints);
}
/// <summary>
@ -784,6 +799,14 @@ namespace CodeImp.DoomBuilder.Editing
ScrollBy(lastmappos.x - mousemappos.x, lastmappos.y - mousemappos.y);
}
}
/// <summary>
/// Override this to setup hints for this editing mode
/// </summary>
protected virtual void SetupHints() { //mxd
hints = new[] { "Press F1 to view help about current editing mode" };
multiselectionHints = new[] { "Press F1 to view help about current editing mode" };
}
#endregion

View file

@ -14,8 +14,8 @@ namespace CodeImp.DoomBuilder.GZBuilder
public static int[] GZ_LIGHTS { get { return gzLights; } }
private static int[] gzLightTypes = { 5, 10, 15 }; //these are actually offsets in gz_lights
public static int[] GZ_LIGHT_TYPES { get { return gzLightTypes; } }
private static int[] gzAnimatedLightTypes = { (int)DynamicLightType.FLICKER, (int)DynamicLightType.RANDOM, (int)DynamicLightType.PULSE };
public static int[] GZ_ANIMATED_LIGHT_TYPES { get { return gzAnimatedLightTypes; } }
private static DynamicLightType[] gzAnimatedLightTypes = { DynamicLightType.FLICKER, DynamicLightType.RANDOM, DynamicLightType.PULSE };
public static DynamicLightType[] GZ_ANIMATED_LIGHT_TYPES { get { return gzAnimatedLightTypes; } }
//asc script action specials
private static int[] acsSpecials = { 80, 81, 82, 83, 84, 85, 226 };

View file

@ -24,6 +24,7 @@ using CodeImp.DoomBuilder.Actions;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Windows;
using System.Threading;
using CodeImp.DoomBuilder.IO;
#endregion
@ -33,8 +34,6 @@ namespace CodeImp.DoomBuilder
{
#region ================== Constants
private const string NUMBERS = "0123456789";
#endregion
#region ================== Variables
@ -155,7 +154,7 @@ namespace CodeImp.DoomBuilder
foreach(char c in General.Map.Options.CurrentName)
{
// Character is a number?
if(NUMBERS.IndexOf(c) > -1)
if(Configuration.NUMBERS.IndexOf(c) > -1)
{
// Include it
numstr += c;

View file

@ -161,7 +161,10 @@ namespace CodeImp.DoomBuilder.IO
private const string ERROR_UNKNOWN_FUNCTION = "Unknown function call.";
private const string ERROR_INVALID_ARGS = "Invalid function arguments.";
private const string ERROR_INCLUDE_UNSUPPORTED = "Include function is not supported in data parsed from stream.";
public const string NUMBERS = "0123456789";
public const string NUMBERS2 = "0123456789-.&";
#endregion
#region ================== Variables
@ -460,8 +463,8 @@ namespace CodeImp.DoomBuilder.IO
else
{
// Check if we can test existance
if(container != null)
{
//if(container != null)
//{
/*
// Test if the key exists in this container
if(container.Contains(key) == true)
@ -472,16 +475,16 @@ namespace CodeImp.DoomBuilder.IO
}
else
*/
{
//{
// Key OK
validateresult = true;
}
}
else
{
//validateresult = true;
//}
//}
//else
//{
// Key OK
validateresult = true;
}
//}
}
}
@ -545,7 +548,7 @@ namespace CodeImp.DoomBuilder.IO
if(cpErrorResult) return null;
}
// Check for numeric character
else if("0123456789-.&".IndexOf(c.ToString(CultureInfo.InvariantCulture)) > -1)
else if(NUMBERS2.IndexOf(c.ToString(CultureInfo.InvariantCulture)) > -1)
{
// Go one byte back, because this
// byte is part of the number!
@ -612,7 +615,7 @@ namespace CodeImp.DoomBuilder.IO
default:
// Is it a number?
if("0123456789".IndexOf(c.ToString(CultureInfo.InvariantCulture)) > -1)
if(NUMBERS.IndexOf(c.ToString(CultureInfo.InvariantCulture)) > -1)
{
int vv = 0;
char vc = '0';
@ -654,28 +657,29 @@ namespace CodeImp.DoomBuilder.IO
}
else
{
// Check for sequence start
if(c == '\\')
{
// Next character is of escape sequence
escape = true;
}
// Check if string ends
else if(c == '\"')
{
return val;
}
// Check for new line
else if(c == '\n')
{
// Count the new line
line++;
}
// Everything else is just part of string
else
{
// Add to value
val += c.ToString(CultureInfo.InvariantCulture);
switch (c) { //mxd
// Check for sequence start
case '\\':
// Next character is of escape sequence
escape = true;
break;
// Check if string ends
case '\"':
return val;
break;
// Check for new line
case '\n':
// Count the new line
line++;
break;
// Everything else is just part of string
default:
// Add to value
val += c.ToString(CultureInfo.InvariantCulture);
break;
}
}
}
@ -929,7 +933,7 @@ namespace CodeImp.DoomBuilder.IO
args.Add(val);
}
// Check for numeric character
else if("0123456789-.&".IndexOf(c.ToString(CultureInfo.InvariantCulture)) > -1)
else if(NUMBERS2.IndexOf(c.ToString(CultureInfo.InvariantCulture)) > -1)
{
// Go one byte back, because this
// byte is part of the number!

View file

@ -332,7 +332,7 @@ namespace CodeImp.DoomBuilder.IO
pm = PM_STRING;
}
// Check for numeric character
else if("0123456789-.&".IndexOf(c.ToString(CultureInfo.InvariantCulture)) > -1)
else if(Configuration.NUMBERS2.IndexOf(c.ToString(CultureInfo.InvariantCulture)) > -1)
{
// Now parsing number
pm = PM_NUMBER;
@ -512,7 +512,7 @@ namespace CodeImp.DoomBuilder.IO
default:
// Is it a number?
if("0123456789".IndexOf(c.ToString(CultureInfo.InvariantCulture)) > -1)
if(Configuration.NUMBERS.IndexOf(c.ToString(CultureInfo.InvariantCulture)) > -1)
{
int vv = 0;
char vc = '0';

View file

@ -950,9 +950,6 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.Shaders.World3D.Texture1 = group.Key;
foreach (VisualGeometry g in group.Value) {
i = 0;
count = 0;
graphics.Device.SetStreamSource(0, g.Sector.GeometryBuffer, 0, WorldVertex.Stride);
//normal lights
@ -963,8 +960,7 @@ namespace CodeImp.DoomBuilder.Rendering
for (i = 0; i < count; i++) {
if (checkBBoxIntersection(g.BoundingBox, lights[i].BoundingBox)) {
lpr = new Vector4(lights[i].Center, lights[i].LightRadius);
if (lpr.W == 0)
continue;
if (lpr.W == 0) continue;
graphics.Shaders.World3D.LightColor = lights[i].LightColor;
graphics.Shaders.World3D.LightPositionAndRadius = lpr;
graphics.Shaders.World3D.ApplySettings();
@ -973,7 +969,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
}
//additive lights.
//additive lights
if (lightOffsets[1] > 0) {
count += lightOffsets[1];
graphics.Device.SetRenderState(RenderState.BlendOperation, BlendOperation.Add);
@ -981,8 +977,7 @@ namespace CodeImp.DoomBuilder.Rendering
for (i = lightOffsets[0]; i < count; i++) {
if (checkBBoxIntersection(g.BoundingBox, lights[i].BoundingBox)) {
lpr = new Vector4(lights[i].Center, lights[i].LightRadius);
if (lpr.W == 0)
continue;
if (lpr.W == 0) continue;
graphics.Shaders.World3D.LightColor = lights[i].LightColor;
graphics.Shaders.World3D.LightPositionAndRadius = lpr;
graphics.Shaders.World3D.ApplySettings();
@ -999,8 +994,7 @@ namespace CodeImp.DoomBuilder.Rendering
for (i = lightOffsets[0] + lightOffsets[1]; i < count; i++) {
if (checkBBoxIntersection(g.BoundingBox, lights[i].BoundingBox)) {
lpr = new Vector4(lights[i].Center, lights[i].LightRadius);
if (lpr.W == 0)
continue;
if (lpr.W == 0) continue;
Color4 lc = lights[i].LightColor;
graphics.Shaders.World3D.LightColor = new Color4(lc.Alpha, (lc.Green + lc.Blue) / 2, (lc.Red + lc.Blue) / 2, (lc.Green + lc.Red) / 2);
graphics.Shaders.World3D.LightPositionAndRadius = lpr;

View file

@ -38,14 +38,14 @@ namespace CodeImp.DoomBuilder.Windows
System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
System.Windows.Forms.ListViewItem listViewItem25 = new System.Windows.Forms.ListViewItem("Press Use to use");
System.Windows.Forms.ListViewItem listViewItem26 = new System.Windows.Forms.ListViewItem("To look around, look around");
System.Windows.Forms.ListViewItem listViewItem27 = new System.Windows.Forms.ListViewItem("Another usefull hint");
System.Windows.Forms.ListViewItem listViewItem28 = new System.Windows.Forms.ListViewItem("Yet another usefull hint");
System.Windows.Forms.ListViewItem listViewItem29 = new System.Windows.Forms.ListViewItem("Yet another usefull hint");
System.Windows.Forms.ListViewItem listViewItem30 = new System.Windows.Forms.ListViewItem("Yet another usefull hint");
System.Windows.Forms.ListViewItem listViewItem31 = new System.Windows.Forms.ListViewItem("Yet another usefull hint");
System.Windows.Forms.ListViewItem listViewItem32 = new System.Windows.Forms.ListViewItem("Yet another usefull hint");
System.Windows.Forms.ListViewItem listViewItem9 = new System.Windows.Forms.ListViewItem("Press Use to use");
System.Windows.Forms.ListViewItem listViewItem10 = new System.Windows.Forms.ListViewItem("To look around, look around");
System.Windows.Forms.ListViewItem listViewItem11 = new System.Windows.Forms.ListViewItem("Another usefull hint");
System.Windows.Forms.ListViewItem listViewItem12 = new System.Windows.Forms.ListViewItem("Yet another usefull hint");
System.Windows.Forms.ListViewItem listViewItem13 = new System.Windows.Forms.ListViewItem("Yet another usefull hint");
System.Windows.Forms.ListViewItem listViewItem14 = new System.Windows.Forms.ListViewItem("Yet another usefull hint");
System.Windows.Forms.ListViewItem listViewItem15 = new System.Windows.Forms.ListViewItem("Yet another usefull hint");
System.Windows.Forms.ListViewItem listViewItem16 = new System.Windows.Forms.ListViewItem("Yet another usefull hint");
this.seperatorfileopen = new System.Windows.Forms.ToolStripSeparator();
this.seperatorfilerecent = new System.Windows.Forms.ToolStripSeparator();
this.seperatoreditgrid = new System.Windows.Forms.ToolStripSeparator();
@ -2158,21 +2158,19 @@ namespace CodeImp.DoomBuilder.Windows
//
// hints
//
this.hints.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.hints.BackColor = System.Drawing.SystemColors.Control;
this.hints.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.hints.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.hints.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.hints.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
listViewItem25,
listViewItem26,
listViewItem27,
listViewItem28,
listViewItem29,
listViewItem30,
listViewItem31,
listViewItem32});
listViewItem9,
listViewItem10,
listViewItem11,
listViewItem12,
listViewItem13,
listViewItem14,
listViewItem15,
listViewItem16});
this.hints.LabelWrap = false;
this.hints.Location = new System.Drawing.Point(20, 21);
this.hints.MultiSelect = false;

View file

@ -2830,8 +2830,11 @@ namespace CodeImp.DoomBuilder.Windows
public void ShowEditModeHints(string[] hintsText) {
if (hintsText != null) {
hintIcon.Visible = true;
hints.BeginUpdate();
hints.Items.Clear();
foreach (string s in hintsText) hints.Items.Add(s);
hints.EndUpdate();
} else {
ClearEditModeHints();
}

View file

@ -195,6 +195,24 @@
<metadata name="sectorinfo.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="heightpanel1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="labelcollapsedinfo.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="buttontoggleinfo.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="linedefinfo.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="thinginfo.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="sectorinfo.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="redrawtimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>433, 17</value>
</metadata>

View file

@ -79,6 +79,7 @@ namespace CodeImp.DoomBuilder.ZDoom
props = new Dictionary<string, List<string>>();
states = new Dictionary<string, StateStructure>();
userVars = new List<string>();//mxd
bool done = false; //mxd
// Always define a game property, but default to 0 values
props["game"] = new List<string>();
@ -104,59 +105,58 @@ namespace CodeImp.DoomBuilder.ZDoom
if(!string.IsNullOrEmpty(token))
{
token = token.ToLowerInvariant();
if(token == ":")
{
// The next token must be the class to inherit from
parser.SkipWhitespace(true);
inheritclass = parser.StripTokenQuotes(parser.ReadToken());
if(string.IsNullOrEmpty(inheritclass) || parser.IsSpecialToken(inheritclass))
{
parser.ReportError("Expected class name to inherit from");
return;
}
else
{
switch (token) {
case ":":
// The next token must be the class to inherit from
parser.SkipWhitespace(true);
inheritclass = parser.StripTokenQuotes(parser.ReadToken());
if(string.IsNullOrEmpty(inheritclass) || parser.IsSpecialToken(inheritclass)) {
parser.ReportError("Expected class name to inherit from");
return;
}
// Find the actor to inherit from
baseclass = parser.GetArchivedActorByName(inheritclass);
}
}
else if(token == "replaces")
{
// The next token must be the class to replace
parser.SkipWhitespace(true);
replaceclass = parser.StripTokenQuotes(parser.ReadToken());
if(string.IsNullOrEmpty(replaceclass) || parser.IsSpecialToken(replaceclass))
{
parser.ReportError("Expected class name to replace");
return;
}
}
else if(token == "native")
{
// Igore this token
}
else if(token == "{")
{
// Actor scope begins here,
// break out of this parse loop
break;
}
else if(token == "-")
{
// This could be a negative doomednum (but our parser sees the - as separate token)
// So read whatever is after this token and ignore it (negative doomednum indicates no doomednum)
parser.ReadToken();
}
else
{
// Check if numeric
if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out doomednum))
{
// Not numeric!
parser.ReportError("Expected numeric editor thing number or start of actor scope while parsing '" + classname + "'");
return;
}
break;
case "replaces":
// The next token must be the class to replace
parser.SkipWhitespace(true);
replaceclass = parser.StripTokenQuotes(parser.ReadToken());
if(string.IsNullOrEmpty(replaceclass) || parser.IsSpecialToken(replaceclass)) {
parser.ReportError("Expected class name to replace");
return;
}
break;
case "native":
// Igore this token
break;
case "{":
// Actor scope begins here,
// break out of this parse loop
done = true;
break;
case "-":
// This could be a negative doomednum (but our parser sees the - as separate token)
// So read whatever is after this token and ignore it (negative doomednum indicates no doomednum)
parser.ReadToken();
break;
default:
// Check if numeric
if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out doomednum)) {
// Not numeric!
parser.ReportError("Expected numeric editor thing number or start of actor scope while parsing '" + classname + "'");
return;
}
break;
}
if (done) break; //mxd
}
else
{
@ -167,191 +167,175 @@ namespace CodeImp.DoomBuilder.ZDoom
// Now parse the contents of actor structure
string previoustoken = "";
done = false; //mxd
while(parser.SkipWhitespace(true))
{
string token = parser.ReadToken();
token = token.ToLowerInvariant();
if((token == "+") || (token == "-"))
{
// Next token is a flag (option) to set or remove
bool flagvalue = (token == "+");
parser.SkipWhitespace(true);
string flagname = parser.ReadToken();
if(!string.IsNullOrEmpty(flagname))
{
// Add the flag with its value
flagname = flagname.ToLowerInvariant();
flags[flagname] = flagvalue;
}
else
{
parser.ReportError("Expected flag name");
return;
}
}
else if((token == "action") || (token == "native"))
{
// We don't need this, ignore up to the first next ;
while(parser.SkipWhitespace(true))
{
string t = parser.ReadToken();
if((t == ";") || (t == null)) break;
}
}
else if(token == "skip_super")
{
skipsuper = true;
}
else if(token == "states")
{
// Now parse actor states until we reach the end of the states structure
while(parser.SkipWhitespace(true))
{
string statetoken = parser.ReadToken();
if(!string.IsNullOrEmpty(statetoken))
{
// Start of scope?
if(statetoken == "{")
{
// This is fine
}
// End of scope?
else if(statetoken == "}")
{
// Done with the states,
// break out of this parse loop
switch (token) {
case "+":
case "-":
// Next token is a flag (option) to set or remove
bool flagvalue = (token == "+");
parser.SkipWhitespace(true);
string flagname = parser.ReadToken();
if (!string.IsNullOrEmpty(flagname)) {
// Add the flag with its value
flagname = flagname.ToLowerInvariant();
flags[flagname] = flagvalue;
} else {
parser.ReportError("Expected flag name");
return;
}
break;
case "action":
case "native":
// We don't need this, ignore up to the first next ;
while (parser.SkipWhitespace(true)) {
string t = parser.ReadToken();
if ((t == ";") || (t == null))
break;
}
// State label?
else if(statetoken == ":")
{
if(!string.IsNullOrEmpty(previoustoken))
{
// Parse actor state
StateStructure st = new StateStructure(this, parser, previoustoken);
if(parser.HasError) return;
states[previoustoken.ToLowerInvariant()] = st;
}
break;
case "skip_super":
skipsuper = true;
break;
case "states":
// Now parse actor states until we reach the end of the states structure
while (parser.SkipWhitespace(true)) {
string statetoken = parser.ReadToken();
if (!string.IsNullOrEmpty(statetoken)) {
// Start of scope?
if (statetoken == "{") {
// This is fine
}
else
{
parser.ReportError("Unexpected end of structure");
return;
// End of scope?
else if (statetoken == "}") {
// Done with the states,
// break out of this parse loop
break;
}
}
else
{
// Keep token
previoustoken = statetoken;
}
}
else
{
parser.ReportError("Unexpected end of structure");
return;
}
}
}
else if(token == "var") //mxd
{
while(parser.SkipWhitespace(true)) {
string t = parser.ReadToken();
if((t == ";") || (t == null)) break;
if(t.StartsWith("user_") && !userVars.Contains(t)) userVars.Add(t);
}
}
else if(token == "}")
{
// Actor scope ends here,
// break out of this parse loop
break;
}
// Monster property?
else if(token == "monster")
{
// This sets certain flags we are interested in
flags["shootable"] = true;
flags["countkill"] = true;
flags["solid"] = true;
flags["canpushwalls"] = true;
flags["canusewalls"] = true;
flags["activatemcross"] = true;
flags["canpass"] = true;
flags["ismonster"] = true;
}
// Projectile property?
else if(token == "projectile")
{
// This sets certain flags we are interested in
flags["noblockmap"] = true;
flags["nogravity"] = true;
flags["dropoff"] = true;
flags["missile"] = true;
flags["activateimpact"] = true;
flags["activatepcross"] = true;
flags["noteleport"] = true;
}
// Clearflags property?
else if(token == "clearflags")
{
// Clear all flags
flags.Clear();
}
// Game property?
else if(token == "game")
{
// Include all tokens on the same line
List<string> games = new List<string>();
while(parser.SkipWhitespace(false))
{
string v = parser.ReadToken();
if(v == null)
{
parser.ReportError("Unexpected end of structure");
return;
}
if(v == "\n") break;
if (v == "}") return; //mxd
if(v != ",")
games.Add(v.ToLowerInvariant());
}
props[token] = games;
}
// Property
else
{
// Property begins with $? Then the whole line is a single value
if(token.StartsWith("$"))
{
// This is for editor-only properties such as $sprite and $category
List<string> values = new List<string>();
if(parser.SkipWhitespace(false))
values.Add(parser.ReadLine());
else
values.Add("");
props[token] = values;
}
else
{
// Next tokens up until the next newline are values
List<string> values = new List<string>();
while(parser.SkipWhitespace(false))
{
string v = parser.ReadToken();
if(v == null)
{
// State label?
else if (statetoken == ":") {
if (!string.IsNullOrEmpty(previoustoken)) {
// Parse actor state
StateStructure st = new StateStructure(this, parser, previoustoken);
if (parser.HasError)
return;
states[previoustoken.ToLowerInvariant()] = st;
} else {
parser.ReportError("Unexpected end of structure");
return;
}
} else {
// Keep token
previoustoken = statetoken;
}
} else {
parser.ReportError("Unexpected end of structure");
return;
}
if(v == "\n") break;
if (v == "}") return; //mxd
if(v != ",")
values.Add(v);
}
props[token] = values;
}
break;
case "var": //mxd
while (parser.SkipWhitespace(true)) {
string t = parser.ReadToken();
if ((t == ";") || (t == null)) break;
if (t.StartsWith("user_") && !userVars.Contains(t))
userVars.Add(t);
}
break;
case "}":
// Actor scope ends here,
// break out of this parse loop
done = true;
break;
// Monster property?
case "monster":
// This sets certain flags we are interested in
flags["shootable"] = true;
flags["countkill"] = true;
flags["solid"] = true;
flags["canpushwalls"] = true;
flags["canusewalls"] = true;
flags["activatemcross"] = true;
flags["canpass"] = true;
flags["ismonster"] = true;
break;
// Projectile property?
case "projectile":
// This sets certain flags we are interested in
flags["noblockmap"] = true;
flags["nogravity"] = true;
flags["dropoff"] = true;
flags["missile"] = true;
flags["activateimpact"] = true;
flags["activatepcross"] = true;
flags["noteleport"] = true;
break;
// Clearflags property?
case "clearflags":
// Clear all flags
flags.Clear();
break;
// Game property?
case "game":
// Include all tokens on the same line
List<string> games = new List<string>();
while (parser.SkipWhitespace(false)) {
string v = parser.ReadToken();
if (v == null) {
parser.ReportError("Unexpected end of structure");
return;
}
if (v == "\n") break;
if (v == "}") return; //mxd
if (v != ",") games.Add(v.ToLowerInvariant());
}
props[token] = games;
break;
// Property
default:
// Property begins with $? Then the whole line is a single value
if (token.StartsWith("$")) {
// This is for editor-only properties such as $sprite and $category
List<string> values = new List<string>();
if (parser.SkipWhitespace(false))
values.Add(parser.ReadLine());
else
values.Add("");
props[token] = values;
} else {
// Next tokens up until the next newline are values
List<string> values = new List<string>();
while (parser.SkipWhitespace(false)) {
string v = parser.ReadToken();
if (v == null) {
parser.ReportError("Unexpected end of structure");
return;
}
if (v == "\n") break;
if (v == "}") return; //mxd
if (v != ",") values.Add(v);
}
props[token] = values;
}
break;
}
if (done) break; //mxd
// Keep token
previoustoken = token;
}

View file

@ -138,66 +138,69 @@ namespace CodeImp.DoomBuilder.ZDoom
}
// Now parse the contents of texture structure
while(parser.SkipWhitespace(true))
bool done = false; //mxd
while(!done && parser.SkipWhitespace(true))
{
string token = parser.ReadToken();
token = token.ToLowerInvariant();
if(token == "flipx")
{
flipx = true;
}
else if(token == "flipy")
{
flipy = true;
}
else if(token == "alpha")
{
if(!ReadTokenFloat(parser, token, out alpha)) return;
alpha = General.Clamp(alpha, 0.0f, 1.0f);
}
else if(token == "rotate") //mxd
{
if(!ReadTokenInt(parser, token, out rotation)) return;
rotation = rotation % 360; //Coalesce multiples
if(rotation < 0) rotation += 360; //Force positive
if(rotation != 0 && rotation != 90 && rotation != 180 && rotation != 270) {
General.ErrorLogger.Add(ErrorType.Warning, "Got unsupported rotation ("+rotation+") in patch " + name);
rotation = 0;
}
}
else if(token == "style") //mxd
{
string s = "";
if(!ReadTokenString(parser, token, out s)) return;
int index = Array.IndexOf(renderStyles, s.ToLowerInvariant());
renderStyle = index == -1 ? TexturePathRenderStyle.Copy : (TexturePathRenderStyle)index;
}
else if(token == "blend") //mxd
{
int val = 0;
if(!ReadTokenColor(parser, token, out val)) return;
blendColor = PixelColor.FromInt(val);
switch (token) {
case "flipx":
flipx = true;
break;
parser.SkipWhitespace(false);
token = parser.ReadToken();
case "flipy":
flipy = true;
break;
case "alpha":
if (!ReadTokenFloat(parser, token, out alpha)) return;
alpha = General.Clamp(alpha, 0.0f, 1.0f);
break;
case "rotate":
if (!ReadTokenInt(parser, token, out rotation)) return;
rotation = rotation % 360; //Coalesce multiples
if (rotation < 0) rotation += 360; //Force positive
if (rotation != 0 && rotation != 90 && rotation != 180 && rotation != 270) {
General.ErrorLogger.Add(ErrorType.Warning, "Got unsupported rotation (" + rotation + ") in patch " + name);
rotation = 0;
}
break;
case "style": //mxd
string s = "";
if (!ReadTokenString(parser, token, out s)) return;
int index = Array.IndexOf(renderStyles, s.ToLowerInvariant());
renderStyle = index == -1 ? TexturePathRenderStyle.Copy : (TexturePathRenderStyle) index;
break;
case "blend": //mxd
int val = 0;
if (!ReadTokenColor(parser, token, out val)) return;
blendColor = PixelColor.FromInt(val);
if(token == ",") { //read tint ammount
parser.SkipWhitespace(false);
if(!ReadTokenFloat(parser, token, out tintAmmount)) return;
tintAmmount = General.Clamp(tintAmmount, 0.0f, 1.0f);
blendStyle = TexturePathBlendStyle.Tint;
} else {
blendStyle = TexturePathBlendStyle.Blend;
// Rewind so this structure can be read again
parser.DataStream.Seek(-token.Length - 1, SeekOrigin.Current);
}
}
else if(token == "}")
{
// Patch scope ends here,
// break out of this parse loop
break;
token = parser.ReadToken();
if (token == ",") { //read tint ammount
parser.SkipWhitespace(false);
if (!ReadTokenFloat(parser, token, out tintAmmount)) return;
tintAmmount = General.Clamp(tintAmmount, 0.0f, 1.0f);
blendStyle = TexturePathBlendStyle.Tint;
} else {
blendStyle = TexturePathBlendStyle.Blend;
// Rewind so this structure can be read again
parser.DataStream.Seek(-token.Length - 1, SeekOrigin.Current);
}
break;
case "}":
// Patch scope ends here,
// break out of this parse loop
done = true;
break;
}
}
}
@ -220,19 +223,14 @@ namespace CodeImp.DoomBuilder.ZDoom
parser.ReportError("Expected numeric value for property '" + propertyname + "'");
return false;
}
else
{
// Success
return true;
}
}
else
{
// Can't find the property value!
parser.ReportError("Expected a value for property '" + propertyname + "'");
value = 0.0f;
return false;
// Success
return true;
}
// Can't find the property value!
parser.ReportError("Expected a value for property '" + propertyname + "'");
value = 0.0f;
return false;
}
// This reads the next token and sets an integral value, returns false when failed
@ -249,19 +247,15 @@ namespace CodeImp.DoomBuilder.ZDoom
parser.ReportError("Expected integral value for property '" + propertyname + "'");
return false;
}
else
{
// Success
return true;
}
}
else
{
// Can't find the property value!
parser.ReportError("Expected a value for property '" + propertyname + "'");
value = 0;
return false;
// Success
return true;
}
// Can't find the property value!
parser.ReportError("Expected a value for property '" + propertyname + "'");
value = 0;
return false;
}
//mxd. This reads the next token and sets a string value, returns false when failed

View file

@ -136,53 +136,55 @@ namespace CodeImp.DoomBuilder.ZDoom
}
// Now parse the contents of texture structure
while(parser.SkipWhitespace(true))
bool done = false; //mxd
while(!done && parser.SkipWhitespace(true))
{
string token = parser.ReadToken();
token = token.ToLowerInvariant();
if(token == "xscale")
{
if(!ReadTokenFloat(parser, token, out xscale)) return;
}
else if(token == "yscale")
{
if(!ReadTokenFloat(parser, token, out yscale)) return;
}
else if(token == "worldpanning")
{
worldpanning = true;
}
else if(token == "offset")
{
// Read x offset
if(!ReadTokenInt(parser, token, out xoffset)) return;
// Now we should find a comma
parser.SkipWhitespace(true);
tokenstr = parser.ReadToken();
if(tokenstr != ",")
{
parser.ReportError("Expected a comma");
return;
}
// Read y offset
if(!ReadTokenInt(parser, token, out yoffset)) return;
}
else if(token == "patch")
{
// Read patch structure
PatchStructure pt = new PatchStructure(parser);
if(parser.HasError) break;
switch (token) {
case "xscale":
if (!ReadTokenFloat(parser, token, out xscale)) return;
break;
// Add the patch
patches.Add(pt);
}
else if(token == "}")
{
// Actor scope ends here,
// break out of this parse loop
break;
case "yscale":
if (!ReadTokenFloat(parser, token, out yscale)) return;
break;
case "worldpanning":
worldpanning = true;
break;
case "offset":
// Read x offset
if (!ReadTokenInt(parser, token, out xoffset)) return;
// Now we should find a comma
parser.SkipWhitespace(true);
tokenstr = parser.ReadToken();
if (tokenstr != ",") {
parser.ReportError("Expected a comma");
return;
}
// Read y offset
if (!ReadTokenInt(parser, token, out yoffset)) return;
break;
case "patch":
// Read patch structure
PatchStructure pt = new PatchStructure(parser);
if (parser.HasError) break;
// Add the patch
patches.Add(pt);
break;
case "}":
// Actor scope ends here,
// break out of this parse loop
done = true;
break;
}
}
}

View file

@ -297,8 +297,7 @@ namespace CodeImp.DoomBuilder.ZDoom
float val;
bool success = float.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out val);
if (success)
value = val * sign;
if (success) value = val * sign;
return success;
}
@ -312,8 +311,7 @@ namespace CodeImp.DoomBuilder.ZDoom
int val;
bool success = int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out val);
if (success)
value = val * sign;
if (success) value = val * sign;
return success;
}

View file

@ -42,10 +42,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected bool paintselectpressed; //mxd
//mxd. Hints
protected string[] hints;
protected string[] multiselectionHints;
#endregion
#region ================== Properties
@ -58,7 +54,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
public BaseClassicMode()
{
// Initialize
SetupHints(); //mxd
// We have no destructor
GC.SuppressFinalize(this);
@ -81,12 +76,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods
//mxd
public override void OnEngage() {
General.Interface.ShowEditModeHints(hints);
base.OnEngage();
}
// This occurs when the user presses Copy. All selected geometry must be marked for copying!
public override bool OnCopyBegin()
{
@ -154,12 +143,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
marqueSelectionMode = MarqueSelectionMode.SELECT;
}
//mxd
protected override void OnEndMultiSelection() {
General.Interface.ShowEditModeHints(hints);
base.OnEndMultiSelection();
}
//mxd
public override void OnUndoEnd() {
General.Map.Renderer2D.UpdateExtraFloorFlag();
@ -180,13 +163,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.RedrawDisplay(); // Redraw display to hide changes :)
}
//mxd
protected override void StartMultiSelection() {
General.Interface.HideInfo();
General.Interface.ShowEditModeHints(multiselectionHints);
base.StartMultiSelection();
}
//mxd
protected virtual void updateSelectionInfo() {
General.Interface.DisplayStatus(StatusType.Selection, string.Empty);
@ -231,12 +207,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
General.Interface.OnEditFormValuesChanged -= thingEditForm_OnValuesChanged;
}
//mxd
protected virtual void SetupHints() {
hints = new[] { "Press F1 to view help about current editing mode" };
multiselectionHints = new[] { "Press F1 to view help about current editing mode" };
}
#endregion