Beispiel #1
0
 private void resetCharacterToolStripMenuItem_Click(object sender, EventArgs e)
 {
     gameSet.characterDictionary[currentCharacterType] = new CharacterSet(currentCharacterType);
     characterSet = gameSet.characterDictionary[currentCharacterType];
     resetCurrentCharacterColorFromDropDown();
     reload_everything();
 }
        public static CharacterSet CharacterColorSetFromZipColorSetChar(Stream fileStream, CharacterConfig.CHARACTERS characterType)
        {
            CharacterSet cs = new CharacterSet(characterType);

            var zip = new ZipArchive(fileStream, ZipArchiveMode.Read);

            foreach (var entry in zip.Entries)
            {
                using (var stream = entry.Open())
                {
                    for (int i = 0; i < 10; i++)
                    {
                        var charCode = CharacterConfig.CodeFromCharacterEnum(characterType);
                        var fileName = charCode + @"/" + "0" + i.ToString() + ".col";
                        if (entry.FullName == fileName)
                        {
                            using (var textSubStream = new StreamReader(stream))
                            {
                                var colText = textSubStream.ReadToEnd();
                                cs.characterColors[i] = Character.CharacterFromColFormat(colText);
                            }
                        }
                    }
                }
            }
            return(cs);
        }
Beispiel #3
0
        private void colorSetToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            var fileContent = string.Empty;
            var filePath    = string.Empty;

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.Filter           = "zip files (*.zip)|*.zip|All files (*.*)|*.*";
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //Get the path of specified file
                    filePath = openFileDialog.FileName;
                    try
                    {
                        //Read the contents of the file into a stream
                        FileStream fileStream = (System.IO.FileStream)openFileDialog.OpenFile();
                        gameSet      = GameSet.GameSetFromZipColorSet(fileStream);
                        characterSet = gameSet.characterDictionary[currentCharacterType];
                        resetCurrentCharacterColorFromDropDown();
                        reload_everything();
                        fileStream.Close();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Invalid colorset format");
                    }
                }
            }
        }
Beispiel #4
0
 private void resetThisColorToolStripMenuItem_Click(object sender, EventArgs e)
 {
     gameSet.characterDictionary[currentCharacterType].characterColors[colorSelectorBox.SelectedIndex] =
         Character.CreateDefaultCharacter(currentCharacterType, (CharacterConfig.BUTTONS)colorSelectorBox.SelectedIndex);
     characterSet = gameSet.characterDictionary[currentCharacterType];
     resetCurrentCharacterColorFromDropDown();
     reload_everything();
 }
Beispiel #5
0
 private void ChangeIndexToCharacter(CharacterConfig.CHARACTERS character)
 {
     currentCharacterType = character;
     characterSet         = gameSet.characterDictionary[character];
     currentCharacter     = characterSet.characterColors[colorSelectorBox.SelectedIndex];
     closeZoomIfNotRelevant();
     reload_everything();
 }
        public static GameSet GameSetFromZipColorSet(Stream fileStream)
        {
            var gs = new GameSet();

            foreach (CharacterConfig.CHARACTERS character in supportedCharacters)
            {
                gs.characterDictionary[character] = CharacterSet.CharacterColorSetFromZipColorSetChar(fileStream, character);
            }
            return(gs);
        }
Beispiel #7
0
 private void resetColorsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     foreach (CharacterConfig.CHARACTERS character in supportedCharacters)
     {
         gameSet.characterDictionary[character] = new CharacterSet(character);
     }
     characterSet = gameSet.characterDictionary[currentCharacterType];
     resetCurrentCharacterColorFromDropDown();
     reload_everything();
 }
Beispiel #8
0
        public void CreateCharacterSet()
        {
            foreach (CharacterConfig.CHARACTERS character in supportedCharacters)
            {
                gameSet.characterDictionary[character] = new CharacterSet(character);
            }

            currentCharacterType = CharacterConfig.CHARACTERS.Dictator;
            characterSet         = gameSet.characterDictionary[CharacterConfig.CHARACTERS.Dictator];
        }
        public static CharacterSet CharacterColorSetFromZipStreamChar(Stream fileStream, CharacterConfig.CHARACTERS characterType)
        {
            CharacterSet cs = new CharacterSet(characterType);

            byte[] sprites   = new byte[cs.sprite_length];
            byte[] portraits = new byte[cs.portrait_length];

            var zip = new ZipArchive(fileStream, ZipArchiveMode.Read);

            foreach (var entry in zip.Entries)
            {
                using (var stream = entry.Open())
                {
                    if (entry.Name == "sfxe.03c" ||
                        entry.Name == "sfxjd.03c" ||
                        entry.Name == "sfxj.03c"
                        )
                    {
                        using (var memorySubStream = new MemoryStream())
                        {
                            stream.CopyTo(memorySubStream);
                            portraits = memorySubStream.ToArray();
                        }
                    }

                    if (entry.Name == "sfxe.04a" ||
                        entry.Name == "sfxjd.04a" ||
                        entry.Name == "sfxj.04a"
                        )
                    {
                        using (var memorySubStream = new MemoryStream())
                        {
                            stream.CopyTo(memorySubStream);
                            sprites = memorySubStream.ToArray();
                        }
                    }
                }
            }

            return(CharacterColorSetFromStreamsChar(sprites, portraits, characterType));
        }
Beispiel #10
0
        public static CharacterSet CharacterColorSetFromStreamsChar(byte[] sprites, byte[] portraits, CharacterConfig.CHARACTERS characterType)
        {
            CharacterSet cs = new CharacterSet(characterType);

            byte[] sprite_bytes   = new byte[cs.sprite_length];
            byte[] portrait_bytes = new byte[cs.portrait_length];
            int    blanka_offset  = 0;

            for (int i = 0; i < 10; i++)
            {
                if (characterType == CharacterConfig.CHARACTERS.Blanka && i == 9)
                {
                    blanka_offset = 0x02;
                }
                Array.Copy(sprites, cs.sprite_offset + i * cs.sprite_length + blanka_offset, sprite_bytes, 0, cs.sprite_length);
                Array.Copy(portraits, cs.portrait_offset + i * cs.portrait_length, portrait_bytes, 0, cs.portrait_length);
                cs.characterColors[i].sprite.LoadStream(sprite_bytes);
                cs.characterColors[i].portrait.LoadStream(portrait_bytes);
            }
            return(cs);
        }