コード例 #1
0
ファイル: AssetManager.cs プロジェクト: vgeirnaert/boardsoup
        public Asset loadAsset(AssetDetails argDetails, String argText, Point[] argPoints)
        {
            Asset a = null;

            // if an asset with this name already exists
            if (assets.ContainsKey(makeTextKey(argDetails, argText)))
            {
                assets.TryGetValue(makeTextKey(argDetails, argText), out a); // obtain it
            }
            else
            {   // if not, make it and add it
                switch (argDetails.type)
                {
                case AssetType.IMAGE:
                    a = makeImageAsset(argText);
                    break;

                case AssetType.SHAPE:
                    a = makeShapeAsset(argText, argPoints);
                    break;

                case AssetType.TEXT:
                    a = makeTextAsset(argText, argDetails);
                    break;
                }

                addAsset(a);
            }
            // return asset
            return(a);
        }
コード例 #2
0
ファイル: AssetManager.cs プロジェクト: vgeirnaert/boardsoup
        private String makeTextKey(AssetDetails argDetails, String argText)
        {
            if (argDetails is TextAssetDetails)
            {
                return(argText + ((TextAssetDetails)argDetails).fontSize + ((TextAssetDetails)argDetails).fontName + ((TextAssetDetails)argDetails).fontColor.ToString());
            }

            return(argText);
        }
コード例 #3
0
ファイル: AssetManager.cs プロジェクト: vgeirnaert/boardsoup
        private Asset makeTextAsset(String text, AssetDetails details)
        {
            if (details is TextAssetDetails)
            {
                TextAssetDetails tad = (TextAssetDetails)details;
                return(new TextAsset(text, tad.fontName, tad.fontSize, tad.fontColor));
            }

            return(new TextAsset(text));
        }