Skip to content

Commit

Permalink
MapRender2: BugFix
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'refs/remotes/origin/maprender2'
  • Loading branch information
Kagamia committed Jul 6, 2017
1 parent 3999ce1 commit 70dafb9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
6 changes: 6 additions & 0 deletions WzComparerR2.MapRender/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Camera
public Camera(GraphicsDeviceManager graphics)
{
this.graphics = graphics;
this.AdjustRectEnabled = true;
}

GraphicsDeviceManager graphics;
Expand Down Expand Up @@ -97,6 +98,8 @@ public bool UseWorldRect
set { useWorldRect = value; }
}

public bool AdjustRectEnabled { get; set; }

private void ChangeDisplayMode()
{
switch (this.displayMode)
Expand Down Expand Up @@ -128,6 +131,9 @@ public void AdjustToWorldRect()
if (this.useWorldRect)
return;

if (!this.AdjustRectEnabled)
return;

if (this.Width > worldRect.Width)
{
this.center.X = worldRect.Center.X;
Expand Down
2 changes: 2 additions & 0 deletions WzComparerR2.MapRender/FrmMapRender2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ private void BindingUIInput()
//截图
this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => { if (CanCapture()) prepareCapture = true; }), KeyCode.Scroll, ModifierKeys.None));

this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => { renderEnv.Camera.AdjustRectEnabled = !renderEnv.Camera.AdjustRectEnabled; }), KeyCode.U, ModifierKeys.Control));

//层隐藏
this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => this.patchVisibility.BackVisible = !this.patchVisibility.BackVisible), KeyCode.D1, ModifierKeys.Control));
this.ui.InputBindings.Add(new KeyBinding(new RelayCommand(_ => this.patchVisibility.ReactorVisible = !this.patchVisibility.ReactorVisible), KeyCode.D2, ModifierKeys.Control));
Expand Down
26 changes: 19 additions & 7 deletions WzComparerR2.MapRender/MapData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,39 +396,51 @@ private void CalcMapSize()
}

var rect = Rectangle.Empty;


int xMAX = int.MinValue;
foreach(LayerNode layer in this.Scene.Layers.Nodes)
{
foreach (ContainerNode<FootholdItem> item in layer.Foothold.Nodes)
{
var fh = item.Item;
var fhRect = new Rectangle(fh.X1, fh.Y1, fh.X2 - fh.X1, fh.Y2 - fh.Y1);
var fhRect = new Rectangle(
Math.Min(fh.X1, fh.X2),
Math.Min(fh.Y1, fh.Y2),
Math.Abs(fh.X2 - fh.X1),
Math.Abs(fh.Y2 - fh.Y1));
xMAX = Math.Max(fhRect.Right, xMAX);
var oldrec = rect;
if (rect.IsEmpty)
{
rect = fhRect;
}
else
{
Rectangle.Union(ref rect, ref fhRect, out rect);
Rectangle newRect;
Rectangle.Union(ref rect, ref fhRect, out newRect);
rect = newRect;
}
}
}

rect.Y -= 250;
rect.Height += 450;

foreach (LadderRopeItem item in this.Scene.Fly.LadderRope.Slots)
{
var lrRect = new Rectangle(item.X, item.Y1, 1, item.Y2 - item.Y1);
var lrRect = new Rectangle(item.X, Math.Min(item.Y1, item.Y2), 1, Math.Abs(item.Y2 - item.Y1));
if (rect.IsEmpty)
{
rect = lrRect;
}
else
{
Rectangle.Union(ref rect, ref lrRect, out rect);
Rectangle newRect;
Rectangle.Union(ref rect, ref lrRect, out newRect);
rect = newRect;
}
}

rect.Y -= 300;
rect.Height += 600;
this.VRect = rect;
}

Expand Down
4 changes: 2 additions & 2 deletions WzComparerR2.MapRender/UI/UIMinimap2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ protected override void InitializeComponents()
this.MinHeight = resource.NW.Height + resource.SW.Height;
this.Width = this.MinWidth;
this.Height = this.MinHeight;
this.MaxWidth = 300;
this.MaxHeight = 300;
this.MaxWidth = 1000;
this.MaxHeight = 1000;

Canvas canvas = new Canvas();
canvas.Background = new NinePatchBrush() { Resource = resource };
Expand Down

0 comments on commit 70dafb9

Please sign in to comment.