示例#1
0
        public static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                ShowHelp("Not Enough Arguments!");
                return;
            }

            bool   useSmallSig  = false;
            bool   useBigEndian = false;
            string filePath     = "";

            for (int i = 0; i < args.Length; ++i)
            {
                if (args[i].StartsWith("-") && args[i].Length > 1)
                {
                    switch (args[i][1])
                    {
                    case 's':     // Use smallSigs
                        useSmallSig = true;
                        break;

                    case 'e':     // Use Big Endian
                        useBigEndian = true;
                        break;

                    default:
                        break;
                    }
                    continue;
                }
                else
                {
                    filePath = args[i];
                }
            }
            if (!string.IsNullOrEmpty(filePath))
            {
                using (var arc = new PCKFile {
                    UseSmallSig = useSmallSig, UseBigEndian = useBigEndian
                })
                {
                    var attr = File.GetAttributes(filePath);
                    if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                    {
                        arc.AddAllFiles(filePath);
                        arc.Save(filePath + ".pck");
                    }
                    else
                    {
                        arc.Load(filePath, true);
                        arc.ExtractAllFiles(Path.GetFileNameWithoutExtension(filePath));
                    }
                }
            }
            else
            {
                ShowHelp("No Path was Given!");
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Load Config from Registry
            _config.LoadConfig();

            // If path is not set at startup, try find the file from the game
            if (string.IsNullOrEmpty(App.ScriptPath))
            {
                App.ScriptPath = GetPathFromSteam();
            }

            // Load the database file if the script was found for DAL RR
            if (!string.IsNullOrEmpty(App.ScriptPath) && App.WorkingGame == Game.DateALiveRioReincarnation)
            {
                // Path to the database.bin file
                string scriptDB = Path.Combine(Path.GetDirectoryName(App.ScriptPath), "database.bin");
                // Check if the database exists
                if (File.Exists(scriptDB))
                {
                    ScriptDB = new STSCFileDatabase();
                    ScriptDB.Load(scriptDB);
                }
                else
                {
                    MessageBox.Show("Could not find database.bin!\n" +
                                    "Voice IDs will be used instead of character names without the database.bin file");
                }
            }
            // Load Script Archive
            ScriptArchive = new PCKFile();
            if (!string.IsNullOrEmpty(App.ScriptPath))
            {
                ScriptArchive.Load(App.ScriptPath, true);
                // Load all the files into memory instead of streaming them
                ScriptArchive.Preload();

                // Load replacement table
                string replacementTablePath = Path.Combine(Path.GetDirectoryName(App.ScriptPath), "replace.ini");
                if (File.Exists(replacementTablePath))
                {
                    App.StringProcess.Load(File.ReadAllText(replacementTablePath, Encoding.UTF8));
                }

                // Load script from config or use default
                string fileName = string.IsNullOrEmpty(_config.LastOpenedScript) && ScriptArchive.FileEntries.Any(t =>
                                                                                                                  t.FileName.ToLowerInvariant() == _config.LastOpenedScript.ToLowerInvariant())
                    ? _config.LastOpenedScript : ScriptArchive.FileEntries.First().FileName;
                LoadScript(fileName);
            }
            DataContext = null;
            DataContext = this;
            var dispatcherTimer = new DispatcherTimer();

            dispatcherTimer.Tick    += PreviewTimer_Tick;
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            dispatcherTimer.Start();
        }
 public PropertyEditorCharacter(CharacterEntry entry, PCKFile archive)
 {
     InitializeComponent();
     Character = new CharacterEntry()
     {
         FriendlyName = entry.FriendlyName, ID = entry.ID
     };
     OldCharacter = entry;
     _archive     = archive;
     DataContext  = this;
 }
 public PropertyEditorMovie(MovieEntry entry, Game game, PCKFile archive)
 {
     InitializeComponent();
     Movie = new MovieEntry()
     {
         FriendlyName = entry.FriendlyName, ID = entry.ID, FilePath = entry.FilePath, Unknown4 = entry.Unknown4, GameID = entry.GameID, Unknown5 = entry.Unknown5
     };
     OldMovie    = entry;
     _game       = game;
     _archive    = archive;
     DataContext = this;
 }
示例#5
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Load Config from Registry
            _config.LoadConfig();

            // If path is not set at startup, try find the file from the game
            if (string.IsNullOrEmpty(App.ScriptPath))
            {
                App.ScriptPath = GetPathFromSteam();
            }

            // Load the database file if the script was found
            if (!string.IsNullOrEmpty(App.ScriptPath))
            {
                // Path to the database.bin file
                string scriptDB = Path.Combine(Path.GetDirectoryName(App.ScriptPath), "database.bin");
                // Check if the database exists
                if (File.Exists(scriptDB))
                {
                    ScriptDB = new STSCFileDatabase();
                    ScriptDB.Load(scriptDB);
                }
                else
                {
                    MessageBox.Show("Could not find database.bin!\n" +
                                    "Voice IDs will be used instead of character names without the database.bin file");
                }
            }
            // Load Script Archive
            ScriptArchive = new PCKFile();
            if (!string.IsNullOrEmpty(App.ScriptPath))
            {
                ScriptArchive.Load(App.ScriptPath, true);
                // Load all the files into memory instead of streaming them
                ScriptArchive.Preload();
                // Load script from config or use default
                LoadScript(string.IsNullOrEmpty(_config.LastOpenedScript) ?
                           ScriptArchive.FileEntries.First().FileName : _config.LastOpenedScript);
            }
            DataContext = null;
            DataContext = this;
            var dispatcherTimer = new DispatcherTimer();

            dispatcherTimer.Tick    += PreviewTimer_Tick;
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            dispatcherTimer.Start();
        }
示例#6
0
 public PropertyEditorArtBook(ArtBookPageEntry entry, PCKFile thumbnailPCK, PCKFile dataPCK)
 {
     InitializeComponent();
     ArtBookPage = new ArtBookPageEntry()
     {
         PagePathThumbnail = entry.PagePathThumbnail,
         PagePathData      = entry.PagePathData,
         Name   = entry.Name,
         ID     = entry.ID,
         GameID = entry.GameID,
         Page   = entry.Page
     };
     OldArtBookPage   = entry;
     ThumbnailArchive = thumbnailPCK;
     DataArchive      = dataPCK;
     DataContext      = this;
 }
示例#7
0
        public void LoadFontPCK(string path)
        {
            FilePath       = path;
            PCKFontArchive = new PCKFile();
            PCKFontArchive.Load(path);

            var textureFilePath  = PCKFontArchive.SearchForFile(".tex");
            var fontCodeFilePath = PCKFontArchive.SearchForFile(".code");

            FontImageTexFile           = new TEXFile();
            FontCodeFile               = new FontFile();
            FontCodeFile.MonospaceOnly = MonospaceOnly;

            // Load Font Code
            if (fontCodeFilePath != null)
            {
                FontCodeFile.Load(PCKFontArchive.GetFileStream(fontCodeFilePath));
            }
            else
            {
                MessageBox.Show("Failed to load Code File!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            if (textureFilePath != null)
            {
                // Load Texture
                FontImageTexFile.Load(PCKFontArchive.GetFileStream(textureFilePath));
                // Set Texture
                UI_FontImage.Source = ImageTools.ConvertToSource(FontImageTexFile.CreateBitmap());
            }
            else
            {
                MessageBox.Show("Failed to load Texture!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            LastIndex  = -1;
            HoverIndex = -1;

            // Reload
            ReloadUI();

            UI_SaveButton.IsEnabled = true;
        }
        private void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            var ofd = new OpenFileDialog
            {
                Filter = "DATE A LIVE Archives (*.pck)|*.pck"
            };

            if (ofd.ShowDialog() == true)
            {
                // Load the database file if the script was found
                if (!string.IsNullOrEmpty(ofd.FileName))
                {
                    // Path to the database.bin file
                    string scriptDB = Path.Combine(Path.GetDirectoryName(ofd.FileName), "database.bin");
                    // Check if the database exists
                    if (File.Exists(scriptDB))
                    {
                        ScriptDB = new STSCFileDatabase();
                        ScriptDB.Load(scriptDB);
                    }
                    else
                    {
                        MessageBox.Show("Could not find database.bin!\n" +
                                        "Voice IDs will be used instead of character names without the database.bin file");
                    }
                }
                // Load Script Archive
                ScriptArchive = new PCKFile();
                ScriptArchive.Load(App.ScriptPath = ofd.FileName, true);
                // Load all the files into memory instead of streaming them
                ScriptArchive.Preload();
                // Load script from config or use default
                LoadScript(string.IsNullOrEmpty(_config.LastOpenedScript) ?
                           ScriptArchive.FileEntries.First().FileName : _config.LastOpenedScript);
                // Reset all the bindings
                DataContext = null;
                DataContext = this;
            }
        }
 public PCKFileSelectorWindow(PCKFile pck)
 {
     InitializeComponent();
     Archive = pck;
     UpdateList();
 }
示例#10
0
        // TODO: Needs Rewriting
        private void CG_ExportImage_Click(object sender, RoutedEventArgs e)
        {
            // Show error if DAL: RR is not installed as its needed to export
            if (!_game.EnableResourceLoading)
            {
                MessageBox.Show("Resource loading is currently disabled. Make sure DAL: RR is installed correctly", "Resource Loading Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (CG_ListView.SelectedIndex == -1)
            {
                return; // Return if no item is selected
            }
            int id   = (CG_ListView.SelectedItem as STSCFileDatabase.CGEntry).CGID;
            var game = (CG_ListView.SelectedItem as STSCFileDatabase.CGEntry).GameID;

            var sfd = new SaveFileDialog();

            sfd.FileName = $"{id}.png";
            sfd.Filter   = "Portable Network Graphics (*.png)|*.png";
            if (sfd.ShowDialog(this) == true)
            {
                try
                {
                    string filepath = Path.Combine(_game.GamePath, $"Data\\Data\\Ma\\{Consts.GAMEDIRNAME[(int)game]}\\MA{id:D6}.pck");

                    var pck = new PCKFile();
                    var ma  = new MAFile();
                    pck.Load(filepath, true);
                    using (var stream = new MemoryStream(pck.GetFileData(0)))
                        ma.Load(stream);

                    int width  = (int)(ma.Layers[0].Verts[3].DestinX * ma.Layers[0].LayerWidth);
                    int height = (int)(ma.Layers[0].Verts[3].DestinY * ma.Layers[0].LayerHeight);

                    if (ma.Layers[0].Verts[3].DestinX == ma.Layers[0].LayerWidth)
                    {
                        width  = (int)ma.Layers[0].LayerWidth;
                        height = (int)ma.Layers[0].LayerHeight;
                    }

                    var bytes = new byte[width * height * 4];
                    for (int i = 0; i < ma.Layers.Count; ++i)
                    {
                        var layer = ma.Layers[i];
                        var tex   = new TEXFile();
                        using (var stream = new MemoryStream(pck.GetFileData(layer.TextureID + 1)))
                            tex.Load(stream);
                        int sx = (int)(layer.Verts[0].SourceX * ma.Layers[i].LayerWidth);
                        int dx = (int)(layer.Verts[0].DestinX * ma.Layers[i].LayerWidth + layer.LayerOffX);
                        int sy = (int)(layer.Verts[0].SourceY * ma.Layers[i].LayerHeight);
                        int dy = (int)(layer.Verts[0].DestinY * ma.Layers[i].LayerHeight + layer.LayerOffY);
                        int sw = (int)(layer.Verts[3].SourceX * ma.Layers[i].LayerWidth);
                        int sh = (int)(layer.Verts[3].SourceY * ma.Layers[i].LayerHeight);

                        for (int y = 0; y < (sh - sy); ++y)
                        {
                            for (int x = 0; x < (sw - sx); ++x)
                            {
                                if ((y + sy) >= tex.SheetHeight || (x + sx) >= tex.SheetWidth)
                                {
                                    break;
                                }
                                int index = ((y + sy) * tex.SheetWidth + (x + sx)) * 4;
                                if (tex.SheetData[index + 3] != 255)
                                {
                                    continue;
                                }
                                bytes[((y + dy) * width + x + dx) * 4 + 3] = tex.SheetData[index + 3];
                                bytes[((y + dy) * width + x + dx) * 4 + 0] = tex.SheetData[index + 0];
                                bytes[((y + dy) * width + x + dx) * 4 + 1] = tex.SheetData[index + 1];
                                bytes[((y + dy) * width + x + dx) * 4 + 2] = tex.SheetData[index + 2];
                            }
                        }
                        DALLib.Imaging.ImageTools.SaveImage(Path.Combine(Path.GetDirectoryName(sfd.FileName), Path.GetFileNameWithoutExtension(sfd.FileName) + $"_{i}.png"), width, height, bytes);
                    }
                    pck.Dispose();
                }
                catch (Exception ex)
                {
                    new ExceptionWindow(ex, "Failed to export CG frames").ShowDialog();
                }
            }
        }