コード例 #1
0
ファイル: lgGDChat.cs プロジェクト: atom-chen/rongyaojt
        public void chat_msg(uint type, string msg, uint cid = 0u, bool withtid = false, uint backshowtp = 0u)
        {
            bool flag = !this.gagChat(msg);

            if (!flag)
            {
                bool flag2 = cid != 0u && type == 5u;
                if (flag2)
                {
                    Dictionary <uint, Variant> buddyList = (this.g_mgr as muLGClient).g_buddyCT.getBuddyList(3u);
                    bool flag3 = buddyList != null && buddyList.ContainsKey(cid);
                    if (flag3)
                    {
                        LGIUIMainUI lGIUIMainUI  = this.g_mgr.g_uiM.getLGUI("LGUIMainUIImpl") as LGIUIMainUI;
                        string      languageText = LanguagePack.getLanguageText("chat", "blacklist");
                        lGIUIMainUI.systemmsg(languageText, 1024u);
                        return;
                    }
                }
                bool flag4 = type == 1u && (this.g_mgr as muLGClient).g_levelsCT.InMultiLvl();
                if (flag4)
                {
                    type = 9u;
                }
                (this.g_mgr.g_netM as muNetCleint).igChatMsgs.chat_msg(type, msg, cid, withtid, backshowtp);
            }
        }
コード例 #2
0
ファイル: Caeser.cs プロジェクト: j-stud-res/cipherbox
        private string AlphabetShifter(string text, int shift, LanguagePack lp)
        {
            StringBuilder stringBuilder = new StringBuilder();
            int           lenght        = (shift > 0) ? (-1) * lp.AlphabetLenght : lp.AlphabetLenght;

            for (int i = 0; i < text.Length; i++)
            {
                char c = text[i];
                if (!lp.IsLetter(c))
                {
                    stringBuilder.Append(c);
                    continue;
                }
                if (lp.IsLowerCase(c))
                {
                    c += (char)shift;
                    c  = (lp.IsLowerCase(c)) ? c : (char)(c + lenght);
                    stringBuilder.Append(c);
                    continue;
                }
                if (lp.IsUpperCase(c))
                {
                    c += (char)shift;
                    c  = (lp.IsUpperCase(c)) ? c : (char)(c + lenght);
                    stringBuilder.Append(c);
                    continue;
                }
            }
            return(stringBuilder.ToString());
        }
 public void switchDataView(bool systemUserSwitch)
 {
     if (systemUserSwitch)
     {
         Button_UserVoices.IsEnabled            = true;
         Button_SystemVoices.IsEnabled          = false;
         DataGridTextColumn_Filename.IsReadOnly = true;
         LanguagePack currentLanguagePack = ComboBox_LanguageCode.SelectedItem as LanguagePack;
         if (currentLanguagePack != null)
         {
             DataGrid_FileList.ItemsSource = currentLanguagePack.SystemVoices;
         }
         else
         {
             DataGrid_FileList.ItemsSource = null;
         }
     }
     else
     {
         Button_UserVoices.IsEnabled            = false;
         Button_SystemVoices.IsEnabled          = true;
         DataGridTextColumn_Filename.IsReadOnly = false;
         LanguagePack currentLanguagePack = ComboBox_LanguageCode.SelectedItem as LanguagePack;
         if (currentLanguagePack != null)
         {
             DataGrid_FileList.ItemsSource = currentLanguagePack.UserVoices;
         }
         else
         {
             DataGrid_FileList.ItemsSource = null;
         }
     }
 }
コード例 #4
0
        public void ReturnsPhrase()
        {
            var pack   = new LanguagePack(_pack, "test");
            var phrase = pack.Read("page", "phrase");

            Assert.Equal(c_phrase, phrase);
        }
コード例 #5
0
    //public static StreamWriter writer;
    //public static StringReader reader;
    //public static TextAsset xmlFile;

    public static void SaveLanguageFile(Language language)
    {
        //Convert Enum into a String (Not recommended method but tough!)
        string       saveName = System.Enum.GetName(typeof(Language), language);
        string       filePath = Application.dataPath + LanguagePackDirectory + saveName + ".txt";
        StreamWriter f        = new StreamWriter(filePath);

        if (CurrentLanguagePack == null)
        {
            loadedLanguagePack = new LanguagePack();
        }

        for (int i = -1; i < CurrentLanguagePack.Keys.Count; i++)
        {
            if (i == -1)
            {
                f.WriteLine(LanguagePackDirectory);
            }
            else
            {
                f.WriteLine(CurrentLanguagePack.Keys[i] + " = " + CurrentLanguagePack.Strings[i]);
            }

            f.WriteLine("\n");
        }
        f.Close();

        PackLoaded = true;
    }
コード例 #6
0
        void RefreshWordViews(LanguagePack languagePack)
        {
            _currentWord = languagePack.SelectedWord;
            //Native probably being english
            if (_nativeWord == null)
            {
                if (languagePack.NativeLanguage == null)
                {
                    languagePack.NativeLanguage = Client.NativeLanguage;
                }
                _nativeWord = new WordView(new CGRect(0, 0, View.Bounds.Width, 30), languagePack.NativeLanguage,
                                           languagePack.SelectedWord.Native);
                View.Add(_nativeWord);
            }

            //Target being Dutch, French etc..
            if (_targetWord == null)
            {
                if (languagePack.TargetLanguage == null)
                {
                    languagePack.TargetLanguage = Client.TargetLanguage;
                }

                _targetWord = new WordView(new CGRect(0, 160, View.Frame.Width, 30), languagePack.TargetLanguage,
                                           languagePack.SelectedWord.Target);
                View.Add(_targetWord);
            }

            _targetWord.Update(languagePack.SelectedWord.Target);
            _nativeWord.Update(languagePack.SelectedWord.Native);

            _countDownValue = 5;
            _countdownTimer.Start();
        }
コード例 #7
0
ファイル: lgSelfPlayer.cs プロジェクト: atom-chen/rongyaojt
        public void on_mod_exp(Variant info)
        {
            this.data["exp"]._int += info["mod_exp"];
            int    num           = info["mod_exp"];
            string languageText  = LanguagePack.getLanguageText("LGUIItemImpl", "getExp");
            string languageText2 = LanguagePack.getLanguageText("LGUIItemImpl", "loseExp");
            bool   flag          = num > 0;
            string val;

            if (flag)
            {
                val = DebugTrace.Printf(languageText, new string[]
                {
                    num.ToString()
                });
            }
            else
            {
                val = DebugTrace.Printf(languageText2, new string[]
                {
                    Math.Abs(num).ToString()
                });
            }
            Variant variant = new Variant();

            variant.pushBack(val);
        }
コード例 #8
0
        /// <summary>
        /// Create a new language and check for saving, etc
        /// </summary>
        public void NewLanguage()
        {
            if (packOpen && packChanges)
            {
                DialogResult res = MessageBox.Show("Would you like to save your current pack first?", "Save?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                switch (res)
                {
                case System.Windows.Forms.DialogResult.Yes:
                    SaveLanguage();
                    break;

                case System.Windows.Forms.DialogResult.Cancel:
                    return;

                case System.Windows.Forms.DialogResult.No:
                    return;
                }
            }

            LanguagePack lp = NewDialog.NewPack();

            if (lp == null)
            {
                return;
            }

            cPack       = lp;
            packOpen    = true;
            packChanges = false;
            packPath    = "";

            UpdateUI();
        }
コード例 #9
0
        public void change_meript(int value)
        {
            int  meript = this.meript;
            int  num    = value - meript;
            bool flag   = num > 0;

            if (flag)
            {
                this._msgStr = LanguagePack.getLanguageText("LGUIItemImpl", "getStarSoul");
            }
            else
            {
                bool flag2 = num < 0;
                if (flag2)
                {
                    this._msgStr = LanguagePack.getLanguageText("LGUIItemImpl", "loseStarSoul");
                    num          = -num;
                }
            }
            this._msgStr = DebugTrace.Printf(this._msgStr, new string[]
            {
                num.ToString()
            });
            this.lgMainui.systemmsg(this._msgStr, 12u);
            this.meript = value;
        }
コード例 #10
0
ファイル: MutiLanguages.cs プロジェクト: windygu/.net-wms
        public static string ParserMessage(string originMsg)
        {
            string       path         = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "language.mdb");
            LanguagePack languagePack = LanguagePack.Current(path);

            if (originMsg == string.Empty)
            {
                return(string.Empty);
            }
            string errMsg = originMsg;

            Regex  regex = new Regex(@"\$([A-Za-z0-9_]+)");
            string word  = string.Empty;

            foreach (Match match in regex.Matches(errMsg))
            {
                word = languagePack.GetString(match.Value, defaultLanguage);

                if (word != null && word != string.Empty)
                {
                    errMsg = errMsg.Replace(match.Value, word);
                }
            }

            return(errMsg);
        }
コード例 #11
0
        private void LanguageCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (LanguageCombobox.SelectedIndex != -1)
            {
                if (LanguageCombobox.SelectedIndex == 0)
                {
                    Properties.Settings.Default.Language_for_Orange = 1;
                }
                if (LanguageCombobox.SelectedIndex == 1)
                {
                    Properties.Settings.Default.Language_for_Orange = 0;
                }
                if (LanguageCombobox.SelectedIndex == 2)
                {
                    Properties.Settings.Default.Language_for_Orange = 2;
                }
                if (LanguageCombobox.SelectedIndex == 3)
                {
                    Properties.Settings.Default.Language_for_Orange = 3;
                }

                Orange.Util.LanguagePack.TYPE = Properties.Settings.Default.Language_for_Orange;

                TopmostToggleSwitch.Header = LanguagePack.TopMost();
                MsgBroker.MsgBrokerMsg arg = new MsgBroker.MsgBrokerMsg();
                arg.MsgOPCode = UI_CONTROL.SET_LANGUAGE;

                (Application.Current as App).msgBroker.SendMessage(arg);
            }
        }
        private bool LanguagePackIsValid(LanguagePack packToValidate)
        {
            bool PackIsValid = true;

            if (packToValidate.VoiceName == null || packToValidate.VoiceName == "")
            {
                MessageBox.Show("Please select a voice to use for the language pack " + packToValidate.LanguageCode + ". if no voice is selected the default one fill be used.");
                PackIsValid = false;
            }

            foreach (var item in packToValidate.UserVoices)
            {
                if (!isSigleLineValid(item))
                {
                    PackIsValid = false;
                }
            }
            foreach (var item in packToValidate.SystemVoices)
            {
                if (!isSigleLineValid(item))
                {
                    PackIsValid = false;
                }
            }
            return(PackIsValid);
        }
        /*******************************************************************************************************************
         * OnClick events
         ******************************************************************************************************************/

        private void Button_Generate_Click(object sender, RoutedEventArgs e)
        {
            string outputPath = TextBox_OutputPath.Text;
            List <LanguagePack> listOfGeneratedPacks = new List <LanguagePack>();

            if (!generateAllLanguages)
            {
                LanguagePack selectedLanguagePack = ComboBox_LanguageCode.SelectedItem as LanguagePack;
                if (!LanguagePackIsValid(selectedLanguagePack))
                {
                    MessageBoxResult result = MessageBox.Show("Do you want to abort and fix the problem? Pressing no will simply skip the generation of the invalid entrys.", "Skip or fix?", MessageBoxButton.YesNo);
                    if (result == MessageBoxResult.Yes)
                    {
                        return;
                    }
                }
                listOfGeneratedPacks.Add(selectedLanguagePack);
            }
            else
            {
                foreach (var item in currentFile.LanguagePacks)
                {
                    if (!LanguagePackIsValid(item))
                    {
                        MessageBoxResult result = MessageBox.Show("Do you want to abort and fix the problem? Pressing no will simply skip the generation of the invalid entrys.", "Skip or fix?", MessageBoxButton.YesNo);
                        if (result == MessageBoxResult.Yes)
                        {
                            return;
                        }
                    }
                    listOfGeneratedPacks.Add(item);
                }
            }
            Task.Factory.StartNew(() => generate(listOfGeneratedPacks, outputPath));
        }
コード例 #14
0
ファイル: SvrNPCConfig.cs プロジェクト: atom-chen/rongyaojt
        public Variant get_npc_data(int npcid)
        {
            bool    flag = this.m_conf == null || !this.m_conf["npc"].ContainsKey(npcid.ToString());
            Variant result;

            if (flag)
            {
                GameTools.PrintError("get_npc_data [" + npcid + "] Config Err!");
                result = null;
            }
            else
            {
                Variant variant = this.m_conf["npc"][npcid.ToString()];
                bool    flag2   = variant == null;
                if (flag2)
                {
                    GameTools.PrintError("get_npc_data npc[" + npcid + "] not exist Err!");
                    result = null;
                }
                else
                {
                    bool flag3 = variant.ContainsKey("name");
                    if (flag3)
                    {
                        variant["name"] = LanguagePack.getLanguageText("npcName", npcid.ToString());
                    }
                    result = variant;
                }
            }
            return(result);
        }
コード例 #15
0
        private void shareFeedsRes(string type, int res)
        {
            bool flag = res == 0;

            if (flag)
            {
                Action <string> action = this._callbacks[type];
                bool            flag2  = action != null;
                if (flag2)
                {
                    action(type);
                    this._callbacks[type] = null;
                }
                string      languageText = LanguagePack.getLanguageText("shareFeeds", "share_success");
                LGIUIMainUI lGIUIMainUI  = (this.g_mgr.g_uiM as muUIClient).getLGUI("LGUIMainUIImpl") as LGIUIMainUI;
                lGIUIMainUI.systemmsg(languageText, 1024u);
                Variant variant  = this.parseTypeStr(type);
                Variant variant2 = this.getfeeds(variant["type"]);
                bool    flag3    = variant2 != null;
                if (flag3)
                {
                    Variant shareFeedData = this.getShareFeedData(variant2, variant["arg"]);
                    bool    flag4         = shareFeedData != null;
                    if (flag4)
                    {
                        bool flag5 = shareFeedData["once"];
                        if (flag5)
                        {
                            this.saveShareFlag(this.getShareFlag(variant["type"], variant["arg"]));
                        }
                    }
                }
            }
        }
コード例 #16
0
        private void initPrefer()
        {
            TrayToggleSwitch.IsChecked         = Properties.Settings.Default.IsTray;
            TrayToggleSwitch.IsCheckedChanged += TrayToggleSwitch_IsCheckedChanged;

            TopmostToggleSwitch.IsChecked         = Config.IsTopMost;
            TopmostToggleSwitch.IsCheckedChanged += TopmostToggleSwitch_IsCheckedChanged;
            TopmostToggleSwitch.Header            = LanguagePack.TopMost();

            if (Properties.Settings.Default.Language_for_Orange == 0)
            {
                LanguageCombobox.SelectedIndex = 1;
            }
            else if (Properties.Settings.Default.Language_for_Orange == 1)
            {
                LanguageCombobox.SelectedIndex = 0;
            }
            else if (Properties.Settings.Default.Language_for_Orange == 2)
            {
                LanguageCombobox.SelectedIndex = 2;
            }
            else if (Properties.Settings.Default.Language_for_Orange == 3)
            {
                LanguageCombobox.SelectedIndex = 3;
            }
        }
コード例 #17
0
        public void mode_clanpt(int value)
        {
            bool flag = this._netData["clan_pt"] >= 0;

            if (flag)
            {
                Variant variant = this._netData;
                variant["clan_pt"] = variant["clan_pt"] + value;
            }
            else
            {
                this._netData["clan_pt"] = value;
            }
            bool flag2 = value > 0;

            if (flag2)
            {
                this._msgStr = LanguagePack.getLanguageText("LGUIItemImpl", "getClanPt");
            }
            else
            {
                this._msgStr = LanguagePack.getLanguageText("LGUIItemImpl", "loseClanPt");
                value        = -value;
            }
            this._msgStr = DebugTrace.Printf(this._msgStr, new string[]
            {
                value.ToString()
            });
            this.lgMainui.systemmsg(this._msgStr, 12u);
        }
コード例 #18
0
ファイル: lgGDWorldline.cs プロジェクト: atom-chen/rongyaojt
        public void set_line(uint l, Action callBack = null)
        {
            bool flag = (this.g_mgr as muLGClient).g_missionCT.isPlayerAcceptedRmis(1u);

            if (flag)
            {
                bool flag2 = this.t_rmis_nchgLine == null;
                if (flag2)
                {
                    this.t_rmis_nchgLine = LanguagePack.getLanguageText("change_line", "rmis_n_chgline");
                }
                this.mainUI.systemmsg(this.t_rmis_nchgLine, 4u);
            }
            else
            {
                bool flag3 = this.VIP_LINE > 0u && this.VIP_LINE == l;
                if (flag3)
                {
                }
                bool flag4 = (long)this._cur_line != (long)((ulong)l);
                if (flag4)
                {
                    this._changeLineCallback = callBack;
                    this._changelineMsg.select_line(l);
                }
            }
        }
コード例 #19
0
        public void FormatsPhrase()
        {
            var pack   = new LanguagePack(_pack, "test");
            var phrase = pack.Read("page", "format", "World");

            Assert.Equal(c_phrase, phrase);
        }
コード例 #20
0
    public static LanguagePack LoadToPack(Language language)
    {
        CurrentLanguage = language;

        try
        {
            string       loadName = System.Enum.GetName(typeof(Language), language);
            string       filePath = LanguagePackDirectory + loadName;
            LanguagePack pk       = new LanguagePack();

            // Read in the STRING contents of xmlFile (TextAsset)
            TextAsset xmlFile;
            string    t;

            if (LanguagePackDirectory.StartsWith("/Resources"))
            {
                filePath = filePath.Substring(11);
                xmlFile  = (TextAsset)Resources.Load(filePath, typeof(TextAsset));
                t        = xmlFile.text;
            }
            else
            {
                StreamReader sr = new StreamReader(Application.dataPath + filePath + ".txt");
                t = sr.ReadToEnd();
                sr.Close();
            }

            using (StringReader f = new StringReader(t))
            {
                string line;
                while ((line = f.ReadLine()) != null)
                {
                    try
                    {
                        pk.AddNewString((string)(line.Split(new string[] { " = " }, System.StringSplitOptions.None)[0]), line.Split(new string[] { " = " }, System.StringSplitOptions.None)[1]);
                        //Debug.Log(line);
                    }
                    catch
                    {
                        if (line.Length > 0)
                        {
                            LanguagePackDirectory = line;
                        }
                    }
                }
            }

            PackLoaded = true;

            return(pk);
        } catch {
            Debug.Log("No File Was Found! Make sure the language file you are trying to load exists!");

            PackLoaded = false;

            return(null);
        }
    }
コード例 #21
0
    public void ApplyText()
    {
        LanguagePack language = MultiLanguageManager.SelectedLanguage;

        if (language != null)
        {
            textRenderer.text = language[termIdentifier];
        }
    }
コード例 #22
0
        private void UpdateLanguagePacksTable()
        {
            if (InvokeRequired)
            {
                Invoke((MethodInvoker) delegate { UpdateLanguagePacksTable(); });
                return;
            }

            foreach (LanguagePack languagePack in languagePacks.Values)
            {
                if (languagePack.Type != LanguagePackType.Basic)
                {
                    continue;
                }

                List <LanguagePack> packs           = GetLanguagePacks(languagePack.Language);
                LanguagePack        ocrLanguagePack = packs.FirstOrDefault(x => x.Type == LanguagePackType.OCR);

                ListViewItem listViewItem = null;
                foreach (ListViewItem item in languagePacksListView.Items)
                {
                    if (item.SubItems[0].Text == languagePack.DisplayName)
                    {
                        listViewItem = item;
                        break;
                    }
                }

                if (listViewItem == null)
                {
                    listViewItem = new ListViewItem(new string[] { "", "", "", "" });
                    languagePacksListView.Items.Add(listViewItem);
                }

                string types = string.Empty;
                List <LanguagePackType> packTypes = new List <LanguagePackType>();
                foreach (LanguagePack pack in packs)
                {
                    if (!packTypes.Contains(pack.Type))
                    {
                        types += pack.Type + ", ";
                    }
                }
                types = types.TrimEnd(',', ' ');
                string downloadSize = languagePack.Size;
                if (ocrLanguagePack != null)
                {
                    downloadSize += " + " + packs.FirstOrDefault(x => x.Type == LanguagePackType.OCR).Size;
                }

                listViewItem.SubItems[0].Text = languagePack.DisplayName;
                listViewItem.SubItems[1].Text = types;
                listViewItem.SubItems[2].Text = downloadSize;
                listViewItem.SubItems[3].Text = ocrLanguagePack == null?languagePack.Installed.ToString() : ocrLanguagePack.Installed.ToString();
            }
        }
コード例 #23
0
 public void sub_bndyb(uint value)
 {
     this.bndyb   = this._netData["bndyb"]._int - (int)value;
     this._msgStr = LanguagePack.getLanguageText("LGUIItemImpl", "loseGift");
     this._msgStr = DebugTrace.Printf(this._msgStr, new string[]
     {
         value.ToString()
     });
     this.lgMainui.systemmsg(this._msgStr, 4u);
 }
コード例 #24
0
        /// <summary>
        ///     Loads everything.
        /// </summary>
        private void LoadAll()
        {
            using (IReader reader = _streamManager.OpenRead())
                _currentPack = _cache.Languages.LoadLanguage(_currentLanguage, reader);

            LoadStrings();
            LoadGroups();

            Dispatcher.Invoke(new Action(delegate { lvLocales.DataContext = _stringView; }));
        }
コード例 #25
0
        /// <summary>
        /// Event handler for when the Quit Game menu entry is selected.
        /// </summary>
        void QuitGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            string message = LanguagePack.Get(vxLocalization.Pause_AreYouSureYouWantToQuit);

            vxMessageBox confirmQuitMessageBox = new vxMessageBox(message, LanguagePack.Get(vxLocalization.Pause));

            confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;

            vxEngine.AddScreen(confirmQuitMessageBox, ControllingPlayer);
        }
コード例 #26
0
            protected override void _onProcess()
            {
                LGIUIMainUI lGIUIMainUI = (this.session as ClientSession).g_mgr.g_uiM.getLGUI("LGUIMainUIImpl") as LGIUIMainUI;
                string      text        = LanguagePack.getLanguageText("UIMdlgTeam", "refuseTeamAsk");

                text = DebugTrace.Printf(text, new string[]
                {
                    this.msgData["name"]
                });
                lGIUIMainUI.systemmsg(text, 4u);
            }
        /*******************************************************************************************************************
         * Change events
         ******************************************************************************************************************/

        private void ComboBox_LanguageCode_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            LanguagePack currentLanguagePack = ComboBox_LanguageCode.SelectedItem as LanguagePack;

            if (currentLanguagePack != null)
            {
                ComboBox_VoiceName.ItemsSource = ListVoices(currentLanguagePack.LanguageCode);
            }
            Button_SystemVoices_Click(sender, e);
            GUIRefresh();
        }
        public LanguagePack createEmptyLanguagePack()
        {
            currentFile.outputPath           = "SOUNDS";
            currentFile.GenerateSystemSounds = true;
            currentFile.GenerateUserSounds   = true;
            currentFile.OverrideSounds       = false;
            LanguagePack newPack = createDefaultVoicePack();

            currentFile.LanguagePacks.Add(newPack);
            return(newPack);
        }
コード例 #29
0
        public void setTradeReqData(Variant msgData)
        {
            this._traderCid  = msgData["cid"];
            this._traderName = msgData["name"];
            LGIUINotify lGIUINotify = (this.g_mgr.g_uiM as muUIClient).getLGUI("notify") as LGIUINotify;

            lGIUINotify.notifyTradeRequest(msgData, true);
            LGIUIMainUI lGIUIMainUI = (this.g_mgr.g_uiM as muUIClient).getLGUI("LGUIMainUIImpl") as LGIUIMainUI;

            lGIUIMainUI.systemmsg(new Variant(this._traderName + LanguagePack.getLanguageText("trade", "request")), LGUIConstant.SYSMSG_TYPE_RB1);
        }
コード例 #30
0
    static public void makeJSON()
    {
        //初期設定を生成
        config = new LanguagePack();

        //初期設定ファイルを生成
        var json = JsonUtility.ToJson(config);

        //初期設定ファイルを書き込み
        File.WriteAllText(jsonPath, json, new UTF8Encoding(false));
    }
コード例 #31
0
    public static void AddKeysFromMaster(Language master, Language slave)
    {
        masterPack = LoadToPack (master);
        slavePack = LoadToPack (slave);

        // Compare and Add

        for (int i = 0; i < masterPack.Keys.Count; i++) {
            if (!slavePack.Keys.Contains (masterPack.Keys [i])) {
                slavePack.AddNewString (masterPack.Keys [i], masterPack.Strings [i]);
            }
        }

        loadedLanguagePack = slavePack;
    }
コード例 #32
0
    //public static StreamWriter writer;
    //public static StringReader reader;
    //public static TextAsset xmlFile;
    public static void SaveLanguageFile(Language language)
    {
        //Convert Enum into a String (Not recommended method but tough!)
        string saveName = System.Enum.GetName(typeof(Language), language);
        string filePath = Application.dataPath + LanguagePackDirectory + saveName + ".txt";
        StreamWriter f = new StreamWriter(filePath);

        if(CurrentLanguagePack==null)
            loadedLanguagePack = new LanguagePack();

        for(int i = -1; i  < CurrentLanguagePack.Keys.Count; i++)
        {
            if(i == -1)
                f.WriteLine(LanguagePackDirectory);
            else
                f.WriteLine(CurrentLanguagePack.Keys[i] + " = " + CurrentLanguagePack.Strings[i]);

            f.WriteLine("\n");
        }
        f.Close();

        PackLoaded = true;
    }
コード例 #33
0
    public static LanguagePack LoadToPack(Language language)
    {
        CurrentLanguage = language;

        try
        {
            string loadName = System.Enum.GetName(typeof(Language), language);
            string filePath = LanguagePackDirectory + loadName;
            LanguagePack pk = new LanguagePack();

            // Read in the STRING contents of xmlFile (TextAsset)
            TextAsset xmlFile;
            string t;

            if(LanguagePackDirectory.StartsWith("/Resources"))
            {
                filePath = filePath.Substring(11);
                xmlFile = (TextAsset)Resources.Load(filePath, typeof(TextAsset));
                t = xmlFile.text;
            }
            else
            {
                StreamReader sr = new StreamReader(Application.dataPath + filePath + ".txt");
                t = sr.ReadToEnd();
                sr.Close();
            }

            using(StringReader f = new StringReader(t))
            {
                string line;
                while((line = f.ReadLine()) != null)
                {
                    try
                    {
                        pk.AddNewString((string)(line.Split(new string[] { " = " }, System.StringSplitOptions.None)[0]), line.Split(new string[] { " = " }, System.StringSplitOptions.None)[1]);
                        //Debug.Log(line);
                    }
                    catch
                    {
                        if(line.Length > 0)
                            LanguagePackDirectory = line;
                    }
                }
            }

            PackLoaded = true;

            return pk;
        } catch {
            Debug.Log("No File Was Found! Make sure the language file you are trying to load exists!");

            PackLoaded = false;

            return null;
        }
    }
コード例 #34
0
    /*
    public static void ConvertToNewFormat(Language language)
    {
        Debug.Log("FINISHED CONVERTING");
        LanguagePack pk = LoadToPack(language);

        string loadName = System.Enum.GetName(typeof(Language), language);
        string filePath = Application.dataPath + "/Resources/" + LanguagePackDirectory + loadName + "_NEW.txt";

        StreamWriter f = new StreamWriter(filePath);
        for(int i = 0; i  < pk.Keys.Count; i++)
        {
            f.WriteLine(pk.Keys[i] + " = " + pk.Strings[i]);
            f.WriteLine("\n");
        }
        f.Close();
    }
    */
    public static void LoadLanguageFile(Language language)
    {
        loadedLanguagePack = LoadToPack(language);
    }