- 累计送礼:
- 0 个
- 累计收礼:
- 1 个
TA的每日心情 | 开心 2026-7-12 04:10 |
|---|
签到天数: 209 天 连续签到: 2 天 [LV.7]常住居民III

管理员
  
- VIP
- 7
- 卡币
- 58883
- OK点
- 16
- 推广点
- 0
- 同能卷
- 50
- 积分
- 68848


|
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.
Ruby: - # * 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
Spoiler: 2 Snapshots
Terms & Conditions
Free for ANY game.
Due credit is mandatory.
Mention this forum in your game credits.
That's it!
本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址: https://forums.rpgmakerweb.com/threads/select-key-item-ace.167060/ |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
|