Skip to content

Commit

Permalink
[HaCreator] fix map simulator rendering issues for bg without any frames
Browse files Browse the repository at this point in the history
  • Loading branch information
lastbattle committed Dec 14, 2022
1 parent 7c3aee3 commit 5f384d6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
10 changes: 6 additions & 4 deletions HaCreator/MapSimulator/MapSimulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,18 @@ protected override void LoadContent()
foreach (BackgroundInstance background in mapBoard.BoardItems.BackBackgrounds)
{
WzImageProperty bgParent = (WzImageProperty)background.BaseInfo.ParentObject;
BackgroundItem bgItem = MapSimulatorLoader.CreateBackgroundFromProperty(texturePool, bgParent, background, _DxDeviceManager.GraphicsDevice, ref usedProps, background.Flip);
backgrounds_back.Add(
MapSimulatorLoader.CreateBackgroundFromProperty(texturePool, bgParent, background, _DxDeviceManager.GraphicsDevice, ref usedProps, background.Flip));
if (bgItem != null)
backgrounds_back.Add(bgItem);
}
foreach (BackgroundInstance background in mapBoard.BoardItems.FrontBackgrounds)
{
WzImageProperty bgParent = (WzImageProperty)background.BaseInfo.ParentObject;
BackgroundItem bgItem = MapSimulatorLoader.CreateBackgroundFromProperty(texturePool, bgParent, background, _DxDeviceManager.GraphicsDevice, ref usedProps, background.Flip);
backgrounds_front.Add(
MapSimulatorLoader.CreateBackgroundFromProperty(texturePool, bgParent, background, _DxDeviceManager.GraphicsDevice, ref usedProps, background.Flip));
if (bgItem != null)
backgrounds_front.Add(bgItem);
}
});

Expand Down
15 changes: 15 additions & 0 deletions HaCreator/MapSimulator/MapSimulatorLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
using System.Linq;
using System.Threading;
using HaSharedLibrary.Wz;
using MapleLib.Helpers;
using SharpDX.Direct2D1.Effects;

namespace HaCreator.MapSimulator
{
Expand Down Expand Up @@ -236,6 +238,14 @@ public static BaseDXDrawableItem CreateMapItemFromProperty(TexturePool texturePo
public static BackgroundItem CreateBackgroundFromProperty(TexturePool texturePool, WzImageProperty source, BackgroundInstance bgInstance, GraphicsDevice device, ref List<WzObject> usedProps, bool flip)
{
List<IDXObject> frames = LoadFrames(texturePool, source, bgInstance.BaseX, bgInstance.BaseY, device, ref usedProps, bgInstance.SpineAni);
if (frames.Count == 0)
{
string error = string.Format("[MapSimulatorLoader] 0 frames loaded for bg texture from src: '{0}'", source.FullPath); // Back_003.wz\\BM3_3.img\\spine\\0

ErrorLogger.Log(ErrorLevel.IncorrectStructure, error);
return null;
}

if (frames.Count == 1)
{
return new BackgroundItem(bgInstance.cx, bgInstance.cy, bgInstance.rx, bgInstance.ry, bgInstance.type, bgInstance.a, bgInstance.front, frames[0], flip, bgInstance.screenMode);
Expand Down Expand Up @@ -357,7 +367,12 @@ public static ReactorItem CreateReactorFromProperty(TexturePool texturePool, Rea
}
}
if (frames.Count == 0)
{
//string error = string.Format("[MapSimulatorLoader] 0 frames loaded for reactor from src: '{0}'", reactorInfo.ID);

//ErrorLogger.Log(ErrorLevel.IncorrectStructure, error);
return null;
}
return new ReactorItem(reactorInstance, frames);
}
#endregion
Expand Down

0 comments on commit 5f384d6

Please sign in to comment.