Skip to content

Instantly share code, notes, and snippets.

@aldoKelvianto
Last active December 20, 2015 11:38
Show Gist options
  • Save aldoKelvianto/6124422 to your computer and use it in GitHub Desktop.
Save aldoKelvianto/6124422 to your computer and use it in GitHub Desktop.
class HeroIndex
$indexHero
def initialize(index)
$indexHero = index
end
end
class Window_Base < Window
#--------------------------------------------------------------------------
# * Draw Face Graphic
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
#--------------------------------------------------------------------------
def draw_actor_face_graphic(actor, x, y)
bitmap = RPG::Cache.picture(actor.name)
src_rect = Rect.new(0, 0, 128, 128)
self.contents.blt(x, y, bitmap, src_rect)
end
end
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 64
y = i * 116
actor = $game_party.actors[i]
draw_actor_face_graphic(actor, x - 64, y)
#draw_actor_graphic(actor, x - 40, y + 80)
draw_actor_name(actor, x + 60, y)
draw_actor_class(actor, x + 144, y)
draw_actor_level(actor, x + 60, y + 32)
draw_actor_state(actor, x + 250, y)
draw_actor_exp(actor, x + 60, y + 64)
draw_actor_hp(actor, x + 236, y + 32)
draw_actor_sp(actor, x + 236, y + 64)
end
end
end
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# * Draw Face
#--------------------------------------------------------------------------
def draw_actor_face_graphic(actor, x, y)
bitmap = RPG::Cache.picture(actor.name)
src_rect = Rect.new(0, 0, 128, 128)
self.contents.blt(x, y, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
#----------------------------
# * Start Here
#----------------------------
actor = $game_party.actors[$indexHero]
if actor == nil then
actor = $game_party.actors[0]
end
# Draw Face
draw_actor_face_graphic(actor, 0, 0)
self.contents.font.color = system_color
self.contents.font.size = 22
posX = 118
posY = -45
# Draw Text (Hero's name)
self.contents.draw_text(x + posX, posY, 120, 120, actor.name)
#----------------------------
# * End Here
#----------------------------
# Changing font color to normal
self.contents.font.color = normal_color
x = y = 0
@cursor_width = 0
# Indent if choice
if $game_temp.choice_start == 0
x = 8
end
# If waiting for a message to be displayed
if $game_temp.message_text != nil
text = $game_temp.message_text
# Control text processing
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# Change "\\\\" to "\000" for convenience
text.gsub!(/\\\\/) { "\000" }
# Change "\\C" to "\001" and "\\G" to "\002"
text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
text.gsub!(/\\[Gg]/) { "\002" }
# Get 1 text character in c (loop until unable to get text)
while ((c = text.slice!(/./m)) != nil)
# If \\
if c == "\000"
# Return to original text
c = "\\"
end
# If \C[n]
if c == "\001"
# Change text color
text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
if color >= 0 and color <= 7
self.contents.font.color = text_color(color)
end
# go to next text
next
end
# If \G
if c == "\002"
# Make gold window
if @gold_window == nil
@gold_window = Window_Gold.new
@gold_window.x = 560 - @gold_window.width
if $game_temp.in_battle
@gold_window.y = 192
else
@gold_window.y = self.y >= 128 ? 32 : 384
end
@gold_window.opacity = self.opacity
@gold_window.back_opacity = self.back_opacity
end
# go to next text
next
end
# If new line text
if c == "\n"
# Update cursor width if choice
if y >= $game_temp.choice_start
@cursor_width = [@cursor_width, x].max
end
# Add 1 to y
y += 1
x = 0
# Indent if choice
if y >= $game_temp.choice_start
x = 8
end
# go to next text
next
end
#----------------------------
# * Draw Text -> Edit
#----------------------------
textX = 128
textY = 32
self.contents.draw_text(x + textX, (32 * y) + textY, 40, 32, c)
# self.contents.draw_text(4 + x, 32 * y, 40, 32, c)
#----------------------------
# * End Here
#----------------------------
# Add x to drawn text width
x += self.contents.text_size(c).width
end
end
# If choice
if $game_temp.choice_max > 0
@item_max = $game_temp.choice_max
self.active = true
self.index = 0
end
# If number input
if $game_temp.num_input_variable_id > 0
digits_max = $game_temp.num_input_digits_max
number = $game_variables[$game_temp.num_input_variable_id]
@input_number_window = Window_InputNumber.new(digits_max)
@input_number_window.number = number
@input_number_window.x = self.x + 8
@input_number_window.y = self.y + $game_temp.num_input_start * 32
end
end
end
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
if @index==0 then
self.cursor_rect.set(-6, -6, self.width - 32, 142)
else
self.cursor_rect.set(-6, @index * 132, self.width - 32, 142)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment