public static void AddError(Mod mod, Resource resource, string format, params object[] args) { if (mod == null) GlobalErrors.Add(new Error(null, string.Format(format, args))); else mod.Errors.Add(new Error(resource, string.Format(format, args))); }
public JsonResource(string location, Mod mod, bool exists) : base(location, mod, exists) { if (exists) { OriginalToken = ResourceManager.LoadJson(this); if (OriginalToken == null) Invalidate(); } }
public Resource(string location, Mod mod, bool exists) { this.Location = location; this.Mod = mod; this.Exists = exists; this.Valid = Exists; this.References = new List<Reference>(); this.ReferredBy = new List<Reference>(); mod.AddResource(this); }
public ModListItem(Mod mod) { this.Mod = mod; this.AddText(mod.Name); if (!mod.Valid) SetBackground(ItemStatus.Error); else { if (mod.Empty) SetBackground(ItemStatus.Ignored); else SetBackground(ItemStatus.Okay); } this.CommandBindings.Add(new CommandBinding( ApplicationCommands.Copy, (o, e) => Clipboard.SetText(this.Mod.Name) )); this.ContextMenu = new ContextMenu(); this.ContextMenu.Items.Add(new MenuItem { Header = "Copy Name", Command = ApplicationCommands.Copy, CommandTarget = this }); }
/// <summary> /// Creates a new, existing resource /// </summary> /// <param name="location"></param> /// <param name="mod"></param> public Resource(string location, Mod mod) : this(location, mod, true) { }
public Manifest(Mod mod) : base(mod.Name + "/manifest.json", mod, mod.FileSystem.Exists("manifest.json")) { if (!Exists) ErrorReporter.AddError(mod, this, "Manifest missing."); }
private void setCurrentMod(Mod mod) { foreach (var listItem in Mods) if (listItem.Mod == mod) setCurrentMod(listItem); }
/// <summary> /// Adds a new mod with a certain file system. /// </summary> /// <param name="name"></param> /// <param name="fs"></param> public static void AddMod(string name, IFileSystem fs) { if (fs == null) throw new ArgumentNullException("fs"); if (mods.ContainsKey(name)) { if (fs is IDisposable) ((IDisposable)fs).Dispose(); return; } mods[name] = new Mod(name, fs); }
/// <summary> /// Attempts to create a pather to a certain resource and returns the file system and the pather /// </summary> /// <param name="name"></param> /// <param name="context"></param> /// <param name="fs"></param> /// <param name="p"></param> /// <returns></returns> private static bool ConstructPather(string name, string context, out Mod mod, out Pather p) { // Is it a file() path? if (name.StartsWith("file(") && name.EndsWith(")")) { // Our location is relative to our current one. name = name.Substring(5, name.Length - 6); // _unless_ it starts with /. Then it's relative to the mod. if (name[0] == '/') { p = new Pather(context); while (p.Count > 1) p.Pop(); // Skip the /. name = name.Substring(1); } else p = new Pather(context); p.Apply(name); } else // absolute to the mods directory... I guess? p = new Pather(name); // Get the fs if (!mods.TryGetValue(p.Root, out mod)) return false; return true; }
private void OpenErrorWindow(Mod mod) { ErrorWindow window; if (ErrorWindows.TryGetValue(mod, out window)) { window.Focus(); return; } window = new ErrorWindow(); window.Owner = this; //window.ShowResourceWindow = OpenResourceWindowCommand; window.DataContext = mod;// new Providers.ResourceViewModel(mod); window.Closed += delegate { ErrorWindows.Remove(mod); }; window.Show(); ErrorWindows.Add(mod, window); }
public Alias(Mod mod, string name, Resource definition, Resource target) : base(definition, definition, target, "alias") { this.Name = name; mod.AddAlias(this); }
public Alias(Mod mod, string name, Resource target) : this(mod, name, mod.Manifest, target) { }