Stop displaying new game if a save file exists.

● ARCHIVED · READ-ONLY
Started by MuyHiram 3 posts View original ↗
  1. I'm currently using the "Single Save File System" code by MeowFace:

    CODE
    Code:
    #==============================================================================
    # ■ Meow Face Single Save File System
    #------------------------------------------------------------------------------
    # Change the game save/load system to work on one save file only.
    #==============================================================================
    # How to Use:
    # [1] Paste this below Material and above Main
    # [2] Set your preferences save file name in the script's SETTINGS AREA
    #==============================================================================
    module MeowSaveFileManager #DO NOT REMOVE!!
    #==============================================================================
    # Settings Area
    #==============================================================================
      #---------------#
      # Save File Name  #
      #---------------#
      FILE_NAME = "meow.dat" #save file name and extension
      #--------------#
      # Saving a Game #
      #--------------#
      SAVE_MESSAGE = "Now Saving..." #save message to display
      SAVE_ICON = 286 #(icon id) set which icon to be displayed with the save message
      #----------------------#
      # Restarting A New Game  #
      #----------------------#
      CONFIRM_MESSAGE = "Are you sure to restart a new game?" #Confirmation message
      OVERWRITE_WARNING = "Warning!! You will lost your current progress!" #Warning Message
      YES = "I'm Sure!"
      NO = "No Way!"
    #==============================================================================
    # End of Settings Area
    # Edit anything past this line at your own risk!
    #==============================================================================
    end
    module DataManager
      def self.save_file_exists? #overwrite
        !Dir.glob(MeowSaveFileManager::FILE_NAME).empty?
      end
      def self.savefile_max #overwrite
        return 1
      end
      def self.make_filename(index) #overwrite
        sprintf(MeowSaveFileManager::FILE_NAME, index + 1)
      end
    end
    class Game_Map
      attr_accessor :sm_show
      alias meow_setup_sm setup
      def setup(map_id) #alias
        meow_setup_sm(map_id)
        @sm_show = false
      end
      def show_sm
        SceneManager.scene.show_save_message
        @sm_show = false
      end
      alias meow_update_sm update
      def update(main = false) #alias
        meow_update_sm(main)
        show_sm if @sm_show
      end
    end
    class Game_Interpreter
      def command_352 #overwrite
        return if $game_party.in_battle
        if DataManager.save_game(0)
          Sound.play_save
          $game_map.sm_show = true
        else
          Sound.play_buzzer
        end
      end
    end
    class Window_SaveMessage < Window_Base
      def initialize
        super(Graphics.width - window_width, Graphics.height - fitting_height(1), window_width, fitting_height(1))
        self.opacity = 0
        self.contents_opacity = 0
        @show_count = 0
        refresh
      end
      def window_width
        return 240
      end
      def update
        super
        if @show_count > 0 && $game_map.name_display
          update_fadein
          @show_count -= 1
        else
          update_fadeout
        end
      end
      def update_fadein
        self.contents_opacity += 16
      end
      def update_fadeout
        self.contents_opacity -= 16
      end
      def open
        refresh
        @show_count = 150
        self.contents_opacity = 0
        self
      end
      def close
        @show_count = 0
        self
      end
      def refresh
        contents.clear
        draw_background(contents.rect)
        draw_icon(MeowSaveFileManager::SAVE_ICON, contents.rect.width-24, 0)
        draw_icon(MeowSaveFileManager::SAVE_ICON, contents.rect.x, 0)
        draw_text(contents.rect.x,contents.rect.y,contents.rect.width, fitting_height(0), MeowSaveFileManager::SAVE_MESSAGE, 1)
      end
      def draw_background(rect)
        temp_rect = rect.clone
        temp_rect.width /= 2
        contents.gradient_fill_rect(temp_rect, back_color2, back_color1)
        temp_rect.x = temp_rect.width
        contents.gradient_fill_rect(temp_rect, back_color1, back_color2)
      end
      def back_color1
        Color.new(0, 0, 0, 192)
      end
      def back_color2
        Color.new(0, 0, 0, 0)
      end
    end
    class Window_TitleCommand < Window_Command
      def make_command_list #overwrite
        add_command(Vocab::new_game, :new_game)
        add_command(Vocab::continue, :continue, continue_enabled) if DataManager.save_file_exists?
        add_command(Vocab::shutdown, :shutdown)
      end
    end
    class Window_StartNewAsk < Window_Base
      def initialize
        super((Graphics.width - window_width)/2, (Graphics.height - fitting_height(5))/2, window_width, fitting_height(5))
        create_message
      end
      def window_width
        return Graphics.width - 40
      end
      def create_message
        draw_text(contents.rect.x,contents.rect.y,contents.rect.width, fitting_height(0), MeowSaveFileManager::CONFIRM_MESSAGE, 1)
        draw_text(contents.rect.x,contents.rect.y+fitting_height(0),contents.rect.width, fitting_height(0), MeowSaveFileManager::OVERWRITE_WARNING, 1)
        draw_text(contents.rect.x,contents.rect.y+fitting_height(2),contents.rect.width, fitting_height(0), "/", 1)
      end
    end
    class Window_StartNewConfirm < Window_HorzCommand
      def initialize
        super(0, 0)
        update_placement
        self.opacity = 0
      end
      def window_width
        return 240
      end
      def col_max
        return 2
      end
      def spacing
        return 12
      end
      def update_placement
        self.x = (Graphics.width - window_width) / 2
      end
      def make_command_list
        add_command(MeowSaveFileManager::YES, :ok)
        add_command(MeowSaveFileManager::NO,   :cancel)
      end
    end
    class Scene_Title < Scene_Base
      alias meow_st_start_sm start
      def start
        meow_st_start_sm
        create_ask_window
        create_confirm_window
      end
      def mf_start_new_game
        DataManager.setup_new_game
        close_command_window
        fadeout_all
        $game_map.autoplay
        SceneManager.goto(Scene_Map)
      end
      def create_ask_window
        @ask_window = Window_StartNewAsk.new
        @ask_window.hide
      end
      def create_confirm_window
        @confirm_select_window = Window_StartNewConfirm.new
        @confirm_select_window.y = @ask_window.y + (24*3)
        @confirm_select_window.set_handler(:ok,     method(:on_confirm_ok))
        @confirm_select_window.set_handler(:cancel, method(:on_confirm_cancel))
        @confirm_select_window.hide.deactivate
      end
      def on_confirm_ok
        @ask_window.close
        @confirm_select_window.close
        DataManager.delete_save_file(0)
        mf_start_new_game
      end
      def on_confirm_cancel
        @ask_window.hide
        @confirm_select_window.hide.deactivate
        @command_window.show.activate
      end
      def command_new_game #overwrite
        if DataManager.save_file_exists?
          @command_window.hide.deactivate
          @ask_window.show
          @confirm_select_window.show.activate
        else
          mf_start_new_game
        end
      end
      def command_continue #overwrite
        close_command_window
        if DataManager.load_game(0)
          Sound.play_load
          fadeout_all
          $game_system.on_after_load
          SceneManager.goto(Scene_Map)
        else
          Sound.play_buzzer
        end
      end
    end
    class Scene_Map < Scene_Base
      def create_save_message_window
        @sm_window = Window_SaveMessage.new
      end
      def show_save_message
        @sm_window.open
      end
      alias meow_sm_caw_sm create_all_windows
      def create_all_windows #alias
        meow_sm_caw_sm
        create_save_message_window
      end
    end
    class Scene_Menu < Scene_MenuBase
      def command_save #overwrite
        if DataManager.save_game(0)
          Sound.play_save
          $game_map.sm_show = true
          return_scene
        else
          Sound.play_buzzer
        end
      end
    end

    Additionally, I want it to stop displaying the New Game option, leaving only the Continue option once a save file is made.

    Similar to how the Continue doesn't display until a save file is made. (in the code.)

    Thank you.
  2. Replace line 133 by this:

    Code:
    add_command(Vocab::new_game, :new_game) if !DataManager.save_file_exists?
  3. felipefalcon said:
    Replace line 133 by this:

    Code:
    add_command(Vocab::new_game, :new_game) if !DataManager.save_file_exists?

    It worked! Thanks.