OSDN Git Service

#36043 rev.920 で手違いが起きたため、一度 rev.919 に戻し、ファイルを再修正。Ech定義の使用を CChip のプロパティを使うよう一部変更。
[dtxmania/dtxmania.git] / DTXManiaプロジェクト / コード / ステージ / CActLVLNFont.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.Text;\r
4 using System.Runtime.InteropServices;\r
5 using System.Drawing;\r
6 using System.Diagnostics;\r
7 using SlimDX;\r
8 using FDK;\r
9 \r
10 namespace DTXMania\r
11 {\r
12         public class CActLVLNFont : CActivity\r
13         {\r
14                 // コンストラクタ\r
15 \r
16                 const int numWidth = 15;\r
17                 const int numHeight = 19;\r
18 \r
19                 public CActLVLNFont()\r
20                 {\r
21                         string numChars = "0123456789?-";\r
22                         st数字 = new ST数字[12, 4];\r
23 \r
24                         for (int j = 0; j < 4; j++)\r
25                         {\r
26                                 for (int i = 0; i < 12; i++)\r
27                                 {\r
28                                         this.st数字[i, j].ch = numChars[i];\r
29                                         this.st数字[i, j].rc = new Rectangle(\r
30                                                                                                 (i % 4) * numWidth + (j % 2) * 64,\r
31                                                                                                 (i / 4) * numHeight + (j / 2) * 64,\r
32                                                                                                 numWidth,\r
33                                                                                                 numHeight\r
34                                         );\r
35                                 }\r
36                         }\r
37                 }\r
38 \r
39 \r
40                 // メソッド\r
41                 public void t文字列描画(int x, int y, string str)\r
42                 {\r
43                         this.t文字列描画(x, y, str, EFontColor.White, EFontAlign.Right);\r
44                 }\r
45                 public void t文字列描画(int x, int y, string str, EFontColor efc, EFontAlign efa)\r
46                 {\r
47                         if (!base.b活性化してない && !string.IsNullOrEmpty(str))\r
48                         {\r
49                                 if (this.tx数値 != null)\r
50                                 {\r
51                                         bool bRightAlign = (efa == EFontAlign.Right);\r
52 \r
53                                         if (bRightAlign)                                                        // 右詰なら文字列反転して右から描画\r
54                                         {\r
55                                                 char[] chars = str.ToCharArray();\r
56                                                 Array.Reverse(chars);\r
57                                                 str = new string(chars);\r
58                                         }\r
59 \r
60                                         foreach (char ch in str)\r
61                                         {\r
62                                                 int p = (ch == '-' ? 11 : ch - '0');\r
63                                                 ST数字 s = st数字[p, (int)efc];\r
64                                                 int sw = s.rc.Width;\r
65                                                 int delta = bRightAlign ? 0 : -sw;\r
66                                                 this.tx数値.t2D描画(CDTXMania.Instance.Device, x + delta, y, s.rc);\r
67                                                 x += bRightAlign ? -sw : sw;\r
68                                         }\r
69                                 }\r
70                         }\r
71                 }\r
72 \r
73 \r
74                 // CActivity 実装\r
75 \r
76                 public override void OnManagedリソースの作成()\r
77                 {\r
78                         if (!base.b活性化してない)\r
79                         {\r
80                                 this.tx数値 = TextureFactory.tテクスチャの生成(CSkin.Path(@"Graphics\ScreenSelect level numbers.png"));\r
81                                 base.OnManagedリソースの作成();\r
82                         }\r
83                 }\r
84                 public override void OnManagedリソースの解放()\r
85                 {\r
86                         if (!base.b活性化してない)\r
87                         {\r
88                                 if ( this.tx数値 != null )\r
89                                 {\r
90                                         this.tx数値.Dispose();\r
91                                         this.tx数値 = null;\r
92                                 }\r
93                                 base.OnManagedリソースの解放();\r
94                         }\r
95                 }\r
96 \r
97 \r
98                 // その他\r
99 \r
100                 #region [ private ]\r
101                 //-----------------\r
102                 [StructLayout(LayoutKind.Sequential)]\r
103                 private struct ST数字\r
104                 {\r
105                         public char ch;\r
106                         public Rectangle rc;\r
107                 }\r
108 \r
109                 public enum EFontColor\r
110                 {\r
111                         Red = 0,\r
112                         Yellow = 1,\r
113                         Orange = 2,\r
114                         White = 3\r
115                 }\r
116                 public enum EFontAlign\r
117                 {\r
118                         Left,\r
119                         Right\r
120                 }\r
121                 private ST数字[,] st数字;\r
122                 private CTexture tx数値;\r
123                 //-----------------\r
124                 #endregion\r
125         }\r
126 }\r