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
| #==============================================================================
# ■ Window_SaveFile2
#------------------------------------------------------------------------------
# par Maker
#==============================================================================
class Window_SaveFile2 < Window_Base
#--------------------------------------------------------------------------
# ● Readers & Accessors
#--------------------------------------------------------------------------
attr_reader :filename
attr_reader :selected
attr_accessor :infos
attr_accessor :refreshed
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize(file_index, filename)
super(0, file_index % 4 * 92, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.opacity = 0
@infos = Window_InfoFile.new(file_index, filename)
@refreshed = false
@file_index = file_index
@filename = "Save#{@file_index + 1}.rxdata"
@time_stamp = Time.at(0)
@file_exist = FileTest.exist?(@filename)
if @file_exist
file = File.open(@filename, "r")
@time_stamp = file.mtime
@characters = Marshal.load(file)
@frame_count = Marshal.load(file)
@game_system = Marshal.load(file)
@game_switches = Marshal.load(file)
@game_variables = Marshal.load(file)
@total_sec = @frame_count / Graphics.frame_rate
file.close
end
refresh
@selected = false
end
#--------------------------------------------------------------------------
# ● Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
if @file_exist
for i in 0...@characters.size
bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
cw = bitmap.rect.width / 4
ch = bitmap.rect.height / 4
src_rect = Rect.new(0, 0, cw, ch)
x = 81 + i * 58 - cw / 2
self.contents.blt(x, 145 - ch, bitmap, src_rect)
end
end
@infos.refresh if @selected == true
end
#--------------------------------------------------------------------------
# ● Selected
#--------------------------------------------------------------------------
def selected=(selected)
@selected = selected
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
alias old_dispose dispose
def dispose
old_dispose
@infos.dispose
end
end
#==============================================================================
# ■ Window_InfoFile
#------------------------------------------------------------------------------
# par Maker
#==============================================================================
class Window_InfoFile < Window_Base
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize(file_index, filename)
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = 20
self.opacity = 0
@file_index = file_index
@filename = "Save#{@file_index + 1}.rxdata"
@time_stamp = Time.at(0)
@file_exist = FileTest.exist?(@filename)
if @file_exist
file = File.open(@filename, "r")
@time_stamp = file.mtime
@characters = Marshal.load(file)
@frame_count = Marshal.load(file)
@game_system = Marshal.load(file)
@game_switches = Marshal.load(file)
@game_variables = Marshal.load(file)
@game_map = Marshal.load(file)
@game_map = Marshal.load(file)
@game_map = Marshal.load(file)
@game_party = Marshal.load(file)
@game_map = Marshal.load(file)
@game_map = Marshal.load(file)
@total_sec = @frame_count / Graphics.frame_rate
file.close
end
@selected = false
end
#--------------------------------------------------------------------------
# ● Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
if @file_exist
self.contents.draw_text(400, 110, 100, 32, "Hp")
self.contents.draw_text(470, 110, 100, 32, "Mp")
self.contents.draw_text(528, 110, 100, 32, "Niv.")
self.contents.font.color = normal_color
for i in 0...@game_party.actors.size
actor = @game_party.actors[i]
self.contents.draw_text(380, 128 + i*28, 200, 32, actor.hp.to_s + "/" + actor.maxhp.to_s + " " + actor.sp.to_s + "/" + actor.maxsp.to_s + " " + actor.level.to_s)
end
map_infos = load_data("Data/MapInfos.rxdata")
name = map_infos[@game_map.map_id].name.to_s
self.contents.draw_text(468, 258, 200, 32, name)
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.draw_text(475, 293, 200, 32, time_string)
end
end
def clear
self.contents.clear
end
end
#==============================================================================
# ■ Scene_File
#------------------------------------------------------------------------------
# セーブ画面およびロード画面のスーパークラスです。
#==============================================================================
class Scene_File2
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize(help_text)
@help_text = help_text
end
#--------------------------------------------------------------------------
# ● Main
#--------------------------------------------------------------------------
def main
@spriteset = Spriteset_Map.new
@help_window = Window_Help.new
@help_window.set_text(@help_text)
@help_window.x = 280
@help_window.y = -63
@help_window.opacity = 0
@help_window.contents_opacity = 0
@confirm_window = Window_HorizCommand.new(["Oui", "Non"])
@confirm_window.visible = false
@confirm_window.active = false
@sav = Sprite.new
@sav.bitmap = RPG::Cache.picture("Sauvegarder-1")
@sav.y = -90
@sav.opacity = 0
@details = Sprite.new
@details.bitmap = RPG::Cache.picture("Sauvegarder-2")
@details.x = 90
@details.opacity = 0
@opt = Sprite.new
@opt.bitmap = RPG::Cache.picture("Sauvegarder-3")
@opt.y = 90
@opt.opacity = 0
@case1 = Sprite.new
@case1.bitmap = RPG::Cache.picture("Sauvegarder-4")
@case1.x = 90
@case1.opacity = 0
@case2 = Sprite.new
@case2.bitmap = RPG::Cache.picture("Sauvegarder-5")
@case2.x = -90
@case2.opacity = 0
@case3 = Sprite.new
@case3.bitmap = RPG::Cache.picture("Sauvegarder-6")
@case3.x = 90
@case3.opacity = 0
@case4 = Sprite.new
@case4.bitmap = RPG::Cache.picture("Sauvegarder-7")
@case4.x = -90
@case4.opacity = 0
@opt.y = 90
@opt.opacity = 0
@curseur = Sprite.new
@curseur.bitmap = RPG::Cache.picture("Curseur-menu")
@y = [75,165,260,355]
@y2 = [335,385]
@curseur.x = 40
@curseur.y = @y[0]
@file_index = $game_temp.last_file_index
@savefile_windows = []
for i in 0..3
@savefile_windows.push(Window_SaveFile2.new(i, make_filename(i)))
@savefile_windows[i].contents_opacity = 0
end
@savefile_windows[@file_index].selected = true
@boucle = false
@tourne = 0
@transcurs = false
@frames = 0
Graphics.transition
slide_in
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@spriteset.dispose
@help_window.dispose
@confirm_window .dispose
for i in @savefile_windows
i.dispose
end
@sav.dispose
@details.dispose
@opt.dispose
@case1.dispose
@case2.dispose
@case3.dispose
@case4.dispose
@curseur.dispose
@curseur2.dispose if @curseur2 != nil
end
#--------------------------------------------------------------------------
# ● Slide In
#--------------------------------------------------------------------------
def slide_in
while @sav.y != 0
@help_window.y += 10
@sav.y += 10
@details.x -= 10
@opt.y -= 10
@case1.x -= 10
@case2.x += 10
@case3.x -= 10
@case4.x += 10
@help_window.contents_opacity += 29
for i in @savefile_windows
i.contents_opacity += 29
end
@sav.opacity += 29
@details.opacity += 29
@opt.opacity += 29
@case1.opacity += 29
@case2.opacity += 29
@case3.opacity += 29
@case4.opacity += 29
Graphics.update
end
end
#--------------------------------------------------------------------------
# ● Slide Out
#--------------------------------------------------------------------------
def slide_out
$game_system.se_play($data_system.cancel_se)
while @sav.y != -90
@help_window.y -= 10
@sav.y -= 10
@details.x += 10
@opt.y += 10
@case1.x += 10
@case2.x -= 10
@case3.x += 10
@case4.x -= 10
@help_window.contents_opacity -= 29
for i in @savefile_windows
i.contents_opacity -= 29
end
@curseur.opacity -= 29
@sav.opacity -= 29
@details.opacity -= 29
@opt.opacity -= 29
@case1.opacity -= 29
@case2.opacity -= 29
@case3.opacity -= 29
@case4.opacity -= 29
Graphics.update
end
if $game_temp.save_calling
$game_temp.save_calling = false
$scene = Scene_Map.new
return
end
$scene = Scene_Menu.new(4)
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
@help_window.update
@confirm_window.update
if @transcurs == false
if @curseur.opacity > 155 and @boucle == false
@curseur.opacity -= 5
@boucle = true if @curseur.opacity == 155
elsif @curseur.opacity < 255 and @boucle == true
@curseur.opacity += 5
@boucle = false if @curseur.opacity == 255
end
@tourne += 1
if @tourne >= 100
@curseur.angle += 15
if @curseur.angle == 360
@tourne = 0
@curseur.angle = 0
end
end
else
@frames += 1
if @frames > 2
@frames = 0
if @curseur.opacity == 255
@curseur.opacity = 0
else
@curseur.opacity = 255
end
end
return
end
for i in @savefile_windows
i.update
if i.selected == true and i.refreshed == false
i.infos.refresh
i.refreshed = true
elsif i.selected == false
i.infos.clear
i.refreshed = false
end
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
sauve_ou_charge
return
end
if Input.trigger?(Input::B)
slide_out
return
end
if Input.trigger?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
obj = @curseur.y == @y[0] ? @y[1] : @curseur.y == @y[1] ? @y[2] : @curseur.y == @y[2] ?@y[3] : @y[0]
dist = (obj - @curseur.y) / 5
while @curseur.y != obj
@curseur.y += dist
Graphics.update
end
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + 1) % 4
@savefile_windows[@file_index].selected = true
end
if Input.trigger?(Input::UP)
$game_system.se_play($data_system.cursor_se)
obj = @curseur.y == @y[0] ? @y[3] : @curseur.y == @y[1] ? @y[0] : @curseur.y == @y[2] ?@y[1] : @y[2]
dist = (@curseur.y - obj) / 5
while @curseur.y != obj
@curseur.y -= dist
Graphics.update
end
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + 3) % 4
@savefile_windows[@file_index].selected = true
end
end
#--------------------------------------------------------------------------
# ● Sauve ou Charge
#--------------------------------------------------------------------------
def sauve_ou_charge
@help_window.set_text("Sauvegarder ou charger ce fichier ?")
@transcurs = true
@curseur2 = Sprite.new
@curseur2.bitmap = RPG::Cache.picture("Curseur-menu")
@curseur2.x = 320
@curseur2.y = @y2[0]
loop do
Graphics.update
Input.update
update
if Input.trigger?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
obj = @curseur2.y == @y2[0] ? @y2[1] : @y2[0]
dist = (obj - @curseur2.y) / 5
while @curseur2.y != obj
@curseur2.y += dist
Graphics.update
end
end
if Input.trigger?(Input::UP)
$game_system.se_play($data_system.cursor_se)
obj = @curseur2.y == @y2[0] ? @y2[1] : @y2[0]
dist = (@curseur2.y - obj) / 5
while @curseur2.y != obj
@curseur2.y -= dist
Graphics.update
end
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@transcurs = false
@curseur.opacity = 255
@curseur2.dispose
@help_window.set_text(@help_text)
break
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
case @curseur2.y
when @y2[0]
@help_window.set_text("Confirmer ?")
@confirm_window.visible = true
@confirm_window.active = true
loop do
Graphics.update
Input.update
update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@confirm_window.visible = false
@confirm_window.active = false
@transcurs = false
@curseur.opacity = 255
@curseur2.dispose
@help_window.set_text(@help_text)
break
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
case @confirm_window.index
when 0
on_decision(make_filename(@file_index))
$game_temp.last_file_index = @file_index
@transcurs = false
@curseur.opacity = 255
@curseur2.dispose
when 1
@transcurs = false
@curseur.opacity = 255
@curseur2.dispose
end
@confirm_window.visible = false
@confirm_window.active = false
@help_window.set_text(@help_text)
break
end
end
break
when @y2[1]
@help_window.set_text("Confirmer ?")
@confirm_window.visible = true
@confirm_window.active = true
loop do
Graphics.update
Input.update
update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@confirm_window.visible = false
@confirm_window.active = false
@transcurs = false
@curseur.opacity = 255
@curseur2.dispose
@help_window.set_text(@help_text)
break
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
case @confirm_window.index
when 0
load(make_filename(@file_index))
$game_temp.last_file_index = @file_index
@transcurs = false
@curseur.opacity = 255
@curseur2.dispose
when 1
@transcurs = false
@curseur.opacity = 255
@curseur2.dispose
end
@confirm_window.visible = false
@confirm_window.active = false
@help_window.set_text(@help_text)
break
end
end
break
end
end
end
end
#--------------------------------------------------------------------------
# ● Make Filename
#--------------------------------------------------------------------------
def make_filename(file_index)
return "Save#{file_index + 1}.rxdata"
end
end
#==============================================================================
# ■ Window_HorizCommand
#------------------------------------------------------------------------------
# par Maker
#==============================================================================
class Window_HorizCommand < Window_Selectable
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize(commands)
super(430, 27, 200, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = 22
self.opacity = 0
@item_max = commands.size
@column_max = commands.size
@commands = commands
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# ● Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
x = 16 + index * 100
self.contents.draw_text(x, 0, 128, 32, @commands[index])
end
end
#==============================================================================
# ■ Scene_Save
#------------------------------------------------------------------------------
# セーブ画面の処理を行うクラスです。
#==============================================================================
class Scene_Save < Scene_File2
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize
super("Choisissez un fichier.")
end
#--------------------------------------------------------------------------
# ● On decision
#--------------------------------------------------------------------------
def on_decision(filename)
$game_system.se_play($data_system.save_se)
file = File.open(filename, "wb")
write_save_data(file)
file.close
if $game_temp.save_calling
$game_temp.save_calling = false
$scene = Scene_Map.new
return
end
$scene = Scene_Menu.new(4)
end
#--------------------------------------------------------------------------
# ● Write Save Data
#--------------------------------------------------------------------------
def write_save_data(file)
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
Marshal.dump(characters, file)
Marshal.dump(Graphics.frame_count, file)
$game_system.save_count += 1
$game_system.magic_number = $data_system.magic_number
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
end
#--------------------------------------------------------------------------
# ● Load
#--------------------------------------------------------------------------
def load(filename)
unless FileTest.exist?(filename)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.load_se)
file = File.open(filename, "rb")
read_save_data(file)
file.close
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
$game_map.update
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● Read Save Data
#--------------------------------------------------------------------------
def read_save_data(file)
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
if $game_system.magic_number != $data_system.magic_number
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
$game_party.refresh
end
end |