Beispiel #1
0
        public Editor(STBLXMLEntry stblEntry = null)
        {
            if (stblEntry != null)
            {
                STBLEntry = stblEntry;
            }

            InitializeComponent();

            IdentifierTextBox.Text = STBLEntry.Identifier;

            LastKeyValue               = STBLEntry.Key;
            KeyDecimalTextBox.Text     = STBLEntry.Key.ToString();
            KeyHexadecimalTextBox.Text = STBLEntry.Key.ToString("x").ToUpper();

            foreach (STBL.Languages language in STBL.GetAllLanguages())
            {
                string languageText = STBLEntry.GetText(language);

                CurrentLanguageStrings[language] = Tools.NormalizeLineEndings(languageText);
                CurrentLanguageStates[language]  = languageText != null ? true : false;
            }

            Forms.SetupLanguageComboBox(LanguageSelector, DefaultLanguage);
        }
Beispiel #2
0
        private void IdentifiersInstanceRandomizeButton_Click(object sender, EventArgs e)
        {
            ulong randomizedKey = STBL.GetRandomULongKey();

            IdentifiersInstanceDecimalTextBox.Text     = randomizedKey.ToString("0");
            IdentifiersInstanceHexadecimalTextBox.Text = randomizedKey.ToString("x").ToUpper();
        }
Beispiel #3
0
        private void KeyRandomizeButton_Click(object sender, EventArgs e)
        {
            uint randomizedKey = STBL.GetRandomUIntKey(blockedKeys: Loading.GetAllEntryKeys());

            KeyDecimalTextBox.Text     = randomizedKey.ToString();
            KeyHexadecimalTextBox.Text = randomizedKey.ToString("x").ToUpper();
        }
Beispiel #4
0
        public SelectorNew()
        {
            InitializeComponent();

            uint randomEntryKey = STBL.GetRandomUIntKey(blockedKeys: Loading.GetAllEntryKeys());

            KeyDecimalTextBox.Text     = randomEntryKey.ToString();
            KeyHexadecimalTextBox.Text = randomEntryKey.ToString("x");
        }
Beispiel #5
0
 public override string ToString()
 {
     if (Language == null)
     {
         return("");
     }
     else
     {
         return(STBL.GetLanguageLocalizedName((STBL.Languages)Language));
     }
 }
Beispiel #6
0
        public SendTo(List <STBLXMLEntry> splittingEntries = null)
        {
            SelectedLanguages = new HashSet <STBL.Languages>(STBL.GetAllLanguages());

            if (splittingEntries != null)
            {
                SplittingEntries = splittingEntries;
            }

            InitializeComponent();
        }
        private void ItemContextMenuRandomizeKeyItem_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow selectedRow in GetAllSelectedItems())
            {
                if (!(selectedRow.DataBoundItem is EntryWrapper selectedRowSource))
                {
                    continue;
                }

                selectedRowSource.STBLEntry.Key = STBL.GetRandomUIntKey(blockedKeys: Loading.GetAllEntryKeys());
            }

            RefreshItems();
        }
Beispiel #8
0
        public static void SetupLanguagePicker(Picker picker, List <STBL.Languages> checkedLanguages)
        {
            foreach (STBL.Languages language in STBL.GetAllLanguages())
            {
                bool languageIsChecked = false;

                if (checkedLanguages.Contains(language))
                {
                    languageIsChecked = true;
                }

                picker.AddItem(new PickerItem(STBL.GetLanguageLocalizedName(language), language), isChecked: languageIsChecked);
            }
        }
Beispiel #9
0
        private void MenuStripEditSelectedResetKeysItem_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow selectedEntryRow in EntryBrowser.GetAllSelectedItems())
            {
                STBLXMLEntry entry = EntryBrowser.FindEntry(selectedEntryRow);

                if (entry != null)
                {
                    continue;
                }

                entry.Key = STBL.GetRandomUIntKey(blockedKeys: Loading.GetAllEntryKeys());
            }

            EntryBrowser.RefreshItems();
        }
Beispiel #10
0
        public static STBLXMLEntry AddNewEntry(uint?key = null, string identifier = "")
        {
            if (key == null)
            {
                key = STBL.GetRandomUIntKey(blockedKeys: GetAllEntryKeys());
            }

            STBLXMLEntry newEntry = new STBLXMLEntry()
            {
                Key        = (uint)key,
                Identifier = identifier
            };

            newEntry.IsDirtyable  = true;
            newEntry.EntryIsDirty = true;

            Data.Entries.Add(newEntry);
            SortEntries();

            return(newEntry);
        }
Beispiel #11
0
        public Translator(STBLXMLEntry stblEntry = null)
        {
            if (stblEntry != null)
            {
                STBLEntry = stblEntry;
            }

            InitializeComponent();

            IdentifierTextBox.Text = STBLEntry.Identifier;

            foreach (STBL.Languages language in STBL.GetAllLanguages())
            {
                string languageText = STBLEntry.GetText(language);

                CurrentLanguageStrings[language] = Tools.NormalizeLineEndings(languageText);
                CurrentLanguageStates[language]  = languageText != null ? true : false;
            }

            Forms.SetupLanguageComboBox(ReferencingLanguageSelector, DefaultReferenceLanguage);
            Forms.SetupLanguageComboBox(EditingLanguageSelector, DefaultEditingLanguage);
        }
Beispiel #12
0
        public MetaData(STBLXMLFile stblFile = null)
        {
            if (stblFile != null)
            {
                STBLFile = stblFile;
            }

            InitializeComponent();

            Forms.SetupLanguageComboBox(FallbackLanguageSelector, STBL.GetLanguage(STBLFile.FallbackLanguage));

            LastSTBLGroupValue               = STBLFile.STBLGroup;
            STBLGroupDecimalTextBox.Text     = STBLFile.STBLGroup.ToString("0");
            STBLGroupHexadecimalTextBox.Text = STBLFile.STBLGroup.ToString("x").ToUpper();

            LastSTBLInstanceValue               = STBLFile.STBLInstance;
            STBLInstanceDecimalTextBox.Text     = STBLFile.STBLInstance.ToString("0");
            STBLInstanceHexadecimalTextBox.Text = STBLFile.STBLInstance.ToString("x").ToUpper();

            STBLNameTextBox.Text = STBLFile.STBLName;

            if (STBLFile.STBLName == "")
            {
                UpdateSTBLNameTextBoxColors(STBLNameTextBox);
            }

            BuildIdentifiersCheckBox.Checked = STBLFile.BuildIdentifiers;

            LastIdentifiersGroupValue               = STBLFile.IdentifiersGroup;
            IdentifiersGroupDecimalTextBox.Text     = STBLFile.IdentifiersGroup.ToString("0");
            IdentifiersGroupHexadecimalTextBox.Text = STBLFile.IdentifiersGroup.ToString("x").ToUpper();

            LastIdentifiersInstanceValue               = STBLFile.IdentifiersInstance;
            IdentifiersInstanceDecimalTextBox.Text     = STBLFile.IdentifiersInstance.ToString("0");
            IdentifiersInstanceHexadecimalTextBox.Text = STBLFile.IdentifiersInstance.ToString("x").ToUpper();

            IdentifiersNameTextBox.Text = STBLFile.IdentifiersName;
        }
Beispiel #13
0
        public static void SetupLanguageComboBox(ComboBox comboBox, STBL.Languages?defaultLanguage, bool includeNullLanguage = false)
        {
            LanguageComboBoxItem        selectedLanguageItem = null;
            List <LanguageComboBoxItem> languageItems        = new List <LanguageComboBoxItem>();

            if (includeNullLanguage)
            {
                LanguageComboBoxItem languageNullItem = new LanguageComboBoxItem(null);

                languageItems.Add(languageNullItem);

                if (defaultLanguage == null)
                {
                    selectedLanguageItem = languageNullItem;
                }
            }

            foreach (STBL.Languages language in STBL.GetAllLanguages())
            {
                LanguageComboBoxItem languageItem = new LanguageComboBoxItem(language);

                if (defaultLanguage == language)
                {
                    selectedLanguageItem = languageItem;
                }

                languageItems.Add(languageItem);
            }

            comboBox.DataSource = languageItems;

            if (selectedLanguageItem != null)
            {
                comboBox.SelectedItem = selectedLanguageItem;
            }
        }
Beispiel #14
0
        public static void ExportToPackageFiles(STBLXMLFile exportingFile, string exportDirectoryPath, bool buildSourceInfoFiles)
        {
            Directory.CreateDirectory(exportDirectoryPath);

            STBL.Languages fallbackLanguage = STBL.GetLanguage(exportingFile.FallbackLanguage);

            foreach (STBL.Languages language in STBL.GetAllLanguages())
            {
                string languageFileName = string.Format(exportingFile.STBLName, new STBL.LanguageFileName(language));

                string stblFileName = languageFileName + "." + STBLFileExtension;
                string stblFilePath = Path.Combine(exportDirectoryPath, stblFileName);

                using (BinaryWriter exportFileWriter = new BinaryWriter(new FileStream(stblFilePath, FileMode.Create))) {
                    string[] texts           = new string[exportingFile.Entries.Count];
                    ushort[] textsByteCounts = new ushort[exportingFile.Entries.Count];
                    uint     entryByteCount  = 0;

                    for (int entryIndex = 0; entryIndex < exportingFile.Entries.Count; entryIndex++)
                    {
                        string entryLanguageText = exportingFile.Entries[entryIndex].GetText(language);

                        if (entryLanguageText == null)
                        {
                            entryLanguageText = exportingFile.Entries[entryIndex].GetText(fallbackLanguage);
                        }

                        if (entryLanguageText == null)
                        {
                            entryLanguageText = exportingFile.Entries[entryIndex].Identifier;
                        }

                        texts[entryIndex] = entryLanguageText;

                        textsByteCounts[entryIndex] = (ushort)Encoding.UTF8.GetByteCount(texts[entryIndex]);
                        entryByteCount += textsByteCounts[entryIndex] + 1u;
                    }

                    exportFileWriter.Write(Encoding.UTF8.GetBytes("STBL"));
                    exportFileWriter.Write((byte)5);
                    exportFileWriter.Write((ushort)0);
                    exportFileWriter.Write((uint)exportingFile.Entries.Count);
                    exportFileWriter.Write(0u);
                    exportFileWriter.Write((ushort)0);
                    exportFileWriter.Write(entryByteCount);

                    for (int textsIndex = 0; textsIndex < exportingFile.Entries.Count; textsIndex++)
                    {
                        exportFileWriter.Write(exportingFile.Entries[textsIndex].Key);
                        exportFileWriter.Write((byte)0);
                        exportFileWriter.Write(textsByteCounts[textsIndex]);
                        exportFileWriter.Write(texts[textsIndex].ToCharArray());
                    }
                }

                if (buildSourceInfoFiles)
                {
                    string sourceInfoFilePath = stblFilePath + "." + SourceInfoFileExtension;

                    string languageInstanceHexadecimal = ((int)language).ToString("x2") + exportingFile.STBLInstance.ToString("x").Substring(2);
                    ulong  languageInstance            = ulong.Parse(languageInstanceHexadecimal, NumberStyles.HexNumber);

                    Tools.WriteXML(sourceInfoFilePath, new SourceInfo()
                    {
                        Name       = languageFileName,
                        TypeID     = 570775514,
                        GroupID    = exportingFile.STBLGroup,
                        InstanceID = languageInstance
                    });
                }
            }
        }
Beispiel #15
0
        public Predicate <STBLXMLEntry> GetFilterPredicate()
        {
            string keyFilterLower = KeyFilter?.ToLower();

            Regex identifierFilterRegex = null;

            if (IdentifierFilterUseRegex)
            {
                identifierFilterRegex = new Regex(IdentifierFilter, RegexOptions.Multiline | (IdentifierFilterMatchCase ? RegexOptions.None : RegexOptions.IgnoreCase));
            }

            Regex textFilterRegex = null;

            if (TextFilterUseRegex)
            {
                textFilterRegex = new Regex(TextFilter, RegexOptions.Multiline | (TextFilterMatchCase ? RegexOptions.None : RegexOptions.IgnoreCase));
            }

            return(delegate(STBLXMLEntry entry) {
                if (KeyFilter != null)
                {
                    string itemKeyDecimal = entry.Key.ToString();
                    string itemKeyHexadecimal = "0x" + entry.Key.ToString("x");

                    if (!itemKeyDecimal.Contains(keyFilterLower) && !itemKeyHexadecimal.Contains(keyFilterLower))
                    {
                        return true;
                    }
                }

                if (IdentifierFilter != null)
                {
                    if (!IdentifierFilterUseRegex || identifierFilterRegex == null)
                    {
                        if (entry.Identifier.IndexOf(IdentifierFilter, IdentifierFilterMatchCase ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase) < 0)
                        {
                            return true;
                        }
                    }
                    else
                    {
                        if (!identifierFilterRegex.IsMatch(entry.Identifier))
                        {
                            return true;
                        }
                    }
                }

                if (TextFilter != null)
                {
                    foreach (STBL.Languages languague in STBL.GetAllLanguages())
                    {
                        string languageText = entry.GetText(languague);

                        if (languageText == null)
                        {
                            continue;
                        }

                        if (!TextFilterUseRegex || textFilterRegex == null)
                        {
                            if (languageText.IndexOf(TextFilter, TextFilterMatchCase ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase) < 0)
                            {
                                return true;
                            }
                        }
                        else
                        {
                            if (!textFilterRegex.IsMatch(languageText))
                            {
                                return true;
                            }
                        }
                    }
                }


                if (UntranslatedFilter != null)
                {
                    try {
                        STBL.Languages untranslatedFilterLanguague = STBL.GetLanguage((int)UntranslatedFilter);

                        if (entry.GetText(untranslatedFilterLanguague) != null)
                        {
                            return true;
                        }
                    } catch { }
                }

                return false;
            });
        }