Пример #1
0
        public Main()
        {
            InitializeComponent();

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

            //Loading ProjectManager
            _ProjectManager = new Sm4shProject();

            //Loading configuration
            if (!File.Exists(UIConstants.CONFIG_FILE))
            {
                if (!CreateConfig())
                {
                    this.Close();
                    return;
                }
            }

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

            _MainLoaded = true;
        }
Пример #2
0
        public void Initialize(Sm4shProject sm4shProject)
        {
            //Init List
            _ListMyMusic.MaxItems = 200;
            _ListSoundDB.MaxItems = 40;

            listEntries.DataSource  = SoundEntryCollection.MyMusicStages;
            _ListSoundDB.DataSource = SoundEntryCollection.SoundEntries;
        }
Пример #3
0
 public override void OpenPluginMenu()
 {
     Sm4shProject.CleanTempFolder();
     if (LaunchForm())
     {
         SavePlugin();
     }
     Sm4shProject.CleanTempFolder();
 }
Пример #4
0
        public CreationProjectInfo(Sm4shMod config, Sm4shProject 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)");
        }
Пример #5
0
        public MyMusicFile(Sm4shProject projectManager, SoundEntryCollection sEntryCollection, string path)
        {
            string 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);
                    }
                }
            }
        }
Пример #6
0
        public void Initialize(Sm4shProject sm4shProject)
        {
            _Sm4shProject = sm4shProject;

            //Init sound files
            refreshBGMFilesListToolStripMenuItem_Click(this, new EventArgs());

            SoundEntryCollection sEntryCollectionOriginal = (SoundEntryCollection)_SoundEntryCollection.Clone();

            _BGMManagement.SoundEntryCollection           = _SoundEntryCollection;
            _BGMManagement.SoundEntryCollectionBackup     = sEntryCollectionOriginal;
            _MyMusicManagement.SoundEntryCollection       = _SoundEntryCollection;
            _MyMusicManagement.SoundEntryCollectionBackup = sEntryCollectionOriginal;
            _BGMManagement.Initialize(sm4shProject);
            _MyMusicManagement.Initialize(sm4shProject);
        }
Пример #7
0
        public PropertyFile(Sm4shProject projectManager, SoundEntryCollection sEntryCollection, string path)
        {
            string 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);
                        }
                    }
                }
            }
        }
Пример #8
0
        public void Initialize(Sm4shProject 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;
        }
Пример #9
0
 public Sm4shPlugin(Sm4shProject project)
     : base(project)
 {
     _ParamApplicationFile = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "tools" + Path.DirectorySeparatorChar + "PARAM.exe";
 }
Пример #10
0
        static void Main(string[] Args)
        {
            if (Args.Length == 0)
            {
                var handle = GetConsoleWindow();
                ShowWindow(handle, SW_HIDE);
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Main main = new Main(Args);
                if (main.MainLoaded)
                {
                    Application.Run(main);
                }
            }
            else
            {
                Sm4shProject _ProjectManager = new Sm4shProject();
                switch (Args[0])
                {
                case "help":
                case "--help":
                    Console.WriteLine("Possible arguments:");
                    Console.WriteLine("To setup configuration: \'gamedump [path/to/gameDump]\'");
                    Console.WriteLine("To build with packing: \'build\'");
                    break;

                case "gamedump":
                case "--gamedump":
                    if (Args.Length != 2)
                    {
                        Console.WriteLine("Expected arguments: \'gamedump [path/to/gameDump]\'");
                        return;
                    }

                    string gameFolder = Args[1];
                    if (gameFolder[gameFolder.Length - 1] != Path.DirectorySeparatorChar)
                    {
                        gameFolder += Path.DirectorySeparatorChar;
                    }

                    if (!PathHelper.IsItSmashFolder(gameFolder))
                    {
                        Console.WriteLine(UIStrings.ERROR_LOADING_GAME_FOLDER);
                        return;
                    }
                    if (!PathHelper.DoesItHavePatchFolder(gameFolder))
                    {
                        Console.WriteLine(UIStrings.ERROR_LOADING_GAME_PATCH_FOLDER);
                        return;
                    }

                    LogHelper.Info("Creating configuration file...");
                    Sm4shMod newProject = _ProjectManager.CreateNewProject(GlobalConstants.CONFIG_FILE, gameFolder);
                    Console.WriteLine(UIStrings.CREATE_PROJECT_SUCCESS);
                    break;

                case "build":
                case "--build":
                    if (!File.Exists(GlobalConstants.CONFIG_FILE))
                    {
                        Console.WriteLine("No configuration exists. Run \'sm4shexplorer.exe gamedump [path/to/gameDump]\'");
                        return;
                    }
                    _ProjectManager.LoadProject(GlobalConstants.CONFIG_FILE);
                    if (_ProjectManager.CurrentProject == null)
                    {
                        return;
                    }

                    Options _Options = new Options(_ProjectManager.CurrentProject);
                    _ProjectManager.RebuildRFAndPatchlist();
                    break;

                default:
                    Console.WriteLine("Unsupported argument. Supported arguments include: help, gamedump, build");
                    break;
                }
            }
        }
Пример #11
0
        public ReorderPlugins(Sm4shProject project)
        {
            InitializeComponent();

            _Project = project;
        }
Пример #12
0
 public Sm4shPlugin(Sm4shProject project)
     : base(project)
 {
 }
Пример #13
0
        public UISoundDBFile(Sm4shProject projectManager, SoundEntryCollection sEntryCollection, string path)
        {
            string 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);
                    }
                }
            }
        }
Пример #14
0
 /// <summary>
 /// Main constructor of the abstract class
 /// </summary>
 /// <param name="project"></param>
 public Sm4shBasePlugin(Sm4shProject project)
 {
     _Project = project;
 }
Пример #15
0
        public SoundMSBTFile(Sm4shProject projectManager, SoundEntryCollection sEntryCollection, string path)
        {
            _ResCol = projectManager.GetResourceCollection(path);
            string 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);
                }
            }
        }