Exemple #1
0
        private void LoadItems(StatsDat sDat, TagsDat tagsDat)
        {
            foreach (var address in RecordAddresses())
            {
                var r = new ModRecord(M, sDat, tagsDat, address);

                if (records.ContainsKey(r.Key))
                {
                    continue;
                }

                DictionaryRecords.Add(address, r);
                records.Add(r.Key, r);

                if (r.Domain == ModDomain.Monster)
                {
                    continue;
                }

                var byTierKey = Tuple.Create(r.Group, r.AffixType);

                if (!recordsByTier.TryGetValue(byTierKey, out var groupMembers))
                {
                    groupMembers             = new List <ModRecord>();
                    recordsByTier[byTierKey] = groupMembers;
                }

                groupMembers.Add(r);
            }

            foreach (var list in recordsByTier.Values)
            {
                list.Sort(ModRecord.ByLevelComparer);
            }
        }
Exemple #2
0
 private void loadItems(StatsDat sDat, TagsDat tagsDat)
 {
     foreach (int addr in RecordAddresses())
     {
         var r = new ModRecord(M, sDat, tagsDat, addr);
         if (records.ContainsKey(r.Key))
         {
             continue;
         }
         records.Add(r.Key, r);
         bool addToItemIiers = r.Domain != 3;
         if (!addToItemIiers)
         {
             continue;
         }
         Tuple <string, ModType> byTierKey = Tuple.Create(r.Group, r.AffixType);
         List <ModRecord>        groupMembers;
         if (!recordsByTier.TryGetValue(byTierKey, out groupMembers))
         {
             groupMembers             = new List <ModRecord>();
             recordsByTier[byTierKey] = groupMembers;
         }
         groupMembers.Add(r);
     }
     foreach (var list in recordsByTier.Values)
     {
         list.Sort(ModRecord.ByLevelComparer);
     }
 }
Exemple #3
0
    private void ShowExtraView()
    {
        Transform  parentTransform = GameObject.Find("UI/Panels/OptionsPanel/Content/ContentViewPanel").transform;
        string     prefabPath      = "Prefabs/MainMenu/Options/ExtraOptionsViewPanel";
        GameObject prefab          = (GameObject)Resources.Load(prefabPath, typeof(GameObject));
        GameObject panel           = Instantiate(prefab, parentTransform);

        panel.name = "ExtraOptionsViewPanel";

        GameObject itemPrefab        = (GameObject)Resources.Load("Prefabs/UI/ExtraOptionPanel", typeof(GameObject));
        GameObject ExtraOptionsPanel = GameObject.Find("UI/Panels/OptionsPanel/Content/ContentViewPanel/ExtraOptionsViewPanel/Viewport/Content").gameObject;

        RectTransform modsPanelRectTransform = ExtraOptionsPanel.GetComponent <RectTransform>();
        Vector3       currentPosition        = new Vector3(modsPanelRectTransform.sizeDelta.x / 2, -FREE_SPACE_EXTRA_OPTIONS, ExtraOptionsPanel.transform.localPosition.z);

        foreach (Transform transform in ExtraOptionsPanel.transform)
        {
            Destroy(transform.gameObject);
        }

        modsPanelRectTransform.sizeDelta = new Vector2(modsPanelRectTransform.sizeDelta.x, 0);
        GameObject.Find("UI/Panels").transform.Find("ModsPanel").Find("Scroll View").GetComponentInChildren <ScrollRect>().verticalNormalizedPosition = 0f;

        foreach (var mod in ExtraOptionsManager.ExtraOptions)
        {
            GameObject ModRecord;

            ModRecord = MonoBehaviour.Instantiate(itemPrefab, ExtraOptionsPanel.transform);
            ModRecord.transform.localPosition = currentPosition;
            ModRecord.name = mod.Key.ToString();

            ModRecord.transform.Find("Label").GetComponent <Text>().text = mod.Value.Name;

            Text description = ModRecord.transform.Find("Text").GetComponent <Text>();
            description.text = mod.Value.Description;
            RectTransform descriptionRectTransform = description.GetComponent <RectTransform>();
            descriptionRectTransform.sizeDelta = new Vector2(descriptionRectTransform.sizeDelta.x, description.preferredHeight);

            RectTransform modRecordRectTransform = ModRecord.GetComponent <RectTransform>();
            modRecordRectTransform.sizeDelta = new Vector2(modRecordRectTransform.sizeDelta.x, modRecordRectTransform.sizeDelta.y + description.preferredHeight);

            currentPosition = new Vector3(currentPosition.x, currentPosition.y - modRecordRectTransform.sizeDelta.y - FREE_SPACE_EXTRA_OPTIONS, currentPosition.z);
            modsPanelRectTransform.sizeDelta = new Vector2(modsPanelRectTransform.sizeDelta.x, modsPanelRectTransform.sizeDelta.y + modRecordRectTransform.sizeDelta.y + FREE_SPACE_EXTRA_OPTIONS);

            ModRecord.transform.Find("Toggle").GetComponent <Toggle>().isOn = ExtraOptionsManager.ExtraOptions[mod.Key].IsOn;
        }
    }
 public PrepareRecord(ModRecord mod, string jsonPath, jtProcGeneric jtProc, List <Localize.Strings.Culture> cultures, Dictionary <string, string> locCache, object content, LocalizationFile locFile, string basePath)
 {
     this.mod      = mod;
     this.jsonPath = jsonPath;
     this.jtProc   = jtProc;
     this.cultures = new HashSet <Localize.Strings.Culture>();
     foreach (Localize.Strings.Culture culture in cultures)
     {
         this.cultures.Add(culture);
     }
     ;
     this.locCache = locCache;
     this.content  = content;
     this.updated  = false;
     this.locFile  = locFile;
     this.basePath = basePath;
 }
Exemple #5
0
    public void InitializePanel()
    {
        GameObject prefab    = (GameObject)Resources.Load("Prefabs/UI/ModPanel", typeof(GameObject));
        GameObject ModsPanel = GameObject.Find("UI/Panels").transform.Find("ModsPanel").Find("Scroll View/Viewport/Content").gameObject;

        RectTransform modsPanelRectTransform = ModsPanel.GetComponent <RectTransform>();
        Vector3       currentPosition        = new Vector3(modsPanelRectTransform.sizeDelta.x / 2, -FREE_SPACE, ModsPanel.transform.localPosition.z);

        foreach (Transform transform in ModsPanel.transform)
        {
            Destroy(transform.gameObject);
        }

        modsPanelRectTransform.sizeDelta = new Vector2(modsPanelRectTransform.sizeDelta.x, 0);
        GameObject.Find("UI/Panels").transform.Find("ModsPanel").Find("Scroll View").GetComponentInChildren <ScrollRect>().verticalNormalizedPosition = 0f;

        foreach (var mod in ModsManager.GetAllMods())
        {
            GameObject ModRecord;

            ModRecord = MonoBehaviour.Instantiate(prefab, ModsPanel.transform);
            ModRecord.transform.localPosition = currentPosition;
            ModRecord.name = mod.Key.ToString();

            ModRecord.transform.Find("Label").GetComponent <Text>().text = mod.Value.Name;

            Text description = ModRecord.transform.Find("Text").GetComponent <Text>();
            description.text = mod.Value.Description;
            RectTransform descriptionRectTransform = description.GetComponent <RectTransform>();
            descriptionRectTransform.sizeDelta = new Vector2(descriptionRectTransform.sizeDelta.x, description.preferredHeight);

            RectTransform modRecordRectTransform = ModRecord.GetComponent <RectTransform>();
            modRecordRectTransform.sizeDelta = new Vector2(modRecordRectTransform.sizeDelta.x, modRecordRectTransform.sizeDelta.y + description.preferredHeight);

            currentPosition = new Vector3(currentPosition.x, currentPosition.y - modRecordRectTransform.sizeDelta.y - FREE_SPACE, currentPosition.z);
            modsPanelRectTransform.sizeDelta = new Vector2(modsPanelRectTransform.sizeDelta.x, modsPanelRectTransform.sizeDelta.y + modRecordRectTransform.sizeDelta.y + FREE_SPACE);

            ModRecord.transform.Find("Toggle").GetComponent <Toggle>().isOn = ModsManager.Mods[mod.Key].IsOn;
        }
    }
Exemple #6
0
 private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     try {
         List <ModRecord>                      mods = ModRecord.GatherMods(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), ".."));
         Dictionary <string, string>           jsonUpdatedContent = new Dictionary <string, string>();
         Dictionary <string, ConversationFile> convUpdatedContent = new Dictionary <string, ConversationFile>();
         int modcounter = 0;
         foreach (ModRecord mod in mods)
         {
             backgroundWorker.ReportProgress((int)Math.Round((float)modcounter * 100.0f / (float)mods.Count)); ++modcounter;
             string modName = ModRecord.Normilize(mod.Name);
             //MessageBox.Show(modName);
             List <string> jsonsPath = new List <string>();
             ModRecord.GetAllJsons(mod.Path, ref jsonsPath, 0);
             foreach (string jsonPath in jsonsPath)
             {
                 bool updated = false;
                 //MessageBox.Show(jsonPath);
                 string filename = ModRecord.Normilize(Path.GetFileNameWithoutExtension(jsonPath));
                 object content  = null;
                 if (Path.GetFileName(jsonPath).ToUpper() == "LOCALIZATION.JSON")
                 {
                     continue;
                 }
                 if (Path.GetExtension(jsonPath).ToUpper() == ".JSON")
                 {
                     string jsonCont = File.ReadAllText(jsonPath);
                     content = JObject.Parse(jsonCont);
                 }
                 else if (Path.GetExtension(jsonPath).ToUpper() == ".BYTES")
                 {
                     content = new ConversationFile(jsonPath);
                 }
                 foreach (var jtproc in partsList)
                 {
                     jtProcGeneric jtProc = jtproc as jtProcGeneric;
                     if (jtProc == null)
                     {
                         continue;
                     }
                     Dictionary <string, string> replaced = new Dictionary <string, string>();
                     jtProc.proc(modName, filename, ref content, replaced, true);
                     foreach (var replacements in replaced)
                     {
                         if (string.IsNullOrEmpty(replacements.Value) == false)
                         {
                             updated = true;
                         }
                     }
                 }
                 if (updated)
                 {
                     if (Path.GetExtension(jsonPath).ToUpper() == ".JSON")
                     {
                         JObject json = content as JObject;
                         if (json != null)
                         {
                             jsonUpdatedContent.Add(jsonPath, json.ToString(Formatting.Indented));
                         }
                         ;
                     }
                     else if (Path.GetExtension(jsonPath).ToUpper() == ".BYTES")
                     {
                         ConversationFile cfile = content as ConversationFile;
                         if (cfile != null)
                         {
                             convUpdatedContent.Add(jsonPath, cfile);
                         }
                         ;
                     }
                 }
                 ;
             }
         }
         foreach (var uJsons in jsonUpdatedContent)
         {
             File.WriteAllText(uJsons.Key, uJsons.Value);
         }
         foreach (var uConv in convUpdatedContent)
         {
             uConv.Value.Save();
         }
     } catch (Exception ex) {
         MessageBox.Show(ex.ToString());
     }
 }