Day.png);">
Apprendre


Vous êtes
nouveau sur
Oniromancie?

Visite guidée
du site


Découvrir
RPG Maker

RM 95
RM 2000/2003
RM XP
RM VX/VX Ace
RM MV/MZ

Apprendre
RPG Maker

Tutoriels
Guides
Making-of

Dans le
Forum

Section Entraide

Sorties: Star Trek: Glorious Wolf - (...) / Sorties: Dread Mac Farlane - episode 3 / News: Plein d'images cools créées par (...) / Sorties: Star Trek: Glorious Wolf - (...) / Jeux: Final Fantasy 2.0 / Chat

Bienvenue
visiteur !




publicité RPG Maker!

Statistiques

Liste des
membres


Contact

Mentions légales

340 connectés actuellement

29190922 visiteurs
depuis l'ouverture

5973 visiteurs
aujourd'hui



Barre de séparation

Partenaires

Indiexpo

Akademiya RPG Maker

Blog Alioune Fall

Fairy Tail Constellations

Lumen

RPG Maker VX

Zarok

RPG Maker Détente

Tous nos partenaires

Devenir
partenaire



forums

Index du forum > Entraide > [RESOLU] [RMXP] Cherche à faire onduler ou trembler le texte


Ardonie - posté le 12/09/2022 à 20:10:12 (854 messages postés) -

❤ 0

Ex Couteau Suisse Agréé

Domaine concerné: Script
Logiciel utilisé: RMXP
Salut à tous !
Je cherche un équivalent RPG Maker XP du plugin de SRDude pour faire onduler ou trembler les textes,
afin de donner plus de vie aux dialogues.



Sylvan Melody, c'est par ici ! | Mes Musiques! | Le making, c'est réaliser le meilleur jeu du monde... à vos yeux."Les RTP c'est quand même très limité. Quand on réalise un jeu, on réalise un univers qui va avec, et cet univers il passe beaucoup par les graphismes, et l'identité qu'on leur donne."


Roi of the Suisse - posté le 12/09/2022 à 23:05:49 (29766 messages postés) - honor -

❤ 0

Alerte neige !

Tu as le script RPG Maker VX sous la main ?
VX et XP ont des systèmes de scripts assez proches, on peut peut-être transposer de l'un à l'autre à peu de frais.

Je pense que ça sera un paragraphe de code à ajouter dans la classe Window_Message, dans la méthode refresh, et qu'il faudra utiliser la fonction d'affichage de texte sur la boîte de message :

Portion de code : Tout sélectionner

1
self.contents.draw_text(position_texte_x, position_texte_y, largeur, hauteur, texte)



1) Tu repères si le texte contient le marqueur qui déclenche l'ondulation du texte.
2) Tu découpes le texte en caractères
3 ) Tu affiches chaque caractère individuellement. La position y étantune sinusoïde qui dépend du temps (numéro de la frame en cours : Graphics.frame_count ), avec un facteur constant dans le sinus pour ajuster la vitesse d'ondulation, et un facteur constant à l'extérieur du sinus pour ajuster l'amplitude d'ondulation.

Pour un tremblement (plutôt qu'une ondulation) du texte, il faut ajouter un delta_x à position_texte_x et un delta_y à position_texte_y. delta_x et delta_y étant des sinus à haute fréquence et faible amplitude pour plus de fluidité. Il faudra sûrement donner à chaque caractère une amplitude aléatoire en x et en y déterminée par la position du caractère dans le texte.

L'essentialisme c'est quand ta voiture a un moteur essence. | Es-tu une star ? | Kujira no Hara | Polaris 03 | Planète Glutko


Ardonie - posté le 12/09/2022 à 23:26:23 (854 messages postés) -

❤ 0

Ex Couteau Suisse Agréé

Merci pour ta réponse, Rots !
Ah, il y aurait un équivalent VX / Ace ? J'ai pas pensé à regarder ce côté-là,
L'exemple ci-dessus est un plugin pour MV.
ça vaut effectivement le coup de regarder, même si je ne sais pas à quel point les scripts de ces versions sont proches de XP...
Je vais faire mes recherches et je reviens. Merci pour la portion de code !

EDIT : J'ai trouvé ça, c'est pour Ace: "Wiggly Text" de Tuckie.

Portion de code : Tout sélectionner

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
=begin
______________________
<  wiggly text          │
│ by tuckie            │
│                      │
│ 7/7/17 woa lucky     │
│ Version: pretty done │
│______________________│
 
       ______________
(-o-)< hi there!! │
      │_____________│
 
__________________________________________
<                                           │
│ uhh hi this lets you animate text〰️〰️〰️〰️ │
│                  pretty cool             │
│ i like credit link to my twitter         │
│ @plsvotetuckie  in the credit.txt        │
│ or website(tell ur fans to give me $100) │
│ tuckie.zone thank you i love yuo ❤️      │
│__________________________________________│
 
=end
 
#==============================================================================
# how2use this scripty boy                                              _ ⬜ ❎
#==============================================================================
# Triggering animations is done via tags in the message window.
#
# Simply add a \ani[0-9] to pick the animation you want, and all text after will
# be animated. If a new text box appears the animation will stop. You can
# manually end animation with a \stop or \ani[7].
#
#-R/-\|NB0\^/-------------------------------------------------------------------
# Much like an animation, you can turn on a rainbow effect with \ran . You can
# turn off the rainbow and animation with \off but \bln will turn off only the
# rainbow effect.
#
#==============================================================================
 
#==============================================================================
# ** SETTINGS | hi im tuckie please tell your players i made this       _ ⬜ ❎
#==============================================================================
 
module WiggleText
 
  # Characters 'drop in' when first drawn.
  DROP_IN     = true
  # Height from where characters drop.
  DROP_HEIGHT = 8
 
  # Enable or disable hitting a button to skip drawing characters one-by-one.
  # true means players can skip, false means they can't.
  SKIP_CHAR   = true
 
  # do /nam[number] to make a nametag box with that specific name
  NAMES = [
      "that guy", #0
      "that other guy",   #1
      "a jerk", #2 etc
  ]
  #the filename of the background for the nametag sprite, place in Graphics/System
  NAME_SPRITE = "Nametag"
 
  # creature comfort feature: If you have a bunch of text codes (nametag, color
  # sound effect, etc) that you need to have at the start of a message make them
  # on line one, and use the text code \lin . this will "reset" the text height
  # so line two is higher up. adjust the height to fit your font with this
  # variable. Measurement in pixels.
  LINE_HEIGHT = 16
end
 
#==============================================================================
# ** Sprite_TextAnim                                                    _ ⬜ ❎
#------------------------------------------------------------------------------
#  Sprite subclass for text animations.
#==============================================================================
 
class Sprite_TextAnim < Sprite
 
  attr_accessor :anim_offset
  attr_accessor :anim_type
  attr_accessor :rainbow
  attr_accessor :rainbow_offset
  attr_accessor :drop
  @timer      = false
  attr_accessor :galv_ani
 
  def drop()
    if WiggleText::DROP_IN
      @drop -= @drop * 0.1
      if @drop < 0
        @drop = 0
      end
      return @drop
    else
      return 0
    end
  end
 
  def ani
      @galv_ani += 0.015
  end
 
  def update
    return unless @anim_offset
 
    if @rainbow
      @rainbow_offset += 0.03
      self.color = Color.new(128 + Math.sin(@rainbow_offset) * 127,
        128 + Math.sin(@rainbow_offset + 2*Math::PI/3) * 127,
        128 + Math.sin(@rainbow_offset + 4*Math::PI/3) * 127,
        255)
    end
    case @anim_type
      when 1
        @anim_offset += 0.115
        self.oy = Math.sin(@anim_offset) * 3 + drop()
        ani()
      when 2
        @anim_offset += 0.2
        self.ox = Math.sin(@anim_offset) * 3
        self.oy = Math.cos(@anim_offset) * -3 + drop()
        ani()
      when 3
        @anim_offset += 0.15
        self.zoom_x = 1 + Math.sin(@anim_offset) * 0.2
        self.zoom_y = 1 + Math.cos(@anim_offset) * 0.2
        self.oy = drop()
        ani()
      when 4
        @anim_offset += 1
        rand = 0
        if @anim_offset % 8 == 0
          rand = 4
          self.ox = rand(rand) - rand(rand)
          self.oy = rand(rand) - rand(rand) + drop()
        end
        ani()
      when 5
        @anim_offset += 0.1
        sample  = Math.sin(@anim_offset) * 5
        self.oy = sample.abs + drop()
        ani()
      when 6
        @anim_offset += 0.1
        self.ox = Math.sin(@anim_offset) * 3
        self.oy = Math.cos(@anim_offset) * -2 + drop()
        self.angle = Math.sin(@anim_offset * 0.5) * 10
        ani()
      when 7
        #no animation
        self.oy = drop()
        ani()
      when 8
        @anim_offset += 0.1
        self.ox = Math.sin(@anim_offset) * 3
        self.oy = Math.cos(@anim_offset) * -2 + drop()
        self.angle = Math.sin(@anim_offset) * 10
      when 9
        @anim_offset += 0.15
        self.zoom_x = 2
        self.zoom_y = 2
        self.oy = Math.sin(@anim_offset / 2) * -4 + drop()
      when 10
        @anim_offset += 0.085
        self.oy = Math.sin(@anim_offset / 2) * 3 + drop() + 2
      else
        return
    end
  end
 
end
 
#==============================================================================
# ** Window_Message                                                     _ ⬜ ❎
#------------------------------------------------------------------------------
#  This message window is used to display text.
#==============================================================================
 
class Window_Message < Window_Base
 
  #--------------------------------------------------------------------------
  # * Window_Message Creation | Alias
  #--------------------------------------------------------------------------
  alias tuckie_wiggly_initialize initialize
  def initialize
    tuckie_wiggly_initialize
    @animchars = []
    @rainbow = false
    @anim_offset = 0
  end
 
  #--------------------------------------------------------------------------
  # * Normal Character Processing | Overwrite
  #--------------------------------------------------------------------------
  def process_normal_character(c, pos)
    if @anim_type && @anim_type > 0
      process_anim_character(c, pos)
    else
      if WiggleText::DROP_IN
        @anim_type = 7
        process_anim_character(c, pos)
      else
        super
      end
    end
    wait_for_one_character
  end
  #--------------------------------------------------------------------------
  # * Animated Character Processing | New Method
  #--------------------------------------------------------------------------
  def process_anim_character(c, pos)
    text_width = text_size(c).width
    if defined? Graphics.fullscreen #MKXP fix
      text_width += text_width * 0.6
      text_width = text_width.round
    end
    letter = Sprite_TextAnim.new(self.viewport)
    bitmap = Bitmap.new(text_width, pos[:height])
    bitmap.font = self.contents.font
    letter.bitmap = bitmap
    letter.x = pos[:x] + self.standard_padding + 9
    letter.y += WiggleText::DROP_HEIGHT if WiggleText::DROP_IN
    letter.y = self.y + standard_padding + pos[:y]
    letter.z = self.z + 10
    letter.anim_offset = @animchars.size
    letter.anim_type = @anim_type
    tuckie_extra(letter)
    letter.update
    bitmap.draw_text(0, 0, 10, pos[:height], c)
    @animchars.push(letter)
    pos[:x] += text_width
  end
  #--------------------------------------------------------------------------
  # * Name Menu Processing | New Method
  #--------------------------------------------------------------------------
  def process_name(c, pos)
    c = WiggleText::NAMES[c]
    text_width = text_size(c).width
    if defined? Graphics.fullscreen #MKXP fix
      text_width += text_width * 0.6
      text_width = text_width.round
    end
 
    letter = Sprite_TextAnim.new(self.viewport)
    bitmap = Bitmap.new(text_width + 4, 20)
    letter.bitmap = bitmap
    bitmap.font = self.contents.font
    letter.x = 23
    letter.y = self.y  + 2
    letter.z = self.z + 10
    letter.anim_offset = @animchars.size
    letter.anim_type = 10 #@anim_type
    tuckie_extra(letter)
    letter.update
    bitmap.draw_text(0, 0, 10, 16, c)
 
    tag = Sprite_TextAnim.new(self.viewport)
    tag.bitmap = Cache.system(WiggleText::NAME_SPRITE)
    tag.x = 14
    tag.y = self.y - 8
    tag.z = self.z + 9
    tag.anim_offset = @animchars.size
    tag.anim_type = 10
    tuckie_extra(tag)
    tag.drop = 0
    tag.update
 
    @animchars.push(tag)
    @animchars.push(letter)
  end
  #--------------------------------------------------------------------------
  # * Animated Emoji Processing | New Method
  #--------------------------------------------------------------------------
  def process_anim_emoji(c, pos)
    text_width = 24
    letter = Sprite_TextAnim.new(self.viewport)
    icon_bitmap = Cache.system("Emoji")
    bitmap = Bitmap.new(24, pos[:height])
    rect = Rect.new(c % 16 * 24, c / 16 * 24, 24, 24)
    bitmap.blt(0, 0, icon_bitmap, rect)
    letter.bitmap = bitmap
    letter.x = pos[:x] + self.standard_padding + 9
    letter.y += WiggleText::DROP_HEIGHT if WiggleText::DROP_IN
    letter.y = self.y + standard_padding + pos[:y]
    letter.z = self.z + 10
    letter.anim_offset = @animchars.size
    letter.anim_type = @anim_type
    tuckie_extra(letter)
    letter.update
    bitmap.draw_text(0, 0, text_width * 2, pos[:height], c)
    @animchars.push(letter)
    pos[:x] += text_width
  end
  #--------------------------------------------------------------------------
  # * Animated Character Extra Conditions | New Method
  #--------------------------------------------------------------------------
  def tuckie_extra(letter)
    if WiggleText::DROP_IN
      letter.drop = WiggleText::DROP_HEIGHT
    else
      letter.drop = 0
    end
    if @anim_type == 5
      letter.anim_offset = 0
    end
    letter.galv_ani = get_galvani
    if @rainbow
      letter.rainbow = true
      letter.rainbow_offset = @animchars.size * 0.5
    end
  end
  #--------------------------------------------------------------------------
  # * Control Character Processing | Alias
  #     code : the core of the control character
  #            e.g. "C" in the case of the control character \C[1].
  #--------------------------------------------------------------------------
  alias tuckie_wiggly_process_escape_character process_escape_character
  def process_escape_character(code, text, pos)
    case code.upcase
    when 'ANI' # Text Animation (by number)
      @anim_type = obtain_escape_param(text)
    when 'OFF' # No Text Animation
      @anim_type = 7 if WiggleText::DROP_IN
      @rainbow = false
    when 'WAV' # Wave animation
      @anim_type = 1
    when 'SHK' # Shake Screen
      $game_map.screen.start_shake(obtain_escape_param(text), 15, 10)
    when 'RAN'
      @rainbow = true
    when 'BLN'
      @rainbow = false
    when 'MOJ'
      process_anim_emoji(obtain_escape_param(text), pos)
    when 'NAM'
      process_name(obtain_escape_param(text), pos)
    when 'LIN'
      pos[:y] -= WiggleText::LINE_HEIGHT
    end
    tuckie_wiggly_process_escape_character(code, text, pos)
  end
  #--------------------------------------------------------------------------
  # * Close Window and Wait for It to Fully Close | Alias
  #--------------------------------------------------------------------------
  alias tuckie_wiggly_close_wait close_and_wait
  def close_and_wait
    dispose_text_animation()
    tuckie_wiggly_close_wait()
  end
  #--------------------------------------------------------------------------
  # * Close Window and Wait for It to Fully Close | Alias
  #--------------------------------------------------------------------------
  alias tuckie_wiggly_dispose dispose
  def dispose
    dispose_text_animation()
    tuckie_wiggly_dispose()
  end
  #--------------------------------------------------------------------------
  # * New Page | Alias
  #--------------------------------------------------------------------------
  alias tuckie_wiggly_new_page new_page
  def new_page(*args)
    dispose_text_animation()
    tuckie_wiggly_new_page(*args)
  end
  #--------------------------------------------------------------------------
  # * Free animated text | New Method
  #--------------------------------------------------------------------------
  def dispose_text_animation
    @animchars.each do |letter|
      letter.dispose
    end
    @animchars = []
    @anim_type = 7
  end
  #--------------------------------------------------------------------------
  # * Update Fast Forward Flag | Alias
  #--------------------------------------------------------------------------
  alias tuckie_wiggle_update_show_fast update_show_fast
  def update_show_fast
    tuckie_wiggle_update_show_fast()
    @show_fast = false if !WiggleText::SKIP_CHAR
  end
  #--------------------------------------------------------------------------
  # * Galv Animated Textbox | Alias
  #--------------------------------------------------------------------------
  def get_galvani # new method
    return @anim_offset
  end
 
  def tuckie_update # new method
    @anim_offset += 0.015
  end
 
  #--------------------------------------------------------------------------
  # * Window Update | Alias
  #--------------------------------------------------------------------------
  alias tuckie_wiggly_update_base update
  def update
    tuckie_update
    update_text_animation()
    tuckie_wiggly_update_base()
  end
  #--------------------------------------------------------------------------
  # * Text Animation Processing | New Method
  #--------------------------------------------------------------------------
  def update_text_animation()
    unless @animchars.empty?
      @animchars.each do |letter|
        letter.update
      end
    end
  end
 
end
# end of script :) have a nice one thankz for looking



Sylvan Melody, c'est par ici ! | Mes Musiques! | Le making, c'est réaliser le meilleur jeu du monde... à vos yeux."Les RTP c'est quand même très limité. Quand on réalise un jeu, on réalise un univers qui va avec, et cet univers il passe beaucoup par les graphismes, et l'identité qu'on leur donne."


Gari - posté le 13/09/2022 à 08:59:36 (5899 messages postés) - honor

❤ 0

C'est cool si tu as réussi à trouver !
Sur XP, ta demande correspond à un mix entre ces deux scripts de Fabien :
- Afficher du texte en spirales, où tu as le modèle du script
- Image ondulante, qui pourrait te permettre d'afficher un texte en image, sans la boîte de dialogue, ce qui serait tout à fait adapté pour une scène d'intro ou un moment un peu glauque
A noter que le fait de faire un effet permanent/continu a l'air d'être assez lourd, c'est peut-être pas à mélanger avec trop d'autres effets.


Roi of the Suisse - posté le 13/09/2022 à 10:51:59 (29766 messages postés) - honor -

❤ 0

Alerte neige !

Tu as essayé d'importer ce script VX dans RPG Maker XP ? Est-ce que ça marche ? Généralement, ça ne marche pas directement, il faut remplacer des noms de variables de VX par les équivalents XP... Parfois ça ne marche pas du tout.

On voit bien dans le script de Tuckie le genre de fonctions qu'on va typiquement utiliser (Math.sin).

Si jamais j'ai besoin d'un effet similaire (tremblement de texte, vague) pour mon propre jeu, peut-être que je ferai le script pour XP. Auquel cas, je le publierai ici.
Je ne promets rien.

L'essentialisme c'est quand ta voiture a un moteur essence. | Es-tu une star ? | Kujira no Hara | Polaris 03 | Planète Glutko


Ardonie - posté le 13/09/2022 à 16:01:35 (854 messages postés) -

❤ 0

Ex Couteau Suisse Agréé

J'ai testé le script dans mon jeu ce matin, malheureusement ce n'est pas compatible tel quel.
Je peux pas vraiment aller plus loin car mes connaissances en script sont extrêmement limitées. Je laisse ça aux experts.
image

Citation:

ça pourrait te permettre d'afficher un texte en image, sans la boîte de dialogue, ce qui serait tout à fait adapté pour une scène d'intro



C'est une idée très intéressante mais je voulais surtout faire onduler le texte dans les dialogues pour faire passer des émotions, comme un baffouillement,
une pensée... Je voulais faire un système de dialogue assez vivant.
Sur MV, ça se fait les doigts dans le nez.
Sur XP, c'est une toute autre histoire ! :F

Sylvan Melody, c'est par ici ! | Mes Musiques! | Le making, c'est réaliser le meilleur jeu du monde... à vos yeux."Les RTP c'est quand même très limité. Quand on réalise un jeu, on réalise un univers qui va avec, et cet univers il passe beaucoup par les graphismes, et l'identité qu'on leur donne."


Roi of the Suisse - posté le 13/09/2022 à 22:42:14 (29766 messages postés) - honor -

❤ 0

Alerte neige !

Voici le script d'ondulation de texte :

https://www.rpg-maker.fr/index.php?page=scripts&id=577

Dans un second temps, je modifierai pour inclure le tremblement de texte.

Je me suis basé sur une version ancienne des scripts de RPG Maker XP + déjà très personnalisée par moi. Ça veut dire qu'il y aura peut-être des petites différences avec les scripts récents et vierges. Il faudra que j'essaie d'appliquer ma recette de cuisine sur un nouveau projet, afin de repérer les différences. Je pourrai aussi à l'occasion préciser le numéros de lignes, ça aidera les gens.

L'essentialisme c'est quand ta voiture a un moteur essence. | Es-tu une star ? | Kujira no Hara | Polaris 03 | Planète Glutko


Ardonie - posté le 14/09/2022 à 06:11:41 (854 messages postés) -

❤ 0

Ex Couteau Suisse Agréé

Oooooh génial ! T'as fais super vite !
Je vais tester ça.

EDIT : Bon, j'ai suivi le tuto, j'ai relu plusieurs fois pour vérifier si j'avais pas raté un truc, mais non...
Bon, au moins, mon jeu ne crache pas, c'est déjà ça ! :tirlalangue2
... Mais quand j'écris \WAVE dans le message, la balise est visible et le texte est tout à fait normal, pas d'ondulation...

J'ai juste modifié Window_Message, j'ai pas ajouté d'autre script ni rien... :pense

Sylvan Melody, c'est par ici ! | Mes Musiques! | Le making, c'est réaliser le meilleur jeu du monde... à vos yeux."Les RTP c'est quand même très limité. Quand on réalise un jeu, on réalise un univers qui va avec, et cet univers il passe beaucoup par les graphismes, et l'identité qu'on leur donne."


Roi of the Suisse - posté le 14/09/2022 à 09:17:54 (29766 messages postés) - honor -

❤ 0

Alerte neige !

Si tu as ça, c'est qu'il y a un problème au niveau du marqueur \WAVE .

Tu ne t'es pas trompé dans le nombre d'antislashes ?
Dans les scripts, il y a toujours deux antislashes \\, tandis que dans l'évènement, il y a un seul antislash \.

Sinon, dans l'évènement, as-tu bien mis un espace après le marqueur \WAVE  ?

J'essaie de penser à ce que tu as pu oublier :pense

L'essentialisme c'est quand ta voiture a un moteur essence. | Es-tu une star ? | Kujira no Hara | Polaris 03 | Planète Glutko


Roi of the Suisse - posté le 14/09/2022 à 14:38:20 (29766 messages postés) - honor -

❤ 0

Alerte neige !

J'ai mis à jour le script pour gérer le tremblement.

L'essentialisme c'est quand ta voiture a un moteur essence. | Es-tu une star ? | Kujira no Hara | Polaris 03 | Planète Glutko


Ardonie - posté le 14/09/2022 à 19:27:40 (854 messages postés) -

❤ 0

Ex Couteau Suisse Agréé

Oui j'ai vu que tu avais ajouté Shake ce matin ! Trop bien !
Du coup j'ai recommencé le tuto de zéro pour ajouter les deux.
Même souci : Il ne se passe rien.

voilà mon script Window_Message après avoir suivi ton tuto.

Portion de code : Tout sélectionner

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
#==============================================================================
# ** Window_Message
#------------------------------------------------------------------------------
#  This message window is used to display text.
#==============================================================================
 
class Window_Message < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(80, 304, 480, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.visible = false
    self.z = 9998
    @fade_in = false
    @fade_out = false
    @contents_showing = false
    @cursor_width = 0
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    terminate_message
    $game_temp.message_window_showing = false
    if @input_number_window != nil
      @input_number_window.dispose
    end
    super
  end
  #--------------------------------------------------------------------------
  # * Terminate Message
  #--------------------------------------------------------------------------
  def terminate_message
    self.active = false
    self.pause = false
    self.index = -1
    self.contents.clear
    # Clear showing flag
    @contents_showing = false
    # Call message callback
    if $game_temp.message_proc != nil
      $game_temp.message_proc.call
    end
    # Clear variables related to text, choices, and number input
    $game_temp.message_text = nil
    $game_temp.message_proc = nil
    $game_temp.choice_start = 99
    $game_temp.choice_max = 0
    $game_temp.choice_cancel_type = 0
    $game_temp.choice_proc = nil
    $game_temp.num_input_start = 99
    $game_temp.num_input_variable_id = 0
    $game_temp.num_input_digits_max = 0
    # Open gold window
    if @gold_window != nil
      @gold_window.dispose
      @gold_window = nil
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    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
            # Est-ce que le texte doit onduler ?
      le_texte_doit_onduler = false
      if text['\\WAVE ']
        text = text.gsub('\\WAVE ', '')
        le_texte_doit_onduler = true
      end
      # Est-ce que le texte doit trembler ?
      le_texte_doit_trembler = false
      if text['\\SHAKE ']
        text = text.gsub('\\SHAKE ', '')
        le_texte_doit_trembler = true
      end
      # 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)
      numero_du_caractere = 0 # pour les animations de texte (ondulation, tremblement)
      # On traite chaque caractère "c" du texte un par un
      while ((c = text.slice!(/./m)) != nil)
        numero_du_caractere += 1
        # Ondulation
        if le_texte_doit_onduler
          amplitude = 3
          frequence = 0.5
          ondulation = (amplitude * Math.sin(numero_du_caractere + Graphics.frame_count * frequence) ).round
        else
          ondulation = 0
        end
        # Tremblement
        if le_texte_doit_trembler
          frequence = 1
          amplitude = 1.5
          angle_aleatoire = (numero_du_caractere + 27.5) * (numero_du_caractere + 57.3) % 100
          dx = Math.sin(angle_aleatoire)
          dy = Math.cos(angle_aleatoire)
          tremblement_x = (amplitude * dx * Math.sin(Graphics.frame_count * frequence) ).round
          tremblement_y = (amplitude * dy * Math.sin(Graphics.frame_count * frequence) ).round
        else
          tremblement_x = 0
          tremblement_y = 0
        end
        # 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
self.contents.draw_text(position_texte_x+tremblement_x, position_texte_y+ondulation+tremblement_y, largeur, hauteur, c)
        # 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
  #--------------------------------------------------------------------------
  # * Set Window Position and Opacity Level
  #--------------------------------------------------------------------------
  def reset_window
    if $game_temp.in_battle
      self.y = 16
    else
      case $game_system.message_position
      when 0  # up
        self.y = 16
      when 1  # middle
        self.y = 160
      when 2  # down
        self.y = 304
      end
    end
    if $game_system.message_frame == 0
      self.opacity = 255
    else
      self.opacity = 0
    end
    self.back_opacity = 160
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    # If fade in
    if @fade_in
      self.contents_opacity += 24
      if @input_number_window != nil
        @input_number_window.contents_opacity += 24
      end
      if self.contents_opacity == 255
        @fade_in = false
      end
      return
    end
    # If inputting number
    if @input_number_window != nil
      @input_number_window.update
      # Confirm
      if Input.trigger?(Input::C)
        $game_system.se_play($data_system.decision_se)
        $game_variables[$game_temp.num_input_variable_id] =
          @input_number_window.number
        $game_map.need_refresh = true
        # Dispose of number input window
        @input_number_window.dispose
        @input_number_window = nil
        terminate_message
      end
      return
    end
    # If message is being displayed
    if @contents_showing
            # Rafraichir le message pour animer l'ondulation/le tremblement
      if $game_temp.message_text != nil and ($game_temp.message_text['\\WAVE '] or $game_temp.message_text['\\SHAKE '])
        refresh
      end
      # If choice isn't being displayed, show pause sign
      if $game_temp.choice_max == 0
        self.pause = true
      end
      # Cancel
      if Input.trigger?(Input::B)
        if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
          $game_system.se_play($data_system.cancel_se)
          $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
          terminate_message
        end
      end
      # Confirm
      if Input.trigger?(Input::C)
        if $game_temp.choice_max > 0
          $game_system.se_play($data_system.decision_se)
          $game_temp.choice_proc.call(self.index)
        end
        terminate_message
      end
      return
    end
    # If display wait message or choice exists when not fading out
    if @fade_out == false and $game_temp.message_text != nil
      @contents_showing = true
      $game_temp.message_window_showing = true
      reset_window
      refresh
      Graphics.frame_reset
      self.visible = true
      self.contents_opacity = 0
      if @input_number_window != nil
        @input_number_window.contents_opacity = 0
      end
      @fade_in = true
      return
    end
    # If message which should be displayed is not shown, but window is visible
    if self.visible
      @fade_out = true
      self.opacity -= 48
      if self.opacity == 0
        self.visible = false
        @fade_out = false
        $game_temp.message_window_showing = false
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index >= 0
      n = $game_temp.choice_start + @index
      self.cursor_rect.set(8, n * 32, @cursor_width, 32)
    else
      self.cursor_rect.empty
    end
  end
end
 



ainsi que les screenshots des events et leur résultat :
image

Sylvan Melody, c'est par ici ! | Mes Musiques! | Le making, c'est réaliser le meilleur jeu du monde... à vos yeux."Les RTP c'est quand même très limité. Quand on réalise un jeu, on réalise un univers qui va avec, et cet univers il passe beaucoup par les graphismes, et l'identité qu'on leur donne."


Gari - posté le 14/09/2022 à 19:40:12 (5899 messages postés) - honor

❤ 0

Si ça peut t'aider Rots, il me semble que j'avais le même souci avec un de tes scripts, c'était celui-là d'ailleurs : https://www.rpg-maker.fr/index.php?page=scripts&id=526
Je sais plus trop où on en avait parlé pour la solution, par contre (je crois que ça fonctionnait en rajoutant un antislash à un endroit précis dans le script).


Roi of the Suisse - posté le 14/09/2022 à 22:33:35 (29766 messages postés) - honor -

❤ 0

Alerte neige !

@Ardonie :
Déjà ta ligne "Draw Text" n'est pas bonne :

Portion de code : Tout sélectionner

1
self.contents.draw_text(position_texte_x+tremblement_x, position_texte_y+ondulation+tremblement_y, largeur, hauteur, c)


Tu aurais dû avoir :

Portion de code : Tout sélectionner

1
self.contents.draw_text(4+x+tremblement_x, 32*y+ondulation+tremblement_y, 40, 32, c)

Mon explication n'était peut-être pas assez claire, mais il fallait additionner tremblement_x, ondulation et tremblement_y à ce qui se trouvait déjà avant. Chez toi c'était 4+x et 32*y.


:susp Mais même, ça n'explique pas le problème que tu as.


:pense Je pense que mon script entre en conflit avec un autre script.
Lorsque tu fais "\." pour marquer une pause dans le dialogue, tu as eu cette fonctionnalité par défaut dans RPG Maker, ou bien tu as eu ça grâce à un script ?
Je crois que c'est ce script-là qui écrase le mien.
Tu es sûr de ne pas avoir un autre script qui vient écraser les fonctions update et refresh de Windows_Message ?

Je viens de tester sur un projet vierge et ça marche, donc c'est pas impossible que ça soit un conflit avec un autre script.

image


Je viens de me rendre compte que tu étais Loly74  XD XD XD
C'est ton style de dessin qui m'as mis la puce à l'oreille.

L'essentialisme c'est quand ta voiture a un moteur essence. | Es-tu une star ? | Kujira no Hara | Polaris 03 | Planète Glutko


Ardonie - posté le 14/09/2022 à 23:23:10 (854 messages postés) -

❤ 0

Ex Couteau Suisse Agréé

Eh oui, Loly74, c'est moi !
Mais... ça fait des années que j'ai changé mon pseudo ! Y a encore des gens qui pensent que je suis une autre personne ? Oo

Ah, oui ! j'avais un doute pour l'étape 3....
Bon, j'ai corrigé, mais rien ne change en jeu : balises toujours visibles et zéro tremblement ou ondulation à l'horizon.
Dis, Rots.... il serait pas plus simple de proposer le script Window_Message modifié dans la catégorie Script du serveur ? Ce serait plus simple que de suivre étape par étape au risque de se planter, non ? :pense

Un conflit de script ? C'est possible ! J'utilise Advanced Message de 桜雅 在土, 和希 et RaTTiE (j'ai fait que copier coller les noms, le script est dispo sur Oniro).
Bah je vais le retirer et voir si ça corige.

EDIT : C'était bien ça ! Le texte ondule et tremble, maintenant ! :lol

Sylvan Melody, c'est par ici ! | Mes Musiques! | Le making, c'est réaliser le meilleur jeu du monde... à vos yeux."Les RTP c'est quand même très limité. Quand on réalise un jeu, on réalise un univers qui va avec, et cet univers il passe beaucoup par les graphismes, et l'identité qu'on leur donne."


Roi of the Suisse - posté le 15/09/2022 à 08:05:12 (29766 messages postés) - honor -

❤ 0

Alerte neige !

Ardonie, jamais entendu parler. Tout le monde t’appelle Loly ou Loly74 :F


Tu peux avoir les deux fonctionnalités à la fois, mais il faut que tu fasses mes modifications sur les fonctions refresh et update de ces scripts là.

En fait, ces scripts proposent une version alternative de refresh et update, qui écrase celle par défaut de RPG Maker. Donc tu auras beau faire mes modifs ça se changera rien, vu que les fonctions refresh et update du fichier Windows_Message ne sont plus appelées.

Et là tu te rends compte qu’avec des scripts monolithiques à copier coller en entier, ok c’est plus simple à installer, mais tu ne peux pas avoir deux scripts à la fois, car l’un va remplacer l’autre.
C’est pour ça que je fais des scripts par modifications chirurgicales, ça permet de cumuler les effets de différents scripts.
Évidemment l’inconvénient c’est que c’est un peu plus pénible à mettre en place, il y a plus d’étapes.

Je proposerai peut-être une version monolithique de mon script plus tard. Mais bonjour les conflits chez tout le monde, car la classe Windows_Message est très convoitée…

L'essentialisme c'est quand ta voiture a un moteur essence. | Es-tu une star ? | Kujira no Hara | Polaris 03 | Planète Glutko


Ardonie - posté le 15/09/2022 à 16:42:23 (854 messages postés) -

❤ 0

Ex Couteau Suisse Agréé

Ah je vois ! Donc j'ai juste à reproduire les étapes de ton tuto sur ce script ?
Désolée si ma question paraissait stupide, c'est vrai qu'expliqué comme ça, ça semble plus flexible et abordable pour les gens qui sont pas des As en scripts.

Non, le tuto est clair, peut-être juste l'étape 3 où j'ai vu ta ligne et la mienne, et c'était pas les mêmes (moi j'avais des chiffres) du coup je me suis demandée si je devais recopier bêtement ou replacer les chiffres là où il fallait... :doute5
Du coup c'est cool que tu aie changé ça.

Mais y a encore des gens qui parlent de moi sous "Loly74" ? Ca me fait marrer.
Bon faut dire, j'ai disparu du site pendant des années.

Sylvan Melody, c'est par ici ! | Mes Musiques! | Le making, c'est réaliser le meilleur jeu du monde... à vos yeux."Les RTP c'est quand même très limité. Quand on réalise un jeu, on réalise un univers qui va avec, et cet univers il passe beaucoup par les graphismes, et l'identité qu'on leur donne."


Roi of the Suisse - posté le 15/09/2022 à 16:46:03 (29766 messages postés) - honor -

❤ 0

Alerte neige !

Tu me diras si tu as réussi à appliquer mes modifs sur ton script Advanced machin.
Si tu as du mal, je pourrai peut-être t'aider, mais selon la tête du script, je ne promets rien :lol

L'essentialisme c'est quand ta voiture a un moteur essence. | Es-tu une star ? | Kujira no Hara | Polaris 03 | Planète Glutko


Ardonie - posté le 15/09/2022 à 17:10:26 (854 messages postés) -

❤ 0

Ex Couteau Suisse Agréé

J'essaye, mais ça fait crasher le jeu dès que je lance une boîte de dialogue...

Sylvan Melody, c'est par ici ! | Mes Musiques! | Le making, c'est réaliser le meilleur jeu du monde... à vos yeux."Les RTP c'est quand même très limité. Quand on réalise un jeu, on réalise un univers qui va avec, et cet univers il passe beaucoup par les graphismes, et l'identité qu'on leur donne."


Roi of the Suisse - posté le 15/09/2022 à 17:52:33 (29766 messages postés) - honor -

❤ 0

Alerte neige !

J'ai jeté un coup d'oeil au script en question, ouais il est un petit peu différent, on ne peut pas appliquer mes modifications sans réfléchir.

Déjà text est remplacé par @now_text, ensuite il sépare la boucle "while c != nil" en "while true" puis "if c != nil", et enfin le draw_text est décuplé et déplacé dans le update :lol
Faut savoir ce qu'on fait quand on y touche, c'est pas anodin.

L'essentialisme c'est quand ta voiture a un moteur essence. | Es-tu une star ? | Kujira no Hara | Polaris 03 | Planète Glutko


Ardonie - posté le 15/09/2022 à 17:55:38 (854 messages postés) -

❤ 0

Ex Couteau Suisse Agréé

Oui, j'ai vu cette différence ! Donc je pourrais remplacer Window_Message par ce script si je le voulais, si je comprends bien ?

Sylvan Melody, c'est par ici ! | Mes Musiques! | Le making, c'est réaliser le meilleur jeu du monde... à vos yeux."Les RTP c'est quand même très limité. Quand on réalise un jeu, on réalise un univers qui va avec, et cet univers il passe beaucoup par les graphismes, et l'identité qu'on leur donne."


Roi of the Suisse - posté le 15/09/2022 à 18:05:23 (29766 messages postés) - honor -

❤ 0

Alerte neige !

Essaye avec ce Advanced Message là :

Portion de code : Tout sélectionner

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
# ▼▲▼ XRXS 9. メッセージ表示フルグレードアップ ver..12d ▼▲▼
# Original Script by  桜雅 在土, 和希, RaTTiE
# Script from: http://f26.aaacafe.ne.jp/~xxms/RPGXP_XRXS9.htm
#
#Advanced Version by: dubealex
#
#To fInd all my NEW features, press CONTROL+F and search for the word "#NEW"
#To found the code where the "Skip Letter By Letter mode", search for "# SKIP"
#
# You can found all the command list on my website
# rmxp.dubealex.com
# Go in the "Script" section.
 
 
#==============================================================================
# ■ Window_Message
#==============================================================================
class Window_Message < Window_Selectable
# 一文字ずつ描写
DEFAULT_TYPING_ENABLE = true                # falseにすると瞬間表示
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias xrxs9_initialize initialize
def initialize
  
   $defaultfonttype = "Tahoma"
   $defaultfontsize = 24
   
   # IF for any reasons the FONT doesn't appears in your game, this is
   # because you are using a different version of RMXP. Look in the class MAIN
   # (under this one)
   # Go at line #10 and #12, and just copy the word that begins with a $ sign
   # and replace what is after the equal sign on lign #27 and 28 of this class.
 
  xrxs9_initialize
  # 再生サウンド名がない場合は""とする
  if $soundname_on_speak == nil then
    $soundname_on_speak = ""
  end
  # 外字ファイルパス設定
  $gaiji_file = "./Graphics/Gaiji/sample.png"
  # 外字データ読み込み
  if FileTest.exist?($gaiji_file)
    @gaiji_cache = Bitmap.new($gaiji_file)
  else
    @gaigi_cache = nil
  end
  # 文字透過転送用バッファ
  @opacity_text_buf = Bitmap.new(32, 32)
end
#--------------------------------------------------------------------------
# ● メッセージ終了処理
#--------------------------------------------------------------------------
alias xrxs9_terminate_message terminate_message
def terminate_message
  if @name_window_frame != nil
    @name_window_frame.dispose
    @name_window_frame = nil
  end
  if @name_window_text  != nil
    @name_window_text.dispose
    @name_window_text  = nil
  end
  xrxs9_terminate_message
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
  # 初期化
  self.contents.clear
  self.contents.font.color = normal_color
  self.contents.font.name = $fontface
  @x = @y = @max_x = @max_y = @indent = @lines = 0
  @face_indent = 0
  @opacity = 255
  @cursor_width = 0
  @write_speed = 0
  @write_wait = 0
  @mid_stop = false
  @face_file = nil
  # @popchar が -2 の場合、標準位置。-1の場合、文字センター。
  # 0以上の場合 キャラポップ。0は主人公、1以降はイベント。
  @popchar = -2
  # 選択肢なら字下げを行う
  if $game_temp.choice_start == 0
    @x = 8
  end
  # 表示待ちのメッセージが・る場合
  if $game_temp.message_text != nil
    @now_text = $game_temp.message_text
        
          # Est-ce que le texte doit onduler ?
      @le_texte_doit_onduler = false
      if @now_text['\\WAVE ']
        @now_text = @now_text.gsub('\\WAVE ', '')
        @le_texte_doit_onduler = true
      end
      # Est-ce que le texte doit trembler ?
      @le_texte_doit_trembler = false
      if @now_text['\\SHAKE ']
        @now_text = @now_text.gsub('\\SHAKE ', '')
        @le_texte_doit_trembler = true
      end
        
    # 顔表示指定\Fが・るか?
    if (/\A\\[Ff]\[(.+?)\]/.match(@now_text))!=nil then
      # ファイルチェック
      if FileTest.exist?("Graphics/Pictures/" + $1 + ".png")
        # 顔グラを描画
        @face_file = $1 + ".png"
        self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
        # 全行 128ピクセルのインデントを入れる。
        @x = @face_indent = 128
      end
      @now_text.gsub!(/\\[Ff]\[(.*?)\]/) { "" }
    end
    # 制御文字処理
    begin
    last_text = @now_text.clone
    # \Vを独自ルーチンに変更(追加部分)
    @now_text.gsub!(/\\[Vv]\[([IiWwAaSs]?)([0-9]+)\]/) { convart_value($1, $2.to_i) }
    end until @now_text == last_text
    @now_text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
      $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
     end
    
    #NEW
    #Dubealex Show Monster Name Feature
     @now_text.gsub!(/\\[Mm]\[([0-9]+)\]/) do
       $data_enemies[$1.to_i] != nil ? $data_enemies[$1.to_i].name : ""
     end
     #End new command
     
    #NEW
    #Dubealex Show Item Price Feature
     @now_text.gsub!(/\\[Pp]rice\[([0-9]+)\]/) do
       $data_items[$1.to_i] != nil ? $data_items[$1.to_i].price : ""
     end
     #End new command
     
    #NEW
    #Dubealex Show Hero Class Name Feature
     @now_text.gsub!(/\\[Cc]lass\[([0-9]+)\]/) do
       $data_classes[$data_actors[$1.to_i].class_id] != nil ? $data_classes[$data_actors[$1.to_i].class_id].name : ""
     end
     #End new command
     
    #NEW
    #Dubealex Show Current Map Name Feature
     @now_text.gsub!(/\\[Mm]ap/) do
       $game_map.name    != nil ? $game_map.name    : ""
     end
     #End new command
     
    # \nameが・るか?
    name_window_set = false
    if (/\\[Nn]ame\[(.+?)\]/.match(@now_text)) != nil
      # 値を設定
      name_window_set = true
      name_text = $1
      # \name[]部分を削除
      @now_text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
    end
    # ウィンドウ位置判定
    if (/\\[Pp]\[([-1,0-9]+)\]/.match(@now_text))!=nil then
      @popchar = $1.to_i
      if @popchar == -1
        @x = @indent = 48
        @y = 4
      end
      @now_text.gsub!(/\\[Pp]\[([-1,0-9]+)\]/) { "" }
    end
    # ウィンドウ幅の取得
    @max_choice_x = 0
    if @popchar >= 0
      @text_save = @now_text.clone
      @max_x = 0
      @max_y = 4
      for i in 0..3
        line = @now_text.split(/\n/)[3-i]
        @max_y -= 1 if line == nil and @max_y <= 4-i
        next if line == nil
        line.gsub!(/\\\w\[(\w+)\]/) { "" }
        cx = contents.text_size(line).width
        @max_x = cx if cx > @max_x
        if i >= $game_temp.choice_start
          @max_choice_x = cx if cx > @max_choice_x
        end
      end
      self.width = @max_x + 32 + @face_indent
      self.height = (@max_y - 1) * 32 + 64
      @max_choice_x -= 68
      @max_choice_x -= @face_indent*216/128
    else
      @max_x = self.width - 32 - @face_indent
      for i in 0..3
        line = @now_text.split(/\n/)[i]
        next if line == nil
        line.gsub!(/\\\w\[(\w+)\]/) { "" }
        cx = contents.text_size(line).width
        if i >= $game_temp.choice_start
          @max_choice_x = cx if cx > @max_choice_x
        end
      end
      @max_choice_x += 8
    end
    # 選択肢ならカーソルの幅を更新
    @cursor_width = 0
    #if @lines >= $game_temp.choice_start
    #  @cursor_width = [@cursor_width, @max_choice_x - @face_indent].max
    #end
    # 便宜上、"\\\\" を "\000" に変換
    @now_text.gsub!(/\\\\/) { "\000" }
    # "\\C" を "\001" に、"\\G" を "\002" に、
    # "\\S" を "\003" に、"\\A" を "\004" に変換
    @now_text.gsub!(/\\[Cc]\[([0123456789ABCDEF#]+)\]/) { "\001[#{$1}]" }
    @now_text.gsub!(/\\[Gg]/) { "\002" }
    @now_text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" }
    @now_text.gsub!(/\\[Aa]\[(.*?)\]/) { "\004[#{$1}]" }
    
     #NEW 
     #Dubealex Font Change Features
     @now_text.gsub!(/\\[Tt]\[(.*?)\]/) { "\050[#{$1}]" }
     #End of dubealex feature
    
    @now_text.gsub!(/\\[.]/) { "\005" }
    @now_text.gsub!(/\\[|]/) { "\006" }
    # 競合すると何かと気まずいので、\016以降を使用する
    @now_text.gsub!(/\\[>]/) { "\016" }
    @now_text.gsub!(/\\[<]/) { "\017" }
    @now_text.gsub!(/\\[!]/) { "\020" }
    @now_text.gsub!(/\\[~]/) { "\021" }
    @now_text.gsub!(/\\[Ee]\[([0-9]+)\]/) { "\022[#{$1}]" }
    # インデント設定(追加部分)
    @now_text.gsub!(/\\[Ii]/) { "\023" }
    # テキスト透過率指定(追加部分)
    @now_text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
    # テキストサイズ指定(追加部分)
    @now_text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
    # 空白挿入(追加部分)
    @now_text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
    # ルビ表示(追加部分)
    @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "\027[#{$1}]" }
    # ここで一旦ウィンドウ位置更新
    reset_window
    # \nameが・るか?
    if name_window_set
      # オフセット位置
      off_x =  0
      off_y =  -10
      # 枠だけウィンドウの作成(余白を 2 に設定)
      space = 2
      x = self.x + off_x - space / 2
      y = self.y + off_y - space / 2
      w = self.contents.text_size(name_text).width + 8 + space
      h = 26 + space
      @name_window_frame = Window_Frame.new(x, y, w, h)
      @name_window_frame.z = self.z + 1
      # 擬似的な空中文字描写ウィンドウを作成
      x = self.x + off_x + 4
      y = self.y + off_y
      @name_window_text  = Air_Text.new(x, y, name_text)
      @name_window_text.z = self.z + 2
    end
  end
  # ウィンドウを更新
  reset_window
  # 選択肢の場合
  if $game_temp.choice_max > 0
    @item_max = $game_temp.choice_max
    self.active = true
    self.index = 0
  end
  # 数値入力の場合
  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
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
  super
  # フェードインの場合
  if @fade_in
    self.contents_opacity += 24
    if @input_number_window != nil
      @input_number_window.contents_opacity += 24
    end
    if self.contents_opacity == 255
      @fade_in = false
    end
    return
  end
  @now_text = nil if @now_text == "" # 変換
  # 表示待ちのメッセージが・る場合
  if @now_text != nil and @mid_stop == false
    if @write_wait > 0
      @write_wait -= 1
      return
    end
    text_not_skip = DEFAULT_TYPING_ENABLE
    while true
      # 最大 x y の保存。
      @max_x = @x if @max_x < @x
      @max_y = @y if @max_y < @y
      # c に 1 文字を取得 (文字が取得できなくなるまでループ)
          numero_du_caractere = 0 # pour les animations de texte (ondulation, tremblement)
      if (c = @now_text.slice!(/./m)) != nil
          
            numero_du_caractere += 1
        # Ondulation
        if @le_texte_doit_onduler
          amplitude = 3
          frequence = 0.5
          ondulation = (amplitude * Math.sin((numero_du_caractere + Graphics.frame_count) * frequence) ).round
        else
          ondulation = 0
        end
        # Tremblement
        if @le_texte_doit_trembler
          frequence = 1
          amplitude = 1.5
          angle_aleatoire = (numero_du_caractere + 27.5) * (numero_du_caractere + 57.3) % 100
          dx = Math.sin(angle_aleatoire)
          dy = Math.cos(angle_aleatoire)
          tremblement_x = (amplitude * dx * Math.sin(Graphics.frame_count * frequence) ).round
          tremblement_y = (amplitude * dy * Math.sin(Graphics.frame_count * frequence) ).round
        else
          tremblement_x = 0
          tremblement_y = 0
        end
          
        # \\ の場合
        if c == "\000"
          # 本来の文字に戻す
          c = "\\"
        end
        # \C[n] の場合
        
        if c == "\001"
          @now_text.sub!(/\[([0123456789ABCDEF#]+)\]/, "")
          temp_color = $1
          color = temp_color.to_i
          leading_x = temp_color.to_s.slice!(/./m)
          if leading_x == "#"
            self.contents.font.color = hex_color(temp_color)
            next
          end
          if color >= 0 and color <= 7
            self.contents.font.color = text_color(color)
          end
          next
        end
 
        # \G の場合
        if c == "\002"
          # ゴールドウィンドウを作成
          if @gold_window == nil and @popchar <= 0
            @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
          # 次の文字へ
          c = ""
        end
        # \S[n] の場合
        if c == "\003"
          # 文字色を変更
          @now_text.sub!(/\[([0-9]+)\]/, "")
          speed = $1.to_i
          if speed >= 0 and speed <= 19
            @write_speed = speed
          end
          # 次の文字へ
          c = ""
        end
        # \A[soundname] の場合
        if c == "\004"
          # 再生ファイルを変更するための準備
          @now_text.sub!(/\[(.*?)\]/, "")
          buftxt = $1.dup.to_s
          # 再生ファイル名に"/"が・るか?
          if buftxt.match(/\//) == nil and buftxt != "" then
            # なければ"Audio/SE/"を結合する
            $soundname_on_speak = "Audio/SE/" + buftxt
          else
            # ・ればそのままコピー
            $soundname_on_speak = buftxt.dup
          end
          # 次の文字へ
          c = ""
        elsif c == "\004" 
          # 次の文字へ
          c = ""
        end
        # \. の場合
        if c == "\005"
          @write_wait += 5
          c = ""
        end
        # \| の場合
        if c == "\006"
          @write_wait += 20
          c = ""
        end
        # \> の場合
        if c == "\016"
          text_not_skip = false
          c = ""
        end
        # \<の場合
        if c == "\017"
          text_not_skip = true
          c = ""
        end
        # \!の場合
        if c == "\020"
          @mid_stop = true
          c = ""
        end
        # \~の場合
        if c == "\021"
          terminate_message
          return
        end
        # \Iの場合(追加部分)
        if c == "\023"
          # 今の@xをインデント位置に設定
          @indent = @x
          c = ""
        end
        # \Oの場合(追加部分)
        if c == "\024"
          @now_text.sub!(/\[([0-9]+)\]/, "")
          @opacity = $1.to_i
          color = self.contents.font.color
          self.contents.font.name = $fontface
          self.contents.font.color = Color.new(color.red, color.green, color.blue, color.alpha * @opacity / 255)
          c = ""
        end
        # \Hの場合(追加部分)
        if c == "\025"
          @now_text.sub!(/\[([0-9]+)\]/, "")
          self.contents.font.size = [[$1.to_i, 6].max, 32].min
          c = ""
        end
        # \Bの場合(追加部分)
        if c == "\026"
          @now_text.sub!(/\[([0-9]+)\]/, "")
          @x += $1.to_i
          c = ""
        end
        
        #NEW
        #Dubealex Font Change Command
         if c == "\050" 
           @now_text.sub!(/\[(.*?)\]/, "")
           buftxt = $1.dup.to_s
           if buftxt.match(/\//) == nil and buftxt != "" then
             self.contents.font.name = buftxt
           end
           c = ""
           end
         #end of font change command
        
        # \Rの場合(追加部分)
        if c == "\027"
          @now_text.sub!(/\[(.*?)\]/, "")
          # 文字を描画
          @x += ruby_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), $1, @opacity)
          # 文字描写のSEを演奏
          if $soundname_on_speak != ""
            Audio.se_play($soundname_on_speak)
          end
          c = ""
        end
        # アイコン描画用シーケンスの場合(追加部分)
        if c == "\030"
          # アイコンファイル名を取得
          @now_text.sub!(/\[(.*?)\]/, "")
          # アイコンを描画
          self.contents.blt(@x , @y * line_height + 8, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
          # 文字描写のSEを演奏
          if $soundname_on_speak != ""
            Audio.se_play($soundname_on_speak)
          end
          @x += 24
          # 次の文字へ
          c = ""
        end
        # 改行文字の場合
        if c == "\n"
          # y に 1 を加算
          @lines += 1
          @y += 1
          @x = 0 + @indent + @face_indent
          # 選択肢なら字下げを行う
          if @lines >= $game_temp.choice_start
            @x = 8 + @indent + @face_indent
            # カーソルの更新
            @cursor_width = @max_choice_x
          end
          # 次の文字へ
          c = ""
        end
        # 外字表示の場合
        if c == "\022"
          # []部分の除去
          @now_text.sub!(/\[([0-9]+)\]/, "")
          # 外字を表示
          @x += gaiji_draw(4 + @x, @y * line_height + (line_height - self.contents.font.size), $1.to_i)
          # 次の文字へ
          c = ""
        end
        if c != ""
          # 文字を描画
          self.contents.draw_text(0 + @x + tremblement_x, 32 * @y + ondulation + tremblement_y, 40, 32, c)
          @x += self.contents.text_size(c).width
          # 文字描写のSEを演奏
          if $soundname_on_speak != "" then
            Audio.se_play($soundname_on_speak)
          end
        end
        # Bボタンが押された場合
        
    # SKIP
    # This allow you to SKIP the letter by letter using a button
    # At your own choice
    # Here's how to customize it:
    # Replace the letter in the end of the line "if Input.trigger?(Input::C)"
    # That is on line #512
    # By the letter of your choice:
    #
    # B = Escape, 0 (On The NumPad), X 
    # C = Enter, Space Bar and C
    # A = Shift, Z 
        if Input.press?(Input::C)
          text_not_skip = false
        end
      else
        text_not_skip = true
        break
      end
      # 終了判定
      if text_not_skip
        break
      end
    end
    @write_wait += @write_speed
    return
  end
  # 数値入力中の場合
  if @input_number_window != nil
    @input_number_window.update
    # 決定
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      $game_variables[$game_temp.num_input_variable_id] =
        @input_number_window.number
      $game_map.need_refresh = true
      # 数値入力ウィンドウを解放
      @input_number_window.dispose
      @input_number_window = nil
      terminate_message
    end
    return
  end
  # メッセージ表示中の場合
  if @contents_showing
    # 選択肢の表示中でなければポーズサインを表示
    if $game_temp.choice_max == 0
      self.pause = true
    end
    
    
    if Input.trigger?(Input::B)
      if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
        $game_system.se_play($data_system.cancel_se)
        $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
        terminate_message
      end
    end
    
    if Input.trigger?(Input::C)
      if $game_temp.choice_max > 0
        $game_system.se_play($data_system.decision_se)
        $game_temp.choice_proc.call(self.index)
      end
      if @mid_stop
        @mid_stop = false
        return
      else
        terminate_message
      end
    end
 
    return
  end
  # フェードアウト中以外で表示待ちのメッセージか選択肢が・る場合
  if @fade_out == false and $game_temp.message_text != nil
    @contents_showing = true
    $game_temp.message_window_showing = true
    refresh
    Graphics.frame_reset
    self.visible = true
    self.contents_opacity = 0
    if @input_number_window != nil
      @input_number_window.contents_opacity = 0
    end
    @fade_in = true
    return
  end
  # 表示すべきメッセージがないが、ウィンドウが可視状態の場合
  if self.visible
    @fade_out = true
    self.opacity -= 48
    if self.opacity == 0
      self.visible = false
      @fade_out = false
      $game_temp.message_window_showing = false
    end
    return
  end
end
#--------------------------------------------------------------------------
# ● キャラクターの取得
#     parameter : パラメータ
#--------------------------------------------------------------------------
def get_character(parameter)
  # パラメータで分岐
  case parameter
  when 0  # プレイヤー
    return $game_player
  else  # 特定のイベント
    events = $game_map.events
    return events == nil ? nil : events[parameter]
  end
end
#--------------------------------------------------------------------------
# ● ウィンドウの位置と不透明度の設定
#--------------------------------------------------------------------------
def reset_window
  # 判定
  if @popchar >= 0
    events = $game_map.events
    if events != nil
      character = get_character(@popchar)
      x = [[character.screen_x -  0 - self.width / 2, 4].max, 636 - self.width].min
      y = [[character.screen_y - 48 - self.height, 4].max, 476 - self.height].min
      self.x = x
      self.y = y
    end
  elsif @popchar == -1
    self.x = -4
    self.y = -4
    self.width = 648
    self.height = 488
  else
    if $game_temp.in_battle
      self.y = 16
    else
      case $game_system.message_position
      when 0  # 上
        self.y = 16
      when 1  # 中
        self.y = 160
      when 2  # 下
        self.y = 304
      end
      self.x = 80
      if @face_file == nil
        self.width = 480
      else
        self.width = 600
        self.x -= 60
      end
      self.height = 160
    end
  end
  self.contents = Bitmap.new(self.width - 32, self.height - 32)
  self.contents.font.color = normal_color
  self.contents.font.name = $fontface
  if @face_file != nil
    self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  end
  if @popchar == -1
    self.opacity = 255
    self.back_opacity = 0
  elsif $game_system.message_frame == 0
    self.opacity = 255
    self.back_opacity = 160
  else
    self.opacity = 0
    self.back_opacity = 160
  end
end
#--------------------------------------------------------------------------
# ● 外字描画
#--------------------------------------------------------------------------
# x   :x座標
# y   :y座標
# num  :外字番号
# 返り値:外字幅(@x増加値)
#--------------------------------------------------------------------------
def gaiji_draw(x, y, num)
  # 外字データが存在しない場合は何もしない
  if @gaiji_cache == nil
    return 0
  else
    # 指定した外字がキャッシュ範囲を超えている場合は何もしない
    if @gaiji_cache.width < num * 24
      return 0
    end
 
    # 文字サイズを計算
    if self.contents.font.size >= 20 and self.contents.font.size <= 24
      size = 24
    else
      size = self.contents.font.size * 100 * 24 / 2200
    end
 
    # 外字データをstretch_bltで転送
    self.contents.stretch_blt(Rect.new(x, y, size, size), @gaiji_cache, Rect.new(num * 24, 0, 24, 24))
 
    # 文字描写のSEを演奏
    if $soundname_on_speak != "" then
      Audio.se_play($soundname_on_speak)
    end
 
    # 文字サイズを返す
    return size
  end
end
#--------------------------------------------------------------------------
# ● line_height
#--------------------------------------------------------------------------
# 返り値:行の高さ(@y増加値)を返します。
#--------------------------------------------------------------------------
def line_height
  # 現状、選択肢等に対応ができない為、自動的に32を返します。
  return 32
 
  # 文字サイズを計算
  if self.contents.font.size >= 20 and self.contents.font.size <= 24
    return 32
  else
    return self.contents.font.size * 15 / 10
  end
end
#--------------------------------------------------------------------------
# ● ルビ文字描画
#--------------------------------------------------------------------------
# target :描画対象。Bitmapクラスを指定。
# x      :x座標
# y      :y座標
# str   :描画文字列。本文,ルビの形式で入力。
#      ,区切りが2つ以上・った場合は自動的に無視される。
# opacity:透過率(0~255)
# 返り値 :文字幅(@x増加値)。
#--------------------------------------------------------------------------
def ruby_draw_text(target, x, y, str,opacity)
  # フォントサイズをバックアップしておく
  sizeback = target.font.size
  # ルビサイズの計算
  target.font.size * 3 / 2 > 32 ? rubysize = 32 - target.font.size : rubysize = target.font.size / 2
  rubysize = [rubysize, 6].max
  
  # opacityに規定値以上の値が入っている場合は修正。
  opacity = [[opacity, 0].max, 255].min
  # strをsplitで分割し、split_sに格納
  split_s = str.split(/,/)
 
  # split_sがnilの場合は""にしておく(誤動作防止)
  split_s[0] == nil ? split_s[0] = "" : nil
  split_s[1] == nil ? split_s[1] = "" : nil
 
  # heightとwidthを計算
  height = sizeback + rubysize
  width  = target.text_size(split_s[0]).width
 
  # バッファ用の幅計算(ルビの幅が本文の幅を越える可能性が・る為)
  target.font.size = rubysize
  ruby_width = target.text_size(split_s[1]).width
  target.font.size = sizeback
 
  buf_width = [target.text_size(split_s[0]).width, ruby_width].max
 
  # 本文の描画幅とルビの描画幅の差を1/2にして変数に格納(後で使用)
  width - ruby_width != 0 ? sub_x = (width - ruby_width) / 2 : sub_x = 0
 
  # opacityが255(透過なし)の場合は通常描画
  if opacity == 255
  # ルビの描画
    target.font.size = rubysize
    target.draw_text(x + sub_x, y - target.font.size, target.text_size(split_s[1]).width, target.font.size, split_s[1])
    target.font.size = sizeback
  # 本文の描画
    target.draw_text(x, y, width, target.font.size, split_s[0])
    return width
  else
    # 表示テキストのheight、widthがバッファサイズを上回る場合は
    # バッファを再生成する。
    if @opacity_text_buf.width < buf_width or @opacity_text_buf.height < height
      @opacity_text_buf.dispose
      @opacity_text_buf = Bitmap.new(buf_width, height)
    # そうでない場合はバッファクリア。
    else
      @opacity_text_buf.clear
    end
    # バッファにテキスト描画
    # ルビの描画
    @opacity_text_buf.font.size = rubysize
    @opacity_text_buf.draw_text(0 , 0, buf_width, rubysize, split_s[1], 1)
    @opacity_text_buf.font.size = sizeback
    # 本文の描画
    @opacity_text_buf.draw_text(0 , rubysize, buf_width, sizeback, split_s[0], 1)
    # ルビの幅が本文の幅を下回る場合
    if sub_x >= 0
      target.blt(x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
    # ルビの幅が本文の幅を上回る場合
    else
      target.blt(x + sub_x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
    end
    # 文字サイズを返す
    return width
  end
end
#--------------------------------------------------------------------------
# ● \V変換
#--------------------------------------------------------------------------
# option :オプション。無指定又は規定外の場合はindexのユーザ変数値を返す。
# index  :インデックス
# 返り値 :変換結果(アイコン表示用シーケンス込み)
#--------------------------------------------------------------------------
def convart_value(option, index)
  # optionがnilの場合は""に直す(誤動作防止)
  option == nil ? option = "" : nil
 
  # optionはdowncaseしておく。
  option.downcase!
 
  # \030はアイコン表示用のシーケンス。\030[アイコンファイル名]で定義。
  case option
  when "i"
    unless $data_items[index].name == nil
      r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
    end
  when "w"
    unless $data_weapons[index].name == nil
      r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
    end
  when "a"
    unless $data_armors[index].name == nil
      r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
    end
  when "s"
    unless $data_skills[index].name == nil
      r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
    end
  else
    r = $game_variables[index]
  end
 
  r == nil ? r = "" : nil
  return r
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
  terminate_message
 
  # 外字キャッシュ開放
  if @gaiji_cache != nil
    unless @gaiji_cache.disposed?
      @gaiji_cache.dispose
    end
  end
 
  # 文字透過転送用バッファ開放
  unless @opacity_text_buf.disposed?
    @opacity_text_buf.dispose
  end
 
  $game_temp.message_window_showing = false
  if @input_number_window != nil
    @input_number_window.dispose
  end
  super
end
#--------------------------------------------------------------------------
# ● カーソルの矩形更新
#--------------------------------------------------------------------------
def update_cursor_rect
  if @index >= 0
    n = $game_temp.choice_start + @index
    self.cursor_rect.set(8 + @indent + @face_indent, n * 32, @cursor_width, 32)
  else
    self.cursor_rect.empty
  end
end
end
#==============================================================================
# ■ Window_Frame (枠だけで中身の無いウィンドウ)
#==============================================================================
class Window_Frame < Window_Base
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
  super(x, y, width, height)
  self.contents = nil
  #self.back_opacity = 240
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
  super
end
end
#==============================================================================
# ■ Air_Text (何も無いところに文字描写 = 枠の無い瞬間表示メッセージウィンドウ)
#==============================================================================
class Air_Text < Window_Base
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, designate_text)
  super(x-16, y-16, 32 + designate_text.size * 12, 56)
  self.opacity      = 0
  self.back_opacity = 0
  self.contents = Bitmap.new(self.width - 32, self.height - 32)
  w = self.contents.width
  h = self.contents.height
  self.contents.font.name = $fontface
  self.contents.font.color = normal_color
  self.contents.draw_text(0, 0, w, h, designate_text)
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
  self.contents.clear
  super
end
end


Je n'ai pas testé :F
Si ça ne marche pas, c'est qu'il faut provoquer l'actualisation quelque part, mais je ne sais pas encore où. Auquel cas c'est chiant, il faudra étudier le script plus en détail pour comprendre sa chronologie.

L'essentialisme c'est quand ta voiture a un moteur essence. | Es-tu une star ? | Kujira no Hara | Polaris 03 | Planète Glutko


Ardonie - posté le 15/09/2022 à 20:57:33 (854 messages postés) -

❤ 0

Ex Couteau Suisse Agréé

Alors c'est très marrant :
l'ondulation et le tremblement "fonctionnent", mais les caractères ne bougent plus !
Leur position est "fixe".
image

Sylvan Melody, c'est par ici ! | Mes Musiques! | Le making, c'est réaliser le meilleur jeu du monde... à vos yeux."Les RTP c'est quand même très limité. Quand on réalise un jeu, on réalise un univers qui va avec, et cet univers il passe beaucoup par les graphismes, et l'identité qu'on leur donne."


Roi of the Suisse - posté le 15/09/2022 à 21:23:58 (29766 messages postés) - honor -

❤ 0

Alerte neige !

Ah non mais en fait Advanced message affiche les messages caractère par caractère. C'est ça la philosophie du truc.
C'est pas compatible avec le tremblement ou l'ondulation, qui nécessitent que tout soit affiché d'un seul coup.
Enfin, Advanced Message n'est pas du tout prévu pour ça à la base. Faudrait le refaire en entier. Et c'est pas quelque chose pour lequel j'ai le temps.
Tu vas devoir choisir entre les deux je crois :-/


Faire une pause au milieu d'un message, ça ne peut pas se faire en mettant deux messages successifs, le second avec la suite ?

MESSAGE : Bonjour Jean-
MESSAGE : Bonjour Jean-Robert comment allez-
MESSAGE : Bonjour Jean-Robert comment allez-vous ?


Ça ne fait pas la même chose ?


Ce script te permet de changer de police en plein dialogue, ça permet peut-être de donner plus de personnalité à tes dialogues ?

https://www.rpg-maker.fr/scripts-213-changement-de-police-en-plein-dialogue.html

Probablement pas compatible avec Advanced Messages...

L'essentialisme c'est quand ta voiture a un moteur essence. | Es-tu une star ? | Kujira no Hara | Polaris 03 | Planète Glutko


Zam - posté le 15/09/2022 à 23:22:02 (5505 messages postés) - staff

❤ 2

Roi of the Suisse a dit:



image



Oh là là, le leak de Polaris 04.


Ardonie - posté le 15/09/2022 à 23:55:29 (854 messages postés) -

❤ 0

Ex Couteau Suisse Agréé

Miiince...C'est dommage qu'on ne puisse pas avoir les deux en même temps !

Bon, bon, bon....

En tout cas, merci de m'avoir consacré de ton temps et partagé tes connaissances.
Moi qui n'y connais rien en script, ça a bien éclairé ma lanterne.
Je vais réfléchir sur quelles features je veux me focaliser.
tiens-moi au courant si jamais tu trouves le temps de modifier ce script.

montrer une partie du message dans une première fenêtre, attendre l'appui de la touche action, puis remontrer le même début du message accompagné de sa suite, c'est une méthode qui fonctionne si on omet l'affichage de texte caractère par caractère. Aussi faut que le joueur appuie sur la touche action autant de fois que nécessaire.

Sylvan Melody, c'est par ici ! | Mes Musiques! | Le making, c'est réaliser le meilleur jeu du monde... à vos yeux."Les RTP c'est quand même très limité. Quand on réalise un jeu, on réalise un univers qui va avec, et cet univers il passe beaucoup par les graphismes, et l'identité qu'on leur donne."

Index du forum > Entraide > [RESOLU] [RMXP] Cherche à faire onduler ou trembler le texte

repondre up

Suite à de nombreux abus, le post en invités a été désactivé. Veuillez vous inscrire si vous souhaitez participer à la conversation.

Haut de page

Merci de ne pas reproduire le contenu de ce site sans autorisation.
Contacter l'équipe - Mentions légales

Plan du site

Communauté: Accueil | Forum | Chat | Commentaires | News | Flash-news | Screen de la semaine | Sorties | Tests | Gaming-Live | Interviews | Galerie | OST | Blogs | Recherche
Apprendre: Visite guidée | RPG Maker 95 | RPG Maker 2003 | RPG Maker XP | RPG Maker VX | RPG Maker MV | Tutoriels | Guides | Making-of
Télécharger: Programmes | Scripts/Plugins | Ressources graphiques / sonores | Packs de ressources | Midis | Eléments séparés | Sprites
Jeux: Au hasard | Notre sélection | Sélection des membres | Tous les jeux | Jeux complets | Le cimetière | RPG Maker 95 | RPG Maker 2000 | RPG Maker 2003 | RPG Maker XP | RPG Maker VX | RPG Maker VX Ace | RPG Maker MV | Autres | Proposer
Ressources RPG Maker 2000/2003: Chipsets | Charsets | Panoramas | Backdrops | Facesets | Battle anims | Battle charsets | Monstres | Systems | Templates
Ressources RPG Maker XP: Tilesets | Autotiles | Characters | Battlers | Window skins | Icônes | Transitions | Fogs | Templates
Ressources RPG Maker VX: Tilesets | Charsets | Facesets | Systèmes
Ressources RPG Maker MV: Tilesets | Characters | Faces | Systèmes | Title | Battlebacks | Animations | SV/Ennemis
Archives: Palmarès | L'Annuaire | Livre d'or | Le Wiki | Divers