OSDN Git Service

#32713 初コミット。SVNrev567時点での、ファイルはbranch/140707(ReBuild XGVersion)から移行したもの。
[dtxmaniaxg-verk/dtxmaniaxg-verk-git.git] / DTXCreatorプロジェクト / コード / 05.譜面 / Cチップ.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.Drawing;
5 using FDK;
6
7 namespace DTXCreator.譜面
8 {
9         public class Cチップ : IComparable<Cチップ>
10         {
11                 public bool bドラッグで選択中;
12                 public bool b移動済;
13                 public bool b確定選択中;
14                 public bool b裏;
15                 public float f値_浮動小数;
16                 public int n移動開始時のレーン番号0to;
17                 public int n移動開始時の小節内の位置grid;
18                 public int n移動開始時の小節番号0to;
19                 public int n読み込み時の解像度 = 0xc0;
20                 public int n枠外レーン数;
21                 public int nチャンネル番号00toFF
22                 {
23                         get
24                         {
25                                 return this._nチャンネル番号00toFF;
26                         }
27                         set
28                         {
29                                 if( ( value < 0 ) || ( value > 0xff ) )
30                                 {
31                                         throw new Exception( "値が範囲(0~255)を超えています。-->[" + value + "]" );
32                                 }
33                                 this._nチャンネル番号00toFF = value;
34                         }
35                 }
36                 public int nレーン番号0to
37                 {
38                         get
39                         {
40                                 return this._nレーン番号0to;
41                         }
42                         set
43                         {
44                                 if( value < 0 )
45                                 {
46                                         throw new Exception( "値が範囲を超えています。-->[" + value + "]" );
47                                 }
48                                 this._nレーン番号0to = value;
49                         }
50                 }
51                 public int n位置grid
52                 {
53                         get
54                         {
55                                 return this._n位置grid;
56                         }
57                         set
58                         {
59                                 this._n位置grid = value;
60                         }
61                 }
62                 public int n値_整数1to1295
63                 {
64                         get
65                         {
66                                 return this._n値_整数1to1295;
67                         }
68                         set
69                         {
70                                 if( ( value < 0 ) || ( value > 36 * 36 - 1 ) )
71                                 {
72                                         throw new Exception( "値が範囲(0~1295)を超えています。-->[" + value + "]" );
73                                 }
74                                 this._n値_整数1to1295 = value;
75                         }
76                 }
77                 public static readonly int nチップの高さdot = 9;
78                 
79                 public int CompareTo( Cチップ other )
80                 {
81                         return ( this.n位置grid - other.n位置grid );
82                 }
83                 public static void tOPENチップを描画する( Graphics g, Rectangle rcチップ描画領域 )
84                 {
85                         t表チップを描画する_本体( g, rcチップ描画領域, Color.White );
86                         string str = "O P E N";
87                         t表チップを描画する_番号( g, rcチップ描画領域, str );
88                 }
89                 public void tコピーfrom( Cチップ ccコピー元 )
90                 {
91                         this._nチャンネル番号00toFF = ccコピー元._nチャンネル番号00toFF;
92                         this._nレーン番号0to = ccコピー元._nレーン番号0to;
93                         this._n値_整数1to1295 = ccコピー元._n値_整数1to1295;
94                         this.f値_浮動小数 = ccコピー元.f値_浮動小数;
95                         this._n位置grid = ccコピー元._n位置grid;
96                         this.b裏 = ccコピー元.b裏;
97                         this.bドラッグで選択中 = ccコピー元.bドラッグで選択中;
98                         this.b確定選択中 = ccコピー元.b確定選択中;
99                         this.n読み込み時の解像度 = ccコピー元.n読み込み時の解像度;
100                         this.b移動済 = ccコピー元.b移動済;
101                         this.n枠外レーン数 = ccコピー元.n枠外レーン数;
102                         this.n移動開始時の小節番号0to = ccコピー元.n移動開始時の小節番号0to;
103                         this.n移動開始時のレーン番号0to = ccコピー元.n移動開始時のレーン番号0to;
104                         this.n移動開始時の小節内の位置grid = ccコピー元.n移動開始時の小節内の位置grid;
105                 }
106                 public static void tチップの周囲の太枠を描画する( Graphics g, Rectangle rcチップ描画領域 )
107                 {
108                         Pen pen = new Pen( Color.White, 2f );
109                         g.DrawRectangle( pen, rcチップ描画領域 );
110                         pen.Dispose();
111                 }
112                 public static void t表チップを描画する( Graphics g, Rectangle rcチップ描画領域, int nチップ番号, Color col色 )
113                 {
114                         t表チップを描画する( g, rcチップ描画領域, nチップ番号, col色, Cレーン.E種別.WAV );   // とにかくCレーン.E種別.BEAT以外を指定する
115                 }
116                 public static void t表チップを描画する( Graphics g, Rectangle rcチップ描画領域, int nチップ番号, Color col色, Cレーン.E種別 e種別 )
117                 {
118                         if ( e種別 == Cレーン.E種別.BEAT )
119                         {
120                                 t表チップを描画する_本体( g, rcチップ描画領域, col色, e種別 );
121                         }
122                         else
123                         {
124                                 t表チップを描画する_本体( g, rcチップ描画領域, col色 );
125                                 if ( nチップ番号 >= 0 )
126                                 {
127                                         string str = C変換.str数値を36進数2桁に変換して返す( nチップ番号 );
128                                         str = str[ 0 ] + " " + str[ 1 ];
129                                         t表チップを描画する_番号( g, rcチップ描画領域, str );
130                                 }
131                         }
132                 }
133                 public static void t表チップを描画する( Graphics g, Rectangle rcチップ描画領域, float fチップ数値, Color col色 )
134                 {
135                         t表チップを描画する_本体( g, rcチップ描画領域, col色 );
136                         if( fチップ数値 >= 0f )
137                         {
138                                 string str = fチップ数値.ToString();
139                                 t表チップを描画する_番号( g, rcチップ描画領域, str );
140                         }
141                 }
142                 public static void t裏チップを描画する( Graphics g, Rectangle rcチップ描画領域, int nチップ番号, Color col色 )
143                 {
144                         t裏チップを描画する( g, rcチップ描画領域, nチップ番号, col色, Cレーン.E種別.WAV );   // とにかくCレーン.E種別.BEAT以外を指定する
145                 }
146                 public static void t裏チップを描画する( Graphics g, Rectangle rcチップ描画領域, int nチップ番号, Color col色, Cレーン.E種別 e種別 )
147                 {
148                         t裏チップを描画する_本体( g, rcチップ描画領域, col色, e種別 );
149
150                         if ( e種別 == Cレーン.E種別.BEAT )
151                         {
152                                 t裏チップを描画する_本体( g, rcチップ描画領域, col色, e種別 );
153                         }
154                         else
155                         {
156                                 t裏チップを描画する_本体( g, rcチップ描画領域, col色 );
157                                 if ( nチップ番号 >= 0 )
158                                 {
159                                         string str = C変換.str数値を36進数2桁に変換して返す( nチップ番号 );
160                                         str = str[ 0 ] + " " + str[ 1 ];
161                                         t裏チップを描画する_番号( g, rcチップ描画領域, str );
162                                 }
163                         }
164         
165                 }
166                 public static void t裏チップを描画する( Graphics g, Rectangle rcチップ描画領域, float fチップ数値, Color col色 )
167                 {
168                         t裏チップを描画する_本体( g, rcチップ描画領域, col色 );
169                         if( fチップ数値 >= 0f )
170                         {
171                                 string str = fチップ数値.ToString();
172                                 t裏チップを描画する_番号( g, rcチップ描画領域, str );
173                         }
174                 }
175                 protected static Font ftチップ文字用フォント = new Font( "MS Gothic", 8f, FontStyle.Bold );
176
177                 #region [ private ]
178                 //-----------------
179                 private int _nチャンネル番号00toFF;
180                 private int _nレーン番号0to;
181                 private int _n位置grid;
182                 private int _n値_整数1to1295;
183
184                 private static void t表チップを描画する_番号( Graphics g, Rectangle rcチップ描画領域, string str番号文字列 )
185                 {
186                         tチップを描画する_番号( g, rcチップ描画領域, str番号文字列, false );
187                 }
188
189                 // BEATレーン専用; ●を書く
190                 private static void t表チップを描画する_本体( Graphics g, Rectangle rcチップ描画領域, Color col色, Cレーン.E種別 e種別 )
191                 {
192                         if ( e種別 == Cレーン.E種別.BEAT )
193                         {
194                                 tチップを描画する_本体( g, rcチップ描画領域, col色, false, true );
195                         }
196                         else
197                         {
198                                 tチップを描画する_本体( g, rcチップ描画領域, col色, false, false );
199                         }
200                 }
201                 private static void t表チップを描画する_本体( Graphics g, Rectangle rcチップ描画領域, Color col色 )
202                 {
203                         tチップを描画する_本体( g, rcチップ描画領域, col色, false, false );
204                 }
205                 private static void t裏チップを描画する_番号( Graphics g, Rectangle rcチップ描画領域, string str番号文字列 )
206                 {
207                         tチップを描画する_番号( g, rcチップ描画領域, str番号文字列, true );
208                 }
209
210                 // BEATレーン専用; ●を書く
211                 private static void t裏チップを描画する_本体( Graphics g, Rectangle rcチップ描画領域, Color col色, Cレーン.E種別 e種別 )
212                 {
213                         if ( e種別 == Cレーン.E種別.BEAT )
214                         {
215                                 tチップを描画する_本体( g, rcチップ描画領域, col色, true, true );
216                         }
217                         else
218                         {
219                                 tチップを描画する_本体( g, rcチップ描画領域, col色, true, false );
220                         }
221                 }
222                 private static void t裏チップを描画する_本体( Graphics g, Rectangle rcチップ描画領域, Color col色 )
223                 {
224                         tチップを描画する_本体( g, rcチップ描画領域, col色, true, false );
225                 }
226
227                 private static void tチップを描画する_本体( Graphics g, Rectangle rcチップ描画領域, Color col色, bool b裏チップである, bool bBEATチップである )
228                 {
229                         int alphaBrush = 128;
230                         int alphaPen = 255;
231                         int alphaPen2 = 64;
232                         if ( b裏チップである )
233                         {
234                                 rcチップ描画領域.Width -= 8;
235                                 rcチップ描画領域.Height -= 2;
236                                 rcチップ描画領域.X += 4;
237                                 rcチップ描画領域.Y++;
238                                 alphaBrush = 80;
239                                 alphaPen = 180;
240                                 alphaPen2 = 44;
241                         }
242                         SolidBrush brush = new SolidBrush( Color.FromArgb( alphaBrush, col色.R, col色.G, col色.B ) );
243                         Pen pen = new Pen( Color.FromArgb( alphaPen, col色.R, col色.G, col色.B ) );
244                         Pen pen2 = new Pen( Color.FromArgb( alphaPen2, col色.R, col色.G, col色.B ) );
245                         g.FillRectangle( brush, rcチップ描画領域 );
246                         g.DrawLine( pen, rcチップ描画領域.X, rcチップ描画領域.Y, rcチップ描画領域.Right, rcチップ描画領域.Y );
247                         g.DrawLine( pen, rcチップ描画領域.X, rcチップ描画領域.Y, rcチップ描画領域.X, rcチップ描画領域.Bottom );
248                         g.DrawLine( pen2, rcチップ描画領域.X, rcチップ描画領域.Bottom, rcチップ描画領域.Right, rcチップ描画領域.Bottom );
249                         g.DrawLine( pen2, rcチップ描画領域.Right, rcチップ描画領域.Bottom, rcチップ描画領域.Right, rcチップ描画領域.Y );
250                         if ( bBEATチップである )
251                         {
252                                 SolidBrush brushWhite = new SolidBrush( Color.White );
253                                 g.FillEllipse(
254                                         brushWhite,
255                                         ( rcチップ描画領域.X + rcチップ描画領域.Width / 2.0f ) - ( rcチップ描画領域.Height / 2.0f ),
256                                         ( rcチップ描画領域.Y ),
257                                         rcチップ描画領域.Height,
258                                         rcチップ描画領域.Height
259                                 );
260                                 brushWhite.Dispose();
261
262                                 if ( b裏チップである )
263                                 {
264                                         Pen pen3 = new Pen( Color.White );
265                                         g.DrawLine( pen3, rcチップ描画領域.X, rcチップ描画領域.Y, rcチップ描画領域.X + rcチップ描画領域.Width, rcチップ描画領域.Y + rcチップ描画領域.Height );
266                                         g.DrawLine( pen3, rcチップ描画領域.X, rcチップ描画領域.Y + rcチップ描画領域.Height, rcチップ描画領域.X + rcチップ描画領域.Width, rcチップ描画領域.Y );
267                                         pen3.Dispose();
268                                 }
269                         }
270                         brush.Dispose();
271                         pen.Dispose();
272                         pen2.Dispose();
273                 }
274                 private static void tチップを描画する_番号( Graphics g, Rectangle rcチップ描画領域, string str番号文字列, bool b裏チップである )
275                 {
276                         // 表裏に関係なく、番号描画は共通
277
278                         StringFormat format = new StringFormat();
279                         format.Alignment = StringAlignment.Center;
280                         format.LineAlignment = StringAlignment.Near;
281                         RectangleF layoutRectangle = new RectangleF();
282                         layoutRectangle.X = rcチップ描画領域.X;
283                         layoutRectangle.Y = rcチップ描画領域.Y + 1;
284                         layoutRectangle.Width = rcチップ描画領域.Width;
285                         layoutRectangle.Height = rcチップ描画領域.Height;
286                         g.DrawString( str番号文字列, ftチップ文字用フォント, Brushes.Black, layoutRectangle, format );
287                         layoutRectangle.X--;
288                         layoutRectangle.Y--;
289                         g.DrawString( str番号文字列, ftチップ文字用フォント, Brushes.White, layoutRectangle, format );
290                 }
291                 //-----------------
292                 #endregion
293         }
294 }