lastbattle / Harepacker-resurrected

All in one .wz file/map editor for MapleStory game files
Mozilla Public License 2.0
416 stars 156 forks source link

AI Image Upscale #246

Closed v3921358 closed 1 month ago

v3921358 commented 1 month ago

I noticed there are two problems about it

  1. we didn't really change about the node value

    PointF pointXY = img.Value.Item2.GetCanvasOriginPosition();
    if (pointXY != null && pointXY.X != 0 && pointXY.Y != 0) {
        pointXY.X *= (SCALE_UP_FACTOR * downscaleFactorAfter); // 4 * 0.25 = 1, 4 * 0.5 = 2
        pointXY.Y *= (SCALE_UP_FACTOR * downscaleFactorAfter);
    }

The reason is what we changed is a copy

    public PointF GetCanvasOriginPosition()
    {
        WzVectorProperty originPos = (WzVectorProperty)this[OriginPropertyName];
        if (originPos != null)
            return new PointF(originPos.X.Value, originPos.Y.Value);

        return new PointF(0, 0);
    }
  1. we should change all vector nodes that the level is under the canvas property, it might looks like this

    public const string OriginPropertyName = "origin";
    public const string HeadPropertyName = "head";
    public const string LtPropertyName = "lt";
    public const string RbPropertyName = "rb";
    
    public void UpdateCanvasPositionRate(double rate)
    {
        string[] vectorProperties = { OriginPropertyName, HeadPropertyName, LtPropertyName, RbPropertyName };
        foreach (var property in vectorProperties)
        {
            var vectorProperty = (WzVectorProperty)this[property];
            if (vectorProperty != null)
            {
                vectorProperty.X.Value = (int)(vectorProperty.X.Value * rate);
                vectorProperty.Y.Value = (int)(vectorProperty.Y.Value * rate);
            }
        }
    }
lastbattle commented 1 month ago

Missed that, thanks for pointing it out.

lastbattle commented 1 month ago

https://github.com/lastbattle/Harepacker-resurrected/commit/496e4e1b9c371fff80eb01a207709f7e6835786b https://github.com/lastbattle/MapleLib/commit/27e89f78cd913c5feb2fafd53d46b59b26e9a996