/GearFoundry/Initializers/FilesAndSettings.cs
C# | 665 lines | 569 code | 47 blank | 49 comment | 10 complexity | baf2da1020ac172f238399d6ef7c70ca MD5 | raw file
- using System;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Diagnostics;
- using System.Linq;
- using Decal.Adapter;
- using System.IO;
- using System.Xml.Serialization;
- using Microsoft.Win32;
- using Decal.Filters;
- using Decal.Interop;
- using System.Runtime.InteropServices;
- using Decal.Adapter.Wrappers;
- using System.Drawing;
- using System.Xml;
- using System.Xml.Linq;
- using System.ComponentModel;
- using VirindiViewService;
- using System.Windows.Forms;
- using ProtoBuf;
- namespace GearFoundry
- {
- public partial class PluginCore
- {
-
- private MasterSettings mMasterSettings = new MasterSettings();
- private AccountSettings mAccountSettings = new AccountSettings();
- private CharacterSettings mCharacterSettings = new CharacterSettings();
-
- private void SaveMasterSettingsFile()
- {
- try
- {
- if(File.Exists(GearFiles.MasterSettingsFilename))
- {
- File.Copy(GearFiles.MasterSettingsFilename, GearFiles.BackupMasterSettingsFilename);
- }
- using (FileStream file = File.Create(GearFiles.MasterSettingsFilename))
- {
- Serializer.Serialize(file, mMasterSettings);
- }
- }catch(Exception ex){LogError(ex);}
- }
-
- private void SaveAccountSettingsFile()
- {
- try
- {
- if(File.Exists(GearFiles.AccountSettingsFilename))
- {
- File.Copy(GearFiles.AccountSettingsFilename, GearFiles.BackupAccountSettingsFilename);
- }
- using (FileStream file = File.Create(GearFiles.AccountSettingsFilename))
- {
- Serializer.Serialize(file, mAccountSettings);
- }
- }catch(Exception ex){LogError(ex);}
- }
-
- private void ReadMasterSettingsFile()
- {
- try
- {
- if(File.Exists(GearFiles.MasterSettingsFilename))
- {
- using (FileStream file = File.OpenRead(GearFiles.MasterSettingsFilename))
- {
- mMasterSettings = Serializer.Deserialize<MasterSettings>(file);
- }
- }
- else if(File.Exists(GearFiles.BackupMasterSettingsFilename))
- {
- using (FileStream file = File.OpenRead(GearFiles.BackupMasterSettingsFilename))
- {
- mMasterSettings = Serializer.Deserialize<MasterSettings>(file);
- }
- }
- else
- {
- mMasterSettings = new MasterSettings();
- BuildCollectionTaskList();
- BuildKillTaskList();
- SaveMasterSettingsFile();
- }
- }
- catch
- {
- if(File.Exists(GearFiles.BackupMasterSettingsFilename))
- {
- using (FileStream file = File.OpenRead(GearFiles.BackupMasterSettingsFilename))
- {
- mMasterSettings = Serializer.Deserialize<MasterSettings>(file);
- }
- }
- else
- {
- mMasterSettings = new MasterSettings();
- BuildCollectionTaskList();
- BuildKillTaskList();
- SaveMasterSettingsFile();
- }
- }
- }
-
- private void ReadAccountSettingsFile()
- {
- try
- {
- if(File.Exists(GearFiles.AccountSettingsFilename))
- {
- using (FileStream file = File.OpenRead(GearFiles.AccountSettingsFilename))
- {
- mAccountSettings = Serializer.Deserialize<AccountSettings>(file);
- }
- }
- else if(File.Exists(GearFiles.BackupAccountSettingsFilename))
- {
- using (FileStream file = File.OpenRead(GearFiles.BackupAccountSettingsFilename))
- {
- mAccountSettings = Serializer.Deserialize<AccountSettings>(file);
- }
- }
- else
- {
- mAccountSettings = new AccountSettings();
- SaveAccountSettingsFile();
- }
- }
- catch
- {
- if(File.Exists(GearFiles.BackupAccountSettingsFilename))
- {
- using (FileStream file = File.OpenRead(GearFiles.BackupAccountSettingsFilename))
- {
- mAccountSettings = Serializer.Deserialize<AccountSettings>(file);
- }
- }
- else
- {
- mAccountSettings = new AccountSettings();
- SaveAccountSettingsFile();
- }
- }
- }
-
- [ProtoContract]
- public class MasterSettings
- {
- [ProtoMember(1)]
- public GearWindowSettings GearWindowSettings = new GearWindowSettings();
- [ProtoMember(2)]
- public FoundrySettings FoundrySettings = new FoundrySettings();
- [ProtoMember(3)]
- public RemoteGearSettings RemoteGearSettings = new RemoteGearSettings();
- [ProtoMember(4)]
- public GearTacticianSettings GearTacticianSettings = new GearTacticianSettings();
- [ProtoMember(5)]
- public SoundSettings SoundSettings = new SoundSettings();
- [ProtoMember(6)]
- public GearVisectionSettings GearVisectionSettings = new GearVisectionSettings();
- [ProtoMember(7)]
- public GearInspectorSettings GearInspectorSettings = new GearInspectorSettings();
- [ProtoMember(8)]
- public GearSenseSettings GearSenseSettings = new GearSenseSettings();
- [ProtoMember(10)]
- public GearTaskerSettings GearTaskerSettings = new GearTaskerSettings();
-
-
-
-
- //Character Specific Settings Lists
- }
-
- [ProtoContract]
- public class AccountSettings
- {
- [ProtoMember(30)]
- public HashSet<CharacterSettings> CharacterSettingsHash = new HashSet<CharacterSettings>();
-
- }
-
- [ProtoContract]
- public class CharacterSettings //Points inside mMasterSettings
- {
- [ProtoMember(50)]
- public string CharacterKey = String.Empty;
- [ProtoMember(51)]
- public SpellComponentsToFill CharacterSpellComponents = new SpellComponentsToFill();
- [ProtoMember(52)]
- public HashSet<TaskStatus> KillTaskStatus = new HashSet<TaskStatus>();
- [ProtoMember(53)]
- public HashSet<TaskStatus> CollectTaskStatus = new HashSet<TaskStatus>();
- [ProtoMember(54)]
- public List<ValetSuit> ValetSuitList = new List<ValetSuit>();
- [ProtoMember(55)]
- public List<int> ValetSlotsList = new List<int>();
- [ProtoMember(56)]
- public PortalGearSettings PortalGearSettings = new PortalGearSettings();
- [ProtoMember(57)]
- public List<QuickSlots> vQuickSlotsSettings = new List<QuickSlots>();
- [ProtoMember(58)]
- public List<QuickSlots> hQuickSlotsSettings = new List<QuickSlots>();
-
-
- }
-
-
- [ProtoContract]
- public class GearWindowSettings
- {
- [ProtoMember(100)]
- public int ButlerHudWidth = 300;
- [ProtoMember(101)]
- public int ButlerHudHeight = 500;
- [ProtoMember(102)]
- public int TaskHudHeight = 125;
- [ProtoMember(103)]
- public int TaskHudWidth = 300;
- }
-
-
- [ProtoContract]
- public class FoundrySettings
- {
- [ProtoMember(200)]
- public bool FoundyEnabled = true;
- [ProtoMember(201)]
- public bool AutoStack = true;
- [ProtoMember(202)]
- public bool AutoCram = true;
- [ProtoMember(203)]
- public bool AutoMoveToPack = true;
- [ProtoMember(204)]
- public bool AutoReadScrolls = true;
- [ProtoMember(205)]
- public bool AutoDessicateJunkLootAetheria = true;
- [ProtoMember(206)]
- public bool AutoRevealAetheria = true;
- [ProtoMember(207)]
- public bool AutoDrainMana = true;
- [ProtoMember(208)]
- public bool AutoCraftCombine = true;
- [ProtoMember(209)]
- public bool AutoCraftCarve = true;
- [ProtoMember(210)]
- public bool AutoRingKeys = true;
- [ProtoMember(211)]
- public bool AutoSalvage = true;
- [ProtoMember(212)]
- public bool AutoSalvageCombine = true;
- [ProtoMember(213)]
- public List<string> CraftingCombineList = new List<string>();
- [ProtoMember(214)]
- public List<string> CraftingCarveList = new List<string>();
- [ProtoMember(215)]
- public List<KeyRingMatch> KeyRingMatchList = new List<KeyRingMatch>();
- [ProtoMember(216)]
- public List<ChestKeyMatch> ChestKeyMatchList = new List<ChestKeyMatch>();
- }
-
- [ProtoContract]
- public class KeyRingMatch
- {
- [ProtoMember(220)]
- public string KeyName = String.Empty;
- [ProtoMember(221)]
- public string RingName = String.Empty;
- }
-
- [ProtoContract]
- public class ChestKeyMatch
- {
- [ProtoMember(230)]
- public string ChestName = String.Empty;
- [ProtoMember(231)]
- public List<string> KeyNames = new List<string>();
- }
-
- [ProtoContract]
- public class SoundSettings
- {
- [ProtoMember(250)]
- public bool MuteSounds = false;
- [ProtoMember(251)]
- public int LandscapeTrophies = 0;
- [ProtoMember(252)]
- public int LandscapeMobs = 0;
- [ProtoMember(253)]
- public int LandscapePlayers = 0;
- [ProtoMember(254)]
- public int CorpseRare = 0;
- [ProtoMember(255)]
- public int CorpseSelfKill = 0;
- [ProtoMember(256)]
- public int CorpseFellowKill = 0;
- [ProtoMember(257)]
- public int DeadMe = 0;
- [ProtoMember(258)]
- public int DeadPermitted = 0;
- [ProtoMember(259)]
- public int CorpseTrophy = 0;
- [ProtoMember(260)]
- public int CorpseRule = 0;
- [ProtoMember(261)]
- public int CorpseSalvage = 0;
- }
-
- [ProtoContract]
- public class RemoteGearSettings
- {
- [ProtoMember(300)]
- public bool GearTacticianRendered = false;
- [ProtoMember(301)]
- public bool GearSenseRendered = false;
- [ProtoMember(302)]
- public bool GearVisectionRendered = false;
- [ProtoMember(303)]
- public bool GearTaskerRendered = false;
- [ProtoMember(304)]
- public bool GearButlerRendered = false;
- [ProtoMember(305)]
- public bool GearInspectorRendered = false;
- [ProtoMember(306)]
- public bool GearPortalRendered = false;
- [ProtoMember(307)]
- public bool hSwitchGearEnabled = false;
- [ProtoMember(308)]
- public bool vSwitchGearEnabled = false;
- [ProtoMember(309)]
- public bool GearInventoryRendered = false;
- [ProtoMember(310)]
- public bool GearArmorRendered = false;
- [ProtoMember(311)]
- public bool WormGearRendered = false;
- }
-
- [ProtoContract]
- public class GearTacticianSettings
- {
- [ProtoMember(330)]
- public bool bCombatHudTrackLifeDebuffs = true;
- [ProtoMember(331)]
- public bool bCombatHudTrackCreatureDebuffs = true;
- [ProtoMember(332)]
- public bool bCombatHudTrackItemDebuffs = true;
- [ProtoMember(333)]
- public bool bCombatHudTrackVoidDebuffs = true;
- [ProtoMember(334)]
- public bool bShowAll = false;
- [ProtoMember(335)]
- public int CombatHudWidth = 305;
- [ProtoMember(336)]
- public int CombatHudHeight = 220;
- [ProtoMember(337)]
- public bool RenderCurrentTargetDebuffView = false;
- }
-
- [ProtoContract]
- public class GearVisectionSettings
- {
- [ProtoMember(350)]
- public bool bAllCorpses = true;
- [ProtoMember(351)]
- public bool bKillsBySelf = true;
- [ProtoMember(352)]
- public bool bKillsByFellows = true;
- [ProtoMember(353)]
- public bool bDeadMes = true;
- [ProtoMember(354)]
- public bool Permitteds = true;
- [ProtoMember(355)]
- public bool RenderMini = false;
- [ProtoMember(356)]
- public List<MyCorpses> DeadMeList = new List<PluginCore.MyCorpses>();
- [ProtoMember(357)]
- public int CorpseHudWidth = 300;
- [ProtoMember(358)]
- public int CorpseHudHeight = 220;
- }
-
- [ProtoContract]
- public class MyCorpses
- {
- [ProtoMember(375)]
- public int GUID;
- [ProtoMember(376)]
- public string Name;
- [ProtoMember(377)]
- public string Coordinates;
- [ProtoMember(378)]
- public int IconID;
- }
-
- [ProtoContract]
- public class GearInspectorSettings
- {
- [ProtoMember(400)]
- public bool IdentifySalvage = true;
- [ProtoMember(401)]
- public bool CheckForL7Scrolls = false;
- [ProtoMember(402)]
- public bool SalvageHighValue = false;
- [ProtoMember(403)]
- public bool RenderMini = false;
- [ProtoMember(404)]
- public bool GSStrings = true;
- [ProtoMember(405)]
- public bool AlincoStrings = true;
- [ProtoMember(406)]
- public int ItemHudWidth = 300;
- [ProtoMember(407)]
- public int ItemHudHeight = 220;
- [ProtoMember(408)]
- public int LootByValue = 0;
- [ProtoMember(409)]
- public int LootByMana = 0;
- }
-
- [ProtoContract]
- public class GearSenseSettings
- {
- [ProtoMember(425)]
- public bool bShowAllMobs = true;
- [ProtoMember(426)]
- public bool bShowSelectedMobs = true;
- [ProtoMember(427)]
- public bool bShowAllPlayers = true;
- [ProtoMember(428)]
- public bool bShowAllegancePlayers = true;
- [ProtoMember(429)]
- public bool bShowFellowPlayers = true;
- [ProtoMember(430)]
- public bool bShowTrophies = true;
- [ProtoMember(431)]
- public bool bShowLifeStones = true;
- [ProtoMember(432)]
- public bool bShowAllPortals = true;
- [ProtoMember(433)]
- public bool bShowAllNPCs = true;
- [ProtoMember(434)]
- public bool bRenderMini = false;
- [ProtoMember(435)]
- public int LandscapeForgetDistance = 100;
- [ProtoMember(436)]
- public int LandscapeHudWidth = 300;
- [ProtoMember(437)]
- public int LandscapeHudHeight = 220;
- }
-
- [ProtoContract]
- public class GearTaskerSettings
- {
- [ProtoMember(450)]
- public int HudWidth = 300;
- [ProtoMember(451)]
- public int HudHeight = 125;
- [ProtoMember(452)]
- public bool RenderMini = false;
- [ProtoMember(453)]
- public bool SquelchTaskReporting = false;
- [ProtoMember(454)]
- public HashSet<KillTask> MasterKillTaskList = new HashSet<KillTask>();
- [ProtoMember(455)]
- public HashSet<CollectTask> MasterCollectTaskList = new HashSet<CollectTask>();
- }
-
- [ProtoContract]
- public class KillTask
- {
- [ProtoMember(475)]
- public int KillTaskId = -1;
- [ProtoMember(476)]
- public string TaskName = String.Empty;
- [ProtoMember(477)]
- public List<string> MobNames = new List<string>();
- [ProtoMember(478)]
- public List<string> NPCNames = new List<string>();
- [ProtoMember(479)]
- public string NPCInfo = String.Empty;
- [ProtoMember(480)]
- public string NPCCoords = String.Empty;
- [ProtoMember(481)]
- public string NPCYellowFlagText = String.Empty;
- [ProtoMember(482)]
- public string NPCYellowCompleteText = String.Empty;
- [ProtoMember(583)]
- public int CompleteCount = 0;
- }
-
- [ProtoContract]
- public class CollectTask
- {
- [ProtoMember(500)]
- public int CollectTaskId = -1;
- [ProtoMember(501)]
- public string TaskName = String.Empty;
- [ProtoMember(502)]
- public string Item = String.Empty;
- [ProtoMember(503)]
- public List<string> MobNames = new List<string>();
- [ProtoMember(504)]
- public List<string> NPCNames = new List<string>();
- [ProtoMember(505)]
- public string NPCInfo = String.Empty;
- [ProtoMember(506)]
- public string NPCCoords = String.Empty;
- [ProtoMember(507)]
- public string NPCYellowFlagText = String.Empty;
- [ProtoMember(508)]
- public string NPCYellowCompleteText = String.Empty;
- [ProtoMember(509)]
- public int CompleteCount = 0;
- }
-
-
- [ProtoContract]
- public class SpellComponentsToFill
- {
- [ProtoMember(1000)]
- public int ManaScarabs = 0;
- [ProtoMember(1001)]
- public int PlatinumScarabs = 0;
- [ProtoMember(1002)]
- public int PyrealScarabs = 0;
- [ProtoMember(1003)]
- public int GoldScarabs = 0;
- [ProtoMember(1004)]
- public int SilverScarabs = 0;
- [ProtoMember(1005)]
- public int CopperScarabs = 0;
- [ProtoMember(1006)]
- public int IronScarabs = 0;
- [ProtoMember(1007)]
- public int LeadScarabs = 0;
- [ProtoMember(1008)]
- public int PrismaticTapers= 0;
- }
-
- [ProtoContract]
- public class ValetSuit
- {
- [ProtoMember(1030)]
- public int TicketStub = 0;
- [ProtoMember(1031)]
- public string SuitName = String.Empty;
- [ProtoMember(1032)]
- public int Icon = 0;
- [ProtoMember(1033)]
- public List<ValetTicket> SuitPieces = new List<ValetTicket>();
- [ProtoMember(1034)]
- public List<int> ClearSlotList = new List<int>();
- }
-
- [ProtoContract]
- public class ValetTicket
- {
- [ProtoMember(1040)]
- public int ItemId = 0;
- [ProtoMember(1041)]
- public int SlotId = 0;
- [ProtoMember(1042)]
- public int Priority = 1;
- }
-
- [ProtoContract]
- public class TaskStatus
- {
- [ProtoMember(1050)]
- public int TaskId = -1;
- [ProtoMember(1051)]
- public int CurrentCount = 0;
- [ProtoMember(1052)]
- public bool track = false;
- [ProtoMember(1053)]
- public bool detect = false;
- [ProtoMember(1054)]
- public bool active = false;
- [ProtoMember(1055)]
- public bool complete = false;
- }
-
- [ProtoContract]
- public class PortalGearSettings
- {
- [ProtoMember(1075)]
- public int nOrbGuid = 0;
- [ProtoMember(1076)]
- public int nOrbIcon = 0x2A38;
- [ProtoMember(1077)]
- public int nFacilityHubGemID = 0;
- }
- [ProtoContract]
- public class QuickSlots
- {
- [ProtoMember(1080)]
- public int ItemId = 0;
- [ProtoMember(1081)]
- public int ItemIcon = 0;
- [ProtoMember(1082)]
- public int IconOverlay = 0;
- [ProtoMember(1083)]
- public int IconUnderlay = 0;
- }
-
- //[ProtoContract]
- //public class QuickSlots
- //{
- // [ProtoMember(1080)]
- // public string Name;
- // [ProtoMember(1081)]
- // public int ItemId = 0;
- // [ProtoMember(1082)]
- // public string objClass;
- // [ProtoMember(1083)]
- // public int ImbueId;
- // [ProtoMember(1084)]
- // public int ItemIcon = 0;
- // [ProtoMember(1085)]
- // public int IconOverlay = 0;
- // [ProtoMember(1086)]
- // public int IconUnderlay = 0;
- //}
- // public static void StartService(string serviceName, int timeoutMilliseconds)
- // {
- // ServiceController service = new ServiceController(serviceName);
- // try
- // {
- // TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
- //
- // service.Start();
- // service.WaitForStatus(ServiceControllerStatus.Running, timeout);
- // }
- // catch
- // {
- // // ...
- // }
- // }
-
- // public static void StopService(string serviceName, int timeoutMilliseconds)
- //{
- // ServiceController service = new ServiceController(serviceName);
- // try
- // {
- // TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
- //
- // service.Stop();
- // service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
- // }
- // catch
- // {
- // // ...
- // }
- //}
-
- }
- }