Created
August 1, 2020 13:43
-
-
Save rutan/ac79d013cac201855befae2e19e04675 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
#=============================================================================== | |
# ■ 16x16アイコン2倍拡大表示さん | |
#------------------------------------------------------------------------------- | |
# 2020/08/01 Ruたん | |
#------------------------------------------------------------------------------- | |
# 16x16のアイコンを2倍拡大(32x32)で表示します。 | |
# このスクリプトは、性質上再定義が多いためなるべく上の方に入れてください。 | |
# | |
# ■ 画像(IconSet)について | |
# RPGツクールVXAceのエディタ側の仕様上、24x24以外の画像を入れると | |
# ツクール上でのアイコンの設定表示がズレてしまいます。 | |
# そのため、画像の規格としては 32x32 の仕様で作成し、 | |
# 各アイコンの中央部分16x16のみを切り抜いて表示しています。 | |
#------------------------------------------------------------------------------- | |
# 【更新履歴】 | |
# 2020/08/01 作成 | |
#------------------------------------------------------------------------------- | |
class Window_Base < Window | |
ICON_DRAW_WIDTH = 32 | |
ICON_ORIGINAL_WIDTH = 24 | |
ICON_SRC_WIDTH = 16 | |
#-------------------------------------------------------------------------- | |
# ● [エイリアス] 制御文字によるアイコン描画の処理 | |
#-------------------------------------------------------------------------- | |
alias original_scale_process_draw_icon process_draw_icon | |
def process_draw_icon(icon_index, pos) | |
original_scale_process_draw_icon(icon_index, pos) | |
pos[:x] += ICON_DRAW_WIDTH - ICON_ORIGINAL_WIDTH | |
end | |
#-------------------------------------------------------------------------- | |
# ● アイコンの描画 | |
# enabled : 有効フラグ。false のとき半透明で描画 | |
#-------------------------------------------------------------------------- | |
alias original_scale_draw_icon draw_icon | |
def draw_icon(icon_index, x, y, enabled = true) | |
bitmap = Cache.system('Iconset') | |
dest_rect = Rect.new(x, y, ICON_DRAW_WIDTH, ICON_DRAW_WIDTH) | |
n = (ICON_ORIGINAL_WIDTH - ICON_SRC_WIDTH) / 2 | |
rect = Rect.new(icon_index % 16 * ICON_ORIGINAL_WIDTH + n, icon_index / 16 * ICON_ORIGINAL_WIDTH + n, ICON_SRC_WIDTH, ICON_SRC_WIDTH) | |
contents.stretch_blt(dest_rect, bitmap, rect, enabled ? 255 : translucent_alpha) | |
end | |
#-------------------------------------------------------------------------- | |
# ● [再定義] ステートおよび強化/弱体のアイコンを描画 | |
#-------------------------------------------------------------------------- | |
def draw_actor_icons(actor, x, y, width = 96) | |
icons = (actor.state_icons + actor.buff_icons)[0, width / ICON_DRAW_WIDTH] | |
icons.each_with_index {|n, i| draw_icon(n, x + ICON_DRAW_WIDTH * i, y) } | |
end | |
#-------------------------------------------------------------------------- | |
# ● [再定義] アイテム名の描画 | |
# enabled : 有効フラグ。false のとき半透明で描画 | |
#-------------------------------------------------------------------------- | |
def draw_item_name(item, x, y, enabled = true, width = 172) | |
return unless item | |
draw_icon(item.icon_index, x, y, enabled) | |
change_color(normal_color, enabled) | |
draw_text(x + ICON_DRAW_WIDTH, y, width, line_height, item.name) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment