Correction to WINDOW Class's Cursor Rectangle #44

Closed
opened 2014-07-02 04:59:40 +00:00 by DerVVulfman · 5 comments
DerVVulfman commented 2014-07-02 04:59:40 +00:00 (Migrated from github.com)

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/ )

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/ )
Ancurio commented 2014-07-02 14:07:55 +00:00 (Migrated from github.com)

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?

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?
Ancurio commented 2014-07-03 00:33:53 +00:00 (Migrated from github.com)

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:
mkxp_final

RMXP:
rmxp_final

Windowskin:
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).

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: ![mkxp_final](https://cloud.githubusercontent.com/assets/1173822/3464248/44d93c1a-0249-11e4-8742-941e0541a0f7.png) RMXP: ![rmxp_final](https://cloud.githubusercontent.com/assets/1173822/3464249/49be33fc-0249-11e4-9b44-6086908d1193.png) Windowskin: ![windowskin](https://cloud.githubusercontent.com/assets/1173822/3464252/536cba90-0249-11e4-80e2-f600c3f84fca.png) 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).
DerVVulfman commented 2014-07-03 04:01:26 +00:00 (Migrated from github.com)

You wanted to see the screens? Sure. The top one is generated with RPGMaker XP while the bottom with MKXP.

glitch

And a skin that is used for both screens:

skin1-1

You wanted to see the screens? Sure. The top one is generated with RPGMaker XP while the bottom with MKXP. ![glitch](https://cloud.githubusercontent.com/assets/7981619/3465427/c9672688-0265-11e4-89cb-ebbbd4d8e89c.png) And a skin that is used for both screens: ![skin1-1](https://cloud.githubusercontent.com/assets/7981619/3465439/0f1db516-0266-11e4-939b-e18dfcad52db.png)
Ancurio commented 2014-07-03 12:38:49 +00:00 (Migrated from github.com)

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.

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.
Ancurio commented 2014-07-08 04:47:12 +00:00 (Migrated from github.com)

Closing this as OP isn't responding.

Closing this as OP isn't responding.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: MapleShrine/mkxp#44
No description provided.