赞 | 2 |
VIP | 109 |
好人卡 | 208 |
积分 | 4 |
经验 | 22037 |
最后登录 | 2024-11-11 |
在线时间 | 1198 小时 |
虚構歪曲
- 梦石
- 0
- 星屑
- 364
- 在线时间
- 1198 小时
- 注册时间
- 2010-12-18
- 帖子
- 3928
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 忧雪の伤 于 2012-8-13 19:30 编辑
- #==============================================================================
- # Name [ CharacterNameDisplay ( 人物名称显示 ) ]
- # Apply To [ RPG Maker XP & RPG Maker VX & RPG Maker VX Ace ]
- #------------------------------------------------------------------------------
- # Author [ 忧雪の伤 ]
- # Last Update [ 2012.8.13 ]
- #------------------------------------------------------------------------------
- # Link [ 66RPG Ideal Script Association ]
- # => http://rpg.blue/group-215-1.html
- # Link [ OWL Authors' Protection Organization ]
- # => http://oapo.qzworld.net/index.html
- #==============================================================================
- #==============================================================================
- # * Test Section
- #==============================================================================
- unless Module.constants.include? RUBY_VERSION == '1.9.2' ? :ISA : 'ISA'
- message = "You need to add that script over this."
- method(RUBY_VERSION == '1.9.2' ? :msgbox : :p)[message]
- `start http://rpg.blue/thread-181551-1-1.html`
- end
- #==============================================================================
- # * Registered Section
- #==============================================================================
- $imported['CharacterNameDisplay'] = '2012.8.13'
- #==============================================================================
- # * Running Section
- #==============================================================================
- module ISA::CharacterNameDisplay
- #--------------------------------------------------------------------------
- # * Setup Section
- #--------------------------------------------------------------------------
- # LocationPlus : 置顶的布尔值 ( true or false )
- # Switch : 返回布尔值的过程对象 ( Method or Proc )
- #--------------------------------------------------------------------------
- LocationPlus = true
- Switch = proc { $game_switches[0] }
- class Sprite < ::Sprite
- #------------------------------------------------------------------------
- # * Setup Section
- #------------------------------------------------------------------------
- # DefaultSize : 默认字体大小 ( Fixnum )
- # DefaultName : 默认字体名称 ( Array or String )
- # DefaultColor : 默认字体颜色 ( Color )
- # DefaultBold : 默认字体粗体 ( true or false )
- # DefaultItalic : 默认字体斜体 ( true or false )
- # DefaultShadow : 默认字体阴影 ( true or false ) [ VX or VA ]
- # DefaultOutline : 默认字体描边 ( true or false ) [ VA ]
- # DefaultOutColor : 默认字体描边颜色 ( Color ) [ VA ]
- #------------------------------------------------------------------------
- DefaultSize = Font.default_size
- DefaultName = Font.default_name
- DefaultColor = Font.default_color
- DefaultBold = Font.default_bold
- DefaultItalic = Font.default_italic
- begin
- DefaultShadow = Font.default_shadow
- DefaultOutline = Font.default_outline
- DefaultOutColor = Font.default_out_color
- rescue
- nil
- end
- attr_reader :string
- def initialize viewport, character
- super viewport
- @block = proc { '' }
- begin
- symbol = :isa_name_for_character_name_display
- case character
- when Game_Player
- case ISA::Edition
- when :xp
- @block = $data_actors[$game_party.actors[0].id].method symbol
- when :vx
- @block = $game_party.members[0].actor.method symbol
- when :va
- @block = character.actor.actor.method symbol
- end
- when (Game_Follower rescue nil)
- @block = character.actor.actor.method symbol
- when Game_Event
- @block = character.instance_variable_get(:@event).method symbol
- end
- rescue
- nil
- end
- @string = @block.call
- @character = character
- self.x = character.screen_x
- self.y = character.screen_y
- refresh
- nil
- end
- def update
- self.x = @character.screen_x
- self.y = @character.screen_y
- self.ox = src_rect.width / 2
- return if @string.equal? @block.call
- @string = @block.call
- refresh
- nil
- end
- def dispose
- super
- bitmap.dispose unless bitmap.nil?
- nil
- end
- def refresh
- bitmap.dispose unless bitmap.nil?
- return if match_each_line.empty?
- src_bitmap = []
- match_each_line.each {|item|
- bitmap = Bitmap.new 16, 16
- bitmap.font = item[1]
- text_size = bitmap.text_size item[0]
- width = text_size.width.zero? ? 16 : text_size.width
- height = text_size.height.zero? ? 16 : text_size.height
- src_bitmap << [Bitmap.new(width, height), item[0], 0]
- plus = (src_bitmap[-2][0].height + src_bitmap[-2][2] rescue 0)
- src_bitmap[-1][2] = src_bitmap[-1][2] + plus
- src_bitmap[-1][0].font = item[1]
- }
- width = (src_bitmap.map {|item| item[0].width }).max
- height = src_bitmap.inject(0) {|result, item| result + item[0].height }
- self.bitmap = Bitmap.new width, height
- src_bitmap.each {|item|
- bitmap.font = item[0].font
- bitmap.draw_text 0, item[2], width, item[0].height, item[1], 1
- }
- nil
- end
- def match_each_line
- @string.dup.split(/\\n/).map {|item|
- font = Font.new
- font.size = DefaultSize
- font.name = DefaultName
- font.color = DefaultColor
- item.slice!(/<size\(([0-9]*)\)>/)
- font.size = $1.to_i unless $1.nil?
- item.slice!(/<name\((.*)\)>/)
- font.name = $1 unless $1.nil?
- item.slice!(/<bold\((true|false)\)>/)
- font.bold = $1 ? eval($1) : DefaultBold
- item.slice!(/<italic\((true|false)\)>/)
- font.italic = $1 ? eval($1) : DefaultItalic
- item.slice!(/<color\((.*)\)>/)
- font.color.set *$1.split(/,/).map {|string| string.to_f } unless $1.nil?
- begin
- item.slice!(/<shadow\((true|false)\)>/)
- font.shadow = $1 ? eval($1) : DefaultShadow
- item.slice!(/<outline\((true|false)\)>/)
- font.outline = $1 ? eval($1) : DefaultOutline
- item.slice!(/<out_color\((.*)\)>/)
- raise StandardError if $1.nil?
- font.out_color.set *$1.split(/,/).map {|item| item.to_f }
- rescue
- nil
- end
- [item, font]
- }
- end
- end
- end
- [RPG::Actor, RPG::Event].each {|item|
- item.class_eval {
- alias isa_name_for_character_name_display name unless $@
- def name *args
- result = isa_name_for_character_name_display(*args).dup
- array = [/<bold\((true|false)\)>/, /<italic\((true|false)\)>/,
- /<shadow\((true|false)\)>/, /<outline\((true|false)\)>/, /<invisible>/,
- /<size\([0-9]*\)>/, /<name\(.*\)>/, /<color\(.*\)>/, /<out_color\(.*\)>/]
- array.each {|item| result.slice! item }
- result.gsub(/\\n/, '')
- end
- }
- }
- class Game_Character
- alias isa_initialize_fisrt_for_character_name_display initialize
- attr_accessor :isa_boolean_for_character_name_display
- def initialize *args
- @isa_boolean_for_character_name_display = true
- isa_initialize_fisrt_for_character_name_display *args
- end
- end
- class Game_Event
- alias isa_initialize_second_for_character_name_display initialize
- def initialize *args
- isa_initialize_second_for_character_name_display *args
- @isa_boolean_for_character_name_display =
- [email protected]_name_for_character_name_display[0, 2]['EV']
- nil
- end
- end
-
- class Sprite_Character
- alias isa_initialize_for_character_name_display initialize
- alias isa_dispose_for_character_name_display dispose
- alias isa_update_for_character_name_display update
- def initialize *args
- sprite = ISA::CharacterNameDisplay::Sprite.new args[0], args[1]
- @isa_name_for_character_name_display = sprite
- isa_initialize_for_character_name_display *args
- end
- def dispose *args
- @isa_name_for_character_name_display.dispose
- isa_dispose_for_character_name_display *args
- end
- def update *args
- sprite = @isa_name_for_character_name_display
- sprite.visible = visible && !sprite.string['<invisible>'] &&
- character.isa_boolean_for_character_name_display &&
- !ISA::CharacterNameDisplay::Switch[]
- sprite.z = self.z + 1
- sprite.update
- return unless ISA::CharacterNameDisplay::LocationPlus
- sprite.oy = src_rect.height + sprite.src_rect.height
- isa_update_for_character_name_display *args
- end
- end
复制代码 |
|