123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using CommonAI.ZoneClient;
- using System.Drawing;
- using GameEditorPlugin.Win32.Runtime;
- using CommonAI.Zone.ZoneEditor;
- using CommonAI.Zone;
- using CommonLang;
- using CommonAI.Zone.Helper;
- using CommonAI.RTS;
- using CommonLang.Vector;
- using GameEditorPlugin.Tools;
- using CommonLang.Vector;
- using CommonFroms.Drawing;
- namespace GameEditorPlugin.Win32.BattleClient
- {
- public class DisplayGameFlag : DisplayObject
- {
- readonly public ZoneFlag Flag;
- readonly public DisplayLayerWorld world;
- readonly public Pen pen;
- readonly public SolidBrush brush;
- public string Name { get { return Flag.Name; } }
- protected bool mIsRect = false;
- protected RectangleF mLocalBounds;
- public DisplayGameFlag(DisplayLayerWorld wd, ZoneFlag data)
- {
- this.world = wd;
- this.Flag = data;
- this.pen = new Pen(Color.FromArgb(Flag.EditorData.Color));
- this.brush = new SolidBrush(Color.FromArgb(Flag.EditorData.Color));
- }
- public override void render(Graphics g)
- {
- float penscale = 1f / world.getCameraScale();
- pen.Width = penscale;
- if (mIsRect)
- {
- g.FillRectangle(brush, mLocalBounds);
- }
- else
- {
- g.FillEllipse(brush, mLocalBounds);
- }
- }
- public override bool Visible { get { return true; } }
- public override float X { get { return Flag.X; } }
- public override float Y { get { return Flag.Y; } }
- public override float Z { get { return 0; } }
- public override RectangleF LocalBounds { get { return mLocalBounds; } }
- }
- public class DisplayGameDecoration : DisplayGameFlag
- {
- private ZoneEditorDecoration LayerFlag;
- public DisplayGameDecoration(DisplayLayerWorld wd, ZoneEditorDecoration zed) :
- base(wd, zed)
- {
- DecorationData rg = zed.Data as DecorationData;
- this.mLocalBounds = new RectangleF(-rg.W / 2, -rg.H / 2, rg.W, rg.H);
- this.mIsRect = rg.RegionType == DecorationData.Shape.RECTANGLE ? true : false;
- LayerFlag = zed;
- }
- public override void renderName(Graphics g, Font font, Brush brush)
- {
- if (world.ShowFlagName)
- {
- SizeF fsize = g.MeasureString(this.Name, font);
- g.DrawString(LayerFlag.Name, font, brush, -fsize.Width / 2, -fsize.Height);
- }
- }
- public override void render(Graphics g)
- {
- float penscale = 1f / world.getCameraScale();
- pen.Width = penscale;
- var Data = LayerFlag.Data;
- if (LayerFlag.Enable && Data.Blockable)
- {
- var brush = new SolidBrush(Color.FromArgb(0x80, pen.Color));
- if (Data.RegionType == DecorationData.Shape.RECTANGLE)
- {
- g.FillRectangle(brush, -Data.W / 2, -Data.H / 2, Data.W, Data.H);
- }
- else if (Data.RegionType == DecorationData.Shape.ROUND)
- {
- g.FillEllipse(brush, -Data.W / 2, -Data.H / 2, Data.W, Data.H);
- }
- else if (Data.RegionType == DecorationData.Shape.STRIP)
- {
- float line_r = Data.W / 2;
- Line2 line = new Line2(0, 0, 0, 0);
- MathVector.movePolar(line.p, Data.StripDirection, -Data.H / 2);
- MathVector.movePolar(line.q, Data.StripDirection, +Data.H / 2);
- DrawingUtils.FillLineRect(g, brush, line.p.X, line.p.Y, line.q.X, line.q.Y, line_r);
- }
- }
- if (Data.RegionType == DecorationData.Shape.RECTANGLE)
- {
- g.DrawRectangle(pen, -Data.W / 2, -Data.H / 2, Data.W, Data.H);
- }
- else if (Data.RegionType == DecorationData.Shape.ROUND)
- {
- g.DrawEllipse(pen, -Data.W / 2, -Data.H / 2, Data.W, Data.H);
- }
- else if (Data.RegionType == DecorationData.Shape.STRIP)
- {
- float line_r = Data.W / 2;
- Line2 line = new Line2(0, 0, 0, 0);
- MathVector.movePolar(line.p, Data.StripDirection, -Data.H / 2);
- MathVector.movePolar(line.q, Data.StripDirection, +Data.H / 2);
- DrawingUtils.DrawLineRect(g, pen, line.p.X, line.p.Y, line.q.X, line.q.Y, line_r);
- }
- }
- }
- }
|