Author Topic: [XP][VXA] XPA_Window  (Read 1961 times)

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19930
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
[XP][VXA] XPA_Window
« on: February 08, 2016, 07:01:53 PM »
XPA_Window
Authors: Blizzard
Version: 1.2
Type: Custom Window Class
Key Term: Game Utility

Introduction

This script is an optimized rewrite of RMXP's Window class. It is primarily intended to be used with "XP Ace". It was made to emulate RMXP's Window class as closely as possible. Even when using this with RMXP, you're likely to get a few FPS more than with the default implementation.

This work is protected by the following license:
Quote
Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
( http://creativecommons.org/licenses/by-nc-sa/3.0/ )

You are free:

to Share - to copy, distribute and transmit the work
to Remix - to adapt the work

Under the following conditions:

Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).

Noncommercial. You may not use this work for commercial purposes.

Share alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.

- For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.

- Any of the above conditions can be waived if you get permission from the copyright holder.

- Nothing in this license impairs or restricts the author's moral rights.

Features

  • implements all functionality from the Window class in RPG Maker XP
  • allows customization of a few parameters which cannot be changed in the default implementation
v1.1
  • fixed hard crash when windowskin coordinates were out of bounds (basically when Bitmap#linear_write was called with out of bounds rects)
v1.2
  • added some compatibility code

Screenshots

N / A

Demo

XPA_Window (includes full source code for the DLL as well with a Visual Studio project for compilation)

Script

Just make a new script above all of your other scripts and paste this code into it.
Script Download

Download this DLL file and place it into the same directory where your Game.exe is. The filename should stay XPA_Window.dll.
DLL Download

Instructions

Inside the script in the first comment.

Compatibility

99% compatible with SDK v1.x. 99% compatible with SDK 2.x. Requires the user to run at least Windows XP SP3.

Credits and Thanks

  • Blizzard

Author's Notes

If you find any bugs, please report them here:
http://forum.chaos-project.com

That's it! N-Joy! =D
« Last Edit: September 22, 2017, 06:34:30 PM by Blizzard »
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline KK20

  • Master Scripter Fixer
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3043
  • LV: 372
  • Gender: Male
  • Bringer of Salt
    • View Profile
Re: [XP][VXA] XPA_Window
« Reply #1 on: September 12, 2017, 09:21:40 AM »
Interesting thing pointed out by Zexion. In XP, you can specify a blank windowskin in the editor and the game will run normally. In XPA, the game crashes (RGSS3 stopped working). This was due to invalid source coordinates prior to making the DLL call.

Replace the Bitmap class in the script to this:
Code: [Select]
class Bitmap
 
  def linear_write(dest, source, src)
    if src.x < source.width && src.y < source.height
      XPA_Window_Config::DLL_CALL.call(self.object_id, dest.x, dest.y,
        dest.width, dest.height, source.object_id, src.x, src.y, src.width,
        src.height)
    end
  end
 
end



Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!


NNID: KK20-CP
Discord: KK20 Tyler#8901
Join the CP Discord Server

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19930
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP][VXA] XPA_Window
« Reply #2 on: September 12, 2017, 08:45:55 PM »
Thanks for finding that bug, but I think that the fix should be on the C level since the DLL call should be safe. I'll integrate the fix right away and upload a new version. :) Feel free to update the one in the XPA package as well.

EDIT: Yup, a few "== 0" conditions should have actually been "<= 0" to fix this problem. New version is up. :)

EDIT: LMAO! Turns out I fixed that issue in CP a long time ago already. xD
« Last Edit: September 12, 2017, 08:58:25 PM by Blizzard »
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline KK20

  • Master Scripter Fixer
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3043
  • LV: 372
  • Gender: Male
  • Bringer of Salt
    • View Profile
Re: [XP][VXA] XPA_Window
« Reply #3 on: September 12, 2017, 09:05:57 PM »
jesus christ...
Thanks for the update Blizz, will add to the XPA package after work :-*



Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!


NNID: KK20-CP
Discord: KK20 Tyler#8901
Join the CP Discord Server

Offline KK20

  • Master Scripter Fixer
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3043
  • LV: 372
  • Gender: Male
  • Bringer of Salt
    • View Profile
Re: [XP][VXA] XPA_Window
« Reply #4 on: September 22, 2017, 04:39:20 AM »
Another thing to add is that there is no reader for viewport. It's a simple fix really
Code: [Select]
def viewport
  @_viewport
end

While we're on the topic of viewports, XPA_Window is interesting as it actually defines its own viewports with each creation. Was there a reason for that? In XP, there is no single window in the default scripts that uses a viewport, hence calling it would give you nil. It's kinda weird how that is, given that Window.new can actually take in an optional viewport parameter (XPA_Window is missing that also by the way).

This was brought to my attention by Whitespirits regarding the new Netplayer script where a detailed window would be drawn when hovering over an item in your inventory.
Code: [Select]
class Window_Base < Window

def draw_help
  @help_window = Sprite.new(self.viewport)
Now normally self.viewport here would just return nil (yeah, this is a huge oversight by the original author). But with XPA_Window, self.viewport will equal the dimensions of the window itself. This created some unintended behaviors where the sprite was not being displayed in the window due to the viewport's limitations.

It's probably best to take a look at the usage of Viewports in XPA_Window's design. I don't think I have ever seen any script assign a viewport to a custom window before; but if we're aiming to be a perfect replica of XP's Window class, we still need to consider it a possibility.



Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!


NNID: KK20-CP
Discord: KK20 Tyler#8901
Join the CP Discord Server

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19930
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP][VXA] XPA_Window
« Reply #5 on: September 22, 2017, 08:11:30 AM »
I see, I see. Do you think I should add that fix then? IMO we should extend functionality to fix issue rather than replicate them for consistency's sake. While nobody does use a viewport in a window, I am aware that it's possible, but IDK if the getter worked in RMXP.

I create the viewports upon window creation to be able to manage the window sprites easier and make sure they don't go out of bounds. And it's much easier to change the viewport coordinates rather than for each of the sprites individually. I think I also saw some performance boosts from this as opposed to manually changing all coordinates, but I can't remember anymore.
« Last Edit: September 22, 2017, 08:15:46 AM by Blizzard »
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline KK20

  • Master Scripter Fixer
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3043
  • LV: 372
  • Gender: Male
  • Bringer of Salt
    • View Profile
Re: [XP][VXA] XPA_Window
« Reply #6 on: September 22, 2017, 08:54:32 AM »
I'm all for improving upon the original design *points to Tilemap* but yeah, we need to make sure we don't remove what was already there for compatibility sake.

Window#viewport does work--I've tested it in XP. I only recall a disposed? method did not exist for some class despite it being in the Help.

I can spend this weekend to go over the design. Curious about that performance boost.



Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!


NNID: KK20-CP
Discord: KK20 Tyler#8901
Join the CP Discord Server

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19930
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP][VXA] XPA_Window
« Reply #7 on: September 22, 2017, 09:31:49 AM »
I THINK there was a performance boost. xD
In any case, let me know whether I should add the viewport fix or not.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline KK20

  • Master Scripter Fixer
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3043
  • LV: 372
  • Gender: Male
  • Bringer of Salt
    • View Profile
Re: [XP][VXA] XPA_Window
« Reply #8 on: September 22, 2017, 10:46:27 AM »
Yes, a fix would be desired.



Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!


NNID: KK20-CP
Discord: KK20 Tyler#8901
Join the CP Discord Server

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19930
  • LV: 642
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP][VXA] XPA_Window
« Reply #9 on: September 22, 2017, 06:34:56 PM »
Fix is up.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.