/// <summary> /// 初期位置カーソル描画:白枠の半透明S /// </summary> protected virtual void drawStartPoint() { DX.SetDrawBlendMode(DX.DX_BLENDMODE_ALPHA, 80); DX.DrawBox( this.parent.StartPosition.X * this.parent.ScaledTileSize - this.parent.ViewRange.Left + 1, this.parent.StartPosition.Y * this.parent.ScaledTileSize - this.parent.ViewRange.Top + 1, (this.parent.StartPosition.X + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Left - 1, (this.parent.StartPosition.Y + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Top - 1, DX.GetColor(0, 0, 0), DX.TRUE); DX.SetDrawBlendMode(DX.DX_BLENDMODE_NOBLEND, -1); DX.DrawBox( this.parent.StartPosition.X * this.parent.ScaledTileSize - this.parent.ViewRange.Left, this.parent.StartPosition.Y * this.parent.ScaledTileSize - this.parent.ViewRange.Top, (this.parent.StartPosition.X + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Left, (this.parent.StartPosition.Y + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Top, DX.GetColor(255, 255, 255), DX.FALSE); if (ViewScale.GetRate(this.parent.Scale) >= 0.5) { //縮小しすぎているときは S を表示しない DX.DrawStringToHandle( this.parent.StartPosition.X * this.parent.ScaledTileSize - this.parent.ViewRange.Left + 1, this.parent.StartPosition.Y * this.parent.ScaledTileSize - this.parent.ViewRange.Top + 1, "S", DX.GetColor(0, 0, 255), this.Fonts[(int)SpecialFont.StartMark], DX.GetColor(255, 255, 255) ); } }
/// <summary> /// 指定したタイル座標に配置されているタイルを描画します。 /// </summary> protected virtual void drawTile(int l, int x, int y) { var rawTileSize = (int)(this.parent.ScaledTileSize / ViewScale.GetRate(this.parent.Scale)); var tile = this.parent.MapData.LayerTiles[l, x, y]; //カーボン元があるマップで、空白タイルの部分はカーボン元の同一座標にあるタイルを描画する if (tile.PalletPosition.IsEmpty && this.parent.MapData.BaseMapLayerTiles != null && x < this.parent.MapData.BaseMapLayerTiles.GetLength(1) && y < this.parent.MapData.BaseMapLayerTiles.GetLength(2)) { tile = this.parent.MapData.BaseMapLayerTiles[l, x, y]; } if (tile.PalletPosition.Y >= Map.AutoTileRowLength) { //単一タイルを描画 DX.DrawRectExtendGraph( x * this.parent.ScaledTileSize - this.parent.ViewRange.Left, y * this.parent.ScaledTileSize - this.parent.ViewRange.Top, (x + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Left, (y + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Top, tile.PalletPosition.X * rawTileSize, tile.PalletPosition.Y * rawTileSize, rawTileSize, rawTileSize, this.pallet.dxPalletHandle, DX.TRUE ); } else { //オートタイル用の1/4描画 for (var q = 0; q < 4; q++) { DX.DrawRectExtendGraph( x * this.parent.ScaledTileSize + (q % 2) * (this.parent.ScaledTileSize / 2) - this.parent.ViewRange.Left, y * this.parent.ScaledTileSize + (q / 2) * (this.parent.ScaledTileSize / 2) - this.parent.ViewRange.Top, x * this.parent.ScaledTileSize + (q % 2) * (this.parent.ScaledTileSize / 2) + (this.parent.ScaledTileSize / 2) - this.parent.ViewRange.Left, y * this.parent.ScaledTileSize + (q / 2) * (this.parent.ScaledTileSize / 2) + (this.parent.ScaledTileSize / 2) - this.parent.ViewRange.Top, (q % 2) * (this.parent.ScaledTileSize / 2), (q / 2) * (this.parent.ScaledTileSize / 2) + tile.GetQuarter((Map.QuarterTile)q) * rawTileSize, rawTileSize / 2, rawTileSize / 2, this.pallet.dxAutoTilesHandle[tile.PalletPosition.X + tile.PalletPosition.Y * Map.TileColumnCount], DX.TRUE ); } } }
/// <summary> /// パレットを再描画 /// </summary> private void picPallet_Paint(object sender, PaintEventArgs e) { if (this.mgr.EdittingData?.CurrentLayer == null || this.picPallet.Image == null) { return; } Common.ApplyHighQualityDrawing(e.Graphics); e.Graphics.DrawImage(this.mgr.EdittingData.CurrentLayer.LayerImage, new Rectangle(Point.Empty, this.picPallet.Size)); e.Graphics.DrawRectangle( new Pen(Color.Red, 3), (int)(this.uctlSectionPos.Result.X * this.mgr.EdittingData.CurrentLayer.SectionSize.Width * ViewScale.GetRate(this.mgr.Scale)), (int)(this.uctlSectionPos.Result.Y * this.mgr.EdittingData.CurrentLayer.SectionSize.Height * ViewScale.GetRate(this.mgr.Scale)), (int)(this.mgr.EdittingData.CurrentLayer.SectionSize.Width * ViewScale.GetRate(this.mgr.Scale)), (int)(this.mgr.EdittingData.CurrentLayer.SectionSize.Height * ViewScale.GetRate(this.mgr.Scale)) ); }
/// <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; }
public override void Draw() { if (this.parent.MapData == null) { return; } //ユーザーによって急にスクロールされると描画されない部分がちょっと見えてしまうので、ちょっと多めに描画する const int margin = 2; var rawTileSize = (int)(this.parent.ScaledTileSize / ViewScale.GetRate(this.parent.Scale)); var left = this.parent.ViewRange.Left / this.parent.ScaledTileSize; var top = this.parent.ViewRange.Top / this.parent.ScaledTileSize; //各種描画処理 this.drawVisibleRangeTiles(margin, left, top); this.drawTemporaryTiles(); this.drawGrid(); this.drawVisibleEVs(rawTileSize); this.drawMapFrame(); this.drawStartPoint(); this.drawCursor(); }
/// <summary> /// 指定したタイル座標に指定したタイルを上書き描画します。 /// </summary> protected void drawTileWithAutotilePattern(int x, int y, Point palPos, Map.AutoTilePattern pattern) { var rawTileSize = (int)(this.parent.ScaledTileSize / ViewScale.GetRate(this.parent.Scale)); if (palPos.Y >= Map.AutoTileRowLength) { //単一タイルを描画 DX.DrawRectExtendGraph( x * this.parent.ScaledTileSize - this.parent.ViewRange.Left, y * this.parent.ScaledTileSize - this.parent.ViewRange.Top, (x + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Left, (y + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Top, palPos.X * rawTileSize, palPos.Y * rawTileSize, rawTileSize, rawTileSize, this.pallet.dxPalletHandle, DX.TRUE ); } else { //オートタイルの指定されたパターンを描画 DX.DrawRectExtendGraph( x * this.parent.ScaledTileSize - this.parent.ViewRange.Left, y * this.parent.ScaledTileSize - this.parent.ViewRange.Top, (x + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Left, (y + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Top, 0, (int)pattern * rawTileSize, rawTileSize, rawTileSize, this.pallet.dxAutoTilesHandle[palPos.X + palPos.Y * Map.TileColumnCount], DX.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 = 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> protected virtual void drawVisibleEVs(int rawTileSize) { //現在のレイヤーがイベントレイヤーでなければ暗くする if (this.parent.SwitchLayers[(int)Map.Layer.Event]) { for (var i = 0; i < this.parent.MapData.EVCount; i++) { var ev = this.parent.MapData[i]; if (ev.TilePosition.X < this.parent.ViewRange.Left / this.parent.ScaledTileSize || this.parent.ViewRange.Right / this.parent.ScaledTileSize < ev.TilePosition.X || ev.TilePosition.Y < this.parent.ViewRange.Top / this.parent.ScaledTileSize || this.parent.ViewRange.Bottom / this.parent.ScaledTileSize < ev.TilePosition.Y) { //範囲外の場合は描画しない continue; } //イベント下地を描画 DX.SetDrawBlendMode( DX.DX_BLENDMODE_ALPHA, (this.parent.CurrentLayer == (int)Map.Layer.Event) ? 80 : 80 - Settings.Default.Map_NonActiveLayerTransparency * 80 / 255 ); DX.DrawBox( ev.TilePosition.X * this.parent.ScaledTileSize - this.parent.ViewRange.Left + 1, ev.TilePosition.Y * this.parent.ScaledTileSize - this.parent.ViewRange.Top + 1, (ev.TilePosition.X + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Left - 1, (ev.TilePosition.Y + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Top - 1, DX.GetColor(0, 0, 0), DX.TRUE ); if (this.parent.CurrentLayer == (int)Map.Layer.Event) { DX.SetDrawBlendMode(DX.DX_BLENDMODE_NOBLEND, -1); } else { DX.SetDrawBlendMode(DX.DX_BLENDMODE_ALPHA, byte.MaxValue - Settings.Default.Map_NonActiveLayerTransparency); } //イベントグラフィックを描画 if (string.IsNullOrEmpty(ev.Pages[0].Graphic) && ViewScale.GetRate(this.parent.Scale) >= 0.5) { //グラフィックをもたない:白枠の半透明EV・縮小しすぎているときは表示しない DX.DrawStringToHandle( ev.TilePosition.X * this.parent.ScaledTileSize - this.parent.ViewRange.Left + 1, ev.TilePosition.Y * this.parent.ScaledTileSize - this.parent.ViewRange.Top + 1, "EV", DX.GetColor(255, 0, 0), this.Fonts[(int)SpecialFont.EVMark], DX.GetColor(255, 255, 255) ); } else if (ev.Pages[0].Graphic.IndexOf(Resources.Split_IDNamePair) != -1) { //タイルグラフィックを持つ:オートタイルは代表タイルで描画 var srcPos = Common.StringToPoint(ev.Pages[0].Graphic); DX.DrawRectExtendGraph( ev.TilePosition.X * this.parent.ScaledTileSize - this.parent.ViewRange.Left, ev.TilePosition.Y * this.parent.ScaledTileSize - this.parent.ViewRange.Top, ev.TilePosition.X * this.parent.ScaledTileSize - this.parent.ViewRange.Left + this.parent.ScaledTileSize, ev.TilePosition.Y * this.parent.ScaledTileSize - this.parent.ViewRange.Top + this.parent.ScaledTileSize, srcPos.X * rawTileSize, srcPos.Y * rawTileSize, rawTileSize, rawTileSize, this.pallet.dxPalletHandle, DX.TRUE ); } else { DX.GetGraphSize(ev.dxHandle, out var width, out var height); DX.DrawRectExtendGraph( ev.TilePosition.X * this.parent.ScaledTileSize - this.parent.ViewRange.Left, ev.TilePosition.Y * this.parent.ScaledTileSize - this.parent.ViewRange.Top, ev.TilePosition.X * this.parent.ScaledTileSize - this.parent.ViewRange.Left + this.parent.ScaledTileSize, ev.TilePosition.Y * this.parent.ScaledTileSize - this.parent.ViewRange.Top + this.parent.ScaledTileSize, width / (int)Map.EventAnimation.Count * 1, height / (Common.GetEnumCount <Map.Direction4>() - 1) * 0, width / (int)Map.EventAnimation.Count, height / (Common.GetEnumCount <Map.Direction4>() - 1), ev.dxHandle, DX.TRUE ); } //イベント外枠 DX.DrawBox( ev.TilePosition.X * this.parent.ScaledTileSize - this.parent.ViewRange.Left, ev.TilePosition.Y * this.parent.ScaledTileSize - this.parent.ViewRange.Top, (ev.TilePosition.X + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Left, (ev.TilePosition.Y + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Top, DX.GetColor(255, 255, 255), DX.FALSE ); //接触範囲 if (!ev.Pages[0].HitRect.IsEmpty) { //イベント外枠からの接続線 [LT, RT, LB, RB の順] DX.DrawLine( (ev.TilePosition.X * this.parent.ScaledTileSize - this.parent.ViewRange.Left) - ev.Pages[0].HitRect.Width * this.parent.ScaledTileSize, (ev.TilePosition.Y * this.parent.ScaledTileSize - this.parent.ViewRange.Top) - ev.Pages[0].HitRect.Height * this.parent.ScaledTileSize, ev.TilePosition.X * this.parent.ScaledTileSize - this.parent.ViewRange.Left, ev.TilePosition.Y * this.parent.ScaledTileSize - this.parent.ViewRange.Top, DX.GetColor(255, 0, 0) ); DX.DrawLine( ((ev.TilePosition.X + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Left), ev.TilePosition.Y * this.parent.ScaledTileSize - this.parent.ViewRange.Top, ((ev.TilePosition.X + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Left) + ev.Pages[0].HitRect.Width * this.parent.ScaledTileSize, (ev.TilePosition.Y * this.parent.ScaledTileSize - this.parent.ViewRange.Top) - ev.Pages[0].HitRect.Height * this.parent.ScaledTileSize, DX.GetColor(255, 0, 0) ); DX.DrawLine( ev.TilePosition.X * this.parent.ScaledTileSize - this.parent.ViewRange.Left, (ev.TilePosition.Y + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Top, (ev.TilePosition.X * this.parent.ScaledTileSize - this.parent.ViewRange.Left) - ev.Pages[0].HitRect.Width * this.parent.ScaledTileSize, ((ev.TilePosition.Y + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Top) + ev.Pages[0].HitRect.Height * this.parent.ScaledTileSize, DX.GetColor(255, 0, 0) ); DX.DrawLine( (ev.TilePosition.X + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Left, (ev.TilePosition.Y + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Top, ((ev.TilePosition.X + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Left) + ev.Pages[0].HitRect.Width * this.parent.ScaledTileSize, ((ev.TilePosition.Y + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Top) + ev.Pages[0].HitRect.Height * this.parent.ScaledTileSize, DX.GetColor(255, 0, 0) ); //接触範囲枠 DX.DrawBox( (ev.TilePosition.X * this.parent.ScaledTileSize - this.parent.ViewRange.Left) - ev.Pages[0].HitRect.Width * this.parent.ScaledTileSize, (ev.TilePosition.Y * this.parent.ScaledTileSize - this.parent.ViewRange.Top) - ev.Pages[0].HitRect.Height * this.parent.ScaledTileSize, ((ev.TilePosition.X + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Left) + ev.Pages[0].HitRect.Width * this.parent.ScaledTileSize, ((ev.TilePosition.Y + 1) * this.parent.ScaledTileSize - this.parent.ViewRange.Top) + ev.Pages[0].HitRect.Height * this.parent.ScaledTileSize, DX.GetColor(255, 0, 0), DX.FALSE ); } } } DX.SetDrawBlendMode(DX.DX_BLENDMODE_NOBLEND, -1); }
/// <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); }