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

[转载发布] Hammy - MKXP-Z Input Device Tracker HUD

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

    连续签到: 2 天

    [LV.7]常住居民III

    9015

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 昨天 15:29 | 显示全部楼层 |阅读模式
    Hammy - MKXP-Z Input Device Tracker HUD v1.01
    On-screen input device indicator with battery level support and per-scene suppression for mkxp-z




    Introduction

    This script provides an on-screen input device indicator HUD for RPG Maker VX Ace running on mkxp-z. It displays a small icon in the top-right corner of the screen reflecting the active input device tracked by the Input Device Tracker.

    AI Disclaimer: Generative AI was used to refine the documentation and presentation of this script, as I am not a native English speaker. Additionally, AI was used for naming conventions in some places and for general beautification of the script.

    mkxp-z Disclaimer: This script is made exclusively for RPG Maker VX Ace running on mkxp-z (Ruby 3.1). It will not run on standard RPG Maker VX Ace without mkxp-z. See the mkxp-z section below for more information.



    Features

    Core HUD Features

    • Top-right corner device icon reflecting the active input device at all times
    • Three display modes controlled by SHOW_BATTERY_ICON and BATTERY_CHANGES_DEVICE_ICON
    • Optional battery icon drawn beside the device icon while a gamepad is active
    • Optional battery-driven device icon override for per-charge-state gamepad icons
    • Optional wide keyboard indicator via a flush-adjacent secondary icon forming a 48×24 px block
    • Per-scene HUD suppression via a configurable scene list (blacklist or whitelist) - no viewport or sprite overhead in suppressed scenes
    • Switch-based HUD hide via a configurable game switch ID - sprites persist and reappear instantly when the switch turns off



    mkxp-z

    mkxp-z is an open-source, cross-platform player for RPG Maker XP, VX, and VX Ace games. It is a heavily modified fork of mkxp originally built to run games based on Pokémon Essentials, which depends heavily on Windows APIs. It is best described as MKXP but supercharged - capable of running all but the most demanding RGSS projects with a bit of porting work.

    mkxp-z supports Windows, Linux (x86, ARM, and POWER), and both Intel and Apple Silicon versions of macOS. Because it ships with Ruby 3.1 rather than the original Ruby 1.9.2 bundled with RPG Maker VX Ace, scripts written for mkxp-z can take advantage of modern Ruby syntax and standard library features.

    This script requires mkxp-z and will not run on default RPG Maker VX Ace.



    Script Calls

    The following script calls are available for use in events and other scripts.

    HUD Visibility Control

    $game_switches[Hammy::InputDeviceTrackerHUD::HIDE_SWITCH_ID] = true/false
    Directly set the HUD hide switch state using the game switches array.
    - true: Hides the HUD (all sprites become invisible)
    - false: Shows the HUD normally

    Examples
                    Ruby:       
    1. # Hide the HUD
    2. $game_switches[Hammy::InputDeviceTrackerHUD::HIDE_SWITCH_ID] = true
    3. # Show the HUD
    4. $game_switches[Hammy::InputDeviceTrackerHUD::HIDE_SWITCH_ID] = false
    复制代码




    Usage

    This section explains the three display modes and how to configure icons, margins, and scene exclusions.

    Display Modes
    The HUD display mode is controlled by two booleans: SHOW_BATTERY_ICON and BATTERY_CHANGES_DEVICE_ICON. Only one mode is active at a time. When both are true, SHOW_BATTERY_ICON takes precedence.


    • Default mode (both false): A single device icon is shown at all times. The icon reflects the current device state using ICONS[:none], ICONS[:keyboard], or ICONS[:gamepad].
    • Battery icon mode (SHOW_BATTERY_ICON = true): A second battery icon is drawn to the left of the screen edge beside the device icon while a gamepad is active. The battery icon index is resolved from BATTERY_ICONS by the current power_level symbol. When no gamepad is connected the battery icon is hidden and the device icon shifts back to its single-icon position automatically.
    • Battery device icon mode (BATTERY_CHANGES_DEVICE_ICON = true): A single icon is shown at all times. While a gamepad is active the icon index is resolved from BATTERY_DEVICE_ICONS by the current power_level symbol instead of the fixed ICONS[:gamepad] value. Non-gamepad states use ICONS as usual.

    Wide Keyboard Icon
    Setting ICONS[:keyboard_ext] to an integer icon index enables a wide keyboard indicator that occupies a 48×24 px region formed by two standard icons placed flush against each other with no margin between them. The extended icon is only shown while the active device is :keyboard. All other device states use the standard 24×24 single-icon layout.


    • Set ICONS[:keyboard_ext] to nil (default) to keep the single 24×24 icon.

    Switch-Based HUD Hide
    A single game switch can be used to hide the HUD at any time without removing it from the scene. The viewport and sprites persist; only their visibility is toggled, so the HUD reappears instantly when the switch is turned off again.


    • Set HIDE_SWITCH_ID to any valid switch ID in your project.
    • When this switch is ON, all HUD sprites are hidden.
    • When this switch is OFF, the HUD displays normally.
    • Usage via event command:
    • Control Switches: Turn ON switch HIDE_SWITCH_ID  → hides the HUD
    • Control Switches: Turn OFF switch HIDE_SWITCH_ID → shows the HUD
    • Usage via script call:
                      Ruby:       
      1. $game_switches[Hammy::InputDeviceTrackerHUD::HIDE_SWITCH_ID] = true
      2. $game_switches[Hammy::InputDeviceTrackerHUD::HIDE_SWITCH_ID] = false
      复制代码

    • HUD suppression via SCENE_LIST takes priority over this switch. In suppressed scenes the HUD is never created, so the switch has no effect.

    Scene Exclusion / Inclusion
    SCENE_LIST holds scene class constants that control per-scene HUD visibility. Whether it acts as a blacklist or a whitelist is determined by SCENE_LIST_IS_WHITELIST. The HUD viewport and sprites are never created for suppressed scenes, so no update overhead is incurred.


    • Blacklist mode (SCENE_LIST_IS_WHITELIST = false, default):
    • The HUD is shown in every scene EXCEPT those listed in SCENE_LIST. An empty array means the HUD appears in every scene.
    • Whitelist mode (SCENE_LIST_IS_WHITELIST = true):
    • The HUD is shown ONLY in scenes listed in SCENE_LIST. Every other scene suppresses the HUD entirely. An empty array means the HUD never appears in any scene.
    • SCENE_LIST uses class constants directly, not strings.



    Configuration

    Edit the constants in the Hammy::InputDeviceTrackerHUD module to configure the HUD layout, display modes, scenes exclusions, hide switch, and icon graphics.

    Layout Settings
    Configure the spacing and render depth of the HUD icons.

    MARGIN
    Gap in pixels between icons and from the screen edges.

    Applied between the device icon and the battery icon when both are visible, and between the rightmost icon and top-right screen edge.

    - Valid values: Any non-negative integer
    - Default:4

    Example
                    Ruby:       
    1. MARGIN = 4
    复制代码


    Z_LEVEL
    Z-depth used for the HUD viewport and all HUD sprites.

    A very high value ensures the HUD renders above all scene content.

    - Valid values: Any integer
    - Default:9999

    Example
                    Ruby:       
    1. Z_LEVEL = 9999
    复制代码


    Display Mode Settings
    Configure which display mode the HUD uses. See the General Setup & Usage Guide for a full explanation of each mode.

    SHOW_BATTERY_ICON
    Shows a battery icon beside the device icon.

    When true, a second battery icon is drawn beside the device icon while a gamepad is active. Takes precedence over BATTERY_CHANGES_DEVICE_ICON when both are true.

    - Valid values: true / false
    - Default:false

    Example
                    Ruby:       
    1. SHOW_BATTERY_ICON = false
    复制代码


    BATTERY_CHANGES_DEVICE_ICON
    Replaces the device icon with a battery-level-specific icon while a gamepad is active.

    Only active when SHOW_BATTERY_ICON is false.

    - Valid values: true / false
    - Default:true

    Example
                    Ruby:       
    1. BATTERY_CHANGES_DEVICE_ICON = true
    复制代码


    Scene Exclusion Settings
    Configure which scenes suppress the HUD entirely. The HUD viewport and sprites are never created for suppressed scenes.

    SCENE_LIST_IS_WHITELIST
    Controls how SCENE_LIST is interpreted.

    When false (blacklist), the HUD is shown in every scene except those listed in SCENE_LIST. When true (whitelist), the HUD is shown only in scenes listed in SCENE_LIST.

    - Valid values: true / false
    - Default:false

    Example
                    Ruby:       
    1. SCENE_LIST_IS_WHITELIST = false
    复制代码


    SCENE_LIST
    List of scene classes used as a blacklist or whitelist depending on SCENE_LIST_IS_WHITELIST (see above).
    - Valid values: Array of scene class constants
    - Default:[Scene_Title, Scene_Menu]

    Example
                    Ruby:       
    1. SCENE_LIST = [Scene_Title, Scene_Menu].freeze
    复制代码


    Switch Settings
    Configure the game switch used to hide the HUD at runtime.

    HIDE_SWITCH_ID
    Controls HUD visibility via a game switch.

    When this switch is ON, all HUD sprites are hidden. When OFF, the HUD displays normally. The viewport and sprites are kept alive while hidden so the HUD reappears instantly when the switch is turned off.

    - Valid values: Any valid switch ID (1 to max switches in project)
    - Default:12

    Example
                    Ruby:       
    1. HIDE_SWITCH_ID = 12
    复制代码


    Icon Settings
    Configure the icon indices used by the HUD. All indices refer to the Graphics/System/Iconset sheet using the standard 24x24 px icon grid with 16 icons per row - the same layout as Window_Base#draw_icon.

    ICONS
    Primary device icon indices keyed by device state symbol.

    none: Icon shown when no device has been detected yet keyboard: Icon shown while the active device is :keyboard keyboard_ext: Optional second icon rendered flush-right of the keyboard icon to form a 48x24 wide indicator. Set to nil to keep the standard 24x24 single icon. gamepad: Icon shown while the active device is :gamepad

    - Valid values: Hash of { symbol => integer or nil }
    - Default:{ none: 0, keyboard: 1, keyboard_ext: nil, gamepad: 2 }

    Example
                    Ruby:       
    1. ICONS = {
    2.   none:         0,
    3.   keyboard:     1,
    4.   keyboard_ext: nil,
    5.   gamepad:      2,
    6. }.freeze
    复制代码


    BATTERY_ICONS
    Battery state icon indices used in battery icon mode.

    Keys match the symbols returned by Input::Controller.power_level. Only active when SHOW_BATTERY_ICON is true.

    - Valid values: Hash of { symbol => integer }
    - Default:{ WIRED: 3, MAX: 4, HIGH: 5, MEDIUM: 6, LOW: 7, EMPTY: 8, UNKNOWN: 9 }

    Example
                    Ruby:       
    1. BATTERY_ICONS = {
    2.   WIRED:   3,
    3.   MAX:     4,
    4.   HIGH:    5,
    5.   MEDIUM:  6,
    6.   LOW:     7,
    7.   EMPTY:   8,
    8.   UNKNOWN: 9,
    9. }.freeze
    复制代码


    BATTERY_DEVICE_ICONS
    Device icon overrides per battery state.

    Applied only while the active device is :gamepad. Only active when BATTERY_CHANGES_DEVICE_ICON is true.

    - Valid values: Hash of { symbol => integer }
    - Default:{ WIRED: 10, MAX: 11, HIGH: 12, MEDIUM: 13, LOW: 14, EMPTY: 15, UNKNOWN: 16 }

    Example
                    Ruby:       
    1. BATTERY_DEVICE_ICONS = {
    2.   WIRED:   10,
    3.   MAX:     11,
    4.   HIGH:    12,
    5.   MEDIUM:  13,
    6.   LOW:     14,
    7.   EMPTY:   15,
    8.   UNKNOWN: 16,
    9. }.freeze
    复制代码




    Installation




    Compatibility

    This script is made strictly for RPG Maker VX Ace running on mkxp-z (Ruby 3.1). It will not run on default RPG Maker VX Ace without mkxp-z.



    License

    MIT License - Free for commercial and non-commercial use.



    Credits

    No credits are required.



    Why VX Ace?

    You might wonder why I'm still making scripts for VX Ace instead of MV/MZ. The answer is simple: Ruby is pure beauty, while JavaScript is a terrible language. Ruby's elegant syntax, intuitive design, and expressive power make scripting a joy. JavaScript, on the other hand, is a chaotic mess of inconsistencies and quirks that I simply despise.

    I work with RPG Maker VX Ace for my own game project, and I share the scripts I create with the community. If you're still using VX Ace, you're in good company!



    Download

    Script:Download from GitHub
    Demo:Download from GitHub





    本贴来自国际rpgmaker官方论坛作者:buddysievers处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/hammy-mkxp-z-input-device-tracker-hud.183628/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-4 17:32 , Processed in 0.091269 second(s), 54 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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