Select Key Item ACE
#1
Select Key Item ACE
by Kyonides

Introduction

This script has only one mission: to display the Select Key Item window with style!

Please read the embedded comments to learn how to use it properly.

Code:
# * Select Key Item ACE * #
#  Scripter : Kyonides Arkanthes
#  2024-03-22

# Display your Key Items on screen with style!
# Don't forget to add some key items to your party's bag before calling
# the Select Item event command or this script might laugh at you! :O
# You might only need to configure 5 CONSTANTS, yes in ALL_CAPS.
# Yet, this script can run just like any plug & play code available out there.

class Window_KeyItem
  # [Red, Green, Blue, Alpha]
  MAIN_COLOR = [0, 0, 0, 160]
  EDGE_COLOR = [0, 0, 0, 0]
  WINDOW_WIDTH = (Graphics.width - 40) / 2
  POS_Y = Graphics.height / 2 - 24
  NO_ITEM_FOUND = "No key items? Really?"
  def initialize(message_window)
    @message_window = message_window
    @cw = WINDOW_WIDTH - 24
    super(WINDOW_WIDTH / 2, 0, WINDOW_WIDTH, 72)
    self.openness = 0
    create_back_bitmap
    create_back_sprite
    self.back_opacity = 0
    self.opacity = 0
    deactivate
    set_handler(:ok,    method(:on_ok))
    set_handler(:cancel, method(:on_cancel))
  end

  def create_back_bitmap
    @back_bitmap = Bitmap.new(@cw, 28)
    rect1 = Rect.new(0, 0, width, 12)
    rect2 = Rect.new(0, 12, width, height - 24)
    rect3 = Rect.new(0, height - 12, width, 12)
    @back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
    @back_bitmap.fill_rect(rect2, back_color1)
    @back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
  end

  def create_back_sprite
    @back_sprite = Sprite.new
    @back_sprite.bitmap = @back_bitmap
    @back_sprite.visible = false
    @back_sprite.x = self.x + 12
    @back_sprite.z = self.z - 1
  end

  def back_color1
    Color.new(*MAIN_COLOR)
  end

  def back_color2
    Color.new(*EDGE_COLOR)
  end

  def start
    self.category = :key_item
    update_placement
    select(0)
    open
    @back_sprite.visible = true
    activate
  end

  def make_item_list
    @data = $game_party.all_items.select {|item| include?(item) }
    @icon_ox = @cw / 2 - item_max * 14
  end

  def update_placement
    self.y = POS_Y
    @back_sprite.y = self.y + 34
  end

  def select(new_index)
    self.index = new_index
    draw_this_item
  end

  def item_max
    @data.size
  end

  def create_contents
    contents.dispose
    self.contents = Bitmap.new(@cw, 48)
  end

  def draw_this_item
    contents.clear_rect(0, 24, @cw, 24)
    item = @data[@index]
    item ? draw_item_found(item) : draw_no_item
  end

  def draw_item_found(item)
    rect = Rect.new(0, 24, @cw - 4, 24)
    draw_item_name(item)
    draw_item_number(rect, item)
  end

  def draw_item(n)
    icon_pos = @data[n].icon_index
    draw_icon(icon_pos, @icon_ox + n * 28, 0, true)
  end

  def draw_item_name(item)
    change_color(normal_color, true)
    draw_text(4, 24, @cw - 32, line_height, item.name)
  end

  def draw_item_number(rect, item)
    draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
  end

  def draw_no_item
    draw_text(4, 24, @cw - 32, line_height, NO_ITEM_FOUND)
  end

  def hide_backdrop
    @back_sprite.visible = false
  end

  def this_rect
    Rect.new(@icon_ox + @index * 28, 0, 24, 24)
  end

  def update_cursor
    if @index < 0
      cursor_rect.empty
      return
    end
    cursor_rect.set(this_rect)
  end

  def process_ok
    if current_item_enabled?
      Sound.play_ok
      Input.update
      call_ok_handler
    else
      Sound.play_buzzer
      call_cancel_handler
    end
    deactivate
  end

  def dispose
    super
    @back_bitmap.dispose
    @back_sprite.dispose
  end
end

class Window_Message
  def input_item
    @item_window.start
    Fiber.yield while @item_window.active
    @item_window.hide_backdrop
  end
end

Screenshots

2 Snapshots

Terms & Conditions

Free for ANY Gamer game.
Due credit is mandatory.
Mention this forum in your game credits.
That's it! Tongue sticking out


Attached Files
.jpg   select_key_item_ace01.jpg (Size: 103.48 KB / Downloads: 3)
.jpg   select_key_item_ace02.jpg (Size: 104.33 KB / Downloads: 3)
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Battle Item Count VX + ACE kyonides 1 316 10-17-2024, 08:01 PM
Last Post: kyonides
   Skill Item Kost ACE kyonides 0 1,077 01-03-2024, 12:07 AM
Last Post: kyonides
   DoubleX RMVXA Item Triggers DoubleX 2 6,696 02-27-2016, 03:02 AM
Last Post: DoubleX
   Victor Engine - Item Command Victor Sant 0 4,565 08-05-2012, 10:36 PM
Last Post: Victor Sant
   Vampyr's SBABS DVV Addon #1: HUD Item Counter & Skill Delay Bar DerVVulfman 1 6,776 06-19-2012, 03:15 AM
Last Post: DerVVulfman



Users browsing this thread: 2 Guest(s)