- Joined
- Apr 17, 2013
- Messages
- 93
- Reaction score
- 6
- First Language
- English
- Primarily Uses
- N/A
Hey. I was going through my bought dlcs the other day, looking for some treasure I might have missed when I had first copy-pasted the "usable" resources elsewhere, and in the RPGMakerDS+_PCK I found Zalerinian's Files+ save script, which gives all sorts of useful details in the save files.
The problem I have, is that the script crashes when pressing continue if prexisting saves (where the script didn't exist), exist (the report says the problem is on line 199). Now, I don't mind that for myself, but my Broken Reality RPG (https://lord-rutsah.itch.io/broken-reality) has a lot of content to cover, meaning my players have already invested tens of hours into playing. Due to the multiclass system and the differences it makes in the story, most fans have 2-3 different playthroughs happening at the same time, and I do not want to tell everyone to just start from the scratch.
Can you think of any way to alter the script to import saves that do not have whatever it is that it's missing?
It looks like a really good script (helping bring much-needed order), but I do not want to tell people 25-35 hours of their lives were for nothing.
I'm including the script here, since it is nowhere to be found on the web. Admins, after a solution has been found (or if it is determined that a solution can't be found), can you delete this post, so that Zalerinian's work isn't given on the web for free? I will message him myself, just in case.
Thank you in advance for any help. I will include your names in Broken Reality's credits.
The problem I have, is that the script crashes when pressing continue if prexisting saves (where the script didn't exist), exist (the report says the problem is on line 199). Now, I don't mind that for myself, but my Broken Reality RPG (https://lord-rutsah.itch.io/broken-reality) has a lot of content to cover, meaning my players have already invested tens of hours into playing. Due to the multiclass system and the differences it makes in the story, most fans have 2-3 different playthroughs happening at the same time, and I do not want to tell everyone to just start from the scratch.
Can you think of any way to alter the script to import saves that do not have whatever it is that it's missing?
It looks like a really good script (helping bring much-needed order), but I do not want to tell people 25-35 hours of their lives were for nothing.
I'm including the script here, since it is nowhere to be found on the web. Admins, after a solution has been found (or if it is determined that a solution can't be found), can you delete this post, so that Zalerinian's work isn't given on the web for free? I will message him myself, just in case.
Code:
=begin
Configuration:
Here is where you can mess with all the easy-to-change bits of the script. The rest is technically editable, but
it won't be as easy as changing these values here, because these are pre-built into the script to give you
customization.
It is important to realzie that not every possible configuration will work. You could easily cause the screen to
have some issues with oversized windows. I cannot supply a list of every configuration that will work, simply
becuase there are a lot of them. There are still many more that won't work, however. It is up to you to make sure
that your configuration will work bug free. The only thing I can guarantee is that the default will work. If you
find a bug somewhere in the default setup, let me know and I will look into having it fixed. Otherwise I cannot
guarantee support for your configuration, as it is too irrational to expect every possible setup will work.
=end
module Zale
class FilesPlus
FileCount = 16 # How many files can the game have? Default is 16.
FileName = "File " # Name of a save file
Currency = "Gold" # What do you call your currency?
MapIcon = 231 # Icon drawn next to your last location.
MoneyIcon = 262 # Icon drawn next to your money.
TimeIcon = 280 # Icon drawn next to your playtime.
EmptyFileIcon = 226 # Icon drawn next in an empty file window
UsedFileIcon = 230 # Icon drawn next in a used file window
TiledBackground = false # Show a tiled background behind the windows? If false, the background must be configured below.
WindowHeight = 3.2 # Window Height is calculated by taking the screen height and dividing it by this number.
WindowWidth = 1.5 # Window Width is calculated by taking the screen width and dividing it by this number.
DeadZone = 6 # An area that will be accepted as 'close enough' to the target. Low values may cause a graphical glitch, which high numbers may cause the window to become off-center.
FilePadding = 25 # Space between file entries
Level = "Lvl " # Text to write before the actor's level is displayed
LevelColor = Color.new(120, 179, 214) # Color to draw the actor's level in. Default: (120, 179, 214) (light blue). Set to: "default" for the normal color.
DrawFaces = true # Draw character faces? Due to size restrictions, the faces will be resized to fit the windows.
DrawSprites = true # Draw character sprites?
DrawMap = true # Draw a preview of the last area you were in.
DefaultMap = "-1" # ID for the image to be drawn if a map file cannot be found.
HideWindow = true # Hide the window when displaying a map image?
BackgroundColor = Color.new(255, 255, 255, 186) # Color for the background of map images. Will only show if HideWindow is true.
MapOpacity = 186 # Opacity of the map image. 0-255, with 255 being fully opaque and 0 being fully transparant.
ScrollMode = "vertical" # Scroll mode. 'vertical' or 'horizontal'
SlowestSpeed = 8 # The slowest speed the windows will scroll. Negitive numbers will be turned postive.
# Please note that this option has the ability to cause graphical glitches or lockups if an unreasonable number is chosen.
ScrollTime = 3 # How fast will the screen scroll? speed = |distance / frame rate * ScrollTime| + SlowestSpeed
BackgroundTile = "Background" # Name of the background to tile. Located in the system folder.
if $data_system == nil
$data_system = load_data("Data/System.rvdata2") # Load the data system.
end
Title1 = $data_system.title1_name # This file must be located in the Titles1 folder.
Title2 = $data_system.title2_name # This file must be located in the Titles2 folder.
end
end
module Cache
=begin
map_image
This is used to load a map preview image from the Maps folder. This is the image that is will be displayed
if the game creator has opted for showing a map preview. This is where it is loaded.
=end
def self.map_image(filename)
load_bitmap("Graphics/Maps/", filename)
end
end
module DataManager
=begin
make_save_header
Here we define how our savefile's header should look like. This is the data that we will be
using to draw on the windows in the menus. The script_id data bit is used to identify the
script and verify the header is in our format. If the script id string is not found, the
header is recreated in this format, allowing us to draw all our information without worry
that anything is broken.
=end
def self.make_save_header
header = {}
header[:playtime] = $game_system.playtime_s
header[:characters] = $game_party.characters_for_savefile
header[:actors] = $game_party.all_members
header[:money] = $game_party.gold
header[:map] = $game_map.display_name
header[:map_id] = $game_map.map_id
header[:script_id] = "Zale Files+"
header
end
end
class Window_FileInfo < Window_Base
=begin
initialize:
Here is where we make the window itself. We call the superclass method, which will actually make the window based on our
math for the size. To try to get maximum compatibility, we base the window size on the game screen's size, as it may
vary based on the game.
If we are in Horizontal scrolling mode, we want to place the windows in a horizontal line rather than a vertical line,
so we check what mode we are using and then build the windows accordingly. Along with how they are placed, when
scrlling mode is set to horizontal, the variable 'size' will be set to the horizontal width of the window, while in
vertical mode is is the vertical height of the window.
To make it easier to read what forumla is what property, they are split up into separate lines for each one.
The formula 'size * index + size + (Zale::FilesPlus::FilePadding * index)' is simply setting the window up to be placed,
either vertically or horizontally. 'size * index' puts the windows in a line, so that they are not on top of each other.
'+ size' gives the windows an offset from the edge of one window length. '+ (Zale::FilesPlus::FilePadding * index)' adds
the space between each window.
The '+ Graphics.height' bit gives the windows a y offset so that when the scene starts, the windows will scroll into view
rather than be partially visible and off center.
=end
def initialize(size, index)
if Zale::FilesPlus::ScrollMode.downcase == "vertical"
super(Graphics.width / 2 - (Graphics.width / Zale::FilesPlus::WindowWidth / 2),
size * index + size + (Zale::FilesPlus::FilePadding * index) + Graphics.height,
Graphics.width / Zale::FilesPlus::WindowWidth,
size)
elsif Zale::FilesPlus::ScrollMode.downcase == "horizontal"
super(size * index + (size / 4) + (Zale::FilesPlus::FilePadding * index) + Graphics.width,
Graphics.height / 2,
size,
Graphics.height / Zale::FilesPlus::WindowHeight
)
end
@index = index
refresh
end
=begin
header_incorrect?:
This is the model of our header that we want. If we find out the header of a savefile is not the same
as this, then we fix it later. This will only tell us if it is broken, it won't fix it itself.
=end
def header_incorrect?
header = DataManager.load_header(@index)
return true if header[:playtime] == nil
return true if header[:actors] == nil
return true if header[:characters] == nil
return true if header[:money] == nil
return true if header[:map] == nil
return true if header[:map_id] == nil
return true if header[:script_id] != "Zale Files+"
end
=begin
refresh:
refresh is an enourmous bit of data that draws on the windows that represent savefiles. Because there
are multiple conditions regarding the drawing of the windows, this method has gotten more and mroe bloated,
however it has been separated into chunks that will be explained below:
Chunk 1:
In the first chunk, we clear the contents of the bitmap. Because this is a refresh call, we want to make sure
we clear anything on the bitmap first. Next, we see if there is actually a savefile at this index or not. Remember,
this method is being called one at a time as the windows are made in Scene_File. @index refers to which window this
one is. If we do see a savefile, we look at the header data. If we think it's wrong because it doesn't match up to
our model, we load the savefile, and then re-save it, which will create the header in our format. This lets us
draw exactly what we need on it later.
Chunk 2:
Now that we're sure the header is in our format, we lead it into a variable so we can use it easily. Now, if the
game creator has opted to have a map image drawn in place of the window, this if statement is run. It wil hide the
default window, and then check to see if the map image of the player's location exists. This is based on the map ID,
which is in the header, hence why we needed to make sure it was in our format. So we look for the map file. If we
do find it, load it into the variable 'map', then clear the bitmap from the window again, just to be sure it's empty.
Now we do a strech block transfer of the entire loaded image to the entire window content bitmap. This will draw the
map's image on the bitmap that we'll write on later. However, what if we don't find the map image? Then what do we do?
There is a default map image option built in, so we'll load that image and put it on the bitmap the same way as before.
This time, however, if we can't find the default image, we don't have one, so we just show the windows as they normally
are again, so it's not just floating text.
chunk 3:
Now we're going to actually draw some data! Here, we draw the playtime in the top right corner, and the map name in the
top left corner. The measurements may seem difficult and long, but that is mostly just ensuring they will fit the window
even if the game's resolution is different (You can have your game resized up to 640x480). After we draw the playtime
and location onto the window, we draw the sprites of those currently in our party. We have to check the filename for
any '$'s, since that will change the size of the character. After measuring everything we need, we draw the sprites on
the bottom of the window.
chunk 4:
Now, at this point we are running code that will only happen if the savefile at this index doesn't exist. Again, if
the game creator has opted to draw a map image, we'll laod the default one. So we hide our window and see if the
picture exists. If it does, load it up and transfer it to the window's bitmap. If the image still doesn't exist,
though, make the window appear again.
=end
def refresh
contents.clear
if FileTest.exist?(DataManager.make_filename(@index))
DataManager.load_game(@index) # Load the game to get access to the variables.
header_incorrect? ? DataManager.save_game(@index) : nil # Save the game, rewriting the header if it is not in our format.
header = DataManager.load_header(@index)
if Zale::FilesPlus::DrawMap == true
if Zale::FilesPlus::HideWindow == true
self.opacity = 0
self.back_opacity = 0
end
if FileTest.exist?("Graphics/Maps/" + header[:map_id].to_s + ".png") || FileTest.exist?("Graphics/Maps/" + header[:map_id].to_s + ".jpg") || FileTest.exist?("Graphics/Maps/" + header[:map_id].to_s + ".jpeg") || FileTest.exist?("Graphics/Maps/" + header[:map_id].to_s + ".bmp")
map = Cache.map_image(header[:map_id].to_s)
contents.clear
dest = Rect.new(contents.rect.x, contents.rect.y + 24, contents.rect.width, contents.rect.height - 48)
contents.fill_rect(contents.rect, Zale::FilesPlus::BackgroundColor) if Zale::FilesPlus::HideWindow == true
contents.stretch_blt(dest, map, map.rect, Zale::FilesPlus::MapOpacity.to_i)
else # Map does not exist.
if FileTest.exist?("Graphics/Maps/" + Zale::FilesPlus::DefaultMap.to_s + ".png") || FileTest.exist?("Graphics/Maps/" + Zale::FilesPlus::DefaultMap.to_s + ".jpg") || FileTest.exist?("Graphics/Maps/" + Zale::FilesPlus::DefaultMap.to_s + ".jpeg") || FileTest.exist?("Graphics/Maps/" + Zale::FilesPlus::DefaultMap.to_s + ".bmp")
map = Cache.map_image(header[:map_id].to_s)
contents.clear
dest = Rect.new(contents.rect.x, contents.rect.y + 24, contents.rect.width, contents.rect.height - 48)
contents.fill_rect(contents.rect, Zale::FilesPlus::BackgroundColor) if Zale::FilesPlus::HideWindow == true
contents.stretch_blt(dest, map, map.rect, Zale::FilesPlus::MapOpacity.to_i)
else
self.opacity = 255
self.back_opacity = 192
end
end # Map exists?
end # Draw map?
draw_text(contents_width - text_size("Playtime: #{header[:playtime]}").width, 0, text_size("Playtime: #{header[:playtime]}").width, Font.default_size, "Playtime: #{header[:playtime]}")
draw_text(26, contents_height - text_size("Location: #{header[:map]}").height, text_size("Location: #{header[:map]}").width, Font.default_size, "Location: #{header[:map]}")
draw_text(26, 0, self.width / 2, Font.default_size, Zale::FilesPlus::FileName + (@index + 1).to_s) # File Name
draw_text(contents_width - text_size("#{Zale::FilesPlus::Currency}: #{$game_party.max_gold}").width, contents_height - Font.default_size, self.width / 2, Font.default_size, "#{Zale::FilesPlus::Currency}: #{header[:money]}")
# Draw all the icons
draw_icon(Zale::FilesPlus::TimeIcon, contents_width - text_size("Playtime: #{header[:playtime]}").width - 26, 0) # Playtime
draw_icon(Zale::FilesPlus::MapIcon, 0, contents_height - Font.default_size) # Map
draw_icon(Zale::FilesPlus::MoneyIcon, contents_width - text_size("#{Zale::FilesPlus::Currency}: #{$game_party.max_gold}").width - 26, contents_height - Font.default_size) # Gold
draw_icon(Zale::FilesPlus::UsedFileIcon, 0, 0) # File
# if Zale::FilesPlus::DrawFaces == true
# header[:characters].each_with_index {|img, index|
# x = 96 * (header[:characters].size / 4) * index + Zale::FilesPlus::SidePadding
# y = self.height / 2 - 96 / 2
# draw_face(img[0], img[1], x, y)
# }
# end
if Zale::FilesPlus::DrawSprites == true
header[:characters].each_with_index {|img, index|
char_height = img[0][/^\$./] ? Cache.character(img[0]).height / 4 : Cache.character(img[0]).height / 8
char_width = img[0][/^\$./] ? Cache.character(img[0]).width / 3 : Cache.character(img[0]).width / 12
char_count = header[:characters].size / 2
# self.width / (header[:characters].size * 2) + (self.width / (header[:characters].size) * index) - (char_width / 2) Centers them horizontally.
x = self.width / (header[:characters].size * 2) + (self.width / (header[:characters].size) * index) - (char_width / 2)
y = contents_height / 2 + char_height / 2
draw_character(img[0], img[1], x, y)
# Draw the character's levels.
Zale::FilesPlus::LevelColor == "default" ? change_color(normal_color) : change_color(Zale::FilesPlus::LevelColor)
draw_text(x - 15, y - 8, char_width + 15, char_height, Zale::FilesPlus::Level + header[:actors][index].level.to_s)
change_color(normal_color) # normal_color is definied in Window_Base
}
end
else # Save doesn't exist.
draw_text(24, 0, self.width / 2, Font.default_size, Zale::FilesPlus::FileName + (@index + 1).to_s)
draw_icon(Zale::FilesPlus::EmptyFileIcon, 0, 0)
if Zale::FilesPlus::DrawMap == true
if Zale::FilesPlus::HideWindow == true
self.opacity = 0
self.back_opacity = 0
end
if FileTest.exist?("Graphics/Maps/" + Zale::FilesPlus::DefaultMap.to_s + ".png") || FileTest.exist?("Graphics/Maps/" + Zale::FilesPlus::DefaultMap.to_s + ".jpg") || FileTest.exist?("Graphics/Maps/" + Zale::FilesPlus::DefaultMap.to_s + ".jpeg") || FileTest.exist?("Graphics/Maps/" + Zale::FilesPlus::DefaultMap.to_s + ".bmp")
map = Cache.map_image(Zale::FilesPlus::DefaultMap)
contents.clear
dest = Rect.new(contents.rect.x, contents.rect.y + 24, contents.rect.width, contents.rect.height - 48)
contents.fill_rect(contents.rect, Zale::FilesPlus::BackgroundColor) if Zale::FilesPlus::HideWindow == true
contents.stretch_blt(dest, map, map.rect, Zale::FilesPlus::MapOpacity)
else
self.opacity = 255
self.back_opacity = 192
end
end
end # Save Exists?
end # Method
end # Class
class Scene_File < Scene_MenuBase
=begin
start:
Begin the scene, call the superclass' start method, then create the viewports, then the windows, and finally set @index to 0.
After this, update is called until this scene is exited.
=end
def start
super
@index = 0
create_viewports
create_windows
end
=begin
create_viewports:
Here we create two additional viewports. One for the background, @back, and one for the scrolling windows,
@scroll. @scroll is put ontop of @back so that it shows ontop of it.
The ox and oy values are used for scrolling the viewports.
=end
def create_viewports
if Zale::FilesPlus::TiledBackground == true
@back = Viewport.new
@back.z = 105
@back.oy = 0
@back.ox = 0
@background = Plane.new(@back)
@background.bitmap = Cache.system(Zale::FilesPlus::BackgroundTile)
else
@sprite1 = Sprite.new
@sprite1.bitmap = Cache.title1(Zale::FilesPlus::Title1)
@sprite1.ox = @sprite1.bitmap.width / 2
@sprite1.oy = @sprite1.bitmap.height / 2
@sprite1.x = Graphics.width / 2
@sprite1.y = Graphics.height / 2
@sprite2 = Sprite.new
@sprite2.bitmap = Cache.title2(Zale::FilesPlus::Title2)
@sprite2.ox = @sprite2.bitmap.width / 2
@sprite2.oy = @sprite2.bitmap.height / 2
@sprite2.x = Graphics.width / 2
@sprite2.y = Graphics.height / 2
end
@scroll = Viewport.new
@scroll.z = 110
@scroll.oy = 0
@scroll.ox = 0
end
=begin
create_windows:
This creates a new Plane object, and assigns it a bitmap. Plane objects take their bitmap and tile it, so it
is used to make the background. It it put on the @back viewport so as to avoid any interference with the windows.
This method also creates all the windows, which are stored in an array by the name of @files.
=end
def create_windows
if Zale::FilesPlus::ScrollMode.downcase == "vertical"
@files = Array.new(Zale::FilesPlus::FileCount){ |i|
Window_FileInfo.new(Graphics.height / Zale::FilesPlus::WindowHeight, i)
}
elsif Zale::FilesPlus::ScrollMode.downcase == "horizontal"
@files = Array.new(Zale::FilesPlus::FileCount) {|i|
Window_FileInfo.new(Graphics.width / Zale::FilesPlus::WindowWidth, i)
}
end
@files.each {|win| win.viewport = @scroll }
process_movement("setup")
end
=begin
update:
Update the screen, input, and all other bits of the system.
Input processing here will change based on the scroll mode and the current index.
=end
def update
super
if (Input.trigger?(:UP) || (Input.repeat?(:UP) && @index != 0 )) && Zale::FilesPlus::ScrollMode.downcase == "vertical"
process_movement("up")
elsif (Input.trigger?(:DOWN) || (Input.repeat?(:DOWN) && @index != Zale::FilesPlus::FileCount - 1 )) && Zale::FilesPlus::ScrollMode.downcase == "vertical"
process_movement("down")
elsif (Input.trigger?(:R) || (Input.repeat?(:R) && @index != Zale::FilesPlus::FileCount - 1 )) && Zale::FilesPlus::ScrollMode.downcase == "vertical" # :R is Pagedown
process_movement("pgd")
elsif (Input.trigger?(:L) || (Input.repeat?(:L) && @index != 0 )) && Zale::FilesPlus::ScrollMode.downcase == "vertical" # :L is Pageup
process_movement("pgu")
elsif (Input.trigger?(:LEFT) || (Input.repeat?(:LEFT) && @index != 0)) && Zale::FilesPlus::ScrollMode.downcase == "horizontal"
process_movement("left")
elsif (Input.trigger?(:RIGHT) || (Input.repeat?(:RIGHT) && @index != Zale::FilesPlus::FileCount - 1 )) && Zale::FilesPlus::ScrollMode.downcase == "horizontal"
process_movement("right")
elsif (Input.trigger?(:L) || (Input.repeat?(:L) && @index != 0)) && Zale::FilesPlus::ScrollMode.downcase == "horizontal"
process_movement("h_pgu")
elsif (Input.trigger?(:R) || (Input.repeat?(:R) && @index != Zale::FilesPlus::FileCount - 1)) && Zale::FilesPlus::ScrollMode.downcase == "horizontal"
process_movement("h_pgd")
elsif Input.trigger?(:C) # Enter is pressed.
on_savefile_ok
elsif Input.trigger?(:B) # Esc is pressed.
on_savefile_cancel
else
end # Input check statement.
# update the fiber.
if @fiber
@fiber.resume
end
end
=begin
process_movement:
This method changes the value of @index based on the key that was pressed and the current location of the cursor.
'dir' refers to the key pressed, and is used to determine the DIRection to scroll.
=end
def process_movement(dir = "")
case dir
when "up"
@index == 0 ? @index = Zale::FilesPlus::FileCount - 1 : @index -= 1
when "pgu" #Pageup
@index == 0 ? @index = Zale::FilesPlus::FileCount - 1 : @index - Zale::FilesPlus::WindowHeight.ceil <= 0 ? @index = 0 : @index -= Zale::FilesPlus::WindowHeight.ceil
when "down"
@index == Zale::FilesPlus::FileCount - 1 ? @index = 0 : @index += 1
when "pgd" # Pagedown.
@index == Zale::FilesPlus::FileCount - 1 ? @index = 0 : @index + Zale::FilesPlus::WindowHeight.ceil >= Zale::FilesPlus::FileCount - 1 ? @index = Zale::FilesPlus::FileCount - 1 : @index += Zale::FilesPlus::WindowHeight.ceil
when "left"
@index == 0 ? @index = Zale::FilesPlus::FileCount - 1 : @index -= 1
when "h_pgu"
@index == 0 ? @index = Zale::FilesPlus::FileCount - 1 : @index - Zale::FilesPlus::WindowWidth.ceil <= 0 ? @index = 0 : @index -= Zale::FilesPlus::WindowWidth.ceil
when "right"
@index == Zale::FilesPlus::FileCount - 1 ? @index = 0 : @index += 1
when "h_pgd"
@index == Zale::FilesPlus::FileCount - 1 ? @index = 0 : @index + Zale::FilesPlus::WindowWidth.ceil >= Zale::FilesPlus::FileCount - 1 ? @index = Zale::FilesPlus::FileCount - 1 : @index += Zale::FilesPlus::WindowWidth.ceil
end
if @fiber == nil
if Zale::FilesPlus::ScrollMode.downcase == "vertical"
@fiber = Fiber.new { scroll_v }
elsif Zale::FilesPlus::ScrollMode.downcase == "horizontal"
@fiber = Fiber.new { scroll_h }
else
end
@fiber.resume
end
end
=begin
scroll_v:
'distance' is how far the screen needs to scroll. How far away is the intended location? It takes the y co-ordinate
of the window that is 'selected', and subtracts half it's height. It then takes this number and subtracts the y of the
current view in the viewport, so the y of what we're seeing, plus one fourth of the screen size. The resulting number is
target for where the viewport will be looking.
In order to exit the scrolling and let the rest of the game continue updating, the loop that causes the scroll will break
once the distance left to scroll is within 6 pixels of the target in either direction, leaving a 13 pixel 'deadzone'.
@scroll.oy (+|-)= (formula) and @back.oy (+|-)= (formula) is what actually causes the scroll. It takes the distance that
it needs to travel, and divides it by the game's framerate. Then, this number is multiplied by scroll time option, and
the absolute value (The number represented as a positive) is taken of it. This will give it the distance it needs to move
to be able to reach its destination in, at most, the specified number of seconds. In order to prevent movements of 1 pixel
per frame update, a minimum speed may be set.
Next, update the graphics so the change is visibile on the screen.
Finally, yield the fiber so the rest of the game can update. The fiber is resumed by the update method once everything else
has had a chance to update.
=end
def scroll_v
loop do
if @scroll.oy + Graphics.height / 4 < @files[@index].y - @files[@index].height / 2
distance = ((@files[@index].y - @files[@index].height / 2) - (@scroll.oy + Graphics.height / 4)).abs
case distance; when -Zale::FilesPlus::DeadZone..Zale::FilesPlus::DeadZone; break; end;
@scroll.oy += (distance / Graphics.frame_rate * Zale::FilesPlus::ScrollTime).abs + Zale::FilesPlus::SlowestSpeed.abs
if @back
@back.oy += (distance / Graphics.frame_rate * Zale::FilesPlus::ScrollTime).abs + Zale::FilesPlus::SlowestSpeed.abs
end
Graphics.update
Fiber.yield
elsif @scroll.oy + Graphics.height / 4 > (@files[@index].y - @files[@index].height / 2).abs
distance = ((@files[@index].y - @files[@index].height / 2) - (@scroll.oy + Graphics.height / 4)).abs
case distance; when -Zale::FilesPlus::DeadZone..Zale::FilesPlus::DeadZone; break; end;
@scroll.oy -= (distance / Graphics.frame_rate * Zale::FilesPlus::ScrollTime).abs + Zale::FilesPlus::SlowestSpeed.abs
if @back
@back.oy -= (distance / Graphics.frame_rate * Zale::FilesPlus::ScrollTime).abs + Zale::FilesPlus::SlowestSpeed.abs
end
Graphics.update
Fiber.yield
else
break
end
end
@fiber = nil
end
=begin
scroll_h:
The same as scroll_v, however this method scrolls on the horizontal axis rather than the vertical. The distance formula for
the horizontal scroll is slightly modified.
=end
def scroll_h
loop do
if @scroll.ox < (@files[@index].x - @files[@index].width / 4).abs
distance = ((@files[@index].x - @files[@index].width / 4).abs - @scroll.ox).abs
case distance; when -Zale::FilesPlus::DeadZone..Zale::FilesPlus::DeadZone; break; end
@scroll.ox += (distance / Graphics.frame_rate * Zale::FilesPlus::ScrollTime) + Zale::FilesPlus::SlowestSpeed.abs
if @back
@back.ox += (distance / Graphics.frame_rate * Zale::FilesPlus::ScrollTime) + Zale::FilesPlus::SlowestSpeed.abs
end
Graphics.update
Fiber.yield
elsif @scroll.ox > (@files[@index].x - @files[@index].width / 4).abs
distance = ((@files[@index].x - @files[@index].width / 4).abs - @scroll.ox).abs
case distance; when -Zale::FilesPlus::DeadZone..Zale::FilesPlus::DeadZone; break; end
@scroll.ox -= (distance / Graphics.frame_rate * Zale::FilesPlus::ScrollTime) + Zale::FilesPlus::SlowestSpeed.abs
if @back
@back.ox -= (distance / Graphics.frame_rate * Zale::FilesPlus::ScrollTime) + Zale::FilesPlus::SlowestSpeed.abs
end
Graphics.update
Fiber.yield
else
break
end
end
@fiber = nil
end
=begin
on_savefile_ok
Called when the :C key is pressed. By default this is enter. This method's action depends on the calling scene.
=end
def on_savefile_ok
end
=begin
on_savefile_cancel
Called when the :B key is pressed. By default this is esc. This will return to the previous scene.
=end
def on_savefile_cancel
Sound.play_cancel
SceneManager.return
end
=begin
Terminate:
Finally, delete all the windows and viewports, since we are leaving the scene and nothing here is needed any longer.
=end
def terminate
super
@scroll.dispose if @scroll
@back.dispose if @back
@background.dispose if @background
@sprite1.dispose if @sprite1
@sprite2.dispose if @sprite2
@files.each {|win| win.dispose }
end
end
Thank you in advance for any help. I will include your names in Broken Reality's credits.
