Correction to WINDOW Class's Cursor Rectangle #44
Labels
No Label
RGSS accuracy
bug
compilation
discussion
documentation
duplicate
enhancement
invalid
performance issue
port request
question
ruby incompatibility
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: MapleShrine/mkxp#44
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Your resident werewolf here, and I recognize what appears to be the basis for the window class due to a very familiar glitch. Can I assume that you may have used Selwyn/Squall's window class script from 2006?
Let me explain.
Selwyn's window class assumes that the cursor rectangle 'border' area is only 1px thick, but RMXP's border was set to use a 2px wide border. Using an RMXP windowskin that uses a 2px wide border is oddly distorted, particularly the right-most side. I experienced it with Selwyn's system and with mkxp.
Selwyn's original version of the cursor rectangle class set up rectangle areas as such:
@rect['cursor_up'] = Rect.new(129, 64, 30, 1)
@rect['cursor_down'] = Rect.new(129, 95, 30, 1)
@rect['cursor_left'] = Rect.new(128, 65, 1, 30)
@rect['cursor_right'] = Rect.new(159, 65, 1, 30)
@rect['upleft'] = Rect.new(128, 64, 1, 1)
@rect['upright'] = Rect.new(159, 64, 1, 1)
@rect['downleft'] = Rect.new(128, 95, 1, 1)
@rect['downright'] = Rect.new(159, 95, 1, 1)
@rect['bg'] = Rect.new(129, 65, 30, 30)
Though it should have been:
# Rectangle Corners
@rect['cursor_up'] = Rect.new(194, 96, 28, 2)
@rect['cursor_down'] = Rect.new(194, 126, 28, 2)
@rect['cursor_left'] = Rect.new(192, 98, 2, 28)
@rect['cursor_right'] = Rect.new(222, 98, 2, 28)
# Rectangle Sides
@rect['upleft'] = Rect.new(192, 96, 2, 2)
@rect['upright'] = Rect.new(222, 96, 2, 2)
@rect['downleft'] = Rect.new(192, 126, 2, 2)
@rect['downright'] = Rect.new(222, 126, 2, 2)
# Rectangle Background
@rect['bg'] = Rect.new(196, 100, 24, 24)
And the routine that Selwyn used to draw the rectangle was unfortunately:
self.bitmap = Bitmap.new(@width, @height)
rect = Rect.new(1, 1, @width - 2, @height - 2)
self.bitmap.stretch_blt(rect, @skin, @rect['bg'])
self.bitmap.blt(0, 0, @skin, @rect['upleft'])
self.bitmap.blt(@width-1, 0, @skin, @rect['upright'])
self.bitmap.blt(0, @height-1, @skin, @rect['downright'])
self.bitmap.blt(@width-1, @height-1, @skin, @rect['downleft'])
rect = Rect.new(1, 0, @width - 2, 1)
self.bitmap.stretch_blt(rect, @skin, @rect['cursor_up'])
rect = Rect.new(0, 1, 1, @height - 2)
self.bitmap.stretch_blt(rect, @skin, @rect['cursor_left'])
rect = Rect.new(1, @height-1, @width - 2, 1)
self.bitmap.stretch_blt(rect, @skin, @rect['cursor_down'])
rect = Rect.new(@width - 1, 1, 1, @height - 2)
self.bitmap.stretch_blt(rect, @skin, @rect['cursor_right'])
When again, it should have been:
# Define cursor bitmap
self.bitmap = Bitmap.new(@width, @height)
# Handle background
rect = Rect.new(1, 1, @width - 2, @height - 2)
self.bitmap.stretch_blt(rect, @skin, @rect['bg'])
# Handle corner placement
self.bitmap.blt(0, 0, @skin, @rect['upleft'])
self.bitmap.blt(@width-2, 0, @skin, @rect['upright'])
self.bitmap.blt(0, @height-2, @skin, @rect['downleft'])
self.bitmap.blt(@width-2, @height-2, @skin, @rect['downright'])
# Handle side placement
rect = Rect.new(2, 0, @width - 3, 2)
self.bitmap.stretch_blt(rect, @skin, @rect['cursor_up'])
rect = Rect.new(0, 1, 2, @height - 3)
self.bitmap.stretch_blt(rect, @skin, @rect['cursor_left'])
rect = Rect.new(2, @height-2, @width - 3, 2)
self.bitmap.stretch_blt(rect, @skin, @rect['cursor_down'])
rect = Rect.new(@width - 2, 2, 2, @height - 3)
self.bitmap.stretch_blt(rect, @skin, @rect['cursor_right'])
As you can tell, I do have some insight. If you want a newer 'revised' version with an animated hand cursor, I can supply my version's code too.
-DerVVulfman ( http://save-point.org/ )
mkxp does use a 2px wide selection rect border. Can you provide the windowskin you're seeing the distortion with, as well the expected outcome (RMXP screenshot) and what you're seeing (mkxp screenshot) please?
I tested this a bit and noticed some discrepancies. First off, the background needs to be linearly interpolated, but other than that, it just looks like RMXP's crappy scaling algorithm is making things look slightly different. Is this acceptable to you?
mkxp:
RMXP:
Windowskin:
Note that both show exactly the same cursor when no scaling is in effect (ie. at 32 32 size).
Some clarification: I didn't base any of my graphical work on mkxp on other peoples' scripts, I just observed how the individual classes behaved and implemented it in C++ (there is zero ruby in mkxp except for the bundled RPG module classes).
You wanted to see the screens? Sure. The top one is generated with RPGMaker XP while the bottom with MKXP.
And a skin that is used for both screens:
Most of that looks like its caused by the nearest texture filtering. I've pushed up a patch changing it to bilinear, which should mitigate most of the effect you're seeing in your game.
You will still see a very slight hunch of the darker bar on the right, but that's because RMXP's stretching algorithm, at lower sizes which are > (32, 32), just "eats" the right and bottom pixel lines of the background; in that regard, mkxp is simply more exact.
Closing this as OP isn't responding.