Esempio n. 1
0
    private bool FontInitialize()
    {           /* MEMO: Solve between the cell (used by each font) and texture. */
        if (null == InstanceRoot)
        {
            return(false);
        }

        /* Create "Material-Table" */
        /* MEMO: Add Texture "Appendix" to Texture (used by "InstanceRoot"). */
        int CountTexture = (int)KindTexture.TERMINATOR;

        Texture2D[] TableTexture         = new Texture2D[CountTexture];
        Material    DataMaterialOriginal = InstanceRoot.MaterialGet((int)KindTexture.INNER, Library_SpriteStudio.KindColorOperation.MIX);

        TableTexture[(int)KindTexture.INNER] = (null != DataMaterialOriginal) ? ((Texture2D)(DataMaterialOriginal.mainTexture)) : null;
        TableTexture[(int)KindTexture.OUTER] = OutsideSSPJFontTexture;

        InstanceRoot.TableMaterialChange(Library_SpriteStudio.Utility.TableMaterial.Create(TableTexture));

        /* Prepare a table for each font */
        /* MEMO: I'm coding without using "Library_SpriteStudio.Utility.TableCell"-function. */
        /*       (To provide a sample for full-scratch "Cell-Table".)                        */
        int CountFont      = (int)Constant.FONT_MAX;
        int CountCharacter = (int)KindCharacter.TERMINATOR;

        ListCellTableFont = new Library_SpriteStudio.Control.CellChange[CountFont][][];
        Library_SpriteStudio.Control.CellChange[][] InstanceCellTableCellMap;
        Library_SpriteStudio.Data.CellMap           DataCellMap;
        for (int i = 0; i < CountFont; i++)
        {
            /* Create "Cell-Table" for a font. */
            /* MEMO: Set length of array to "1" because original SSAE-data is using only 1 Cell-Map. */
            InstanceCellTableCellMap = new Library_SpriteStudio.Control.CellChange[1][];
            ListCellTableFont[i]     = InstanceCellTableCellMap;

            Library_SpriteStudio.Control.CellChange[] InstanceCellTable = new Library_SpriteStudio.Control.CellChange[CountCharacter];
            InstanceCellTableCellMap[0] = InstanceCellTable;

            /* Get Cell-Map (in Animation-Data) */
            int IndexTexture = IndexTextures[i];

            DataCellMap = null; /* Value "Error" */
            if ((int)Constant.FONT_INSIDEPROJECT_MAX > i)
            {                   /* Default(inside Animation-Data) Cell-Map */
                if (null != InstanceRoot.DataCellMap)
                {
                    DataCellMap = InstanceRoot.DataCellMap.DataGetCellMap(0);
                }
            }
            else
            {                   /* Appendix(Outside Animation-Data) Cell-Map */
                if (null != OutsideSSPJFontCellMap)
                {
                    DataCellMap = OutsideSSPJFontCellMap.DataGetCellMap(0);
                }
            }

            /* Set Cell-Data (for the number of characters which is being used) */
            if (null != DataCellMap)
            {
                int IndexCell;
                Library_SpriteStudio.Data.Cell DataCell;
                for (int j = 0; j < CountCharacter; j++)
                {
                    /* Get original Cell-Data */
                    IndexCell = DataCellMap.IndexGetCell(NameCells[i][j]);
                    if (0 <= IndexCell)
                    {                           /* Valid */
                        DataCell = DataCellMap.DataGetCell(IndexCell);
                    }
                    else
                    {                           /* Not Found */
                        DataCell = null;
                    }

                    /* Set Cell-Data */
                    if (null != DataCell)
                    {                           /* Valid */
                        InstanceCellTable[j].DataSet(IndexTexture, DataCellMap, DataCell);
                    }
                    else
                    {                           /* Invalid */
                        InstanceCellTable[j].CleanUp();
                    }
                }
            }
            else
            {                   /* Error (Cell-Map is not Found) */
                for (int j = 0; j < CountCharacter; j++)
                {
                    /* Set "Invalid" to Cell */
                    InstanceCellTable[j].CleanUp();
                }
            }
        }

        return(true);
    }