Skip to content

Commit

Permalink
Merge pull request #142 from taida957789/fix-canvas-outlink-bug
Browse files Browse the repository at this point in the history
Fix some canvas outlink data was not found
  • Loading branch information
lastbattle authored Sep 26, 2021
2 parents 30ff917 + bb0c956 commit 93b0768
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions MapleLib/WzLib/WzProperties/WzCanvasProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
using MapleLib.WzLib.Util;
using System;
using System.Drawing;
using System.Text.RegularExpressions;

namespace MapleLib.WzLib.WzProperties
{
Expand Down Expand Up @@ -323,9 +324,22 @@ public WzImageProperty GetLinkedWzImageProperty()
{
if (!(currentWzObj is WzDirectory)) // keep looping if its not a WzImage
continue;

WzFile wzFileParent = ((WzDirectory)currentWzObj).wzFile;
WzObject foundProperty = wzFileParent.GetObjectFromPath(_outlink);
Match match = Regex.Match(wzFileParent.Name, @"^([A-Za-z]+)([0-9]*).wz");

string prefixWz = match.Groups[1].Value + "/"; // remove ended numbers and .wz from wzfile name

WzObject foundProperty;

if (_outlink.StartsWith(prefixWz))
{
// fixed root path
string realpath = _outlink.Replace(prefixWz, WzFileParent.Name.Replace(".wz", "") + "/");
foundProperty = wzFileParent.GetObjectFromPath(realpath);
} else
{
foundProperty = wzFileParent.GetObjectFromPath(_outlink);
}
if (foundProperty != null && foundProperty is WzImageProperty property)
{
return property;
Expand Down

0 comments on commit 93b0768

Please sign in to comment.