mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
More or less standardised separator comments in the code
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
#===============================================================================
|
||||
# The Game module contains methods for saving and loading the game.
|
||||
#===============================================================================
|
||||
module Game
|
||||
module_function
|
||||
|
||||
# Initializes various global variables and loads the game data.
|
||||
def self.initialize
|
||||
def initialize
|
||||
$game_temp = Game_Temp.new
|
||||
$game_system = Game_System.new
|
||||
$data_animations = load_data("Data/Animations.rxdata")
|
||||
@@ -18,7 +22,7 @@ module Game
|
||||
|
||||
# Loads bootup data from save file (if it exists) or creates bootup data (if
|
||||
# it doesn't).
|
||||
def self.set_up_system
|
||||
def set_up_system
|
||||
save_data = (SaveData.exists?) ? SaveData.read_from_file(SaveData::FILE_PATH) : {}
|
||||
if save_data.empty?
|
||||
SaveData.initialize_bootup_values
|
||||
@@ -36,7 +40,7 @@ module Game
|
||||
|
||||
# Called when starting a new game. Initializes global variables
|
||||
# and transfers the player into the map scene.
|
||||
def self.start_new
|
||||
def start_new
|
||||
if $game_map&.events
|
||||
$game_map.events.each_value { |event| event.clear_starting }
|
||||
end
|
||||
@@ -60,12 +64,12 @@ module Game
|
||||
# Loads the game from the given save data and starts the map scene.
|
||||
# @param save_data [Hash] hash containing the save data
|
||||
# @raise [SaveData::InvalidValueError] if an invalid value is being loaded
|
||||
def self.load(save_data)
|
||||
def load(save_data)
|
||||
validate save_data => Hash
|
||||
SaveData.load_all_values(save_data)
|
||||
$game_temp.last_uptime_refreshed_play_time = System.uptime
|
||||
$stats.play_sessions += 1
|
||||
self.load_map
|
||||
load_map
|
||||
pbAutoplayOnSave
|
||||
$game_map.update
|
||||
$PokemonMap.updateMap
|
||||
@@ -73,7 +77,7 @@ module Game
|
||||
end
|
||||
|
||||
# Loads and validates the map. Called when loading a saved game.
|
||||
def self.load_map
|
||||
def load_map
|
||||
$game_map = $map_factory.map
|
||||
magic_number_matches = ($game_system.magic_number == $data_system.magic_number)
|
||||
if !magic_number_matches || $PokemonGlobal.safesave
|
||||
@@ -108,7 +112,7 @@ module Game
|
||||
# @param safe [Boolean] whether $PokemonGlobal.safesave should be set to true
|
||||
# @return [Boolean] whether the operation was successful
|
||||
# @raise [SaveData::InvalidValueError] if an invalid value is being saved
|
||||
def self.save(save_file = SaveData::FILE_PATH, safe: false)
|
||||
def save(save_file = SaveData::FILE_PATH, safe: false)
|
||||
validate save_file => String, safe => [TrueClass, FalseClass]
|
||||
$PokemonGlobal.safesave = safe
|
||||
$game_system.save_count += 1
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#===============================================================================
|
||||
# ** Modified Scene_Map class for Pokémon.
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# Modified Scene_Map class for Pokémon.
|
||||
#===============================================================================
|
||||
class Scene_Map
|
||||
attr_reader :spritesetGlobal
|
||||
|
||||
@@ -42,24 +42,26 @@
|
||||
module EventHandlers
|
||||
@@events = {}
|
||||
|
||||
module_function
|
||||
|
||||
# Add a named callback for the given event.
|
||||
def self.add(event, key, proc)
|
||||
def add(event, key, proc)
|
||||
@@events[event] = NamedEvent.new if !@@events.has_key?(event)
|
||||
@@events[event].add(key, proc)
|
||||
end
|
||||
|
||||
# Remove a named callback from the given event.
|
||||
def self.remove(event, key)
|
||||
def remove(event, key)
|
||||
@@events[event]&.remove(key)
|
||||
end
|
||||
|
||||
# Clear all callbacks for the given event.
|
||||
def self.clear(key)
|
||||
def clear(key)
|
||||
@@events[key]&.clear
|
||||
end
|
||||
|
||||
# Trigger all callbacks from an Event if it has been defined.
|
||||
def self.trigger(event, *args)
|
||||
def trigger(event, *args)
|
||||
return @@events[event]&.trigger(*args)
|
||||
end
|
||||
end
|
||||
@@ -80,25 +82,27 @@ end
|
||||
module MenuHandlers
|
||||
@@handlers = {}
|
||||
|
||||
def self.add(menu, option, hash)
|
||||
module_function
|
||||
|
||||
def add(menu, option, hash)
|
||||
@@handlers[menu] = HandlerHash.new if !@@handlers.has_key?(menu)
|
||||
@@handlers[menu].add(option, hash)
|
||||
end
|
||||
|
||||
def self.remove(menu, option)
|
||||
def remove(menu, option)
|
||||
@@handlers[menu]&.remove(option)
|
||||
end
|
||||
|
||||
def self.clear(menu)
|
||||
def clear(menu)
|
||||
@@handlers[menu]&.clear
|
||||
end
|
||||
|
||||
def self.each(menu)
|
||||
def each(menu)
|
||||
return if !@@handlers.has_key?(menu)
|
||||
@@handlers[menu].each { |option, hash| yield option, hash }
|
||||
end
|
||||
|
||||
def self.each_available(menu, *args)
|
||||
def each_available(menu, *args)
|
||||
return if !@@handlers.has_key?(menu)
|
||||
options = @@handlers[menu]
|
||||
keys = options.keys
|
||||
@@ -115,7 +119,7 @@ module MenuHandlers
|
||||
end
|
||||
end
|
||||
|
||||
def self.call(menu, option, function, *args)
|
||||
def call(menu, option, function, *args)
|
||||
option_hash = @@handlers[menu][option]
|
||||
return nil if !option_hash || !option_hash[function]
|
||||
return option_hash[function].call(*args)
|
||||
|
||||
Reference in New Issue
Block a user