Jump to content
Rpg²S Forum
  • 0

Di nuovo quei maledetti colori del font...


Zosimos
 Share

Question

Salve a tutti,

 

sapete che, nonostante mi diletti a smanettare con il Ruby, gli script rimangono sempre una mia costante tragedia.

 

In questi giorni sono alle prese con lo Stat Distribution System, che potete trovare qui

 

Ora, ovviamente quel sistema di finestre mi fa orrore e raccapriccio, per cui ho pensato di modificarla in modo che venisse così:

 

Prova.PNG

 

Ok, non badate allo scompaginamento, sistemo le coordinate più tardi.

Ecco le mie modifiche:

 

 

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

:=:=:=:=

# Stat Distribution System by Blizzard

# Tradotto da Amos_MHF http://www.rpg2s.net/

# Versione: 1.33b

# Tipo: Actor Attribute Modifier

# Data: 25.3.2007

# Data v1.1b: 6.4.2007

# Data v1.2b: 22.8.2007

# Data v1.3b: 12.9.2007

# Data v1.33b: 5.11.2007

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#

# Compatibilità:

#

# 99% compatibile con SDK v1.x. 80% compatibile con SDK 2.x.

# Danneggerà i vecchi salvataggi.

# Può causare problemi con sistemi personalizzati di level-up.

# 99% compatibile con qualsiasi altro script.

#

#

# Caratteristiche:

#

# - distribuzione di punti tra statistiche diverse

# - finestra di conferma alla fine della distribuzione

# - chiama automaticamente la "caller scene" dopo la distribuzione

# - aggiunge/toglie facilmente punti premendo DESTRA/SINISTRA

# - tieni premuto Q per aggiungere 10 punti alla volta

# - tieni premuto W per aggiungere 100 punti alla volta

# - uno Stat Distribution System che funziona come dovrebbe...

#

#

# Configurazione:

#

# Configura seguendo le istruzioni.

#

# STARTING_POINTS - quanti punti deve avere l'eroe al livello 1

# POINTS_PER_LEVEL - punti guadagnati per ogni livello

# DISPLAY_ICON - visualizza un'icona sulla mappa se almeno un eroe

# ha dei punti da distribuire

# ICON_DATA - opzioni personalizzabili per l'icone: [X, Y, OPACITY]

# i valori predefiniti sono [612, 452, 192]

# OWN_ICON - usa un'icona personalizzata (nella cartella Icons,

# chiamata "point_notify")

# EVASION - il nome mostrato per l'Evasione

# STR_LIMIT - la massima STR possibile

# DEX_LIMIT - la massima DEX possibile

# AGI_LIMIT - la massima AGI possibile

# INT_LIMIT - la massima INT possibile

# WINDOW_MODE - true per avere le finestre a sinistra,

# false per averle a destra

# AUTOMATIC_CALL - true per chiamare la scene dopo una battaglia con

# almeno un eroe salito di livello

# AUTOMATIC_MAP_CALL - true per chiamare la scene dopo un level-up di almeno

# un eroe sulla mappa

#

#

# Puoi aggiungere punti manualmente con la seguente sintassi:

#

# $game_party.actors[X].add_stat_points(Z)

# $game_actors[Y].add_stat_points(Z)

#

# O puoi rimuoverne:

#

# $game_party.actors[X].remove_stat_points(Z)

# $game_actors[Y].remove_stat_points(Z)

#

# X - posizione dell'eroe nel party (INIZIA DA ZERO!)

# Y - ID dell'eroe nel database

# Z - numero di punti

#

# Puoi chiamare questa scene con il comando evento Call Script inserendo:

#

# $scene = Scene_Points.new

#

#

# Nota bene:

#

# Diminuire il livello di un eroe non farà diminuire i suoi punti.

# Dovrai farlo manualmente.

#

#

# Se trovi dei bug, segnalalo qui:

# http://www.chaosproject.co.nr

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

 

module BlizzCFG

 

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

# INIZIO Configurazione

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

STARTING_POINTS = 0

POINTS_PER_LEVEL = 10

DISPLAY_ICON = true

ICON_DATA = [612, 452, 192]

OWN_ICON = false

EVASION = 'EVA'

STR_LIMIT = 999

DEX_LIMIT = 999

AGI_LIMIT = 999

INT_LIMIT = 999

WINDOW_MODE = true

AUTOMATIC_CALL = false

AUTOMATIC_MAP_CALL = true

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

# FINE Configurazione

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

ATTR_LIMITS = [sTR_LIMIT, DEX_LIMIT, AGI_LIMIT, INT_LIMIT]

# ensures compatibility

$stat_system = 1.33

 

end

 

#==============================================================================

# Array

#==============================================================================

 

class Array

 

def sum

result = 0

self.each {|i| result += i if i.is_a?(Numeric)}

return result

end

 

end

 

#==============================================================================

# Game_Actor

#==============================================================================

 

class Game_Actor

 

attr_reader :points

 

alias setup_sds_later setup

def setup(actor_id)

@points = BlizzCFG::STARTING_POINTS

setup_sds_later(actor_id)

end

 

alias exp_sds_later exp=

def exp=(exp)

old_level = @level

exp_sds_later(exp)

add_stat_points((@level - old_level) * BlizzCFG::POINTS_PER_LEVEL)

end

 

def add_stat_points(val)

@points += val if val > 0

end

 

def remove_stat_points(val)

@points = [@points-val, 0].max

end

 

end

 

#==============================================================================

# Window_Base

#==============================================================================

 

class Window_Base

 

def draw_actor_battler(actor, x, y)

bitmap = RPG::Cache.character("Face/" + actor.character_name, actor.character_hue)

cw, ch = bitmap.width, bitmap.height

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x - cw/2, y - ch/2, bitmap, src_rect)

self.back_opacity = 0

self.opacity = 0

end

 

alias draw_actor_parameter_sds_later draw_actor_parameter

def draw_actor_parameter(actor, x, y, type)

if type == 7

self.contents.font.color = system_color3

self.back_opacity = 0

self.opacity = 0

self.contents.draw_text(x, y, 120, 32, BlizzCFG::EVASION)

self.contents.font.color = system_color3

self.contents.draw_text(x + 120, y, 36, 32, actor.eva.to_s, 2)

else

draw_actor_parameter_sds_later(actor, x, y, type)

end

end

 

end

 

#==============================================================================

# Window_Distribution_Status

#==============================================================================

 

class Window_Distribution_Status

 

attr_accessor :actor

 

def initialize(actor)

super(BlizzCFG::WINDOW_MODE ? 160 : 0, 0, 480, 480)

@actor = actor

self.contents = Bitmap.new(width - 32, height - 32)

self.contents.font.color = system_color3

if $fontface != nil

self.contents.font.name = $fontface

self.contents.font.size = $fontsize

self.back_opacity = 0

self.opacity = 0

elsif $defaultfonttype != nil

self.contents.font.name = $defaultfonttype

self.contents.font.size = $defaultfontsize

end

refresh

end

 

def refresh

self.contents.clear

unless @actor == nil

# self.contents.font.color = system_color3

draw_actor_battler(@actor, 120, 0)

# draw_actor_name(@actor, 4, 0)

draw_actor_level(@actor, 4, 64)

# draw_actor_state(@actor, 4, 96)

self.contents.font.color = system_color3

self.contents.draw_text(4, 128, 80, 32, 'EXP')

self.contents.draw_text(4, 160, 80, 32, 'al Level-Up')

self.contents.font.color = system_color3

self.contents.draw_text(4, 128, 156, 32, @actor.exp_s, 2)

self.contents.draw_text(4, 160, 156, 32, @actor.next_rest_exp_s, 2)

self.contents.font.color = system_color3

draw_actor_hp(@actor, 4, 224, 172)

draw_actor_sp(@actor, 4, 256, 172)

self.contents.font.color = system_color3

draw_actor_parameter(@actor, 4, 320, 0)

draw_actor_parameter(@actor, 4, 352, 1)

draw_actor_parameter(@actor, 4, 384, 2)

draw_actor_parameter(@actor, 4, 416, 7)

# self.contents.font.color = system_color3

#self.contents.draw_text(240, 240, 96, 32, 'Equip')

#self.contents.font.color = system_color3

#draw_item_name($data_weapons[@actor.weapon_id], 240, 288)

#draw_item_name($data_armors[@actor.armor1_id], 240, 320)

#draw_item_name($data_armors[@actor.armor2_id], 240, 352)

#draw_item_name($data_armors[@actor.armor3_id], 240, 384)

#draw_item_name($data_armors[@actor.armor4_id], 240, 416)

end

end

 

end

 

#==============================================================================

# Window_Distribution

#==============================================================================

 

class Window_Distribution

 

attr_accessor :actor

attr_reader :points

 

def initialize(actor)

super(BlizzCFG::WINDOW_MODE ? 0 : 480, 160, 160, 320)

self.contents = Bitmap.new(width - 32, height - 32)

if $fontface != nil

self.contents.font.name = $fontface

self.contents.font.size = $fontsize

self.contents.font.color = system_color3

self.back_opacity = 0

self.opacity = 0

elsif $defaultfonttype != nil

self.contents.font.name = $defaultfonttype

self.contents.font.size = $defaultfontsize

self.contents.font.color = system_color3

end

self.active, self.index, = false, 0

@item_max, @actor, @att, @points = 4, actor, [0, 0, 0, 0], 0

refresh

end

 

def set_new_attributes

@actor.str += @att[0]

@actor.dex += @att[1]

@actor.agi += @att[2]

@actor.int += @att[3]

@actor.remove_stat_points(@points)

end

 

def actor=(actor)

@actor = actor

@att[0] = @att[1] = @att[2] = @att[3] = @points = 0

end

 

def refresh

self.contents.clear

unless @actor == nil

self.back_opacity = 0

self.contents.font.color = system_color3

self.contents.draw_text(52, 0, 72, 32, 'DP', 2)

self.contents.draw_text(4, 32, 120, 32, $data_system.words.str)

self.contents.draw_text(4, 96, 120, 32, $data_system.words.dex)

self.contents.draw_text(4, 160, 120, 32, $data_system.words.agi)

self.contents.draw_text(4, 224, 120, 32, $data_system.words.int)

self.contents.font.color = system_color3

self.contents.draw_text(4, 0, 48, 32, "#{actor.points-@points}", 2)

self.contents.draw_text(36, 64, 56, 32, "#{@actor.str+@att[0]}", 2)

self.contents.draw_text(36, 128, 56, 32, "#{@actor.dex+@att[1]}", 2)

self.contents.draw_text(36, 192, 56, 32, "#{@actor.agi+@att[2]}", 2)

self.contents.draw_text(36, 256, 56, 32, "#{@actor.int+@att[3]}", 2)

self.contents.font.size += 8

self.contents.font.bold = true

(0...4).each {|i|

self.contents.draw_text(0, (i + 1) * 64 - 8, 32, 42, '«', 2)

self.contents.draw_text(96, (i + 1) * 64 - 8, 32, 42, '»')}

self.contents.font.bold = false

self.contents.font.size -= 8

end

end

 

def add_points(num)

attr = [@actor.str, @actor.dex, @actor.agi, @actor.int]

if @points

attr[index]+@att[index]

@points = [@points + num, @actor.points].min

@att[index] = [@att[index]+num, @points+@att[index]-@att.sum].min

return true

end

return false

end

 

def remove_points(num)

if @points > 0 && @att[index] > 0

@points = [@points - num, 0].max

@att[index] = [@att[index] - num, 0].max

return true

end

return false

end

 

def update

super

return unless self.active

if Input.press?(Input::R)

if Input.repeat?(Input::RIGHT)

if add_points(100)

$game_system.se_play($data_system.cursor_se)

refresh

else

$game_system.se_play($data_system.buzzer_se)

end

elsif Input.repeat?(Input::LEFT)

if remove_points(100)

$game_system.se_play($data_system.cursor_se)

refresh

else

$game_system.se_play($data_system.buzzer_se)

end

end

elsif Input.press?(Input::L)

if Input.repeat?(Input::RIGHT)

if add_points(10)

$game_system.se_play($data_system.cursor_se)

refresh

else

$game_system.se_play($data_system.buzzer_se)

end

elsif Input.repeat?(Input::LEFT)

if remove_points(10)

$game_system.se_play($data_system.cursor_se)

refresh

else

$game_system.se_play($data_system.buzzer_se)

end

end

elsif Input.repeat?(Input::RIGHT)

if add_points(1)

$game_system.se_play($data_system.cursor_se)

refresh

else

$game_system.se_play($data_system.buzzer_se)

end

elsif Input.repeat?(Input::LEFT)

if remove_points(1)

$game_system.se_play($data_system.cursor_se)

refresh

else

$game_system.se_play($data_system.buzzer_se)

end

end

end

 

def update_cursor_rect

if @index

self.cursor_rect.empty

else

self.cursor_rect.set(32, (@index+1)*64, 64, 32)

end

end

 

end

 

#==============================================================================

# Window_Sure

#==============================================================================

 

class Window_Sure

 

attr_accessor :actor

 

def initialize(width, commands)

commands.push('')

super

@item_max, self.index = commands.size - 1, 0

self.x, self.y, self.z = 320-self.width/2, 240-self.height/2, 10000

refresh

end

 

def refresh

super

self.contents.font.color = system_color3

self.contents.draw_text(4, 0, self.contents.width - 8, 32, 'Sei sicuro?', 1)

end

 

def draw_item(index, color)

self.contents.font.color = color

rect = Rect.new(4, 32 * (index+1), self.contents.width - 8, 32)

self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))

self.contents.draw_text(rect, @commands[index], 1)

end

 

def update_cursor_rect

if @index

self.cursor_rect.empty

else

self.cursor_rect.set(32, (@index+1)*32, self.contents.width - 64, 32)

end

end

 

end

 

#==============================================================================

# Scene_Points

#==============================================================================

 

class Scene_Points

 

def initialize

@actor, @scene = $game_party.actors[0], $scene.class

end

 

def main

@sprite = Sprite.new

@sprite.bitmap = RPG::Cache.title("backdrop")

commands = ['Distribuzione', 'Prossimo', 'Precedente', 'Fine']

@command_window = Window_Command.new(160, commands)

@command_window.x = (BlizzCFG::WINDOW_MODE ? 0 : 480)

@command_window.opacity = 0

@status_window = Window_Distribution_Status.new(@actor)

@distro_window = Window_Distribution.new(@actor)

Graphics.transition

loop do

Graphics.update

Input.update

update

break if $scene != self

end

Graphics.freeze

[@command_window, @status_window, @distro_window].each {|win| win.dispose}

@sprite.bitmap.dispose

@sprite.dispose

end

 

def make_sure_window

commands = ['Annulla', 'Accetta cambiamenti', 'Annulla cambiamenti']

@sure_window = Window_Sure.new(256, commands)

end

 

def update

if @command_window.active

@command_window.update

update_main_command

elsif @sure_window != nil

@sure_window.update

update_sure

elsif @distro_window.active

@distro_window.update

if Input.trigger?(Input::B)

$game_system.se_play($data_system.cancel_se)

@command_window.active, @distro_window.active = true, false

end

end

end

 

def update_main_command

if Input.trigger?(Input::B)

$game_system.se_play($data_system.cancel_se)

if @distro_window.points != 0

@command_window.index, @command_window.active = 3, false

make_sure_window

else

$scene = @scene.new

end

elsif Input.trigger?(Input::C)

$game_system.se_play($data_system.decision_se)

case @command_window.index

when 0 then @command_window.active, @distro_window.active = false, true

when 1

if @distro_window.points != 0

@command_window.active = false

make_sure_window

else

i = (@actor.index+1) % $game_party.actors.size

@actor = @status_window.actor = @distro_window.actor = $game_party.actors

[@status_window, @distro_window].each {|win| win.refresh}

@distro_window.index = 0

end

when 2

if @distro_window.points != 0

@command_window.active = false

make_sure_window

else

i = (@actor.index+$game_party.actors.size-1) % $game_party.actors.size

@actor = @status_window.actor = @distro_window.actor = $game_party.actors

[@status_window, @distro_window].each {|win| win.refresh}

@distro_window.index = 0

end

when 3

if @distro_window.points != 0

@command_window.active = false

make_sure_window

else

$scene = @scene.new

end

end

end

end

 

def update_sure

if Input.trigger?(Input::B)

$game_system.se_play($data_system.cancel_se)

@sure_window.dispose

@sure_window, @command_window.active = nil, true

elsif Input.trigger?(Input::C)

$game_system.se_play($data_system.decision_se)

case @command_window.index

when 1

if @sure_window.index > 0

@distro_window.set_new_attributes if @sure_window.index == 1

i = (@actor.index+1) % $game_party.actors.size

@actor = @status_window.actor = @distro_window.actor = $game_party.actors

[@status_window, @distro_window].each {|win| win.refresh}

end

@sure_window.dispose

@sure_window, @command_window.active = nil, true

when 2

if @sure_window.index > 0

@distro_window.set_new_attributes if @sure_window.index == 1

i = (@actor.index+$game_party.actors.size-1) % $game_party.actors.size

@actor = @status_window.actor = @distro_window.actor = $game_party.actors

[@status_window, @distro_window].each {|win| win.refresh}

end

@sure_window.dispose

@sure_window, @command_window.active = nil, true

when 3

if @sure_window.index > 0

@distro_window.set_new_attributes if @sure_window.index == 1

$scene = @scene.new

end

@sure_window.dispose

@sure_window, @command_window.active = nil, true

end

end

end

 

end

 

#==============================================================================

# Scene_Battle

#==============================================================================

 

class Scene_Battle

 

alias main_sds_later main

def main

main_sds_later

if BlizzCFG::AUTOMATIC_CALL &&

$game_party.actors.any? {|actor| actor.points > 0}

$scene = Scene_Points.new

end

end

 

end

 

#==============================================================================

# Scene_Map

#==============================================================================

 

class Scene_Map

 

alias main_sds_later main

def main

main_sds_later

@notify.dispose if @notify != nil

end

 

alias upd_sds_later update

def update

check_icon if BlizzCFG::DISPLAY_ICON

upd_sds_later

if BlizzCFG::AUTOMATIC_MAP_CALL &&

$game_party.actors.any? {|actor| actor.points > 0}

$scene = Scene_Points.new

end

end

 

def check_icon

if $game_party.actors.any? {|actor| actor.points > 0}

if @notify == nil

@notify = RPG::Sprite.new

if BlizzCFG::OWN_ICON

@notify.bitmap = RPG::Cache.icon('point_notify')

else

@notify.bitmap = Bitmap.new(24, 24)

@notify.bitmap.fill_rect(0, 0, 24, 24, Color.new(0, 0, 0))

@notify.bitmap.fill_rect(22, 1, 2, 23, Color.new(0, 0, 0))

@notify.bitmap.fill_rect(1, 22, 23, 2, Color.new(0, 0, 0))

@notify.bitmap.set_pixel(23, 0, Color.new(0, 0, 0))

@notify.bitmap.set_pixel(0, 23, Color.new(0, 0, 0))

@notify.bitmap.fill_rect(2, 2, 20, 20, Color.new(0, 0, 0))

@notify.bitmap.fill_rect(4, 10, 16, 4, Color.new(0, 0, 0))

@notify.bitmap.fill_rect(10, 4, 4, 16, Color.new(0, 0, 0))

@notify.opacity = BlizzCFG::ICON_DATA[2]

end

@notify.x, @notify.y = BlizzCFG::ICON_DATA[0, 2]

@notify.z = 5000

@notify.blink_on

end

@notify.update

elsif @notify != nil

@notify.dispose

@notify = nil

end

end

 

end

 

 

 

La domanda è: come CRIBBIO si fa a far sì che anche quelle maledette scritte gialle e bianche risultino marroni o comunque scure? Sono due giorni che mi ci sto rompendo la testa sopra senza alcun risultato.

 

Vi ringrazio in anticipo per qualsiasi informazione saprete darmi.

 

PS: per un casino successo con il tag Codice, questo post è stato pubblicato due volte, di cui una in finestra vuota. Prego gli Adm di cancellare l'altro.

Edited by Zosimos

Gioco in Sviluppo:

http://www.studibizantini.it/docs/Logo.png

 

Blog: Ode to my Forthcoming Winter

Riferimento

 

Contest:

http://rpg2s.net/gif/SCContest2Oct.gifx2 http://rpg2s.net/gif/SCContest1Oct.gifx1

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

self.contents.font.color = Color.new (0,0,0,0)

Da sinistra verso destra : r,g,b,opacity.

Invece se questo colore lo vuoi usare spesso e volentieri vai nella winow_base e aggiungi insieme a i colori (es. system_color):

 

def Marrone (nome che ti pare)

return Color.new(192, 224, 255, 255)

end

 

per richiamarlo

 

self.contents.font.color = Marrone (nome che ti pare).

 

;)

http://img256.imageshack.us/img256/7639/ihateyou.gif

Un uomo senza religione è come un pesce senza bicicletta.

http://img18.imageshack.us/img18/3668/decasoft1.png

http://rpg2s.net/gif/SCContest1Oct.gifhttp://rpg2s.net/gif/SCContest2Oct.gifhttp://rpg2s.net/gif/SCContest2Oct.gif

Link to comment
Share on other sites

  • 0

Nu guarda non era questo il problema, lui settava effettivamente il colore come marrone (system_color3) nello script, però poi lo script richiamava i draw_actor_hp/sp/parameter di altri script che a loro volta settavano altri colori, rendendo vano il settaggio messo nello script!

 

Comunque abbiamo risolto, dopo un paio d'ore di ricerche di tutti i pezzi i vari richiami, abbiamo creato praticamente dei de draw_actor_hp_zos, che eliminavano il settaggio del colore e insomma, ora va tutto alla grande XD

 

Ah se dovesse tornare utile a qualcuno, per le scritte bianche della finestrella dei comandi in alto a sinistra siamo andati in Window_Command e dove c'è il settaggio dei colori abbiamo messo una condizione:

if $scene.is_a?(Scene_Points)

in modo tale da far apparire le scritte marroni solo nella Scene_Points (che è questa qui del topic, per capirci) ;)

http://i30.tinypic.com/xehois.gif

} 2rA - web site {

E' disponibile il primo capitolo completo di 2rA!

} 2rA: Capitolo I {

Link to comment
Share on other sites

  • 0

Madò, ragazzi, che sfacchinata.

Dopo che quel sant'uomo di nihil-omen si è giustamente ritirato per la nanna, sono stato un'altra ora e mezza buona a smanettare per comprendere un po' la faccenda. Anche perchè ad un certo punto si era messo a farmi tutto marrone, compreso l'Equip_Left, il che mi dava un po' sui nervi.

 

Alla fine ne sono venuto più o meno a capo. Ho messo lo script del menu custom più in basso, e ho regolato la condizione:

 

if $scene.is_a?(Scene_Points)

 

per il font_color, oltre che per il draw_item come abbiamo fatto in Window_Command.

E funziona, vivaddio.

 

Non dico che ho imparato il Ruby (impresa vana, alla quale nemmeno mi accingo), ma se non altro ora ne so qualcosa di più.

Gioco in Sviluppo:

http://www.studibizantini.it/docs/Logo.png

 

Blog: Ode to my Forthcoming Winter

Riferimento

 

Contest:

http://rpg2s.net/gif/SCContest2Oct.gifx2 http://rpg2s.net/gif/SCContest1Oct.gifx1

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...