- TopherMembre
- Nombre de messages : 12
Age : 35
Distinction : aucune
Date d'inscription : 11/03/2008
[Résolu] Modifier la position d'un HUD
Mer 20 Juil 2011 - 11:44
Bonjour à tous.
J'utilise le script d'affichage HUD de SojaBird. Il montre les HP/MP de tous les héros, devient transparent quand le personnage passe en-dessous... Il est sobre, je l'aime vraiment bien.
Malheureusement je ne vois pas où est la portion de code qui positionne le HUD, qui se trouve par défaut en bas à droite. J'aimerais qu'elle soit en haut à droite.
Si quelqu'un sait comment le modifier j'en serais ravi.
Voici le script :
Une capture si cela peut enjoliver le sujet. ^^
J'utilise le script d'affichage HUD de SojaBird. Il montre les HP/MP de tous les héros, devient transparent quand le personnage passe en-dessous... Il est sobre, je l'aime vraiment bien.
Malheureusement je ne vois pas où est la portion de code qui positionne le HUD, qui se trouve par défaut en bas à droite. J'aimerais qu'elle soit en haut à droite.
Si quelqu'un sait comment le modifier j'en serais ravi.
Voici le script :
- Code:
#==============================================================================
# ** Window_Hud
# Par SojaBird
#------------------------------------------------------------------------------
# HUD pour tous les héros et personnalisable. Réalisé par SojaBird Copyright 2009.
#==============================================================================
# To toggle the hud's display, just do a callscript "hud"
# Pour définir l'affichage du HUD, faire un appel de script "hud(true)" ou "hud(false)"
module ALL_NAME_HP_MP
HUD_SWITCH = 1 # Turn this ON to show HUD
ITEM_ID = 1 # Id of item to show
ACTOR_ID = 0 # Id of actor to show hp/mp (actor1=0, actor2=1...actorN=N-1)
HIDE = true # Cacher si le joueur est sous le HUD (true/false)
OPACITY = 100 # Opacité lorsque le HUD est caché (défaut 100)
WIDTH = 150 # Longueur du HUD [>32-544] 150 par défaut
NAME_WIDTH = 50 # Largeur accordée aux noms
BG_DISPLAY = false # Affichage ou non d'une fenêtre [true/false] True par défaut
HUD_START_DISPLAY = false # Affichage ou non au départ du jeu [true/false] True par défaut
end
################################################################################
def hud(arg = nil)
$game_system.hud_display = !$game_system.hud_display if arg == nil
$game_system.hud_display = arg if arg != nil
end
################################################################################
class All_Name_Hp_Mp < Window_Base
include ALL_NAME_HP_MP
def initialize
@m = $game_party.members
@as = @m.size
@w = WIDTH
@h = @as * 24 + 32
@x = 544 - @w
@y = 416 - @h
super(@x, @y, @w, @h)
@bw = self.contents.width - NAME_WIDTH
@bh = 6
self.visible = $game_system.hud_display
self.opacity = OPACITY
self.opacity = 0 if !BG_DISPLAY
hide_status
refresh
end
def refresh
@y = 0
@a_list = []
contents.clear
@m.each do |i|
@name = i.name
@hp = i.hp
@mp = i.mp
@lvl = i.level
@act = [@name, @hp, @mp, @lvl]
@a_list.push(@act)
draw_actor_info(i, "name", 0, @y, NAME_WIDTH)
draw_actor_info(i, "hp", NAME_WIDTH, @y + (WLH / 2) - @bh, @bw, @bh)
@y += 12
draw_actor_info(i, "mp", NAME_WIDTH, @y, @bw, @bh)
@y += 12
end
end
def draw_actor_info(actor, info, x, y, width, height = WLH)
case info
when "name"
self.contents.font.color = hp_color(actor)
self.contents.draw_text(x, y, width, height, actor.name)
when "hp"
draw_actor_gauge(actor, info, x, y, width, height)
when "mp"
draw_actor_gauge(actor, info, x, y, width, height)
end
end
def draw_actor_gauge(actor, info, x, y, width, height)
case info
when "hp"
gw = width * actor.hp / [actor.maxhp, 1].max
gc1 = hp_gauge_color1
gc2 = hp_gauge_color2
when "mp"
gw = width * actor.mp / [actor.maxmp, 1].max
gc1 = mp_gauge_color1
gc2 = mp_gauge_color2
end
self.contents.fill_rect(x, y, width, height, gauge_back_color)
self.contents.gradient_fill_rect(x, y, gw, height, gc1, gc2)
end
def draw_actor_mp(actor, x, y, width = 120)
draw_actor_mp_gauge(actor, x, y, width)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 30, WLH, Vocab::mp_a)
self.contents.font.color = mp_color(actor)
last_font_size = self.contents.font.size
xr = x + width
if width < 120
self.contents.draw_text(xr - 44, y, 44, WLH, actor.mp, 2)
else
self.contents.draw_text(xr - 99, y, 44, WLH, actor.mp, 2)
self.contents.font.color = normal_color
self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2)
self.contents.draw_text(xr - 44, y, 44, WLH, actor.maxmp, 2)
end
end
def draw_actor_mp_gauge(actor, x, y, width = 120)
gw = width * actor.mp / [actor.maxmp, 1].max
gc1 = mp_gauge_color1
gc2 = mp_gauge_color2
self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
end
def hide_status
if HIDE == true
if $game_player.screen_x + 16 > self.x and
$game_player.screen_y + 4 > self.y and
$game_player.screen_x - 16 < self.x + self.width and
$game_player.screen_y - 28 < self.y + self.height
self.opacity = OPACITY if BG_DISPLAY
self.contents_opacity = OPACITY
else
self.opacity = 255 if BG_DISPLAY
self.contents_opacity = 255
end
end
end
def update
self.visible = $game_system.hud_display
return if !self.visible
hide_status
@m.each do |i|
if @a_list[i.index][0] != i.name or
@a_list[i.index][1] != i.hp or
@a_list[i.index][2] != i.mp or
@a_list[i.index][3] != i.level
refresh
end
end
end
end
#------------------------------------------------------------
# * Scene_Map: Attach HUD to map
#------------------------------------------------------------
class Scene_Map < Scene_Base
alias start_hud start
alias terminate_hud terminate
alias update_hud update
def start
start_hud
@all_name_hp_mp = All_Name_Hp_Mp.new
end
def terminate
@all_name_hp_mp.dispose
terminate_hud
end
def update
update_hud
@all_name_hp_mp.update
end
end
#------------------------------------------------------------
# * Game_System: Check for display
#------------------------------------------------------------
class Game_System
alias hud_initialize initialize
attr_accessor :hud_display
def initialize
hud_initialize
@hud_display = ALL_NAME_HP_MP::HUD_START_DISPLAY
end
end
=begin
Affichage HUD le plus simple, mais enlève l'effet des fonds de combats
#=============================================================================
# Window Hud (pris du Vlad ABS par Vlad)
#=============================================================================
class Window_Hud < Window_Base
def initialize
super(0,0,128,96)
self.opacity = 0
# self.visible = false
refresh
end
def refresh
self.contents.clear
actor = $game_actors[1]
draw_actor_hp(actor, 0, 0, 96)
draw_actor_mp(actor, 0, 24, 96)
end
def update
# self.visible = true if $game_switches[1] == true # 1=interruptor que activa y desactiva el HUD
refresh
end
end
class Scene_Map
alias hud_main main
alias hud_update update
alias hud_terminate terminate
def main
@hud = Window_Hud.new
hud_main
end
def update
@hud.update
hud_update
end
def terminate
@hud.dispose
end
end
=end
Une capture si cela peut enjoliver le sujet. ^^
- Coco'Staffeux retraité
- Nombre de messages : 6578
Age : 30
Localisation : Nord/Douai
Distinction : EL DICTATOR COCO'
Coco-Dieu en puissance
Grand gourou suppléant de la secte des MAGIKARP
Leader charismatique des 2beStaffieux
N°1 du forum
Président, vice-présidents et membres honoraires de la cour suprême du forum
Président de l'association des grosses distinctions CMB
Date d'inscription : 02/07/2008
Re: [Résolu] Modifier la position d'un HUD
Mer 20 Juil 2011 - 12:50
Il me semble qu'il y a un rapport avec ça dans l'initialize :
J'ai plus trop de souvenirs du RGSS, mais essayes avec ça à la place :
Je peux pas essayer, j'ai pas retéléchargé VX sur mon nouveau PC, donc dis moi ce que ça fait (Avec un screen ça serait cool)
- Code:
@as = @m.size
@w = WIDTH
@h = @as * 24 + 32
@x = 544 - @w
@y = 416 - @h
super(@x, @y, @w, @h)
J'ai plus trop de souvenirs du RGSS, mais essayes avec ça à la place :
- Code:
@as = @m.size
@w = WIDTH
@h = @as * 24 + 32
@x = 544 - @w
@y = 416 - @h
super(@x, 0, @w, @h)
Je peux pas essayer, j'ai pas retéléchargé VX sur mon nouveau PC, donc dis moi ce que ça fait (Avec un screen ça serait cool)
- TopherMembre
- Nombre de messages : 12
Age : 35
Distinction : aucune
Date d'inscription : 11/03/2008
Re: [Résolu] Modifier la position d'un HUD
Mer 20 Juil 2011 - 13:36
Ah raté, en haut à gauche cette fois.
Non je plaisante en fait merci beaucoup pour cet éclaircissement, grâce à ça j'ai pu comprendre et l'adapter moi-même. Bonne journée à toi.
Si vous voulez l'affichage en haut à gauche :
- Code:
super(0, 0, @w, @h)
- Code:
super(0, @y, @w, @h)
- Coco'Staffeux retraité
- Nombre de messages : 6578
Age : 30
Localisation : Nord/Douai
Distinction : EL DICTATOR COCO'
Coco-Dieu en puissance
Grand gourou suppléant de la secte des MAGIKARP
Leader charismatique des 2beStaffieux
N°1 du forum
Président, vice-présidents et membres honoraires de la cour suprême du forum
Président de l'association des grosses distinctions CMB
Date d'inscription : 02/07/2008
Re: [Résolu] Modifier la position d'un HUD
Mer 20 Juil 2011 - 15:43
J'ai corrigé entre deux, j'ai mis "super(@x, 0, @w, @h)" parce que je t'avais mal lu, je pensais que tu voulais en haut à gauche ^^
Sinon de rien, et bonne continuation
Je lock car c'est résolu
Sinon de rien, et bonne continuation
Je lock car c'est résolu
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum
|
|