Skip to content

Commit

Permalink
[HaCreator] Fix simulator -- minimap alignment if the lenght of the m…
Browse files Browse the repository at this point in the history
…apname is longer than map image
  • Loading branch information
lastbattle committed Dec 24, 2020
1 parent c5b2c53 commit 21fa0f1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion HaCreator/MapSimulator/MapSimulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public MapSimulator(Board mapBoard, string titleName)
PreferredBackBufferWidth = Math.Max(RenderWidth, 1),
PreferredBackBufferHeight = Math.Max(RenderHeight, 1),
PreferredBackBufferFormat = SurfaceFormat.Color,
PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8,
PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8,
};
_DxDeviceManager.ApplyChanges();

Expand Down
15 changes: 9 additions & 6 deletions HaCreator/MapSimulator/MapSimulatorLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ public static MinimapItem CreateMinimapFromProperty(WzSubProperty minimapFramePr

// Constants
const float TOOLTIP_FONTSIZE = 10f;
const int MAPMARK_IMAGE_ALIGN_LEFT = 7; // the number of pixels from the left to draw the map mark image
const int MAP_IMAGE_ALIGN_LEFT = 2; // the number of pixels from the left to draw the minimap image
System.Drawing.Color color_bgFill = System.Drawing.Color.Transparent;
System.Drawing.Color color_foreGround = System.Drawing.Color.White;

Expand All @@ -555,10 +557,11 @@ public static MinimapItem CreateMinimapFromProperty(WzSubProperty minimapFramePr

effective_width = Math.Max((int)tooltipSize.Width + nw.Width, effective_width); // set new width

System.Drawing.Bitmap miniMapUIImage = new System.Drawing.Bitmap(effective_width, effective_height);

int mapDrawPositionX = (effective_width / 2) - nw.Width; // map is on the center. The position relative to the UI
int miniMapAlignXFromLeft = MAP_IMAGE_ALIGN_LEFT;
if (effective_width > miniMapImage.Width) // if minimap is smaller in size than the (text + frame), minimap will be aligned to the center instead
miniMapAlignXFromLeft = (effective_width - miniMapImage.Width) / 2/* - miniMapAlignXFromLeft*/;

System.Drawing.Bitmap miniMapUIImage = new System.Drawing.Bitmap(effective_width, effective_height);
using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(miniMapUIImage))
{
// Frames and background
Expand All @@ -572,12 +575,12 @@ public static MinimapItem CreateMinimapFromProperty(WzSubProperty minimapFramePr
if (Program.InfoManager.MapMarks.ContainsKey(mapBoard.MapInfo.mapMark))
{
System.Drawing.Bitmap mapMark = Program.InfoManager.MapMarks[mapBoard.MapInfo.mapMark];
graphics.DrawImage(mapMark.ToImage(), 7, 17);
graphics.DrawImage(mapMark.ToImage(), MAPMARK_IMAGE_ALIGN_LEFT, 17);
}

// Map image
graphics.DrawImage(miniMapImage,
mapDrawPositionX, // map is on the center
miniMapAlignXFromLeft, // map is on the center
n.Height);

graphics.Flush();
Expand All @@ -594,7 +597,7 @@ public static MinimapItem CreateMinimapFromProperty(WzSubProperty minimapFramePr
BaseDXDrawableItem item_pixelDot = new BaseDXDrawableItem(dxObj_miniMapPixel, false)
{
Position = new Point(
mapDrawPositionX, // map is on the center
miniMapAlignXFromLeft, // map is on the center
0)
};

Expand Down
1 change: 1 addition & 0 deletions HaSharedLibrary/Render/BaseDXDrawableItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public BaseDXDrawableItem(IDXObject frame0, bool flip)
this._Position = new Point(0, 0);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected IDXObject GetCurrFrame(int TickCount)
{
if (notAnimated)
Expand Down

0 comments on commit 21fa0f1

Please sign in to comment.