Example #1
0
    public void DownloadDictionary()
    {
        remoteManifest = IniRead.ReadFromString(download.text);
        string remoteDict = serverLocation + game.gameType.TypeName() + "/Localization.txt";

        StartCoroutine(Download(remoteDict, delegate { ReadManifest(); }));
    }
Example #2
0
    // This loads content from a pack by object
    // Duplicate content will be replaced by the higher priority value
    void LoadContent(ContentPack cp)
    {
        // Don't reload content
        if (loadedPacks.Contains(cp.id))
        {
            return;
        }

        foreach (string ini in cp.iniFiles)
        {
            IniData d = IniRead.ReadFromIni(ini);
            // Bad ini file not a fatal error, just ignore (will be in log)
            if (d == null)
            {
                return;
            }

            // Add each section
            foreach (KeyValuePair <string, Dictionary <string, string> > section in d.data)
            {
                AddContent(section.Key, section.Value, Path.GetDirectoryName(ini), cp.id);
            }
        }
        loadedPacks.Add(cp.id);

        foreach (string s in cp.clone)
        {
            LoadContentID(s);
        }
    }
Example #3
0
        public void Initialize()
        {
            const string fileName = "SystemSetting";

#if !UNITY_EDITOR
            var path = Path.Combine(Application.persistentDataPath, fileName + ".ini");
            if (!File.Exists(path))
            {
                using (var asset = AssetService.Get().Load($"Config/{fileName}", typeof(TextAsset))) {
                    File.WriteAllText(path, asset.GetTextAsset().text);
                }
            }

            using (var reader = new StreamReader(path)) {
                SystemSetting = IniRead.Parse(reader);
            }
#else
            using (var asset = AssetService.Get().Load($"Config/{fileName}", typeof(TextAsset))) {
                using (var reader = new StringReader(asset.GetTextAsset().text)) {
                    SystemSetting = IniRead.Parse(reader);
                }
            }
#endif

            IniRead.SystemSetting = SystemSetting;
        }
Example #4
0
        public void ReadingFile()
        {
            var Reader = IniRead.Parse(@"C:\data\Projects\ini_read\ini\test.ini");

            bool testbool = Reader.GetBool("user", "active");

            Debug.WriteLine("bool value " + testbool);
            Assert.IsTrue(testbool == true);

            testbool = Reader.GetBool("kek", "for");
            Debug.WriteLine("bool value " + testbool);
            Assert.IsTrue(testbool == true);

            string teststring = Reader.GetString("kek", "want");

            Debug.WriteLine("string value " + teststring);
            Assert.IsTrue(teststring == "connect");

            double testdouble = Reader.GetDouble("user", "pi");

            Debug.WriteLine("double value " + testdouble);
            Assert.IsTrue(testdouble == 3.14159);

            int testint = Reader.GetInt("kek", "hilarious");

            Debug.WriteLine("int value " + testint);
            Assert.IsTrue(testint == 3);
        }
Example #5
0
    public PuzzleSlide(int depth)
    {
        if (depth < 1)
        {
            depth = 1;
        }
        List <Dictionary <string, string> > options = new List <Dictionary <string, string> >();
        TextAsset textAsset  = (TextAsset)Resources.Load("slidepuzzles");
        string    puzzleText = textAsset.text;
        IniData   puzzles    = IniRead.ReadFromString(puzzleText);

        while (options.Count == 0)
        {
            foreach (Dictionary <string, string> p in puzzles.data.Values)
            {
                int moves = 1;
                int.TryParse(p["moves"], out moves);
                if (moves == depth)
                {
                    options.Add(p);
                }
            }
            depth--;
            if (depth == 0)
            {
                ValkyrieDebug.Log("Error: Unable to find puzzle.");
                Application.Quit();
            }
        }
        Loadpuzzle(options[Random.Range(0, options.Count)]);
        moves = 0;
    }
Example #6
0
    // Check if an import is required
    public bool NeedImport()
    {
        // Read the import log
        logFile = ContentData.ContentPath() + gameType + "/ffg/import.ini";
        IniData log = IniRead.ReadFromIni(logFile);

        // If no import log, import is required
        if (log == null)
        {
            return(true);
        }

        bool appVersionOK  = false;
        bool valkVersionOK = false;

        // Check that the FFG app version in import is new enough
        string lastImport = log.Get("Import", "FFG");

        appVersionOK = VersionNewerOrEqual(finder.RequiredFFGVersion(), lastImport);

        // Check that the Valkyrie version in import is new enough
        lastImport    = log.Get("Import", "Valkyrie");
        valkVersionOK = VersionNewerOrEqual(requiredValkyrieVersion, lastImport);
        return(!appVersionOK || !valkVersionOK);
    }
Example #7
0
        // Check if an import is required
        public bool NeedImport()
        {
            // Read the import log
            logFile = Path.Combine(contentPath, "import.ini");
            IniData log = IniRead.ReadFromIni(logFile);

            // If no import log, import is required
            if (log == null)
            {
                return(true);
            }

            bool appVersionOK  = false;
            bool valkVersionOK = false;

            // Check that the FFG app version in import is new enough
            string lastImport = log.Get("Import", "FFG");

            appVersionOK = VersionNewerOrEqual(finder.RequiredFFGVersion(), lastImport);

            // Check that the Valkyrie version in import is new enough
            int lastValkVersion = 0;

            int.TryParse(log.Get("Import", "Valkyrie"), out lastValkVersion);
            valkVersionOK = (FFGImport.version == lastValkVersion);
            return(!appVersionOK || !valkVersionOK);
        }
Example #8
0
    public void DrawList()
    {
        localManifest = IniRead.ReadFromString("");
        if (File.Exists(saveLocation() + "/manifest.ini"))
        {
            localManifest = IniRead.ReadFromIni(saveLocation() + "/manifest.ini");
        }

        // Heading
        DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Download " + game.gameType.QuestName());

        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();
        db.SetFont(game.gameType.GetHeaderFont());

        TextButton tb;
        // Start here
        int offset = 5;

        // Loop through all available quests
        // FIXME: this isn't paged Dictionary<string, Dictionary<string, string>> data;
        foreach (KeyValuePair <string, Dictionary <string, string> > kv in remoteManifest.data)
        {
            string file = kv.Key + ".valkyrie";
            // Size is 1.2 to be clear of characters with tails
            if (File.Exists(saveLocation() + "/" + file))
            {
                int localVersion  = 0;
                int remoteVersion = 0;
                int.TryParse(localManifest.Get(kv.Key, "version"), out localVersion);
                int.TryParse(remoteManifest.Get(kv.Key, "version"), out remoteVersion);
                if (localVersion < remoteVersion)
                {
                    tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 4, 1.2f), "  [Update] " + kv.Value["name"], delegate { Selection(file); }, Color.blue, offset);
                    tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetSmallFont();
                    tb.button.GetComponent <UnityEngine.UI.Text>().alignment  = TextAnchor.MiddleLeft;
                    tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0, 0.1f);
                }
                else
                {
                    db = new DialogBox(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 4, 1.2f), "  " + kv.Value["name"], Color.grey);
                    db.AddBorder();
                    db.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.05f, 0.05f, 0.05f);
                    db.textObj.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft;
                }
            }
            else
            {
                tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 4, 1.2f), "  " + kv.Value["name"], delegate { Selection(file); }, Color.white, offset);
                tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetSmallFont();
                tb.button.GetComponent <UnityEngine.UI.Text>().alignment  = TextAnchor.MiddleLeft;
                tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0, 0.1f);
            }
            offset += 2;
        }

        tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Cancel(); }, Color.red);
        tb.SetFont(game.gameType.GetHeaderFont());
    }
        private void ArchivoGuardar(string NomArchLatis)
        {
            //Crear carpteta temporal
            string lxNomCsl  = Path.GetFileNameWithoutExtension(NomArchLatis);
            string lxBaseDir = (Path.GetDirectoryName(NomArchLatis));

            string lxDir = Path.Combine(lxBaseDir, lxNomCsl + "_Qry");

            if (!Directory.Exists(lxDir))
            {
                Directory.CreateDirectory(lxDir);
            }

            //Guardar cfg.ini
            string lxArchCfgIni = Path.Combine(lxDir, CFG_INI);

            txtCfg.Save(lxArchCfgIni);

            //Guardar script.sql
            string lxScriptSQL = IniRead.ValorObtener(lxArchCfgIni, "CFG", "Script");

            if (string.IsNullOrEmpty(lxScriptSQL))
            {
                lxScriptSQL = Path.Combine(lxDir, lxNomCsl + ".sql");
            }
            else
            {
                lxScriptSQL = Path.Combine(lxDir, lxScriptSQL);
            }

            txtSQL.Save(lxScriptSQL);

            //Comprimir carpeta temporal en formato .zip con extensión .latis
            using (var zip = File.OpenWrite(NomArchLatis))
            {
                using (var zipWriter = WriterFactory.Open(zip, ArchiveType.Zip, CompressionType.Deflate))
                {
                    string[] lxFileList = Directory.GetFiles(lxDir);
                    foreach (var filePath in lxFileList)
                    {
                        zipWriter.Write(Path.GetFileName(filePath), filePath);
                    }
                }
            }
            StatusBarSet($"Archivo '{NomArchLatis}' Guardado.");

            try
            {
                //Eliminar directorio temporal
                Directory.Delete(lxDir, true);
            }
            catch (Exception ex)
            {
                _ = MessageBox.Show(ex.Message, "Guardar", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #10
0
    // Initialise data from the file on disk
    public ConfigFile()
    {
        data = new IniData();
        string optionsFile = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "/Valkyrie/config.ini";

        if (File.Exists(optionsFile))
        {
            data = IniRead.ReadFromIni(optionsFile);
        }
    }
Example #11
0
    // Initialise data from the file on disk
    public ConfigFile()
    {
        data = new IniData();
        string optionsFile = Game.AppData() + "/config.ini";

        if (File.Exists(optionsFile))
        {
            data = IniRead.ReadFromIni(optionsFile);
        }
    }
Example #12
0
    static public void Extract(string target_path, string archive_name, Extract_mode mode)
    {
        // make sure save is done, to not manipulate file being currently written
        if (_job_started)
        {
            _jobHandle.Join();
            _job_started = false;
        }

        try
        {
            if (!Directory.Exists(target_path))
            {
                Directory.CreateDirectory(target_path);
            }

            ZipFile zip = ZipFile.Read(archive_name);

            if (mode == Extract_mode.ZIPMANAGER_EXTRACT_FULL)
            {
                zip.ExtractAll(target_path, ExtractExistingFileAction.OverwriteSilently);
            }

            if (mode == Extract_mode.ZIPMANAGER_EXTRACT_INI_TXT || mode == Extract_mode.ZIPMANAGER_EXTRACT_INI_TXT_PIC)
            {
                zip.ExtractSelectedEntries("name = quest.ini", null, target_path, ExtractExistingFileAction.OverwriteSilently);
                zip.ExtractSelectedEntries("name = Localization.*.txt", null, target_path, ExtractExistingFileAction.OverwriteSilently);

                if (mode == Extract_mode.ZIPMANAGER_EXTRACT_INI_TXT_PIC)
                {
                    Dictionary <string, string> iniData = IniRead.ReadFromIni(target_path + "/quest.ini", "Quest");
                    if (iniData.ContainsKey("image"))
                    {
                        zip.ExtractSelectedEntries("name = " + iniData["image"], null, target_path, ExtractExistingFileAction.OverwriteSilently);
                    }
                }
            }

            if (mode == Extract_mode.ZIPMANAGER_EXTRACT_SAVE_INI_PIC)
            {
                zip.ExtractSelectedEntries("name = save.ini", null, target_path, ExtractExistingFileAction.OverwriteSilently);
                zip.ExtractSelectedEntries("name = image.png", null, target_path, ExtractExistingFileAction.OverwriteSilently);

                // search in subfolder (* before filename is required for Android)
                zip.ExtractSelectedEntries("name = *quest.ini", null, target_path, ExtractExistingFileAction.OverwriteSilently);
                zip.ExtractSelectedEntries("name = *Localization.*.txt", null, target_path, ExtractExistingFileAction.OverwriteSilently);
            }

            zip.Dispose();
        }
        catch (System.Exception e)
        {
            ValkyrieDebug.Log("Warning: Unable to read file: " + archive_name + "\nException" + e.ToString());
        }
    }
Example #13
0
    public static void Load()
    {
        Game game = Game.Get();

        try
        {
            if (File.Exists(SaveFile()))
            {
                string data = File.ReadAllText(SaveFile());

                IniData saveData = IniRead.ReadFromString(data);

                Destroyer.Dialog();

                game.cd = new ContentData(game.gameType.DataDirectory());
                // Check if we found anything
                if (game.cd.GetPacks().Count == 0)
                {
                    Debug.Log("Error: Failed to find any content packs, please check that you have them present in: " + game.gameType.DataDirectory() + System.Environment.NewLine);
                    Application.Quit();
                }

                game.cd.LoadContentID("");
                Dictionary <string, string> packs = saveData.Get("Packs");
                foreach (KeyValuePair <string, string> kv in packs)
                {
                    game.cd.LoadContentID("");
                    game.cd.LoadContentID(kv.Key);
                }

                new Quest(saveData);
                game.heroCanvas.SetupUI();
                game.heroCanvas.UpdateImages();
                game.heroCanvas.UpdateStatus();

                if (game.gameType.DisplayMorale())
                {
                    game.moraleDisplay = new MoraleDisplay();
                }
                if (!game.gameType.DisplayHeroes())
                {
                    game.heroCanvas.Clean();
                }

                // Create the menu button
                new MenuButton();
                new NextStageButton();
            }
        }
        catch (System.Exception)
        {
            Debug.Log("Error: Unable to open save file: " + SaveFile());
            Application.Quit();
        }
    }
Example #14
0
    // Read a content pack for list of files and meta data
    public void PopulatePackList(string path)
    {
        // All packs must have a content_pack.ini, otherwise ignore
        if (File.Exists(path + "/content_pack.ini"))
        {
            ContentPack pack = new ContentPack();

            // Get all data from the file
            IniData d = IniRead.ReadFromIni(path + "/content_pack.ini");
            // Todo: better error handling
            if (d == null)
            {
                Debug.Log("Failed to get any data out of " + path + "/content_pack.ini!");
                Application.Quit();
            }

            pack.name = d.Get("ContentPack", "name");
            if (pack.name.Equals(""))
            {
                Debug.Log("Failed to get name data out of " + path + "/content_pack.ini!");
                Application.Quit();
            }

            // id can be empty/missing
            pack.id = d.Get("ContentPack", "id");

            // If this is invalid we will just handle it later, not fatal
            pack.image = path + "/" + d.Get("ContentPack", "image");

            // Black description isn't fatal
            pack.description = d.Get("ContentPack", "description");

            // Get all the other ini files in the pack
            List <string> files = new List <string>();
            // content_pack file is included
            files.Add(path + "/content_pack.ini");

            // No extra files is valid
            if (d.Get("ContentPackData") != null)
            {
                foreach (string file in d.Get("ContentPackData").Keys)
                {
                    files.Add(path + "/" + file);
                }
            }
            // Save list of files
            pack.iniFiles = files;

            // Add content pack
            allPacks.Add(pack);

            // We finish without actually loading the content, this is done later (content optional)
        }
    }
Example #15
0
 private void LoadFile()
 {
     try
     {
         Dictionary <string, string> dictionary = new Dictionary <string, string>();
         XmlRead read = new XmlRead();
         Dictionary <string, string> item = read.GetItem(FileName.File1);
         foreach (KeyValuePair <string, string> pair in item)
         {
             this.combobox.Items.Add("[" + pair.Key + "]" + pair.Value);
             dictionary.Add(pair.Key, pair.Value);
         }
         this.combobox.Items.Add("----------------------");
         Dictionary <string, string> dictionary3 = read.GetItem(FileName.File2);
         foreach (KeyValuePair <string, string> pair in dictionary3)
         {
             this.combobox.Items.Add("[" + pair.Key + "]" + pair.Value);
             dictionary.Add(pair.Key, pair.Value);
         }
         this.file_1.set_FileFilter("Excel文件(*.xls)|*.xls");
         this.file_2.set_FileFilter("Excel文件(*.xls)|*.xls");
         this.file_1.get_TextBoxFile().Text = IniRead.GetPrivateProfileString("File", "File1Path");
         this.file_2.get_TextBoxFile().Text = IniRead.GetPrivateProfileString("File", "File2Path");
         this.com_sheet_1.Text = IniRead.GetPrivateProfileString("File", "TableInFile1");
         this.com_sheet_2.Text = IniRead.GetPrivateProfileString("File", "TableInFile2");
         string privateProfileString = IniRead.GetPrivateProfileString("FieldCon", "FileNumber");
         int    result = 1;
         int.TryParse(privateProfileString, out result);
         this.radioButton1.Checked = result == 1;
         this.radioButton2.Checked = result == 2;
         DataGridView view  = this.dataGridView1;
         DataTable    table = WenBenItem.Items();
         foreach (DataRow row in table.Rows)
         {
             string str2 = IniRead.GetPrivateProfileString("FieldCon", row["key"].ToString());
             if (str2 != "0.0")
             {
                 view.Rows[Convert.ToInt32(row["id"]) - 1].Cells["WenJianLie"].Value = str2;
             }
         }
         view.Rows[6].Cells["MoRen"].Value    = IniRead.GetPrivateProfileString("FieldCon", "DefaultFuHeRen");
         view.Rows[7].Cells["MoRen"].Value    = IniRead.GetPrivateProfileString("FieldCon", "DefaultShouKuanRen");
         view.Rows[0x13].Cells["MoRen"].Value = IniRead.GetPrivateProfileString("FieldCon", "DefaultShuiLv");
         this.combo_1.Text = "[" + IniRead.GetPrivateProfileString("TableCon", "MainTableField") + "]" + read.GetKey1();
         this.combo_2.Text = "[" + IniRead.GetPrivateProfileString("TableCon", "AssistantTableField") + "]" + read.GetKey2();
         this.txt_1.Text   = IniRead.GetPrivateProfileString("TableCon", "MainTableIgnoreRow");
         this.txt_2.Text   = IniRead.GetPrivateProfileString("TableCon", "AssistantTableIgnoreRow");
     }
     catch (Exception exception)
     {
         HandleException.HandleError(exception);
     }
 }
Example #16
0
 /// <summary>
 /// Parse downloaded ini data
 /// </summary>
 /// <param name="download">download object</param>
 /// <param name="call">Function to call after parse</param>
 public void IniFetched(WWW download, UnityEngine.Events.UnityAction call)
 {
     if (download.error == null)
     {
         IniData remoteManifest = IniRead.ReadFromString(download.text);
         data = remoteManifest.Get("Quest");
     }
     else
     {
         iniError = true;
     }
     call();
 }
Example #17
0
    // Populate data
    public void LoadQuestData()
    {
        ValkyrieDebug.Log("Loading quest from: \"" + questPath + "\"" + System.Environment.NewLine);
        game = Game.Get();

        components       = new Dictionary <string, QuestComponent>();
        questActivations = new Dictionary <string, ActivationData>();

        // Read the main quest file
        IniData questIniData = IniRead.ReadFromIni(questPath);

        // Failure to read quest is fatal
        if (questIniData == null)
        {
            ValkyrieDebug.Log("Failed to load quest from: \"" + questPath + "\"");
            Application.Quit();
        }

        // List of data files
        files = new List <string>();
        // The main data file is included
        files.Add(questPath);

        // Find others (no addition files is not fatal)
        if (questIniData.Get("QuestData") != null)
        {
            foreach (string file in questIniData.Get("QuestData").Keys)
            {
                // path is relative to the main file (absolute not supported)
                files.Add(Path.GetDirectoryName(questPath) + "/" + file);
            }
        }

        foreach (string f in files)
        {
            // Read each file
            questIniData = IniRead.ReadFromIni(f);
            // Failure to read a file is fatal
            if (questIniData == null)
            {
                ValkyrieDebug.Log("Unable to read quest file: \"" + f + "\"");
                Application.Quit();
            }
            // Loop through all ini sections
            foreach (KeyValuePair <string, Dictionary <string, string> > section in questIniData.data)
            {
                // Add the section to our quest data
                AddData(section.Key, section.Value, Path.GetDirectoryName(f));
            }
        }
    }
Example #18
0
    public void LoadQuestData()
    {
        Debug.Log("Loading quest from: \"" + questPath + "\"");
        game = Game.Get();

        components    = new Dictionary <string, QuestComponent>();
        flags         = new List <string>();
        heroSelection = new Dictionary <string, List <Game.Hero> >();

        // Read the main quest file
        IniData d = IniRead.ReadFromIni(questPath);

        // Failure to read quest is fatal
        if (d == null)
        {
            Debug.Log("Failed to load quest from: \"" + questPath + "\"");
            Application.Quit();
        }

        // List of data files
        files = new List <string>();
        // The main data file is included
        files.Add(questPath);

        // Find others (no addition files is not fatal)
        if (d.Get("QuestData") != null)
        {
            foreach (string file in d.Get("QuestData").Keys)
            {
                // path is relative to the main file (absolute not supported)
                files.Add(Path.GetDirectoryName(questPath) + "/" + file);
            }
        }

        foreach (string f in files)
        {
            // Read each file
            d = IniRead.ReadFromIni(f);
            // Failure to read a file is fatal
            if (d == null)
            {
                Debug.Log("Unable to read quest file: \"" + f + "\"");
                Application.Quit();
            }
            foreach (KeyValuePair <string, Dictionary <string, string> > section in d.data)
            {
                // Add the section to our quest data
                AddData(section.Key, section.Value, Path.GetDirectoryName(f));
            }
        }
    }
Example #19
0
    /// <summary>
    /// Parse the downloaded remote manifest and start download of individual quest files
    /// </summary>
    public void DownloadManifest()
    {
        if (download.error != null)
        {
            Application.Quit();
        }
        IniData remoteManifest = IniRead.ReadFromString(download.text);

        foreach (KeyValuePair <string, Dictionary <string, string> > kv in remoteManifest.data)
        {
            remoteQuests.Add(new RemoteQuest(kv));
        }
        DownloadQuestFiles();
    }
Example #20
0
    private void QuestsDownload_callback(string data, bool error, System.Uri uri)
    {
        if (error)
        {
            error_download             = true;
            error_download_description = data;
            // Callback to display screen
            if (cb_download != null)
            {
                cb_download(false);
            }

            quest_list_mode = QuestListMode.ERROR_DOWNLOAD;

            return;
        }

        if (!force_local_quest)
        {
            quest_list_mode = QuestListMode.ONLINE;
        }

        // Parse ini
        IniData remoteManifest = IniRead.ReadFromString(data);

        foreach (KeyValuePair <string, Dictionary <string, string> > quest_kv in remoteManifest.data)
        {
            remote_quests_data.Add(quest_kv.Key, new QuestData.Quest(quest_kv.Key, quest_kv.Value));
        }

        if (remote_quests_data.Count == 0)
        {
            Debug.Log("ERROR: Quest list is empty\n");
            error_download             = true;
            error_download_description = "ERROR: Quest list is empty";
            if (cb_download != null)
            {
                cb_download(false);
            }
            return;
        }

        CheckLocalAvailability();

        if (cb_download != null)
        {
            cb_download(true);
        }
    }
Example #21
0
    /// <summary>
    /// Parse the downloaded remote manifest and start download of individual quest files
    /// </summary>
    public void DownloadManifest_callback(string data, bool error)
    {
        if (error)
        {
            // Hide loading screen
            Destroyer.Dialog();

            // draw error message
            float     error_string_width = 0;
            UIElement ui = new UIElement();
            if (data == "ERROR NETWORK")
            {
                StringKey ERROR_NETWORK = new StringKey("val", "ERROR_NETWORK");
                ui.SetText(ERROR_NETWORK, Color.red);
                error_string_width = ui.GetStringWidth(ERROR_NETWORK, UIScaler.GetMediumFont());
            }
            else
            {
                StringKey ERROR_HTTP = new StringKey("val", "ERROR_HTTP", game.stats.error_download_description);
                ui.SetText(ERROR_HTTP, Color.red);
                error_string_width = ui.GetStringWidth(ERROR_HTTP, UIScaler.GetMediumFont());
            }
            ui.SetLocation(UIScaler.GetHCenter() - (error_string_width / 2f), UIScaler.GetVCenter(), error_string_width, 2.4f);
            ui.SetTextAlignment(TextAnchor.MiddleCenter);
            ui.SetFontSize(UIScaler.GetLargeFont());
            ui.SetBGColor(Color.clear);

            // draw return button
            ui = new UIElement();
            ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2);
            ui.SetText(CommonStringKeys.BACK, Color.red);
            ui.SetButton(delegate { Cancel(); });
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            new UIElementBorder(ui, Color.red);

            return;
        }

        IniData remoteManifest = IniRead.ReadFromString(data);

        foreach (KeyValuePair <string, Dictionary <string, string> > kv in remoteManifest.data)
        {
            remoteQuests.Add(new RemoteQuest(kv));
        }
        DownloadQuestFiles();
    }
Example #22
0
    // This loads content from a pack by object
    // Duplicate content will be replaced by the higher priority value
    void LoadContent(ContentPack cp)
    {
        foreach (string ini in cp.iniFiles)
        {
            IniData d = IniRead.ReadFromIni(ini);
            // Bad ini file not a fatal error, just ignore (will be in log)
            if (d == null)
            {
                return;
            }

            // Add each section
            foreach (KeyValuePair <string, Dictionary <string, string> > section in d.data)
            {
                AddContent(section.Key, section.Value, Path.GetDirectoryName(ini), cp.id);
            }
        }
    }
Example #23
0
    // This loads content from a pack by object
    // Duplicate content will be replaced by the higher priority value
    void LoadContent(ContentPack cp)
    {
        // Don't reload content
        if (loadedPacks.Contains(cp.id))
        {
            return;
        }

        foreach (string ini in cp.iniFiles)
        {
            IniData d = IniRead.ReadFromIni(ini);
            // Bad ini file not a fatal error, just ignore (will be in log)
            if (d == null)
            {
                return;
            }

            // Add each section
            foreach (KeyValuePair <string, Dictionary <string, string> > section in d.data)
            {
                AddContent(section.Key, section.Value, Path.GetDirectoryName(ini), cp.id);
            }
        }

        foreach (KeyValuePair <string, List <string> > kv in cp.localizationFiles)
        {
            DictionaryI18n packageDict = DictionaryI18n.ReadFromFileList("", kv.Value, DictionaryI18n.DEFAULT_LANG, Game.Get().currentLang);
            if (packageDict == null)
            {
                // Unable to load dictionary
                return;
            }
            packageDict.setCurrentLanguage(Game.Get().currentLang);

            LocalizationRead.AddDictionary(kv.Key, packageDict);
        }

        loadedPacks.Add(cp.id);

        foreach (string s in cp.clone)
        {
            LoadContentID(s);
        }
    }
Example #24
0
    // This loads content from a pack by object
    // Duplicate content will be replaced by the higher priority value
    void LoadContent(ContentData.ContentPack cp)
    {
        // Don't reload content
        if (cd.loadedPacks.Contains(cp.id))
        {
            return;
        }

        foreach (KeyValuePair <string, List <string> > kv in cp.localizationFiles)
        {
            DictionaryI18n packageDict = new DictionaryI18n();
            foreach (string file in kv.Value)
            {
                packageDict.AddDataFromFile(file);
            }

            LocalizationRead.AddDictionary(kv.Key, packageDict);
        }

        foreach (string ini in cp.iniFiles)
        {
            IniData d = IniRead.ReadFromIni(ini);
            // Bad ini file not a fatal error, just ignore (will be in log)
            if (d == null)
            {
                return;
            }

            // Add each section
            foreach (KeyValuePair <string, Dictionary <string, string> > section in d.data)
            {
                LoadContent(section.Key, section.Value, Path.GetDirectoryName(ini), cp.id);
            }
        }


        cd.loadedPacks.Add(cp.id);

        foreach (string s in cp.clone)
        {
            LoadContentID(s);
        }
    }
Example #25
0
 private void CheckLastSetType()
 {
     if (File.Exists(IniRead.path))
     {
         string privateProfileString = IniRead.GetPrivateProfileString("FieldCon", "Invtype");
         if ((this.invtype == InvType.Common) || (this.invtype == InvType.Special))
         {
             string str2 = this.invtype.ToString();
             if ((privateProfileString.CompareTo("Common") != 0) && (privateProfileString.CompareTo("Special") != 0))
             {
                 CreateIniFile.Create();
             }
         }
         else if (this.invtype.ToString().CompareTo(privateProfileString) != 0)
         {
             CreateIniFile.Create();
         }
     }
 }
Example #26
0
    private void CheckLocalAvailability()
    {
        // load information on local quests
        IniData localManifest = IniRead.ReadFromIni(ContentData.DownloadPath() + "/manifest.ini");

        if (localManifest == null)
        {
            return;
        }

        // Update download status for each questData and check if update is available
        foreach (KeyValuePair <string, QuestData.Quest> quest_data in remote_quests_data)
        {
            if (localManifest.data.ContainsKey(quest_data.Key))
            {
                quest_data.Value.downloaded       = true;
                quest_data.Value.update_available = (localManifest.data[quest_data.Key]["version"] != quest_data.Value.version);
            }
        }
    }
Example #27
0
        public Quest(string p)
        {
            path = p;
            IniData d = IniRead.ReadFromIni(p + "/quest.ini");

            if (d == null)
            {
                Debug.Log("Warning: Invalid quest:" + p + "/quest.ini!");
                return;
            }

            name = d.Get("Quest", "name");
            if (name.Equals(""))
            {
                Debug.Log("Warning: Failed to get name data out of " + p + "/content_pack.ini!");
                return;
            }

            // Missing description is OK
            description = d.Get("Quest", "description");
        }
Example #28
0
    public bool NeedImport()
    {
        logFile = ContentData.ContentPath() + gameType + "/ffg/import.ini";
        IniData log = IniRead.ReadFromIni(logFile);

        if (log == null)
        {
            return(true);
        }

        bool appVersionOK  = false;
        bool valkVersionOK = false;

        string lastImport = log.Get("Import", "FFG");

        appVersionOK = VersionNewerOrEqual(finder.RequiredFFGVersion(), lastImport);

        lastImport    = log.Get("Import", "Valkyrie");
        valkVersionOK = VersionNewerOrEqual(requiredValkyrieVersion, lastImport);
        return(!appVersionOK || !valkVersionOK);
    }
Example #29
0
        public Quest(string p)
        {
            path = p;
            Dictionary <string, string> d = IniRead.ReadFromIni(p + "/quest.ini", "Quest");

            if (d.ContainsKey("type"))
            {
                type = d["type"];
            }
            else
            {
                // Default to D2E to support historical quests
                type = "D2E";
            }

            if (d.ContainsKey("name"))
            {
                name = d["name"];
            }
            else
            {
                ValkyrieDebug.Log("Warning: Failed to get name data out of " + p + "/content_pack.ini!");
                return;
            }

            if (d.ContainsKey("packs") && d["packs"].Length > 0)
            {
                packs = d["packs"].Split(' ');
            }
            else
            {
                packs = new string[0];
            }

            // Missing description is OK
            if (d.ContainsKey("description"))
            {
                description = d["description"];
            }
        }
Example #30
0
    public void DownloadImages(Stack <string> images = null)
    {
        string remoteDict = serverLocation + game.gameType.TypeName() + "/Localization.txt";

        if (images == null)
        {
            remoteManifest = IniRead.ReadFromString(download.text);
            images         = new Stack <string>();
            foreach (KeyValuePair <string, Dictionary <string, string> > kv in remoteManifest.data)
            {
                if (remoteManifest.Get(kv.Key, "image").Length > 0)
                {
                    images.Push(remoteManifest.Get(kv.Key, "image"));
                }
            }
            if (images.Count == 0)
            {
                StartCoroutine(Download(remoteDict, delegate { ReadManifest(); }));
                return;
            }
            StartCoroutine(Download(serverLocation + game.gameType.TypeName() + "/" + images.Peek(), delegate { DownloadImages(images); }));
            return;
        }

        if (download.error == null)
        {
            textures.Add(images.Pop(), download.texture);
        }
        else
        {
            images.Pop();
        }
        if (images.Count > 0)
        {
            StartCoroutine(Download(serverLocation + game.gameType.TypeName() + "/" + images.Peek(), delegate { DownloadImages(images); }));
            return;
        }

        StartCoroutine(Download(remoteDict, delegate { ReadManifest(); }));
    }