设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 137|回复: 0

[转载发布] Select Key Item ACE

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 2026-8-3 11:03:58 | 显示全部楼层 |阅读模式
    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:       
    1. # * Select Key Item ACE * #
    2. #   Scripter : Kyonides Arkanthes
    3. #   2024-03-22
    4. # Display your Key Items on screen with style!
    5. # Don't forget to add some key items to your party's bag before calling
    6. # the Select Item event command or this script might laugh at you! :O
    7. # You might only need to configure 5 CONSTANTS, yes in ALL_CAPS.
    8. # Yet, this script can run just like any plug & play code available out there.
    9. class Window_KeyItem
    10.   # [Red, Green, Blue, Alpha]
    11.   MAIN_COLOR = [0, 0, 0, 160]
    12.   EDGE_COLOR = [0, 0, 0, 0]
    13.   WINDOW_WIDTH = (Graphics.width - 40) / 2
    14.   POS_Y = Graphics.height / 2 - 24
    15.   NO_ITEM_FOUND = "No key items? Really?"
    16.   def initialize(message_window)
    17.     @message_window = message_window
    18.     @cw = WINDOW_WIDTH - 24
    19.     super(WINDOW_WIDTH / 2, 0, WINDOW_WIDTH, 72)
    20.     self.openness = 0
    21.     create_back_bitmap
    22.     create_back_sprite
    23.     self.back_opacity = 0
    24.     self.opacity = 0
    25.     deactivate
    26.     set_handler(:ok,     method(:on_ok))
    27.     set_handler(:cancel, method(:on_cancel))
    28.   end
    29.   def create_back_bitmap
    30.     @back_bitmap = Bitmap.new(@cw, 28)
    31.     rect1 = Rect.new(0, 0, width, 12)
    32.     rect2 = Rect.new(0, 12, width, height - 24)
    33.     rect3 = Rect.new(0, height - 12, width, 12)
    34.     @back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
    35.     @back_bitmap.fill_rect(rect2, back_color1)
    36.     @back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
    37.   end
    38.   def create_back_sprite
    39.     @back_sprite = Sprite.new
    40.     @back_sprite.bitmap = @back_bitmap
    41.     @back_sprite.visible = false
    42.     @back_sprite.x = self.x + 12
    43.     @back_sprite.z = self.z - 1
    44.   end
    45.   def back_color1
    46.     Color.new(*MAIN_COLOR)
    47.   end
    48.   def back_color2
    49.     Color.new(*EDGE_COLOR)
    50.   end
    51.   def start
    52.     self.category = :key_item
    53.     update_placement
    54.     select(0)
    55.     open
    56.     @back_sprite.visible = true
    57.     activate
    58.   end
    59.   def make_item_list
    60.     @data = $game_party.all_items.select {|item| include?(item) }
    61.     @icon_ox = @cw / 2 - item_max * 14
    62.   end
    63.   def update_placement
    64.     self.y = POS_Y
    65.     @back_sprite.y = self.y + 34
    66.   end
    67.   def select(new_index)
    68.     self.index = new_index
    69.     draw_this_item
    70.   end
    71.   def item_max
    72.     @data.size
    73.   end
    74.   def create_contents
    75.     contents.dispose
    76.     self.contents = Bitmap.new(@cw, 48)
    77.   end
    78.   def draw_this_item
    79.     contents.clear_rect(0, 24, @cw, 24)
    80.     item = @data[@index]
    81.     item ? draw_item_found(item) : draw_no_item
    82.   end
    83.   def draw_item_found(item)
    84.     rect = Rect.new(0, 24, @cw - 4, 24)
    85.     draw_item_name(item)
    86.     draw_item_number(rect, item)
    87.   end
    88.   def draw_item(n)
    89.     icon_pos = @data[n].icon_index
    90.     draw_icon(icon_pos, @icon_ox + n * 28, 0, true)
    91.   end
    92.   def draw_item_name(item)
    93.     change_color(normal_color, true)
    94.     draw_text(4, 24, @cw - 32, line_height, item.name)
    95.   end
    96.   def draw_item_number(rect, item)
    97.     draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
    98.   end
    99.   def draw_no_item
    100.     draw_text(4, 24, @cw - 32, line_height, NO_ITEM_FOUND)
    101.   end
    102.   def hide_backdrop
    103.     @back_sprite.visible = false
    104.   end
    105.   def this_rect
    106.     Rect.new(@icon_ox + @index * 28, 0, 24, 24)
    107.   end
    108.   def update_cursor
    109.     if @index < 0
    110.       cursor_rect.empty
    111.       return
    112.     end
    113.     cursor_rect.set(this_rect)
    114.   end
    115.   def process_ok
    116.     if current_item_enabled?
    117.       Sound.play_ok
    118.       Input.update
    119.       call_ok_handler
    120.     else
    121.       Sound.play_buzzer
    122.       call_cancel_handler
    123.     end
    124.     deactivate
    125.   end
    126.   def dispose
    127.     super
    128.     @back_bitmap.dispose
    129.     @back_sprite.dispose
    130.   end
    131. end
    132. class Window_Message
    133.   def input_item
    134.     @item_window.start
    135.     Fiber.yield while @item_window.active
    136.     @item_window.hide_backdrop
    137.   end
    138. 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
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-17 06:19 , Processed in 0.138643 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表