mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Tweaks relating to previous commit
This commit is contained in:
@@ -50,7 +50,7 @@ def pbPrintException(e)
|
||||
|
||||
print("#{message}\r\nThis exception was logged in #{errorlogline}.\r\nHold Ctrl after closing this message to copy it to the clipboard.")
|
||||
# Give a ~500ms coyote time to start holding Control
|
||||
(0.5 / (1.0 / Graphics.frame_rate)).ceil.times{
|
||||
(Graphics.frame_rate / 2).ceil.times{
|
||||
Graphics.update
|
||||
Input.update
|
||||
if Input.press?(Input::CTRL)
|
||||
|
||||
@@ -66,8 +66,15 @@ class TileDrawingHelper
|
||||
return self.new(bmtileset,bmautotiles)
|
||||
end
|
||||
|
||||
def initialize(tileset,autotiles)
|
||||
def initialize(tileset, autotiles)
|
||||
if tileset.mega?
|
||||
@tileset = TileWrap::wrapTileset(tileset)
|
||||
tileset.dispose
|
||||
@shouldWrap = true
|
||||
else
|
||||
@tileset = tileset
|
||||
@shouldWrap = false
|
||||
end
|
||||
@autotiles = autotiles
|
||||
end
|
||||
|
||||
@@ -107,6 +114,7 @@ class TileDrawingHelper
|
||||
def bltSmallRegularTile(bitmap,x,y,cxTile,cyTile,id)
|
||||
return if id < 384 || !@tileset || @tileset.disposed?
|
||||
rect = Rect.new((id - 384) % 8 * 32, (id - 384) / 8 * 32, 32, 32)
|
||||
rect = TileWrap::getWrappedRect(rect) if @shouldWrap
|
||||
bitmap.stretch_blt(Rect.new(x, y, cxTile, cyTile), @tileset, rect)
|
||||
end
|
||||
|
||||
|
||||
@@ -38,113 +38,6 @@ end
|
||||
|
||||
|
||||
|
||||
#####################################################################
|
||||
# TODO: Delete this class in Ruby 2+.
|
||||
class WeakRef
|
||||
@@id_map = {}
|
||||
@@id_rev_map = {}
|
||||
@@final = lambda do |id|
|
||||
rids = @@id_map[id]
|
||||
if rids
|
||||
rids.each { |rid| @@id_rev_map.delete(rid) }
|
||||
@@id_map.delete(id)
|
||||
end
|
||||
rid = @@id_rev_map[id]
|
||||
if rid
|
||||
@@id_rev_map.delete(id)
|
||||
@@id_map[rid].delete(id)
|
||||
@@id_map.delete(rid) if @@id_map[rid].empty?
|
||||
end
|
||||
end
|
||||
|
||||
# Create a new WeakRef from +orig+.
|
||||
def initialize(orig)
|
||||
__setobj__(orig)
|
||||
end
|
||||
|
||||
def __getobj__
|
||||
unless @@id_rev_map[self.__id__] == @__id
|
||||
return nil
|
||||
end
|
||||
begin
|
||||
ObjectSpace._id2ref(@__id)
|
||||
rescue RangeError
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def __setobj__(obj)
|
||||
@__id = obj.__id__
|
||||
unless @@id_rev_map.key?(self)
|
||||
ObjectSpace.define_finalizer obj, @@final
|
||||
ObjectSpace.define_finalizer self, @@final
|
||||
end
|
||||
@@id_map[@__id] = [] unless @@id_map[@__id]
|
||||
@@id_map[@__id].push self.__id__
|
||||
@@id_rev_map[self.__id__] = @__id
|
||||
end
|
||||
|
||||
# Returns true if the referenced object still exists, and false if it has
|
||||
# been garbage collected.
|
||||
def weakref_alive?
|
||||
@@id_rev_map[self.__id__] == @__id
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
# TODO: Delete this class in Ruby 2+.
|
||||
class WeakHashtable
|
||||
include Enumerable
|
||||
|
||||
def initialize
|
||||
@hash = {}
|
||||
end
|
||||
|
||||
def clear
|
||||
@hash.clear
|
||||
end
|
||||
|
||||
def delete(value)
|
||||
@hash.delete(value)
|
||||
end
|
||||
|
||||
def include?(value)
|
||||
@hash.include?(value)
|
||||
end
|
||||
|
||||
def each
|
||||
@hash.each { |i| yield i }
|
||||
end
|
||||
|
||||
def keys
|
||||
@hash.keys
|
||||
end
|
||||
|
||||
def values
|
||||
@hash.values
|
||||
end
|
||||
|
||||
def [](key)
|
||||
o = @hash[key]
|
||||
return o if !o
|
||||
if o.weakref_alive?
|
||||
o = o.__getobj__
|
||||
else
|
||||
@hash.delete(key)
|
||||
o = nil
|
||||
end
|
||||
return o
|
||||
end
|
||||
|
||||
def []=(key, o)
|
||||
o = WeakRef.new(o) if o != nil
|
||||
@hash[key] = o
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
module RPG
|
||||
module Cache
|
||||
def self.load_bitmap(folder_name, filename, hue = 0)
|
||||
@@ -247,9 +140,7 @@ end
|
||||
|
||||
|
||||
module BitmapCache
|
||||
# TODO: Replace this with the commented line in Ruby 2+.
|
||||
@cache = WeakHashtable.new
|
||||
# @cache = ObjectSpace::WeakMap.new
|
||||
@cache = ObjectSpace::WeakMap.new
|
||||
|
||||
def self.fromCache(i)
|
||||
return nil if !@cache.include?(i)
|
||||
@@ -279,17 +170,9 @@ module BitmapCache
|
||||
|
||||
def self.load_bitmap(path, hue = 0, failsafe = false)
|
||||
cached = true
|
||||
path = canonicalize(path)
|
||||
path = -canonicalize(path) # Creates a frozen string from the path, to ensure identical paths are treated as identical
|
||||
objPath = fromCache(path)
|
||||
if !objPath
|
||||
# TODO: Delete this in Ruby 2+.
|
||||
@cleancounter = ((@cleancounter || 0) + 1) % 10
|
||||
if @cleancounter == 0
|
||||
for i in @cache.keys
|
||||
@cache.delete(i) if !fromCache(i)
|
||||
end
|
||||
end
|
||||
# TODO: Up to here.
|
||||
begin
|
||||
bm = BitmapWrapper.new(path)
|
||||
rescue Hangup
|
||||
@@ -402,9 +285,7 @@ module BitmapCache
|
||||
end
|
||||
|
||||
def self.clear
|
||||
# TODO: Replace this with the commented line in Ruby 2+.
|
||||
@cache.clear
|
||||
# @cache = ObjectSpace::WeakMap.new
|
||||
@cache = ObjectSpace::WeakMap.new
|
||||
GC.start
|
||||
end
|
||||
end
|
||||
|
||||
@@ -373,12 +373,12 @@ def pbBattleOnStepTaken(repel_active)
|
||||
return if !$PokemonEncounters.encounter_possible_here?
|
||||
encounterType = $PokemonEncounters.encounter_type
|
||||
return if encounterType < 0
|
||||
return if !$PokemonEncounter.step_triggers_encounter?(encounterType)
|
||||
return if !$PokemonEncounters.step_triggers_encounter?(encounterType)
|
||||
$PokemonTemp.encounterType = encounterType
|
||||
encounter = $PokemonEncounters.choose_wild_pokemon(encounterType)
|
||||
encounter = EncounterModifier.trigger(encounter)
|
||||
if $PokemonEncounter.allow_encounter?(encounter, repel_active)
|
||||
if $PokemonEncounter.have_double_wild_battle?
|
||||
if $PokemonEncounters.allow_encounter?(encounter, repel_active)
|
||||
if $PokemonEncounters.have_double_wild_battle?
|
||||
encounter2 = $PokemonEncounters.choose_wild_pokemon(encounterType)
|
||||
encounter2 = EncounterModifier.trigger(encounter2)
|
||||
pbDoubleWildBattle(encounter[0], encounter[1], encounter2[0], encounter2[1])
|
||||
|
||||
@@ -229,7 +229,7 @@ class PokemonPokedexInfo_Scene
|
||||
# Write the height and weight
|
||||
height = species_data.height
|
||||
weight = species_data.weight
|
||||
if pbGetCountry == 0xF4 # If the user is in the United States
|
||||
if System.user_language[3..4] == "US" # If the user is in the United States
|
||||
inches = (height / 0.254).round
|
||||
pounds = (weight / 0.45359).round
|
||||
textpos.push([_ISPRINTF("{1:d}'{2:02d}\"", inches / 12, inches % 12), 460, 158, 1, base, shadow])
|
||||
@@ -263,7 +263,7 @@ class PokemonPokedexInfo_Scene
|
||||
# Write the category
|
||||
textpos.push([_INTL("????? Pokémon"), 246, 74, 0, base, shadow])
|
||||
# Write the height and weight
|
||||
if pbGetCountry == 0xF4 # If the user is in the United States
|
||||
if System.user_language[3..4] == "US" # If the user is in the United States
|
||||
textpos.push([_INTL("???'??\""), 460, 158, 1, base, shadow])
|
||||
textpos.push([_INTL("????.? lbs."), 494, 190, 1, base, shadow])
|
||||
else
|
||||
|
||||
@@ -171,11 +171,7 @@ class PokemonRegionMap_Scene
|
||||
# TODO: Why is this PBS file writer here?
|
||||
def pbSaveMapData
|
||||
File.open("PBS/townmap.txt","wb") { |f|
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
Compiler.add_PBS_header_to_file(f)
|
||||
for i in 0...@mapdata.length
|
||||
map = @mapdata[i]
|
||||
next if !map
|
||||
|
||||
@@ -851,33 +851,33 @@ class AnimationCanvas < Sprite
|
||||
@dirty[@currentcel]=true
|
||||
return
|
||||
end
|
||||
if Input.triggerex?(0x50) || Input.repeatex?(0x50) # "P" for properties
|
||||
if Input.triggerex?(:P) || Input.repeatex?(:P) # Properties
|
||||
pbCellProperties(self)
|
||||
@dirty[@currentcel]=true
|
||||
return
|
||||
end
|
||||
if Input.triggerex?(0x4C) || Input.repeatex?(0x4C) # "L" for lock
|
||||
if Input.triggerex?(:L) || Input.repeatex?(:L) # Lock
|
||||
cel[AnimFrame::LOCKED]=(cel[AnimFrame::LOCKED]==0) ? 1 : 0
|
||||
@dirty[@currentcel]=true
|
||||
end
|
||||
if Input.triggerex?(0x52) || Input.repeatex?(0x52) # "R" for rotate right
|
||||
if Input.triggerex?(:R) || Input.repeatex?(:R) # Rotate right
|
||||
cel[AnimFrame::ANGLE]+=10
|
||||
cel[AnimFrame::ANGLE]%=360
|
||||
@dirty[@currentcel]=true
|
||||
end
|
||||
if Input.triggerex?(0x45) || Input.repeatex?(0x45) # "E" for rotate left
|
||||
if Input.triggerex?(:E) || Input.repeatex?(:E) # Rotate left
|
||||
cel[AnimFrame::ANGLE]-=10
|
||||
cel[AnimFrame::ANGLE]%=360
|
||||
@dirty[@currentcel]=true
|
||||
end
|
||||
if Input.triggerex?(0x6B) || Input.repeatex?(0x6B) # "+" for zoom in
|
||||
if Input.triggerex?(:KP_PLUS) || Input.repeatex?(:KP_PLUS) # Zoom in
|
||||
cel[AnimFrame::ZOOMX]+=10
|
||||
cel[AnimFrame::ZOOMX]=1000 if cel[AnimFrame::ZOOMX]>1000
|
||||
cel[AnimFrame::ZOOMY]+=10
|
||||
cel[AnimFrame::ZOOMY]=1000 if cel[AnimFrame::ZOOMY]>1000
|
||||
@dirty[@currentcel]=true
|
||||
end
|
||||
if Input.triggerex?(0x6D) || Input.repeatex?(0x6D) # "-" for zoom in
|
||||
if Input.triggerex?(:KP_MINUS) || Input.repeatex?(:KP_MINUS) # Zoom out
|
||||
cel[AnimFrame::ZOOMX]-=10
|
||||
cel[AnimFrame::ZOOMX]=10 if cel[AnimFrame::ZOOMX]<10
|
||||
cel[AnimFrame::ZOOMY]-=10
|
||||
|
||||
@@ -1054,7 +1054,7 @@ def animationEditorMain(animation)
|
||||
sliderwin.invalidate
|
||||
end
|
||||
next
|
||||
elsif Input.triggerex?(0x51) # Q
|
||||
elsif Input.triggerex?(:Q)
|
||||
if canvas.currentCel
|
||||
pbDefinePath(canvas)
|
||||
sliderwin.invalidate
|
||||
|
||||
Reference in New Issue
Block a user