protected string ProcessTextCommand_SlotInfo(string args) { uint gameSlotToCopy; if (args.Length == 1 && uint.TryParse(args, out gameSlotToCopy) && gameSlotToCopy >= 1 && gameSlotToCopy <= 5) { if (MemoryHandler.FoundSavedPresetSigs()) { byte[] gamePreset = new byte[104]; try { WaymarkPreset tempPreset = WaymarkPreset.Parse(MemoryHandler.ReadSlot(gameSlotToCopy)); return("Slot " + gameSlotToCopy.ToString() + " Contents:\r\n" + tempPreset.GetPresetDataString(mConfiguration.GetZoneNameDelegate, mConfiguration.ShowIDNumberNextToZoneNames)); } catch (Exception e) { PluginLog.Log($"An unknown error occured while trying to read the game's waymark data: {e}"); return("An unknown error occured while trying to read the game's waymark data."); } } else { return("Unable to read game's waymark data."); } } else { return("An invalid game slot number was provided."); } }
// Initialization public void Initialize(DalamudPluginInterface pluginInterface) { // Configuration mPluginInterface = pluginInterface; mConfiguration = mPluginInterface.GetPluginConfig() as Configuration ?? new Configuration(); mConfiguration.Initialize(mPluginInterface); MemoryHandler.Init(mPluginInterface); ZoneInfoHandler.Init(mPluginInterface); // Text Command Initialization mPluginInterface.CommandManager.AddHandler(mTextCommandName, new CommandInfo(ProcessTextCommand) { HelpMessage = "Performs waymark preset commands. Use \"/pwaymark help\" for detailed usage information." }); // UI Initialization mUI = new PluginUI(mConfiguration, mPluginInterface); mPluginInterface.UiBuilder.OnBuildUi += DrawUI; mPluginInterface.UiBuilder.OnOpenConfigUi += (sender, args) => DrawConfigUI(); mUI.SetCurrentTerritoryTypeID(mPluginInterface.ClientState.TerritoryType); mUI.Initialize(); // Event Subscription mPluginInterface.ClientState.TerritoryChanged += OnTerritoryChanged; // Tell the user if there's something out of the ordinary. if (!MemoryHandler.FoundSavedPresetSigs()) { mPluginInterface.Framework.Gui.Chat.Print("Error initializing WaymarkPresetPlugin: Cannot write to or read from game."); } }
protected string ProcessTextCommand_Import(string args) { uint gameSlotToCopy; if (args.Length == 1 && uint.TryParse(args, out gameSlotToCopy) && gameSlotToCopy >= 1 && gameSlotToCopy <= MemoryHandler.MaxPresetSlotNum) { if (MemoryHandler.FoundSavedPresetSigs()) { try { WaymarkPreset tempPreset = WaymarkPreset.Parse(MemoryHandler.ReadSlot(gameSlotToCopy)); int importedIndex = mConfiguration.PresetLibrary.ImportPreset(tempPreset); mConfiguration.Save(); return($"Imported game preset {gameSlotToCopy} as library preset {importedIndex}."); } catch (Exception e) { PluginLog.Log($"An unknown error occured while trying to read the game's waymark data: {e}"); return("An unknown error occured while trying to read the game's waymark data."); } } else { return("Unable to read game's waymark data."); } } else { return($"An invalid game slot number was provided."); } }