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
| #╔════╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═════╗
#║ ╔══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╗ ║
#╠─╣ Smooth Cursor ╠─╣
#╠─╣ by RPG Maker Source. ╠─╣
#╠─╣ www.rpgmakersource.com ╠─╣
#║ ╚══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╝ ║
#╠════╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═════╣
#║ ┌────┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴─────┐ ║
#╠─┤ Version 1.0.4 24/05/15 DD/MM/YY ├─╣
#║ └────┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬─────┘ ║
#╠══════╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══════╣
#║ ║
#║ This work is protected by the following license: ║
#║ ╔══════════════════════════════════════════════════════════════════╗ ║
#║ │ │ ║
#║ │ Copyright © 2014 Maker Systems. │ ║
#║ │ │ ║
#║ │ This software is provided 'as-is', without any kind of │ ║
#║ │ warranty. Under no circumstances will the author be held │ ║
#║ │ liable for any damages arising from the use of this software. │ ║
#║ │ │ ║
#║ │ Permission is granted to anyone to use this software on their │ ║
#║ │ free or commercial games made with a legal copy of RPG Maker │ ║
#║ │ VX Ace, as long as Maker Systems - RPG Maker Source is │ ║
#║ │ credited within the game. │ ║
#║ │ │ ║
#║ │ Selling this code or any portions of it 'as-is' or as part of │ ║
#║ │ another code, is not allowed. │ ║
#║ │ │ ║
#║ │ The original header, which includes this copyright notice, │ ║
#║ │ must not be edited or removed from any verbatim copy of the │ ║
#║ │ sotware nor from any edited version. │ ║
#║ │ │ ║
#║ ╚══════════════════════════════════════════════════════════════════╝ ║
#║ ║
#║ ║
#╠══════════════════════════════════════════════════════════════════════════════╣
#║ 1. VERSION HISTORY. ▼ ║
#╠══════════════════════════════════════════════════════════════════════════════╣
#║ ║
#║ • Version 1.0.0, 24/11/14 - (DD/MM/YY). ║
#║ ║
#║ • Version 1.0.1, 30/11/14 - (DD/MM/YY). ║
#║ ║
#║ • Version 1.0.2, 17/12/14 - (DD/MM/YY). ║
#║ ║
#║ • Version 1.0.3, 30/03/15 - (DD/MM/YY). ║
#║ ║
#║ • Version 1.0.4, 24/05/15 - (DD/MM/YY). ║
#║ ║
#╠══════════════════════════════════════════════════════════════════════════════╣
#╠══════════════════════════════════════════════════════════════════════════════╣
#║ 2. USER MANUAL. ▼ ║
#╠══════════════════════════════════════════════════════════════════════════════╣
#║ ║
#║ ┌──────────────────────────────────────────────────────────────────────────┐ ║
#║ │ ■ Introduction. │ ║
#║ └┬┬┬┬──────────────────────────────────────────────────────────────────┬┬┬┬┘ ║
#║ ║
#║ Hello there! This script is "plug and play", you can simply insert it into ║
#║ your project and it will perform flawlessly. ║
#║ ║
#║ This script embellishes your GUIs by changing the way the default Window ║
#║ cursor works in RPG Maker VX Ace. The cursor will smoothly move to its new ║
#║ position when selecting items and will also smoothly change its size when ║
#║ needed. ║
#║ ║
#║ The scrolling of the window contents will also be smooth. ║
#║ ║
#║ We hope you enjoy it. ║
#║ ║
#║ Thanks for choosing our products. ║
#║ ║
#║ ┌──────────────────────────────────────────────────────────────────────────┐ ║
#║ │ ■ Configuration. │ ║
#║ └┬┬┬┬──────────────────────────────────────────────────────────────────┬┬┬┬┘ ║
#║ ║
#║ "How do I change the speed of the cursor movement?" ║
#║ Right click anywhere in the script editor and select "Find" (or CTRL + F) ║
#║ search for "DELAY_LEVEL" (without quotation marks). ║
#║ ║
#║ You will see something like "DELAY_LEVEL = 4" ║
#║ ║
#║ Set the number after the equality sign to any numer you like, bigger or ║
#║ equal than 1. The bigger the number, the stronger the deceleration effect ║
#║ and thus the slower the cursor speed when changing selections (or ║
#║ dimensions). Small numbers result in a faster deceleration, default value ║
#║ is 4. ║
#║ ║
#║ ║
#╠══════════════════════════════════════════════════════════════════════════════╣
#╠══════════════════════════════════════════════════════════════════════════════╣
#║ 3. NOTES. ▼ ║
#╠══════════════════════════════════════════════════════════════════════════════╣
#║ ║
#║ Have fun and enjoy! ║
#║ ║
#╠══════════════════════════════════════════════════════════════════════════════╣
#╠══════════════════════════════════════════════════════════════════════════════╣
#║ 4. CONTACT. ▼ ║
#╠══════════════════════════════════════════════════════════════════════════════╣
#║ ║
#║ Keep in touch with us and be the first to know about new releases: ║
#║ ║
#║ www.rpgmakersource.com ║
#║ www.facebook.com/RPGMakerSource ║
#║ www.twitter.com/RPGMakerSource ║
#║ www.youtube.com/user/RPGMakerSource ║
#║ ║
#║ Get involved! Have an idea for a system? Let us know. ║
#║ ║
#║ Spread the word and help us reach more people so we can continue creating ║
#║ awesome resources for you! ║
#║ ║
#╚══════════════════════════════════════════════════════════════════════════════╝)
#
#==============================================================================
# ** MakerSystems
#------------------------------------------------------------------------------
# Module for our Systems.
#==============================================================================
module MakerSystems
#============================================================================
# ** SmoothCursor
#----------------------------------------------------------------------------
# Module for Smooth Cursor.
#============================================================================
module SmoothCursor
#------------------------------------------------------------------------
# * Low values yield a fast effect. [OPT]
#------------------------------------------------------------------------
DELAY_LEVEL = 4
end
end
#==============================================================================
# ** Window_Selectable
#------------------------------------------------------------------------------
# Alias to Update. Update Cursor Replaced. Added method to handle the effect.
#==============================================================================
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# * Update Alias [NEW]
#--------------------------------------------------------------------------
alias_method(:ms_smooth_cursor_original_update, :update)
#--------------------------------------------------------------------------
# * Update [MOD]
#--------------------------------------------------------------------------
def update
# Original method.
ms_smooth_cursor_original_update
# Stop unless cursor update is needed.
return unless @ms_smooth_cursor_target && self.index >= 0 && !disposed?
# Update smooth cursor features.
ms_smooth_cursor_update
end
#--------------------------------------------------------------------------
# * Smooth Cursor Update [NEW]
#--------------------------------------------------------------------------
def ms_smooth_cursor_update
# Current Rect.
now = cursor_rect
# Get the target Rect.
target = @ms_smooth_cursor_target[0]
# Get the target Offset Y.
target_oy = @ms_smooth_cursor_target[1]
# Shortcut to desired delay.
delay = MakerSystems::SmoothCursor::DELAY_LEVEL.to_f
# Calculates and applies step value for X.
step = ((target.x - now.x).to_f / delay)
now.x += target.x > now.x ? step.ceil : step.floor
# Calculates and applies step value for Y.
step = ((target.y - now.y).to_f / delay)
now.y += target.y > now.y ? step.ceil : step.floor
# Calculates and applies step value for Width.
step = ((target.width - now.width).to_f / delay)
now.width += target.width > now.width ? step.ceil : step.floor
# Calculates and applies step value for Height.
step = ((target.height - now.height).to_f / delay)
now.height += target.height > now.height ? step.ceil : step.floor
if self.respond_to?(:visible_line_number) && visible_line_number == 1
# Calculates and applies step value for Offset Y.
step = ((target_oy - self.ox).to_f / delay)
self.ox += target_oy > self.ox ? step.ceil : step.floor
# If targets reached, stop ms_smooth_cursor_update.
if cursor_rect == target && self.ox == target_oy
@ms_smooth_cursor_target = nil
end
else
# Calculates and applies step value for Offset Y.
step = ((target_oy - self.oy).to_f / delay)
self.oy += target_oy > self.oy ? step.ceil : step.floor
# If targets reached, stop ms_smooth_cursor_update.
if cursor_rect == target && self.oy == target_oy
@ms_smooth_cursor_target = nil
end
end
end
#--------------------------------------------------------------------------
# * Top Col (HorzCommand), [NEW]
#--------------------------------------------------------------------------
def ms_smooth_cursor_hrzcommand_top_col=(col)
col = 0 if col < 0
col = col_max - 1 if col > col_max - 1
@ms_smooth_cursor_target_ox = col * (item_width + spacing)
end
#--------------------------------------------------------------------------
# * Bottom Col (HorzCommand). [NEW]
#--------------------------------------------------------------------------
def ms_smooth_cursor_hrzcommand_bottom_col=(col)
self.ms_smooth_cursor_hrzcommand_top_col = col - (col_max - 1)
end
#--------------------------------------------------------------------------
# * Ensure Cursor Visible (HorzCommand). [NEW]
#--------------------------------------------------------------------------
def ms_smooth_cursor_hrzcommand_ensure_cursor_visible
self.ms_smooth_cursor_hrzcommand_top_col = index if index < top_col
self.ms_smooth_cursor_hrzcommand_bottom_col = index if index > bottom_col
end
#--------------------------------------------------------------------------
# * Update Cursor. [REP]
#--------------------------------------------------------------------------
def update_cursor
if @cursor_all
cursor_rect.set(0, 0, contents.width, row_max * item_height)
self.top_row = 0
elsif @index < 0
cursor_rect.empty
else
if self.respond_to?(:visible_line_number) && visible_line_number == 1 &&
self.respond_to?(:top_col)
# Special case for HorzCommand window or any horizontally extended one.
ms_target_oy = self.ox
ms_smooth_cursor_hrzcommand_ensure_cursor_visible
if @ms_smooth_cursor_target_ox
ms_target_oy = @ms_smooth_cursor_target_ox
end
else
# Manages Offset Y as in ensure_cursor_visible but instead of using
# top_row to set the value, passes it to ms_smooth_cursor_update.
ms_target_oy = self.oy
if row < top_row || row > bottom_row
msrow = row
msrow = msrow - (page_row_max - 1) if row > bottom_row
msrow = 0 if msrow < 0
msrow = row_max - 1 if msrow > row_max - 1
ms_target_oy = msrow * item_height
end
end
# New targets.
@ms_smooth_cursor_target = [item_rect(@index), ms_target_oy]
end
end
end |