Compatibility issue with MOG - Scene File A (V1.3)

Discussion in 'RGSSx Script Support' started by Tw0Face, Dec 6, 2018.

  1. Tw0Face

    Tw0Face Your boss Veteran

    Messages:
    44
    Likes Received:
    39
    First Language:
    German
    Primarily Uses:
    RMVXA
    Hi guys,

    I need some help to make my Mouse Script compatible with Moghunter's Save-Script (MOG - Scene File A (V1.3) ). Currently, they don't seem to work together. I think, the Moghunter's Save-Script need to be altered a lil bit in order to work with my Mouse System, because whenever I want to load or save, I receive this super sweet error message.

    [​IMG]

    I hope someone can help me with that. Thanks for your time. I'll make sure to credit you of course. ;)

    Code:
    CPOS = Win32API.new 'user32', 'GetCursorPos', ['p'], 'v'
    WINX = Win32API.new 'user32', 'FindWindowEx', ['l','l','p','p'], 'i'
    ASKS = Win32API.new 'user32', 'GetAsyncKeyState', ['p'], 'i'
    SMET = Win32API.new 'user32', 'GetSystemMetrics', ['i'], 'i'
    WREC = Win32API.new 'user32', 'GetWindowRect', ['l','p'], 'v'
     
    #MOUSE_ICON, set to the index of the icon to use as a cursor
    MOUSE_ICON = 33
    CURSOR_OFFSET_X = -12
    CURSOR_OFFSET_Y = -12
     
    #Keeps cursor sprite within the game window
    MOUSE_KEEP_WINDOW = true
     
    #Whether clicking requires cursor to be within window or not
    MOUSE_CLICK_WITHIN = false
     
    #Whether to use 8 directional movement or not
    MOUSE_DIR8 = false
    #Use the Mouse Button Overlay:
    USE_MOUSE_BUTTONS = false
    #And here is where you set up your buttons! Simple overlay:
    #(Picture files are to be stored in System)
    #
    # [ x , y, "filename", "script call when left clicked" ]
    MOUSE_BUTTONS = [
                [0,416-32,"Shadow.png","SceneManager.call(Scene_Equip)"],
                [32,416-32,"Shadow.png","SceneManager.call(Scene_Item)"], ]
     
    SHOWMOUS = Win32API.new 'user32', 'ShowCursor', 'i', 'i'
    SHOWMOUS.call(0)
     
    #Switch option to enable/disable the script
    USE_MOUSE_SWITCH = false
    MOUSE_SWITCH = 487
     
    module Mouse
      def self.setup
        @enabled = true
        @delay = 0
        bwap = true if SMET.call(23) != 0
        bwap ? @lmb = 0x02 : @lmb = 0x01
        bwap ? @rmb = 0x02 : @rmb = 0x02
      end
      def self.update
        return false unless @enabled
        return false if USE_MOUSE_SWITCH && !$game_switches[MOUSE_SWITCH]
        self.setup if @lmb.nil?
        @delay -= 1
        @window_loc = WINX.call(0,0,"RGSS PLAYER",0)
        if ASKS.call(@lmb) == 0 then @l_clicked = false end
        if ASKS.call(@rmb) == 0 then @r_clicked = false end
        rect = '0000000000000000'
        cursor_pos = '00000000'
        WREC.call(@window_loc, rect)
        side, top = rect.unpack("ll")
        CPOS.call(cursor_pos)
        @m_x, @m_y = cursor_pos.unpack("ll")
        w_x = side + SMET.call(5) + SMET.call(45)
        w_y = top + SMET.call(6) + SMET.call(46) + SMET.call(4)
        @m_x -= w_x; @m_y -= w_y
        if MOUSE_KEEP_WINDOW
          @m_x = [[@m_x, 0].max,Graphics.width-5].min
          @m_y = [[@m_y, 0].max,Graphics.height-5].min
        end
        return true
      end
      def self.pos?
        return[-50,-50] unless self.update
        return [@m_x, @m_y]
      end
      def self.lclick?(repeat = false)
        return unless self.update
        return false if @l_clicked
        if ASKS.call(@lmb) != 0 then
          @l_clicked = true if !repeat
          return true end
      end
      def self.rclick?(repeat = false)
        return unless self.update
        return false if @r_clicked
        if ASKS.call(@rmb) != 0 then
          @r_clicked = true if !repeat
          return true end
      end
      def self.slowpeat
        return unless self.update
        return false if @delay > 0
        @delay = 120
        return true
      end
      def self.within?(rect)
        return unless self.update
        return false if @m_x < rect.x or @m_y < rect.y
        bound_x = rect.x + rect.width; bound_y = rect.y + rect.height
        return true if @m_x < bound_x and @m_y < bound_y
        return false
      end
      def self.disable
        @enabled = false
        SHOWMOUS.call(1)
      end
      def self.enable
        @enabled = true
        SHOWMOUS.call(0)
      end
    end
     
    Mouse.setup
     
    module DataManager
      class << self
        alias mouse_init init
      end
      def self.init
        mouse_init
        $cursor = Mouse_Cursor.new
      end
    end
     
    class Scene_Base
      alias cursor_update update_basic
      def update_basic
        cursor_update
        mouse_cursor
      end
      def mouse_cursor
        pos = Mouse.pos?
        $cursor.x = pos[0] + CURSOR_OFFSET_X
        $cursor.y = pos[1] + CURSOR_OFFSET_Y
      end
    end
     
    class Mouse_Cursor < Sprite_Base
      def initialize
        super
        @icon = MOUSE_ICON
        self.bitmap = Bitmap.new(24,24)
        draw_cursor
        self.z = 255
      end
      def set_icon(icon)
        return if @icon == icon
        @icon = icon
        draw_cursor
      end
      def draw_cursor
        self.bitmap.clear
        icon_bitmap = Cache.system("Iconset")
        rect = Rect.new(@icon % 16 * 24, @icon / 16 * 24, 24, 24)
        self.bitmap.blt(0, 0, icon_bitmap, rect)
      end
    end
     
    class Window_Selectable
      alias mouse_update update
      alias mouse_init initialize
      def initialize(x,y,w,h)
        mouse_init(x,y,w,h)
        @mouse_all_rects = []
        @timer = 0
      end
      def update
        mouse_update
        update_mouse if self.active
      end
      def update_mouse
        @timer -= 1
        @mouse_all_rects = []
        item_max.times {|i|
          rect = item_rect(i)
          rect.x += self.x + standard_padding - self.ox
          rect.y += self.y + standard_padding - self.oy
          if !self.viewport.nil?
            rect.x += self.viewport.rect.x - self.viewport.ox
            rect.y += self.viewport.rect.y - self.viewport.oy
          end
          @mouse_all_rects.push(rect) }
        item_max.times {|i|
          next if @timer > 0
          next unless Mouse.within?(@mouse_all_rects[i])
          @timer = 10 if i > top_row * 2 + page_item_max - 1
          @timer = 10 if i < top_row * 2
          self.index = i }
        process_cancel if Mouse.rclick? && cancel_enabled?
        return if MOUSE_CLICK_WITHIN && !within_index
        process_ok if Mouse.lclick? && ok_enabled?
      end
      def within_index
        item_max.times {|i|
          return true if Mouse.within?(@mouse_all_rects[i]) }
        return false
      end
    end
     
    class Window_NameInput
      alias mouse_process_handling process_handling
      def process_handling
        mouse_process_handling
        process_back if Mouse.rclick?
      end
      def item_max
        return 90
      end
    end
     
    class Window_Message < Window_Base
      def input_pause
        self.pause = true
        wait(10)
        Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C) || Mouse.lclick? #if !SceneManager.scene_is?(Scene_Map))
        Input.update
        self.pause = false
      end
    end
     
    class Scene_File < Scene_MenuBase
      alias mouse_update update
      def update
        mouse_update
        mouse_input
      end
      def mouse_input
        xx = 0
        yy = 56
        width = Graphics.width
        rectcm1 = Rect.new(xx, yy, width, savefile_height)
        rectcm2 = Rect.new(xx, yy + rectcm1.height, width, savefile_height)
        rectcm3 = Rect.new(xx, yy + rectcm1.height * 2, width, savefile_height)
        rectcm4 = Rect.new(xx, yy + rectcm1.height * 3, width, savefile_height)
        rectttl = Rect.new(xx, yy, width, rectcm1.height * 4)
        rectcmA = Rect.new(0, yy - 12, Graphics.width, 24)
        rectcmB = Rect.new(0, Graphics.height - 12, Graphics.width, 24)
        @scroll = self.top_index
        last_index = @index
        @index = (0 + @scroll) if Mouse.within?(rectcm1)
        @index = (1 + @scroll) if Mouse.within?(rectcm2)
        @index = (2 + @scroll) if Mouse.within?(rectcm3)
        @index = (3 + @scroll) if Mouse.within?(rectcm4)
        cursor_down(false) if Mouse.within?(rectcmB) and Mouse.slowpeat
        cursor_up(false) if Mouse.within?(rectcmA) and Mouse.slowpeat
        if @index != last_index
          Sound.play_cursor
          @savefile_windows[last_index].selected = false
          @savefile_windows[@index].selected = true
        end
        on_savefile_ok if Mouse.lclick? and Mouse.within?(rectttl)
        on_savefile_cancel if Mouse.rclick? and Mouse.within?(rectttl)
      end
    end
     
    class Scene_Gameover
      alias mouse_update update
      def update
        mouse_update
        goto_title if Mouse.lclick? or Mouse.rclick?
      end
    end
     
    class Game_Player < Game_Character < Scene_MenuBase
      alias mouse_move_update update
      def update
        mouse_move_update
        mouse_input
        
      end
      def mouse_input
        begin     
        return if USE_MOUSE_BUTTONS && SceneManager.scene.mouse_overlay.update
        rescue
        return
      end
    
        Graphics.width / 32 % 2 == 0 ? xxx = 16 : xxx = 0
        Graphics.height / 32 % 2 == 0 ? yyy = 16 : yyy = 0
        x = $game_map.display_x + (Mouse.pos?[0] + xxx) / 32
        y = $game_map.display_y + (Mouse.pos?[1] + yyy) / 32
        x -= 0.5 if Graphics.width / 32 % 2 == 0
        y -= 0.5 if Graphics.height / 32 % 2 == 0
    
        if MOUSE_DIR8
          x = (-((($game_player.screen_x-16)/32)-$game_player.x)) * 32 + Mouse.pos?[0]
          y = (-((($game_player.screen_y-16)/32)-$game_player.y)) * 32 + Mouse.pos?[1]
          x -= @x * 32 + 16
          y -= @y * 32 + 16
          aimangle = Math.atan((x.abs)/(y.abs)) * (180 / Math::PI) if y.abs !=0
          if y.abs == 0 && x.abs >= 0
            aimangle = 90
            end
          if y.abs == 0 && x.abs < 0
            aimangle = 270
            end
            aimangle = 180 - aimangle if x > 0 && y >= 0
            aimangle += 180 if x <= 0 && y >= 0
            aimangle = 360 - aimangle if x <= 0 && y < 0
    
            
            $aim = aimangle * Math::PI / 180
            $lightaim = aimangle
            
    set_direction(8) if aimangle >= 337.6 || aimangle <= 22.5
    set_direction(9) if aimangle >= 22.6 && aimangle <= 67.5
    set_direction(6) if aimangle >= 67.6 && aimangle <= 112.5
    set_direction(3) if aimangle >= 112.6 && aimangle <= 157.5
    set_direction(2) if aimangle >= 157.6 && aimangle <= 202.5
    set_direction(1) if aimangle >= 202.6 && aimangle <= 247.5
    set_direction(4) if aimangle >= 247.6 && aimangle <= 292.5
    set_direction(7) if aimangle >= 292.6 && aimangle <= 337.5
    
      
        else
          x = $game_map.display_x + Mouse.pos?[0] / 32
          y = $game_map.display_y + Mouse.pos?[1] / 32
          sx = distance_x_from(x)
          sy = distance_y_from(y)
          if sx.abs > sy.abs
            set_direction(sx > 0 ? 4 : 6)
            set_direction(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0
          elsif sy != 0
            set_direction(sy > 0 ? 8 : 2)
            set_direction(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0
          end
        end
      end
    end
    

    Code:
    #==============================================================================
    # +++ MOG - Scene File A (V1.3) +++
    #==============================================================================
    # By Moghunter
    # http://www.atelier-rgss.com/
    #==============================================================================
    # Tela de salvar e carregar animado versão A.
    #==============================================================================
    # Serão necessários as seguintes imagens na pasta Graphics/System
    #
    # Save_Number.png
    # Save_Background.png
    # Save_Character_Floor.png
    # Save_Layout01.png
    # Save_Layout02.png
    # Save_Window01.png
    # Save_Window02.png
    #
    #==============================================================================
    #
    #==============================================================================
    # ● Histórico (Version History)
    #==============================================================================
    # v 1.3 - Melhor codificação.
    # v 1.1 - Melhoria no sistema de dispose de imagens.
    #==============================================================================
    module MOG_SCENE_FILE
      #Quantidade de slots de saves.
      FILES_MAX = 10
    end
    
    #==============================================================================
    # ■ Game Temp
    #==============================================================================
    class Game_Temp
    
      attr_accessor :scene_save
      #--------------------------------------------------------------------------
      # ● Initialize
      #--------------------------------------------------------------------------
      alias mog_scene_file_initialize initialize
      def initialize
          mog_scene_file_initialize
          @scene_save = false 
      end
     
    end
    #==============================================================================
    # ■ Window_Base
    #==============================================================================
    class Window_Base < Window
     
      #--------------------------------------------------------------------------
      # ● draw_picture_number(x,y,value,file_name,align, space, frame_max ,frame_index)     
      #--------------------------------------------------------------------------
      # X - Posição na horizontal
      # Y - Posição na vertical
      # VALUE - Valor Numérico
      # FILE_NAME - Nome do arquivo
      # ALIGN - Centralizar 0 - Esquerda 1- Centro 2 - Direita 
      # SPACE - Espaço entre os números.
      # FRAME_MAX - Quantidade de quadros(Linhas) que a imagem vai ter.
      # FRAME_INDEX - Definição do quadro a ser utilizado.
      #-------------------------------------------------------------------------- 
      def draw_picture_number(x,y,value, file_name,align = 0, space = 0, frame_max = 1,frame_index = 0)     
          number_image = Cache.system(file_name)
          frame_max = 1 if frame_max < 1
          frame_index = frame_max -1 if frame_index > frame_max -1
          align = 2 if align > 2
          cw = number_image.width / 10
          ch = number_image.height / frame_max
          h = ch * frame_index
          number = value.abs.to_s.split(//)
          case align
             when 0
                plus_x = (-cw + space) * number.size
             when 1
                plus_x = (-cw + space) * number.size
                plus_x /= 2
             when 2 
                plus_x = 0
          end
          for r in 0..number.size - 1       
              number_abs = number[r].to_i
              number_rect = Rect.new(cw * number_abs, h, cw, ch)
              self.contents.blt(plus_x + x + ((cw - space) * r), y , number_image, number_rect)       
          end   
          number_image.dispose 
      end
      
      #--------------------------------------------------------------------------
      # ● Draw Help Layout
      #--------------------------------------------------------------------------
      def draw_face_save(name,x,y,type)
          if type == 0
             image_name = name + "_0"
          elsif type == 1
             image_name = name + "_1"         
          else 
             image_name = name + "_2"
          end
          image = Cache.face(image_name)   
          cw = image.width 
          ch = image.height
          src_rect = Rect.new(0, 0, cw, ch)   
          self.contents.blt(x , y , image, src_rect) 
          image.dispose
      end   
        
      #--------------------------------------------------------------------------
      # ● draw_parameter_layout
      #-------------------------------------------------------------------------- 
      def draw_parameter_layout(x,y)
          image = Cache.system("Save_Window01")   
          cw = image.width 
          ch = image.height
          src_rect = Rect.new(0, 0, cw, ch)   
          self.contents.blt(x , y , image, src_rect)     
          image.dispose
      end   
     
      #--------------------------------------------------------------------------
      # ● draw_parameter_layout2
      #-------------------------------------------------------------------------- 
      def draw_parameter_layout2(x,y,type)
          if type == 0
             image = Cache.system("Save_Window02")   
          else   
             image = Cache.system("Save_Window03") 
          end 
          cw = image.width 
          ch = image.height
          src_rect = Rect.new(0, 0, cw, ch)   
          self.contents.blt(x , y , image, src_rect)     
          image.dispose
      end       
     
      #--------------------------------------------------------------------------
      # ● draw_character_floor
      #-------------------------------------------------------------------------- 
      def draw_character_floor(x,y)
          image = Cache.system("Save_Character_Floor")   
          cw = image.width 
          ch = image.height
          src_rect = Rect.new(0, 0, cw, ch)   
          self.contents.blt(x , y , image, src_rect)   
          image.dispose
      end
     
    end 
        
    #==============================================================================
    # ■ DataManager
    #==============================================================================
    module DataManager
    
      #--------------------------------------------------------------------------
      # ● Make Save Header
      #-------------------------------------------------------------------------- 
      def self.make_save_header
          header = {}
          header[:characters] = $game_party.characters_for_savefile
          header[:playtime_s] = $game_system.playtime_s
          header[:playtime] = $game_system.playtime
          header[:map_name] = $game_map.display_name
          header[:members] = $game_party.members
          header
      end 
    end 
    
    #==============================================================================
    # ■ Window_SaveFile
    #==============================================================================
    class Window_SaveFile_A < Window_Base
      attr_reader   :filename               
      attr_reader   :file_exist               
      attr_reader   :time_stamp             
      attr_reader   :selected                 
      attr_reader   :file_index
     
      #--------------------------------------------------------------------------
      # ● Initialize
      #--------------------------------------------------------------------------
      def initialize(file_index, filename)
          super(0, 0,720, 140)
          self.opacity = 0
          @file_index = file_index
          @filename = filename
          load_gamedata
          refresh
          @selected = false
      end
     
      #--------------------------------------------------------------------------
      # ● load_gamedata
      #--------------------------------------------------------------------------
      def load_gamedata
        @time_stamp = Time.at(0)
        @file_exist = FileTest.exist?(@filename)
        if @file_exist
           header = DataManager.load_header(@file_index)
           if header == nil
              @file_exist = false
              return
           end 
           @characters = header[:characters]
           @total_sec = header[:playtime]
           @mapname = header[:map_name]
           @members = header[:members]
        end
      end
     
      #--------------------------------------------------------------------------
      # ● Refresh
      #--------------------------------------------------------------------------
      def refresh
          self.contents.clear
          self.contents.font.color = normal_color
          xp = 96
          ex = 60   
          if @file_exist
             if @total_sec == nil
                draw_parameter_layout2(0,50,0)
                draw_parameter_layout(-10 + xp,0)
                value = @file_index + 1
                draw_picture_number(13 + xp, 32,value, "Save_Number_01",1,0,3,0)           
                self.contents.draw_text(140, 50, 450, 32, "Error! - Please, dont't use your old Save Files...", 0)
                return
            end 
            draw_parameter_layout2(0,50,0)
            draw_parameter_layout(-10 + xp,0)
            value = @file_index + 1
            draw_picture_number(13 + xp, 32,value, "Save_Number_01",1,0,3,1)
            draw_party_characters(180 + xp, 75,ex)
            draw_playtime(495, 20, contents.width - 4, 2)
            draw_map_location( 400 + xp,64)
            draw_level(185 + xp,85,ex)
            draw_face_save(40 + xp,0)
          else 
            draw_parameter_layout2(0,50,1)
            draw_parameter_layout(-10 + xp,0)
            value = @file_index + 1
            draw_picture_number(13 + xp, 32,value, "Save_Number_01",1,0,3,0)       
             self.contents.draw_text(260, 50, 120, 32, "No Data", 1)
          end
        end
        
      #--------------------------------------------------------------------------
      # ● draw_face
      #--------------------------------------------------------------------------
      def draw_face_save(x,y)
         draw_actor_face(@members[0], x, y)
      end
     
      #--------------------------------------------------------------------------
      # ● draw_level
      #--------------------------------------------------------------------------
      def draw_level(x,y,ex)
          self.contents.font.color = normal_color   
          for i in 0...@members.size
            break if i > 3
            level = @members[i].level
            draw_picture_number(x + (ex  * i) , y ,level - 1, "Save_Number_01",1,0,3,1)
          end       
      end
     
      #--------------------------------------------------------------------------
      # ● draw_map_location
      #--------------------------------------------------------------------------
      def draw_map_location(x,y)
          self.contents.font.bold = false
          self.contents.font.name = "Verdana"
          self.contents.font.size = 13
          self.contents.font.italic = false
          self.contents.draw_text(400, 60, 125, 20, @mapname.to_s, 0)
      end
      #--------------------------------------------------------------------------
      # ● draw_party_characters
      #--------------------------------------------------------------------------
      def draw_party_characters(x, y,ex)
          for i in 0...@characters.size
            break if i > 3
            name = @characters[i][0]
            index = @characters[i][1]
            draw_character_floor(- 35 + x + i * ex,y - 20)     
            draw_character(name, index, x + i * ex, y)
          end
      end
     
      #--------------------------------------------------------------------------
      # ● draw_playtime
      #--------------------------------------------------------------------------
      def draw_playtime(x, y, width, align)
          hour = @total_sec / 60 / 60
          min = @total_sec / 60 % 60
          sec = @total_sec % 60
          time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
          draw_picture_number(x + 18 * 0, y ,0, "Save_Number_01",0,0,3,0) if hour < 10
          draw_picture_number(x + 18 * 1, y ,hour, "Save_Number_01",0,0,3,0)
          draw_picture_number(x + 18 * 3, y ,0, "Save_Number_01",0,0,3,0) if min < 10
          draw_picture_number(x + 18 * 4, y ,min, "Save_Number_01",0,0,3,0)
          draw_picture_number(x + 18 * 6, y ,0, "Save_Number_01",0,0,3,0) if sec < 10
          draw_picture_number(x + 18 * 7, y ,sec , "Save_Number_01",0,0,3,0)     
      end
     
      #--------------------------------------------------------------------------
      # ● selected
      #--------------------------------------------------------------------------
      def selected=(selected)
          @selected = selected
      end
    end
    
    #==============================================================================
    # ■ Scene Save
    #==============================================================================
    class Scene_Save < Scene_File
      #--------------------------------------------------------------------------
      # ● Initialize
      #--------------------------------------------------------------------------
      def initialize
          $game_temp.scene_save = true
          super
      end 
    end 
    #==============================================================================
    # ■ Scene Load
    #==============================================================================
    class Scene_Load < Scene_File
      #--------------------------------------------------------------------------
      # ● Initialize
      #--------------------------------------------------------------------------
      def initialize
          $game_temp.scene_save = false
          super
      end 
    end
    
    #==============================================================================
    # ■ Scene_File
    #==============================================================================
    class Scene_File
      include MOG_SCENE_FILE
     
     
      #--------------------------------------------------------------------------
      # ● initialize
      #--------------------------------------------------------------------------
      def initialize
          @saving = $game_temp.scene_save
          @file_max = FILES_MAX
          @file_max = 1 if FILES_MAX < 1
          execute_dispose
          create_layout
          create_savefile_windows
          @index = DataManager.last_savefile_index
          @check_prev_index = true
          @savefile_windows[@index].selected = true   
      end
     
     #--------------------------------------------------------------------------
     # ● Main
     #--------------------------------------------------------------------------         
     def main
         Graphics.transition
         execute_loop
         execute_dispose
     end   
     
     #--------------------------------------------------------------------------
     # ● Execute Loop
     #--------------------------------------------------------------------------           
     def execute_loop
         loop do
              Graphics.update
              Input.update
              update
              if SceneManager.scene != self
                  break
              end
         end
     end   
     
      #--------------------------------------------------------------------------
      # ● Create_background
      #-------------------------------------------------------------------------- 
      def create_layout
          @background = Plane.new 
          @background.bitmap = Cache.system("Save_Background")
          @background.z = 0
          @layout_01 = Sprite.new 
          @layout_01.bitmap = Cache.system("Save_Layout01")
          @layout_01.z = 1     
          @layout_01.blend_type = 1
          image = Cache.system("Save_Layout02")
          @bitmap = Bitmap.new(image.width,image.height)
          cw = image.width
          ch = image.height / 2
          if @saving
             h = 0
          else 
             h = ch
          end 
          src_rect = Rect.new(0, h, cw, ch)
          @bitmap.blt(0,0, image, src_rect)     
          @layout_02 = Sprite.new 
          @layout_02.bitmap = @bitmap
          @layout_02.z = 3
          @layout_02.y = 370
          image.dispose
      end
     
      #--------------------------------------------------------------------------
      # ● Execute Dispose
      #--------------------------------------------------------------------------
      def execute_dispose
          return if @background == nil
          Graphics.freeze
          @background.bitmap.dispose
          @background.dispose
          @background = nil
          @layout_01.bitmap.dispose   
          @layout_01.dispose     
          @layout_02.bitmap.dispose
          @layout_02.dispose
          @bitmap.dispose
          dispose_item_windows
      end
     
      #--------------------------------------------------------------------------
      # ● Frame Update
      #--------------------------------------------------------------------------
      def update
          update_savefile_windows
          update_savefile_selection
          check_start_index
      end
     
      #--------------------------------------------------------------------------
      # ● check_start_index
      #--------------------------------------------------------------------------
      def check_start_index
          return if @check_prev_index == false
          @check_prev_index = false
          check_active_window   
      end 
        
      #--------------------------------------------------------------------------
      # ● check_active_window   
      #--------------------------------------------------------------------------
      def check_active_window   
          @index = 0 if @index == nil
          for i in 0...@file_max 
            @pw = @index - 1
            @pw = 0 if @pw > @file_max - 1
            @pw = @file_max- 1 if @pw < 0       
            @aw = @index
            @nw = @index + 1
            @nw = 0 if @nw > @file_max - 1
            @nw = @file_max - 1  if @nw < 0
            case @savefile_windows[i].file_index
               when @pw,@nw
                    @savefile_windows[i].visible = true
                    @savefile_windows[i].contents_opacity = 80
               when @aw 
                    @savefile_windows[i].visible = true
                    @savefile_windows[i].contents_opacity = 255
               else
                    @savefile_windows[i].visible = false
            end
          end         
      end
        
      #--------------------------------------------------------------------------
      # ● Create Save File Window
      #--------------------------------------------------------------------------
      def create_savefile_windows
        @pw_pos = [-160,32]
        @aw_pos = [-96,160]
        @nw_pos = [-32,288]     
        @savefile_windows = []
        for i in 0...@file_max
            @savefile_windows[i] = Window_SaveFile_A.new(i, DataManager.make_filename(i))
            @savefile_windows[i].z = 2
            @savefile_windows[i].visible = false
            @savefile_windows[i].x = 400
        end
        check_active_window
        @item_max = @file_max
      end
     
      #--------------------------------------------------------------------------
      # ● Dispose of Save File Window
      #--------------------------------------------------------------------------
      def dispose_item_windows
          for window in @savefile_windows
              window.dispose
          end
      end
     
      #--------------------------------------------------------------------------
      # ● Update Save File Window
      #--------------------------------------------------------------------------
      def update_savefile_windows
          update_slide_window
          for window in @savefile_windows
            window.update
          end
      end
     
      #--------------------------------------------------------------------------
      # ● update_slide_window
      #-------------------------------------------------------------------------- 
      def update_slide_window
          @background.ox += 0
          slide_window_x(@pw,@pw_pos[0])
          slide_window_x(@aw,@aw_pos[0])
          slide_window_x(@nw,@nw_pos[0])
          slide_window_y(@pw,@pw_pos[1])
          slide_window_y(@aw,@aw_pos[1])
          slide_window_y(@nw,@nw_pos[1])
      end
        
      #--------------------------------------------------------------------------
      # ● slide_window_x
      #--------------------------------------------------------------------------   
      def slide_window_x(i,x_pos)
          if @savefile_windows[i].x < x_pos
             @savefile_windows[i].x += 15
             @savefile_windows[i].x = x_pos if @savefile_windows[i].x > x_pos
          end 
          if @savefile_windows[i].x > x_pos
             @savefile_windows[i].x -= 15
             @savefile_windows[i].x = x_pos if @savefile_windows[i].x < x_pos       
           end             
      end   
        
      #--------------------------------------------------------------------------
      # ● slide_window_y
      #--------------------------------------------------------------------------   
      def slide_window_y(i,y_pos)
          if @savefile_windows[i].y < y_pos
             @savefile_windows[i].y += 15
             @savefile_windows[i].y = y_pos if @savefile_windows[i].y > y_pos
          end 
          if @savefile_windows[i].y > y_pos
             @savefile_windows[i].y -= 15
             @savefile_windows[i].y = y_pos if @savefile_windows[i].y < y_pos       
           end             
      end   
        
      #--------------------------------------------------------------------------
      # ● reset_position
      #--------------------------------------------------------------------------     
      def reset_position(diretion)
          check_active_window     
          case diretion
             when 0
                @savefile_windows[@pw].y = -64
                @savefile_windows[@pw].x = 0
             when 1 
                @savefile_windows[@nw].y = 440
                @savefile_windows[@nw].x = 0
          end       
      end
        
      #--------------------------------------------------------------------------
      # ● Update Save File Selection
      #--------------------------------------------------------------------------
      def update_savefile_selection
          if Input.trigger?(Input::C)
             on_savefile_ok
          elsif Input.trigger?(Input::B)
             Sound.play_cancel
             return_scene
          else
            last_index = @index
            if Input.trigger?(Input::DOWN)
               execute_index(1)
               if @file_max > 2
                  reset_position(1)
               else
                  reset_position(0)
               end 
            end
            if Input.trigger?(Input::UP)
               execute_index(-1)
               reset_position(0)
            end
            if @index != last_index
               Sound.play_cursor
               @savefile_windows[last_index].selected = false
               @savefile_windows[@index].selected = true
            end     
          end
      end
    
      #--------------------------------------------------------------------------
      # ● Execute Index
      #-------------------------------------------------------------------------- 
      def execute_index(value)
          @index += value
          @index = @index >= @file_max ? 0 : @index < 0 ? (@file_max - 1) : @index
      end
     
    end
    
    $mog_rgss3_scene_file = true
    

    Greetings,
    Tw0Face
     
    #1
  2. Tw0Face

    Tw0Face Your boss Veteran

    Messages:
    44
    Likes Received:
    39
    First Language:
    German
    Primarily Uses:
    RMVXA
    Nobody?
     
    #2
  3. Powell

    Powell Veteran Veteran

    Messages:
    42
    Likes Received:
    2
    First Language:
    English
    Primarily Uses:
    N/A
    When you check the script editor is it Mog's script that gives you the error message at line 89? also have you checked if any of the available mouse scripts have the same issue with this?
     
    #3
    Tw0Face likes this.
  4. Tw0Face

    Tw0Face Your boss Veteran

    Messages:
    44
    Likes Received:
    39
    First Language:
    German
    Primarily Uses:
    RMVXA
    @ Powell: No, it's not in Mog's Script. The error messages shows that the error appears in Scene_File line 89.
    Code:
    def savefile_height
        @savefile_viewport.rect.height / visible_max               #line 89
      end
    
    I think it's because Mog's Script uses the term "rect" in a slightly different way and that's why I get an error in my default scripts. Anyway, this makes no sense to me because the method "rect" is already defined and it works all fine without Mog's Script.

    Greetings,
    Tw0Face
     
    #4
  5. Roninator2

    Roninator2 Gamer Veteran

    Messages:
    1,138
    Likes Received:
    195
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    have you tried using a different mouse script?
     
    #5
  6. Tw0Face

    Tw0Face Your boss Veteran

    Messages:
    44
    Likes Received:
    39
    First Language:
    German
    Primarily Uses:
    RMVXA
    @Roninator2: I just need to have Mog's Script work with it. Mog's Script doesn't fit with other Mouse Systems like Shaz or Jet as well. I was looking for a long time to find the "perfect" Mouse system. With any other Mouse Script, I would have even more Script issues.

    Greetings,
    Tw0Face
     
    Last edited: Dec 9, 2018
    #6
  7. Sixth

    Sixth Veteran Veteran

    Messages:
    2,035
    Likes Received:
    729
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    Mog's script completely rewrites the Scene_File class, and it doesn't make a @savefile_viewport variable at all (which would be the viewport for all savefile windows by default).

    That mouse script uses the method savefile_height, which would use that @savefile_viewport's rect to determine the mouse area for the savefile windows, but because of the reason mentioned above, there is no such variable there, so it can't have a rect method/variable.

    The entire Scene_File part of that mouse script will have to be rewritten to work with Mog's script.
    If you make me a demo with both scripts setup in it, I can take a look at it during my coffee breaks.

    Btw, which mouse script is this? Who is the author? I can't see any documentation for it.
    I'm surprised that this line:
    Code:
    class Game_Player < Game_Character < Scene_MenuBase
    Didn't trigger any errors right at the startup. o_O
     
    #7
    Tw0Face and Powell like this.
  8. Roninator2

    Roninator2 Gamer Veteran

    Messages:
    1,138
    Likes Received:
    195
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    That's not correct. I'm using MOG savefile A and Shaz super simple mouse. I have no issues.
     
    #8
  9. Tw0Face

    Tw0Face Your boss Veteran

    Messages:
    44
    Likes Received:
    39
    First Language:
    German
    Primarily Uses:
    RMVXA
    @Sixth: Thank you very much. I've sent you a Demo Project yesterday for you to look at. Would be really happy if you could help me.

    @Roninator2: As far as I know, Shaz' Script has no mouse aiming. Every other Mouse Script features Pathfinding instead which I don't need at all. The Mouse Script I'm currently using is actually best for me.

    Greetings,
    Tw0Face
     
    #9
  10. Sixth

    Sixth Veteran Veteran

    Messages:
    2,035
    Likes Received:
    729
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    That should do the trick.
    No idea how you planned mouse controls in that menu, so I just made it the way I think it's good.
     
    #10
    Tw0Face likes this.
  11. Tw0Face

    Tw0Face Your boss Veteran

    Messages:
    44
    Likes Received:
    39
    First Language:
    German
    Primarily Uses:
    RMVXA
    @Sixth: This is perfect! Thank you very much!
     
    #11

Share This Page