public AutoMTBFix(List <Nus3BankFile> nus3Banks, SmashProjectManager project)
        {
            _Nus3Banks           = nus3Banks;
            _SmashProjectManager = project;

            _MTB = new MTB(Globals.PathHelper.FolderEditorMods + "data" + Path.DirectorySeparatorChar + "sound" + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "fightermodelbanktable.mtb");
        }
        public SlotModsList()
        {
            InitializeComponent();
            InitializeAudioComboBoxes();

            _SmashProjectManager = SmashProjectManager.instance;
        }
Exemple #3
0
        public Main()
        {
            InitializeComponent();

            //Version
            this.Text += " v." + GlobalConstants.VERSION;

            //Loading ProjectManager
            _ProjectManager = new SmashProjectManager();
            _ProjectManager.LoadConfig();

            //Loading configuration
            if (!File.Exists(_ProjectManager._Config.LastProject))
            {
                if (!CreateProject())
                {
                    this.Close();
                    return;
                }
            }
            LoadProject();

            //Console Redirection
            _ConsoleText     = new ConsoleRedirText(textConsole);
            _ConsoleProgress = new ConsoleRedirProgress(backgroundWorker);

            HelpBox.Initialize(_ProjectManager);
            Rendering.OpenTKSharedResources.InitializeSharedResources();

            _MainLoaded = true;
        }
Exemple #4
0
 public Sm4shMusic()
 {
     _SmashProjectManager = SmashProjectManager.instance;
     _BGMManagement       = _SmashProjectManager._BGMManagementPage;
     _MyMusicManagement   = _SmashProjectManager._MyMusicPage;
     Load();
 }
Exemple #5
0
        public ModsList(bool a_isActiveList, ModListType a_modListType)
        {
            InitializeComponent();

            _SmashProjectManager = SmashProjectManager.instance;
            _IsActiveList        = a_isActiveList;
            _ModListType         = a_modListType;
        }
Exemple #6
0
        public MyMusicFile(SmashProjectManager projectManager, SoundEntryCollection sEntryCollection, string path)
        {
            string mymusicFile;

            mymusicFile = PathHelper.FolderEditorMods + path;
            if (!File.Exists(mymusicFile))
            {
                mymusicFile = projectManager.ExtractResource(path, PathHelper.FolderTemp);
            }
            SoundEntryCollection = sEntryCollection;
            _Path = path;

            using (FileStream fileStream = File.Open(mymusicFile, FileMode.Open))
            {
                using (BinaryReader b = new BinaryReader(fileStream))
                {
                    if (new string(b.ReadChars(3)) != "MMB")
                    {
                        throw new Exception(string.Format("Can't load '{0}', the file is either compressed or its not a MMB file.", mymusicFile));
                    }

                    //Keep header
                    b.BaseStream.Position = 0;
                    _Header = b.ReadBytes(HEADER_LEN);

                    //Number of elements
                    b.BaseStream.Position = HEADER_LEN;
                    int nbrStages = b.ReadInt32();

                    //Offsets per element
                    int[] offsetsPerElement = new int[nbrStages];
                    for (int i = 0; i < nbrStages; i++)
                    {
                        offsetsPerElement[i] = b.ReadInt32();
                    }

                    //Stage offset
                    int stageStartOffset = HEADER_LEN + 0x4 + (nbrStages * 0x4) + 0x20; //0x20 = Magic Padding

                    for (int i = 0; i < nbrStages; i++)
                    {
                        MyMusicStage myMusicStage       = new MyMusicStage(i);
                        int          currentStageOffset = stageStartOffset + offsetsPerElement[i];

                        b.BaseStream.Position = currentStageOffset;
                        uint nbrBGMs = b.ReadUInt32();

                        currentStageOffset += 0x4;
                        for (int j = 0; j < nbrBGMs; j++)
                        {
                            b.BaseStream.Position = currentStageOffset + (j * 0x3c);
                            myMusicStage.BGMs.Add(ParseBGMEntry(b));
                        }
                        SoundEntryCollection.MyMusicStages.Add(myMusicStage);
                    }
                }
            }
        }
 public CharacterStringsMSBT(SmashProjectManager project, bool createNew = true)
 {
     if (createNew || !File.Exists(PathHelper.FolderEditorMods + "data/ui/message/melee.msbt"))
     {
         _SmashProjectManager = project;
         _SmashProjectManager.ExtractResource("data/ui/message/melee.msbt", PathHelper.FolderEditorMods, true);
     }
     msbt = new MSBT(PathHelper.FolderEditorMods + "data/ui/message/melee.msbt");
 }
Exemple #8
0
        public void Initialize(SmashProjectManager sm4shProject)
        {
            //Init List
            _ListMyMusic.MaxItems = 200;
            _ListSoundDB.MaxItems = 40;

            listEntries.DataSource  = SoundEntryCollection.MyMusicStages;
            _ListSoundDB.DataSource = SoundEntryCollection.SoundEntries;
        }
        public Preferences(SmashProjectManager project)
        {
            InitializeComponent();

            _Project = project;

            checkBoxDebug.Checked = _Project._Config.Debug;
            textBoxHexEditor.Text = _Project._Config.ProjectHexEditorFile;
        }
Exemple #10
0
 public CharacterDBParam(SmashProjectManager project, bool createNew = true)
 {
     Param = new PARAM();
     if (createNew || !File.Exists(PathHelper.FolderEditorMods + "data(us_en)/param/ui/ui_character_db.bin"))
     {
         _SmashProjectManager = project;
         _SmashProjectManager.ExtractResource("data(us_en)/param/ui/ui_character_db.bin", PathHelper.FolderEditorMods, true);
     }
     Param.LoadFile(PathHelper.FolderEditorMods + "data(us_en)/param/ui/ui_character_db.bin");
 }
Exemple #11
0
        public StageMods()
        {
            InitializeComponent();

            _SmashProjectManager = SmashProjectManager.instance;
            CreateDataGrids();

            Globals.EventManager.OnStageModSelectionChanged += StageModSelectionChanged;
            RefreshModsLists();
        }
        public BuildSettings(SmashProjectManager project)
        {
            InitializeComponent();

            _SmashProjectManager = project;

            string[] BuildSafetyStrings = { "Allow All", "No Known Crashing Metal Models", "Only Known Working Metal Models" };
            comboBoxCrashSafety.DataSource = BuildSafetyStrings;

            checkBoxWifiSafe.Checked          = _SmashProjectManager.CurrentProject.BuildIsWifiSafe;
            comboBoxCrashSafety.SelectedIndex = _SmashProjectManager.CurrentProject.BuildSafetySetting;
        }
Exemple #13
0
        public CreationProjectInfo(SmashMod config, SmashProjectManager project)
        {
            InitializeComponent();

            _Config  = config;
            _Project = project;

            ddpGameRegion.Items.Add("JPN (Zone 1)");
            ddpGameRegion.Items.Add("USA (Zone 2)");
            ddpGameRegion.Items.Add("??? (Zone 3)");
            ddpGameRegion.Items.Add("EUR (Zone 4)");
        }
        public Explorer()
        {
            _ProjectManager = SmashProjectManager.instance;

            InitializeComponent();

            treeView.ImageList = new ImageList();
            treeView.ImageList.Images.Add(UIConstants.ICON_FOLDER, Resources.icon_folder);
            treeView.ImageList.Images.Add(UIConstants.ICON_FILE, Resources.icon_file);
            treeView.ImageList.Images.Add(UIConstants.ICON_PACKED, Resources.icon_packed);

            RefreshTreeView();
        }
        public PropertyFile(SmashProjectManager projectManager, SoundEntryCollection sEntryCollection, string path)
        {
            string propertyFile;

            propertyFile = PathHelper.FolderEditorMods + path;
            if (!File.Exists(propertyFile))
            {
                propertyFile = projectManager.ExtractResource(path, PathHelper.FolderTemp);
            }
            SoundEntryCollection = sEntryCollection;
            _Path = path;

            using (FileStream fileStream = File.Open(propertyFile, FileMode.Open))
            {
                using (BinaryReader b = new BinaryReader(fileStream))
                {
                    if (new string(b.ReadChars(3)) != "MPB")
                    {
                        throw new Exception(string.Format("Can't load '{0}', the file is either compressed or its not a MPB file", propertyFile));
                    }

                    //Keep header
                    b.BaseStream.Position = 0;
                    _Header = b.ReadBytes(HEADER_LEN);

                    //Nbr BGM
                    b.BaseStream.Position = HEADER_LEN;
                    uint nbrBgm = b.ReadUInt32();

                    //Songtable
                    uint   songTableOffset = HEADER_LEN + 0x4 + (nbrBgm * 0x4);
                    uint[] songIds         = new uint[nbrBgm];
                    b.BaseStream.Position = HEADER_LEN + 0x4;
                    for (int i = 0; i < nbrBgm; i++)
                    {
                        songIds[i] = b.ReadUInt32();
                    }

                    //Parsing
                    for (int i = 0; i < nbrBgm; i++)
                    {
                        if (songIds[i] != 0xffffffff)
                        {
                            b.BaseStream.Position = songTableOffset + songIds[i];
                            BGMEntry sEntry = ParseProperty(b, i);
                            SoundEntryCollection.SoundEntriesBGMs.Add(sEntry);
                        }
                    }
                }
            }
        }
        public CharacterMods()
        {
            InitializeComponent();

            _SmashProjectManager = SmashProjectManager.instance;

            InitializeCharactersComboBox();
            CreateDataGrids();

            _IsInitialized = true;

            comboBoxCharacters_SelectedIndexChanged(this, null);
            Globals.EventManager.OnCharSlotModSelectionChanged    += CharSlotModSelectionChanged;
            Globals.EventManager.OnCharGeneralModSelectionChanged += CharGeneralModSelectionChanged;
        }
Exemple #17
0
        public void Initialize(SmashProjectManager sm4shProject)
        {
            RefreshBGMTextArea();

            _EnumSoundSource = (EnumEntity[])((IEnumerable <SoundSource>)Enum.GetValues(typeof(SoundSource))).Select(c => new EnumEntity()
            {
                Value = (int)c, Name = c.ToString()
            }).ToArray();
            ddlSoundSource.Items.Clear();
            ddlSoundSource.Items.AddRange(_EnumSoundSource);

            _EnumSoundMixType = (EnumEntity[])((IEnumerable <SoundMixType>)Enum.GetValues(typeof(SoundSource))).Select(c => new EnumEntity()
            {
                Value = (int)c, Name = c.ToString()
            }).ToArray();
            ddlSoundMixType.Items.Clear();
            ddlSoundMixType.Items.AddRange(_EnumSoundMixType);

            _EnumBackgroundBehavior = (EnumEntity[])((IEnumerable <SoundTestBackImageBehavior>)Enum.GetValues(typeof(SoundTestBackImageBehavior))).Select(c => new EnumEntity()
            {
                Value = (int)c, Name = c.ToString()
            }).ToArray();
            ddlBackRotationBehavior.Items.Clear();
            ddlBackRotationBehavior.Items.AddRange(_EnumBackgroundBehavior);

            _EnumIcons = (EnumEntity[])IconsDB.Icons.Select(c => new EnumEntity()
            {
                Value = (int)c.Key, Name = c.Value
            }).ToArray();
            ddlGroupStageCreation.Items.Clear();
            ddlGroupStageCreation.Items.Add(new EnumEntity()
            {
                Name = "NULL", Value = -1
            });
            ddlGroupStageCreation.Items.AddRange(_EnumIcons);
            ddlSoundIconID.Items.Clear();
            ddlSoundIconID.Items.Add(new EnumEntity()
            {
                Name = "NULL", Value = -1
            });
            ddlSoundIconID.Items.AddRange(_EnumIcons);

            listEntries.DataSource = SoundEntryCollection.SoundEntries;
        }
        public ModRow(SmashProjectManager a_smashProjectManager, bool a_isActiveList, ModsList.ModListType a_modListType)
        {
            InitializeComponent();

            _SmashProjectManager = a_smashProjectManager;
            _IsActiveList        = a_isActiveList;
            _ModListType         = a_modListType;
            switch (_ModListType)
            {
            case (ModsList.ModListType.CharacterSlots):
            case (ModsList.ModListType.CharacterGeneral):
                EventManager.OnCharSlotModSelectionChanged    += OnModSelectionChanged;
                EventManager.OnCharGeneralModSelectionChanged += OnModSelectionChanged; break;

            case (ModsList.ModListType.Stage):
                EventManager.OnStageModSelectionChanged += OnModSelectionChanged; break;

            case (ModsList.ModListType.General):
                EventManager.OnMiscModSelectionChanged += OnModSelectionChanged; break;
            }
        }
Exemple #19
0
        public ModImportCharacterSlot(SmashProjectManager a_smashProjectManager)
        {
            InitializeComponent();

            _SmashProjectManager = a_smashProjectManager;
        }
Exemple #20
0
        public SlotModProperties(string modPath, string charName, SmashProjectManager project)
        {
            InitializeComponent();
            ModPath              = modPath;
            CharName             = charName;
            _SmashProjectManager = project;
            DB.Fighter currentFighter = project._CharacterModsPage.CurrentFighter;
            PathKami    = ModPath + Path.DirectorySeparatorChar + "kamimod.xml";
            PathVoice   = ModPath + Path.DirectorySeparatorChar + "sound" + Path.DirectorySeparatorChar + "snd_vc_" + (string.IsNullOrEmpty(currentFighter.nameSoundPack) ? CharName : currentFighter.nameSoundPack) + "_cxx.nus3bank";
            PathSound   = ModPath + Path.DirectorySeparatorChar + "sound" + Path.DirectorySeparatorChar + "snd_se_" + (string.IsNullOrEmpty(currentFighter.nameSoundPack) ? CharName : currentFighter.nameSoundPack) + "_cxx.nus3bank";
            PathChr00   = ModPath + Path.DirectorySeparatorChar + "chr" + Path.DirectorySeparatorChar + "chr_00_" + CharName + "_XX.nut";
            PathChr11   = ModPath + Path.DirectorySeparatorChar + "chr" + Path.DirectorySeparatorChar + "chr_11_" + CharName + "_XX.nut";
            PathChr13   = ModPath + Path.DirectorySeparatorChar + "chr" + Path.DirectorySeparatorChar + "chr_13_" + CharName + "_XX.nut";
            PathStock90 = ModPath + Path.DirectorySeparatorChar + "chr" + Path.DirectorySeparatorChar + "stock_90_" + CharName + "_XX.nut";
            PathChrn11  = ModPath + Path.DirectorySeparatorChar + "chr" + Path.DirectorySeparatorChar + "chrn_11_" + CharName + "_XX.nut";

            XMLData = Utils.DeserializeXML <CharacterSlotModXML>(PathKami);
            if (XMLData == null)
            {
                return;
            }

            XMLData.isDirty = false;

            if (XMLData.BoxingRingText == null)
            {
                XMLData.BoxingRingText = String.Empty;
            }
            if (XMLData.CharacterName == null)
            {
                XMLData.CharacterName = String.Empty;
            }
            if (XMLData.DisplayName == null)
            {
                XMLData.DisplayName = String.Empty;
            }
            if (XMLData.Notes == null)
            {
                XMLData.Notes = String.Empty;
            }

            XMLData.chr_00   = File.Exists(PathChr00);
            XMLData.chr_11   = File.Exists(PathChr11);
            XMLData.chr_13   = File.Exists(PathChr13);
            XMLData.stock_90 = File.Exists(PathStock90);
            XMLData.chrn_11  = File.Exists(PathChrn11);
            XMLData.Voice    = File.Exists(PathVoice);
            XMLData.Sound    = File.Exists(PathSound);

            if (XMLData.chr_00)
            {
                pictureBox_chr00.BackgroundImage = FileTypes.NUT.BitmapFromPortraitNut(PathChr00);
                UpdatePictureBoxClickable(pictureBox_chr00);
            }
            if (XMLData.chr_11)
            {
                pictureBox_chr11.BackgroundImage = FileTypes.NUT.BitmapFromPortraitNut(PathChr11);
                UpdatePictureBoxClickable(pictureBox_chr11);
            }
            if (XMLData.chr_13)
            {
                pictureBox_chr13.BackgroundImage = FileTypes.NUT.BitmapFromPortraitNut(PathChr13);
                UpdatePictureBoxClickable(pictureBox_chr13);
            }
            if (XMLData.stock_90)
            {
                pictureBox_stock90.BackgroundImage = FileTypes.NUT.BitmapFromPortraitNut(PathStock90);
                UpdatePictureBoxClickable(pictureBox_stock90);
            }
            if (XMLData.chrn_11)
            {
                pictureBox_chrn11.BackgroundImage = FileTypes.NUT.BitmapFromPortraitNut(PathChrn11, true);
                UpdatePictureBoxClickable(pictureBox_chrn11);
            }

            textBoxDisplayName.Text       = XMLData.DisplayName;
            checkBoxUseCustomName.Checked = XMLData.UseCustomName;
            textBoxCustomName.Text        = XMLData.CharacterName;
            textBoxBoxingRing.Text        = XMLData.BoxingRingText.Replace("\n", "\r\n");
            textBoxCustomName.Enabled     = checkBoxUseCustomName.Checked;
            textBoxBoxingRing.Enabled     = checkBoxUseCustomName.Checked;

            bool hasModels = false;

            string[] nutFiles = new string[0];
            if (Directory.Exists(ModPath + Path.DirectorySeparatorChar + "model"))
            {
                if (Directory.Exists(ModPath + Path.DirectorySeparatorChar + "model" + Path.DirectorySeparatorChar + "body"))
                {
                    nutFiles = Directory.GetFiles(ModPath + Path.DirectorySeparatorChar + "model" + Path.DirectorySeparatorChar + "body", "*.nut", SearchOption.AllDirectories);
                }
                if (nutFiles.Length > 0)
                {
                    hasModels = true;
                }
                else
                {
                    nutFiles = Directory.GetFiles(ModPath + Path.DirectorySeparatorChar + "model", "*.nut", SearchOption.AllDirectories);
                    if (nutFiles.Length > 0)
                    {
                        hasModels = true;
                    }
                }
            }
            if (hasModels)
            {
                FileTypes.NUT nut = new FileTypes.NUT();
                nut.Read(nutFiles[0]);
                if (nut.Textures.Count > 0)
                {
                    XMLData.TextureID = (nut.Textures[0].HashId & 0x0000FF00) >> 8;
                }
                XMLData.Haslxx = Directory.Exists(ModPath + Path.DirectorySeparatorChar + "model" + Path.DirectorySeparatorChar + "lxx");
                List <string> modelparts = currentFighter.modelParts;
                if (modelparts != null)
                {
                    string modelsString = "";
                    for (int i = 0; i < modelparts.Count; ++i)
                    {
                        if (i != 0)
                        {
                            modelsString += ", ";
                        }
                        modelsString += modelparts[i] + " = " + (Directory.Exists(ModPath + Path.DirectorySeparatorChar + "model" + Path.DirectorySeparatorChar + modelparts[i]) ? "Yes" : "No");
                    }
                    if (currentFighter.lowPolySlots != DB.Fighter.LowPolySlots.None)
                    {
                        modelsString += ", lxx = " + (XMLData.Haslxx ? "Yes" : "No");
                    }
                    labelModels.Text = modelsString;
                }
            }
            else
            {
                labelModels.Text              = "Mod has no models";
                XMLData.TextureID             = -1;
                XMLData.MetalModel            = CharacterSlotModXML.MetalModelStatus.Works;
                comboBoxMetalModel.Enabled    = false;
                textBoxTextureID.Enabled      = false;
                buttonTextureIDChange.Enabled = false;
            }
            textBoxTextureID.Text = XMLData.TextureID.ToString();

            checkBoxWifiSafe.Checked      = XMLData.WifiSafe;
            comboBoxMetalModel.DataSource = new List <String> {
                "Unknown", "Works", "Errors", "Crashes"
            };
            comboBoxMetalModel.SelectedIndex = (int)XMLData.MetalModel;

            labelVoicePack.Text = XMLData.Voice ? "Yes" : "No";
            labelSoundPack.Text = XMLData.Sound ? "Yes" : "No";

            buttonExport_chr00.Enabled   = XMLData.chr_00;
            buttonExport_chr11.Enabled   = XMLData.chr_11;
            buttonExport_chr13.Enabled   = XMLData.chr_13;
            buttonExport_stock90.Enabled = XMLData.stock_90;
            buttonExport_chrn11.Enabled  = XMLData.chrn_11;
            buttonVoiceRemove.Enabled    = XMLData.Voice;
            buttonSoundRemove.Enabled    = XMLData.Sound;

            //TODO: Portraits

            textBoxNotes.Text = XMLData.Notes.Replace("\n", "\r\n");

            IsInitialized = true;
        }
        public SoundMSBTFile(SmashProjectManager projectManager, SoundEntryCollection sEntryCollection, string path)
        {
            _ResCol = projectManager.GetResourceCollection(path);
            string soundMSBTFile;

            soundMSBTFile = PathHelper.FolderEditorMods + path;
            if (!File.Exists(soundMSBTFile))
            {
                soundMSBTFile = projectManager.ExtractResource(path, PathHelper.FolderTemp);
            }
            SoundEntryCollection = sEntryCollection;
            _VarsMSBT            = new SortedDictionary <string, MSBTVariable>();
            _Path = path;

            using (FileStream fileStream = File.Open(soundMSBTFile, FileMode.Open))
            {
                using (BinaryReader b = new BinaryReader(fileStream))
                {
                    ParseFileHeader(b);
                    if (_Header.Label != "MsgStdBn")
                    {
                        throw new Exception(string.Format("Can't load '{0}', the file doesn't appear to be a MSBT file.", soundMSBTFile));
                    }

                    //Keep header
                    b.BaseStream.Position = 0;
                    uint offSetLBL1 = HEADER_LEN;

                    //Getting offset to ATR1
                    b.BaseStream.Position = offSetLBL1;
                    _SectionLBL1          = ParseSectionHeader(b);
                    if (_SectionLBL1.Label != "LBL1")
                    {
                        throw new Exception(string.Format("Error while reading '{0}', can't find LBL1 section.", soundMSBTFile));
                    }
                    uint offSetATR1 = offSetLBL1 + HEADER_LBL1 + _SectionLBL1.SectionSize;
                    while (offSetATR1 % 0x10 != 0)// || offSetATR1 == offSetLBL1 + HEADER_LBL1 + _SectionLBL1.SectionSize)
                    {
                        offSetATR1++;
                    }


                    //Getting offset to TXT2
                    b.BaseStream.Position = offSetATR1;
                    _SectionATR1          = ParseSectionHeader(b);
                    if (_SectionATR1.Label != "ATR1")
                    {
                        throw new Exception(string.Format("Error while reading '{0}', can't find ATR1 section.", soundMSBTFile));
                    }
                    b.BaseStream.Position = offSetATR1 + HEADER_ATR1;
                    _ATR1Bloc             = b.ReadBytes((int)_SectionATR1.SectionSize);
                    uint offSetTXT2 = offSetATR1 + HEADER_ATR1 + _SectionATR1.SectionSize;
                    while (offSetTXT2 % 0x10 != 0)// || offSetTXT2 == offSetATR1 + HEADER_ATR1 + _SectionATR1.SectionSize)
                    {
                        offSetTXT2++;
                    }

                    //Parsing TXT2
                    b.BaseStream.Position = offSetTXT2;
                    _SectionTXT2          = ParseSectionHeader(b);
                    if (_SectionTXT2.Label != "TXT2")
                    {
                        throw new Exception(string.Format("Error while reading '{0}', can't find TXT2 section.", soundMSBTFile));
                    }
                    b.BaseStream.Position += 8;
                    uint   txt2NbrEntries = ReadUInt32BigEndian(b);
                    uint[] offSetIntList  = new uint[txt2NbrEntries];
                    for (int i = 0; i < txt2NbrEntries; i++)
                    {
                        offSetIntList[i] = ReadUInt32BigEndian(b);
                    }

                    b.BaseStream.Position = offSetTXT2 + HEADER_TXT2;
                    byte[]   txt2Bloc      = b.ReadBytes((int)_SectionTXT2.SectionSize);
                    string[] msbtvariables = GetMSBTStringVariables(txt2Bloc, txt2NbrEntries, offSetIntList);

                    //Associate strings to variable names
                    b.BaseStream.Position = offSetLBL1 + HEADER_LBL1;
                    _SizeHashTable        = ReadUInt32BigEndian(b);
                    uint lbl1ChecksumSize = _SizeHashTable * 0x8;
                    uint nbrEntries       = 0;
                    for (int i = 0; i < _SizeHashTable; i++)
                    {
                        nbrEntries            += ReadUInt32BigEndian(b);
                        b.BaseStream.Position += 4;
                    }
                    if (msbtvariables.Length != nbrEntries)
                    {
                        throw new Exception(string.Format("Error while reading '{0}', the number of LBL1 entries doesn't match the number of TXT2 entries.", soundMSBTFile));
                    }

                    b.BaseStream.Position = offSetLBL1 + HEADER_LBL1 + 0x4 + lbl1ChecksumSize;
                    for (int i = 0; i < nbrEntries; i++)
                    {
                        string       variableName  = b.ReadString();
                        uint         variableIndex = ReadUInt32BigEndian(b);
                        MSBTVariable newVariable   = new MSBTVariable(variableName, msbtvariables[variableIndex]);
                        _VarsMSBT.Add(variableName, newVariable);
                    }
                }
            }

            //Assign SoundEntries variables
            if (!_ResCol.IsRegion)
            {
                foreach (SoundEntry sEntry in sEntryCollection.SoundEntries)
                {
                    sEntry.Title          = GetVariableValue(VAR_TITLE + sEntry.OriginalSoundLabel, Strings.DEFAULT_SENTRY_TITLE);
                    sEntry.SoundTestTitle = GetVariableValue(VAR_TITLE2 + sEntry.OriginalSoundLabel, Strings.DEFAULT_SENTRY_TITLE2);
                    sEntry.Description    = GetVariableValue(VAR_DESCRIPTION + sEntry.OriginalSoundLabel, string.Empty);
                    sEntry.Description2   = GetVariableValue(VAR_DESCRIPTION2 + sEntry.OriginalSoundLabel, string.Empty);
                    sEntry.Source         = GetVariableValue(VAR_SOURCE + sEntry.OriginalSoundLabel, string.Empty);
                }
            }
        }
 public static void Initialize(SmashProjectManager a_project)
 {
     _ProjectManager = a_project;
 }
        public void Start(SmashProjectManager project)
        {
            _SmashProjectManager = project;

            _SoundEntryCollection = new SoundEntryCollection();

            BGMFilesDB.InitializeBGMDB(_SmashProjectManager.CurrentProject.GameVersion, _SmashProjectManager.CurrentProject.IsSwitch);
            BGMStageDB.InitializeBGMMyMusicDB(_SmashProjectManager.CurrentProject.GameVersion, _SmashProjectManager.CurrentProject.IsSwitch);
            _PropertyFile = new PropertyFile(_SmashProjectManager, _SoundEntryCollection, "data/sound/config/bgm_property.mpb");
            _SoundEntryCollection.GenerateSoundEntriesBGMDictionary();
            _UISoundDBFile = new UISoundDBFile(_SmashProjectManager, _SoundEntryCollection, "data/param/ui/ui_sound_db.bin");
            _SoundEntryCollection.GenerateSoundEntriesDictionary();
            _MyMusicFile = new MyMusicFile(_SmashProjectManager, _SoundEntryCollection, "data/sound/config/bgm_mymusic.mmb");

            //Generation SoundMSBT dictionaries
            _SoundMSBTFiles = new List <SoundMSBTFile>();
            foreach (ResourceCollection resCol in _SmashProjectManager.ResourceDataCollection)
            {
                if (!resCol.CachedFilteredResources.ContainsKey("ui/message/sound.msbt"))
                {
                    continue;
                }
                SoundMSBTFile soundMSBTFile = new SoundMSBTFile(_SmashProjectManager, _SoundEntryCollection, resCol.PartitionName + "/ui/message/sound.msbt");
                _SoundMSBTFiles.Add(soundMSBTFile);
            }

            //Generate Dictionaries
            _SoundEntryCollection.GenerateStagesDictionaries();

            //Check stage sound integrity between MyMusic Stages and SoundDB Stages.
            //General rule: All BGMS present in MyMusic stages must be in SoundDB, the opposite isnt true.
            foreach (MyMusicStage myMusicStage in _SoundEntryCollection.MyMusicStages)
            {
                if (myMusicStage.BGMStage.BGMDBID != null)
                {
                    //From MyMusic
                    List <BGMEntry> bgmsMyMusic = new List <BGMEntry>();
                    foreach (MyMusicStageBGM myMusicStageBGM in myMusicStage.BGMs)
                    {
                        //if(myMusicStageBGM.unk4 == 0x0) //Filter songs
                        bgmsMyMusic.Add(myMusicStageBGM.BGMEntry);
                    }

                    //From SoundDB
                    List <BGMEntry> bgmsSoundDB = new List <BGMEntry>();
                    foreach (SoundDBStageSoundEntry sDBStageSoundEntry in _SoundEntryCollection.SoundDBStagesPerID[(int)myMusicStage.BGMStage.BGMDBID].SoundEntries)
                    {
                        if (sDBStageSoundEntry.SoundEntry == null)
                        {
                            LogHelper.Warning(string.Format("SOUNDID '{0}' have an issue with one of its associated stages.", sDBStageSoundEntry.SoundID));
                            continue;
                        }
                        foreach (SoundEntryBGM sEntryBGM in sDBStageSoundEntry.SoundEntry.BGMFiles)
                        {
                            bgmsSoundDB.Add(sEntryBGM.BGMEntry);
                        }
                    }
                    //HACK FOR KK
                    foreach (SoundEntry sEntry in _SoundEntryCollection.SoundEntries)
                    {
                        if (!sEntry.InSoundTest)
                        {
                            foreach (SoundEntryBGM sEntryBGM in sEntry.BGMFiles)
                            {
                                if (sEntryBGM.BGMEntry != null)
                                {
                                    bgmsSoundDB.Add(sEntryBGM.BGMEntry);
                                }
                            }
                        }
                    }

                    //Compare
                    foreach (BGMEntry sEntryBGM in bgmsMyMusic)
                    {
                        if (!bgmsSoundDB.Contains(sEntryBGM))
                        {
                            //throw new Exception(string.Format("Error sound integrity between MyMusic Stages and SoundDB Stages for stage '{0}': '{1}' was not present.", myMusicStage.BGMStage.Label, sEntryBGM.BGMTitle));
                            LogHelper.Error(string.Format("Error sound integrity between MyMusic Stages and SoundDB Stages for stage '{0}': '{1}' was not present.", myMusicStage.BGMStage.Label, sEntryBGM.BGMTitle));
                        }
                    }
                }
            }

            //Launch Form
            Initialize();
        }
        public UISoundDBFile(SmashProjectManager projectManager, SoundEntryCollection sEntryCollection, string path)
        {
            string uiSoundDBFile;

            uiSoundDBFile = PathHelper.FolderEditorMods + path;
            if (!File.Exists(uiSoundDBFile))
            {
                uiSoundDBFile = projectManager.ExtractResource(path, PathHelper.FolderTemp);
            }
            SoundEntryCollection = sEntryCollection;
            _Path    = path;
            _Project = projectManager;

            using (FileStream fileStream = File.Open(uiSoundDBFile, FileMode.Open))
            {
                using (BinaryReader b = new BinaryReader(fileStream))
                {
                    byte[] header = b.ReadBytes(2);
                    if (header[0] != 0xff || header[1] != 0xff)
                    {
                        throw new Exception(string.Format("Can't load '{0}', the file doesn't appear to be 'ui_sound_db.bin'.", uiSoundDBFile));
                    }

                    //Keep header
                    b.BaseStream.Position = 0;
                    _Header = b.ReadBytes(HEADER_LEN);

                    //Number of elements
                    b.BaseStream.Position = HEADER_LEN;
                    int nbrStages = ReadNbrEntries(b);

                    //Offset to second table
                    int offsetUnknownSecondTable = HEADER_LEN + 0x5 + (nbrStages * 0xd2);
                    b.BaseStream.Position = offsetUnknownSecondTable;
                    int nbrUnknownSecondTableBlocs = ReadNbrEntries(b);
                    b.BaseStream.Position = offsetUnknownSecondTable;
                    _SecondBloc           = b.ReadBytes((int)(0x5 + (nbrUnknownSecondTableBlocs * 0xa)));

                    //Offset to variable/songid table
                    int offsetSongTable = offsetUnknownSecondTable + 0x5 + (nbrUnknownSecondTableBlocs * 0xa);
                    b.BaseStream.Position = offsetSongTable;
                    int nbrSoundEntries = ReadNbrEntries(b);

                    //Retrieve all sounds
                    for (int i = 0; i < nbrSoundEntries; i++)
                    {
                        int        index  = ReadInt32(b);
                        SoundEntry sEntry = ParseSoundEntry(b, index);
                        if (sEntry != null && (INCLUDE_EMPTY_SOUND || sEntry.BGMFiles.Count == 0 || sEntry.BGMFiles[0].BGMID != 0x450))
                        {
                            SoundEntryCollection.SoundEntries.Add(sEntry);
                        }
                    }

                    //Retrieve info per stage
                    for (int i = 0; i < nbrStages; i++)
                    {
                        b.BaseStream.Position = HEADER_LEN + 0x5 + (i * 0xd2);
                        int stageId   = ReadInt32(b);
                        int nbrSounds = ReadInt32(b);

                        List <SoundDBStageSoundEntry> stageSoundEntries = new List <SoundDBStageSoundEntry>();
                        for (int j = 0; j < nbrSounds; j++)
                        {
                            int sEntryIndex = ReadInt32(b);
                            stageSoundEntries.Add(new SoundDBStageSoundEntry(SoundEntryCollection, sEntryIndex));
                        }
                        SoundDBStage soundDBStage = new SoundDBStage(SoundEntryCollection, stageId);
                        soundDBStage.SoundEntries = stageSoundEntries;
                        SoundEntryCollection.SoundDBStages.Add(soundDBStage);
                    }
                }
            }
        }