Ejemplo n.º 1
0
        public static StashData Load(FullRareSetManagerCore plugin)
        {
            StashData result;
            var       dataFileFullPath = plugin.DirectoryFullName + "\\" + STASH_DATA_FILE;

            if (File.Exists(dataFileFullPath))
            {
                var json = File.ReadAllText(dataFileFullPath);

                try
                {
                    result = JsonConvert.DeserializeObject <StashData>(json);
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
            else
            {
                result = new StashData();
                Save(plugin, result);
            }

            return(result);
        }
        public static void Save(Core plugin, StashData data)
        {
            try
            {
                if (data == null)
                {
                    return;
                }
                var dataFileFullPath = plugin.PluginDirectory + "\\" + STASH_DATA_FILE;
                var settingsDirName  = Path.GetDirectoryName(dataFileFullPath);
                if (!Directory.Exists(settingsDirName))
                {
                    Directory.CreateDirectory(settingsDirName);
                }

                using (var stream = new StreamWriter(File.Create(dataFileFullPath)))
                {
                    var json = JsonConvert.SerializeObject(data, Formatting.Indented);
                    stream.Write(json);
                }
            }
            catch
            {
                PoeHUD.Plugins.BasePlugin.LogError($"Plugin {plugin.PluginName} error save settings!", 3);
            }
        }
Ejemplo n.º 3
0
        private void SetupOrClose()
        {
            if (!Settings.Enable.Value)
            {
                // If threads are implemented they should be closed here.
                return;
            }

            CheckGitUpdateConfig();

            _sData      = StashData.Load(this);
            _inventDrop = new DropAllToInventory(this);

            DisplayData = new ItemDisplayData[8];

            for (var i = 0; i <= 7; i++)
            {
                DisplayData[i] = new ItemDisplayData();
            }

            UpdateItemsSetsInfo();

            GameController.Area.OnAreaChange += OnAreaChange;

            Settings.WeaponTypePriority.SetListValues(new List <string> {
                "Two handed", "One handed"
            });
        }
Ejemplo n.º 4
0
 public override void OnClose()
 {
     if (_sData != null)
     {
         StashData.Save(this, _sData);
     }
 }
Ejemplo n.º 5
0
        public override void Initialise()
        {
            _sData = StashData.Load(this);

            if (_sData == null)
            {
                LogMessage("RareSetManager: Can't load cached items from file StashData.json. Creating new config. Open stash tabs for updating info. Tell to developer if this happen often enough.", 10);
                _sData = new StashData();
            }

            _inventDrop = new DropAllToInventory(this);

            DisplayData = new ItemDisplayData[8];

            for (var i = 0; i <= 7; i++)
            {
                DisplayData[i] = new ItemDisplayData();
            }

            UpdateItemsSetsInfo();

            Settings.WeaponTypePriority.SetListValues(new List <string> {
                "Two handed", "One handed"
            });

            Settings.CalcByFreeSpace.OnValueChanged  += UpdateItemsSetsInfo;
            GameController.Area.OnAreaChange         += OnAreaChange;
            MenuPlugin.KeyboardMouseEvents.MouseDown += OnMouseEvent;
            API.SubscribePluginEvent("StashUpdate", ExternalUpdateStashes);
        }
        public static StashData Load(Core plugin)
        {
            StashData result;
            var       dataFileFullPath = plugin.PluginDirectory + "\\" + STASH_DATA_FILE;

            if (File.Exists(dataFileFullPath))
            {
                var json = File.ReadAllText(dataFileFullPath);
                result = JsonConvert.DeserializeObject <StashData>(json);
            }
            else
            {
                result = new StashData();
                Save(plugin, result);
            }
            return(result);
        }
Ejemplo n.º 7
0
        public override bool Initialise()
        {
            Input.RegisterKey(Settings.DropToInventoryKey.Value);
            _sData = StashData.Load(this);

            if (_sData == null)
            {
                LogMessage(
                    "RareSetManager: Can't load cached items from file StashData.json. Creating new config. Open stash tabs for updating info. Tell to developer if this happen often enough.",
                    10);

                _sData = new StashData();
            }

            _inventDrop = new DropAllToInventory(this);

            DisplayData = new ItemDisplayData[8];

            for (var i = 0; i <= 7; i++)
            {
                DisplayData[i] = new ItemDisplayData();
            }

            UpdateItemsSetsInfo();

            Settings.WeaponTypePriority.SetListValues(new List <string> {
                "Two handed", "One handed"
            });

            Settings.CalcByFreeSpace.OnValueChanged += delegate { UpdateItemsSetsInfo(); };

            FrSetManagerPublishInformation = new FRSetManagerPublishInformation();
            //WorldItemsController.OnEntityAdded += args => EntityAdded(args.Entity);
            //WorldItemsController.OnEntityRemoved += args => EntityRemoved(args.Entity);
            //WorldItemsController.OnItemPicked += WorldItemsControllerOnOnItemPicked;
            return(true);
        }