public static void DisposeModule(CoreModuleInfo cmi) { if (cmi == null) { return; } cmi.ToConsole("Disposing..."); if (!cmi.Disposed) { if (cmi.DisposeSupported) { TryCatch(cmi.GetDisposeHandler(), cmi.ToConsole); } TryCatch(cmi.OnDisposed, cmi.ToConsole); if (OnModuleDisposed != null) { TryCatch(() => OnModuleDisposed(cmi), cmi.ToConsole); } cmi.ToConsole("Done."); } else { cmi.ToConsole("Already disposed, no action taken."); } }
public static void SaveModule(CoreModuleInfo cmi) { if (cmi == null || !cmi.Enabled) { return; } cmi.ToConsole("Saving..."); TryCatch(cmi.SaveOptions, cmi.ToConsole); if (cmi.SaveSupported) { TryCatch(cmi.GetSaveHandler(), cmi.ToConsole); } TryCatch(cmi.OnSaved, cmi.ToConsole); if (OnModuleSaved != null) { TryCatch(() => OnModuleSaved(cmi), cmi.ToConsole); } cmi.ToConsole("Done."); }
public static void LoadModule(CoreModuleInfo cmi) { if (cmi == null || !cmi.Enabled) { return; } cmi.ToConsole("Loading..."); TryCatch(cmi.LoadOptions, cmi.ToConsole); if (cmi.LoadSupported) { TryCatch(cmi.GetLoadHandler(), cmi.ToConsole); } TryCatch(cmi.OnLoaded, cmi.ToConsole); if (OnModuleLoaded != null) { TryCatch(() => OnModuleLoaded(cmi), cmi.ToConsole); } cmi.ToConsole("Done."); }
public static void ConfigureModule(CoreModuleInfo cmi) { if (cmi == null || !cmi.Enabled) { return; } cmi.ToConsole("Configuring..."); if (!cmi.Configured) { if (cmi.ConfigSupported) { TryCatch(cmi.GetConfigHandler(), cmi.ToConsole); } TryCatch(cmi.OnConfigured, cmi.ToConsole); if (OnModuleConfigured != null) { TryCatch(() => OnModuleConfigured(cmi), cmi.ToConsole); } cmi.ToConsole("Done."); } else { cmi.ToConsole("Already configured, no action taken."); } }
public static void InvokeModule(CoreModuleInfo cmi) { if (cmi == null || !cmi.Enabled) { return; } cmi.ToConsole("Invoking..."); if (!cmi.Invoked) { if (cmi.InvokeSupported) { TryCatch(cmi.GetInvokeHandler(), cmi.ToConsole); } TryCatch(cmi.OnInvoked, cmi.ToConsole); if (OnModuleInvoked != null) { TryCatch(() => OnModuleInvoked(cmi), cmi.ToConsole); } cmi.ToConsole("Done."); } else { cmi.ToConsole("Already invoked, no action taken."); } }
private void CompileModule(int x, int y, int w, int h, CoreModuleInfo cm) { CompileBufferEntry(x, y, w, h, 0, cm); y += 75; h -= 75; cm.CompileControlPanel(this, x, y, w, h); }
public static void DisplayTo(Mobile user, CoreModuleInfo cm) { var node = "Plugins|Modules"; if (cm != null) { node += "|" + cm.FullName; } DisplayTo(user, false, node); }
public static void InvokeModuleEnabled(CoreModuleInfo cmi) { if (cmi == null) { return; } if (OnModuleEnabled != null) { TryCatch(() => OnModuleEnabled(cmi), ToConsole); } }
public static void InvokeModuleDisabled(CoreModuleInfo cmi) { if (cmi == null) { return; } if (OnModuleDisabled != null) { OnModuleDisabled(cmi); } }
private static void OnCoreCommand(CommandEventArgs e) { if (e == null || e.Mobile == null || e.Mobile.Deleted) { return; } if (e.Arguments == null || e.Arguments.Length == 0) { new MenuGump( e.Mobile as PlayerMobile, null, new MenuGumpOptions( new[] { new ListGumpEntry("Help", () => OnCoreCommand(new CommandEventArgs(e.Mobile, e.Command, "?", new[] { "?" }))), new ListGumpEntry("Services", () => new CoreServiceListGump(e.Mobile as PlayerMobile).Send()), new ListGumpEntry("Modules", () => new CoreModuleListGump(e.Mobile as PlayerMobile).Send()) })).Send(); return; } switch (e.Arguments[0].ToLower()) { case "?": case "help": { e.Mobile.SendMessage(0x55, "Usage: {0}{1} <srv | mod | ? | help>", CommandSystem.Prefix, e.Command); e.Mobile.SendMessage(0x55, "Usage: srv <name> <ver | save>"); e.Mobile.SendMessage(0x55, "Usage: mod <name> <ver | save | enable | disable>"); } break; case "srv": { if (e.Arguments.Length < 2) { new CoreServiceListGump(e.Mobile as PlayerMobile).Send(); return; } string search = e.Arguments[1]; CoreServiceInfo info = _CoreServices.FirstOrDefault(csi => Insensitive.Contains(csi.Name, search)); if (info == null) { new CoreServiceListGump(e.Mobile as PlayerMobile).Send(); return; } if (e.Arguments.Length < 3) { e.Mobile.SendGump(new PropertiesGump(e.Mobile, info)); return; } switch (e.Arguments[2].ToLower()) { case "ver": case "version": e.Mobile.SendMessage(0x55, "{0} version: {1}", info.Name, info.Version); break; case "save": { Action sh = info.GetSaveHandler(); if (sh == null) { e.Mobile.SendMessage(0x22, "{0} does not implement the CSSave feature.", info.Name); return; } TryCatch(sh, ex => e.Mobile.SendMessage(0x22, "An error occured, check the logs for more information.")); } break; } } break; case "mod": { if (e.Arguments.Length < 2) { new CoreModuleListGump(e.Mobile as PlayerMobile).Send(); return; } string search = e.Arguments[1]; CoreModuleInfo info = _CoreModules.FirstOrDefault(cmi => Insensitive.Contains(cmi.Name, search)); if (info == null) { new CoreModuleListGump(e.Mobile as PlayerMobile).Send(); return; } if (e.Arguments.Length < 3) { e.Mobile.SendGump(new PropertiesGump(e.Mobile, info)); return; } switch (e.Arguments[2].ToLower()) { case "ver": case "version": e.Mobile.SendMessage(0x55, "{0} version: {1}", info.Name, info.Version); break; case "enable": { if (info.Enabled) { e.Mobile.SendMessage(0x22, "{0} is already enabled.", info.Name); } else { info.Enabled = true; e.Mobile.SendMessage(0x55, "{0} has been enabled.", info.Name); } } break; case "disable": { if (!info.Enabled) { e.Mobile.SendMessage(0x22, "{0} is already disabled.", info.Name); } else { info.Enabled = false; e.Mobile.SendMessage(0x55, "{0} has been disabled.", info.Name); } } break; case "save": { Action sh = info.GetSaveHandler(); if (sh == null) { e.Mobile.SendMessage(0x22, "{0} does not implement the CMSave feature.", info.Name); } else { TryCatch( sh, ex => { e.Mobile.SendMessage(0x22, "An error occured, check the logs for more information."); ToConsole(ex); }); } } break; } } break; } }