virtual public void AddCategory(string categoryName)
        {
            Text cn = new Text(categoryName);

            if (Categories != null)
            {
                foreach (TextCollection tc in Categories)
                {
                    if (tc.Values.Contains(cn))
                    {
                        return;
                    }
                }
            }

            if (Categories == null ||
                Categories.Length == 0)
            {
                Categories = new TextCollection[1] {
                    new TextCollection(categoryName)
                };
                Categories[0].Name = "CATEGORIES";
            }
            else
            {
                Categories[0].Values.Add(cn);
            }
        }
Beispiel #2
0
        virtual public void AddResource(string resource)
        {
            Text r = new Text(resource);

            if (Resources != null)
            {
                foreach (TextCollection tc in Resources)
                {
                    if (tc.Values.Contains(r))
                    {
                        return;
                    }
                }
            }

            if (Resources == null ||
                Resources.Length == 0)
            {
                Resources = new TextCollection[1] {
                    new TextCollection(resource)
                };
                Resources[0].Name = "RESOURCES";
            }
            else
            {
                Resources[0].Values.Add(r);
            }
        }
        private static void UpdateCount(TextCollection textCollection, Label countLabel)
        {
            int total = textCollection.TotalCharacterCount;
            int max   = textCollection.MaxCharacterCount;

            countLabel.Text      = $"{total}/{max}";
            countLabel.ForeColor = total >= max ? Color.Red : SystemColors.ControlText;
        }
Beispiel #4
0
 public ActionResult Save(Bam.Net.Translation.Text[] values)
 {
     try
     {
         TextCollection saver = new TextCollection();
         saver.AddRange(values);
         saver.Save();
         return(Json(new { Success = true, Message = "", Dao = "" }));
     }
     catch (Exception ex)
     {
         return(GetErrorResult(ex));
     }
 }
Beispiel #5
0
        public void Init()
        {
            this.gpCupSelectTexts  = Context.Game.Settings.GPCupSelectTexts;
            this.gpResultsCupTexts = Context.Game.Settings.GPResultsCupTexts;
            this.gpPodiumCupTexts  = Context.Game.Settings.GPPodiumCupTexts;

            this.fireEvents = false;

            if (this.gpCupSelectTexts == null)
            {
                // NOTE: Japanese ROM, text editing not supported for GP cup names
                this.gpCupSelectTextsGroupBox.Enabled = false;

                this.cupTextBox1.Text = string.Empty;
                this.cupTextBox2.Text = string.Empty;
                this.cupTextBox3.Text = string.Empty;
                this.cupTextBox4.Text = string.Empty;

                this.gpCupSelectTextsCountLabel.Text = string.Empty;
            }
            else
            {
                this.gpCupSelectTextsGroupBox.Enabled = true;

                this.cupTextBox1.Text = this.gpCupSelectTexts[0].Value;
                this.cupTextBox2.Text = this.gpCupSelectTexts[1].Value;
                this.cupTextBox3.Text = this.gpCupSelectTexts[2].Value;
                this.cupTextBox4.Text = this.gpCupSelectTexts[3].Value;

                UpdateCount(this.gpCupSelectTexts, this.gpCupSelectTextsCountLabel);
            }

            this.resultsTextBox1.Text = this.gpResultsCupTexts[0].Value;
            this.resultsTextBox2.Text = this.gpResultsCupTexts[1].Value;
            this.resultsTextBox3.Text = this.gpResultsCupTexts[2].Value;
            this.resultsTextBox4.Text = this.gpResultsCupTexts[3].Value;

            UpdateCount(this.gpResultsCupTexts, this.gpResultsCupTextsCountLabel);

            this.podiumTextBox1.Text = this.gpPodiumCupTexts[0].Value;
            this.podiumTextBox2.Text = this.gpPodiumCupTexts[1].Value;
            this.podiumTextBox3.Text = this.gpPodiumCupTexts[2].Value;
            this.podiumTextBox4.Text = this.gpPodiumCupTexts[3].Value;
            this.podiumTextBox5.Text = this.gpPodiumCupTexts[4].Value;

            UpdateCount(this.gpPodiumCupTexts, this.gpPodiumCupTextsCountLabel);

            this.fireEvents = true;
        }
Beispiel #6
0
        public void Init(TextCollection textCollection)
        {
            this.textCollection = textCollection;
            this.indexDictionary.Clear();

            this.BeginUpdate();
            this.Items.Clear();
            int index = 0;

            foreach (TextItem textItem in this.textCollection)
            {
                this.indexDictionary.Add(textItem, index++);
                textItem.PropertyChanged += this.textItem_PropertyChanged;
                this.Items.Add(textItem);
            }

            this.EndUpdate();
        }
        public void Init(TextCollection names)
        {
            this.names = names;

            this.fireEvents = false;

            this.textBox1.Text = names[0].Value;
            this.textBox2.Text = names[1].Value;
            this.textBox3.Text = names[2].Value;
            this.textBox4.Text = names[3].Value;
            this.textBox5.Text = names[4].Value;
            this.textBox6.Text = names[5].Value;
            this.textBox7.Text = names[6].Value;
            this.textBox8.Text = names[7].Value;

            this.fireEvents = true;

            this.UpdateCount();
        }
        private void OnTextBoxTextChanged(object sender, TextCollection textCollection, Label countLabel)
        {
            if (!this.fireEvents)
            {
                return;
            }

            this.fireEvents = false;

            TextBox textBox = sender as TextBox;
            int     id      = (int)textBox.Tag;
            int     sel     = textBox.SelectionStart;

            textCollection[id].Value = textBox.Text;

            textBox.Text           = textCollection[id].Value; // Retrieve validated text
            textBox.SelectionStart = sel;                      // Restore text input position

            this.fireEvents = true;

            UpdateCount(textCollection, countLabel);
        }
Beispiel #9
0
    // change the language to the specified language index
    public void ChangeLanguage(int langIndex)
    {
        if ((TextCollection == null) || (TextCollection.Count == 0))
        {
            return;
        }

        TextCollection textCol = TextCollection [langIndex % TextCollection.Count];

        title.text        = textCol.title;
        description.text  = textCol.description;
        banner.text       = textCol.banner.ToUpper();
        subType1.text     = textCol.subType1.ToUpper();
        subFee1.text      = textCol.subFee1;
        subBilling1.text  = textCol.subBilling1;
        subType2.text     = textCol.subType2.ToUpper();
        subFee2.text      = textCol.subFee2;
        subBilling2.text  = textCol.subBilling2;
        special.text      = textCol.special.ToUpper();
        cont.text         = textCol.cont;
        noCommitment.text = textCol.noCommitment;
        restore.text      = textCol.restore;
        noThanks.text     = textCol.noThanks;
    }
        public void Init()
        {
            this.courseSelectTexts = Context.Game.Settings.CourseSelectTexts;

            this.fireEvents = false;

            this.courseTextBox1.Text  = this.courseSelectTexts[0].Value;
            this.courseTextBox2.Text  = this.courseSelectTexts[1].Value;
            this.courseTextBox3.Text  = this.courseSelectTexts[2].Value;
            this.courseTextBox4.Text  = this.courseSelectTexts[3].Value;
            this.courseTextBox5.Text  = this.courseSelectTexts[4].Value;
            this.courseTextBox6.Text  = this.courseSelectTexts[5].Value;
            this.courseTextBox7.Text  = this.courseSelectTexts[6].Value;
            this.courseTextBox8.Text  = this.courseSelectTexts[7].Value;
            this.courseTextBox9.Text  = this.courseSelectTexts[8].Value;
            this.courseTextBox10.Text = this.courseSelectTexts[9].Value;
            this.courseTextBox11.Text = this.courseSelectTexts[10].Value;
            this.courseTextBox12.Text = this.courseSelectTexts[11].Value;
            this.courseTextBox13.Text = this.courseSelectTexts[12].Value;

            UpdateCount(this.courseSelectTexts, this.courseSelectTextsCountLabel);

            this.fireEvents = true;
        }
Beispiel #11
0
 public TextCollectionSerializer(TextCollection tc)
     : base(tc)
 {
     this.m_TC = tc;
 }
Beispiel #12
0
        private void Init(byte[] romBuffer, Offsets offsets, TextCollection names)
        {
            // TODO: Retrieve order dynamically from the ROM
            int[] reorder = { 5, 4, 6, 9, 8, 10, 7, 12 }; // To reorder the themes, as they're not in the same order as the names

            int[] paletteOffsets     = Utilities.ReadBlockOffset(romBuffer, offsets[Offset.ThemePalettes], this.themes.Length);
            int[] roadTileGfxOffsets = Utilities.ReadBlockOffset(romBuffer, offsets[Offset.ThemeRoadGraphics], this.themes.Length);
            int[] bgTileGfxOffsets   = Utilities.ReadBlockOffset(romBuffer, offsets[Offset.ThemeBackgroundGraphics], this.themes.Length);
            int[] bgLayoutOffsets    = Utilities.ReadBlockOffset(romBuffer, offsets[Offset.ThemeBackgroundLayouts], this.themes.Length);

            bool roadTilesetHackApplied = Themes.IsRoadTilesetHackApplied(romBuffer, offsets);

            byte[]   commonRoadTilePaletteIndexes;
            byte[][] commonRoadTileGfx;

            if (roadTilesetHackApplied)
            {
                commonRoadTilePaletteIndexes = null;
                commonRoadTileGfx            = null;
            }
            else
            {
                int commonRoadTileUpperByte  = offsets[Offset.CommonTilesetGraphicsUpperByte];
                int commonRoadTileLowerBytes = offsets[Offset.CommonTilesetGraphicsLowerBytes];
                int commonRoadTileOffset     = Utilities.BytesToOffset(
                    romBuffer[commonRoadTileLowerBytes],
                    romBuffer[commonRoadTileLowerBytes + 1],
                    romBuffer[commonRoadTileUpperByte]
                    );
                byte[] commonRoadTileData = Codec.Decompress(romBuffer, commonRoadTileOffset);
                commonRoadTilePaletteIndexes = Themes.GetPaletteIndexes(commonRoadTileData, RoadTileset.CommonTileCount);
                commonRoadTileGfx            = Utilities.ReadBlockGroupUntil(commonRoadTileData, RoadTileset.TileCount, -1, 32);
            }

            bool tileGenresRelocated = Themes.AreTileGenresRelocated(romBuffer, offsets[Offset.TileGenreLoad]);

            byte[]          roadTileGenreData;
            byte[][]        roadTileGenreIndexes;
            RoadTileGenre[] commonRoadTileGenres;

            if (tileGenresRelocated)
            {
                roadTileGenreData    = null;
                roadTileGenreIndexes = null;
                commonRoadTileGenres = null;
            }
            else
            {
                roadTileGenreData    = Codec.Decompress(romBuffer, offsets[Offset.TileGenres]);
                roadTileGenreIndexes = Utilities.ReadBlockGroup(romBuffer, offsets[Offset.TileGenreIndexes], 2, Theme.Count * 2);
                commonRoadTileGenres = Themes.GetTileGenres(roadTileGenreData, 0, RoadTileset.CommonTileCount);
            }

            for (int i = 0; i < this.themes.Length; i++)
            {
                TextItem nameItem = names[reorder[i]];

                // HACK: Force the length to 512 in case the color palette data in the ROM is corrupt ("EarthBound Kart Beta" has this issue)
                byte[]   paletteData = Codec.Decompress(romBuffer, paletteOffsets[i], 512);
                Palettes palettes    = new Palettes(paletteData);

                byte[]   roadTileData = Codec.Decompress(romBuffer, roadTileGfxOffsets[i]);
                byte[][] roadTileGfx  = Utilities.ReadBlockGroupUntil(roadTileData, RoadTileset.TileCount, -1, 32);
                byte[]   allRoadTilePaletteIndexes;
                byte[][] allRoadTileGfx;

                if (roadTilesetHackApplied)
                {
                    allRoadTilePaletteIndexes = Themes.GetPaletteIndexes(roadTileData, RoadTileset.TileCount);
                    allRoadTileGfx            = roadTileGfx;
                }
                else
                {
                    byte[] roadTilePaletteIndexes = Themes.GetPaletteIndexes(roadTileData, RoadTileset.ThemeTileCount);
                    allRoadTilePaletteIndexes = new byte[RoadTileset.TileCount];
                    Buffer.BlockCopy(roadTilePaletteIndexes, 0, allRoadTilePaletteIndexes, 0, RoadTileset.ThemeTileCount);
                    Buffer.BlockCopy(commonRoadTilePaletteIndexes, 0, allRoadTilePaletteIndexes, RoadTileset.ThemeTileCount, RoadTileset.CommonTileCount);

                    allRoadTileGfx = new byte[RoadTileset.TileCount][];
                    Array.Copy(roadTileGfx, 0, allRoadTileGfx, 0, roadTileGfx.Length);

                    // Clone the commonRoadTileGfx jagged array,
                    // because we don't want theme-specific tile graphics update to affect other themes
                    byte[][] commonRoadTileGfxClone = new byte[commonRoadTileGfx.Length][];
                    for (int j = 0; j < commonRoadTileGfxClone.Length; j++)
                    {
                        commonRoadTileGfxClone[j] = Utilities.ReadBlock(commonRoadTileGfx[j], 0, commonRoadTileGfx[j].Length);
                    }

                    Array.Copy(commonRoadTileGfxClone, 0, allRoadTileGfx, RoadTileset.ThemeTileCount, commonRoadTileGfxClone.Length);

                    // Set empty tile default graphics value
                    for (int j = roadTileGfx.Length; j < RoadTileset.ThemeTileCount; j++)
                    {
                        allRoadTileGfx[j] = new byte[32];
                    }
                }

                RoadTileGenre[] allRoadTileGenres;

                if (tileGenresRelocated)
                {
                    int tileGenreOffset = offsets[Offset.TileGenresRelocated] + i * RoadTileset.TileCount;
                    allRoadTileGenres = Themes.GetTileGenres(romBuffer, tileGenreOffset, RoadTileset.TileCount);
                }
                else
                {
                    int             roadTileGenreIndex = roadTileGenreIndexes[i][0] + (roadTileGenreIndexes[i][1] << 8);
                    RoadTileGenre[] roadTileGenres     = Themes.GetTileGenres(roadTileGenreData, roadTileGenreIndex, roadTileGfx.Length);
                    allRoadTileGenres = new RoadTileGenre[RoadTileset.TileCount];
                    Array.Copy(roadTileGenres, 0, allRoadTileGenres, 0, roadTileGenres.Length);
                    Array.Copy(commonRoadTileGenres, 0, allRoadTileGenres, RoadTileset.ThemeTileCount, commonRoadTileGenres.Length);

                    // Set empty tile default genre value
                    for (int j = roadTileGfx.Length; j < RoadTileset.ThemeTileCount; j++)
                    {
                        allRoadTileGenres[j] = RoadTileGenre.Road;
                    }
                }

                RoadTileset roadTileset = Themes.GetRoadTileset(palettes, allRoadTilePaletteIndexes, allRoadTileGfx, allRoadTileGenres);

                byte[]            bgTileData = Codec.Decompress(romBuffer, bgTileGfxOffsets[i]);
                byte[][]          bgTileGfx  = Utilities.ReadBlockGroupUntil(bgTileData, 0, -1, 16);
                BackgroundTileset bgTileset  = Themes.GetBackgroundTileset(palettes, bgTileGfx);

                byte[]           bgLayoutData = Codec.Decompress(romBuffer, bgLayoutOffsets[i]);
                BackgroundLayout bgLayout     = new BackgroundLayout(bgLayoutData);

                Background background = new Background(bgTileset, bgLayout);

                this.themes[i] = new Theme(nameItem, palettes, roadTileset, background);
            }
        }
Beispiel #13
0
 public Themes(byte[] romBuffer, Offsets offsets, TextCollection names)
 {
     this.themes = new Theme[Theme.Count];
     this.Init(romBuffer, offsets, names);
     this.HandleChanges();
 }
        private void TestTexts(string[] expectedTexts, byte[] expectedIndexes, byte[] expectedBytes, TextCollection textColl)
        {
            Assert.AreEqual(expectedTexts.Length, textColl.Count);

            for (int i = 0; i < expectedTexts.Length; i++)
            {
                Assert.AreEqual(expectedTexts[i], textColl[i].Value);
            }

            if (expectedBytes != null)
            {
                byte[] textBytes = textColl.GetBytes(out byte[] indexes);
                Assert.AreEqual(expectedIndexes, indexes);
                Assert.AreEqual(expectedBytes, textBytes);

                // The original data is filled with text with no extra room,
                // so the total character count should be equal to the max.
                Assert.AreEqual(textColl.MaxCharacterCount, textColl.TotalCharacterCount);
            }
        }