Example #1
0
    public void Init(TextAssetReader newAsset)
    {
        //Initialize parameters
        minSize         = new Vector2(300, 300);
        virtualPosition = Vector2.zero;

        currentAsset = newAsset;

        Show();
    }
Example #2
0
        /// <summary>
        /// Import presets from mod and local presets from disk.
        /// </summary>
        public void LoadPresets()
        {
            if (Presets.Count > 0)
            {
                Presets.Clear();
            }

            // Get presets from mod
            if (mod.HasAsset(presetsFileName))
            {
                List <Preset> modPresets = new List <Preset>();
                if (TryDeserialize(mod, presetsFileName, ref modPresets))
                {
                    Presets.AddRange(modPresets);
                }
            }

            // Local presets (managed from gui)
            Directory.CreateDirectory(mod.ConfigurationDirectory);
            string localPresetsPath = LocalPresetsPath;

            if (File.Exists(LegacyLocalPresetsPath))
            {
                ModManager.MoveOldConfigFile(LegacyLocalPresetsPath, localPresetsPath);
            }
            if (File.Exists(localPresetsPath))
            {
                List <Preset> localPresets = new List <Preset>();
                if (TryDeserialize(localPresetsPath, ref localPresets))
                {
                    foreach (var preset in localPresets)
                    {
                        preset.IsLocal = true;
                    }
                    Presets.AddRange(localPresets);
                }
            }

            // Imported presets (readonly)
            Presets.AddRange(TextAssetReader.ReadAll <Preset>(string.Format("Presets/{0}", mod.FileName), "json"));

            // Legacy imported presets (readonly)
            foreach (string path in Directory.GetFiles(mod.DirPath, string.Format("{0}_presets_*.json", mod.FileName)))
            {
                List <Preset> importedPresets = new List <Preset>();
                if (TryDeserialize(path, ref importedPresets))
                {
                    Presets.AddRange(importedPresets);
                }

                Debug.LogWarningFormat($"Imported legacy preset for {mod}.");
            }

            HasLoadedPresets = true;
        }
Example #3
0
        public unsafe void ReadBytesInt()
        {
            var textAsset = new TextAsset("0123");
            var reader    = new TextAssetReader(textAsset);

            for (byte index = 0; index < 4; index++)
            {
                byte value;
                reader.ReadBytes(&value, sizeof(byte));
                Assert.AreEqual(index, value - 48);
            }
        }
Example #4
0
 private async void OnInfoButton(object sender, EventArgs eventArgs)
 {
     if (CurrentPage is PictureFeed)
     {
         await DisplayAlert(PictureFeed.Headline, TextAssetReader.Get("Info_PictureFeed.txt"), Text.Ok);
     }
     else if (CurrentPage is TimelineFeed)
     {
         await DisplayAlert(TimelineFeed.Headline, TextAssetReader.Get("Info_TimelineFeed.txt"), Text.Ok);
     }
     else if (CurrentPage is ContactFeed)
     {
         await DisplayAlert(ContactFeed.Headline, TextAssetReader.Get("Info_ContactPage.txt"), Text.Ok);
     }
 }
Example #5
0
        public unsafe void ReadBytes()
        {
            var textAsset = new TextAsset("0123");
            var reader    = new TextAssetReader(textAsset);

            var bytes = new NativeArray <byte>(4, Allocator.TempJob);

            byte *destination = (byte *)bytes.GetUnsafePtr();

            reader.ReadBytes(destination, 4);

            for (var index = 0; index < 4; index++)
            {
                Assert.AreEqual(index, bytes[index] - 48);
            }

            bytes.Dispose();
        }
Example #6
0
        /// <summary>
        /// Rebuilds dictionary of classic spells by re-reading SPELLS.STD.
        /// </summary>
        void RebuildClassicSpellsDict()
        {
            standardSpells.Clear();

            List <SpellRecord.SpellRecordData> spells = DaggerfallSpellReader.ReadSpellsFile(Path.Combine(DaggerfallUnity.Instance.Arena2Path, DaggerfallSpellReader.DEFAULT_FILENAME));

            TextAssetReader.Merge(spells, "SpellRecords.json", (record, data) => record.index == data["index"].AsInt64);
            foreach (SpellRecord.SpellRecordData spell in spells)
            {
                // "Holy Touch" and "Holy Word" have same ID but different properties
                // Not sure of best way to handle - just ignoring duplicate for now
                if (standardSpells.ContainsKey(spell.index))
                {
                    //Debug.LogErrorFormat("RebuildClassicSpellsDict found duplicate key {0} for spell {1}. Existing spell={2}", spell.index, spell.spellName, classicSpells[spell.index].spellName);
                    continue;
                }

                standardSpells.Add(spell.index, spell);
            }
        }
        private async void ShowSecurityQuestionProposals(object sender, EventArgs eventArgs)
        {
            string proposalsAsset = TextAssetReader.Get("SecurityQuestions.txt");

            string[] proposals = proposalsAsset.Replace("\r", "").Split('\n');
            string   question  = await DisplayActionSheet(Text.TitleOnSecurityProposals, Text.Cancel, null, proposals);

            if (string.IsNullOrWhiteSpace(question) || question == Text.Cancel)
            {
                return;
            }

            if (sender == FirstQuestionMenuButton)
            {
                SecurityQuestion1.Text = question;
            }
            else
            {
                SecurityQuestion2.Text = question;
            }
        }
Example #8
0
 private void OnEnable()
 {
     assetTarget = target as TextAssetReader;
 }
 private async void OnInfoButton(object sender, EventArgs eventArgs)
 {
     await DisplayAlert(Headline, TextAssetReader.Get("Info_SettingsPage.txt"), Text.Ok);
 }