[XP] Wecoc's Mosaic Shop System

Started by Wecoc, May 25, 2013, 02:11:21 pm

Previous topic - Next topic

Wecoc

Wecoc's Mosaic Shop System
Authors: Wecoc
Version: 1.0
Type: Custom Shop System
Key Term: Custom Shop System



Introduction

This shop script displays objects as a mosaic and not on a list. It has configurable parts, using the module NewShopWecoc.
The script requires Window_Selectable +


Features


  • Easy configurable with the module

  • The item's price window moves with the cursor

  • Window_ShopNumber can be activated or deactivated




Screenshots

Spoiler: ShowHide






Demo

Not necessary.


Script

Insert them above main

Window_Selectable +
Spoiler: ShowHide

#==============================================================================
# [Scripter's Tool] Window_Selectable +
#------------------------------------------------------------------------------
# This window class contains cursor movement and scroll functions.
# New functions for the class Window_Selectable
# by: Wecoc
#==============================================================================

class Window_Selectable < Window_Base
  attr_reader  :index
  attr_reader  :help_window
  def initialize(x, y, width, height)
    super(x, y, width, height)
    @item_max = 1 # Número máximo de elementos que contiene la ventana.
    @column_max = 1 # Número máximo de columnas
    @index = -1
    @virtualOy=0 # y en la que sale el primer item de la lista. Defecto: 0
    @row_hplus=0 # Viene definido más abajo.
    self.rowHeight=32 # Separación entre filas. Defecto: 32
    @column_spacing=32 # Separación entre columnas. Defecto: 32
  end

  def count # Número de ítems
    return @item_max || 0
  end

  def index=(index)
    if @index!=index
      @index = index
      self.refresh
    end
    if self.active and @help_window != nil
      update_help
    end
    update_cursor_rect
  end

  def rowHeight # Separación entre filas
    return @row_height || 32
  end

  def rowHeight=(value)
    if @row_height != value
      @row_height = [1,value].max
      @row_hplus = (([32,@row_height].max)-32)/2
    # @row_hplus controla mejor la separación para encuadrar los items.
    # No hace falta cambiarlo porque lo hace solo, cuando se cambia @row_height.
    # Nótese que su valor default es 0/2 = 0
      update_cursor_rect
    end
  end

  def columns # Número de columnas
    return @column_max || 1
  end

  def columns=(value)
    if @column_max != value
      @column_max=[1,value].max
      update_cursor_rect
    end
  end

  def columnSpacing # Separación entre columnas
    return @column_spacing || 32
  end

  def columnSpacing=(value)
    if @column_spacing != value
      @column_spacing=[0,value].max
      update_cursor_rect
    end
  end

  def row_max # Número máximo de filas
    return (@item_max + @column_max - 1) / @column_max
  end

  def top_row # El número de fila superior, que se muestra en la ventana, donde
    # 0 es la fila superior de los elementos.
    # Divide la coordenada de origen y por lo que vale el alto de una fila.
    return ((self.oy+@virtualOy) / (@row_height || 32)).to_i
  end

  def top_item # El item correspondiente al top_row, que variará según la columna
    return top_row * @column_max
  end

  def top_row=(row)
    if row > row_max - 1
      row = row_max - 1
    end
    if row < 0
      row = 0
    end
    self.oy = row * @row_height
  end

  def page_row_max # Número máximo de filas que se pueden mostrar a la vez.
    return ((self.height - 32) / @row_height).to_i
  end
  def page_item_max # Número máximo de items que se pueden mostrar a la vez.
    return page_row_max * @column_max
  end

  def help_window=(help_window)
    @help_window = help_window
    if self.active and @help_window != nil
      update_help
    end
  end

  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 = self.width / @column_max - 32
    x = @index % @column_max * (cursor_width + @column_spacing)
    y = @index / @column_max * @row_height - self.oy
    self.cursor_rect.set(x, y, cursor_width, @row_height)
  end

  def update
    super
    if self.active and @item_max > 0 and @index >= 0
      if Input.repeat?(Input::DOWN) # Pulsar abajo
        #if (Input.trigger?(Input::DOWN) and (@item_max % @column_max)==0) or
        if (Input.trigger?(Input::DOWN) and (@column_max==1)) or
          @index < @item_max - @column_max
          $game_system.se_play($data_system.cursor_se)
          @index = (@index + @column_max) % @item_max
          update_cursor_rect
        end
      end
      if Input.repeat?(Input::UP) # Pulsar arriba
        if (Input.trigger?(Input::UP) and (@item_max%@column_max)==0) or
          @index >= @column_max
          $game_system.se_play($data_system.cursor_se)
          @index = (@index - @column_max + @item_max) % @item_max
          update_cursor_rect
        end
      end
      if Input.repeat?(Input::RIGHT) # Pulsar Derecha
        if @column_max >= 2 and @index < @item_max - 1
          $game_system.se_play($data_system.cursor_se)
          @index += 1
          update_cursor_rect
        end
      end
      if Input.repeat?(Input::LEFT) # Pulsar Izquierda
        if @column_max >= 2 and @index > 0
          $game_system.se_play($data_system.cursor_se)
          @index -= 1
          update_cursor_rect
        end
      end
      if Input.repeat?(Input::R) # Pulsar R (o RePag)
        if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
          $game_system.se_play($data_system.cursor_se)
          @index = [@index + self.page_item_max, @item_max - 1].min
          self.top_row += self.page_row_max
          update_cursor_rect
        end
      end
      if Input.repeat?(Input::L) # Pulsar L (o AvPag)
        if self.top_row > 0
          $game_system.se_play($data_system.cursor_se)
          @index = [@index - self.page_item_max, 0].max
          self.top_row -= self.page_row_max
          update_cursor_rect
        end
      end
    end
    if self.active and @help_window != nil
      update_help
    end
    update_cursor_rect
  end
end


Wecoc's Mosaic Shop System
Spoiler: ShowHide

#==============================================================================
# WECOC'S "MOSAIC" SHOP SYSTEM v1.0
#------------------------------------------------------------------------------
# By: Wecoc
#------------------------------------------------------------------------------
# This shop script displays objects as a mosaic and not on a list.
# It has configurable parts, using the module NewShopWecoc.
# I attached some possible options. Hope you like the script.
# The script requires Window_Selectable +

=begin

  ------------------------------
  VERSION 1

  COLUMN_MAX = 4
  ROW_HEIGHT = 64
  SHOW_OWN_BIG = true
  TEXT_SIZE = 16
  TEXT_BOLD = true
  SHOW_BIG_PSTATUS = true
  SHOW_OWN_SMALL = false
  SHOW_SMALL_PSTATUS = false
  SHOW_NUMBER = true
  ------------------------------
  VERSION 2

  COLUMN_MAX = 10
  ROW_HEIGHT = 32
  SHOW_OWN_BIG = false
  TEXT_SIZE = 14
  TEXT_BOLD = true
  SHOW_BIG_PSTATUS = false
  SHOW_OWN_SMALL = true
  SHOW_SMALL_PSTATUS = true
  SHOW_NUMBER = false
  ------------------------------
  VERSION 3

  COLUMN_MAX = 3
  ROW_HEIGHT = 45
  SHOW_OWN_BIG = true
  TEXT_SIZE = 20
  TEXT_BOLD = false
  SHOW_BIG_PSTATUS = false
  SHOW_OWN_SMALL = false
  SHOW_SMALL_PSTATUS = false
  SHOW_NUMBER = false
=end
#==============================================================================

#------------------------------------------------------------------------------
# MODULE GLOBALS
#------------------------------------------------------------------------------

module NewShopWecoc
 
  # -------------------------
  COLUMN_MAX = 4 # Indicates how many columns have Window_Buy and Window_Sell
  ROW_HEIGHT = 64 # Indicates how the cursor measured (row height)
  # -------------------------
 
  # If true, the item's name will appear on the mosaic,
  # and under it how many you own.
  SHOW_OWN_BIG = true
   
    # Text size of the name of the item and "Own: x" and if bold or not
    TEXT_SIZE = 16
    TEXT_BOLD = true
   
    # Only if SHOW_OWN_BIG es activated. If SHOW_BIG_PSTATUS is true, it says
    # if the weapon or armor is better that which actors wear.
    SHOW_BIG_PSTATUS = true
   
      MINUS = Color.new(255,  0,  0)  # Color when it's worse
      EQUAL = Color.new(255, 255,  0) # Color when it's equal
      PLUS  = Color.new(  0, 255,  0) # Color when it's better
      OFF  = Color.new(100, 110, 120) # Color when actor can't wear it
  # -------------------------
  # If true it will display how many items you own with a small number
  SHOW_OWN_SMALL = false
  # If true it says if the weapon or armor is better that which PLAYER wears
  SHOW_SMALL_PSTATUS = false
  # If true, number_window (Window_ShopNumber) works as always.
  # If false it does not work and you can just buy items one by one.
  SHOW_NUMBER = false
end

#------------------------------------------------------------------------------
# Window_ShopBuy
#------------------------------------------------------------------------------

class Window_ShopBuy < Window_Selectable

  # initialize considering COLUMN_MAX y ROW_HEIGHT
  def initialize(shop_goods)
    super(0, 128, 640, 352)
    @column_max = NewShopWecoc::COLUMN_MAX
    self.rowHeight=NewShopWecoc::ROW_HEIGHT
    @shop_goods = shop_goods
    refresh
    self.index = 0
  end

  def item
    return @data[self.index]
  end

  # refresh with @row_height correction
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for goods_item in @shop_goods
      case goods_item[0]
      when 0
        item = $data_items[goods_item[1]]
      when 1
        item = $data_weapons[goods_item[1]]
      when 2
        item = $data_armors[goods_item[1]]
      end
      if item != nil
        @data.push(item)
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * @row_height)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end

  # draw_item (the most configurable part)
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item # Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon # Weapon
      number = $game_party.weapon_number(item.id)
      for i in 0...$game_party.actors.size
        number += 1 if $game_party.actors[i].weapon_id == item.id
      end
    when RPG::Armor # Armor
      number = $game_party.armor_number(item.id)
      for i in 0...$game_party.actors.size
        number += 1 if $game_party.actors[i].armor1_id == item.id
        number += 1 if $game_party.actors[i].armor2_id == item.id
        number += 1 if $game_party.actors[i].armor3_id == item.id
        number += 1 if $game_party.actors[i].armor4_id == item.id
      end
    end
    if item.price <= $game_party.gold and number < 99
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
   
  if NewShopWecoc::SHOW_OWN_BIG # SHOW_OWN_BIG = true
    cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
    cursor_height = NewShopWecoc::ROW_HEIGHT
    column_max = NewShopWecoc::COLUMN_MAX
   
    x = index % column_max * 640 / column_max
    y = index / column_max * cursor_height
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x+2, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.font.size = NewShopWecoc::TEXT_SIZE #16
    self.contents.font.bold = NewShopWecoc::TEXT_BOLD
    self.contents.draw_text(x + 30, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 30, y+20, 212, 32, "Own: "+number.to_s, 0)
    self.contents.font.size = 25
    if NewShopWecoc::SHOW_BIG_PSTATUS # SHOW_BIG_PSTATUS = true
      case item
      when RPG::Weapon # Weapon
        for i in 0...$game_party.actors.size
          itemcomp = $game_party.actors[i].weapon_id
          if $game_party.actors[i].equippable?(item)
            if itemcomp == 0 or $data_weapons[itemcomp].price < item.price # PLUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::PLUS
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "+", 0)
            elsif $data_weapons[itemcomp].price == item.price # EQUAL
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::EQUAL
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "=", 0)
            elsif $data_weapons[itemcomp].price > item.price # MINUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::MINUS
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "-", 0)
            end
          else # You can't equip
            if self.contents.font.color != disabled_color
              self.contents.font.color = NewShopWecoc::OFF
            end
            self.contents.draw_text(x+15+i*30, y+36, 212, 32, "/", 0)
          end
        end
      when RPG::Armor # Armor
        for i in 0...$game_party.actors.size
          case item.kind
            when 0 ; itemcomp = $game_party.actors[i].armor1_id
            when 1 ; itemcomp = $game_party.actors[i].armor2_id
            when 2 ; itemcomp = $game_party.actors[i].armor3_id
            when 3 ; itemcomp = $game_party.actors[i].armor4_id
          end
          if $game_party.actors[i].equippable?(item)
            if itemcomp == 0 or $data_armors[itemcomp].price < item.price # PLUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::PLUS
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "+", 0)
            elsif $data_armors[itemcomp].price == item.price # EQUAL
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::EQUAL
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "=", 0)
            elsif $data_armors[itemcomp].price > item.price # MINUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::MINUS
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "-", 0)
            end
          else # You can't equip
            if self.contents.font.color != disabled_color
              self.contents.font.color = NewShopWecoc::OFF
            end
            self.contents.draw_text(x+15+i*30, y+36, 212, 32, "/", 0)
          end
        end
      end
    end
    else # SHOW_OWN_BIG = false
      cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
      cursor_height = NewShopWecoc::ROW_HEIGHT
      column_max = NewShopWecoc::COLUMN_MAX
     
      x = index%column_max * 640/column_max + cursor_width/2-12
      y = index/column_max * cursor_height + cursor_height/2-12
      rect = Rect.new(x, y, self.width / @column_max - 32, 32)
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      bitmap = RPG::Cache.icon(item.icon_name)
      opacity = self.contents.font.color == normal_color ? 255 : 128
      self.contents.blt(x, y, bitmap, Rect.new(0, 0, 24, 24), opacity)
     
      if NewShopWecoc::SHOW_OWN_SMALL # SHOW_OWN_SMALL = true
        self.contents.font.size = NewShopWecoc::TEXT_SIZE # 16
        self.contents.font.bold = NewShopWecoc::TEXT_BOLD
        self.contents.draw_text(x+18, y+5, 32, 32, number.to_s, 0)
      end
      if NewShopWecoc::SHOW_SMALL_PSTATUS # SHOW_SMALL_PSTATUS = true
        self.contents.font.size = NewShopWecoc::TEXT_SIZE # 16
        self.contents.font.bold = NewShopWecoc::TEXT_BOLD
        case item
        when RPG::Weapon # Weapon
          itemcomp = $game_party.actors[0].weapon_id
          if $game_party.actors[0].equippable?(item)
            if itemcomp == 0 or $data_weapons[itemcomp].price < item.price # PLUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::PLUS
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "+", 0)
            elsif $data_weapons[itemcomp].price == item.price # EQUAL
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::EQUAL
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "=", 0)
            elsif $data_weapons[itemcomp].price > item.price # MINUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::MINUS
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "-", 0)
            end
          end
        when RPG::Armor # Armor
          case item.kind
            when 0 ; itemcomp = $game_party.actors[0].armor1_id
            when 1 ; itemcomp = $game_party.actors[0].armor2_id
            when 2 ; itemcomp = $game_party.actors[0].armor3_id
            when 3 ; itemcomp = $game_party.actors[0].armor4_id
          end
          if $game_party.actors[0].equippable?(item)
            if itemcomp == 0 or $data_armors[itemcomp].price < item.price # PLUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::PLUS
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "+", 0)
            elsif $data_armors[itemcomp].price == item.price # EQUAL
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::EQUAL
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "=", 0)
            elsif $data_armors[itemcomp].price > item.price # MINUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::MINUS
              end
              self.contents.draw_text(x+18, y-14, 32, 32, "-", 0)
            end
          end
        end
      end     
    end
  end

  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

#------------------------------------------------------------------------------
# Window_ShopSell
#------------------------------------------------------------------------------

class Window_ShopSell < Window_Selectable

  # initialize considering COLUMN_MAX y ROW_HEIGHT
  def initialize
    super(0, 128, 640, 352)
    @column_max = NewShopWecoc::COLUMN_MAX
    self.rowHeight=NewShopWecoc::ROW_HEIGHT
    refresh
    self.index = 0
  end

  def item
    return @data[self.index]
  end

  # refresh with @row_height correction
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    for i in 1...$data_weapons.size
      if $game_party.weapon_number(i) > 0
        @data.push($data_weapons[i])
      end
    end
    for i in 1...$data_armors.size
      if $game_party.armor_number(i) > 0
        @data.push($data_armors[i])
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * @row_height)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end

  # draw_item (the most configurable part)
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item # Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon # Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor # Armor
      number = $game_party.armor_number(item.id)
    end
    if item.price > 0
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
   
  if NewShopWecoc::SHOW_OWN_BIG # SHOW_OWN_BIG = true
    cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
    cursor_height = NewShopWecoc::ROW_HEIGHT
    column_max = NewShopWecoc::COLUMN_MAX
   
    x = index % column_max * 640 / column_max
    y = index / column_max * cursor_height
   
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x+2, y+4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.font.size = NewShopWecoc::TEXT_SIZE #16
    self.contents.font.bold = NewShopWecoc::TEXT_BOLD
    self.contents.draw_text(x + 30, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 30, y+20, 212, 32, "Own: "+number.to_s, 0)
    self.contents.font.size = 25
    if NewShopWecoc::SHOW_BIG_PSTATUS # SHOW_BIG_PSTATUS = true
      case item
      when RPG::Weapon
        for i in 0...$game_party.actors.size
          itemcomp = $game_party.actors[i].weapon_id
          if $game_party.actors[i].equippable?(item)
            if itemcomp == 0 or $data_weapons[itemcomp].price < item.price # PLUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::PLUS
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "+", 0)
            elsif $data_weapons[itemcomp].price == item.price # EQUAL
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::EQUAL
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "=", 0)
            elsif $data_weapons[itemcomp].price > item.price # MINUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::MINUS
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "-", 0)
            end
          else # You can't equip
            if self.contents.font.color != disabled_color
              self.contents.font.color = NewShopWecoc::OFF
            end
            self.contents.draw_text(x+15+i*30, y+36, 212, 32, "/", 0)
          end
        end
      when RPG::Armor
        for i in 0...$game_party.actors.size
          case item.kind
            when 0 ; itemcomp = $game_party.actors[i].armor1_id
            when 1 ; itemcomp = $game_party.actors[i].armor2_id
            when 2 ; itemcomp = $game_party.actors[i].armor3_id
            when 3 ; itemcomp = $game_party.actors[i].armor4_id
          end
          if $game_party.actors[i].equippable?(item)
            if itemcomp == 0 or $data_armors[itemcomp].price < item.price # PLUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::PLUS
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "+", 0)
            elsif $data_armors[itemcomp].price == item.price # EQUAL
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::EQUAL
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "=", 0)
            elsif $data_armors[itemcomp].price > item.price # MINUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::MINUS
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "-", 0)
            end
          else # You can't equip
            if self.contents.font.color != disabled_color
              self.contents.font.color = NewShopWecoc::OFF
            end
            self.contents.draw_text(x+15+i*30, y+36, 212, 32, "/", 0)
          end
        end
      end
    end
    else # SHOW_OWN_BIG = false
      cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
      cursor_height = NewShopWecoc::ROW_HEIGHT
      column_max = NewShopWecoc::COLUMN_MAX
     
      x = index%column_max * 640/column_max + cursor_width/2-12
      y = index/column_max * cursor_height + cursor_height/2-12
      rect = Rect.new(x, y, self.width / @column_max - 32, 32)
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      bitmap = RPG::Cache.icon(item.icon_name)
      opacity = self.contents.font.color == normal_color ? 255 : 128
      self.contents.blt(x, y, bitmap, Rect.new(0, 0, 24, 24), opacity)
     
      if NewShopWecoc::SHOW_OWN_SMALL # SHOW_OWN_SMALL = true
        self.contents.font.size = NewShopWecoc::TEXT_SIZE # 16
        self.contents.font.bold = NewShopWecoc::TEXT_BOLD
        self.contents.draw_text(x+18, y+5, 32, 32, number.to_s, 0)
      end
      if NewShopWecoc::SHOW_SMALL_PSTATUS # SHOW_SMALL_PSTATUS = true
        self.contents.font.size = NewShopWecoc::TEXT_SIZE # 16
        self.contents.font.bold = NewShopWecoc::TEXT_BOLD
        case item
        when RPG::Weapon # Weapon
          itemcomp = $game_party.actors[0].weapon_id
          if $game_party.actors[0].equippable?(item)
            if itemcomp == 0 or $data_weapons[itemcomp].price < item.price # PLUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::PLUS
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "+", 0)
            elsif $data_weapons[itemcomp].price == item.price # EQUAL
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::EQUAL
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "=", 0)
            elsif $data_weapons[itemcomp].price > item.price # MINUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::MINUS
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "-", 0)
            end
          end
        when RPG::Armor # Armor
          case item.kind
            when 0 ; itemcomp = $game_party.actors[0].armor1_id
            when 1 ; itemcomp = $game_party.actors[0].armor2_id
            when 2 ; itemcomp = $game_party.actors[0].armor3_id
            when 3 ; itemcomp = $game_party.actors[0].armor4_id
          end
          if $game_party.actors[0].equippable?(item)
            if itemcomp == 0 or $data_armors[itemcomp].price < item.price # PLUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::PLUS
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "+", 0)
            elsif $data_armors[itemcomp].price == item.price # IGUAL
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::EQUAL
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "=", 0)
            elsif $data_armors[itemcomp].price > item.price # MINUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::MINUS
              end
              self.contents.draw_text(x+18, y-14, 32, 32, "-", 0)
            end
          end
        end
      end     
    end
  end

  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

#------------------------------------------------------------------------------
# Window_ShopGold
#------------------------------------------------------------------------------

class Window_ShopGold < Window_Base

  def initialize
    @buying = true
    super(230,0,120,64)
    self.z = 9980
    self.contents = Bitmap.new(width - 32, height - 32)
  end

  def refresh
    self.contents.clear
    if @item == nil
      return
    end
    case @item
    when RPG::Item
      number = $game_party.item_number(@item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(@item.id)
    when RPG::Armor
      number = $game_party.armor_number(@item.id)
    end

    self.contents.font.color = normal_color
    if @item.price == 0
      self.contents.font.color = disabled_color
    end
    if ($game_party.gold < @item.price) and buying?
      self.contents.font.color = disabled_color
    end
    if number == 99 and buying?
      self.contents.font.color = disabled_color
    end
    if buying?
      gold = $data_system.words.gold
      self.contents.draw_text(0,0,120-32,32,@item.price.to_s+gold,1)
    else
      gold = $data_system.words.gold
      self.contents.draw_text(0,0,120-32,32,(@item.price/2).to_s+gold,1)
    end
  end

  def buying?
    return @buying
  end

  def buying=(value)
    @buying = value
  end

  def item=(value)
    @item=value
  end
end

#==============================================================================
# Scene_Shop
#==============================================================================

class Scene_Shop
  def main
    # Window_Help - Window with the description of each object
    @help_window = Window_Help.new
    # Window_ShopCommand - "Buy", "Sell", "Leave"
    @command_window = Window_ShopCommand.new
   
    # Window_Gold - Window with the money group owns
    @gold_window = Window_Gold.new
    @gold_window.x = 480
    @gold_window.y = 64
   
    # Window_Base - Empty window for when you're not buying or selling
    @dummy_window = Window_Base.new(0, 128, 640, 352)
   
    # Window_ShopBuy - Window with the objects to buy
    @buy_window = Window_ShopBuy.new($game_temp.shop_goods)
    @buy_window.active = false
    @buy_window.visible = false
    @buy_window.help_window = @help_window
   
    # Window_ShopSell - Window with the objects to sell
    @sell_window = Window_ShopSell.new
    @sell_window.active = false
    @sell_window.visible = false
    @sell_window.help_window = @help_window
   
    # Window_ShopNumber - It shows the number of objects to buy or sell
    @number_window = Window_ShopNumber.new
    @number_window.z = 1000
    @number_window.active = false
    @number_window.visible = false

    # Window_ShopGold - Window with the price of each object
    @shopgold_window = Window_ShopGold.new
    @shopgold_window.visible = false

    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @help_window.dispose
    @command_window.dispose
    @gold_window.dispose
    @dummy_window.dispose
    @buy_window.dispose
    @sell_window.dispose
    @shopgold_window.dispose
    @number_window.dispose
  end

  def update
    @help_window.update
    @command_window.update
    @gold_window.update
    @dummy_window.update
    @buy_window.update
    @sell_window.update
    @number_window.update
    if @command_window.active
      update_command
      return
    end
    if @buy_window.active
      update_buy
      return
    end
    if @sell_window.active
      update_sell
      return
    end
    if @number_window.active
      update_number
      return
    end
  end

  def update_command
    if Input.trigger?(Input::B) # Cancel
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C) # Accept
      case @command_window.index
      when 0  # Buy
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @dummy_window.visible = false
        @buy_window.active = true
        @buy_window.visible = true
        @buy_window.refresh
       
        @shopgold_window.buying = true
        shopgold_position # Price window position
        @shopgold_window.visible = true
        @shopgold_window.refresh
      when 1  # Sell
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @dummy_window.visible = false
        @sell_window.active = true
        @sell_window.visible = true
        @sell_window.refresh
       
        @shopgold_window.buying = false
        shopgold_position # Price window position
        @shopgold_window.visible = true
        @shopgold_window.refresh
      when 2  # Leave
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Map.new
      end
      return
    end
  end

  def update_buy
    if Input.press?(Input.dir4) # Moving around the window
      @shopgold_window.buying = true
      shopgold_position # Price window position
      @shopgold_window.visible = true
      @shopgold_window.refresh
    end
    if Input.trigger?(Input::B) # Cancel
      $game_system.se_play($data_system.cancel_se)
      @shopgold_window.visible = false
      @command_window.active = true
      @dummy_window.visible = true
      @buy_window.active = false
      @buy_window.visible = false
      @help_window.set_text("")
      return
    end
    if Input.trigger?(Input::C) # Accept
      @item = @buy_window.item
      if @item == nil or @item.price > $game_party.gold
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      case @item
      when RPG::Item
        number = $game_party.item_number(@item.id)
      when RPG::Weapon
        number = $game_party.weapon_number(@item.id)
      when RPG::Armor
        number = $game_party.armor_number(@item.id)
      end
      if number == 99
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if NewShopWecoc::SHOW_NUMBER # Number Window
        $game_system.se_play($data_system.decision_se)
        max = @item.price == 0 ? 99 : $game_party.gold / @item.price
        max = [max, 99 - number].min
        @number_window.set(@item, max, @item.price)
        @number_window.active = true
        @number_window.visible = true
        @buy_window.active = false
        @shopgold_window.visible = false
      else
        $game_system.se_play($data_system.shop_se)
        case @item
        when RPG::Item
          $game_party.gain_item(@item.id, 1)
        when RPG::Weapon
          $game_party.gain_weapon(@item.id, 1)
        when RPG::Armor
          $game_party.gain_armor(@item.id, 1)
        end
        $game_party.lose_gold(@item.price)
        @buy_window.refresh
        @gold_window.refresh
        @shopgold_window.refresh
      end
    end
  end

  def update_sell
    if Input.press?(Input.dir4) # Moving around the window
      @shopgold_window.buying = false
      shopgold_position # Price window position
      @shopgold_window.visible = true
      @shopgold_window.refresh
    end
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @shopgold_window.visible = false
      @command_window.active = true
      @dummy_window.visible = true
      @sell_window.active = false
      @sell_window.visible = false
      @help_window.set_text("")
      return
    end
    if Input.trigger?(Input::C)
      @item = @sell_window.item
      if @item == nil or @item.price == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if NewShopWecoc::SHOW_NUMBER # Number Window
        $game_system.se_play($data_system.decision_se)
        case @item
        when RPG::Item
          number = $game_party.item_number(@item.id)
        when RPG::Weapon
          number = $game_party.weapon_number(@item.id)
        when RPG::Armor
          number = $game_party.armor_number(@item.id)
        end
        max = number
        @sell_window.active = false
        @shopgold_window.visible = false
        @number_window.set(@item, max, @item.price / 2)
        @number_window.active = true
        @number_window.visible = true
      else
        $game_system.se_play($data_system.shop_se)
        $game_party.gain_gold(@item.price / 2)
        case @item
        when RPG::Item
          $game_party.lose_item(@item.id, 1)
        when RPG::Weapon
          $game_party.lose_weapon(@item.id, 1)
        when RPG::Armor
          $game_party.lose_armor(@item.id, 1)
        end
        @gold_window.refresh
        @sell_window.refresh
        @shopgold_window.item = @sell_window.item
        @shopgold_window.refresh
      end
    end
  end

  def update_number
    if Input.trigger?(Input::B) # Cancel
      $game_system.se_play($data_system.cancel_se)
      @number_window.active = false
      @number_window.visible = false
      case @command_window.index
      when 0  # Buy
        @buy_window.active = true
        @buy_window.visible = true
      when 1  # Sell
        @sell_window.active = true
        @sell_window.visible = true
      end
      return
    end
    if Input.trigger?(Input::C) # Accept
      $game_system.se_play($data_system.shop_se)
      @number_window.active = false
      @number_window.visible = false
      case @command_window.index
      when 0  # Buy
        $game_party.lose_gold(@number_window.number * @item.price)
        case @item
        when RPG::Item
          $game_party.gain_item(@item.id, @number_window.number)
        when RPG::Weapon
          $game_party.gain_weapon(@item.id, @number_window.number)
        when RPG::Armor
          $game_party.gain_armor(@item.id, @number_window.number)
        end
        @gold_window.refresh
        @buy_window.refresh
        @shopgold_window.refresh
       
        @buy_window.active = true
        @shopgold_window.visible = true
      when 1  # Sell
        $game_party.gain_gold(@number_window.number * (@item.price / 2))
        case @item
        when RPG::Item
          $game_party.lose_item(@item.id, @number_window.number)
        when RPG::Weapon
          $game_party.lose_weapon(@item.id, @number_window.number)
        when RPG::Armor
          $game_party.lose_armor(@item.id, @number_window.number)
        end
        @gold_window.refresh
        @sell_window.refresh
        @shopgold_window.item = @sell_window.item
        @shopgold_window.refresh

        @sell_window.active = true
        @shopgold_window.visible = true
      end
      return
    end
  end

  def shopgold_position # Window position (centered with the cursor)
    if @buy_window.visible == true # Buy
      @shopgold_window.item = @buy_window.item
      cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
      cursor_height = NewShopWecoc::ROW_HEIGHT
      column_max = NewShopWecoc::COLUMN_MAX
      window_width = @shopgold_window.width
      index = @buy_window.index
     
      @shopgold_window.x = index%column_max * 640/column_max +
                          cursor_width/2-(window_width/2)+16
      @shopgold_window.x = [@shopgold_window.x, 5].max
      @shopgold_window.x = [@shopgold_window.x, 640-5-@shopgold_window.width].min
      @shopgold_window.y = index/column_max*cursor_height-
                          @buy_window.top_row*cursor_height+76
    else # Sell
      @shopgold_window.item = @sell_window.item
      cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
      cursor_height = NewShopWecoc::ROW_HEIGHT
      column_max = NewShopWecoc::COLUMN_MAX
      window_width = @shopgold_window.width
      index = @sell_window.index
     
      @shopgold_window.x = index%column_max * 640/column_max +
                          cursor_width/2-(window_width/2)+16
      @shopgold_window.x = [@shopgold_window.x, 5].max
      @shopgold_window.x = [@shopgold_window.x, 640-5-@shopgold_window.width].min
      @shopgold_window.y = index/column_max*cursor_height-
                          @sell_window.top_row*cursor_height+76
    end
  end
end



Instructions

Not much to say, module NewShopWecoc is on the top of the code.


Compatibility

Not compatible with other shop systems but yes with anything else.


Credits and Thanks


  • Wecoc




Author's Notes

If you have any problem with that script or with incompatibilities don't hestitate to ask. If you need it I also can make a demo.

Zexion

This is a really nice script! I like that you included more than one layout because I didn't really like the first one, but then I clicked the second one and was happy :P
Rune-Scape style shop lol