[RMXP] Editing Moghunter's Picture Gallery Script

● ARCHIVED · READ-ONLY
Started by slimmmeiske2 5 posts View original ↗
  1. Hello,

    I've been messing around with Moghunter's Picture Gallery script, trying to edit it to fit my needs (with my limited RGSS knowledge).
    However there's a couple of things that I just can't seem to fix/find myself.
    galleryscripthelpupdate.png
    1. I want the columns centered on each page of the book. I've been able to move the columns and now the first one is in its right place. I can't find how to make the space between the two columns bigger though, so the second one isn't centered yet.
    2. I want the text to be black. I've been able to set the numbers beneath the pictures to black, but the bottom row continues to confound me.
    EDIT: So I've been able to change it, by changing the line "@info = Window_Help.new" to a Window_Help2 class and changing the colour there. I can't help but think there's simpler solution, so if anyone knows it, I'd love to hear it still.

    I would appreciate any help you can give. :)
  2. This should do the trick for you. Though you'll have to set the customization options yourself to get it how you like. Here's the script:
    Spoiler
    Code:
    #===============================================================================
    # MOG Gallery - Customize Layout
    # Author: Mobius XVI
    # Version: 1.0
    # Date: 31 Aug 2018
    #===============================================================================
    #
    # Introduction:
    #
    #   The purpose of this script is to allow you to modify the layout of MOG's
    #   picture gallery script.
    #
    # Instructions:
    #
    #  - Place this script below the MOG Gallery script but above main
    #
    # Issues/Bugs/Possible Bugs:
    #
    #   - None yet.
    #
    #  Credits/Thanks:
    #    - Mobius XVI, author
    #    - MOG, author, original script:
    #      https://atelierrgss.wordpress.com/scripts/rpg-maker-xp/
    #
    #  License
    #
    #    The MIT License (MIT)
    #
    #    Copyright (c) 2018 darmes
    #
    #     Permission is hereby granted, free of charge, to any person obtaining a copy
    #     of this software and associated documentation files (the "Software"), to deal
    #     in the Software without restriction, including without limitation the rights
    #     to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    #     copies of the Software, and to permit persons to whom the Software is
    #     furnished to do so, subject to the following conditions:
    #
    #     The above copyright notice and this permission notice shall be included in all
    #     copies or substantial portions of the Software.
    #
    #     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    #     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    #     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    #     AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    #     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    #     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    #     SOFTWARE.
    #
    #==============================================================================
    # CUSTOMIZATION START
    #==============================================================================
    module MOG_PICTURE_GALLERY
     
      X_start = 15
      Y_start = 12
      Thumbnail_Width  = 150
      Thumbnail_Height = 80
      Number_Columns = 3
      Vertical_Spacing = 30
      Horizontal_Spacing = 65
      Cursor_Padding = 12
      Font_Name = "MS PGothic"
      Font_Color = Color.new(0,0,0)
     
    end
    #==============================================================================
    # CUSTOMIZATION END -- DON'T EDIT BELOW THIS LINE!!!
    #==============================================================================
    
    #==============================================================================
    # * Window_Base
    #==============================================================================
    class Window_Base < Window
      #--------------------------------------------------------------------------
      # Draw_Thumbnail
      #-------------------------------------------------------------------------- 
      def draw_thumbnail(x,y,id)
          image = RPG::Cache.gallery(id.to_s) rescue nil
          return if image == nil
          cw = image.width
          ch = image.height
          src_rect = Rect.new(0, 0, cw , ch)
          tw = MOG_PICTURE_GALLERY::Thumbnail_Width
          th = MOG_PICTURE_GALLERY::Thumbnail_Height
          src_rect2 = Rect.new(x, y, tw, th) 
          self.contents.stretch_blt(src_rect2, image, src_rect)
      end
    end 
    
    #==============================================================================
    # * Window_Picture
    #==============================================================================
    class Window_Picture < Window_Selectable
     
     #------------------------------------------------------------------------------
     # * Initialize
     #------------------------------------------------------------------------------   
      def initialize(page)
          super(0, 64, 640, 365)
          self.opacity = 0
          @column_max = MOG_PICTURE_GALLERY::Number_Columns
          @page = page
          @pic_max = MOG_PICTURE_GALLERY::MAX_PICTURES
          @pic_max = 1 if @pic_max <= 0
          @item_max = MOG_PICTURE_GALLERY::Number_Columns * page_row_max
          @pag_max = @pic_max / @item_max
          if @pag_max == page
             o = @pag_max * @item_max
             o2 =  @pic_max - o
             @item_max = o2
          end 
          refresh(page)
          self.index = 0
      end
      #--------------------------------------------------------------------------
      # * Get Number of Rows Displayable on 1 Page
      #--------------------------------------------------------------------------
      def page_row_max
        # Subtract a frame height of 32 from the window height, and divide it by
        # 1 row height of 32
        return ((self.height - 32) + MOG_PICTURE_GALLERY::Vertical_Spacing) / \
                (80 + MOG_PICTURE_GALLERY::Vertical_Spacing)
      end
      #--------------------------------------------------------------------------
      # * Get horizontal spacing
      #--------------------------------------------------------------------------
      def horizontal_spacing
        MOG_PICTURE_GALLERY::Thumbnail_Width + MOG_PICTURE_GALLERY::Horizontal_Spacing
      end
      #--------------------------------------------------------------------------
      # * Get vertical spacing
      #--------------------------------------------------------------------------
      def vertical_spacing
        MOG_PICTURE_GALLERY::Thumbnail_Height + MOG_PICTURE_GALLERY::Vertical_Spacing
      end
      #------------------------------------------------------------------------------
      # * draw_item
      #------------------------------------------------------------------------------   
      def draw_item(index,page)
          np = @item_max * page
          picture_number = index + 1 + np
          #x = 15 + index % 3 * 215
          x = MOG_PICTURE_GALLERY::X_start + \
              ((index % @column_max) * horizontal_spacing)
          #y = 12 + index / 3 *110
          y = MOG_PICTURE_GALLERY::Y_start + \
              ((index / @column_max) * vertical_spacing)
          s = picture_number
          s = 0 if $game_system.gallery[picture_number] == nil
          draw_thumbnail(x,y,s)
          self.contents.font.name  = MOG_PICTURE_GALLERY::Font_Name
          self.contents.font.color = MOG_PICTURE_GALLERY::Font_Color
          self.contents.draw_text(x + 45,y + 70, 64, 32, "N - " + picture_number.to_s,1)
          self.contents.font.name  = Font.default_name
          self.contents.font.color = normal_color
      end
     
     #------------------------------------------------------------------------------
     # * update_cursor_rect
     #------------------------------------------------------------------------------   
      def update_cursor_rect
          if @index < 0
             self.cursor_rect.empty
             return
          end
          row = @index / @column_max
          if row < self.top_row
             self.top_row = row
          end
          if row > self.top_row + (self.page_row_max - 1)
             self.top_row = row - (self.page_row_max - 1)
          end
          cursor_width = MOG_PICTURE_GALLERY::Thumbnail_Width + \
                         (2 * MOG_PICTURE_GALLERY::Cursor_Padding)
          cursor_height = MOG_PICTURE_GALLERY::Thumbnail_Height + \
                         (2 * MOG_PICTURE_GALLERY::Cursor_Padding)
          #x = index % 3 * 215
          x = MOG_PICTURE_GALLERY::X_start - \
              MOG_PICTURE_GALLERY::Cursor_Padding + \
              (index % @column_max) * horizontal_spacing
          #y = index / 3 *110
          y = MOG_PICTURE_GALLERY::Y_start - \
              MOG_PICTURE_GALLERY::Cursor_Padding + \
              (index / @column_max) * vertical_spacing
          self.cursor_rect.set(x, y, cursor_width, cursor_height)
      end   
    end
    
    #==============================================================================
    # * Window_Picture_Help
    #==============================================================================
    class Window_Picture_Help < Window_Help
      #--------------------------------------------------------------------------
      # * Set Text
      #  text  : text string displayed in window
      #  align : alignment (0..flush left, 1..center, 2..flush right)
      #--------------------------------------------------------------------------
      def set_text(text, align = 0)
        # If at least one part of text and alignment differ from last time
        if text != @text or align != @align
          # Redraw text
          self.contents.clear
          self.contents.font.name  = MOG_PICTURE_GALLERY::Font_Name
          self.contents.font.color = MOG_PICTURE_GALLERY::Font_Color
          self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
          @text = text
          @align = align
          @actor = nil
        end
        self.visible = true
      end
    end
    
    #==============================================================================
    # * Scene_ArtPictures
    #==============================================================================
    class Scene_Picture_Gallery
     #------------------------------------------------------------------------------
     # * Create Window
     #------------------------------------------------------------------------------     
     def create_window
         @info = Window_Picture_Help.new
         @info.y = 416
         @info.opacity = 0
         @wp_page = 0
         @wp_page_old = @wp_page
         @wp_index = 0
         @wp =[]
         for i in 0...@max_pages
             @wp[i] = Window_Picture.new(i)
             @wp[i].x = 32 * i
         end 
         check_active_window(true)
         refresh_info_window(true)
     end
     
    end
    and here's the explanation of the various options.
    Spoiler
    Picture1.png
  3. @MobiusXVI Thank you so much. That works perfectly.

    There's just one thing I noticed now that I actually pasted into the game project with my other scripts. It seems the gallery and the mouse script aren't working together.
    gh8g4X3.png
    I just tried the mouse script in Moghunter gallery demo (so without any customization) and it's not working there either. I don't know how hard it is to get them to work together. So if it's impossible or too difficult, just tell me:aswt:
  4. I can give you the snippet below. It's a quick and dirty fix. It will let you use the mouse with the gallery but not the arrow keys. To make things *actually* compatible would take a more significant investment of time. As far as script order, I got this all to work in the gallery demo by placing the gallery script first, then my edits to the gallery script, then the mouse script, then my edits to the mouse script.
    Spoiler
    Code:
    #==============================================================================
    # * Window_Picture
    #==============================================================================
    class Window_Picture < Window_Selectable
      alias_method :seph_mouseselectable_wndslct_update, :update
      #-------------------------------------------------------------------------- 
        # * Frame Update 
        #-------------------------------------------------------------------------- 
        def update       
            # agf = hide mouse   
            if $mouse_sprite.visible == true       
            
            # If Mouse Selectable, Active, at Least 1 Item and Non-negitive index   
            if self.mouse_selectable && self.active && @item_max > 0 && @index >= 0     
                # Gets Mouse Position     
                mouse_x, mouse_y = *Mouse.position           
                
                # If Mouse Within Window             
                if mouse_x.between? (self.x, self.x + self.width) &&         
                    mouse_y.between? (self.y, self.y + self.height)       
                    # Calculates Mouse X and Y Position Within Window       
                    mouse_x -= self.x; mouse_y -= self.y       
                    # Subtracts Window Padding       
                    mouse_x -= @window_padding; mouse_y -= @window_padding       
                    # Subtracts Mouse Oh       
                    mouse_y -= self.mouse_oh       
                    # Gets Cursor Width       
                    cursor_width = MOG_PICTURE_GALLERY::Thumbnail_Width + \
                         (2 * MOG_PICTURE_GALLERY::Cursor_Padding)
            cursor_height = MOG_PICTURE_GALLERY::Thumbnail_Height + \
                         (2 * MOG_PICTURE_GALLERY::Cursor_Padding)
                    # Passes Through Item Max       
                    for i in 0...@item_max         
                        # Calculates Index Position         
                        x = MOG_PICTURE_GALLERY::X_start - \
                  MOG_PICTURE_GALLERY::Cursor_Padding + \
                  (i % @column_max) * horizontal_spacing
              y = MOG_PICTURE_GALLERY::Y_start - \
                  MOG_PICTURE_GALLERY::Cursor_Padding + \
                  (i / @column_max) * vertical_spacing       
                        # If Mouse Between Rect         
                        if mouse_x.between?(x, x + cursor_width) &&             
                            mouse_y.between?(y, y + cursor_height)           
                            # Set Index           
                            prev_index = @index           
                            @index = i           
                            if prev_index != @index             
                                $game_system.se_play($data_system.cursor_se)           
                            end           
                            break         
                        end       
                    end     
                end   
            end       
    
            end       
        
            # Original Update   
            #seph_mouseselectable_wndslct_update 
        update_cursor_rect
        end 
    end
  5. @MobiusXVI Thanks for your quick response and the hotfix. :) I figured it would be time consuming. Guess, I'll have some thinking to do.

    In the meantime, this thread can be closed.