/* ******************************************************** */
            //! Create "Cell-Map Change"-Table (1 Cell-Map)

            /*!
             * @param	InstanceCellMap
             *      Original "Cell-Map"
             * @param	IndexTexture
             *      Index of Texture (in the Material-Table)
             * @retval	Return-Value
             *      Created "Cell-Map Change"-Table (1 Cell-Map)<br>
             *      null == Failure
             *
             * Create the "Cell-Map Change"-Table on the basis of the original "Cell-Map" information.<br>
             * Caution: The result is referencing data in original "Cell-Map".
             */
            public static Library_SpriteStudio.Control.CellChange[] CellMapCreate(Library_SpriteStudio.Data.CellMap InstanceCellMap, int IndexTexture)
            {
                Library_SpriteStudio.Control.CellChange[] Rv = null;
                if (null != InstanceCellMap)
                {
                    Library_SpriteStudio.Data.Cell DataCell = null;
                    if (null != InstanceCellMap.ListCell)
                    {
                        int Count = InstanceCellMap.ListCell.Length;
                        Rv = new Library_SpriteStudio.Control.CellChange[Count];
                        if (null != Rv)
                        {
                            for (int i = 0; i < Count; i++)
                            {
                                DataCell = InstanceCellMap.ListCell[i];
                                if (null == DataCell)
                                {                                       /* Invalid */
                                    Rv[i].CleanUp();
                                }
                                else
                                {
                                    Rv[i].DataSet(IndexTexture, InstanceCellMap, DataCell);
                                }
                            }
                        }
                    }
                    else
                    {                           /* Has no Cells */
                        Rv = new Library_SpriteStudio.Control.CellChange[0];
                    }
                }
                return(Rv);
            }
            /* ******************************************************** */
            //! Copy "Cell-Map Change"-Table

            /*!
             * @param	ListCellMap
             *      Original "Cell-Map"s
             * @retval	Return-Value
             *      Created "Cell-Map Change"-Table<br>
             *      null == Failure
             *
             * Create the "Cell-Map Change"-Table on the basis of the original "Cell-Map" information of the animation data.<br>
             * Caution: The result is referencing data in original "Cell-Map"s. (but "Cell" data is another instance)
             */
            public static Library_SpriteStudio.Control.CellChange[][] Copy(Library_SpriteStudio.Data.CellMap[] ListCellMap)
            {
                Library_SpriteStudio.Control.CellChange[][] Rv = null;
                if (null != ListCellMap)
                {
                    int Count = ListCellMap.Length;
                    Rv = new Library_SpriteStudio.Control.CellChange[Count][];
                    if (null != Rv)
                    {
                        Library_SpriteStudio.Data.CellMap CellMapNew = null;
                        if (null != CellMapNew)
                        {
                            for (int i = 0; i < Count; i++)
                            {
                                CellMapNew = new Library_SpriteStudio.Data.CellMap();
                                CellMapNew.Duplicate(ListCellMap[i]);
                                Rv[i] = CellMapCopy(CellMapNew, i);

                                CellMapNew.ListCell = null;                                     /* Dis-Use */
                            }
                        }
                    }
                }
                return(Rv);
            }
            /* ******************************************************** */
            //! Get Cell's data

            /*!
             * @param	Output
             *      Result storage destination
             * @param	InstanceTableCellChange
             *      "Cell-Map Change"-Table
             * @param	IndexCellMap
             *      Index of "Cell-Map"
             * @param	IndexCell
             *      Index of Cell in "Cell-Map"
             * @retval	Return-Value
             *      true == "Output" is valid<br>
             *      false == "Output" is invalid
             *
             * Get cell's data in "Cell-Map Change"-Table.
             */
            public static bool CellGet(ref Library_SpriteStudio.Control.CellChange Output,
                                       Library_SpriteStudio.Control.CellChange[][] InstanceTableCellChange,
                                       int IndexCellMap,
                                       int IndexCell
                                       )
            {
                if (false == TableCheckValidIndex(InstanceTableCellChange, IndexCellMap, IndexCell))
                {
                    return(false);
                }

                Output = InstanceTableCellChange[IndexCellMap][IndexCell];
                return(true);
            }
            /* ******************************************************** */
            //! Create "Cell-Map Change"-Table

            /*!
             * @param	ListCellMap
             *      Original "Cell-Map"s
             * @retval	Return-Value
             *      Created "Cell-Map Change"-Table<br>
             *      null == Failure
             *
             * Create the "Cell-Map Change"-Table on the basis of the original "Cell-Map" information.<br>
             * Caution: The result is referencing data in original "Cell-Map"s.
             */
            public static Library_SpriteStudio.Control.CellChange[][] Create(Library_SpriteStudio.Data.CellMap[] ListCellMap)
            {
                Library_SpriteStudio.Control.CellChange[][] Rv = null;
                if (null != ListCellMap)
                {
                    int Count = ListCellMap.Length;
                    Rv = new Library_SpriteStudio.Control.CellChange[Count][];
                    if (null != Rv)
                    {
                        for (int i = 0; i < Count; i++)
                        {
                            Rv[i] = CellMapCreate(ListCellMap[i], i);
                        }
                    }
                }
                return(Rv);
            }
            /* ******************************************************** */
            //! Full-Copy "Cell-Map Change"-Table (1 Cell-Map)

            /*!
             * @param	InstanceCellMap
             *      Original "Cell-Map"
             * @param	IndexTexture
             *      Index of Texture (in the Material-Table)
             * @retval	Return-Value
             *      Created "Cell-Map Change"-Table (1 Cell-Map)<br>
             *      null == Failure
             *
             * Create the "Cell-Map Change"-Table on the basis of the original "Cell-Map" information.<br>
             * Caution: The result is another instance from original "Cell-Map"s.
             */
            public static Library_SpriteStudio.Control.CellChange[] CellMapCopyFull(Library_SpriteStudio.Data.CellMap InstanceCellMap, int IndexTexture)
            {
                Library_SpriteStudio.Control.CellChange[] Rv = null;
                if (null != InstanceCellMap)
                {
                    Library_SpriteStudio.Data.Cell DataCell = null;
                    if (null != InstanceCellMap.ListCell)
                    {
                        Library_SpriteStudio.Data.CellMap DataCellMapNew = null;
                        Library_SpriteStudio.Data.Cell    DataCellNew    = null;
                        int Count = InstanceCellMap.ListCell.Length;
                        Rv = new Library_SpriteStudio.Control.CellChange[Count];
                        if (null != Rv)
                        {
                            for (int i = 0; i < Count; i++)
                            {
                                DataCell = InstanceCellMap.ListCell[i];
                                if (null == DataCell)
                                {                                       /* Invalid */
                                    Rv[i].CleanUp();
                                }
                                else
                                {
                                    DataCellMapNew = new Library_SpriteStudio.Data.CellMap();
                                    DataCellMapNew.Duplicate(InstanceCellMap);
                                    DataCellMapNew.ListCell = null;                                     /* Dis-Use */

                                    DataCellNew = new Library_SpriteStudio.Data.Cell();
                                    DataCellNew.Duplicate(DataCell);

                                    Rv[i].DataSet(IndexTexture, DataCellMapNew, DataCellNew);
                                }
                            }
                        }
                    }
                    else
                    {                           /* Has no Cells */
                        Rv = new Library_SpriteStudio.Control.CellChange[0];
                    }
                }
                return(Rv);
            }
Beispiel #6
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);
    }