Scene_Base
Authors: Nathmatt
Version: 1.02
IntroductionThis script is an updated version of the original Scene_Base
Features
- Automatically updates active windows
- Automatically disposes all windows & sprites
Screenshotsno screenshot
Demono demo
Script[SPOILER]
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Scene_Base by Nathmatt
# Version: 1.01
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This work is protected by the following license:
# #----------------------------------------------------------------------------
# #
# # 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.
# #
# #-----------------------------------------------------------------------------
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#==============================================================================
# ** Scene_Base
#------------------------------------------------------------------------------
# This is a superclass of all scenes in the game.
#==============================================================================
class Scene_Base
attr_accessor :windows
attr_accessor :sprites
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
add_processing # Adds processing
start # Start processing
perform_transition # Perform transition
post_start # Post-start processing
Input.update # Update input information
loop do
Graphics.update # Update game screen
Input.update # Update input information
update # Update frame
update_windows # update windows
break if $scene != self # When screen is switched, interrupt loop
end
Graphics.update
pre_terminate # Pre-termination processing
Graphics.freeze # Prepare transition
terminate # Termination processing
terminate_windows # terminate windows
end
#--------------------------------------------------------------------------
# * Add processing
#--------------------------------------------------------------------------
def add_processing
@windows = []
@sprites = []
@animate = 0
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update_windows
@windows.each{|s| s.update if !s.updated? && s.active}
end
#--------------------------------------------------------------------------
# * Terminate Windows Processing
#--------------------------------------------------------------------------
def terminate_windows
@windows.each{|s| s.dispose if !s.disposed?}
@sprites.each{|s| s.dispose if !s.disposed?}
end
end
#==============================================================================
# Window
#==============================================================================
class Window
alias scene_base_initialize initialize unless $@
def initialize(viewport = nil)
scene_base_initialize(viewport = nil)
self.openness = 0
$scene.windows.push(self)
end
alias scene_base_update update unless $@
def update
@frame_count = Graphics.frame_count if @frame_count != Graphics.frame_count
scene_base_update
end
def updated?
return true if @frame_count == Graphics.frame_count
end
end
#==============================================================================
# Sprite
#==============================================================================
class Sprite
alias scene_base_initialize initialize unless $@
def initialize(viewport = nil)
scene_base_initialize(viewport = nil)
$scene.sprites.push(self)
end
end[/SPOILER]
Instructionsjust place above main
CompatibilityShould not have any compatibility issues
Credits and Thanks
- Nathmatt
- modern algebra for the unless $@ code
Author's NotesIf you have any suggestions post here
Wow a nice idea!
But i don't know if it's helpfull. I think you'll update unneeded things like Windows which aren't active and this can cause laggs.
Anyways I think it's a good idea. xD
Deity
Well, it's not a bad idea, I guess. But I'm not sure how much it will be used since most people writing a script would rather just dispose the windows manually than require the user to install a whole other script. However, it's nice if you have a series of scripts that you'll release as a compilation. One thing I'll mention is that you don't need to recopy the entire class, only the parts you want to change, so you can make the script quite a bit smaller than it is.
Also, you'll probably want to add an unless $@ after the aliases in Window and Sprite, as you will get an F12 error otherwise.
i made it as more of a use it with the custom scripts you make for yourself and made sure it only updates windows 1nce per frame so if they have been updated they wont update again
fixed the only updates active windows and the unless $@