Skip to content

Commit

Permalink
[HaRepacker] move animation preview to XNA window
Browse files Browse the repository at this point in the history
  • Loading branch information
lastbattle committed Jul 13, 2020
1 parent 5ce1126 commit 179da68
Show file tree
Hide file tree
Showing 36 changed files with 513 additions and 339 deletions.
7 changes: 4 additions & 3 deletions HaCreator/GUI/InstanceEditor/BackgroundInstanceEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Windows.Controls;
using HaCreator.MapEditor.Info;
using Spine;
using HaSharedLibrary.Render.DX;

namespace HaCreator.GUI.InstanceEditor
{
Expand Down Expand Up @@ -50,7 +51,7 @@ public BackgroundInstanceEditor(BackgroundInstance item)
cyBox.Value = item.cy;

// Resolutions
foreach (MapRenderResolution val in Enum.GetValues(typeof(MapRenderResolution)))
foreach (RenderResolution val in Enum.GetValues(typeof(RenderResolution)))
{
ComboBoxItem comboBoxItem = new ComboBoxItem();
comboBoxItem.Tag = val;
Expand All @@ -63,7 +64,7 @@ public BackgroundInstanceEditor(BackgroundInstance item)
int i = 0;
foreach (ComboBoxItem citem in comboBox_screenMode.Items)
{
if ((int) ((MapRenderResolution)citem.Tag) == item.screenMode)
if ((int) ((RenderResolution)citem.Tag) == item.screenMode)
{
comboBox_screenMode.SelectedIndex = i;
break;
Expand Down Expand Up @@ -146,7 +147,7 @@ protected override void okButton_Click(object sender, EventArgs e)
item.ry = (int)ryBox.Value;
item.cx = (int)cxBox.Value;
item.cy = (int)cyBox.Value;
item.screenMode = (int) ((MapRenderResolution)((ComboBoxItem)comboBox_screenMode.SelectedItem).Tag); // combo box selection. 800x600, 1024x768, 1280x720, 1920x1080
item.screenMode = (int) ((RenderResolution)((ComboBoxItem)comboBox_screenMode.SelectedItem).Tag); // combo box selection. 800x600, 1024x768, 1280x720, 1920x1080

// Spine
if (!groupBox_spine.Enabled)
Expand Down
7 changes: 4 additions & 3 deletions HaCreator/GUI/UserSettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

using HaCreator.MapEditor.Instance.Shapes;
using HaCreator.MapSimulator;
using HaSharedLibrary.Render.DX;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand Down Expand Up @@ -33,7 +34,7 @@ public UserSettingsForm()
autoBackupBox.Checked = UserSettings.BackupEnabled;

// Resolutions
foreach (MapRenderResolution val in Enum.GetValues(typeof(MapRenderResolution)))
foreach (RenderResolution val in Enum.GetValues(typeof(RenderResolution)))
{
ComboBoxItem comboBoxItem = new ComboBoxItem();
comboBoxItem.Tag = val;
Expand All @@ -46,7 +47,7 @@ public UserSettingsForm()
int i = 0;
foreach (ComboBoxItem item in comboBox_resolution.Items)
{
if ((MapRenderResolution)item.Tag == UserSettings.SimulateResolution)
if ((RenderResolution)item.Tag == UserSettings.SimulateResolution)
{
comboBox_resolution.SelectedIndex = i;
break;
Expand Down Expand Up @@ -114,7 +115,7 @@ protected override void okButton_Click(object sender, EventArgs e)
UserSettings.DotWidth = (int)dotwBox.Value;
MapleDot.OnDotWidthChanged(); // Update DotWidth in dots to avoid requiring a restart
UserSettings.NonActiveAlpha = (int)inactiveaBox.Value;
UserSettings.SimulateResolution = ((MapRenderResolution) ((ComboBoxItem) comboBox_resolution.SelectedItem).Tag); // combo box selection. 800x600, 1024x768, 1280x720, 1920x1080
UserSettings.SimulateResolution = ((RenderResolution) ((ComboBoxItem) comboBox_resolution.SelectedItem).Tag); // combo box selection. 800x600, 1024x768, 1280x720, 1920x1080
UserSettings.ClipText = clipBox.Checked;
UserSettings.FixFootholdMispositions = fixFh.Checked;
UserSettings.InverseUpDown = invertUpDownBox.Checked;
Expand Down
21 changes: 8 additions & 13 deletions HaCreator/HaCreator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -382,21 +382,17 @@
<Compile Include="MapEditor\UndoRedo\UndoRedoAction.cs" />
<Compile Include="MapEditor\UndoRedo\UndoRedoBatch.cs" />
<Compile Include="MapEditor\UserObjectsManager.cs" />
<Compile Include="MapSimulator\Objects\FieldObject\BackgroundItem.cs" />
<Compile Include="MapSimulator\DX\IDXObject.cs" />
<Compile Include="MapSimulator\DX\DXSpineObject.cs" />
<Compile Include="MapSimulator\Objects\BaseItem.cs" />
<Compile Include="MapSimulator\Objects\FieldObject\MobItem.cs" />
<Compile Include="MapSimulator\Objects\FieldObject\TooltipItem.cs" />
<Compile Include="MapSimulator\Objects\UIObject\MinimapItem.cs" />
<Compile Include="MapSimulator\Objects\UIObject\MouseCursorItem.cs" />
<Compile Include="MapSimulator\Objects\FieldObject\NpcItem.cs" />
<Compile Include="MapSimulator\MapObjects\FieldObject\BackgroundItem.cs" />
<Compile Include="MapSimulator\MapObjects\FieldObject\MobItem.cs" />
<Compile Include="MapSimulator\MapObjects\FieldObject\TooltipItem.cs" />
<Compile Include="MapSimulator\MapObjects\UIObject\MinimapItem.cs" />
<Compile Include="MapSimulator\MapObjects\UIObject\MouseCursorItem.cs" />
<Compile Include="MapSimulator\MapObjects\FieldObject\NpcItem.cs" />
<Compile Include="MapSimulator\MapSimulator.cs" />
<Compile Include="MapSimulator\MapSimulatorLoader.cs" />
<Compile Include="MapSimulator\MapRenderResolution.cs" />
<Compile Include="GUI\TabItemContainer.cs" />
<Compile Include="MapSimulator\Objects\FieldObject\PortalItem.cs" />
<Compile Include="MapSimulator\Objects\FieldObject\ReactorItem.cs" />
<Compile Include="MapSimulator\MapObjects\FieldObject\PortalItem.cs" />
<Compile Include="MapSimulator\MapObjects\FieldObject\ReactorItem.cs" />
<Compile Include="MapSimulator\TexturePool.cs" />
<Compile Include="MapSimulator\UIFrameHelper.cs" />
<Compile Include="CustomControls\ColorDialog.xaml.cs">
Expand Down Expand Up @@ -524,7 +520,6 @@
<Compile Include="MapEditor\Instance\ISnappable.cs" />
<Compile Include="MapEditor\Layer.cs" />
<Compile Include="MapEditor\Input\Mouse.cs" />
<Compile Include="MapSimulator\DX\DXObject.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Collections\AnchorEnumerator.cs" />
Expand Down
4 changes: 3 additions & 1 deletion HaCreator/MapEditor/Board.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using HaCreator.MapEditor.Input;
using HaCreator.MapEditor.Instance.Shapes;
using System.Threading;
using HaSharedLibrary.Util;

namespace HaCreator.MapEditor
{
Expand Down Expand Up @@ -200,7 +201,8 @@ public void RenderBoard(SpriteBatch sprite)
parent.FillRectangle(sprite, minimapArea, Color.Gray);
// Render minimap
if (miniMapTexture == null)
miniMapTexture = BoardItem.TextureFromBitmap(parent.GraphicsDevice, miniMap);
miniMapTexture = miniMap.ToTexture2D(parent.GraphicsDevice);

sprite.Draw(miniMapTexture, minimapImageArea, null, Color.White, 0, new Vector2(0, 0), SpriteEffects.None, 0.99999f);
// Render current location on minimap
parent.DrawRectangle(sprite, new Rectangle(hScroll / _mag, vScroll / _mag, parent.CurrentDXWindowSize.Width / _mag, (int)parent.CurrentDXWindowSize.Height / _mag), Color.Blue);
Expand Down
15 changes: 0 additions & 15 deletions HaCreator/MapEditor/BoardItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,6 @@ public virtual void RemoveItem(List<UndoRedoAction> undoPipe)
}
}

public static Texture2D TextureFromBitmap(GraphicsDevice device, System.Drawing.Bitmap bitmap)
{
if (bitmap == null)
{
return null; //todo handle this in a useful way
}

using (System.IO.MemoryStream s = new System.IO.MemoryStream())
{
bitmap.Save(s, System.Drawing.Imaging.ImageFormat.Png);
s.Seek(0, System.IO.SeekOrigin.Begin);
return Texture2D.FromStream(device, s);
}
}

public virtual void BindItem(BoardItem item, XNA.Point distance)
{
lock (Board.ParentControl)
Expand Down
5 changes: 3 additions & 2 deletions HaCreator/MapEditor/Info/MapleDrawableInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

using HaSharedLibrary.Util;
using MapleLib.WzLib;
using Microsoft.Xna.Framework.Graphics;
using System;
Expand Down Expand Up @@ -48,9 +49,9 @@ public virtual Texture2D GetTexture(SpriteBatch sprite)
if (texture == null)
{
if (image != null && image.Width == 1 && image.Height == 1)
texture = BoardItem.TextureFromBitmap(sprite.GraphicsDevice, global::HaCreator.Properties.Resources.placeholder);
texture = global::HaCreator.Properties.Resources.placeholder.ToTexture2D(sprite.GraphicsDevice);
else
texture = BoardItem.TextureFromBitmap(sprite.GraphicsDevice, image);
texture = image.ToTexture2D(sprite.GraphicsDevice);
}
return texture;
}
Expand Down
3 changes: 2 additions & 1 deletion HaCreator/MapEditor/MultiBoard.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using HaCreator.MapEditor.Instance;
using HaCreator.MapEditor.Text;
using HaCreator.MapSimulator;
using HaSharedLibrary.Util;
using MapleLib.WzLib.WzStructure.Data;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
Expand Down Expand Up @@ -233,7 +234,7 @@ private Microsoft.Xna.Framework.Graphics.Texture2D CreatePixel()
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(1, 1);
bmp.SetPixel(0, 0, System.Drawing.Color.White);

return BoardItem.TextureFromBitmap(DxDevice, bmp);
return bmp.ToTexture2D(DxDevice);
}

public Board CreateBoard(Microsoft.Xna.Framework.Point mapSize, Point centerPoint, System.Windows.Controls.ContextMenu menu)
Expand Down
3 changes: 2 additions & 1 deletion HaCreator/MapEditor/Text/FontEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.Xna.Framework.Graphics;
using System.Drawing.Imaging;
using System.Drawing.Text;
using HaSharedLibrary.Util;

namespace HaCreator.MapEditor.Text
{
Expand Down Expand Up @@ -70,7 +71,7 @@ private CharTexture RasterizeCharacter(char ch)
graphics.DrawString(text, font, brush, 0, 0, format);
}

return new CharTexture(BoardItem.TextureFromBitmap(device, bitmap), width, height);
return new CharTexture(bitmap.ToTexture2D(device), width, height);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HaCreator.MapSimulator.DX;
using HaSharedLibrary.Render.DX;
using MapleLib.WzLib.WzStructure.Data;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
Expand All @@ -9,7 +9,7 @@

namespace HaCreator.MapSimulator.Objects.FieldObject
{
public class BackgroundItem : BaseItem
public class BackgroundItem : BaseDXDrawableItem
{
private int rx;
private int ry;
Expand Down Expand Up @@ -180,7 +180,7 @@ public void IncreaseShiftY(int cy, int TickCount)

public override void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime,
int mapShiftX, int mapShiftY, int centerX, int centerY,
int renderWidth, int renderHeight, float RenderObjectScaling, MapRenderResolution mapRenderResolution,
int renderWidth, int renderHeight, float RenderObjectScaling, RenderResolution mapRenderResolution,
int TickCount)
{
if (((int) mapRenderResolution & screenMode) != screenMode || disabledBackground) // dont draw if the screenMode isnt for this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using HaCreator.MapEditor.Instance;
using HaCreator.MapSimulator.DX;
using HaSharedLibrary.Render.DX;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Spine;
Expand All @@ -11,7 +11,7 @@

namespace HaCreator.MapSimulator.Objects.FieldObject
{
public class MobItem : BaseItem
public class MobItem : BaseDXDrawableItem
{
private readonly MobInstance mobInstance;

Expand All @@ -30,7 +30,7 @@ public MobItem(MobInstance mobInstance, IDXObject frame0)

public override void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime,
int mapShiftX, int mapShiftY, int centerX, int centerY,
int renderWidth, int renderHeight, float RenderObjectScaling, MapRenderResolution mapRenderResolution,
int renderWidth, int renderHeight, float RenderObjectScaling, RenderResolution mapRenderResolution,
int TickCount)
{
base.Draw(sprite, skeletonMeshRenderer, gameTime,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using HaCreator.MapEditor.Instance;
using HaCreator.MapSimulator.DX;
using HaSharedLibrary.Render.DX;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Spine;
Expand All @@ -11,7 +11,7 @@

namespace HaCreator.MapSimulator.Objects.FieldObject
{
public class NpcItem : BaseItem
public class NpcItem : BaseDXDrawableItem
{
private readonly NpcInstance npcInstance;

Expand All @@ -30,7 +30,7 @@ public NpcItem(NpcInstance npcInstance, IDXObject frame0)

public override void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime,
int mapShiftX, int mapShiftY, int centerX, int centerY,
int renderWidth, int renderHeight, float RenderObjectScaling, MapRenderResolution mapRenderResolution,
int renderWidth, int renderHeight, float RenderObjectScaling, RenderResolution mapRenderResolution,
int TickCount)
{
base.Draw(sprite, skeletonMeshRenderer, gameTime,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using HaCreator.MapEditor.Instance;
using HaCreator.MapSimulator.DX;
using HaSharedLibrary.Render.DX;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Spine;
Expand All @@ -11,7 +11,7 @@

namespace HaCreator.MapSimulator.Objects.FieldObject
{
public class PortalItem : BaseItem
public class PortalItem : BaseDXDrawableItem
{
private readonly PortalInstance portalInstance;

Expand All @@ -30,7 +30,7 @@ public PortalItem(PortalInstance portalInstance, IDXObject frame0)

public override void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime,
int mapShiftX, int mapShiftY, int centerX, int centerY,
int renderWidth, int renderHeight, float RenderObjectScaling, MapRenderResolution mapRenderResolution,
int renderWidth, int renderHeight, float RenderObjectScaling, RenderResolution mapRenderResolution,
int TickCount)
{
base.Draw(sprite, skeletonMeshRenderer, gameTime,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using HaCreator.MapEditor.Instance;
using HaCreator.MapSimulator.DX;
using HaSharedLibrary.Render.DX;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Spine;
Expand All @@ -11,7 +11,7 @@

namespace HaCreator.MapSimulator.Objects.FieldObject
{
public class ReactorItem : BaseItem
public class ReactorItem : BaseDXDrawableItem
{
private readonly ReactorInstance reactorInstance;

Expand All @@ -30,7 +30,7 @@ public ReactorItem(ReactorInstance reactorInstance, IDXObject frame0)

public override void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime,
int mapShiftX, int mapShiftY, int centerX, int centerY,
int renderWidth, int renderHeight, float RenderObjectScaling, MapRenderResolution mapRenderResolution,
int renderWidth, int renderHeight, float RenderObjectScaling, RenderResolution mapRenderResolution,
int TickCount)
{
base.Draw(sprite, skeletonMeshRenderer, gameTime,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using HaCreator.MapEditor.Instance.Shapes;
using HaCreator.MapSimulator.DX;
using HaSharedLibrary.Render.DX;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Spine;
Expand All @@ -11,7 +11,7 @@

namespace HaCreator.MapSimulator.Objects.FieldObject
{
public class TooltipItem : BaseItem
public class TooltipItem : BaseDXDrawableItem
{
private readonly ToolTipInstance tooltipInstance;
public ToolTipInstance TooltipInstance
Expand All @@ -35,7 +35,7 @@ public TooltipItem(ToolTipInstance npcInstance, IDXObject frame0)

public override void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime,
int mapShiftX, int mapShiftY, int centerX, int centerY,
int renderWidth, int renderHeight, float RenderObjectScaling, MapRenderResolution mapRenderResolution,
int renderWidth, int renderHeight, float RenderObjectScaling, RenderResolution mapRenderResolution,
int TickCount)
{
base.Draw(sprite, skeletonMeshRenderer, gameTime,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HaCreator.MapSimulator.DX;
using HaSharedLibrary.Render.DX;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Spine;
Expand All @@ -13,11 +13,11 @@ namespace HaCreator.MapSimulator.Objects.UIObject
/// <summary>
/// Mini map window item
/// </summary>
public class MinimapItem : BaseItem
public class MinimapItem : BaseDXDrawableItem
{
private readonly BaseItem item_pixelDot;
private readonly BaseDXDrawableItem item_pixelDot;

public MinimapItem(IDXObject frames, BaseItem item_pixelDot)
public MinimapItem(IDXObject frames, BaseDXDrawableItem item_pixelDot)
: base(frames, false)
{
this.item_pixelDot = item_pixelDot;
Expand All @@ -27,7 +27,7 @@ public MinimapItem(IDXObject frames, BaseItem item_pixelDot)

public override void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRenderer, GameTime gameTime,
int mapShiftX, int mapShiftY, int centerX, int centerY,
int RenderWidth, int RenderHeight, float RenderObjectScaling, MapRenderResolution mapRenderResolution,
int RenderWidth, int RenderHeight, float RenderObjectScaling, RenderResolution mapRenderResolution,
int TickCount)
{
// control minimap render UI position via
Expand Down
Loading

1 comment on commit 179da68

@lastbattle
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gif output

Please sign in to comment.