* Added better indication of the fact overlay is blocked on the first and last row, and blocked it on walls too.
* PgUp/PgDown implementation on all tools * DPI fixes * Found and nuked a GDI+ object memory leak * Building tool now primarily uses the buildings layer on the map and not the technos one. Might split this up completely and get rid of the concept of blocking other types... * Pen colour in NavigationWidget now only changes if it's a different colour, or the pen object is not initialised.
This commit is contained in:
parent
91a8d515db
commit
2317a06511
15
CHANGELOG.md
15
CHANGELOG.md
@ -120,7 +120,7 @@ Released on 20 Aug 2022 at 22:37 UTC
|
||||
* Added \*.ini to the list of possible extensions for opening RA maps. Apparently before I only added it for saving.
|
||||
* The editor will now accept nonstandard extensions from drag & drop without any issues. For TD maps, it will need to find the accompanying bin or ini file with the correct extension.
|
||||
* Files opened from filenames with nonstandard extensions will not change these extensions when saving the file. This also means RA maps opened from a .ini file will no longer change the extension to .mpr when saving.
|
||||
* Terrain objects will now only pop up a poperties box for setting a trigger on TD maps.
|
||||
* Terrain objects will now only pop up a properties box for setting a trigger on TD maps.
|
||||
* Optimised loading so the editor will skip loading objects from different theaters.
|
||||
* User settings (game folder, invite warning, and the dialog locations) will now be properly ported over from previous versions.
|
||||
* Added support for loading mod xml info and graphics through the "ModsToLoad" setting in "CnCTDRAMapEditor.exe.config". The syntax is a semicolon-separated list, with each entry either a Steam workshop ID, or a folder under "Documents\CnCRemastered\Mods\". As folder, the path must contain the "Tiberian_Dawn" or "Red_Alert" part at the start. That prefix folder will also be used as consistency check for the mod type as defined inside "ccmod.json". Mods given by folder name will also be looked up in the Steam workshop folders, with the prefix folder used only for the consistency check. Mods do NOT have to be enabled in the game to work in the editor. [NOTE: game prefix requirement for paths removed when this was split into settings per game in v1.4.4.0]
|
||||
@ -197,6 +197,7 @@ Released on 22 Aug 2022 at 09:28 UTC
|
||||
* The title of the window will now show an asterisk behind the filename to indicate that the current file has unsaved changes.
|
||||
* Maps loaded from file are now seen as 'modified' if any issues were detected that made the editor change or discard data during the loading process.
|
||||
* The triggers check feedback (TD only) now also uses the large window used for showing the map load errors.
|
||||
* In Tiberian Dawn, buildings where "Prebuilt" is disabled will now show as House "None", with black team color, since Tiberian Dawn has no real restrictions on which House can build these.
|
||||
|
||||
### v1.4.2.0:
|
||||
|
||||
@ -441,3 +442,15 @@ Released on 03 Apr 2023 at 19:20 GMT
|
||||
* Celltriggers are now slightly more transparent when outside Celltrigger editing mode.
|
||||
* Added character count to the briefing screen. if WriteClassicBriefing is enabled a warning wil be given if the amount exceeds the maximum the classic game can handle. If the warning is ignored, the classic briefing will truncated on the maximum it can handle, to prevent game crashes.
|
||||
* Fixed saving of Red Alert's classic briefing, to also obey the classic internal maximum, and to correctly split on line break @ characters.
|
||||
|
||||
|
||||
### v1.4.5.1:
|
||||
|
||||
Unreleased
|
||||
|
||||
* All overlay placement is now correctly restricted to not be allowed on the top or bottom row of the map, showing red indicators when in placement mode.
|
||||
* Resource placement with a brush size larger than 1 shows red cells inside the brush area when hovering over the top or bottom cells of the map. At size 1, the brush is simply completely red.
|
||||
* Resource tool will accept PageUp and PageDown buttons for incrementing and decrementing its size.
|
||||
* Applied DPI changes that might fix issues with objects drawing weirdly on some people's systems.
|
||||
* PageUp and PageDown buttons will now consistently move through the tool list in all editing modes.
|
||||
* Removed [ and ] as shortcuts to affect resource paint size because they did not work consistently on foreign keyboards. The functionality was also changed to PageUp and PageDown.
|
||||
|
@ -70,6 +70,7 @@ namespace MobiusEditor.Controls
|
||||
{
|
||||
InitializeComponent();
|
||||
infoImage = new Bitmap(27, 27);
|
||||
infoImage.SetResolution(96, 96);
|
||||
using (Graphics g = Graphics.FromImage(infoImage))
|
||||
{
|
||||
g.DrawIcon(SystemIcons.Information, new Rectangle(0, 0, infoImage.Width, infoImage.Height));
|
||||
|
@ -54,6 +54,7 @@ namespace MobiusEditor.Controls
|
||||
{
|
||||
InitializeComponent();
|
||||
infoImage = new Bitmap(27, 27);
|
||||
infoImage.SetResolution(96, 96);
|
||||
using (Graphics g = Graphics.FromImage(infoImage))
|
||||
{
|
||||
g.DrawIcon(SystemIcons.Information, new Rectangle(0, 0, infoImage.Width, infoImage.Height));
|
||||
|
@ -277,6 +277,7 @@ namespace MobiusEditor.Dialogs
|
||||
using (Graphics gExportImage = Graphics.FromImage(exportImage))
|
||||
using (Bitmap overlaysImage = new Bitmap(fullSize.Width, fullSize.Height))
|
||||
{
|
||||
overlaysImage.SetResolution(96, 96);
|
||||
using (Graphics gOverlaysImage = Graphics.FromImage(overlaysImage))
|
||||
{
|
||||
ViewTool.PostRenderMap(gOverlaysImage, gamePlugin, gamePlugin.Map, scale, layers, MapLayerFlag.None, false);
|
||||
|
@ -196,10 +196,12 @@ namespace MobiusEditor.Dialogs
|
||||
int actualWidth = Math.Min(width, maxWidth);
|
||||
int actualHeight = Math.Min(height, maxHeight);
|
||||
finalImage = new Bitmap(actualWidth, actualHeight, PixelFormat.Format32bppArgb);
|
||||
finalImage.SetResolution(96, 96);
|
||||
byte[] imgData = new byte[imageData.Length];
|
||||
Array.Copy(imageData, 0, imgData, 0, imageData.Length);
|
||||
using (Bitmap origData = new Bitmap(width, height, PixelFormat.Format32bppArgb))
|
||||
{
|
||||
origData.SetResolution(96, 96);
|
||||
// Remove all alpha.
|
||||
for (Int32 i = 3; i < imgData.Length; i += 4)
|
||||
{
|
||||
|
@ -312,12 +312,15 @@ namespace MobiusEditor.Dialogs
|
||||
{
|
||||
try
|
||||
{
|
||||
(txtPreview.Tag as Image)?.Dispose();
|
||||
Bitmap preview = null;
|
||||
Bitmap preview = txtPreview.Tag as Bitmap;
|
||||
txtPreview.Tag = null;
|
||||
preview?.Dispose();
|
||||
preview = null;
|
||||
if (File.Exists(txtPreview.Text))
|
||||
{
|
||||
using (Bitmap b = new Bitmap(txtPreview.Text))
|
||||
{
|
||||
b.SetResolution(96, 96);
|
||||
preview = b.FitToBoundingBox(Globals.MapPreviewSize.Width, Globals.MapPreviewSize.Height, Color.Black);
|
||||
}
|
||||
}
|
||||
@ -356,6 +359,7 @@ namespace MobiusEditor.Dialogs
|
||||
// Now generates all contents.
|
||||
using (Bitmap pr = plugin.Map.GenerateWorkshopPreview(plugin.GameType, true).ToBitmap())
|
||||
{
|
||||
pr.SetResolution(96, 96);
|
||||
pr.Save(defaultPreview, ImageFormat.Png);
|
||||
}
|
||||
if (plugin.Map.BasicSection.SoloMission)
|
||||
|
@ -66,6 +66,7 @@ namespace MobiusEditor.Dialogs
|
||||
InitializeComponent();
|
||||
lblTooLong.Text = "Teamtype length exceeds " + maxLength + " characters!";
|
||||
infoImage = new Bitmap(27, 27);
|
||||
infoImage.SetResolution(96, 96);
|
||||
using (Graphics g = Graphics.FromImage(infoImage))
|
||||
{
|
||||
g.DrawIcon(SystemIcons.Information, new Rectangle(0, 0, infoImage.Width, infoImage.Height));
|
||||
@ -619,11 +620,7 @@ namespace MobiusEditor.Dialogs
|
||||
ttf.Dispose();
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
try
|
||||
{
|
||||
lblTriggerInfo.Image = null;
|
||||
}
|
||||
catch { /*ignore*/}
|
||||
lblTriggerInfo.Image = null;
|
||||
try
|
||||
{
|
||||
infoImage.Dispose();
|
||||
|
72
CnCTDRAMapEditor/MainForm.Designer.cs
generated
72
CnCTDRAMapEditor/MainForm.Designer.cs
generated
@ -77,8 +77,8 @@ namespace MobiusEditor
|
||||
this.toolsOptionsSafeDraggingMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolsOptionsRandomizeDragPlaceMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolsOptionsPlacementGridMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolsOptionsCratesOnTopMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolsOptionsOutlineAllCratesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolsOptionsCratesOnTopMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolsRandomizeTilesMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolsExportImageMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@ -121,7 +121,6 @@ namespace MobiusEditor
|
||||
this.copyrightStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.mouseToolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.mainToolStrip = new System.Windows.Forms.ToolStrip();
|
||||
this.mapPanel = new MobiusEditor.Controls.MapPanel();
|
||||
this.mapToolStripButton = new MobiusEditor.Controls.ViewToolStripButton();
|
||||
this.smudgeToolStripButton = new MobiusEditor.Controls.ViewToolStripButton();
|
||||
this.overlayToolStripButton = new MobiusEditor.Controls.ViewToolStripButton();
|
||||
@ -134,6 +133,7 @@ namespace MobiusEditor
|
||||
this.waypointsToolStripButton = new MobiusEditor.Controls.ViewToolStripButton();
|
||||
this.cellTriggersToolStripButton = new MobiusEditor.Controls.ViewToolStripButton();
|
||||
this.selectToolStripButton = new MobiusEditor.Controls.ViewToolStripButton();
|
||||
this.mapPanel = new MobiusEditor.Controls.MapPanel();
|
||||
this.mainMenuStrip.SuspendLayout();
|
||||
this.mainStatusStrip.SuspendLayout();
|
||||
this.mainToolStrip.SuspendLayout();
|
||||
@ -424,16 +424,6 @@ namespace MobiusEditor
|
||||
this.toolsOptionsPlacementGridMenuItem.Text = "Show &grid while placing / moving";
|
||||
this.toolsOptionsPlacementGridMenuItem.CheckedChanged += new System.EventHandler(this.ToolsOptionsPlacementGridMenuItem_CheckedChanged);
|
||||
//
|
||||
// toolsOptionsCratesOnTopMenuItem
|
||||
//
|
||||
this.toolsOptionsCratesOnTopMenuItem.Checked = true;
|
||||
this.toolsOptionsCratesOnTopMenuItem.CheckOnClick = true;
|
||||
this.toolsOptionsCratesOnTopMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.toolsOptionsCratesOnTopMenuItem.Name = "toolsOptionsCratesOnTopMenuItem";
|
||||
this.toolsOptionsCratesOnTopMenuItem.Size = new System.Drawing.Size(293, 22);
|
||||
this.toolsOptionsCratesOnTopMenuItem.Text = "Show crates on top of other objects";
|
||||
this.toolsOptionsCratesOnTopMenuItem.CheckedChanged += new System.EventHandler(this.ToolsOptionsCratesOnTopMenuItem_CheckedChanged);
|
||||
//
|
||||
// toolsOptionsOutlineAllCratesMenuItem
|
||||
//
|
||||
this.toolsOptionsOutlineAllCratesMenuItem.Checked = true;
|
||||
@ -444,6 +434,16 @@ namespace MobiusEditor
|
||||
this.toolsOptionsOutlineAllCratesMenuItem.Text = "Show crate outline indicators on all crates";
|
||||
this.toolsOptionsOutlineAllCratesMenuItem.Click += new System.EventHandler(this.toolsOptionsOutlineAllCratesMenuItem_Click);
|
||||
//
|
||||
// toolsOptionsCratesOnTopMenuItem
|
||||
//
|
||||
this.toolsOptionsCratesOnTopMenuItem.Checked = true;
|
||||
this.toolsOptionsCratesOnTopMenuItem.CheckOnClick = true;
|
||||
this.toolsOptionsCratesOnTopMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.toolsOptionsCratesOnTopMenuItem.Name = "toolsOptionsCratesOnTopMenuItem";
|
||||
this.toolsOptionsCratesOnTopMenuItem.Size = new System.Drawing.Size(293, 22);
|
||||
this.toolsOptionsCratesOnTopMenuItem.Text = "Show crates on top of other objects";
|
||||
this.toolsOptionsCratesOnTopMenuItem.CheckedChanged += new System.EventHandler(this.ToolsOptionsCratesOnTopMenuItem_CheckedChanged);
|
||||
//
|
||||
// toolsRandomizeTilesMenuItem
|
||||
//
|
||||
this.toolsRandomizeTilesMenuItem.Name = "toolsRandomizeTilesMenuItem";
|
||||
@ -482,7 +482,7 @@ namespace MobiusEditor
|
||||
this.viewLayersSmudgeMenuItem,
|
||||
this.viewLayersWaypointsMenuItem});
|
||||
this.viewLayersToolStripMenuItem.Name = "viewLayersToolStripMenuItem";
|
||||
this.viewLayersToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.viewLayersToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
|
||||
this.viewLayersToolStripMenuItem.Text = "&Layers";
|
||||
//
|
||||
// viewLayersEnableAllMenuItem
|
||||
@ -583,7 +583,7 @@ namespace MobiusEditor
|
||||
this.viewIndicatorsBuildingFakeLabelsMenuItem,
|
||||
this.viewIndicatorsCrateOutlinesMenuItem});
|
||||
this.viewIndicatorsToolStripMenuItem.Name = "viewIndicatorsToolStripMenuItem";
|
||||
this.viewIndicatorsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.viewIndicatorsToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
|
||||
this.viewIndicatorsToolStripMenuItem.Text = "&Indicators";
|
||||
//
|
||||
// viewIndicatorsEnableAllMenuItem
|
||||
@ -688,7 +688,7 @@ namespace MobiusEditor
|
||||
this.viewExtraIndicatorsEffectAreaRadiusMenuItem,
|
||||
this.viewExtraIndicatorsWaypointRevealRadiusMenuItem});
|
||||
this.viewExtraIndicatorsToolStripMenuItem.Name = "viewExtraIndicatorsToolStripMenuItem";
|
||||
this.viewExtraIndicatorsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.viewExtraIndicatorsToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
|
||||
this.viewExtraIndicatorsToolStripMenuItem.Text = "&Extra Indicators";
|
||||
//
|
||||
// viewExtraIndicatorsMapSymmetryMenuItem
|
||||
@ -835,27 +835,6 @@ namespace MobiusEditor
|
||||
this.mainToolStrip.Text = "toolStrip1";
|
||||
this.mainToolStrip.MouseMove += new System.Windows.Forms.MouseEventHandler(this.MainToolStrip_MouseMove);
|
||||
//
|
||||
// mapPanel
|
||||
//
|
||||
this.mapPanel.AllowDrop = true;
|
||||
this.mapPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32)))));
|
||||
this.mapPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.mapPanel.FocusOnMouseEnter = true;
|
||||
this.mapPanel.Location = new System.Drawing.Point(0, 55);
|
||||
this.mapPanel.MapImage = null;
|
||||
this.mapPanel.MaxZoom = 8D;
|
||||
this.mapPanel.MinZoom = 1D;
|
||||
this.mapPanel.Name = "mapPanel";
|
||||
this.mapPanel.Size = new System.Drawing.Size(1008, 484);
|
||||
this.mapPanel.SmoothScale = false;
|
||||
this.mapPanel.TabIndex = 4;
|
||||
this.mapPanel.Zoom = 1D;
|
||||
this.mapPanel.ZoomStep = 1D;
|
||||
this.mapPanel.PostRender += new System.EventHandler<MobiusEditor.Event.RenderEventArgs>(this.mapPanel_PostRender);
|
||||
this.mapPanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.MapPanel_DragDrop);
|
||||
this.mapPanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.MapPanel_DragEnter);
|
||||
this.mapPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.MapPanel_MouseMove);
|
||||
//
|
||||
// mapToolStripButton
|
||||
//
|
||||
this.mapToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("mapToolStripButton.Image")));
|
||||
@ -977,6 +956,27 @@ namespace MobiusEditor
|
||||
this.selectToolStripButton.Visible = false;
|
||||
this.selectToolStripButton.Click += new System.EventHandler(this.mainToolStripButton_Click);
|
||||
//
|
||||
// mapPanel
|
||||
//
|
||||
this.mapPanel.AllowDrop = true;
|
||||
this.mapPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32)))));
|
||||
this.mapPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.mapPanel.FocusOnMouseEnter = true;
|
||||
this.mapPanel.Location = new System.Drawing.Point(0, 55);
|
||||
this.mapPanel.MapImage = null;
|
||||
this.mapPanel.MaxZoom = 8D;
|
||||
this.mapPanel.MinZoom = 1D;
|
||||
this.mapPanel.Name = "mapPanel";
|
||||
this.mapPanel.Size = new System.Drawing.Size(1008, 484);
|
||||
this.mapPanel.SmoothScale = false;
|
||||
this.mapPanel.TabIndex = 4;
|
||||
this.mapPanel.Zoom = 1D;
|
||||
this.mapPanel.ZoomStep = 1D;
|
||||
this.mapPanel.PostRender += new System.EventHandler<MobiusEditor.Event.RenderEventArgs>(this.mapPanel_PostRender);
|
||||
this.mapPanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.MapPanel_DragDrop);
|
||||
this.mapPanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.MapPanel_DragEnter);
|
||||
this.mapPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.MapPanel_MouseMove);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
@ -1351,6 +1351,7 @@ namespace MobiusEditor
|
||||
{
|
||||
using (Bitmap bm = new Bitmap(imagePath))
|
||||
{
|
||||
bm.SetResolution(96, 96);
|
||||
imageWidth = bm.Width;
|
||||
imageHeight = bm.Height;
|
||||
imageData = ImageUtils.GetImageData(bm, PixelFormat.Format32bppArgb);
|
||||
|
@ -259,6 +259,7 @@ namespace MobiusEditor.Model
|
||||
if (!render.Item1.IsEmpty)
|
||||
{
|
||||
var th = new Bitmap(render.Item1.Width, render.Item1.Height);
|
||||
th.SetResolution(96, 96);
|
||||
using (var g = Graphics.FromImage(th))
|
||||
{
|
||||
MapRenderer.SetRenderSettings(g, Globals.PreviewSmoothScale);
|
||||
|
@ -138,6 +138,7 @@ namespace MobiusEditor.Model
|
||||
var oldImage = Thumbnail;
|
||||
var tileSize = Globals.PreviewTileSize;
|
||||
Bitmap th = new Bitmap(tileSize.Width * Size.Width, tileSize.Height * Size.Height);
|
||||
th.SetResolution(96, 96);
|
||||
bool found = false;
|
||||
using (Graphics g = Graphics.FromImage(th))
|
||||
{
|
||||
|
@ -354,9 +354,10 @@ namespace MobiusEditor.Model
|
||||
// To avoid having to redo the calculations on random tiles.
|
||||
ThumbnailIconWidth = loopWidth;
|
||||
ThumbnailIconHeight = loopHeight;
|
||||
var thumbnail = new Bitmap(loopWidth * size.Width, loopHeight * size.Height);
|
||||
var th = new Bitmap(loopWidth * size.Width, loopHeight * size.Height);
|
||||
th.SetResolution(96, 96);
|
||||
bool found = mask[0, 0];
|
||||
using (var g = Graphics.FromImage(thumbnail))
|
||||
using (var g = Graphics.FromImage(th))
|
||||
{
|
||||
MapRenderer.SetRenderSettings(g, Globals.PreviewSmoothScale);
|
||||
g.Clear(Color.Transparent);
|
||||
@ -409,10 +410,10 @@ namespace MobiusEditor.Model
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
try { thumbnail.Dispose(); }
|
||||
try { th.Dispose(); }
|
||||
catch { /* ignore */ }
|
||||
}
|
||||
Thumbnail = found ? thumbnail : null;
|
||||
Thumbnail = found ? th : null;
|
||||
IconMask = mask;
|
||||
if (oldImage != null)
|
||||
{
|
||||
|
@ -191,6 +191,7 @@ namespace MobiusEditor.Model
|
||||
var renderSize = new Size(tileSize.Width * Size.Width, tileSize.Height * Size.Height);
|
||||
Rectangle overlayBounds = MapRenderer.RenderBounds(tile.Image.Size, Size, Globals.PreviewTileScale);
|
||||
Bitmap th = new Bitmap(renderSize.Width, renderSize.Height);
|
||||
th.SetResolution(96, 96);
|
||||
using (Graphics g = Graphics.FromImage(th))
|
||||
{
|
||||
MapRenderer.SetRenderSettings(g, Globals.PreviewSmoothScale);
|
||||
|
@ -149,9 +149,13 @@ namespace MobiusEditor.Model
|
||||
Strength = 256,
|
||||
Direction = direction
|
||||
};
|
||||
// Renderer draws a border of a full cell around the unit. In practice this is excessive,
|
||||
// so for a nicer preview we use only half a cell around.
|
||||
var unitThumbnail = new Bitmap(Globals.PreviewTileWidth * 2, Globals.PreviewTileHeight * 2);
|
||||
unitThumbnail.SetResolution(96, 96);
|
||||
using (Bitmap bigThumbnail = new Bitmap(Globals.PreviewTileWidth * 3, Globals.PreviewTileHeight * 3))
|
||||
{
|
||||
bigThumbnail.SetResolution(96, 96);
|
||||
using (var g = Graphics.FromImage(bigThumbnail))
|
||||
{
|
||||
MapRenderer.SetRenderSettings(g, Globals.PreviewSmoothScale);
|
||||
|
@ -22,6 +22,7 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
@ -36,6 +37,7 @@ namespace MobiusEditor
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
TryEnableDPIAware();
|
||||
const string gameId = "1213210";
|
||||
// Change current culture to en-US
|
||||
if (Thread.CurrentThread.CurrentCulture.Name != "en-US")
|
||||
@ -177,6 +179,34 @@ namespace MobiusEditor
|
||||
}
|
||||
Globals.TheMegafileManager.Dispose();
|
||||
}
|
||||
[DllImport("SHCore.dll")]
|
||||
private static extern bool SetProcessDpiAwareness(PROCESS_DPI_AWARENESS awareness);
|
||||
|
||||
private enum PROCESS_DPI_AWARENESS
|
||||
{
|
||||
Process_DPI_Unaware = 0,
|
||||
Process_System_DPI_Aware = 1,
|
||||
Process_Per_Monitor_DPI_Aware = 2
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern bool SetProcessDPIAware();
|
||||
|
||||
internal static void TryEnableDPIAware()
|
||||
{
|
||||
try
|
||||
{
|
||||
SetProcessDpiAwareness(PROCESS_DPI_AWARENESS.Process_Per_Monitor_DPI_Aware);
|
||||
}
|
||||
catch
|
||||
{
|
||||
try
|
||||
{ // fallback, use (simpler) internal function
|
||||
SetProcessDPIAware();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
private static string[] GetModPaths(string gameId, string modstoLoad, string modFolder, string modIdentifier)
|
||||
{
|
||||
|
@ -441,7 +441,9 @@ namespace MobiusEditor.RedAlert
|
||||
Map.MapSection.PropertyChanged += MapSection_PropertyChanged;
|
||||
if (mapImage)
|
||||
{
|
||||
MapImage = new Bitmap(Map.Metrics.Width * Globals.MapTileWidth, Map.Metrics.Height * Globals.MapTileHeight);
|
||||
Bitmap mapImg = new Bitmap(Map.Metrics.Width * Globals.MapTileWidth, Map.Metrics.Height * Globals.MapTileHeight);
|
||||
mapImg.SetResolution(96, 96);
|
||||
MapImage = mapImg;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -587,6 +587,7 @@ namespace MobiusEditor.Render
|
||||
// Avoid overlay showing as semiitransparent.
|
||||
using (Bitmap factory = new Bitmap(maxSize.Width, maxSize.Height))
|
||||
{
|
||||
factory.SetResolution(96, 96);
|
||||
using (Graphics factoryG = Graphics.FromImage(factory))
|
||||
{
|
||||
var factBounds = RenderBounds(tile.Image.Size, building.Type.Size, tileScale);
|
||||
@ -839,6 +840,7 @@ namespace MobiusEditor.Render
|
||||
// Combine body and turret to one image, then paint it. This is done because it might be semitransparent.
|
||||
using (Bitmap unitBm = new Bitmap(renderBounds.Width, renderBounds.Height))
|
||||
{
|
||||
unitBm.SetResolution(96, 96);
|
||||
using (Graphics unitG = Graphics.FromImage(unitBm))
|
||||
{
|
||||
if (tile != null) {
|
||||
@ -1216,6 +1218,7 @@ namespace MobiusEditor.Render
|
||||
int actualOutlineY = (int)Math.Max(1, outline * tileSize.Height);
|
||||
using (Bitmap bm = new Bitmap(tileSize.Width, tileSize.Height, PixelFormat.Format32bppArgb))
|
||||
{
|
||||
bm.SetResolution(96, 96);
|
||||
using (Graphics g2 = Graphics.FromImage(bm))
|
||||
{
|
||||
g2.DrawImage(tile.Image, relOverlayBounds, 0, 0, tile.Image.Width, tile.Image.Height, GraphicsUnit.Pixel);
|
||||
|
@ -146,7 +146,9 @@ namespace MobiusEditor.SoleSurvivor
|
||||
}
|
||||
if (mapImage)
|
||||
{
|
||||
MapImage = new Bitmap(Map.Metrics.Width * Globals.MapTileWidth, Map.Metrics.Height * Globals.MapTileHeight);
|
||||
Bitmap mapImg = new Bitmap(Map.Metrics.Width * Globals.MapTileWidth, Map.Metrics.Height * Globals.MapTileHeight);
|
||||
mapImg.SetResolution(96, 96);
|
||||
MapImage = mapImg;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,9 @@ namespace MobiusEditor.TiberianDawn
|
||||
Map.MapSection.PropertyChanged += MapSection_PropertyChanged;
|
||||
if (mapImage)
|
||||
{
|
||||
MapImage = new Bitmap(Map.Metrics.Width * Globals.MapTileWidth, Map.Metrics.Height * Globals.MapTileHeight);
|
||||
Bitmap mapImg = new Bitmap(Map.Metrics.Width * Globals.MapTileWidth, Map.Metrics.Height * Globals.MapTileHeight);
|
||||
mapImg.SetResolution(96, 96);
|
||||
MapImage = mapImg;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ namespace MobiusEditor.Tools
|
||||
}
|
||||
if (map.Metrics.GetCell(navigationWidget.MouseCell, out int cell))
|
||||
{
|
||||
if (map.Technos[cell] is Building building)
|
||||
if (map.Buildings[cell] is Building building)
|
||||
{
|
||||
selectedBuilding = null;
|
||||
selectedBuildingLocation = null;
|
||||
@ -205,6 +205,10 @@ namespace MobiusEditor.Tools
|
||||
{
|
||||
EnterPlacementMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckSelectShortcuts(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildingTool_KeyUp(object sender, KeyEventArgs e)
|
||||
@ -272,7 +276,7 @@ namespace MobiusEditor.Tools
|
||||
|
||||
private void AddMoveUndoTracking(Building toMove, Point startLocation)
|
||||
{
|
||||
Point? finalLocation = map.Technos[toMove];
|
||||
Point? finalLocation = map.Buildings[toMove];
|
||||
Dictionary<Point, Smudge> eaten = selectedBuildingEatenSmudge.ToDictionary(p => p.Key, p => p.Value);
|
||||
if (!finalLocation.HasValue || finalLocation.Value == selectedBuildingLocation)
|
||||
{
|
||||
@ -348,7 +352,7 @@ namespace MobiusEditor.Tools
|
||||
startedDragging = true;
|
||||
}
|
||||
Building toMove = selectedBuilding;
|
||||
var oldLocation = map.Technos[toMove].Value;
|
||||
var oldLocation = map.Buildings[toMove].Value;
|
||||
var newLocation = new Point(Math.Max(0, e.NewCell.X - selectedBuildingPivot.X), Math.Max(0, e.NewCell.Y - selectedBuildingPivot.Y));
|
||||
mapPanel.Invalidate(map, toMove);
|
||||
Point[] oldBibPoints = null;
|
||||
@ -604,6 +608,39 @@ namespace MobiusEditor.Tools
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckSelectShortcuts(KeyEventArgs e)
|
||||
{
|
||||
int maxVal = buildingTypesBox.Items.Count - 1;
|
||||
int curVal = buildingTypesBox.SelectedIndex;
|
||||
int newVal;
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Home:
|
||||
newVal = 0;
|
||||
break;
|
||||
case Keys.End:
|
||||
newVal = maxVal;
|
||||
break;
|
||||
case Keys.PageDown:
|
||||
newVal = Math.Min(curVal + 1, maxVal);
|
||||
break;
|
||||
case Keys.PageUp:
|
||||
newVal = Math.Max(curVal - 1, 0);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (curVal != newVal)
|
||||
{
|
||||
buildingTypesBox.SelectedIndex = newVal;
|
||||
BuildingType selected = SelectedBuildingType;
|
||||
if (placementMode && selected != null)
|
||||
{
|
||||
mapPanel.Invalidate(map, new Rectangle(navigationWidget.MouseCell, selected.OverlapBounds.Size));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EnterPlacementMode()
|
||||
{
|
||||
if (placementMode)
|
||||
@ -702,6 +739,7 @@ namespace MobiusEditor.Tools
|
||||
var renderBuilding = MapRenderer.Render(plugin.GameType, map.Theater, new Point(0, 0), Globals.PreviewTileSize, Globals.PreviewTileScale, mockBuilding);
|
||||
Size previewSize = mockBuilding.OverlapBounds.Size;
|
||||
var buildingPreview = new Bitmap(previewSize.Width * Globals.PreviewTileWidth, previewSize.Height * Globals.PreviewTileHeight);
|
||||
buildingPreview.SetResolution(96, 96);
|
||||
using (var g = Graphics.FromImage(buildingPreview))
|
||||
{
|
||||
MapRenderer.SetRenderSettings(g, Globals.PreviewSmoothScale);
|
||||
|
@ -36,6 +36,7 @@ namespace MobiusEditor.Tools.Dialogs
|
||||
{
|
||||
InitializeComponent();
|
||||
infoImage = new Bitmap(27, 27);
|
||||
infoImage.SetResolution(96, 96);
|
||||
using (Graphics g = Graphics.FromImage(infoImage))
|
||||
{
|
||||
g.DrawIcon(SystemIcons.Information, new Rectangle(0, 0, infoImage.Width, infoImage.Height));
|
||||
|
@ -248,6 +248,10 @@ namespace MobiusEditor.Tools
|
||||
{
|
||||
EnterPlacementMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckSelectShortcuts(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void InfantryTool_KeyUp(object sender, KeyEventArgs e)
|
||||
@ -612,6 +616,38 @@ namespace MobiusEditor.Tools
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckSelectShortcuts(KeyEventArgs e)
|
||||
{
|
||||
int maxVal = infantryTypesBox.Items.Count - 1;
|
||||
int curVal = infantryTypesBox.SelectedIndex;
|
||||
int newVal;
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Home:
|
||||
newVal = 0;
|
||||
break;
|
||||
case Keys.End:
|
||||
newVal = maxVal;
|
||||
break;
|
||||
case Keys.PageDown:
|
||||
newVal = Math.Min(curVal + 1, maxVal);
|
||||
break;
|
||||
case Keys.PageUp:
|
||||
newVal = Math.Max(curVal - 1, 0);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (curVal != newVal)
|
||||
{
|
||||
infantryTypesBox.SelectedIndex = newVal;
|
||||
if (placementMode)
|
||||
{
|
||||
mapPanel.Invalidate(map, Rectangle.Inflate(new Rectangle(navigationWidget.MouseCell, new Size(1, 1)), 1, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EnterPlacementMode()
|
||||
{
|
||||
if (placementMode)
|
||||
@ -692,6 +728,7 @@ namespace MobiusEditor.Tools
|
||||
if (mockInfantry.Type != null)
|
||||
{
|
||||
var infantryPreview = new Bitmap(Globals.PreviewTileWidth, Globals.PreviewTileHeight);
|
||||
infantryPreview.SetResolution(96, 96);
|
||||
using (var g = Graphics.FromImage(infantryPreview))
|
||||
{
|
||||
MapRenderer.SetRenderSettings(g, Globals.PreviewSmoothScale);
|
||||
|
@ -94,6 +94,10 @@ namespace MobiusEditor.Tools
|
||||
{
|
||||
EnterPlacementMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckSelectShortcuts(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void OverlaysTool_KeyUp(object sender, KeyEventArgs e)
|
||||
@ -150,33 +154,34 @@ namespace MobiusEditor.Tools
|
||||
|
||||
private void MouseoverWidget_MouseCellChanged(object sender, MouseCellChangedEventArgs e)
|
||||
{
|
||||
Point mouseCell = e.NewCell;
|
||||
if (placementMode)
|
||||
{
|
||||
if (Control.MouseButtons == MouseButtons.Left)
|
||||
{
|
||||
AddOverlay(e.NewCell);
|
||||
AddOverlay(mouseCell);
|
||||
}
|
||||
else if (Control.MouseButtons == MouseButtons.Right)
|
||||
{
|
||||
RemoveOverlay(e.NewCell);
|
||||
RemoveOverlay(mouseCell);
|
||||
}
|
||||
if (SelectedOverlayType != null)
|
||||
{
|
||||
// For Concrete
|
||||
mapPanel.Invalidate(map, Rectangle.Inflate(new Rectangle(e.OldCell, new Size(1, 1)), 1, 1));
|
||||
mapPanel.Invalidate(map, Rectangle.Inflate(new Rectangle(e.NewCell, new Size(1, 1)), 1, 1));
|
||||
mapPanel.Invalidate(map, Rectangle.Inflate(new Rectangle(mouseCell, new Size(1, 1)), 1, 1));
|
||||
}
|
||||
}
|
||||
else if ((e.MouseButtons == MouseButtons.Left) || (e.MouseButtons == MouseButtons.Right))
|
||||
{
|
||||
PickOverlay(e.NewCell);
|
||||
PickOverlay(mouseCell);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddOverlay(Point location)
|
||||
{
|
||||
OverlayType selected = SelectedOverlayType;
|
||||
// Can't place overlay on top and bottom row, for some odd reason.
|
||||
// Can't place overlay on top and bottom row. See OverlayClass::Read_INI
|
||||
if (selected == null || location.Y == 0 || location.Y == map.Metrics.Height - 1)
|
||||
{
|
||||
return;
|
||||
@ -257,6 +262,38 @@ namespace MobiusEditor.Tools
|
||||
url.Track(undoAction, redoAction);
|
||||
}
|
||||
|
||||
private void CheckSelectShortcuts(KeyEventArgs e)
|
||||
{
|
||||
int maxVal = overlayTypeComboBox.Items.Count - 1;
|
||||
int curVal = overlayTypeComboBox.SelectedIndex;
|
||||
int newVal;
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Home:
|
||||
newVal = 0;
|
||||
break;
|
||||
case Keys.End:
|
||||
newVal = maxVal;
|
||||
break;
|
||||
case Keys.PageDown:
|
||||
newVal = Math.Min(curVal + 1, maxVal);
|
||||
break;
|
||||
case Keys.PageUp:
|
||||
newVal = Math.Max(curVal - 1, 0);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (curVal != newVal)
|
||||
{
|
||||
overlayTypeComboBox.SelectedIndex = newVal;
|
||||
if (placementMode)
|
||||
{
|
||||
mapPanel.Invalidate(map, navigationWidget.MouseCell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EnterPlacementMode()
|
||||
{
|
||||
if (placementMode)
|
||||
@ -265,6 +302,7 @@ namespace MobiusEditor.Tools
|
||||
}
|
||||
placementMode = true;
|
||||
navigationWidget.MouseoverSize = Size.Empty;
|
||||
navigationWidget.PenColor = Color.Red;
|
||||
if (SelectedOverlayType != null)
|
||||
{
|
||||
mapPanel.Invalidate(map, Rectangle.Inflate(new Rectangle(navigationWidget.MouseCell, new Size(1, 1)), 1, 1));
|
||||
@ -280,6 +318,7 @@ namespace MobiusEditor.Tools
|
||||
}
|
||||
placementMode = false;
|
||||
navigationWidget.MouseoverSize = new Size(1, 1);
|
||||
navigationWidget.PenColor = Color.Yellow;
|
||||
if (SelectedOverlayType != null)
|
||||
{
|
||||
mapPanel.Invalidate(map, Rectangle.Inflate(new Rectangle(navigationWidget.MouseCell, new Size(1, 1)), 1, 1));
|
||||
@ -306,6 +345,7 @@ namespace MobiusEditor.Tools
|
||||
if (SelectedOverlayType != null)
|
||||
{
|
||||
var overlayPreview = new Bitmap(Globals.PreviewTileWidth, Globals.PreviewTileHeight);
|
||||
overlayPreview.SetResolution(96, 96);
|
||||
Overlay mockOverlay = new Overlay()
|
||||
{
|
||||
Type = SelectedOverlayType,
|
||||
@ -361,20 +401,25 @@ namespace MobiusEditor.Tools
|
||||
{
|
||||
base.PreRenderMap();
|
||||
previewMap = map.Clone(true);
|
||||
if (placementMode)
|
||||
if (!placementMode)
|
||||
{
|
||||
var location = navigationWidget.MouseCell;
|
||||
if (SelectedOverlayType != null)
|
||||
{
|
||||
if (previewMap.Metrics.GetCell(location, out int cell))
|
||||
{
|
||||
if (previewMap.Overlay[cell] == null)
|
||||
{
|
||||
previewMap.Overlay[cell] = new Overlay { Type = SelectedOverlayType, Icon = 0, Tint = Color.FromArgb(128, SelectedOverlayType.Tint) };
|
||||
mapPanel.Invalidate(previewMap, Rectangle.Inflate(new Rectangle(location, new Size(1, 1)), 1, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
navigationWidget.MouseoverSize = Size.Empty;
|
||||
var location = navigationWidget.MouseCell;
|
||||
OverlayType selected = this.SelectedOverlayType;
|
||||
if (selected == null || !previewMap.Metrics.GetCell(location, out int cell))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (location.Y == 0 || location.Y == map.Metrics.Height - 1)
|
||||
{
|
||||
navigationWidget.MouseoverSize = new Size(1, 1);
|
||||
}
|
||||
if (previewMap.Overlay[cell] == null)
|
||||
{
|
||||
previewMap.Overlay[cell] = new Overlay { Type = SelectedOverlayType, Icon = 0, Tint = Color.FromArgb(128, SelectedOverlayType.Tint) };
|
||||
mapPanel.Invalidate(previewMap, Rectangle.Inflate(new Rectangle(location, new Size(1, 1)), 1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -385,7 +430,9 @@ namespace MobiusEditor.Tools
|
||||
{
|
||||
MapRenderer.RenderAllCrateOutlines(graphics, previewMap, Globals.MapTileSize, Globals.MapTileScale, false);
|
||||
}
|
||||
MapRenderer.RenderAllBoundsFromCell(graphics, Globals.MapTileSize, previewMap.Overlay.Where(x => x.Value.Type.IsOverlay), previewMap.Metrics);
|
||||
int secondRow = map.Metrics.Width;
|
||||
int lastRow = map.Metrics.Length - map.Metrics.Width;
|
||||
MapRenderer.RenderAllBoundsFromCell(graphics, Globals.MapTileSize, previewMap.Overlay.Where(x => x.Value.Type.IsOverlay && x.Cell >= secondRow && x.Cell < lastRow), previewMap.Metrics);
|
||||
}
|
||||
|
||||
public override void Activate()
|
||||
|
@ -80,6 +80,7 @@ namespace MobiusEditor.Tools
|
||||
else
|
||||
{
|
||||
navigationWidget.MouseoverSize = new Size((int)brushSizeNud.Value, (int)brushSizeNud.Value);
|
||||
CheckRedPenEdges();
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,12 +95,12 @@ namespace MobiusEditor.Tools
|
||||
|
||||
private void ResourceTool_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.OemOpenBrackets)
|
||||
if (e.KeyCode == Keys.PageDown)
|
||||
{
|
||||
brushSizeNud.DownButton();
|
||||
mapPanel.Invalidate();
|
||||
}
|
||||
else if (e.KeyCode == Keys.OemCloseBrackets)
|
||||
else if (e.KeyCode == Keys.PageUp)
|
||||
{
|
||||
brushSizeNud.UpButton();
|
||||
mapPanel.Invalidate();
|
||||
@ -153,6 +154,7 @@ namespace MobiusEditor.Tools
|
||||
|
||||
private void MouseoverWidget_MouseCellChanged(object sender, MouseCellChangedEventArgs e)
|
||||
{
|
||||
CheckRedPenEdges();
|
||||
if (placementMode)
|
||||
{
|
||||
if (additivePlacement)
|
||||
@ -164,20 +166,6 @@ namespace MobiusEditor.Tools
|
||||
RemoveResource(e.NewCell);
|
||||
}
|
||||
}
|
||||
/*/
|
||||
// This code doesn't function. Thankfully, resources don't actually paint a preview anyway.
|
||||
// MapToClient seems fundamentally broken; it requires coordinates of the mouse at image scale.
|
||||
if (brushSizeNud.Value > 1)
|
||||
{
|
||||
foreach (var cell in new Point[] { e.OldCell, e.NewCell })
|
||||
{
|
||||
mapPanel.Invalidate(mapPanel.MapToClient(new Rectangle(
|
||||
new Point(cell.X - ((int)brushSizeNud.Value / 2), cell.Y - ((int)brushSizeNud.Value / 2)),
|
||||
new Size((int)brushSizeNud.Value, (int)brushSizeNud.Value)
|
||||
)));
|
||||
}
|
||||
}
|
||||
//*/
|
||||
}
|
||||
|
||||
private void AddResource(Point location)
|
||||
@ -193,7 +181,7 @@ namespace MobiusEditor.Tools
|
||||
rectangle.Inflate(navigationWidget.MouseoverSize.Width / 2, navigationWidget.MouseoverSize.Height / 2);
|
||||
foreach (var subLocation in rectangle.Points())
|
||||
{
|
||||
// Can't place overlay on top and bottom row, for some odd reason.
|
||||
// Can't place overlay on top and bottom row. See OverlayClass::Read_INI
|
||||
if (subLocation.Y == 0 || subLocation.Y == map.Metrics.Height - 1)
|
||||
{
|
||||
continue;
|
||||
@ -241,6 +229,20 @@ namespace MobiusEditor.Tools
|
||||
Update();
|
||||
}
|
||||
|
||||
private void CheckRedPenEdges()
|
||||
{
|
||||
// Only check if size is 1x1; otherwise it'll be marked by PostRenderMap.
|
||||
if (navigationWidget.MouseoverSize.Width == 1 && navigationWidget.MouseoverSize.Height == 1
|
||||
&& navigationWidget.MouseCell.Y == 0 || navigationWidget.MouseCell.Y == map.Metrics.Height - 1)
|
||||
{
|
||||
navigationWidget.PenColor = Color.Red;
|
||||
}
|
||||
else
|
||||
{
|
||||
navigationWidget.PenColor = Color.Yellow;
|
||||
}
|
||||
}
|
||||
|
||||
private void EnterPlacementMode(bool additive)
|
||||
{
|
||||
if (placementMode)
|
||||
@ -348,7 +350,20 @@ namespace MobiusEditor.Tools
|
||||
protected override void PostRenderMap(Graphics graphics)
|
||||
{
|
||||
base.PostRenderMap(graphics);
|
||||
List<int> redCells = new List<int>();
|
||||
Rectangle rectangle = new Rectangle(navigationWidget.MouseCell, new Size(1, 1));
|
||||
rectangle.Inflate(navigationWidget.MouseoverSize.Width / 2, navigationWidget.MouseoverSize.Height / 2);
|
||||
int lastRow = map.Metrics.Height - 1;
|
||||
foreach (var subLocation in rectangle.Points())
|
||||
{
|
||||
// Can't place overlay on top and bottom row. See OverlayClass::Read_INI
|
||||
if ((subLocation.Y == 0 || subLocation.Y == lastRow) && map.Metrics.GetCell(subLocation, out int cell))
|
||||
{
|
||||
redCells.Add(cell);
|
||||
}
|
||||
}
|
||||
MapRenderer.RenderAllBoundsFromCell(graphics, Globals.MapTileSize, map.Overlay.Where(x => x.Value.Type.IsResource), map.Metrics);
|
||||
MapRenderer.RenderAllBoundsFromCell(graphics, Globals.MapTileSize, redCells, map.Metrics, Color.Red);
|
||||
}
|
||||
|
||||
public override void Activate()
|
||||
|
@ -193,6 +193,10 @@ namespace MobiusEditor.Tools
|
||||
{
|
||||
EnterPlacementMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckSelectShortcuts(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void SmudgeTool_KeyUp(object sender, KeyEventArgs e)
|
||||
@ -474,6 +478,39 @@ namespace MobiusEditor.Tools
|
||||
return found;
|
||||
}
|
||||
|
||||
private void CheckSelectShortcuts(KeyEventArgs e)
|
||||
{
|
||||
int maxVal = smudgeTypeListBox.Items.Count - 1;
|
||||
int curVal = smudgeTypeListBox.SelectedIndex;
|
||||
int newVal;
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Home:
|
||||
newVal = 0;
|
||||
break;
|
||||
case Keys.End:
|
||||
newVal = maxVal;
|
||||
break;
|
||||
case Keys.PageDown:
|
||||
newVal = Math.Min(curVal + 1, maxVal);
|
||||
break;
|
||||
case Keys.PageUp:
|
||||
newVal = Math.Max(curVal - 1, 0);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (curVal != newVal)
|
||||
{
|
||||
smudgeTypeListBox.SelectedIndex = newVal;
|
||||
SmudgeType selected = SelectedSmudgeType;
|
||||
if (placementMode && selected != null)
|
||||
{
|
||||
mapPanel.Invalidate(map, new Rectangle(navigationWidget.MouseCell, selected.Size));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EnterPlacementMode()
|
||||
{
|
||||
if (placementMode)
|
||||
@ -545,6 +582,7 @@ namespace MobiusEditor.Tools
|
||||
Size mockSize = mockType.Size;
|
||||
CellMetrics mockMetrics = new CellMetrics(mockSize);
|
||||
var smudgePreview = new Bitmap(Globals.PreviewTileWidth * mockSize.Width, Globals.PreviewTileWidth * mockSize.Height);
|
||||
smudgePreview.SetResolution(96, 96);
|
||||
using (var g = Graphics.FromImage(smudgePreview))
|
||||
{
|
||||
MapRenderer.SetRenderSettings(g, Globals.PreviewSmoothScale);
|
||||
|
@ -417,10 +417,10 @@ namespace MobiusEditor.Tools
|
||||
ExitAllModes();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ExitAllModes();
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// ExitAllModes();
|
||||
//}
|
||||
}
|
||||
|
||||
private void TemplateTool_KeyUp(object sender, KeyEventArgs e)
|
||||
@ -1236,6 +1236,10 @@ namespace MobiusEditor.Tools
|
||||
|
||||
private void UpdateTooltip()
|
||||
{
|
||||
if (!placementMode)
|
||||
{
|
||||
|
||||
}
|
||||
FacingType showEdge = dragEdge != FacingType.None ? dragEdge : DetectDragEdge(dragStartPoint.HasValue);
|
||||
if (boundsMode && (showEdge != FacingType.None || (dragStartPoint.HasValue && dragStartBounds.HasValue)))
|
||||
{
|
||||
|
@ -197,6 +197,10 @@ namespace MobiusEditor.Tools
|
||||
{
|
||||
EnterPlacementMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckSelectShortcuts(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void TerrainTool_KeyUp(object sender, KeyEventArgs e)
|
||||
@ -400,6 +404,39 @@ namespace MobiusEditor.Tools
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckSelectShortcuts(KeyEventArgs e)
|
||||
{
|
||||
int maxVal = terrainTypeListBox.Items.Count - 1;
|
||||
int curVal = terrainTypeListBox.SelectedIndex;
|
||||
int newVal;
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Home:
|
||||
newVal = 0;
|
||||
break;
|
||||
case Keys.End:
|
||||
newVal = maxVal;
|
||||
break;
|
||||
case Keys.PageDown:
|
||||
newVal = Math.Min(curVal + 1, maxVal);
|
||||
break;
|
||||
case Keys.PageUp:
|
||||
newVal = Math.Max(curVal - 1, 0);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (curVal != newVal)
|
||||
{
|
||||
terrainTypeListBox.SelectedIndex = newVal;
|
||||
TerrainType selected = SelectedTerrainType;
|
||||
if (placementMode && selected != null)
|
||||
{
|
||||
mapPanel.Invalidate(map, new Rectangle(navigationWidget.MouseCell, selected.OverlapBounds.Size));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EnterPlacementMode()
|
||||
{
|
||||
if (placementMode)
|
||||
@ -467,6 +504,7 @@ namespace MobiusEditor.Tools
|
||||
{
|
||||
Size previewSize = mockTerrain.Type.OverlapBounds.Size;
|
||||
var terrainPreview = new Bitmap(previewSize.Width * Globals.PreviewTileWidth, previewSize.Height * Globals.PreviewTileHeight);
|
||||
terrainPreview.SetResolution(96, 96);
|
||||
using (var g = Graphics.FromImage(terrainPreview))
|
||||
{
|
||||
MapRenderer.SetRenderSettings(g, Globals.PreviewSmoothScale);
|
||||
|
@ -239,6 +239,10 @@ namespace MobiusEditor.Tools
|
||||
{
|
||||
EnterPlacementMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckSelectShortcuts(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void UnitTool_KeyUp(object sender, KeyEventArgs e)
|
||||
@ -443,6 +447,38 @@ namespace MobiusEditor.Tools
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckSelectShortcuts(KeyEventArgs e)
|
||||
{
|
||||
int maxVal = unitTypesBox.Items.Count - 1;
|
||||
int curVal = unitTypesBox.SelectedIndex;
|
||||
int newVal;
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Home:
|
||||
newVal = 0;
|
||||
break;
|
||||
case Keys.End:
|
||||
newVal = maxVal;
|
||||
break;
|
||||
case Keys.PageDown:
|
||||
newVal = Math.Min(curVal + 1, maxVal);
|
||||
break;
|
||||
case Keys.PageUp:
|
||||
newVal = Math.Max(curVal - 1, 0);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (curVal != newVal)
|
||||
{
|
||||
unitTypesBox.SelectedIndex = newVal;
|
||||
if (placementMode)
|
||||
{
|
||||
mapPanel.Invalidate(map, Rectangle.Inflate(new Rectangle(navigationWidget.MouseCell, new Size(1, 1)), 1, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EnterPlacementMode()
|
||||
{
|
||||
if (placementMode)
|
||||
@ -511,6 +547,7 @@ namespace MobiusEditor.Tools
|
||||
if (mockUnit.Type != null)
|
||||
{
|
||||
var unitPreview = new Bitmap(Globals.PreviewTileWidth * 3, Globals.PreviewTileWidth * 3);
|
||||
unitPreview.SetResolution(96, 96);
|
||||
using (var g = Graphics.FromImage(unitPreview))
|
||||
{
|
||||
MapRenderer.SetRenderSettings(g, Globals.PreviewSmoothScale);
|
||||
|
@ -111,20 +111,25 @@ namespace MobiusEditor.Tools
|
||||
|
||||
private void MapPanel_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
Point mouseCell = navigationWidget.MouseCell;
|
||||
if (placementMode)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
AddWall(navigationWidget.MouseCell);
|
||||
// Overlay is not allowed on first and last row. See OverlayClass::Read_INI
|
||||
if (mouseCell.Y > 0 && mouseCell.Y < map.Metrics.Height - 1)
|
||||
{
|
||||
AddWall(mouseCell);
|
||||
}
|
||||
}
|
||||
else if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
RemoveWall(navigationWidget.MouseCell);
|
||||
RemoveWall(mouseCell);
|
||||
}
|
||||
}
|
||||
else if ((e.Button == MouseButtons.Left) || (e.Button == MouseButtons.Right))
|
||||
{
|
||||
PickWall(navigationWidget.MouseCell);
|
||||
PickWall(mouseCell);
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,45 +155,52 @@ namespace MobiusEditor.Tools
|
||||
|
||||
private void MouseoverWidget_MouseCellChanged(object sender, MouseCellChangedEventArgs e)
|
||||
{
|
||||
Point mouseCell = e.NewCell;
|
||||
if (placementMode)
|
||||
{
|
||||
if (Control.MouseButtons == MouseButtons.Left)
|
||||
{
|
||||
AddWall(e.NewCell);
|
||||
if (mouseCell.Y > 0 && mouseCell.Y < map.Metrics.Height - 1)
|
||||
{
|
||||
AddWall(mouseCell);
|
||||
}
|
||||
}
|
||||
else if (Control.MouseButtons == MouseButtons.Right)
|
||||
{
|
||||
RemoveWall(e.NewCell);
|
||||
RemoveWall(mouseCell);
|
||||
}
|
||||
if (SelectedWallType != null)
|
||||
{
|
||||
mapPanel.Invalidate(map, Rectangle.Inflate(new Rectangle(e.OldCell, new Size(1, 1)), 1, 1));
|
||||
mapPanel.Invalidate(map, Rectangle.Inflate(new Rectangle(e.NewCell, new Size(1, 1)), 1, 1));
|
||||
mapPanel.Invalidate(map, Rectangle.Inflate(new Rectangle(mouseCell, new Size(1, 1)), 1, 1));
|
||||
}
|
||||
}
|
||||
else if (e.MouseButtons == MouseButtons.Right)
|
||||
{
|
||||
PickWall(e.NewCell);
|
||||
PickWall(mouseCell);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddWall(Point location)
|
||||
{
|
||||
OverlayType selected = SelectedWallType;
|
||||
// Can't place overlay on top and bottom row. See OverlayClass::Read_INI
|
||||
if (selected == null || location.Y == 0 || location.Y == map.Metrics.Height - 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (map.Metrics.GetCell(location, out int cell))
|
||||
{
|
||||
if (SelectedWallType != null)
|
||||
var overlay = new Overlay { Type = SelectedWallType, Icon = 0 };
|
||||
if (map.Technos.CanAdd(cell, overlay) && map.Buildings.CanAdd(cell, overlay))
|
||||
{
|
||||
var overlay = new Overlay { Type = SelectedWallType, Icon = 0 };
|
||||
if (map.Technos.CanAdd(cell, overlay) && map.Buildings.CanAdd(cell, overlay))
|
||||
if (!undoOverlays.ContainsKey(cell))
|
||||
{
|
||||
if (!undoOverlays.ContainsKey(cell))
|
||||
{
|
||||
undoOverlays[cell] = map.Overlay[cell];
|
||||
}
|
||||
map.Overlay[cell] = overlay;
|
||||
redoOverlays[cell] = overlay;
|
||||
mapPanel.Invalidate(map, Rectangle.Inflate(new Rectangle(location, new Size(1, 1)), 1, 1));
|
||||
undoOverlays[cell] = map.Overlay[cell];
|
||||
}
|
||||
map.Overlay[cell] = overlay;
|
||||
redoOverlays[cell] = overlay;
|
||||
mapPanel.Invalidate(map, Rectangle.Inflate(new Rectangle(location, new Size(1, 1)), 1, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -262,6 +274,7 @@ namespace MobiusEditor.Tools
|
||||
}
|
||||
placementMode = true;
|
||||
navigationWidget.MouseoverSize = Size.Empty;
|
||||
navigationWidget.PenColor = Color.Red;
|
||||
if (SelectedWallType != null)
|
||||
{
|
||||
mapPanel.Invalidate(map, Rectangle.Inflate(new Rectangle(navigationWidget.MouseCell, new Size(1, 1)), 1, 1));
|
||||
@ -277,6 +290,7 @@ namespace MobiusEditor.Tools
|
||||
}
|
||||
placementMode = false;
|
||||
navigationWidget.MouseoverSize = new Size(1, 1);
|
||||
navigationWidget.PenColor = Color.Yellow;
|
||||
if (SelectedWallType != null)
|
||||
{
|
||||
mapPanel.Invalidate(map, Rectangle.Inflate(new Rectangle(navigationWidget.MouseCell, new Size(1, 1)), 1, 1));
|
||||
@ -317,28 +331,35 @@ namespace MobiusEditor.Tools
|
||||
{
|
||||
base.PreRenderMap();
|
||||
previewMap = map.Clone(true);
|
||||
if (placementMode)
|
||||
if (!placementMode)
|
||||
{
|
||||
var location = navigationWidget.MouseCell;
|
||||
if (SelectedWallType != null)
|
||||
{
|
||||
if (previewMap.Metrics.GetCell(location, out int cell))
|
||||
{
|
||||
var overlay = new Overlay { Type = SelectedWallType, Icon = 0, Tint = Color.FromArgb(128, Color.White) };
|
||||
if (previewMap.Technos.CanAdd(cell, overlay) && previewMap.Buildings.CanAdd(cell, overlay))
|
||||
{
|
||||
previewMap.Overlay[cell] = overlay;
|
||||
mapPanel.Invalidate(previewMap, Rectangle.Inflate(new Rectangle(location, new Size(1, 1)), 1, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
navigationWidget.MouseoverSize = Size.Empty;
|
||||
var location = navigationWidget.MouseCell;
|
||||
OverlayType selected = this.SelectedWallType;
|
||||
if (selected == null || !previewMap.Metrics.GetCell(location, out int cell))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (location.Y == 0 || location.Y == map.Metrics.Height - 1)
|
||||
{
|
||||
navigationWidget.MouseoverSize = new Size(1, 1);
|
||||
}
|
||||
var overlay = new Overlay { Type = selected, Icon = 0, Tint = Color.FromArgb(128, Color.FromArgb(128, selected.Tint)) };
|
||||
if (previewMap.Technos.CanAdd(cell, overlay) && previewMap.Buildings.CanAdd(cell, overlay))
|
||||
{
|
||||
previewMap.Overlay[cell] = overlay;
|
||||
mapPanel.Invalidate(previewMap, Rectangle.Inflate(new Rectangle(location, new Size(1, 1)), 1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PostRenderMap(Graphics graphics)
|
||||
{
|
||||
base.PostRenderMap(graphics);
|
||||
MapRenderer.RenderAllBoundsFromCell(graphics, Globals.MapTileSize, previewMap.Overlay.Where(x => x.Value.Type.IsWall), previewMap.Metrics);
|
||||
int secondRow = map.Metrics.Width;
|
||||
int lastRow = map.Metrics.Length - map.Metrics.Width;
|
||||
MapRenderer.RenderAllBoundsFromCell(graphics, Globals.MapTileSize, previewMap.Overlay.Where(x => x.Value.Type.IsWall && x.Cell >= secondRow && x.Cell < lastRow), previewMap.Metrics);
|
||||
}
|
||||
|
||||
public override void Activate()
|
||||
|
@ -255,6 +255,7 @@ namespace MobiusEditor.Utility
|
||||
public static Bitmap FitToBoundingBox(this Image image, Rectangle cutout, int maxWidth, int maxHeight, Color clearColor)
|
||||
{
|
||||
Bitmap newImg = new Bitmap(maxWidth, maxHeight);
|
||||
newImg.SetResolution(image.HorizontalResolution, image.VerticalResolution);
|
||||
Rectangle resized = GeneralUtils.GetBoundingBoxCenter(cutout.Width, cutout.Height, maxWidth, maxHeight);
|
||||
using (Graphics g = Graphics.FromImage(newImg))
|
||||
{
|
||||
@ -331,6 +332,8 @@ namespace MobiusEditor.Utility
|
||||
const int border = filterSize / 2;
|
||||
var result = new Color[bitmap.Width, bitmap.Height];
|
||||
var sharpenImage = new Bitmap(bitmap);
|
||||
// Not sure if needed with a clone like this... still, better be sure.
|
||||
sharpenImage.SetResolution(bitmap.HorizontalResolution, bitmap.VerticalResolution);
|
||||
int width = bitmap.Width;
|
||||
int height = bitmap.Height;
|
||||
// Lock image bits for read/write.
|
||||
|
@ -269,6 +269,7 @@ namespace MobiusEditor.Utility
|
||||
public static Bitmap BuildImage(Byte[] sourceData, Int32 width, Int32 height, Int32 stride, PixelFormat pixelFormat, Color[] palette, Color? defaultColor)
|
||||
{
|
||||
Bitmap newImage = new Bitmap(width, height, pixelFormat);
|
||||
newImage.SetResolution(96, 96);
|
||||
BitmapData targetData = newImage.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, newImage.PixelFormat);
|
||||
Int32 newDataWidth = ((Image.GetPixelFormatSize(pixelFormat) * width) + 7) / 8;
|
||||
Int32 targetStride = targetData.Stride;
|
||||
@ -301,6 +302,7 @@ namespace MobiusEditor.Utility
|
||||
public static Bitmap PaintOn32bpp(Image image, Color? transparencyFillColor)
|
||||
{
|
||||
Bitmap bp = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppArgb);
|
||||
bp.SetResolution(image.HorizontalResolution, image.VerticalResolution);
|
||||
using (Graphics gr = Graphics.FromImage(bp))
|
||||
{
|
||||
if (transparencyFillColor.HasValue)
|
||||
|
@ -247,6 +247,7 @@ namespace MobiusEditor.Utility
|
||||
// Makes a 1x1 green pixel image, and applies the recolor operation to it.
|
||||
using (Bitmap bitmap = new Bitmap(1, 1, PixelFormat.Format32bppArgb))
|
||||
{
|
||||
bitmap.SetResolution(96, 96);
|
||||
bitmap.SetPixel(0, 0, RemapBaseColor);
|
||||
if (tc != null)
|
||||
{
|
||||
|
@ -94,14 +94,20 @@ namespace MobiusEditor.Utility
|
||||
{
|
||||
if (!cachedTextures.ContainsKey(filename))
|
||||
{
|
||||
cachedTextures.Add(filename, new Bitmap(bm));
|
||||
Bitmap cacheCopy = new Bitmap(bm);
|
||||
cacheCopy.SetResolution(96, 96);
|
||||
cachedTextures.Add(filename, cacheCopy);
|
||||
}
|
||||
return (new Bitmap(bm), bounds);
|
||||
Bitmap retCopy = new Bitmap(bm);
|
||||
retCopy.SetResolution(96, 96);
|
||||
return (retCopy, bounds);
|
||||
}
|
||||
}
|
||||
if (teamColorTextures.TryGetValue((filename, teamColor), out (Bitmap bitmap, Rectangle opaqueBounds) result))
|
||||
{
|
||||
return (new Bitmap(result.bitmap), result.opaqueBounds);
|
||||
Bitmap retCopy = new Bitmap(result.bitmap);
|
||||
retCopy.SetResolution(96, 96);
|
||||
return (retCopy, result.opaqueBounds);
|
||||
}
|
||||
if (!cachedTextures.TryGetValue(filename, out result.bitmap))
|
||||
{
|
||||
@ -189,25 +195,31 @@ namespace MobiusEditor.Utility
|
||||
}
|
||||
if (tga != null)
|
||||
{
|
||||
var bitmap = tga.ToBitmap(true);
|
||||
if (metadata != null)
|
||||
{
|
||||
var size = new Size(metadata["size"][0].ToObject<int>(), metadata["size"][1].ToObject<int>());
|
||||
var crop = Rectangle.FromLTRB(
|
||||
metadata["crop"][0].ToObject<int>(),
|
||||
metadata["crop"][1].ToObject<int>(),
|
||||
metadata["crop"][2].ToObject<int>(),
|
||||
metadata["crop"][3].ToObject<int>()
|
||||
);
|
||||
var uncroppedBitmap = new Bitmap(size.Width, size.Height, bitmap.PixelFormat);
|
||||
using (var g = Graphics.FromImage(uncroppedBitmap))
|
||||
using (var bitmap = tga.ToBitmap(true))
|
||||
{
|
||||
g.DrawImage(bitmap, crop, new Rectangle(Point.Empty, bitmap.Size), GraphicsUnit.Pixel);
|
||||
bitmap.SetResolution(96, 96);
|
||||
var size = new Size(metadata["size"][0].ToObject<int>(), metadata["size"][1].ToObject<int>());
|
||||
var crop = Rectangle.FromLTRB(
|
||||
metadata["crop"][0].ToObject<int>(),
|
||||
metadata["crop"][1].ToObject<int>(),
|
||||
metadata["crop"][2].ToObject<int>(),
|
||||
metadata["crop"][3].ToObject<int>()
|
||||
);
|
||||
var uncroppedBitmap = new Bitmap(size.Width, size.Height, bitmap.PixelFormat);
|
||||
uncroppedBitmap.SetResolution(96, 96);
|
||||
using (var g = Graphics.FromImage(uncroppedBitmap))
|
||||
{
|
||||
g.DrawImage(bitmap, crop, new Rectangle(Point.Empty, bitmap.Size), GraphicsUnit.Pixel);
|
||||
}
|
||||
cachedTextures[filename] = uncroppedBitmap;
|
||||
}
|
||||
cachedTextures[filename] = uncroppedBitmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
var bitmap = tga.ToBitmap(true);
|
||||
bitmap.SetResolution(96, 96);
|
||||
cachedTextures[filename] = bitmap;
|
||||
}
|
||||
}
|
||||
@ -257,6 +269,7 @@ namespace MobiusEditor.Utility
|
||||
imageData.Metadata["crop"][3].ToObject<int>()
|
||||
);
|
||||
var uncroppedBitmap = new Bitmap(size.Width, size.Height, bitmap.PixelFormat);
|
||||
uncroppedBitmap.SetResolution(96, 96);
|
||||
using (var g = Graphics.FromImage(uncroppedBitmap))
|
||||
{
|
||||
g.DrawImage(bitmap, crop, new Rectangle(Point.Empty, bitmap.Size), GraphicsUnit.Pixel);
|
||||
@ -310,18 +323,20 @@ namespace MobiusEditor.Utility
|
||||
{
|
||||
return result;
|
||||
}
|
||||
result.bitmap = new Bitmap(result.bitmap);
|
||||
Bitmap resBm = new Bitmap(result.bitmap);
|
||||
resBm.SetResolution(96, 96);
|
||||
result.bitmap = resBm;
|
||||
if (teamColor != null)
|
||||
{
|
||||
Rectangle opaqueBounds;
|
||||
teamColor.ApplyToImage(result.bitmap, out opaqueBounds);
|
||||
teamColor.ApplyToImage(resBm, out opaqueBounds);
|
||||
result.opaqueBounds = opaqueBounds;
|
||||
// EXPERIMENTAL: might be better not to cache this?
|
||||
//teamColorTextures[(filename, teamColor)] = (new Bitmap(result.bitmap), result.opaqueBounds);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.opaqueBounds = ImageUtils.CalculateOpaqueBounds(result.bitmap);
|
||||
result.opaqueBounds = ImageUtils.CalculateOpaqueBounds(resBm);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -406,6 +421,7 @@ namespace MobiusEditor.Utility
|
||||
var bitmapData = bitmap.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.WriteOnly, bitmap.PixelFormat);
|
||||
Marshal.Copy(image.Data, 0, bitmapData.Scan0, image.Stride * image.Height);
|
||||
bitmap.UnlockBits(bitmapData);
|
||||
bitmap.SetResolution(96, 96);
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
@ -420,6 +436,7 @@ namespace MobiusEditor.Utility
|
||||
{
|
||||
// Generate.
|
||||
bm = new Bitmap(48, 48);
|
||||
bm.SetResolution(96, 96);
|
||||
using (Graphics graphics = Graphics.FromImage(bm))
|
||||
{
|
||||
using (SolidBrush outside = new SolidBrush(Color.FromArgb(128, 107, 107, 107)))
|
||||
@ -435,6 +452,7 @@ namespace MobiusEditor.Utility
|
||||
}
|
||||
// Post-process dummy image.
|
||||
Bitmap newBm = new Bitmap(Globals.OriginalTileWidth, Globals.OriginalTileHeight);
|
||||
newBm.SetResolution(96, 96);
|
||||
ColorMatrix colorMatrix = new ColorMatrix();
|
||||
colorMatrix.Matrix33 = 0.5f;
|
||||
var imageAttributes = new ImageAttributes();
|
||||
|
@ -61,6 +61,7 @@ namespace MobiusEditor.Utility
|
||||
static Tileset()
|
||||
{
|
||||
transparentTileImage = new Bitmap(Globals.OriginalTileWidth, Globals.OriginalTileHeight);
|
||||
transparentTileImage.SetResolution(96, 96);
|
||||
transparentTileImage.MakeTransparent();
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,10 @@ namespace MobiusEditor.Widgets
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.ToArgb() == penColor.ToArgb() && defaultMouseoverPen != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
penColor = value;
|
||||
Pen p = defaultMouseoverPen;
|
||||
defaultMouseoverPen = null;
|
||||
@ -260,6 +264,11 @@ namespace MobiusEditor.Widgets
|
||||
|
||||
public void RenderRect(Graphics graphics, Point mouseCell)
|
||||
{
|
||||
if (defaultMouseoverPen == null)
|
||||
{
|
||||
// Forces creation of pen object
|
||||
this.PenColor = penColor;
|
||||
}
|
||||
Pen p = defaultMouseoverPen;
|
||||
if (!MouseoverSize.IsEmpty && p != null)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user