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
| #==============================================================================
# ■ [XP] Options
#==============================================================================
# » Modifié par : Voximilien
# » Version : 1.0
#
# » Scripts d'origine :
# - Game Options par Ayene : http://www.ultimateam.pl/tagteam/rgss/game-options-xp.html
# - Audio Settings par EJlol : http://save-point.org/thread-2439.html
#==============================================================================
#
# » Description :
# Le script ajoute un menu Options.
# Vous pourrez ajuster le volume du BGM, BGS, ME, et SE.
#
#
# » Installation :
#
# - Mettre ce script au dessus de Main.
#
# - Modifiez Scene_Menu en y ajoutant (vers la ligne 24)
# s6 = "Options"
#
# - Modifiez Scene_Menu en changeant cette ligne (vers la ligne 26)
# s7 = "Quitter le jeu"
# Il faut juste changer le s6 en s7 comme ci-dessus.
#
# - Modifiez Scene_Menu en y ajoutant s7 dans la liste entre crochets. (vers la ligne 27)
# @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
#
# - Modifiez Scene_Menu en y ajoutant (vers les lignes 160)
# when 5 # Options
# $game_system.se_play($data_system.decision_se)
# $scene = Scene_Option.new
#
# - Modifiez Scene_Menu en changeant cette ligne (vers la ligne 165)
# when 6 # End game
# Il faut juste changer le when 5 en when 6 comme ci-dessus.
#
#==============================================================================
#
# Si vous désirez faire apparaître les Options avec la commande
# "Insérer un script", utilisez la commande suivante :
#
# $scene = Scene_Option.new
#
#==============================================================================
module AYENE
# Nom du fichier avec les options de jeu qui seront sauvegardé (créé un fichier supplémentaire)
FILENAME = "Options"
# Principales options de jeu
OPTION_COMMANDS = [
"Volume BGM",
"Volume BGS",
"Volume ME",
"Volume SE"
]
# Texte qui va décrire chaque commande ci-dessus.
OPTION_HELP = [
"Ajuste le volume de la musique.",
"Ajuste le volume des sons d'ambiances.",
"Ajuste le volume des ME.",
"Ajuste le volume des SE."
]
end
#==============================================================================
# ** Game_Option
#==============================================================================
class Game_Option
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :bgm_volume
attr_accessor :bgs_volume
attr_accessor :me_volume
attr_accessor :se_volume
#------------------------------------------------------------------------
# * Alias Listings
#------------------------------------------------------------------------
unless self.method_defined?(:ejlol_as_gsystem_initialize)
alias_method :ejlol_as_gsystem_initialize, :initialize
end
#--------------------------------------------------------------------------
# * Initialisation de l'objet
#--------------------------------------------------------------------------
def initialize
ejlol_as_gsystem_initialize
# Volume par défaut
@bgm_volume = 30 # 0 ~ 100
@bgs_volume = 30 # 0 ~ 100
@me_volume = 30 # 0 ~ 100
@se_volume = 35 # 0 ~ 100
@filename = AYENE::FILENAME + ".rxdata"
end
#--------------------------------------------------------------------------
# * Sauvegarde des Options
#--------------------------------------------------------------------------
def save
file = File.open(@filename, "wb")
Marshal.dump($game_option, file)
file.close
end
#--------------------------------------------------------------------------
# * Chargement des Options
#--------------------------------------------------------------------------
def load
if FileTest.exist?(@filename)
file = File.open(@filename, "rb")
$game_option = Marshal.load(file)
file.close
end
end
end
#==============================================================================
# ** Game_System
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Change backgroundmusic volume
# volume : the volume
#--------------------------------------------------------------------------
def bgm_volume=(volume)
@bgm_volume = [[volume, 100].min, 0].max
bgm_play(@playing_bgm)
end
#--------------------------------------------------------------------------
# * Change backgroundsound volume
# volume : the volume
#--------------------------------------------------------------------------
def bgs_volume=(volume)
@bgs_volume = [[volume, 100].min, 0].max
bgs_play(@playing_bgs)
end
#--------------------------------------------------------------------------
# * Change ME volume
# volume : the volume
#--------------------------------------------------------------------------
def me_volume=(volume)
@me_volume = [[volume, 100].min, 0].max
me_play(@playing_me)
end
#--------------------------------------------------------------------------
# * Change SE volume
# volume : the volume
#--------------------------------------------------------------------------
def se_volume=(volume)
@se_volume = [[volume, 100].min, 0].max
se_play(@playing_se)
end
end
#==============================================================================
# ** Audio
#==============================================================================
module Audio
class << self
#------------------------------------------------------------------------
# * Alias Listings
#------------------------------------------------------------------------
unless self.method_defined?(:ejlol_as_audio_bgmplay)
alias_method :ejlol_as_audio_bgmplay, :bgm_play
alias_method :ejlol_as_audio_bgsplay, :bgs_play
alias_method :ejlol_as_audio_meplay, :me_play
alias_method :ejlol_as_audio_seplay, :se_play
end
#------------------------------------------------------------------------
# * BGM Play
#------------------------------------------------------------------------
def bgm_play(filename, volume = 100, pitch = 100)
volume = Integer(volume * $game_option.bgm_volume / 100.0)
# Original BGM Play Method
ejlol_as_audio_bgmplay(filename, volume, pitch)
end
#------------------------------------------------------------------------
# * BGS Play
#------------------------------------------------------------------------
def bgs_play(filename, volume = 80, pitch = 100)
volume = Integer(volume * $game_option.bgs_volume / 100.0)
# Original BGS Play Method
ejlol_as_audio_bgsplay(filename, volume, pitch)
end
#------------------------------------------------------------------------
# * ME Play
#------------------------------------------------------------------------
def me_play(filename, volume = 100, pitch = 100)
volume = Integer(volume * $game_option.me_volume / 100.0)
# Original ME Play Method
ejlol_as_audio_meplay(filename, volume, pitch)
end
#------------------------------------------------------------------------
# * SE Play
#------------------------------------------------------------------------
def se_play(filename, volume = 80, pitch = 100)
volume = Integer(volume * $game_option.se_volume / 100.0)
# Original SE Play Method
ejlol_as_audio_seplay(filename, volume, pitch)
end
end
end
#==============================================================================
# ** Window_VolCommand
#==============================================================================
class Window_VolCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(y, type)
super(200, y, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
@type = type
refresh
self.index = -1
self.opacity = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
case @type
when 0
vol = $game_option.bgm_volume
when 1
vol = $game_option.bgs_volume
when 2
vol = $game_option.me_volume
when 3
vol = $game_option.se_volume
end
w = 150
max = 100
rate = (vol < max ? vol * w / max : w) * (w/100)
color1 = Color.new(24, 184, 70, 192)
color2 = Color.new(0, 0, 80, 192)
self.contents.gradient_bar_volume(4, 8, w, color1, color2, rate)
text = sprintf("%d%%", vol)
self.contents.draw_text(w+20, 0, 76, 32, text, 0)
end
end
#==============================================================================
# ** Scene_Title
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
alias aye_sctitle_main main
def main
filename = AYENE::FILENAME + ".rxdata"
if FileTest.exist?(filename)
file = File.open(filename, "rb")
$game_option = Marshal.load(file)
file.close
$game_option.load
else
$game_option = Game_Option.new
$game_option.save
end
aye_sctitle_main
end
end
#==============================================================================
# ** Scene_Option
#==============================================================================
class Scene_Option
include AYENE
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@dummy_window = Window_Base.new(0, 64, 640, 416)
# Command Window
@command_window = Window_Command.new(640, OPTION_COMMANDS) # Le 640 est la largeur de la séléction
@command_window.x = 0
@command_window.y = 64
@command_window.opacity = 0
# Volume
@bgs = $game_option.bgs_volume
@bgm = $game_option.bgm_volume
@me = $game_option.me_volume
@se = $game_option.se_volume
# Help Window
@help_window = Window_Help.new
@help_window.set_text(OPTION_HELP[@command_window.index])
@help_window.x = 0
@help_window.y = 0
@sub_command_window = []
y = 64
4.times {|i|
@sub_command_window.push(Window_VolCommand.new(y, i))
y += 32
}
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@command_window.dispose
@help_window.dispose
@dummy_window.dispose
for i in @sub_command_window
i.dispose
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
@command_window.update
if @command_window.active
update_command
end
@help_window.set_text(OPTION_HELP[@command_window.index])
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# Si bouton B est pressé
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(5) # <- Sur quel menu vous allez revenir après avoir quitté les Options.
@command_window.active = true
@sub_command_window[@command_window.index].active = false
@sub_command_window[@command_window.index].index = -1
return
end
# Si bouton C est pressé
case @command_window.index
when 0 # Volume BGM
@bgm = $game_option.bgm_volume
$game_option.save
if Input.press?(Input::RIGHT) and $game_option.bgm_volume < 100
$game_option.bgm_volume += 1
$game_system.bgm_play($game_system.bgm_memorize)
@sub_command_window[@command_window.index].refresh
elsif Input.press?(Input::LEFT) and $game_option.bgm_volume > 0
$game_option.bgm_volume -= 1
$game_system.bgm_play($game_system.bgm_memorize)
@sub_command_window[@command_window.index].refresh
end
# -------------------------------------------------------------------------
when 1 # Volume BGS
@bgs = $game_option.bgs_volume
$game_option.save
if Input.press?(Input::RIGHT) and $game_option.bgs_volume < 100
$game_option.bgs_volume += 1
$game_system.bgs_play($game_system.bgs_memorize)
@sub_command_window[@command_window.index].refresh
elsif Input.press?(Input::LEFT) and $game_option.bgs_volume > 0
$game_option.bgs_volume -= 1
$game_system.bgs_play($game_system.bgs_memorize)
@sub_command_window[@command_window.index].refresh
end
# -------------------------------------------------------------------------
when 2 # Volume ME
@me = $game_option.me_volume
$game_option.save
if Input.press?(Input::RIGHT) and $game_option.me_volume < 100
$game_option.me_volume += 1
@sub_command_window[@command_window.index].refresh
elsif Input.press?(Input::LEFT) and $game_option.me_volume > 0
$game_option.me_volume -= 1
@sub_command_window[@command_window.index].refresh
end
# -------------------------------------------------------------------------
when 3 # Volume SE
@se = $game_option.se_volume
$game_option.save
if Input.press?(Input::RIGHT) and $game_option.se_volume < 100
$game_option.se_volume += 1
@sub_command_window[@command_window.index].refresh
elsif Input.press?(Input::LEFT) and $game_option.se_volume > 0
$game_option.se_volume -= 1
@sub_command_window[@command_window.index].refresh
end
end
end
#--------------------------------------------------------------------------
# * Window Refresh
#--------------------------------------------------------------------------
def subwindow_refresh
for i in @sub_command_window
i.refresh
end
end
end
#==============================================================================
# ** Bitmap
#==============================================================================
class Bitmap
#--------------------------------------------------------------------------
# * Draw Gradient Fill Rectangle (Volume Bar)
#--------------------------------------------------------------------------
def gradient_bar_volume(x, y, w, color1, color2, rate)
fill_rect(x, y+1, w+2, 14, Color.new(0, 0, 0, 150))
(1..4).each {|i|
color = Color.new(color2.red*i/4, color2.green*i/4, color2.blue*i/4, 255)
fill_rect(x + 2, (y + i * 2)-1, w-2, 18 - i * 4, color)
color = Color.new(color1.red*i/4, color1.green*i/4, color1.blue*i/4, 255)
fill_rect(x + 2, (y + i * 2)-1, rate-2, 18 - i * 4, color)}
end
end |