private void ReceiveCommand(Client client, string cmd, string[] args) { switch (cmd) { case "bind": flashPtr = WinApi.GetForegroundWindow(); try { var flashProcess = Process.GetProcesses().Single(p => p.Id != 0 && p.MainWindowHandle == flashPtr); if (flashProcess.ProcessName != config.FlashPlayerName) { gui?.ShowChangeFlashNameMessage(flashProcess.ProcessName, config.FlashPlayerName, () => { config.FlashPlayerName = flashProcess.ProcessName; client.Notify("Updated config!"); ConfigManager.WriteXML(config); }); } } catch { } gui?.SetHandle(flashPtr); client.Notify("FameBot is now active"); break; case "start": Start(); client.Notify("FameBot is starting"); break; case "stop1": Stop(); client.Notify("FameBot is stopping"); break; case "gui": gui?.Close(); gui = new FameBotGUI(); gui.Show(); break; case "options": PluginUtils.ShowGenericSettingsGUI(Settings.Default, "Bot Settings"); break; case "famebot": if (args.Length >= 1) { if (string.Compare("set", args[0], true) == 0) { if (args.Length < 2 || string.IsNullOrEmpty(args[1])) { client.Notify("No argument to set was provided"); return; } var setting = args[1].ToLower(); switch (setting) { case "realmposition": case "rp": config.RealmLocation = client.PlayerData.Pos; ConfigManager.WriteXML(config); client.Notify("Successfully changed realm position!"); break; case "fountainposition": case "fp": config.FountainLocation = client.PlayerData.Pos; ConfigManager.WriteXML(config); client.Notify("Successfully changed fountain position!"); break; default: client.Notify("Unrecognized setting."); break; } } if (string.Compare("prefer", args[0], true) == 0) { if (args.Length < 2 || string.IsNullOrEmpty(args[1])) { client.Notify("No realm name was provided"); return; } preferredRealmName = args[1]; client.Notify("Set preferred realm to " + args[1]); } } break; } }
private void HideGUI() { logEvent = null; gui?.Close(); }