예제 #1
0
 internal void SetCharsetProject(CharsetProject Charset)
 {
     m_Charset = Charset;
     CharsetWasImported();
 }
예제 #2
0
        private void btnImportCharset_Click(object sender, EventArgs e)
        {
            string filename;

            //Clear();
            if (OpenFile("Open charset", C64Studio.Types.Constants.FILEFILTER_CHARSET + C64Studio.Types.Constants.FILEFILTER_CHARSET_CHARPAD + C64Studio.Types.Constants.FILEFILTER_ALL, out filename))
            {
                if (System.IO.Path.GetExtension(filename).ToUpper() == ".CHARSETPROJECT")
                {
                    // a project
                    GR.Memory.ByteBuffer projectFile = GR.IO.File.ReadAllBytes(filename);

                    C64Studio.Formats.CharsetProject project = new C64Studio.Formats.CharsetProject();
                    if (!project.ReadFromBuffer(projectFile))
                    {
                        return;
                    }
                    m_Charset.BackgroundColor = project.BackgroundColor;
                    m_Charset.MultiColor1     = project.MultiColor1;
                    m_Charset.MultiColor2     = project.MultiColor2;
                    m_Charset.NumCharacters   = project.NumCharacters;
                    m_Charset.ShowGrid        = project.ShowGrid;

                    for (int i = 0; i < 256; ++i)
                    {
                        m_Charset.Characters[i].Color = project.Characters[i].Color;
                        m_Charset.Characters[i].Data  = new GR.Memory.ByteBuffer(project.Characters[i].Data);
                        m_Charset.Characters[i].Mode  = project.Characters[i].Mode;
                    }

                    editCharactersFrom.Text = m_Charset.NumCharacters.ToString();

                    characterEditor.CharsetUpdated(m_Charset);

                    Modified = true;
                    return;
                }
                else if (System.IO.Path.GetExtension(filename).ToUpper() == ".CTM")
                {
                    // a charpad project file
                    GR.Memory.ByteBuffer projectFile = GR.IO.File.ReadAllBytes(filename);

                    Formats.CharpadProject cpProject = new C64Studio.Formats.CharpadProject();
                    if (!cpProject.LoadFromFile(projectFile))
                    {
                        return;
                    }

                    m_Charset.BackgroundColor = cpProject.BackgroundColor;
                    m_Charset.MultiColor1     = cpProject.MultiColor1;
                    m_Charset.MultiColor2     = cpProject.MultiColor2;

                    m_Charset.NumCharacters = cpProject.NumChars;
                    if (m_Charset.NumCharacters > 256)
                    {
                        m_Charset.NumCharacters = 256;
                    }
                    for (int charIndex = 0; charIndex < m_Charset.NumCharacters; ++charIndex)
                    {
                        m_Charset.Characters[charIndex].Data  = cpProject.Characters[charIndex].Data;
                        m_Charset.Characters[charIndex].Color = cpProject.Characters[charIndex].Color;
                        m_Charset.Characters[charIndex].Mode  = cpProject.MultiColor ? Types.CharsetMode.MULTICOLOR : C64Studio.Types.CharsetMode.HIRES;
                    }

                    editCharactersFrom.Text = m_Charset.NumCharacters.ToString();
                    characterEditor.CharsetUpdated(m_Charset);
                    SetModified();
                    return;
                }
                // treat as binary .chr file
                GR.Memory.ByteBuffer charData = GR.IO.File.ReadAllBytes(filename);

                ImportFromData(charData);
            }
        }