Ejemplo n.º 1
0
 public static PersonaEncoding NewEncoding()
 {
     if (newEncoding == null)
     {
         newEncoding = new PersonaEncoding(Path.Combine(DirFont, NewFontName + ".fntmap"));
     }
     return(newEncoding);
 }
Ejemplo n.º 2
0
 public static PersonaEncoding OldEncoding()
 {
     if (oldEncoding == null)
     {
         oldEncoding = new PersonaEncoding(Path.Combine(DirFont, OldFontName + ".fntmap"));
     }
     return(oldEncoding);
 }
Ejemplo n.º 3
0
 public static void SavePTPFile(GameFile objectFile, string path, PersonaEncoding oldEncoding = null)
 {
     if (objectFile.GameData is BMD bmd)
     {
         PTP PTP = new PTP(bmd);
         if (oldEncoding != null)
         {
             PTP.CopyOld2New(oldEncoding);
         }
         File.WriteAllBytes(path, PTP.GetData());
     }
 }
 public PersonaEncoding GetPersonaEncoding(string name)
 {
     if (encodings.ContainsKey(name))
     {
         return(encodings[name]);
     }
     else
     {
         var enc = new PersonaEncoding(Path.Combine(sourcedir, name + ".fntmap"));
         encodings.Add(name, enc);
         return(enc);
     }
 }
Ejemplo n.º 5
0
        bool Save()
        {
            if (IsChanged)
            {
                var result = MessageBox.Show("Save changed?", "Save", MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Yes);

                if (result == MessageBoxResult.Yes)
                {
                    var enc = Static.EncodingManager.GetPersonaEncoding(Static.FontManager.GetPersonaFontName(_FontSelect));
                    if (enc.Tag == "Empty")
                    {
                        PersonaEncoding personaEncoding = new PersonaEncoding();
                        foreach (var a in GlyphList)
                        {
                            if (a.Char.Length > 0)
                            {
                                personaEncoding.Add(a.Index, a.Char[0]);
                            }
                        }

                        personaEncoding.SaveFNTMAP(Path.Combine(Static.FontManager.sourcedir, Static.FontManager.GetPersonaFontName(_FontSelect) + ".FNTMAP"));
                    }
                    else
                    {
                        foreach (var a in GlyphList)
                        {
                            if (a.Char.Length > 0)
                            {
                                enc.Add(a.Index, a.Char[0]);
                            }
                        }
                        enc.SaveFNTMAP(enc.FilePath);
                        Static.EncodingManager.Update(Static.FontManager.GetPersonaFontName(_FontSelect));
                    }
                }
                else if (result == MessageBoxResult.Cancel)
                {
                    return(false);
                }

                IsChanged = false;
                return(true);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 6
0
        public static void OpenPTPFile(GameFile objectFile, string path, PersonaEncoding newEncoding)
        {
            if (objectFile == null)
            {
                throw new System.ArgumentNullException(nameof(objectFile));
            }
            if (path == null)
            {
                throw new System.ArgumentNullException(nameof(path));
            }
            if (newEncoding == null)
            {
                return;
            }

            if (objectFile.GameData is BMD bmd)
            {
                if (File.Exists(path))
                {
                    PTP PTP = new PTP(File.ReadAllBytes(path));
                    objectFile.GameData = new BMD(PTP, newEncoding);
                }
            }
        }
Ejemplo n.º 7
0
        private void ContextMenu_SaveAs()
        {
            SaveFileDialog SFD = new SaveFileDialog();

            SFD.OverwritePrompt = true;
            SFD.AddExtension    = false;
            SFD.FileName        = PersonaFile.Name.Replace('/', '+');
            SFD.Filter          = $"RAW(*{Path.GetExtension(SFD.FileName)})|*{Path.GetExtension(SFD.FileName)}";

            if (PersonaFile.GameData is IImage)
            {
                SFD.Filter += $"|PNG (*.png)|*.png";
            }
            if (PersonaFile.GameData is ITable)
            {
                SFD.Filter += $"|XML data table (*.xml)|*.xml";
            }
            if (PersonaFile.GameData is BMD)
            {
                SFD.Filter += $"|Persona Text Project (*.ptp)|*.ptp";
            }
            if (PersonaFile.GameData is PTP)
            {
                SFD.Filter += $"|BMD Text File (*.bmd)|*.bmd";
            }

            SFD.InitialDirectory = Path.GetDirectoryName(Static.OpenedFile);
            if (SFD.ShowDialog() == true)
            {
                if (SFD.FilterIndex == 1)
                {
                    File.WriteAllBytes(SFD.FileName, PersonaFile.GameData.GetData());
                }
                else
                {
                    string ext = Path.GetExtension(SFD.FileName);
                    if (ext.Equals(".png", StringComparison.CurrentCultureIgnoreCase))
                    {
                        PersonaEditorCMD.PersonaEditorTools.SaveImageFile(PersonaFile, SFD.FileName);
                    }
                    else if (ext.Equals(".ptp", StringComparison.CurrentCultureIgnoreCase))
                    {
                        var result = ToolBox.Show(ToolBoxType.SaveAsPTP);
                        if (result == ToolBoxResult.Ok)
                        {
                            PersonaEncoding temp = ApplicationSettings.AppSetting.Default.SaveAsPTP_CO2N ? Static.EncodingManager.GetPersonaEncoding(ApplicationSettings.AppSetting.Default.SaveAsPTP_Font) : null;
                            PersonaEditorCMD.PersonaEditorTools.SavePTPFile(PersonaFile, SFD.FileName, temp);
                        }
                    }
                    else if (ext.Equals(".bmd", StringComparison.CurrentCultureIgnoreCase))
                    {
                        Encoding encoding = Static.EncodingManager.GetPersonaEncoding(ApplicationSettings.AppSetting.Default.PTPNewDefault);
                        BMD      bmd      = new BMD(PersonaFile.GameData as PTP, encoding);
                        File.WriteAllBytes(SFD.FileName, bmd.GetData());
                    }
                    else if (ext.Equals(".xml", StringComparison.CurrentCultureIgnoreCase))
                    {
                        PersonaEditorCMD.PersonaEditorTools.SaveTableFile(PersonaFile, SFD.FileName);
                    }
                    else
                    {
                        throw new Exception("SavePersonaFileDialog");
                    }
                }
            }
        }