static void DoFileWrite(string path, File.Background b) { CodeTask.RunOneThing(path, b); if (Context.saveAllPngs) { string filename = Path.ChangeExtension(Path.Combine(path, b.Name), ".png"); // we just have one b.Frame.Image.Save(filename); } }
static void DoFileWrite(string path, File.AudioFile s) { CodeTask.RunOneThing(path, s); if (s.Data == null) { return; } string filename = Path.ChangeExtension(Path.Combine(path, s.Name), s.extension); using (FileStream fs = new FileStream(filename, FileMode.Create)) s.Data.CopyTo(fs); }
static void DoFileWrite(string path, File.Font f) { CodeTask.RunOneThing(path, f); if (Context.saveAllPngs) { string filename = Path.ChangeExtension(Path.Combine(path, f.Name), ".fnt"); // we just have one BMFontWriter.SaveAsBMFont(filename, f); // f.Frame.Image.Save(filename); } }
static void DoFileWrite(string path, File.Sprite s) { CodeTask.RunOneThing(path, s); if (Context.saveAllPngs) { if (s.Frames.Length == 0) { return; } else if (s.Frames.Length == 1) { string filename = Path.ChangeExtension(Path.Combine(path, s.Name), ".png"); // we just have one s.Frames[0].Image.Save(filename); } else // we want to cycle though them all { for (int i = 0; i < s.Frames.Length; i++) { string filename = Path.ChangeExtension(Path.Combine(path, s.Name + "_" + i), ".png"); // we just have one s.Frames[i].Image.Save(filename); } } } if (Context.saveAllMasks) { if (s.Masks.Count == 0) { return; } else if (s.Masks.Count == 1) { string filename = Path.ChangeExtension(Path.Combine(path, s.Name + "_mask"), ".png"); // we just have one s.Masks[0].Save(filename); } else { for (int i = 0; i < s.Masks.Count; i++) { string filename = Path.ChangeExtension(Path.Combine(path, s.Name + "_mask_" + i), ".png"); // we just have one s.Masks[i].Save(filename); } } } }
static void DoFileWrite(string path, File.Room room) { if (room.code_offset > 0 && room.Room_Code == null) // fill in room init { room.Room_Code = AllWriter.QuickCodeToLine(File.Codes[room.code_offset]); } foreach (var oi in room.Objects) // fill in instance init { if (oi.Code_Offset > 0 && oi.Room_Code == null) { oi.Room_Code = AllWriter.QuickCodeToLine(File.Codes[oi.Code_Offset]); } if (oi.Object_Index > -1 && oi.Object_Name == null) { oi.Object_Name = File.Objects[oi.Object_Index].Name; } } CodeTask.RunOneThing(path, room); }
public void FinishProcessing() { if (Context.oneFile) { CodeTask.RunOneThing("sprites", File.Sprites); CodeTask.RunOneThing("rooms", File.Rooms); CodeTask.RunOneThing("objects", File.Objects); CodeTask.RunOneThing("backgrounds", File.Backgrounds); CodeTask.RunOneThing("sounds", File.Sounds); CodeTask.RunOneThing("paths", File.Paths); CodeTask.RunOneThing("fonts", File.Fonts); CodeTask.RunOneThing("strings", File.Strings); } if (!Context.doThreads) { return; } if (_todo != null && _todo.Count > 0) { // ok, we have the jobs start them all up! foreach (var t in _todo) { t.Task.Start(); } using (var progress = new ProgressBar()) { ErrorContext.ProgressBar = progress; int totalTasks = _todo.Count; int tasksDone = 0; // foreach (var ct in _todo) totalTasks += ct.TotalTasks; while (tasksDone < totalTasks) { totalTasks = 0; tasksDone = 0; for (int i = _todo.Count - 1; i >= 0; i--) { var ct = _todo[i]; if (ct != null) { if (ct.Task.IsFaulted) { ExceptionHandler(ct.Name, ct.Task); Context.FatalError("Fatal exception in task"); } if (ct.Task.IsCompleted) { _todo.RemoveAt(i); } else { totalTasks += ct.TotalTasks; tasksDone += ct.TasksFinished; } } else { _todo.RemoveAt(i); } } if (totalTasks > 0) { progress.Report((double)tasksDone / totalTasks); } Thread.Sleep(50); } ; } ErrorContext.ProgressBar = null; } }
static void DoFileWrite(string path, File.Path p) { CodeTask.RunOneThing(path, p); }