From 401116b014ac2443aada5db71914c328b0928240 Mon Sep 17 00:00:00 2001 From: DepressedTWM Date: Sun, 9 Aug 2026 00:58:04 +0400 Subject: [PATCH] fdfdf --- scripts/CMakeLists.txt | 6 +- scripts/Data_Settings.rb | 1 - scripts/Scene_File.rb | 131 +++++++++++++++++++++++++++++++++++++ scripts/Scene_Load.rb | 116 ++++++++++++++++++++++++++++++++ scripts/Scene_Map.rb | 5 +- scripts/Scene_Save.rb | 88 +++++++++++++++++++++++++ scripts/Window_SaveFile.rb | 91 ++++++++++++++++++++++++++ scripts/_scripts.txt | 4 ++ 8 files changed, 439 insertions(+), 3 deletions(-) create mode 100644 scripts/Scene_File.rb create mode 100644 scripts/Scene_Load.rb create mode 100644 scripts/Scene_Save.rb create mode 100644 scripts/Window_SaveFile.rb diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 71965e0..c612fc8 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -88,7 +88,11 @@ set(scripts Input.rb Dynamic_Light.rb Dynamic_Resolution.rb - ModAPI.rb) + ModAPI.rb + Scene_Save.rb + Scene_File.rb + Window_SaveFile.rb + Scene_Load.rb) find_program(RUBY_EXE ruby DOC "Location of the Ruby executable") set(game_dir "${CMAKE_BINARY_DIR}/bin") diff --git a/scripts/Data_Settings.rb b/scripts/Data_Settings.rb index b2dc8cb..b4a050a 100644 --- a/scripts/Data_Settings.rb +++ b/scripts/Data_Settings.rb @@ -301,7 +301,6 @@ class Window_Settings { :type => :bool, :name => "Disable System API Dependent Puzzles(For wayland users)", - :icon => [0, 1], :parameter => :disable_pizzles_for_fuckin_gayland_users_gayland_devs_fix_your_bullshit_already }, ], diff --git a/scripts/Scene_File.rb b/scripts/Scene_File.rb new file mode 100644 index 0000000..89968a3 --- /dev/null +++ b/scripts/Scene_File.rb @@ -0,0 +1,131 @@ +#============================================================================== +# ** Scene_File +#------------------------------------------------------------------------------ +# This is a superclass for the save screen and load screen. +#============================================================================== + +class Scene_File + #-------------------------------------------------------------------------- + # * Object Initialization + # help_text : text string shown in the help window + #-------------------------------------------------------------------------- + def initialize(help_text) + @help_text = help_text + end + #-------------------------------------------------------------------------- + # * Main Processing + #-------------------------------------------------------------------------- + def main + # Make help window + @help_window = Window_Help.new + @help_window.set_text(@help_text) + # Make save file window + @savefile_windows = [] + for i in 0..99 + @savefile_windows.push(Window_SaveFile.new(i, make_filename(i))) + end + # Select last file to be operated + @file_index = $game_temp.last_file_index + @savefile_windows[@file_index].selected = true + updateVisibleSavefileWindows + # Execute transition + Graphics.transition + # Main loop + while true + # Update game screen + Graphics.update + # Update input information + Input.update + # Frame update + update + # Abort loop if screen is changed + if $scene != self + break + end + end + # Prepare for transition + Graphics.freeze + # Dispose of windows + @help_window.dispose + for i in @savefile_windows + i.dispose + end + end + #-------------------------------------------------------------------------- + # * Frame Update + #-------------------------------------------------------------------------- + def update + # Update windows + @help_window.update + for i in @savefile_windows + i.update + end + # If C button was pressed + if Input.trigger?(Input::ACTION) + # Call method: on_decision (defined by the subclasses) + on_decision(make_filename(@file_index)) + $game_temp.last_file_index = @file_index + return + end + # If B button was pressed + if Input.trigger?(Input::CANCEL) + # Call method: on_cancel (defined by the subclasses) + on_cancel + return + end + # If the down directional button was pressed + if Input.repeat?(Input::DOWN) + # If the down directional button pressed down is not a repeat, + # or cursor position is more in front than 3 + if Input.trigger?(Input::DOWN) or @file_index < 99 + # Play cursor SE + $game_system.se_play($data_system.cursor_se) + # Move cursor down + @savefile_windows[@file_index].selected = false + @file_index = (@file_index + 1) + if @file_index > 99 + @file_index = 0 + end + @savefile_windows[@file_index].selected = true + updateVisibleSavefileWindows + return + end + end + # If the up directional button was pressed + if Input.repeat?(Input::UP) + # If the up directional button pressed down is not a repeat、 + # or cursor position is more in back than 0 + if Input.trigger?(Input::UP) or @file_index > 0 + # Play cursor SE + $game_system.se_play($data_system.cursor_se) + # Move cursor up + @savefile_windows[@file_index].selected = false + @file_index = (@file_index - 1) + if @file_index < 0 + @file_index = 99 + end + @savefile_windows[@file_index].selected = true + updateVisibleSavefileWindows + return + end + end + end + #-------------------------------------------------------------------------- + # * Make File Name + # file_index : save file index (0-3) + #-------------------------------------------------------------------------- + def make_filename(file_index) + return "Save#{file_index + 1}.rxdata" + end + + def updateVisibleSavefileWindows + for i in 0..99 + @savefile_windows[i].visible = false + end + + screen_start_index = @file_index - (@file_index % 4) + for i in screen_start_index..(screen_start_index + 3) + @savefile_windows[i].visible = true + end + end +end diff --git a/scripts/Scene_Load.rb b/scripts/Scene_Load.rb new file mode 100644 index 0000000..996dc7d --- /dev/null +++ b/scripts/Scene_Load.rb @@ -0,0 +1,116 @@ +#============================================================================== +# ** Scene_Load +#------------------------------------------------------------------------------ +# This class performs load screen processing. +#============================================================================== + +class Scene_Load < Scene_File + #-------------------------------------------------------------------------- + # * Object Initialization + #-------------------------------------------------------------------------- + def initialize + # Remake temporary object + $game_temp = Game_Temp.new + # Timestamp selects new file + $game_temp.last_file_index = 0 + latest_time = CTime.at(0) + for i in 0..99 + filename = make_filename(i) + if FileTest.exist?(filename) + file = File.open(filename, "r") + if file.mtime > latest_time + latest_time = file.mtime + $game_temp.last_file_index = i + end + file.close + end + end + super("Which file would you like to load?") + end + #-------------------------------------------------------------------------- + # * Decision Processing + #-------------------------------------------------------------------------- + def on_decision(filename) + # If file doesn't exist + unless FileTest.exist?(filename) + # Play buzzer SE + $game_system.se_play($data_system.buzzer_se) + return + end + # Play load SE + $game_system.se_play($data_system.load_se) + # Read save data + file = File.open(filename, "rb") + read_save_data(file) + file.close + # Restore BGM and BGS + $game_system.bgm_play($game_system.playing_bgm) + $game_system.bgs_play($game_system.playing_bgs) + # Update map (run parallel process event) + $game_map.update + # Switch to map screen + $scene = Scene_Map.new + end + #-------------------------------------------------------------------------- + # * Cancel Processing + #-------------------------------------------------------------------------- + def on_cancel + # Play cancel SE + $game_system.se_play($data_system.cancel_se) + # Switch to title screen + $scene = Scene_Map.new + end + #-------------------------------------------------------------------------- + # * Read Save Data + # file : file object for reading (opened) + #-------------------------------------------------------------------------- + def read_save_data(file) + # Read character data for drawing save file + characters = Marshal.load(file) + # Read frame count for measuring play time + Graphics.frame_count = Marshal.load(file) + # Read each type of game object + $game_system = Marshal.load(file) + $game_switches = Marshal.load(file) + $game_variables = Marshal.load(file) + $game_self_switches = Marshal.load(file) + $game_screen = Marshal.load(file) + $game_actors = Marshal.load(file) + $game_party = Marshal.load(file) + $game_troop = Marshal.load(file) + $game_map = Marshal.load(file) + $game_player = Marshal.load(file) + $game_followers = Marshal.load(file) + $game_oneshot = Marshal.load(file) + $game_fasttravel = Marshal.load(file) + $game_temp.footstep_sfx = Marshal.load(file) + + # If magic number is different from when saving + # (if editing was added with editor) + if $game_system.magic_number != $data_system.magic_number + # Load map + $game_map.setup($game_map.map_id) + $game_player.center($game_player.x, $game_player.y) + end + # Refresh party members + $game_party.refresh + + f_prev = $game_player + for f in $game_followers + f.leader = f_prev + f.moveto($game_player.x, $game_player.y) + f_prev = f + end + + + # check for debug file to add debug items + if Settings[:debug] + # debug save + $game_party.gain_item(54, 1) + # plight skip + $game_party.gain_item(82, 1) + end + + load_perma_flags + end +end diff --git a/scripts/Scene_Map.rb b/scripts/Scene_Map.rb index 4349da4..1578050 100644 --- a/scripts/Scene_Map.rb +++ b/scripts/Scene_Map.rb @@ -346,7 +346,10 @@ class Scene_Map $game_player.straighten @window_debug.open elsif $game_temp.save_calling - call_save + # Straighten player position + $game_player.straighten + # Switch to save screen + $scene = Scene_Save.new elsif $game_temp.debug_calling $game_temp.debug_calling = false $game_system.se_play($data_system.decision_se) diff --git a/scripts/Scene_Save.rb b/scripts/Scene_Save.rb new file mode 100644 index 0000000..161d635 --- /dev/null +++ b/scripts/Scene_Save.rb @@ -0,0 +1,88 @@ +#============================================================================== +# ** Scene_Save +#------------------------------------------------------------------------------ +# This class performs save screen processing. +#============================================================================== + +class Scene_Save < Scene_File + #-------------------------------------------------------------------------- + # * Object Initialization + #-------------------------------------------------------------------------- + def initialize + super("Which file would you like to save to?") + end + #-------------------------------------------------------------------------- + # * Decision Processing + #-------------------------------------------------------------------------- + def on_decision(filename) + # Play save SE + $game_system.se_play($data_system.save_se) + # Write save data + file = File.open(filename, "wb") + write_save_data(file) + file.close + # If called from event + if $game_temp.save_calling + # Clear save call flag + $game_temp.save_calling = false + # Switch to map screen + $scene = Scene_Map.new + return + end + # Switch to menu screen + $scene = Scene_Menu.new(4) + end + #-------------------------------------------------------------------------- + # * Cancel Processing + #-------------------------------------------------------------------------- + def on_cancel + # Play cancel SE + $game_system.se_play($data_system.cancel_se) + # If called from event + if $game_temp.save_calling + # Clear save call flag + $game_temp.save_calling = false + # Switch to map screen + $scene = Scene_Map.new + return + end + # Switch to menu screen + $scene = Scene_Menu.new(4) + end + #-------------------------------------------------------------------------- + # * Write Save Data + # file : write file object (opened) + #-------------------------------------------------------------------------- + def write_save_data(file) + # Make character data for drawing save file + characters = [] + for i in 0...$game_party.actors.size + actor = $game_party.actors[i] + characters.push([actor.character_name, actor.character_hue]) + end + # Write character data for drawing save file + Marshal.dump(characters, file) + # Wrire frame count for measuring play time + Marshal.dump(Graphics.frame_count, file) + # Increase save count by 1 + $game_system.save_count += 1 + # Save magic number + # (A random value will be written each time saving with editor) + $game_system.magic_number = $data_system.magic_number + # Write each type of game object + Marshal.dump($game_system, file) + Marshal.dump($game_switches, file) + Marshal.dump($game_variables, file) + Marshal.dump($game_self_switches, file) + Marshal.dump($game_screen, file) + Marshal.dump($game_actors, file) + Marshal.dump($game_party, file) + Marshal.dump($game_troop, file) + Marshal.dump($game_map, file) + Marshal.dump($game_player, file) + Marshal.dump($game_followers, file) + Marshal.dump($game_oneshot, file) + Marshal.dump($game_fasttravel, file) + Marshal.dump($game_temp.footstep_sfx , file) + end +end diff --git a/scripts/Window_SaveFile.rb b/scripts/Window_SaveFile.rb new file mode 100644 index 0000000..1ae4a22 --- /dev/null +++ b/scripts/Window_SaveFile.rb @@ -0,0 +1,91 @@ +#============================================================================== +# ** Window_SaveFile +#------------------------------------------------------------------------------ +# This window displays save files on the save and load screens. +#============================================================================== + +class Window_SaveFile < Window_Base + #-------------------------------------------------------------------------- + # * Public Instance Variables + #-------------------------------------------------------------------------- + attr_reader :filename # file name + attr_reader :selected # selected + #-------------------------------------------------------------------------- + # * Object Initialization + # file_index : save file index (0-3) + # filename : file name + #-------------------------------------------------------------------------- + def initialize(file_index, filename) + super(0, 64 + file_index % 4 * 104, 640, 104) + self.contents = Bitmap.new(width - 32, height - 32) + @file_index = file_index + @filename = "Save#{@file_index + 1}.rxdata" + @time_stamp = CTime.at(0) + @file_exist = FileTest.exist?(@filename) + if @file_exist + file = File.open(@filename, "r") + @time_stamp = file.mtime + @characters = Marshal.load(file) + @frame_count = Marshal.load(file) + @game_system = Marshal.load(file) + @game_switches = Marshal.load(file) + @game_variables = Marshal.load(file) + @total_sec = @frame_count / Graphics.frame_rate + file.close + end + refresh + @selected = false + end + #-------------------------------------------------------------------------- + # * Refresh + #-------------------------------------------------------------------------- + def refresh + self.contents.clear + # Draw file number + self.contents.font.color = normal_color + name = "File#{@file_index + 1}" + self.contents.draw_text(4, 0, 600, 32, name) + @name_width = contents.text_size(name).width + # If save file exists + if @file_exist + # Draw character + for i in 0...@characters.size + bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1]) + cw = bitmap.rect.width / 4 + ch = bitmap.rect.height / 4 + src_rect = Rect.new(0, 0, cw, ch) + x = 300 - @characters.size * 32 + i * 64 - cw / 2 + self.contents.blt(x, 68 - ch, bitmap, src_rect) + end + # Draw play time + hour = @total_sec / 60 / 60 + min = @total_sec / 60 % 60 + sec = @total_sec % 60 + time_string = sprintf("%02d:%02d:%02d", hour, min, sec) + self.contents.font.color = normal_color + self.contents.draw_text(4, 8, 600, 32, time_string, 2) + # Draw timestamp + self.contents.font.color = normal_color + time_string = @time_stamp.strftime("%Y/%m/%d %H:%M") + self.contents.draw_text(4, 40, 600, 32, time_string, 2) + end + end + #-------------------------------------------------------------------------- + # * Set Selected + # selected : new selected (true = selected, false = unselected) + #-------------------------------------------------------------------------- + def selected=(selected) + @selected = selected + update_cursor_rect + end + #-------------------------------------------------------------------------- + # * Cursor Rectangle Update + #-------------------------------------------------------------------------- + def update_cursor_rect + if @selected + self.cursor_rect.set(0, 0, @name_width + 8, 32) + else + self.cursor_rect.empty + end + end +end diff --git a/scripts/_scripts.txt b/scripts/_scripts.txt index 08433f2..d36eac6 100644 --- a/scripts/_scripts.txt +++ b/scripts/_scripts.txt @@ -59,6 +59,7 @@ Window_DebugLeft Window_DebugRight Window_MainMenu Window_TPtL +Window_SaveFile Interpreter_1 Interpreter_2 @@ -68,10 +69,13 @@ Interpreter_5 Interpreter_6 Interpreter_7 +Scene_File Scene_Title Scene_Map Scene_Name Scene_Debug +Scene_Save +Scene_Load # Persistent data Persistent