-
Notifications
You must be signed in to change notification settings - Fork 3
/
orms.rb
1468 lines (1369 loc) · 58.2 KB
/
orms.rb
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
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
#==============================================================================
# ** OLD_RM_STYLE v1.1.4
#------------------------------------------------------------------------------
# By Joke @biloumaster <[email protected]>
# GitHub: https://github.com/RMEx/OLD_RM_STYLE
#------------------------------------------------------------------------------
# Make a RM2K(3)-like game with RMVXAce!
# (or the oldschool overkill game that you dreamed for a long time)
# See the "ORMS_CONFIG" module below to see all the features and configure it!
# Go on the GitHub page to learn more about the bitmap fonts and the features!
#==============================================================================
#==============================================================================
# ** CONFIGURATION
#==============================================================================
unless Module.const_defined?(:ORMS_CONFIG)
module ORMS_CONFIG
# BITMAP_FONT_FEATURE:
BITMAP_FONT = true # Use the bitmap font picture to draw texts if true
# BITMAP_FONT_FEATURE_OPTIONS:
FONT_WIDTH = 6 # See BMP Font character's width
FONT_HEIGHT = 14 # See BMP Font character's height
DOUBLE_FONT_SIZE = true # Double the BMP Font Size if true
LINE_HEIGHT = 32 # Line height: VXAce: 24 2K(3): 32
PADDING = 16 # Padding: VXAce: 12 2K(3): 16
SHADOW = true # Draw text shadow using the last color in "Font_color.png"
REWRITE_ALL_TEXTS = true # Rewrite Bitmap.draw_text instead of Window_Base.draw_text
# BOX_FEATURES:
OPAQUE_BOX = false # Opaque text box if true
STOP_CURSOR_BLINKING = true # Stop cursor blinking if true
OLDSCHOOL_CHOICE_LIST = true # RM2K(3)-like choice list like if true
# SCREEN_FEATURES:
OLD_RESOLUTION = false # Just set game resolution to 640*480 (to simulate RM2k(3)'s 320*240)
TOGGLE_FULLSCREEN = :F4 # The shortcut (:F3..:F11) to toggle the fullscreen mode like RM2k(3)
TOGGLE_WINDOW_MODE = :F5 # The shortcut (:F3..:F11) to toggle to TINY 1x WINDOW MODE like RM2k(3)
# Re-define also the Fullscreen++ shortcuts if you use it too.
# If you use Fullscreen++, place Fullscreen++ right before orms!
#
# => Set the shortcut to 0 if you don't want the feature
PIXELATE_SCREEN = false # If you want fat pixels everywhere!
# This feature is a bit greedy, but it tries to optimize itself with
# a custom frame skipping method. This feature activate a custom FPS
# display (F2) that shows the real FPS, counting the frame skipping.
PIXELATION_SHORTCUT = :F6 # The shortcut (:F3..:F11) to activate/deactivate pixelation ingame.
# Don't forget to tell the player he can use this shortcut!
# An alternative is to use the "Orms.set(:pixelate_screen, false)" method
#
# => Set the shortcut to 0 if you don't want the feature
# RESSOURCES_FEATURES:
USE_OLD_RM_BACKDROP = false # Battlebacks1/2 auto-resized by two
USE_OLD_RM_MONSTER = false # Battlers auto-resized by two
USE_OLD_RM_PANORAMA = false # Parallaxes auto-resized by two
USE_OLD_RM_PICTURE = false # Pictures auto-resized by two
USE_OLD_RM_TITLE = false # Titles1/2 auto-resized by two
USE_OLD_RM_CHARSET = false # Characters auto-resized by two
BACKDROP_ALIGN_TOP = false # Align Battlebacks to top instead of center (for RM2K backdrops)
KILL_CHARSET_SHIFT_Y = false # Does as if all "Characters" had "!" in their name
OLD_CHARSET_DIRECTION = false # In VXAce's ressources, directions are "DOWN, LEFT, RIGHT, UP"
# but in RM2k(3)'s ressources, it's "UP, RIGHT, DOWN, LEFT"
# this fix allows you to use directly charsets from 2k(3)!
# DESTROY_NEW_RM_FEATURE:
DEACTIVATE_DASH = false # No dash when you press shift if true
end
end
#==============================================================================
# ** Additional methods for the user:
#------------------------------------------------------------------------------
# - Orms.set(feature, state) # Change the orms' features state when you want
# (example: Orms.set(:bitmap_font, false))
# - Orms.deactivate # Deactivate all orms' features when you want
# - Orms.activate # Reactivate all orms' features when you want
# - Orms.active? # Check if orms is active
# - Orms.active?(feature) # Check if orms and the given feature are active
# (example: Orms.active?(:pixelate_screen))
#==============================================================================
module Orms
extend self
#--------------------------------------------------------------------------
# * Change the orms' features state when you want
#--------------------------------------------------------------------------
def set(feature, state)
feature = feature.to_s.upcase.to_sym
ORMS_CONFIG.const_set(feature, state)
if Graphics.respond_to?(:orms_screen) && [feature, state] == [:PIXELATE_SCREEN, false]
Graphics.orms_screen.dispose unless Graphics.orms_screen.nil?
end
if SceneManager.scene.is_a?(Scene_Map) || SceneManager.scene.is_a?(Scene_Battle)
if [:BITMAP_FONT, :LINE_HEIGHT, :PADDING].include?(feature)
SceneManager.scene.create_all_windows
end
end
end
#--------------------------------------------------------------------------
# * Deactivate all orms' features when you want
#--------------------------------------------------------------------------
def deactivate
@active = false
if Graphics.respond_to?(:orms_screen) && Graphics.orms_screen
Graphics.orms_screen.dispose
end
if SceneManager.scene.is_a?(Scene_Map) || SceneManager.scene.is_a?(Scene_Battle)
SceneManager.scene.create_all_windows
end
end
#--------------------------------------------------------------------------
# * Reactivate all orms' features when you want
#--------------------------------------------------------------------------
def activate
@active = true
end
#--------------------------------------------------------------------------
# * Check if orms and the given feature are active
#--------------------------------------------------------------------------
def active?(feature = true)
@active = true if @active.nil?
if feature.is_a?(Symbol)
feature = feature.upcase
feature = ORMS_CONFIG.const_get(feature)
end
@active && feature
end
end
#==============================================================================
# ** BITMAP_FONT cache and USE_OLD_RM_*
#------------------------------------------------------------------------------
# BITMAP_FONT: Use the bitmap font picture to draw texts
# USE_OLD_RM_*: See ORMS_CONFIG > RESSOURCES_FEATURES above
#==============================================================================
#==============================================================================
# ** Cache
#------------------------------------------------------------------------------
# This module loads graphics, creates bitmap objects, and retains them.
# Now it can double the size of bitmaps specified in ORMS_CONFIG at loading
# and it generates and retains the BITMAP_FONT
#==============================================================================
module Cache
#--------------------------------------------------------------------------
# * Singleton
#--------------------------------------------------------------------------
class << self
#--------------------------------------------------------------------------
# * Generate Bitmap Font
#--------------------------------------------------------------------------
def generate_bitmap_font
mask = Bitmap.new("Graphics/System/Font")
color_set = Bitmap.new("Graphics/System/Font_color")
bmp_font = Bitmap.new(mask.width, mask.height * 32)
# draw shadow
if ORMS_CONFIG::SHADOW
shadow_color = color_set.get_pixel(127, 63)
shadow = Bitmap.new(mask.width, mask.height)
shadow.height.times do |y|
shadow.width.times do |x|
if mask.get_pixel(x, y).red == 255
shadow.set_pixel(x, y, shadow_color)
end
end
end
32.times do |i|
bmp_font.blt(1, i * mask.height + 1, shadow, mask.rect)
end
end
# draw font
mask.height.times do |y|
mask.width.times do |x|
if mask.get_pixel(x, y).red == 255
32.times do |i|
xc = i % 8 * 16 + x % ORMS_CONFIG::FONT_WIDTH
yc = i / 8 * 16 + y
bmp_font.set_pixel(x, y + i * mask.height, color_set.get_pixel(xc, yc))
end
end
end
end
bmp_font
end
#--------------------------------------------------------------------------
# * Get Bitmap Font
#--------------------------------------------------------------------------
def bitmap_font
if @cache[:bitmap_font] && @cache[:bitmap_font].disposed?
@cache[:bitmap_font] = generate_bitmap_font
end
@cache[:bitmap_font] ||= generate_bitmap_font
end
#--------------------------------------------------------------------------
# * Load Bitmap
#--------------------------------------------------------------------------
alias_method :orms_load_bitmap, :load_bitmap
def load_bitmap(*args)
case args[0]
when "Graphics/Battlebacks1/", "Graphics/Battlebacks2/"
return load_2k_bitmap(*args) if ORMS_CONFIG::USE_OLD_RM_BACKDROP
when "Graphics/Battlers/"
return load_2k_bitmap(*args) if ORMS_CONFIG::USE_OLD_RM_MONSTER
when "Graphics/Characters/"
return load_2k_bitmap(*args) if ORMS_CONFIG::USE_OLD_RM_CHARSET
when "Graphics/Parallaxes/"
return load_2k_bitmap(*args) if ORMS_CONFIG::USE_OLD_RM_PANORAMA
when "Graphics/Pictures/"
return load_2k_bitmap(*args) if ORMS_CONFIG::USE_OLD_RM_PICTURE
when "Graphics/Titles1/", "Graphics/Titles2/"
return load_2k_bitmap(*args) if ORMS_CONFIG::USE_OLD_RM_TITLE
end
orms_load_bitmap(*args)
end
#--------------------------------------------------------------------------
# * Load Bitmap to be resized by two
#--------------------------------------------------------------------------
def load_2k_bitmap(folder_name, filename, hue = 0)
return load_bitmap(folder_name, filename, hue) unless Orms.active?
@cache ||= {}
if filename.empty?
empty_bitmap
elsif hue == 0
normal_2k_bitmap(folder_name + filename)
else
hue_changed_2k_bitmap(folder_name + filename, hue)
end
end
#--------------------------------------------------------------------------
# * Create/Get Normal Bitmap resized by two
#--------------------------------------------------------------------------
def normal_2k_bitmap(path)
unless include?(path)
bmp = Bitmap.new(path)
@cache[path] = Bitmap.new(bmp.width*2, bmp.height*2)
@cache[path].stretch_blt(@cache[path].rect, bmp, bmp.rect)
bmp.dispose
end
@cache[path]
end
#--------------------------------------------------------------------------
# * Create/Get Hue-Changed Bitmap resized by two
#--------------------------------------------------------------------------
def hue_changed_2k_bitmap(path, hue)
key = [path, hue]
unless include?(key)
bmp = Bitmap.new(path)
bmp.hue_change(hue)
@cache[key] = Bitmap.new(bmp.width*2, bmp.height*2)
@cache[key].stretch_blt(@cache[key].rect, bmp, bmp.rect)
bmp.dispose
end
@cache[key]
end
end
end
if ORMS_CONFIG::BACKDROP_ALIGN_TOP
#==============================================================================
# ** Spriteset_Battle
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# * Move Sprite to Screen Center
#--------------------------------------------------------------------------
def center_sprite(sprite)
sprite.ox = sprite.bitmap.width / 2
sprite.x = Graphics.width / 2
end
end
end
#==============================================================================
# ** BITMAP_FONT
#------------------------------------------------------------------------------
# Use the bitmap font picture to draw texts
#==============================================================================
#==============================================================================
# ** ORMS_Bitmap_Font
#------------------------------------------------------------------------------
# This module writes texts using Cache.bitmap_font.
# It extends the behaviour of Window_Base if REWRITE_ALL_TEXTS is FALSE
# It extends the behaviour of Bitmap class if REWRITE_ALL_TEXTS is TRUE
#==============================================================================
module ORMS_Bitmap_Font
#--------------------------------------------------------------------------
# * Singleton
#--------------------------------------------------------------------------
class << self
#--------------------------------------------------------------------------
# * Included
#--------------------------------------------------------------------------
def included(base)
base.class_eval do
#--------------------------------------------------------------------------
# * Get Text Size
#--------------------------------------------------------------------------
def text_size(str)
return orms_text_size(str) unless Orms.active?(:bitmap_font)
s = ORMS_CONFIG::DOUBLE_FONT_SIZE ? 2 : 1
w = ORMS_CONFIG::FONT_WIDTH
h = ORMS_CONFIG::FONT_HEIGHT
return Rect.new(0, 0, s * w, s * h) unless str
Rect.new(0, 0, s * w * str.length, s * h)
end
#--------------------------------------------------------------------------
# * Draw Text
#--------------------------------------------------------------------------
def draw_text(*args)
unless Orms.active?(:bitmap_font)
args.pop if args.length == 4 || args.length == 7
return orms_draw_text(*args)
end
if args.length.between?(2,4)
x, y, width, text = args[0].x, args[0].y, args[0].width, args[1].to_s.clone
align = args[2] || 0
color_id = args[3] || @color_id || 0
else
x, y, width, text = args[0], args[1], args[2], args[4].to_s.clone
align = args[5] || 0
color_id = args[6] || @color_id || 0
end
if align == 1
x = x + (width - text_size(text).width) / 2
end
if align == 2
x = x + width - text_size(text).width
end
until text.empty?
draw_char(text.slice!(0, 1), x, y, color_id)
x += ORMS_CONFIG::FONT_WIDTH * (ORMS_CONFIG::DOUBLE_FONT_SIZE ? 2 : 1)
end
end
#--------------------------------------------------------------------------
# * Draw One Character
#--------------------------------------------------------------------------
def draw_char(char, x, y, color_id = 0)
s = ORMS_CONFIG::DOUBLE_FONT_SIZE ? 2 : 1
w = ORMS_CONFIG::FONT_WIDTH
h = ORMS_CONFIG::FONT_HEIGHT
bmp = Cache.bitmap_font
char = 1 if char.ord > bmp.width / w - 1
dest = Rect.new(x, y, w * s, h * s)
src = Rect.new(char.ord * w, color_id * h, w, h)
if ORMS_CONFIG::REWRITE_ALL_TEXTS
stretch_blt(dest, bmp, src)
else
contents.stretch_blt(dest, bmp, src)
end
end
end
end
end
end
#==============================================================================
# ** ORMS_Bitmap
#------------------------------------------------------------------------------
# can draw with the bitmap font!
#==============================================================================
class ORMS_Bitmap < Bitmap
alias_method :orms_draw_text, :draw_text
alias_method :orms_text_size, :text_size
include ORMS_Bitmap_Font
end
if ORMS_CONFIG::BITMAP_FONT
#==============================================================================
# ** Window_Base
#==============================================================================
class Window_Base
#--------------------------------------------------------------------------
# * Get Text Color
#--------------------------------------------------------------------------
def text_color(n)
@color_id = n
windowskin.get_pixel(64 + (n % 8) * 8, 96 + (n / 8) * 8)
end
#--------------------------------------------------------------------------
# * Draw Text
#--------------------------------------------------------------------------
alias_method :orms_draw_text, :draw_text
def draw_text(*args)
return orms_draw_text(*args) unless Orms.active?(:bitmap_font)
args.push(0) if args.length == 2 || args.length == 5
args.push(@color_id)
contents.draw_text(*args)
end
#--------------------------------------------------------------------------
# * Get Text Colors
#--------------------------------------------------------------------------
def system_color; text_color(6); end; # System
def crisis_color; text_color(4); end; # Crisis
def knockout_color; text_color(11); end; # Knock out
def mp_cost_color; text_color(10); end; # MP cost
def power_up_color; text_color(9); end; # Equipment power up
def power_down_color; text_color(11); end; # Equipment power down
def tp_cost_color; text_color(9); end; # TP cost
#--------------------------------------------------------------------------
# * Change Text Drawing Color
#--------------------------------------------------------------------------
alias_method :orms_change_color, :change_color
def change_color(color, enabled = true)
return orms_change_color(color, enabled) unless Orms.active?(:bitmap_font)
contents.font.color.set(enabled ? color : text_color(3))
end
#--------------------------------------------------------------------------
# * Calculate Line Height
#--------------------------------------------------------------------------
alias_method :orms_calc_line_height, :calc_line_height
def calc_line_height(text, restore_font_size = true)
unless Orms.active?(:bitmap_font)
return orms_calc_line_height(text, restore_font_size)
end
line_height
end
#--------------------------------------------------------------------------
# * Get Line Height
#--------------------------------------------------------------------------
alias_method :orms_line_height, :line_height
def line_height
return orms_line_height unless Orms.active?(:bitmap_font)
ORMS_CONFIG::LINE_HEIGHT
end
end
#==============================================================================
# ** REWRITE ALL TEXTS or Window_Base only
#==============================================================================
if ORMS_CONFIG::REWRITE_ALL_TEXTS
class Bitmap
alias_method :orms_draw_text, :draw_text
alias_method :orms_text_size, :text_size
end
Bitmap.send(:include, ORMS_Bitmap_Font)
else
Window_Base.send(:include, ORMS_Bitmap_Font)
end
#==============================================================================
# ** Window_NameEdit
#==============================================================================
class Window_NameEdit
#--------------------------------------------------------------------------
# * Get Line Height
#--------------------------------------------------------------------------
def line_height
24
end
end
#==============================================================================
# ** Window_NameInput
#==============================================================================
class Window_NameInput
#--------------------------------------------------------------------------
# * Write "Pge" instead of "Page"
#--------------------------------------------------------------------------
LATIN1[88] = 'Nx'
LATIN2[88] = 'Pr'
#--------------------------------------------------------------------------
# * Get Line Height
#--------------------------------------------------------------------------
def line_height
24
end
end
#==============================================================================
# ** Window_EquipStatus
#==============================================================================
class Window_EquipStatus
#--------------------------------------------------------------------------
# * Draw Right Arrow
#--------------------------------------------------------------------------
def draw_right_arrow(x, y)
change_color(system_color)
draw_text(x, y, 22, line_height, " >", 1)
end
end
#==============================================================================
# ** Window_Message
#==============================================================================
class Window_Message
#--------------------------------------------------------------------------
# * Draw Face Graphic
#--------------------------------------------------------------------------
alias_method :orms_draw_face, :draw_face
def draw_face(*args)
return orms_draw_face(*args) unless Orms.active?(:bitmap_font)
args[2] = args[3] = (contents_height - 96) / 2
orms_draw_face(*args)
end
#--------------------------------------------------------------------------
# * Get New Line Position
#--------------------------------------------------------------------------
alias_method :orms_new_line_x, :new_line_x
def new_line_x
return orms_new_line_x unless Orms.active?(:bitmap_font)
x = [96, height - standard_padding].max
$game_message.face_name.empty? ? 0 : x
end
#--------------------------------------------------------------------------
# * Get Standard Padding Size
#--------------------------------------------------------------------------
alias_method :orms_standard_padding, :standard_padding
def standard_padding
return orms_standard_padding unless Orms.active?(:bitmap_font)
ORMS_CONFIG::PADDING
end
end
class Window_ActorCommand
alias_method :orms_standard_padding, :standard_padding
def standard_padding
return orms_standard_padding unless Orms.active?(:bitmap_font)
ORMS_CONFIG::PADDING
end
end
class Window_BattleStatus
alias_method :orms_standard_padding, :standard_padding
def standard_padding
return orms_standard_padding unless Orms.active?(:bitmap_font)
ORMS_CONFIG::PADDING
end
end
class Window_BattleEnemy
alias_method :orms_standard_padding, :standard_padding
def standard_padding
return orms_standard_padding unless Orms.active?(:bitmap_font)
ORMS_CONFIG::PADDING
end
end
class Window_PartyCommand
alias_method :orms_standard_padding, :standard_padding
def standard_padding
return orms_standard_padding unless Orms.active?(:bitmap_font)
ORMS_CONFIG::PADDING
end
end
#==============================================================================
# ** Window_MenuStatus
#==============================================================================
class Window_MenuStatus
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
alias_method :orms_draw_item, :draw_item
def draw_item(index)
return orms_draw_item(index) unless Orms.active?(:bitmap_font)
actor = $game_party.members[index]
enabled = $game_party.battle_members.include?(actor)
rect = item_rect(index)
draw_item_background(index)
draw_actor_face(actor, rect.x + 1, rect.y + 1, enabled)
draw_actor_simple_status(actor, rect.x + 108, rect.y)
end
end
#==============================================================================
# ** Window_TitleCommand
#==============================================================================
class Window_TitleCommand
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
alias_method :orms_window_width, :window_width
def window_width
return orms_window_width unless Orms.active?(:bitmap_font)
s = ORMS_CONFIG::DOUBLE_FONT_SIZE ? 2 : 1
max = @list.map {|i| i[:name].length * ORMS_CONFIG::FONT_WIDTH * s}.max
max + 2 * standard_padding + 8
end
#--------------------------------------------------------------------------
# * Update Window Position
#--------------------------------------------------------------------------
def update_placement
self.x = (Graphics.width - width) / 2
self.y = 296 * Graphics.height / 480 #RM2k(3) style, OK?
end
end
end
#==============================================================================
# ** OPAQUE_BOX
#------------------------------------------------------------------------------
# Opaque text box
#==============================================================================
if ORMS_CONFIG::OPAQUE_BOX
#==============================================================================
# ** Window_Base
#==============================================================================
class Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias_method :orms_opaque_initialize, :initialize
def initialize(*args)
orms_opaque_initialize(*args)
self.back_opacity = 255 if Orms.active?(:opaque_box)
end
end
end
#==============================================================================
# ** STOP_CURSOR_BLINKING
#------------------------------------------------------------------------------
# Stop cursor blinking
#==============================================================================
if ORMS_CONFIG::STOP_CURSOR_BLINKING
#==============================================================================
# ** Window_Selectable
#==============================================================================
class Window_Selectable
#--------------------------------------------------------------------------
# * The cursor's blink status
#--------------------------------------------------------------------------
alias_method :orms_active, :active
def active
return orms_active unless Orms.active?(:stop_cursor_blinking)
@active
end
alias_method :orms_blink_active, :active=
def active=(index)
return orms_blink_active(index) unless Orms.active?(:stop_cursor_blinking)
orms_blink_active(false)
@active = index
end
end
end
#==============================================================================
# ** OLDSCHOOL_CHOICE_LIST
#------------------------------------------------------------------------------
# RM2K(3)-like choice list like
#==============================================================================
if ORMS_CONFIG::OLDSCHOOL_CHOICE_LIST
#==============================================================================
# ** Window_Base
#==============================================================================
class Window_Base
#--------------------------------------------------------------------------
# * Public instance variables
#--------------------------------------------------------------------------
attr_accessor :line_number
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias_method :orms_choice_initialize, :initialize
def initialize(*args)
orms_choice_initialize(*args)
@line_number = 0
end
end
#==============================================================================
# ** Window_Message
#==============================================================================
class Window_Message
#--------------------------------------------------------------------------
# * New Page
#--------------------------------------------------------------------------
alias_method :orms_choice_new_page, :new_page
def new_page(text, pos)
orms_choice_new_page(text, pos)
@line_number = text.split("\n").length
end
end
#==============================================================================
# ** Window_ChoiceList
#==============================================================================
class Window_ChoiceList
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias_method :oldschool_choice_initialize, :initialize
def initialize(message_window)
oldschool_choice_initialize(message_window)
if Orms.active?(:oldschool_choice_list)
self.windowskin = Cache.system("Window").clone
self.windowskin.fill_rect(Rect.new(0,0,168,64), Color.new(0,0,0,0))
end
end
#--------------------------------------------------------------------------
# * Start Input Processing
#--------------------------------------------------------------------------
alias_method :orms_start, :start
def start
if Orms.active?(:oldschool_choice_list)
if @message_window.openness == 0
@message_window.create_contents
@message_window.line_number = 0
@message_window.open
end
if (@message_window.line_number + $game_message.choices.size >
@message_window.visible_line_number)
@message_window.input_pause
@message_window.new_page("", {x:0, y:0, new_x:0, height:0})
end
end
orms_start
end
#--------------------------------------------------------------------------
# * Update Window Position
#--------------------------------------------------------------------------
alias_method :orms_update_placement, :update_placement
def update_placement
orms_update_placement unless Orms.active?(:oldschool_choice_list)
self.x = @message_window.new_line_x + 6
self.y = @message_window.y + @message_window.line_number * @message_window.line_height
self.width = @message_window.width - self.x - 10
self.height = fitting_height($game_message.choices.size)
self.viewport ||= Viewport.new
self.viewport.z = 200
end
end
end
#==============================================================================
# ** OLD_CHARSET_DIRECTION
#------------------------------------------------------------------------------
# In VXAce's ressources, directions are "DOWN, LEFT, RIGHT, UP"
# but in RM2k(3)'s ressources, it's "UP, RIGHT, DOWN, LEFT"
# this fix allows you to use directly charsets from 2k(3)!
#==============================================================================
if ORMS_CONFIG::OLD_CHARSET_DIRECTION
#==============================================================================
# ** Sprite_Character
#==============================================================================
class Sprite_Character
#--------------------------------------------------------------------------
# * Update Transfer Origin Rectangle
#--------------------------------------------------------------------------
alias_method :orms_update_src_rect, :update_src_rect
def update_src_rect
return orms_update_src_rect unless Orms.active?(:old_charset_direction)
if @tile_id == 0
direction = [2, 3, 1, 0][@character.direction / 2 - 1]
index = @character.character_index
pattern = @character.pattern < 3 ? @character.pattern : 1
sx = (index % 4 * 3 + pattern) * @cw
sy = (index / 4 * 4 + direction) * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
end
end
#==============================================================================
# ** Game_Event
#==============================================================================
class Game_Event
#--------------------------------------------------------------------------
# * Set Up Event Page Settings
#--------------------------------------------------------------------------
alias_method :orms_setup_page_setting, :setup_page_settings
def setup_page_settings
orms_setup_page_setting
if Orms.active?(:old_charset_direction)
@original_direction = @direction = [8, 6, 2, 4][@page.graphic.direction / 2 - 1]
end
end
end
end
#==============================================================================
# ** KILL_CHARSET_SHIFT_Y
#------------------------------------------------------------------------------
# Does as if all "Characters" had "!" in their name
#==============================================================================
if ORMS_CONFIG::KILL_CHARSET_SHIFT_Y
class Game_CharacterBase
alias_method :orms_shift_y, :shift_y
def shift_y
return orms_shift_y unless Orms.active?(:kill_charset_shift_y)
0
end
end
end
#==============================================================================
# ** PIXELATE_SCREEN
#------------------------------------------------------------------------------
# If you want fat pixels everywhere
#==============================================================================
if ORMS_CONFIG::PIXELATE_SCREEN
#==============================================================================
# ** ORMS_FPS
#------------------------------------------------------------------------------
# Calculate the FPS of the RGSS processing and the screen refreshing
#==============================================================================
module ORMS_FPS
extend self
#--------------------------------------------------------------------------
# * Public instance variables
#--------------------------------------------------------------------------
attr_reader :fps, :ups, :ups2, :visible
attr_accessor :previous_time
#--------------------------------------------------------------------------
# * Update rate: Number of times the FPS is calculated per second
#--------------------------------------------------------------------------
UPDATE_RATE = 2.0
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
update_ups
update_ups2
end
#--------------------------------------------------------------------------
# * Graphics.updates per second calculation
#--------------------------------------------------------------------------
def update_ups
@frame_count ||= 0
@frame_count += 1
dt = Time.now - @previous_time
if dt >= 1.0 / UPDATE_RATE
@ups = (@frame_count / dt).round
@ups = [@ups, Graphics.frame_rate + 10].min
update_fps(dt)
@frame_count = 0
@previous_time = Time.now
update_counter
end
end
#--------------------------------------------------------------------------
# * Graphics.updates real time frequency
#--------------------------------------------------------------------------
def update_ups2
@previous_time2 ||= @previous_time
dt = Time.now - @previous_time2
if dt >= 1.0 / Graphics.frame_rate
@ups2 = (1.0 / dt).round
@previous_time2 = Time.now
end
end
#--------------------------------------------------------------------------
# * Pixelated frames per second
#--------------------------------------------------------------------------
def update_fps(dt)
if Orms.active?(:pixelate_screen)
sframe_count = Graphics.frame_counter || Graphics.frame_rate
@fps = (sframe_count / dt).round
else
@fps = @ups
end
Graphics.frame_counter = 0
end
#--------------------------------------------------------------------------
# * Initialize the displayed counter
#--------------------------------------------------------------------------
def initialize_counter
@background = Sprite.new(Viewport.new(4, 4, 200, 30))
@background.viewport.z = 600
@background.bitmap = Bitmap.new(1, 1)
@background.bitmap.set_pixel(0, 0, Color.new(0, 0, 0, 127))
@counter = Sprite.new(@background.viewport)
begin
@counter.bitmap = ORMS_Bitmap.new(200, 30)
rescue
@counter.bitmap = Bitmap.new(200, 30)
end
@counter.x = 2
@counter.y = -4
@counter.z = 10
end
#--------------------------------------------------------------------------
# * Update the displayed counter
#--------------------------------------------------------------------------
def update_counter
@visible ||= false
return unless @visible
if @counter.nil? || @counter.disposed?
@visible ? initialize_counter : return
end
text = [@ups, @fps].uniq
size = @counter.bitmap.text_size(text.join("~"))
size2 = @counter.bitmap.text_size(text[0].to_s) if text.length == 2
@background.zoom_x = size.width + 4
@background.zoom_y = size.height - 6
@counter.bitmap.clear
color = 9
color = 4 if text[0] <= 30
color = 11 if text[0] <= 15
@counter.bitmap.draw_text(size, text[0].to_s, 0, color)
if text.length == 2
size.x = size2.width
size.width -= size2.width
@counter.bitmap.draw_text(size, "~" + text[1].to_s, 0, 3)
end
end
#--------------------------------------------------------------------------
# * Toggle the counter display
#--------------------------------------------------------------------------
def toggle_display
initialize_counter if @counter.nil? || @counter.disposed?
@visible = !@visible
visible = @visible
end
def visible=(v)
return if @counter.nil? || @counter.disposed?
@counter.visible = @background.visible = v
end
end
#==============================================================================
# ** ORMS_MESSAGE
#------------------------------------------------------------------------------
# Display messages at top/right screen corner (used for "pixelation ON/OFF")
#==============================================================================
module ORMS_MESSAGE
extend self
#--------------------------------------------------------------------------
# * Update the displayed message
#--------------------------------------------------------------------------
def update
create_message_sprite if @message.nil? || @message.disposed?
@timer ||= 0
@message.opacity == 0 ? @timer = 0 : @timer += 1
@message.opacity -= 20 if @timer > 30
end
#--------------------------------------------------------------------------
# * Create the sprite
#--------------------------------------------------------------------------
def create_message_sprite
@message = Sprite.new(Viewport.new(Graphics.width - 200, 4, 204, 30))
@message.viewport.z = 600
@message.x = -4
@message.y = -2
@message.z = 10
end
#--------------------------------------------------------------------------
# * Display a message
#--------------------------------------------------------------------------
def display(text, color)
@message.bitmap = get_message_bitmap(text, color)
@message.opacity = 255
end
#--------------------------------------------------------------------------
# * Get the Bitmap corresponding to the message and cache it
#--------------------------------------------------------------------------
def get_message_bitmap(text, color)
@texts ||= Hash.new
if @texts[text].nil? || @texts[text].is_a?(Bitmap) && @texts[text].disposed?
begin
@texts[text] = ORMS_Bitmap.new(200, 30)
rescue
@texts[text] = Bitmap.new(200, 30)
end
draw_message(@texts[text], text, color)