Added int2.Clamp(Rectangle). All queries for map geometry use map.Bounds.

This commit is contained in:
Paul Chote
2010-11-24 12:24:48 +13:00
parent 1dfe437641
commit fc5830a687
14 changed files with 63 additions and 52 deletions

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Widgets.Delegates
var ml = bg.GetWidget<ListBoxWidget>("MAP_LIST");
bg.GetWidget<MapPreviewWidget>("MAPCHOOSER_MAP_PREVIEW").Map = () => Map;
bg.GetWidget<LabelWidget>("CURMAP_TITLE").GetText = () => Map.Title;
bg.GetWidget<LabelWidget>("CURMAP_SIZE").GetText = () => "{0}x{1}".F(Map.Width, Map.Height);
bg.GetWidget<LabelWidget>("CURMAP_SIZE").GetText = () => "{0}x{1}".F(Map.Bounds.Width, Map.Bounds.Height);
bg.GetWidget<LabelWidget>("CURMAP_THEATER").GetText = () => Rules.TileSets[Map.Tileset].Name;
bg.GetWidget<LabelWidget>("CURMAP_PLAYERS").GetText = () => Map.PlayerCount.ToString();

View File

@@ -91,14 +91,14 @@ namespace OpenRA.Widgets
mapChooserSheet = new Sheet(new Size( preview.Width, preview.Height ) );
mapChooserSheet.Texture.SetData( preview );
mapChooserSprite = new Sprite( mapChooserSheet, new Rectangle( 0, 0, map.Width, map.Height ), TextureChannel.Alpha );
mapChooserSprite = new Sprite( mapChooserSheet, new Rectangle( 0, 0, map.Bounds.Width, map.Bounds.Height ), TextureChannel.Alpha );
// Update map rect
PreviewScale = Math.Min(RenderBounds.Width * 1.0f / map.Width, RenderBounds.Height * 1.0f / map.Height);
var size = Math.Max(map.Width, map.Height);
var dw = (int)(PreviewScale * (size - map.Width)) / 2;
var dh = (int)(PreviewScale * (size - map.Height)) / 2;
MapRect = new Rectangle(RenderBounds.X + dw, RenderBounds.Y + dh, (int)(map.Width * PreviewScale), (int)(map.Height * PreviewScale));
PreviewScale = Math.Min(RenderBounds.Width * 1.0f / map.Bounds.Width, RenderBounds.Height * 1.0f / map.Bounds.Height);
var size = Math.Max(map.Bounds.Width, map.Bounds.Height);
var dw = (int)(PreviewScale * (size - map.Bounds.Width)) / 2;
var dh = (int)(PreviewScale * (size - map.Bounds.Height)) / 2;
MapRect = new Rectangle(RenderBounds.X + dw, RenderBounds.Y + dh, (int)(map.Bounds.Width * PreviewScale), (int)(map.Bounds.Height * PreviewScale));
}
Game.Renderer.RgbaSpriteRenderer.DrawSprite( mapChooserSprite,