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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
| #Basic Mouse System
#----------#
#Features: Provides a series of functions to find the current x, y position of
# the mouse and whether it is being clicked or not (left or right click)
#
#Usage: Script calls:
# Mouse.pos? - returns the x, y position as an array
# Mouse.lclick?(repeat) - returns if left click is achieved
# repeat = true for repeated checks
# Mouse.rclick?(repeat) - same as above for right click
# Mouse.within?(rect) - passes a Rect through to check if cursor
# is within it, returns true if so
#
#No Customization
#
#----------#
#-- Script by: V.M of D.T
#--- Free to use in any non-commercial project with credit given
CPOS = Win32API.new \'user32\', \'GetCursorPos\', [\'p\'], \'v\'
WINX = Win32API.new \'user32\', \'FindWindowEx\', [\'l\',\'l\',\'p\',\'p\'], \'i\'
ASKS = Win32API.new \'user32\', \'GetAsyncKeyState\', [\'p\'], \'i\'
SMET = Win32API.new \'user32\', \'GetSystemMetrics\', [\'i\'], \'i\'
WREC = Win32API.new \'user32\', \'GetWindowRect\', [\'l\',\'p\'], \'v\'
module Mouse
def self.setup
@delay = 0
bwap = true if SMET.call(23) != 0
bwap ? @lmb = 0x02 : @lmb = 0x01
bwap ? @rmb = 0x01 : @rmb = 0x02
end
def self.update
self.setup if @lmb.nil?
@delay -= 1
@window_loc = WINX.call(0,0,\"RGSS PLAYER\",0)
if ASKS.call(@lmb) == 0 then @l_clicked = false end
if ASKS.call(@rmb) == 0 then @r_clicked = false end
rect = \'0000000000000000\'
cursor_pos = \'00000000\'
WREC.call(@window_loc, rect)
side, top = rect.unpack(\"ll\")
CPOS.call(cursor_pos)
@m_x, @m_y = cursor_pos.unpack(\"ll\")
w_x = side + SMET.call(5) + SMET.call(45)
w_y = top + SMET.call(6) + SMET.call(46) + SMET.call(4)
@m_x -= w_x; @m_y -= w_y
end
def self.pos?
self.update
return [@m_x, @m_y]
end
def self.lclick?(repeat = false)
self.update
return false if @l_clicked
if ASKS.call(@lmb) != 0 then
@l_clicked = true if !repeat
return true end
end
def self.rclick?(repeat = false)
self.update
return false if @r_clicked
if ASKS.call(@rmb) != 0 then
@r_clicked = true if !repeat
return true end
end
def self.slowpeat
self.update
return false if @delay > 0
@delay = 120
return true
end
def self.within?(rect)
self.update
return false if @m_x < rect.x or @m_y < rect.y
bound_x = rect.x + rect.width; bound_y = rect.y + rect.height
return true if @m_x < bound_x and @m_y < bound_y
return false
end
end
#Mouse Movement - Basic Mouse System Addon
#----------#
#Features: Moves the hero in a 4dir pattern based on where the mouse is currently
# while it\'s clicked. No pathfinding, just movement.
#
#Usage: Plug and Play
#
#
#No Customization
#
#----------#
#-- Script by: V.M of D.T
#--- Same Terms as Basic Mouse System
class Game_Player < Game_Character
alias mouse_move_update update
def update
mouse_move_update
mouse_input
end
def mouse_input
return if !movable? || $game_map.interpreter.running?
if !Mouse.lclick?(true) then return end
if moving? then return end
pos = Mouse.pos?
xx = $game_player.screen_x
yy = $game_player.screen_y
cen_pos = [xx,yy]
x_diff = cen_pos[0] - pos[0]
y_diff = cen_pos[1] - pos[1]
if Mouse.within?(Rect.new(xx - 16,yy - 32,32,32)) then return end
if x_diff > 0 and y_diff > 0
x_diff >= y_diff ? move_straight(4) : move_straight(8)
return
end
if x_diff < 0 and y_diff > 0
x_diff *= -1
x_diff >= y_diff ? move_straight(6) : move_straight(8)
return
end
if x_diff > 0 and y_diff < 0
y_diff *= -1
x_diff >= y_diff ? move_straight(4) : move_straight(2)
return
end
if x_diff < 0 and y_diff < 0
x_diff *= -1
y_diff *= -1
x_diff >= y_diff ? move_straight(6) : move_straight(2)
return
end
end
end
#Mouse Battle - Basic Mouse System Addon
#----------#
#Features: Adds basic mouse functionality to the default battle system!
# Left click pretty much acts as the accept button
# Right click pretty much acts as the cancel button
#
#Usage: Plug and Play
#
#No Customization
#
#----------#
#-- Script by: V.M of D.T
#--- Same Terms as Basic Mouse System
class Scene_Battle
WLH = 24
OFS = 12
alias mouse_update_basic update_basic
def update_basic
mouse_update_basic
mouse_update
end
def mouse_update
#ACTOR_WINDOW
if @actor_window.active
xx = Graphics.width - @enemy_window.width
yy = Graphics.height - @enemy_window.height
width = @actor_window.contents.width
rectcm1 = Rect.new(xx + OFS, yy + OFS, width, WLH)
rectcm2 = Rect.new(rectcm1.x, rectcm1.y + 24, width, WLH)
rectcm3 = Rect.new(rectcm1.x, rectcm2.y + 24, width, WLH)
rectcm4 = Rect.new(rectcm1.x, rectcm3.y + 24, width, WLH)
rectttl = Rect.new(rectcm1.x, rectcm1.y, width * 2, WLH * 4)
@actor_window.index = 0 if Mouse.within?(rectcm1)
@actor_window.index = 1 if Mouse.within?(rectcm2)
@actor_window.index = 2 if Mouse.within?(rectcm3)
@actor_window.index = 3 if Mouse.within?(rectcm4)
@actor_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@actor_window.process_cancel if Mouse.rclick? and Mouse.within?(rectttl)
end
#ITEM_WINDOW
if @item_window.active
xx = 0
yy = @help_window.height
width = @item_window.contents.width / 2
hold_rect = []; temp = 2
smax = [@item_window.item_max, ((@item_window.height - 24) / WLH) * 2].min
rectttl = Rect.new(xx, yy, @item_window.contents.width, @item_window.contents.height)
rectcmA = Rect.new(Graphics.width / 2 - 50, @help_window.height - 12, 100, 24)
rectcmB = Rect.new(Graphics.width / 2 - 50, Graphics.height - @actor_command_window.height - 12, 100, 24)
for i in Range.new(0,smax - 1)
tempx = xx + OFS + width * (temp % 2)
tempy = yy + OFS + 24 * ((temp / 2) - 1)
hold_rect.push(Rect.new(tempx, tempy, width, WLH))
temp += 1
end
@scroll = @item_window.top_row + (@item_window.top_row * 2 / 2)
for i in Range.new(0,@item_window.item_max - 1)
next if hold_rect[i].nil?
@item_window.index = (i + @scroll) if Mouse.within?(hold_rect[i])
end
@item_window.cursor_down if Mouse.within?(rectcmB) and Mouse.slowpeat
@item_window.cursor_up if Mouse.within?(rectcmA) and Mouse.slowpeat
@item_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@item_window.process_cancel if Mouse.rclick? and Mouse.within?(rectttl)
end
#SKILL_WINDOW
if @skill_window.active
xx = 0
yy = @help_window.height
width = @skill_window.contents.width / 2
hold_rect = []; temp = 2
rectttl = Rect.new(xx, yy, @skill_window.contents.width, @skill_window.contents.height)
rectcmA = Rect.new(Graphics.width / 2 - 50, @help_window.height - 12, 100, 24)
rectcmB = Rect.new(Graphics.width / 2 - 50, Graphics.height - @actor_command_window.height - 12, 100, 24)
for i in Range.new(0,@skill_window.item_max - 1)
tempx = xx + OFS + width * (temp % 2)
tempy = yy + OFS + 24 * ((temp / 2) - 1)
hold_rect.push(Rect.new(tempx, tempy, width, WLH))
temp += 1
end
@scroll = @skill_window.top_row + (@skill_window.top_row * 2 / 2)
for i in Range.new(0,@skill_window.item_max - 1)
next if hold_rect[i].nil?
@skill_window.index = (i + @scroll) if Mouse.within?(hold_rect[i])
end
@skill_window.cursor_down if Mouse.within?(rectcmB) and Mouse.slowpeat
@skill_window.cursor_up if Mouse.within?(rectcmA) and Mouse.slowpeat
@skill_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@skill_window.process_cancel if Mouse.rclick? and Mouse.within?(rectttl)
end
#ENEMY_WINDOW
if @enemy_window.active
xx = Graphics.width - @enemy_window.width
yy = Graphics.height - @enemy_window.height
width = @enemy_window.contents.width / 2
rectcm1 = Rect.new(xx + OFS, yy + OFS, width, WLH)
rectcm2 = Rect.new(rectcm1.x + width, rectcm1.y, width, WLH)
rectcm3 = Rect.new(rectcm1.x, rectcm1.y + 24, width, WLH)
rectcm4 = Rect.new(rectcm1.x + width, rectcm3.y, width, WLH)
rectcm5 = Rect.new(rectcm1.x, rectcm3.y + 24, width, WLH)
rectcm6 = Rect.new(rectcm1.x + width, rectcm5.y, width, WLH)
rectcm7 = Rect.new(rectcm1.x, rectcm5.y + 24, width, WLH)
rectcm8 = Rect.new(rectcm1.x + width, rectcm7.y, width, WLH)
rectttl = Rect.new(rectcm1.x, rectcm1.y, width * 2, WLH * 4)
@enemy_window.index = 0 if Mouse.within?(rectcm1)
@enemy_window.index = 1 if Mouse.within?(rectcm2) and !$game_troop.alive_members[1].nil?
@enemy_window.index = 2 if Mouse.within?(rectcm3) and !$game_troop.alive_members[2].nil?
@enemy_window.index = 3 if Mouse.within?(rectcm4) and !$game_troop.alive_members[3].nil?
@enemy_window.index = 4 if Mouse.within?(rectcm5) and !$game_troop.alive_members[4].nil?
@enemy_window.index = 5 if Mouse.within?(rectcm6) and !$game_troop.alive_members[5].nil?
@enemy_window.index = 6 if Mouse.within?(rectcm7) and !$game_troop.alive_members[6].nil?
@enemy_window.index = 7 if Mouse.within?(rectcm8) and !$game_troop.alive_members[7].nil?
@enemy_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@enemy_window.process_cancel if Mouse.rclick? and Mouse.within?(rectttl)
end
#ACTOR_COMMAND_WINDOW
if @actor_command_window.active
xx = Graphics.width - @actor_command_window.width
yy = Graphics.height - @actor_command_window.height
width = @actor_command_window.contents.width
rectcm1 = Rect.new(xx + OFS, yy + OFS, width, WLH)
rectcmA = Rect.new(rectcm1.x, rectcm1.y - WLH, width, WLH)
rectcm2 = Rect.new(rectcm1.x, rectcm1.y + WLH, width, WLH)
rectcm3 = Rect.new(rectcm1.x, rectcm2.y + WLH, width, WLH)
rectcm4 = Rect.new(rectcm1.x, rectcm3.y + WLH, width, WLH)
rectcmB = Rect.new(rectcm1.x, rectcm4.y + WLH, width, WLH)
rectttl = Rect.new(rectcm1.x, rectcm1.y, width, WLH * 4)
@actor_command_window.cursor_up if Mouse.within?(rectcmA) and @actor_command_window.item_max > 4
@actor_command_window.cursor_down if Mouse.within?(rectcmB) and @actor_command_window.item_max > 4
@scroll = @actor_command_window.top_row
@actor_command_window.index = (0 + @scroll) if Mouse.within?(rectcm1)
@actor_command_window.index = (1 + @scroll) if Mouse.within?(rectcm2)
@actor_command_window.index = (2 + @scroll) if Mouse.within?(rectcm3)
@actor_command_window.index = (3 + @scroll) if Mouse.within?(rectcm4)
@actor_command_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@actor_command_window.process_cancel if Mouse.rclick? and Mouse.within?(rectttl)
end
#PARTY_COMMAND_WINDOW
if @party_command_window.openness > 254
xx = 0
yy = Graphics.height - @party_command_window.height
width = @party_command_window.contents.width
rectcm1 = Rect.new(xx + OFS, yy + OFS, width, WLH)
rectcm2 = Rect.new(rectcm1.x, rectcm1.y + WLH, width, WLH)
rectttl = Rect.new(rectcm1.x, rectcm1.y, width, WLH * 2)
@party_command_window.index = 0 if Mouse.within?(rectcm1)
@party_command_window.index = 1 if Mouse.within?(rectcm2)
@party_command_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
#END
end
end
end
class Window_Message < Window_Base
def input_pause
self.pause = true
wait(10)
Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C) || (Mouse.lclick? if !SceneManager.scene_is?(Scene_Map))
Input.update
self.pause = false
end
end
#Mouse Title/File - Basic Mouse System Addon
#----------#
#Features: Adds basic mouse functionality to the Title screen and Save screen
# and GameOver screen!
# Left click pretty much acts as the accept button
# Right click pretty much acts as the cancel button
#
#Usage: Plug and Play
#
#No Customization
#
#----------#
#-- Script by: V.M of D.T
#--- Same Terms as Basic Mouse System
class Scene_Title < Scene_Base
def update
super
mouse_input
end
def mouse_input
new_game_rect = Rect.new(@command_window.x + 12, @command_window.y + 12, @command_window.contents.width, 24)
cont_rect = Rect.new(new_game_rect.x, new_game_rect.y + 24, new_game_rect.width, 24)
shutdown_rect = Rect.new(cont_rect.x, cont_rect.y + 24, cont_rect.width, 24)
rectttl = Rect.new(cont_rect.x, new_game_rect.y, cont_rect.width, 24*3)
@command_window.index = 0 if Mouse.within?(new_game_rect)
@command_window.index = 1 if Mouse.within?(cont_rect)
@command_window.index = 2 if Mouse.within?(shutdown_rect)
@command_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
end
end
class Scene_File < Scene_MenuBase
alias mouse_update update
def update
mouse_update
mouse_input
end
def mouse_input
xx = 0
yy = 56
width = Graphics.width
rectcm1 = Rect.new(xx, yy, width, savefile_height)
rectcm2 = Rect.new(xx, yy + rectcm1.height, width, savefile_height)
rectcm3 = Rect.new(xx, yy + rectcm1.height * 2, width, savefile_height)
rectcm4 = Rect.new(xx, yy + rectcm1.height * 3, width, savefile_height)
rectttl = Rect.new(xx, yy, width, rectcm1.height * 4)
rectcmA = Rect.new(0, yy - 12, Graphics.width, 24)
rectcmB = Rect.new(0, Graphics.height - 12, Graphics.width, 24)
@scroll = self.top_index
last_index = @index
@index = (0 + @scroll) if Mouse.within?(rectcm1)
@index = (1 + @scroll) if Mouse.within?(rectcm2)
@index = (2 + @scroll) if Mouse.within?(rectcm3)
@index = (3 + @scroll) if Mouse.within?(rectcm4)
cursor_down(false) if Mouse.within?(rectcmB) and Mouse.slowpeat
cursor_up(false) if Mouse.within?(rectcmA) and Mouse.slowpeat
if @index != last_index
Sound.play_cursor
@savefile_windows[last_index].selected = false
@savefile_windows[@index].selected = true
end
on_savefile_ok if Mouse.lclick? and Mouse.within?(rectttl)
on_savefile_cancel if Mouse.rclick? and Mouse.within?(rectttl)
end
end
class Scene_Gameover
alias mouse_update update
def update
mouse_update
goto_title if Mouse.lclick? or Mouse.rclick?
end
end
#Mouse Menu - Basic Mouse System Addon
#----------#
#Features: Adds basic mouse functionality to the Menu and subjacent options
# Left click pretty much acts as the accept button
# Right click pretty much acts as the cancel button
# Right click on map to pull it up
#
#Usage: Plug and Play
#
#No Customization
#
#----------#
#-- Script by: V.M of D.T
#--- Same Terms as Basic Mouse System
class Scene_Menu < Scene_MenuBase
OFS = 12
WLH = 24
alias mouse_update update
def update
mouse_update
mouse_input
end
def mouse_input
if !@status_window.active
hold_rect = []
xx = @command_window.x + OFS
yy = @command_window.y + OFS
width = @command_window.width
rectttl = Rect.new(xx, yy, width, WLH * 7)
for i in Range.new(0, 6)
hold_rect.push(Rect.new(xx, yy, width, WLH))
yy += WLH
end
for i in Range.new(0, 6)
@command_window.index = i if Mouse.within?(hold_rect[i])
end
@command_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@command_window.process_cancel if Mouse.rclick?
else
hold_rect = []
xx = @status_window.x + OFS
yy = @status_window.y + OFS
width = @status_window.width
rectttl = Rect.new(xx, yy, width, @status_window.contents.height)
for i in Range.new(0, $game_party.members.size - 1)
hold_rect.push(Rect.new(xx, yy, width, @status_window.item_height))
yy += @status_window.item_height
end
for i in Range.new(0, $game_party.members.size - 1)
@status_window.index = i if Mouse.within?(hold_rect[i])
end
@status_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@status_window.process_cancel if Mouse.rclick? and Mouse.within?(rectttl)
end
end
end
class Scene_Item
OFS = 12
WLH = 24
alias mouse_update update
def update
mouse_update
mouse_input
end
def mouse_input
if @category_window.active
hold_rect = []
xx = @category_window.x + OFS
yy = @category_window.y + OFS
width = @category_window.contents.width / 4
rectttl = Rect.new(xx, yy, width * 4, @category_window.contents.height)
for i in Range.new(0,3)
hold_rect.push(Rect.new(xx, yy, width, @category_window.contents.height))
xx += width
end
for i in Range.new(0,3)
@category_window.index = i if Mouse.within?(hold_rect[i])
end
@category_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@category_window.process_cancel if Mouse.rclick?
elsif @item_window.active
xx = @item_window.x + OFS
yy = @item_window.y + OFS
width = @item_window.contents.width / 2
hold_rect = []; temp = 2
smax = [@item_window.item_max, ((@item_window.height - 24) / WLH) * 2].min
rectttl = Rect.new(xx, yy, @item_window.contents.width, @item_window.contents.height)
rectcmA = Rect.new(@item_window.width / 2 - 50, yy - 12, 100, 24)
rectcmB = Rect.new(@item_window.width / 2 - 50, yy - 12 + @item_window.height, 100, 24)
for i in Range.new(0,smax - 1)
tempx = xx + width * (temp % 2)
tempy = yy + 24 * ((temp / 2) - 1)
hold_rect.push(Rect.new(tempx, tempy, width, WLH))
temp += 1
end
@scroll = @item_window.top_row + (@item_window.top_row * 2 / 2)
for i in Range.new(0,@item_window.item_max - 1)
next if hold_rect[i].nil?
@item_window.index = (i + @scroll) if Mouse.within?(hold_rect[i])
end
@item_window.cursor_down if Mouse.within?(rectcmB) and Mouse.slowpeat
@item_window.cursor_up if Mouse.within?(rectcmA) and Mouse.slowpeat
@item_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@item_window.process_cancel if Mouse.rclick?
elsif @actor_window.active
hold_rect = []
xx = @actor_window.x + OFS
yy = @actor_window.y + OFS
width = @actor_window.width
rectttl = Rect.new(xx, yy, width, @actor_window.contents.height)
for i in Range.new(0, $game_party.members.size - 1)
hold_rect.push(Rect.new(xx, yy, width, @actor_window.item_height))
yy += @actor_window.item_height
end
for i in Range.new(0, $game_party.members.size - 1)
@actor_window.index = i if Mouse.within?(hold_rect[i])
end
@actor_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@actor_window.process_cancel if Mouse.rclick?
end
end
end
class Scene_Skill
OFS = 12
WLH = 24
alias mouse_update update
def update
mouse_update
mouse_input
end
def mouse_input
if @command_window.active
hold_rect = []
xx = @command_window.x + OFS
yy = @command_window.y + OFS
width = @command_window.contents.width
rectttl = Rect.new(xx, yy, width, @command_window.contents.height)
for i in Range.new(0,@command_window.item_max-1)
hold_rect.push(Rect.new(xx, yy, width, WLH))
yy += WLH
end
for i in Range.new(0,@command_window.item_max-1)
@command_window.index = i if Mouse.within?(hold_rect[i])
end
@command_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@command_window.process_cancel if Mouse.rclick?
elsif @item_window.active
xx = @item_window.x + OFS
yy = @item_window.y + OFS
width = @item_window.contents.width / 2
hold_rect = []; temp = 2
smax = [@item_window.item_max, ((@item_window.height - 24) / WLH) * 2].min
rectttl = Rect.new(xx, yy, @item_window.contents.width, @item_window.contents.height)
rectcmA = Rect.new(@item_window.width / 2 - 50, yy - 12, 100, 24)
rectcmB = Rect.new(@item_window.width / 2 - 50, yy - 12 + @item_window.height, 100, 24)
for i in Range.new(0,smax - 1)
tempx = xx + width * (temp % 2)
tempy = yy + 24 * ((temp / 2) - 1)
hold_rect.push(Rect.new(tempx, tempy, width, WLH))
temp += 1
end
@scroll = @item_window.top_row + (@item_window.top_row * 2 / 2)
for i in Range.new(0,@item_window.item_max - 1)
next if hold_rect[i].nil?
@item_window.index = (i + @scroll) if Mouse.within?(hold_rect[i])
end
@item_window.cursor_down if Mouse.within?(rectcmB) and Mouse.slowpeat
@item_window.cursor_up if Mouse.within?(rectcmA) and Mouse.slowpeat
@item_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@item_window.process_cancel if Mouse.rclick?
elsif @actor_window.active
hold_rect = []
xx = @actor_window.x + OFS
yy = @actor_window.y + OFS
width = @actor_window.width
rectttl = Rect.new(xx, yy, width, @actor_window.contents.height)
for i in Range.new(0, $game_party.members.size - 1)
hold_rect.push(Rect.new(xx, yy, width, @actor_window.item_height))
yy += @actor_window.item_height
end
for i in Range.new(0, $game_party.members.size - 1)
@actor_window.index = i if Mouse.within?(hold_rect[i])
end
@actor_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@actor_window.process_cancel if Mouse.rclick?
end
end
end
class Scene_Equip
OFS = 12
WLH = 24
alias mouse_update update
def update
mouse_update
mouse_input
end
def mouse_input
if @command_window.active
hold_rect = []
xx = @command_window.x + OFS
yy = @command_window.y + OFS
width = @command_window.width / 3
rectttl = Rect.new(xx, yy, width * 3, @command_window.contents.height)
for i in Range.new(0, 2)
hold_rect.push(Rect.new(xx, yy, width, WLH))
xx += width
end
for i in Range.new(0, 2)
@command_window.index = i if Mouse.within?(hold_rect[i])
end
@command_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@command_window.process_cancel if Mouse.rclick?
elsif @slot_window.active
hold_rect = []
xx = @slot_window.x + OFS
yy = @slot_window.y + OFS
width = @slot_window.width
rectttl = Rect.new(xx, yy, width, @slot_window.contents.height)
for i in Range.new(0, 4)
hold_rect.push(Rect.new(xx, yy, width, WLH))
yy += WLH
end
for i in Range.new(0, 4)
@slot_window.index = i if Mouse.within?(hold_rect[i])
end
@slot_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@slot_window.process_cancel if Mouse.rclick?
elsif @item_window.active
xx = @item_window.x + OFS
yy = @item_window.y + OFS
width = @item_window.contents.width / 2
hold_rect = []; temp = 2
smax = [@item_window.item_max, ((@item_window.height - 24) / WLH) * 2].min
rectttl = Rect.new(xx, yy, @item_window.contents.width, @item_window.contents.height)
rectcmA = Rect.new(@item_window.width / 2 - 50, yy - 12, 100, 24)
rectcmB = Rect.new(@item_window.width / 2 - 50, yy - 12 + @item_window.height, 100, 24)
for i in Range.new(0,smax - 1)
tempx = xx + width * (temp % 2)
tempy = yy + 24 * ((temp / 2) - 1)
hold_rect.push(Rect.new(tempx, tempy, width, WLH))
temp += 1
end
@scroll = @item_window.top_row + (@item_window.top_row * 2 / 2)
for i in Range.new(0,@item_window.item_max - 1)
next if hold_rect[i].nil?
@item_window.index = (i + @scroll) if Mouse.within?(hold_rect[i])
end
@item_window.cursor_down if Mouse.within?(rectcmB) and Mouse.slowpeat
@item_window.cursor_up if Mouse.within?(rectcmA) and Mouse.slowpeat
@item_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@item_window.process_cancel if Mouse.rclick?
end
end
end
class Scene_Status
alias mouse_update update
def update
mouse_update
mouse_input
end
def mouse_input
@status_window.process_pagedown if Mouse.lclick?
@status_window.process_cancel if Mouse.rclick?
end
end
class Scene_End
OFS = 12
WLH = 24
alias mouse_update update
def update
mouse_update
mouse_input
end
def mouse_input
hold_rect = []
xx = @command_window.x + OFS
yy = @command_window.y + OFS
width = @command_window.width
rectttl = Rect.new(xx, yy, width, @command_window.contents.height)
for i in Range.new(0, 2)
hold_rect.push(Rect.new(xx, yy, width, WLH))
yy += WLH
end
for i in Range.new(0, 2)
@command_window.index = i if Mouse.within?(hold_rect[i])
end
@command_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@command_window.process_cancel if Mouse.rclick?
end
end
#Mouse Shop - Basic Mouse System Addon
#----------#
#Features: Adds basic mouse functionality to the Shop!
# Left click pretty much acts as the accept button
# Right click pretty much acts as the cancel button
#
#Usage: Plug and Play
#
#No Customization
#
#----------#
#-- Script by: V.M of D.T
#--- Same Terms as Basic Mouse System
class Scene_Shop
OFS = 12
WLH = 24
alias mouse_update update
def update
mouse_update
mouse_input
end
def mouse_input
if @command_window.active
hold_rect = []
xx = @command_window.x + OFS
yy = @command_window.y + OFS
width = @command_window.contents.width / 3
rectttl = Rect.new(xx, yy, width * 3, WLH)
for i in Range.new(0, 2)
hold_rect.push(Rect.new(xx, yy, width, WLH))
xx += width
end
for i in Range.new(0, 2)
@command_window.index = i if Mouse.within?(hold_rect[i])
end
@command_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@command_window.process_cancel if Mouse.rclick?
elsif @buy_window.active
hold_rect = []
xx = @buy_window.x + OFS
yy = @buy_window.y + OFS
width = @buy_window.contents.width
rectttl = Rect.new(xx, yy, @buy_window.contents.width, @buy_window.contents.height)
rectcmA = Rect.new(@buy_window.width / 2 - 50, yy - 12, 100, 24)
rectcmB = Rect.new(@buy_window.width / 2 - 50, yy - 12 + @buy_window.height, 100, 24)
for i in Range.new(0,@buy_window.item_max - 1)
hold_rect.push(Rect.new(xx, yy, width, WLH))
yy += WLH
end
@scroll = @buy_window.top_row + (@buy_window.top_row * 2 / 2)
for i in Range.new(0,@buy_window.item_max - 1)
next if hold_rect[i].nil?
@buy_window.index = (i + @scroll) if Mouse.within?(hold_rect[i])
end
@buy_window.cursor_down if Mouse.within?(rectcmB) and Mouse.slowpeat
@buy_window.cursor_up if Mouse.within?(rectcmA) and Mouse.slowpeat
@buy_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@buy_window.process_cancel if Mouse.rclick?
elsif @number_window.active
xx = @number_window.x + @number_window.contents.width - 26
yy = @number_window.y + @number_window.contents.height / 2 - 36
width = 24
rectttl = Rect.new(@number_window.x, @number_window.y, @number_window.width, @number_window.height)
rectcmA = Rect.new(xx, yy - 24, 36, 36)
rectcmB = Rect.new(xx, yy + 24, 36, 36)
@number_window.change_number(1) if Mouse.within?(rectcmA) and Mouse.lclick?(true)
@number_window.change_number(-1) if Mouse.within?(rectcmB) and Mouse.lclick?(true)
@number_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl) and !Mouse.within?(rectcmA) and !Mouse.within?(rectcmB)
@number_window.process_cancel if Mouse.rclick?
@number_window.refresh
elsif @category_window.active
hold_rect = []
xx = @category_window.x + OFS
yy = @category_window.y + OFS
width = @category_window.contents.width / 4
rectttl = Rect.new(xx, yy, width * 4, @category_window.contents.height)
for i in Range.new(0,3)
hold_rect.push(Rect.new(xx, yy, width, @category_window.contents.height))
xx += width
end
for i in Range.new(0,3)
@category_window.index = i if Mouse.within?(hold_rect[i])
end
@category_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@category_window.process_cancel if Mouse.rclick?
elsif @sell_window.active
xx = @sell_window.x + OFS
yy = @sell_window.y + OFS
width = @sell_window.contents.width / 2
hold_rect = []; temp = 2
smax = [@sell_window.item_max, ((@sell_window.height - 24) / WLH) * 2].min
rectttl = Rect.new(xx, yy, @sell_window.contents.width, @sell_window.contents.height)
rectcmA = Rect.new(@sell_window.width / 2 - 50, yy - 12, 100, 24)
rectcmB = Rect.new(@sell_window.width / 2 - 50, yy - 12 + @sell_window.height, 100, 24)
for i in Range.new(0,smax - 1)
tempx = xx + width * (temp % 2)
tempy = yy + 24 * ((temp / 2) - 1)
hold_rect.push(Rect.new(tempx, tempy, width, WLH))
temp += 1
end
@scroll = @sell_window.top_row + (@sell_window.top_row * 2 / 2)
for i in Range.new(0,@sell_window.item_max - 1)
next if hold_rect[i].nil?
@sell_window.index = (i + @scroll) if Mouse.within?(hold_rect[i])
end
@sell_window.cursor_down if Mouse.within?(rectcmB) and Mouse.slowpeat
@sell_window.cursor_up if Mouse.within?(rectcmA) and Mouse.slowpeat
@sell_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@sell_window.process_cancel if Mouse.rclick?
end
end
end
class Window_ShopNumber
alias mouse_refresh refresh
def refresh
mouse_refresh
xx = self.contents.width - 30
yy = self.contents.height / 2 - 36
self.contents.draw_text(xx, yy - 24, 24, 24, \"+\", 1)
self.contents.draw_text(xx, yy + 24, 24, 24, \"-\", 1)
end
end
#Mouse Name - Basic Mouse System Addon
#----------#
#Features: Adds basic mouse functionality to the Name Input screen!
# Left click pretty much acts as the accept button
# Right click pretty much acts as the cancel button
#
#Usage: Plug and Play
#
#No Customization
#
#----------#
#-- Script by: V.M of D.T
#--- Same Terms as Basic Mouse System
class Scene_Name
OFS = 12
WLH = 24
alias mouse_update update
def update
mouse_update
mouse_input
end
def mouse_input
hold_rect = []
xx = @input_window.x + OFS
yy = @input_window.y + OFS
width = (@input_window.contents.width - 12 ) / 10
rectttl = Rect.new(xx, yy, @input_window.contents.width, @input_window.contents.height)
for i in Range.new(0, 89)
hold_rect.push(Rect.new(xx, yy, width, WLH))
xx += width
xx += 12 if (i + 1) % 5 == 0
if (i + 1) % 10 == 0
xx = @input_window.x + OFS
yy += WLH
end
end
for i in Range.new(0, 89)
@input_window.index = i if Mouse.within?(hold_rect[i])
end
@input_window.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
@input_window.process_back if Mouse.rclick?
end
end
#Mouse Map - Basic Mouse System Addon
#----------#
#Features: Adds basic mouse functionality to the map events!
# Right clicking on a adjacent event activates them!
#
#Usage: Plug and Play
#
#No Customization
#
#----------#
#-- Script by: V.M of D.T
#--- Same Terms as Basic Mouse System
class Scene_Map
alias mouse_update update
def update
mouse_update
mouse_input_events
end
def mouse_input_events
xx = $game_player.screen_x
yy = $game_player.screen_y
xx -= 16;
recttop = Rect.new(xx - 6, yy - 80, 44, 48)
rectrit = Rect.new(xx + 32, yy - 36, 48, 44)
rectbot = Rect.new(xx - 6, yy, 44, 48)
rectleft = Rect.new(xx - 48, yy - 38, 48, 44)
mouse_action(8) if Mouse.within?(recttop)
mouse_action(6) if Mouse.within?(rectrit)
mouse_action(2) if Mouse.within?(rectbot)
mouse_action(4) if Mouse.within?(rectleft)
call_menu if Mouse.rclick? and !$game_map.interpreter.running?
end
def mouse_action(d)
return if !Mouse.rclick?
$game_player.set_direction(d)
$game_player.check_action_event
end
end
class Window_Message < Window_Base
def input_pause
self.pause = true
wait(10)
Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C) || Mouse.lclick?
Input.update
self.pause = false
end
end
class Window_Command
OFS = 12
WLH = 24
alias mouse_update update
def update
mouse_update
mouse_input if SceneManager.scene_is?(Scene_Map) and self.active
end
def mouse_input
hold_rect = []
xx = self.x + OFS
yy = self.y + OFS
width = self.contents.width
rectttl = Rect.new(xx, yy, width, WLH * 4)
for i in Range.new(0, self.item_max - 1)
hold_rect.push(Rect.new(xx, yy, width, WLH))
yy += WLH
end
for i in Range.new(0, self.item_max - 1)
self.index = i if Mouse.within?(hold_rect[i])
end
self.process_ok if Mouse.lclick? and Mouse.within?(rectttl)
self.process_cancel if Mouse.rclick?
end
end
class Window_NumberInput
OFS = 12
WLH = 24
alias mouse_update update
def update
mouse_update
mouse_input if SceneManager.scene_is?(Scene_Map) and self.active
end
def mouse_input
hold_rect = []
xx = self.x + OFS
yy = self.y + OFS
width = 20
rectttl = Rect.new(xx, yy, self.contents.width, WLH)
for i in Range.new(0, @digits_max - 1)
hold_rect.push(Rect.new(xx, yy, width, WLH))
xx += width
end
for i in Range.new(0, @digits_max - 1)
@index = i if Mouse.within?(hold_rect[i])
end
rectok = Rect.new(xx, yy, 34, 24)
rectnum = Rect.new(self.x + OFS, yy, @digits_max * 20, WLH)
self.process_ok if Mouse.within?(rectok) and Mouse.lclick?
process_mouse_change if Mouse.within?(rectnum)
end
def refresh
contents.clear
change_color(normal_color)
s = sprintf(\"%0*d\", @digits_max, @number)
@digits_max.times do |i|
rect = item_rect(i)
rect.x += 1
draw_text(rect, s[i,1], 1)
end
draw_text(self.contents.width - 24, 0, 34, WLH, \"OK\")
end
def update_placement
self.width = @digits_max * 20 + padding * 2 + 34
self.height = fitting_height(1)
self.x = (Graphics.width - width) / 2
if @message_window.y >= Graphics.height / 2
self.y = @message_window.y - height - 8
else
self.y = @message_window.y + @message_window.height + 8
end
end
def process_mouse_change
return unless active
Sound.play_cursor
place = 10 ** (@digits_max - 1 - @index)
n = @number / place % 10
@number -= n * place
n = (n + 1) % 10 if Mouse.lclick?
n = (n + 9) % 10 if Mouse.rclick?
@number += n * place
refresh
end
end
#Mouse Cursor - Basic Mouse System Addon
#----------#
#Features: Adds a customizable mouse cursor! Bonus!
#
#Usage: Plug and Play
#
#Customization: MOUSE_ICON, the index of the icon for the cursor
#
#----------#
#-- Script by: V.M of D.T
#--- Same Terms as Basic Mouse System
#MOUSE_ICON, set to the index of the icon to use as a cursor
MOUSE_ICON = 147
SHOWMOUS = Win32API.new \'user32\', \'ShowCursor\', \'i\', \'i\'
SHOWMOUS.call(0)
module DataManager
class << self
alias mouse_init init
end
def self.init
mouse_init
$cursor = Mouse_Cursor.new
end
end
class Scene_Base
alias cursor_update update_basic
def update_basic
cursor_update
mouse_cursor
end
def mouse_cursor
pos = Mouse.pos?
$cursor.x = pos[0]
$cursor.y = pos[1]
end
end
class Mouse_Cursor < Sprite_Base
def initialize
super
draw_cursor
self.z = 255
end
def draw_cursor
self.bitmap = nil
self.bitmap = Cache.system(\"Iconset\")
rect = Rect.new(MOUSE_ICON % 16 * 24, MOUSE_ICON / 16 * 24, 24, 24)
self.bitmap.blt(0, 0, self.bitmap, rect)
self.src_rect.set(0, 0, 24, 24)
end
end |