mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 04:12:12 +00:00
Added Xabis' ACS includes patch (well, most of it)
This commit is contained in:
parent
1afd4febb6
commit
e243450f74
5 changed files with 151 additions and 18 deletions
|
@ -77,7 +77,30 @@ namespace CodeImp.DoomBuilder.Compilers
|
|||
TimeSpan deltatime;
|
||||
int line = 0;
|
||||
string sourcedir = Path.GetDirectoryName(sourcefile);
|
||||
|
||||
|
||||
// Copy includes from the resources into the compiler's folder, preserving relative pathing and naming
|
||||
foreach (string include in General.Map.ScriptIncludes) {
|
||||
//grab the script text from the resources
|
||||
MemoryStream s = General.Map.Data.LoadFile(include);
|
||||
if (s != null) {
|
||||
//pull the pk3 or directory sub folder out if applicable
|
||||
FileInfo fi = new FileInfo(this.tempdir.FullName + @"\" + include);
|
||||
|
||||
//do not allow files to be overwritten, either accidentally or maliciously
|
||||
if (!fi.Exists) {
|
||||
General.WriteLogLine("Copying script include: " + include);
|
||||
|
||||
//create the directory path as needed
|
||||
if (fi.DirectoryName != "")
|
||||
Directory.CreateDirectory(fi.DirectoryName);
|
||||
|
||||
//dump the script into the target file
|
||||
BinaryReader reader = new BinaryReader(s);
|
||||
File.WriteAllBytes(fi.FullName, reader.ReadBytes((int)s.Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create parameters
|
||||
string args = this.parameters;
|
||||
args = args.Replace("%FI", inputfile);
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
internal IncludeDelegate OnInclude;
|
||||
|
||||
private List<string> parsedLumps;
|
||||
private List<string> includes;
|
||||
|
||||
private List<ScriptItem> namedScripts;
|
||||
private List<ScriptItem> numberedScripts;
|
||||
|
@ -27,18 +28,29 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom
|
|||
namedScripts = new List<ScriptItem>();
|
||||
numberedScripts = new List<ScriptItem>();
|
||||
parsedLumps = new List<string>();
|
||||
includes = new List<string>();
|
||||
}
|
||||
|
||||
internal List<string> Includes {
|
||||
get { return includes; }
|
||||
}
|
||||
|
||||
public override bool Parse(Stream stream, string sourcefilename) {
|
||||
return Parse(stream, sourcefilename, false);
|
||||
return Parse(stream, sourcefilename, false, false);
|
||||
}
|
||||
|
||||
public bool Parse(Stream stream, string sourcefilename, bool processIncludes) {
|
||||
return Parse(stream, sourcefilename, processIncludes, false);
|
||||
}
|
||||
|
||||
public bool Parse(Stream stream, string sourcefilename, bool processIncludes, bool isinclude) {
|
||||
base.Parse(stream, sourcefilename);
|
||||
|
||||
//already parsed this?
|
||||
if (parsedLumps.IndexOf(sourcefilename) != -1) return false;
|
||||
parsedLumps.Add(sourcefilename);
|
||||
if (isinclude)
|
||||
includes.Add(sourcefilename);
|
||||
|
||||
// Keep local data
|
||||
Stream localstream = datastream;
|
||||
|
|
|
@ -89,6 +89,7 @@ namespace CodeImp.DoomBuilder {
|
|||
//mxd
|
||||
private List<ScriptItem> namedScripts;
|
||||
private List<ScriptItem> numberedScripts;
|
||||
private List<string> scriptincludes;
|
||||
|
||||
// Disposing
|
||||
private bool isdisposed = false;
|
||||
|
@ -132,6 +133,8 @@ namespace CodeImp.DoomBuilder {
|
|||
}
|
||||
}
|
||||
internal List<ScriptItem> NumberedScripts { get { return numberedScripts; } }
|
||||
internal List<string> ScriptIncludes { get { return scriptincludes; } }
|
||||
|
||||
public ViewMode ViewMode { get { return renderer2d.ViewMode; } }
|
||||
|
||||
#endregion
|
||||
|
@ -159,6 +162,7 @@ namespace CodeImp.DoomBuilder {
|
|||
//mxd
|
||||
numberedScripts = new List<ScriptItem>();
|
||||
namedScripts = new List<ScriptItem>();
|
||||
scriptincludes = new List<string>();
|
||||
}
|
||||
|
||||
// Disposer
|
||||
|
@ -1398,6 +1402,7 @@ namespace CodeImp.DoomBuilder {
|
|||
parser.Parse(stream, "SCRIPTS", true);
|
||||
namedScripts.AddRange(parser.NamedScripts);
|
||||
numberedScripts.AddRange(parser.NumberedScripts);
|
||||
scriptincludes.AddRange(parser.Includes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1410,7 +1415,7 @@ namespace CodeImp.DoomBuilder {
|
|||
//mxd
|
||||
private void updateScriptsFromLocation(AcsParserSE parser, string path) {
|
||||
MemoryStream s = General.Map.Data.LoadFile(path);
|
||||
if(s != null && s.Length > 0) parser.Parse(s, path, true);
|
||||
if(s != null && s.Length > 0) parser.Parse(s, path, true, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -105,8 +105,33 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Interpret the number given
|
||||
int action = 0;
|
||||
if(int.TryParse(value, out action))
|
||||
int[] args = null;
|
||||
string[] parts = value.Split(';');
|
||||
bool match;
|
||||
string argtext;
|
||||
|
||||
//For the search, the user may make the following query:
|
||||
// action;arg0,arg1,arg2,arg3,arg4
|
||||
//
|
||||
//this allows users to search for lines that contain actions with specific arguments.
|
||||
//useful for locating script lines
|
||||
//
|
||||
//Since the Linedef object does not contain a reference to arg0str, this search cannot match named scripts
|
||||
|
||||
if(int.TryParse(parts[0], out action))
|
||||
{
|
||||
//parse the arg value out
|
||||
if (parts.Length > 1) {
|
||||
args = new int[] {0, 0, 0, 0, 0};
|
||||
string[] argparts = parts[1].Split(',');
|
||||
int argout;
|
||||
for(int i = 0; i < argparts.Length && i < args.Length; i++) {
|
||||
if (int.TryParse(argparts[i], out argout)) {
|
||||
args[i] = argout;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Where to search?
|
||||
ICollection<Linedef> list = withinselection ? General.Map.Map.GetSelectedLinedefs(true) : General.Map.Map.Linedefs;
|
||||
|
||||
|
@ -116,15 +141,34 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Action matches?
|
||||
if(l.Action == action)
|
||||
{
|
||||
// Replace
|
||||
if(replacewith != null) l.Action = replaceaction;
|
||||
match = true;
|
||||
argtext = "";
|
||||
|
||||
// Add to list
|
||||
LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
|
||||
if(!info.IsNull)
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.Index + " (" + info.Title + ")"));
|
||||
else
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.Index));
|
||||
//if args were specified, then process them
|
||||
if (args != null) {
|
||||
argtext = " args: (";
|
||||
for (int x = 0; x < args.Length; x++)
|
||||
{
|
||||
if (args[x] != 0 && args[x] != l.Args[x]) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
argtext += (x == 0 ? "" : ",") + l.Args[x].ToString();
|
||||
}
|
||||
argtext += ")";
|
||||
}
|
||||
|
||||
if (match) {
|
||||
// Replace
|
||||
if (replacewith != null) l.Action = replaceaction;
|
||||
|
||||
// Add to list
|
||||
LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
|
||||
if (!info.IsNull)
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.Index + " (" + info.Title + ")" + argtext));
|
||||
else
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.Index + argtext));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,8 +114,37 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Interpret the number given
|
||||
int findaction = 0;
|
||||
if(int.TryParse(value, out findaction))
|
||||
int[] args = null;
|
||||
string[] parts = value.Split(';');
|
||||
bool match;
|
||||
string argtext;
|
||||
|
||||
//For the search, the user may make the following query:
|
||||
// action;arg0,arg1,arg2,arg3,arg4
|
||||
//
|
||||
//this allows users to search for things that contain actions with specific arguments.
|
||||
//useful for locating enemies that trigger a certain script
|
||||
//
|
||||
//Since the Thing object does not contain a reference to arg0str, this search cannot match named scripts
|
||||
|
||||
|
||||
if (int.TryParse(parts[0], out findaction))
|
||||
{
|
||||
//parse the arg value out
|
||||
if (parts.Length > 1)
|
||||
{
|
||||
args = new int[] { 0, 0, 0, 0, 0 };
|
||||
string[] argparts = parts[1].Split(',');
|
||||
int argout;
|
||||
for (int i = 0; i < argparts.Length && i < args.Length; i++)
|
||||
{
|
||||
if (int.TryParse(argparts[i], out argout))
|
||||
{
|
||||
args[i] = argout;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Where to search?
|
||||
ICollection<Thing> list = withinselection ? General.Map.Map.GetSelectedThings(true) : General.Map.Map.Things;
|
||||
|
||||
|
@ -125,12 +154,32 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Match?
|
||||
if(t.Action == findaction)
|
||||
{
|
||||
// Replace
|
||||
if(replacewith != null) t.Action = replaceaction;
|
||||
match = true;
|
||||
argtext = "";
|
||||
|
||||
// Add to list
|
||||
ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type);
|
||||
objs.Add(new FindReplaceObject(t, "Thing " + t.Index + " (" + ti.Title + ")"));
|
||||
//if args were specified, then process them
|
||||
if (args != null) {
|
||||
argtext = " args: (";
|
||||
for (int x = 0; x < args.Length; x++)
|
||||
{
|
||||
if (args[x] != 0 && args[x] != t.Args[x]) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
argtext += (x == 0 ? "" : ",") + t.Args[x].ToString();
|
||||
}
|
||||
argtext += ")";
|
||||
}
|
||||
|
||||
if (match)
|
||||
{
|
||||
// Replace
|
||||
if (replacewith != null) t.Action = replaceaction;
|
||||
|
||||
// Add to list
|
||||
ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type);
|
||||
objs.Add(new FindReplaceObject(t, "Thing " + t.Index + " (" + ti.Title + ")" + argtext));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue