示例#1
0
        public void GetHealed(int healin, List <Modifier> effects)
        {
            var currentHealing = healin;

            foreach (Modifier mod in ModsList)
            {
                if (mod.getHealed())
                {
                    if (mod.target.Equals(""))
                    {
                        currentHealing += mod.value;
                    }
                }
            }

            if (effects != null)
            {
                foreach (Modifier mod in effects)
                {
                    ModsList.Add(mod);
                }
            }

            CurrentHealth += currentHealing;
        }
示例#2
0
 private void Install_Click(object sender, EventArgs e)
 {
     modList.Clear();
     for (int i = 0; i < modNames.Count; i++)
     {
         if (ModsList.GetItemChecked(i))
         {
             string a = modNames[i];
             modList.Add(new Mod(a, modPaths[i]));
         }
     }
     SaveData(Application.StartupPath + "/rc" + gameID + "Mods/mods.xml", modList);
     foreach (Mod mini in modList)
     {
         string[] aw = Directory.GetDirectories(mini.path);
         if (Directory.Exists(mini.path + "/rc" + gameID))
         {
             Copy(mini.path + "/rc" + gameID, (File.ReadAllLines(Application.StartupPath + "/Data.wkj")[gameID] + "/rc" + gameID));
         }
         if (Directory.Exists(mini.path + "/Common"))
         {
             Copy(mini.path + "/Common", (File.ReadAllLines(Application.StartupPath + "/Data.wkj")[gameID] + "/Common"));
         }
     }
 }
示例#3
0
        public void Refresh()
        {
            //Logging Start
            Logger.ProgressValue   = 0;
            Logger.IsIndeterminate = true;
            Logger.Status          = "Refreshing...";
            Logger.Log             = "";

            IsInitialized = false;
            ModsList.Clear();

            bool initProfiles = GetProfileInfo();

            if (initProfiles)
            {
                WorkspaceViewModel wvm = (WorkspaceViewModel)AnchorablesSource.First(x => x.ContentId == "mods");
                //FIXME check for updates
                wvm.GetModDataAsync();

                Logger.LogString($"Refreshed Modlist.");
            }

            //Logging End
            Logger.ProgressValue   = 100;
            Logger.IsIndeterminate = false;
            Logger.Status          = "Finished.";
            Logger.NotifyStatusChanged();
        }
示例#4
0
 public void RemoveMod(Mod m)
 {
     if (m != null)
     {
         ModsList.Remove(m);
         m.LinkedProfiles.Remove(this);
     }
 }
示例#5
0
 public void AddMod(Mod m)
 {
     if (m != null)
     {
         ModsList.Add(m);
         m.LinkedProfiles.Add(this);
     }
 }
示例#6
0
 private void Save_Click(object sender, EventArgs e)
 {
     modList.Clear();
     for (int i = 0; i < modNames.Count; i++)
     {
         if (ModsList.GetItemChecked(i))
         {
             string a = modNames[i];
             modList.Add(new Mod(a, modPaths[i]));
         }
     }
     SaveData(Application.StartupPath + "/rc" + gameID + "Mods/mods.xml", modList);
 }
示例#7
0
        public void Save()
        {
            WorkspaceViewModel wvm = (WorkspaceViewModel)AnchorablesSource.First(x => x.ContentId == "mods");

            //var dbg = wvm.ModsCollectionView.CurrentItem;
            //wvm.ModsCollectionView.CommitEdit();
            //wvm.ModsCollectionView.Refresh();


            //Logging Start
            Logger.ProgressValue   = 0;
            Logger.IsIndeterminate = true;
            Logger.Status          = "Saving...";

            Dos2.ModManager.Properties.Settings.Default.Save();

            MessageBoxResult result = MessageBox.Show(
                "Save current load order? This operation cannot be undone.",
                "Save Load Order?", MessageBoxButton.OKCancel, MessageBoxImage.Warning);

            if (result == MessageBoxResult.OK)
            {
                lt.SaveModSettings(ActiveProfile, ModsList.ToList());

                // refresh
                //FIXME this should be redundant
                bool initProfiles = GetProfileInfo();
                if (initProfiles)
                {
                    //FIXME check for updates
                    wvm.GetModDataAsync();
                }
                Logger.LogString($"Saved Modlist for profile {ActiveProfile.Name}.");
            }
            else
            {
                MessageBoxResult viper = MessageBox.Show("You'll coward don't even smoke crack.");
                // do noting
            }

            //Logging End
            Logger.ProgressValue   = 100;
            Logger.IsIndeterminate = false;
            Logger.LogString("Finished Saving.");
            Logger.NotifyStatusChanged();
        }
示例#8
0
 public void setupConfigs()
 {
     Manager.usercfg = new Userconfigs();
     Manager.usercfg.Initialize();
     Manager.usercfg.Read();
     this.cfg_emptyStartWorld = Manager.usercfg.emptyStartWorld;
     this.cfg_ExtraThread     = Manager.usercfg.ExtraThread;
     this.cfg_HyperThreading  = Manager.usercfg.HyperThreading;
     this.cfg_noLog           = Manager.usercfg.noLog;
     this.cfg_noPause         = Manager.usercfg.noPause;
     this.cfg_noStartScreen   = Manager.usercfg.noStartScreen;
     this.cfg_onlyPbo         = Manager.usercfg.onlyPbo;
     this.cfg_showScriptError = Manager.usercfg.showScriptError;
     this.cfg_stopMultiCore   = Manager.usercfg.stopMultiCore;
     Manager.modslist         = new ModsList();
     Manager.modslist.Initialize();
     Manager.modslist.Read();
 }
示例#9
0
        public void TakeDamage(int amount, string type, List <Modifier> effects)
        {
            var currentArmour  = BaseArmorValue;
            var currentWarding = BaseWarding;

            foreach (Modifier mod in ModsList)
            {
                if (mod.defend())
                {
                    if (mod.target.Equals("Armour"))
                    {
                        currentArmour += mod.value;
                    }
                    else if (mod.target.Equals("Warding"))
                    {
                        currentWarding += mod.value;
                    }
                    else if (mod.target.Equals("Health"))
                    {
                        CurrentHealth += mod.value;
                    }
                }
            }
            if (type.Equals("Physical"))
            {
                CurrentHealth -= amount * (int)((100 - currentArmour) / 100f);
            }
            else if (type.Equals("Magical"))
            {
                CurrentHealth -= amount * (int)((100 - currentWarding) / 100f);
            }

            if (effects != null)
            {
                foreach (Modifier mod in effects)
                {
                    ModsList.Add(mod);
                }
            }

            CheckDeath();
        }
示例#10
0
        /// <summary>
        /// Applies Profile Settings to ModList
        /// </summary>
        #region Appply Mod Settings
        /// <summary>
        /// Change Load Order and enables mods depending on active profile
        /// </summary>
        public void ApplyModSettings(Dos2ModsSettings activeSettings)
        {
            //Dos2ModsSettings activeSettings = ParentViewModel.Profiles.FirstOrDefault(x => x.IsActive);
            foreach (var mod in ModsList)
            {
                mod.IsEnabled = activeSettings.ActiveMods.Contains(mod.UUID);
                //find index of mod by UUID
                mod.LoadOrder = activeSettings.ModLoadOrder.FindIndex(x => x == mod.UUID);
            }
            var uncategorized = ModsList.Where(x => x.LoadOrder < 0).ToList();

            foreach (var item in uncategorized)
            {
                // give highest load order index
                int maxLoadOrder = ModsList.Max(x => x.LoadOrder);
                item.LoadOrder = maxLoadOrder + 1;
            }

            SortCollectionByProperty("LoadOrder");
        }
示例#11
0
        public void Endstep()
        {
            foreach (Modifier mod in ModsList)
            {
                if (mod.turnEnd())
                {
                    if (mod.target.Equals("Health"))
                    {
                        CurrentHealth += mod.value;
                    }
                }
                mod.duration--;
                if (mod.duration >= 0)
                {
                    ModsList.RemoveAt(ModsList.IndexOf(mod));
                }
            }

            CheckDeath();
        }
示例#12
0
 public void LoadData(string path)
 {
     if (File.Exists(path))
     {
         XmlSerializer x  = new XmlSerializer(modList.GetType());
         StreamReader  st = new StreamReader(path);
         modList = (List <Mod>)x.Deserialize(st);
         foreach (Mod man in modList)
         {
             active.Add(man.name);
         }
         for (int i = 0; i < ModsList.Items.Count; i++)
         {
             if (active.Contains(ModsList.Items[i]))
             {
                 ModsList.SetItemChecked(i, true);
             }
         }
         st.Close();
     }
 }
示例#13
0
        void IDropTarget.Drop(IDropInfo dropInfo)
        {
            Dos2Mod sourceItem = dropInfo.Data as Dos2Mod;
            Dos2Mod targetItem = dropInfo.TargetItem as Dos2Mod;

            var insertIndex = dropInfo.InsertIndex;
            var sourceIndex = dropInfo.DragInfo.SourceIndex;

            insertIndex = Math.Min(insertIndex, ModsList.Count - 1);

            if (!ParentViewModel.IsInitialized)
            {
                return;
            }

            if (insertIndex < sourceIndex) //move up
            {
                List <Dos2Mod> higher = ModsList.Where(x => x.LoadOrder >= insertIndex && x.LoadOrder < sourceIndex).ToList();
                foreach (var item in higher)
                {
                    item.LoadOrder += 1;
                }
                sourceItem.LoadOrder = insertIndex;
            }
            else //move down
            {
                List <Dos2Mod> lower = ModsList.Where(x => x.LoadOrder <= insertIndex && x.LoadOrder > sourceIndex).ToList();
                foreach (var item in lower)
                {
                    item.LoadOrder -= 1;
                }
                sourceItem.LoadOrder = insertIndex;
            }


            SortCollectionByProperty("LoadOrder");
        }
示例#14
0
        /// <summary>
        /// Gets Moddata from paks if not already in ModList
        /// </summary>
        #region GetModData
        /// <summary>
        /// Gets Moddata from paks if not already in ModList
        /// </summary>
        public async void GetModDataAsync()
        {
            string modDir = Path.Combine(Path.GetDirectoryName(Dos2.ModManager.Properties.Settings.Default.Mods), @"Mods");

            // checks
            #region checks
            if (!Directory.Exists(Dos2.ModManager.Properties.Settings.Default.WorkingDir) ||
                !Directory.Exists(modDir))
            {
                MessageBoxResult result = MessageBox.Show(
                    "No mod directory found. Please check your paths.",
                    "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                ParentViewModel.Logger.Status = "Finished With Errors.";
                return;
            }
            if (!Directory.GetFiles(modDir).ToList().Any())
            {
                return;
            }
            #endregion

            try
            {
                List <string> modFiles = Directory.GetFiles(modDir).ToList();

                //Logging Start
                ParentViewModel.Logger.ProgressValue   = 0;
                ParentViewModel.Logger.IsIndeterminate = false;
                ParentViewModel.Logger.LogString("Fetching Mod Data...");
                ParentViewModel.Logger.Status = "Fetching mod data...";

                for (int i = 0; i < modFiles.Count; i++)
                {
                    string modPath = modFiles[i];

                    //get UUID
                    string uuid = Path.GetFileNameWithoutExtension(modPath).Split('_').Last();
                    string meta = "";

                    //check if mod is already in ModList
                    // FIXME check for updates
                    if (!ModsList.Where(x => x.UUID.Equals(uuid)).Any())
                    {
                        meta = await Task.Run(() => ParentViewModel.pt.ExtractModMeta(modPath));

                        if (String.IsNullOrEmpty(meta))
                        {
                            continue;
                        }

                        //interpret meta.lsx
                        Dos2Mod mod = InterpretModMeta(meta);
                        mod.PakPath = modPath;

                        //add to modslist
                        ModsList.Add(mod);
                    }
                    else
                    {
                        //is updated
                        Dos2Mod oldmod = ModsList.FirstOrDefault(x => x.UUID.Equals(uuid));
                        if (oldmod.IsUpdated)
                        {
                            //extract meta.lsx and interpret

                            //replace existing mod
                            throw new NotImplementedException();
                        }
                        else
                        {
                            //do nothing.
                        }
                    }

                    //Logging Progress
                    int prg = Convert.ToInt32(100 / (modFiles.Count - 1) * i);
                    ParentViewModel.Logger.ProgressValue = prg;
                }

                //Logging End
                ParentViewModel.Logger.IsIndeterminate = false;
                ParentViewModel.Logger.Status          = "Finished.";
                ParentViewModel.Logger.LogString("Finished fetching mod data...");
                ParentViewModel.Logger.NotifyStatusChanged();

                // populate files list for mods
                GetModFilesAsync();
                ApplyModSettings(ParentViewModel.ActiveProfile);
            }
            catch (Exception e)
            {
                MessageBoxResult result = MessageBox.Show(
                    "Something went wrong when trying to load mod data. Please check your paths.",
                    "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ParentViewModel.Logger.Status = "Finished With Errors.";
                ParentViewModel.Logger.LogString("Something went wrong when trying to load mod data. Please check your paths.");
                ParentViewModel.Logger.LogString(e.ToString());
                return;
            }
        }
    public void LoadModdables()
    {
        //looking for mods in the mods folder at presistentDataPath/mods/
        GameModsLocation = Application.persistentDataPath + "/mods/";
        Array.Clear(ModsLoc, 0, ModsLoc.Length);
        Array.Clear(ModsNames, 0, ModsNames.Length);
        ModsLoc   = Directory.GetDirectories(GameModsLocation);
        ModsNames = Directory.GetDirectories(GameModsLocation);

        int validModsCount = 0;

        for (int i = 0; i < ModsLoc.Length; i++)
        {
            ModsNames[i] = ModsLoc[i].Replace(GameModsLocation, "");
            if (File.Exists(ModsLoc[i] + "/mod_" + ModsNames[i] + ".json"))
            {
                validModsCount += 1;
            }
            else
            {
                ModsNames[i] = "mod_ contents not found!";
            }
        }

        //validating found mods
        LoadedMods     = new ModsList[validModsCount];
        ValidModsNames = new string[validModsCount];
        ValidModsLoc   = new string[validModsCount];

        for (int i = 0; i < ModsNames.Length; i++)
        {
            int index = Array.IndexOf(ValidModsNames, null);
            if (index != -1)
            {
                if (ModsNames[i] != "mod_ contents not found!")
                {
                    ValidModsNames[index] = ModsNames[i];
                    ValidModsLoc[index]   = ModsLoc[i];
                    Debug.Log(ValidModsLoc[index] + "/mod_" + ValidModsNames[index] + ".json");
                }
            }
        }

        //Loading mod_ identifier files
        for (int i = 0; i < ValidModsNames.Length; i++)
        {
            if (File.Exists(ValidModsLoc[i] + "/mod_" + ValidModsNames[i] + ".json"))
            {
                string   ModjsonLoad = File.ReadAllText(ValidModsLoc[i] + "/mod_" + ValidModsNames[i] + ".json");
                ModsList tmp_LoadedMods_item;
                tmp_LoadedMods_item = JsonUtility.FromJson <ModsList>(ModjsonLoad);
                if (tmp_LoadedMods_item != null)
                {
                    LoadedMods[i]                = new ModsList();
                    LoadedMods[i].ModName        = tmp_LoadedMods_item.ModName;
                    LoadedMods[i].ModDescription = tmp_LoadedMods_item.ModDescription;
                    LoadedMods[i].ModAuthor      = tmp_LoadedMods_item.ModAuthor;
                    LoadedMods[i].loadBiomes     = tmp_LoadedMods_item.loadBiomes;
                    LoadedMods[i].ModVersion     = tmp_LoadedMods_item.ModVersion;
                    LoadedMods[i].ModGameVersion = tmp_LoadedMods_item.ModGameVersion;
                    Debug.Log("mod_" + ValidModsNames[i] + " Json Loaded Succesfully");
                }
                else
                {
                    Debug.Log("mod_" + ValidModsNames[i] + " Is either corrupted or invalid.");
                }
            }
            else
            {
                Debug.Log(ValidModsLoc[i] + "/mod_" + ValidModsNames[i] + ".json Does Not Exist");
            }
        }

        //Loading mod contetns
        for (int i = 0; i < ValidModsNames.Length; i++)
        {
            if (LoadedMods[i].loadBiomes == true)
            {
                if (File.Exists(ValidModsLoc[i] + "/biomes_" + ValidModsNames[i] + ".json"))
                {
                    string     BiomejsonLoad = File.ReadAllText(ValidModsLoc[i] + "/biomes_" + ValidModsNames[i] + ".json");
                    SaveBiomes tmpBiomesModded;
                    tmpBiomesModded = JsonUtility.FromJson <SaveBiomes>(BiomejsonLoad);

                    //Constructing Tiles
                    if (File.Exists(ValidModsLoc[i] + "/biomes_resources_" + ValidModsNames[i] + "/tile_constructor.json"))
                    {
                        string          TileConstructLoadJson = File.ReadAllText(ValidModsLoc[i] + "/biomes_resources_" + ValidModsNames[i] + "/tile_constructor.json");
                        TileConstructor TileConstruct;
                        TileConstruct = JsonUtility.FromJson <TileConstructor>(TileConstructLoadJson);
                        for (int t = 0; t < TileConstruct.TileContruct.Length; t++)
                        {
                            if (File.Exists(ValidModsLoc[i] + "/biomes_resources_" + ValidModsNames[i] + "/" + TileConstruct.TileContruct[t].ModTileTextureLocation))
                            {
                                for (int biom = 0; biom < tmpBiomesModded.s_BiomesList.Length; biom++)
                                {
                                    //tmpBiomesModded.s_BiomesList[biom].SurfaceRuleTiles[0] = ;
                                }
                            }
                        }
                    }

                    int previousModdedBiomesArrayLength = BiomesListModdable.Length;
                    Array.Resize(ref BiomesListModdable, previousModdedBiomesArrayLength + tmpBiomesModded.s_BiomesList.Length);
                    Array.Copy(tmpBiomesModded.s_BiomesList, 0, BiomesListModdable, previousModdedBiomesArrayLength, tmpBiomesModded.s_BiomesList.Length);
                }
                else
                {
                    Debug.Log(ValidModsLoc[i] + "/biomes_" + ValidModsNames[i] + ".json");
                }
            }
        }
    }
示例#16
0
 public void Modify(Modifier mod)
 {
     ModsList.Add(mod);
 }