/// <summary> /// 指定したインデックスのエネミーの位置を指定した分だけ移動させます。 /// </summary> public void OffsetPosition(int index, Point scaledposoffset, Size scaledwndSize, ViewScale.ScaleRate scale) { var enemyPos = this.Enemies[index].Position; var enemySize = this.Enemies[index].Size; ViewScale.ApplyRateToPoint(ref enemyPos, scale); ViewScale.ApplyRateToSize(ref enemySize, scale); var afterRange = new Rectangle(enemyPos.X + scaledposoffset.X, enemyPos.Y + scaledposoffset.Y, enemySize.Width, enemySize.Height); //拡大率を解除する var originalposoffset = scaledposoffset; var originalwndSize = scaledwndSize; ViewScale.RestoreOriginalPoint(ref originalposoffset, scale); ViewScale.RestoreOriginalSize(ref originalwndSize, scale); //端点に範囲外になる場合は調整する var limit = (int)(limitPosition * ViewScale.GetRate(scale)); if (afterRange.Right < limit) { this.Enemies[index].Position = new Point(-this.Enemies[index].Size.Width + limitPosition, this.Enemies[index].Position.Y); } else if (afterRange.Bottom < limit) { this.Enemies[index].Position = new Point(this.Enemies[index].Position.X, -this.Enemies[index].Size.Height + limitPosition); } else if (afterRange.Left > scaledwndSize.Width - limit) { this.Enemies[index].Position = new Point(originalwndSize.Width - limitPosition, this.Enemies[index].Position.Y); } else if (afterRange.Top > scaledwndSize.Height - limit) { this.Enemies[index].Position = new Point(this.Enemies[index].Position.X, originalwndSize.Height - limitPosition); } else { //調整しなかった場合のみ差分移動する this.Enemies[index].OffsetPosition(originalposoffset); } this.IsDirty = true; }
/// <summary> /// デザイナーのスケール変更 /// </summary> private void tolScale_SelectedIndexChanged(object sender, EventArgs e) { if (this.mgr == null) { return; } this.mgr.Scale = (ViewScale.ScaleRate) this.tolScale.SelectedIndex; //デザイナーを更新:プレビュー画面をゲームウィンドウの解像度と一致させる var scaledWndSize = mgrDBUnit.WindowSize; ViewScale.ApplyRateToSize(ref scaledWndSize, this.mgr.Scale); Bitmap bmp = null; if (!scaledWndSize.IsEmpty) { bmp = new Bitmap(scaledWndSize.Width, scaledWndSize.Height); } this.picPreview.Image = bmp; this.picPreview.Refresh(); }
/// <summary> /// デザイナー:ドラッグ開始 /// </summary> private void picPreview_MouseDown(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } var NotFound = true; //レイヤーはインデックスが後ろになるほど上に描画される構造であるため、逆から判定する for (var i = this.mgr.EdittingData.Enemies.Count - 1; i >= 0; i--) { //拡大率を適用する var enemyPos = this.mgr.EdittingData.Enemies[i].Position; var enemySize = this.mgr.EdittingData.Enemies[i].Size; var pos = new Point(e.X, e.Y); ViewScale.RestoreOriginalPoint(ref pos, this.mgr.Scale); ViewScale.ApplyRateToPoint(ref enemyPos, this.mgr.Scale); ViewScale.ApplyRateToSize(ref enemySize, this.mgr.Scale); //ドラッグ可能な領域である場合 if (new Rectangle(enemyPos, enemySize).Contains(e.X, e.Y)) { this.drugObj = new DrugObject(i, new Point(e.X, e.Y)); this.ltvAnalyzer.SelectedIndices.Add(i); NotFound = false; break; } } if (NotFound) { this.drugObj = null; this.ltvAnalyzer.SelectedIndices.Clear(); this.picPreview.Refresh(); } }
/// <summary> /// デザイナーのスケール変更 /// </summary> private void tolScale_SelectedIndexChanged(object sender, EventArgs e) { if (this.mgr == null) { return; } this.mgr.Scale = (ViewScale.ScaleRate) this.tolScale.SelectedIndex; //デザイナーを更新:プレビュー画面をゲームウィンドウの解像度と一致させる var scaledWndSize = mgrDBEffect.ScreenSize; ViewScale.ApplyRateToSize(ref scaledWndSize, this.mgr.Scale); this.pnlPreview.Size = scaledWndSize; //パレットサイズを更新 if (this.mgr.EdittingData?.CurrentLayer?.LayerImage != null) { this.picPallet.Image = new Bitmap( (int)(this.mgr.EdittingData.CurrentLayer.LayerImage.Width * ViewScale.GetRate(this.mgr.Scale)), (int)(this.mgr.EdittingData.CurrentLayer.LayerImage.Height * ViewScale.GetRate(this.mgr.Scale)) ); this.picPallet.Refresh(); } }
/// <summary> /// 指定したグラフィック描画オブジェクトを用いてデザイナー用の描画を行います。 /// </summary> public void DrawDesigner(Graphics g, Size scaledwndSize, int activeIndex) { Common.ApplyHighQualityDrawing(g); //背景描画 if (this.backPicture != null) { g.DrawImage(this.backPicture, new Rectangle(Point.Empty, scaledwndSize)); } //各エネミーを描画 if (this.EdittingData != null) { for (var i = 0; i < this.EdittingData.Enemies.Count; i++) { //現在の表示倍率に合わせる var pos = this.EdittingData.Enemies[i].Position; var size = this.EdittingData.Enemies[i].Img?.Size ?? Size.Empty; ViewScale.ApplyRateToPoint(ref pos, this.Scale); ViewScale.ApplyRateToSize(ref size, this.Scale); if (this.EdittingData.Enemies[i].Img != null) { g.FillRectangle(new SolidBrush(Color.FromArgb(100, (i == activeIndex) ? Color.Yellow : Color.White)), new Rectangle(pos, size)); g.DrawImage(this.EdittingData.Enemies[i].Img, new Rectangle(pos, size)); var strSize = g.MeasureString(this.EdittingData.Enemies[i].Name, Settings.Default.Text_Font); g.DrawString(this.EdittingData.Enemies[i].Name, Settings.Default.Text_Font, Brushes.White, new Point(pos.X, pos.Y - (int)strSize.Height)); } } } //ガイド線描画 g.DrawRectangle(new Pen(Color.LightGray, 3), 0, 0, scaledwndSize.Width, scaledwndSize.Height); g.DrawLine(Pens.LightGray, scaledwndSize.Width / 2, 0, scaledwndSize.Width / 2, scaledwndSize.Height); g.DrawLine(Pens.LightGray, 0, scaledwndSize.Height / 2, scaledwndSize.Width, scaledwndSize.Height / 2); }
/// <summary> /// エフェクトを描画します。 /// </summary> public override void Draw() { var scaledScreenSize = new Size(mgrDBEffect.ScreenSize.Width, mgrDBEffect.ScreenSize.Height); ViewScale.ApplyRateToSize(ref scaledScreenSize, this.parent.Scale); DX.SetDrawBlendMode(DX.DX_BLENDMODE_NOBLEND, -1); //背景の格子 if (this.editorMode) { this.DrawGridPattern(); } //ターゲットグラフィック DX.GetGraphSize(dxTargetHdl, out var x, out var y); var tgtSize = new Size(x, y); ViewScale.ApplyRateToSize(ref tgtSize, this.parent.Scale); DX.DrawExtendGraph( scaledScreenSize.Width / 2 - tgtSize.Width / 2, scaledScreenSize.Height / 2 - tgtSize.Height / 2, scaledScreenSize.Width / 2 + tgtSize.Width / 2, scaledScreenSize.Height / 2 + tgtSize.Height / 2, dxTargetHdl, DX.TRUE ); //対象フレームの各レイヤー if (this.TargetEffectData != null && this.FrameNumber != -1) { foreach (var layer in this.TargetEffectData.Layers) { var trans = 255 - layer.Frames[this.FrameNumber].Transparent; if (this.editorMode && this.TargetEffectData.CurrentLayer != layer) { trans -= 150; //非アクティブレイヤーはさらに透明度を落とす } //ブレンド設定適用 switch (layer.Frames[this.FrameNumber].Blend) { case Media.BlendMode.Alpha: DX.SetDrawBlendMode(DX.DX_BLENDMODE_ALPHA, trans); break; case Media.BlendMode.Add: DX.SetDrawBlendMode(DX.DX_BLENDMODE_ADD, trans); break; case Media.BlendMode.Subtract: DX.SetDrawBlendMode(DX.DX_BLENDMODE_SUB, trans); break; case Media.BlendMode.Multiply: DX.SetDrawBlendMode(DX.DX_BLENDMODE_MULA, trans); break; case Media.BlendMode.Invsrc: DX.SetDrawBlendMode(DX.DX_BLENDMODE_INVSRC, trans); break; } //描画処理 DX.DrawRectRotaGraph( scaledScreenSize.Width / 2 + layer.Frames[this.FrameNumber].ViewPosition.X, scaledScreenSize.Height / 2 + layer.Frames[this.FrameNumber].ViewPosition.Y, layer.Frames[this.FrameNumber].SectionPosition.X * layer.SectionSize.Width, layer.Frames[this.FrameNumber].SectionPosition.Y * layer.SectionSize.Height, layer.SectionSize.Width, layer.SectionSize.Height, layer.Frames[this.FrameNumber].Extend / 100.0 * ViewScale.GetRate(this.parent.Scale), Math.PI / 180 * layer.Frames[this.FrameNumber].Angle, layer.dxGraphHdl, DX.TRUE, DX.FALSE ); //レイヤー枠とファイル名を描画 if (this.editorMode) { if (this.TargetEffectData.CurrentLayer != layer) { DX.SetDrawBlendMode(DX.DX_BLENDMODE_ALPHA, 100); } else { DX.SetDrawBlendMode(DX.DX_BLENDMODE_NOBLEND, -1); } DX.DrawBox( (int)(scaledScreenSize.Width / 2 + layer.Frames[this.FrameNumber].ViewPosition.X - layer.SectionSize.Width / 2 * layer.Frames[this.FrameNumber].Extend * ViewScale.GetRate(this.parent.Scale) / 100), (int)(scaledScreenSize.Height / 2 + layer.Frames[this.FrameNumber].ViewPosition.Y - layer.SectionSize.Height / 2 * layer.Frames[this.FrameNumber].Extend * ViewScale.GetRate(this.parent.Scale) / 100), (int)(scaledScreenSize.Width / 2 + layer.Frames[this.FrameNumber].ViewPosition.X + layer.SectionSize.Width / 2 * layer.Frames[this.FrameNumber].Extend * ViewScale.GetRate(this.parent.Scale) / 100), (int)(scaledScreenSize.Height / 2 + layer.Frames[this.FrameNumber].ViewPosition.Y + layer.SectionSize.Height / 2 * layer.Frames[this.FrameNumber].Extend * ViewScale.GetRate(this.parent.Scale) / 100), DX.GetColor(0, 255, 0), DX.FALSE ); DX.DrawString( (int)(scaledScreenSize.Width / 2 + layer.Frames[this.FrameNumber].ViewPosition.X - layer.SectionSize.Width / 2 * layer.Frames[this.FrameNumber].Extend * ViewScale.GetRate(this.parent.Scale) / 100), (int)(scaledScreenSize.Height / 2 + layer.Frames[this.FrameNumber].ViewPosition.Y - layer.SectionSize.Height / 2 * layer.Frames[this.FrameNumber].Extend / 100 * ViewScale.GetRate(this.parent.Scale)) - 20, Path.GetFileName(layer.FileName), DX.GetColor(255, 255, 255) ); } } } DX.SetDrawBlendMode(DX.DX_BLENDMODE_NOBLEND, -1); //中心線 if (this.editorMode) { DX.SetDrawBlendMode(DX.DX_BLENDMODE_ALPHA, 150); DX.DrawLine(0, scaledScreenSize.Height / 2, scaledScreenSize.Width, scaledScreenSize.Height / 2, DX.GetColor(200, 200, 200)); DX.DrawLine(scaledScreenSize.Width / 2, 0, scaledScreenSize.Width / 2, scaledScreenSize.Height, DX.GetColor(200, 200, 200)); } //画面枠 DX.DrawBox(this.screenOffset.X, this.screenOffset.Y, scaledScreenSize.Width, scaledScreenSize.Height, DX.GetColor(255, 255, 255), DX.FALSE); }