-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRS_CustomTitleScene.rb
302 lines (260 loc) · 10.3 KB
/
RS_CustomTitleScene.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
#================================================================
# The MIT License
# Copyright (c) 2020 biud436
# ---------------------------------------------------------------
# Free for commercial and non commercial use.
#================================================================
=begin
# * Name : 눈보라 효과가 적용된 타이틀 메뉴 / RS_CustomTitleScene.rb
# * Author : biud436
# * First Release Date : 2014. 06. 27
# * Description :
This script allows you to change the UI of Window_TitleCommand on title scene and also adds weather effect.
To use this script,
Place decompressed resource files in your Graphics/Pictures folder after downloading resource file at following the link.
Link : https://blog.naver.com/biud436/220042810055
But, This is pretty old script.
# * Version Log :
2019.12.20 (v1.1.0) :
- 리팩토링 및 이미지 수정
=end
$imported = {} if $imported.nil?
$imported["RS_CustomTitleScene.rb"] = true
module RS
module CustomTitle
# Image
# Our first step is to set all the images we need for the menu.
# You will see that it changes an animation of the menu button pressing the arrow key,
# When you press an up or down arrow key, it will change the index of menu image and
# it will pick the correct appearance for the title command.
# The image loads from Graphics/Pictures folder on the your root game directory.
IMAGE = {
:BASE => "base_1", # if the image is to symbol named :BASE, it represents there is a no selected image.
:START => "base_2", # if the image is to symbol called ":START", it represents it is selected the start button.
:CONTINUE => "base_3",
:SHUTDOWN => "base_4",
}
# All images must have a z-index in order to perform a z-index layering.
Z = {
:VIEWPORT => 1000, # Weather effect. its z-index must be pretty higher than other images.
:ICON => 156,
:MENU_BACKGROUND => 154,
:MENU_COMMAND_SPRITE => 155,
}
# 타이틀 커맨드의 위치
# :LEFT, :CENTER, :RIGHT 중 하나여야 합니다.
DEFAULT_ANCHOR = :LEFT
# 아이콘의 인덱스
# 아이콘을 표시하고 싶지 않다면 0으로 설정하세요.
# The icon allows you to show a icon label to certain button.
# But if you don't need to use it, you have to set the icon number is to 0.
ICON_INDEX = 272
end
end
#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# 타이틀을 만드는 스크립트입니다
#==============================================================================
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# * 초기화
#--------------------------------------------------------------------------
alias rs_custom_title_scene_start start
def start
rs_custom_title_scene_start
init_members
create_icon_sprite
create_weather_viewport
create_weather
end
#--------------------------------------------------------------------------
# * 아이콘 흔들기를 위한 변수를 선언해줍니다
#--------------------------------------------------------------------------
def init_members
@time = 0
end
#--------------------------------------------------------------------------
# * 날씨 효과를 그려줄 뷰포트를 선언합니다
#--------------------------------------------------------------------------
def create_weather_viewport
@weather_viewport = Viewport.new
@weather_viewport.z = RS::CustomTitle::Z[:VIEWPORT]
end
#--------------------------------------------------------------------------
# * 날씨 효과를 만들어줍니다
#--------------------------------------------------------------------------
def create_weather
@weather = Spriteset_Weather.new(@weather_viewport)
end
def dispose_icon
# 스프라이트 아이콘를 해제합니다
@icon.bitmap.dispose
@icon.dispose
end
def dispose_menu_command_sprite
# 스프라이트 메뉴를 해제합니다
@menu_command_sprite.bitmap.dispose
@menu_command_sprite.dispose
end
def dispose_menu_background
# 메뉴 뒷부분을 장식한 검정색 스프라이트를 해제합니다
@menu_background.bitmap.dispose
@menu_background.dispose
end
def dispose_weather
# 날씨 효과을 해제합니다
@weather.dispose
end
def dispose_viewport
# 뷰포트를 해제합니다
@weather_viewport.dispose
end
#--------------------------------------------------------------------------
# * 파괴
#--------------------------------------------------------------------------
alias rs_custom_title_scene_terminate terminate
def terminate
rs_custom_title_scene_terminate
dispose_icon
dispose_menu_command_sprite
dispose_menu_background
dispose_weather
dispose_viewport
end
#--------------------------------------------------------------------------
# * 아이콘 만들기
#--------------------------------------------------------------------------
def create_icon_sprite
@icon = Sprite.new
@icon.z = RS::CustomTitle::Z[:ICON]
@icon.visible = false
@icon.bitmap = Bitmap.new(24, 24)
bitmap = Cache.system("Iconset")
idx = RS::CustomTitle::ICON_INDEX
rect = Rect.new(idx % 16 * 24, idx / 16 * 24, 24, 24)
@icon.bitmap.blt(0, 0, bitmap, rect)
end
#--------------------------------------------------------------------------
# * 스프라이트 메뉴 만들기
#--------------------------------------------------------------------------
def create_sprite_menu
menu_command_bitmap = Cache.picture(RS::CustomTitle::IMAGE[:BASE])
menu_command_bitmap_width = menu_command_bitmap.width
menu_command_bitmap_height = menu_command_bitmap.height
black2 = Color.new(0, 0, 25, 64)
black1 = Color.new(0, 0, 0, 0)
base_tone = Tone.new(-10, 100, 20)
rect = Rect.new(0, 0, menu_command_bitmap_width, menu_command_bitmap_height)
# 검은색 바탕 부분을 그려줍니다
@menu_background = Sprite.new
@menu_background.bitmap = Bitmap.new(menu_command_bitmap_width, menu_command_bitmap_height)
@menu_background.bitmap.gradient_fill_rect(rect, black2, black1)
@menu_background.bitmap.blur
@menu_background.x = @command_window.x
@menu_background.y = @command_window.y
@menu_background.z = RS::CustomTitle::Z[:MENU_BACKGROUND]
# 타이틀 메뉴를 그려줍니다
@menu_command_sprite = Sprite.new
@menu_command_sprite.bitmap = menu_command_bitmap
@menu_command_sprite.x = @command_window.x
@menu_command_sprite.y = @command_window.y
@menu_command_sprite.z = RS::CustomTitle::Z[:MENU_COMMAND_SPRITE]
# 타이틀 메뉴의 톤을 바꿔줄 수 있습니다
@menu_command_sprite.tone = base_tone
end
#--------------------------------------------------------------------------
# * 아이콘 위치 지정
#--------------------------------------------------------------------------
def set_icon(x,y)
return if !@icon
bitmap = @icon.bitmap
@icon.x = (bitmap.width / 2) + x - 15
@icon.y = (bitmap.height / 2) + y
end
#--------------------------------------------------------------------------
# * 업데이트
#--------------------------------------------------------------------------
def update
super
# 커서의 움직임이 감지되면 그림을 변경합니다
change_sprite if !@command_window.nil? and @command_window.cursor_movable?
weather_update
# 플레이타임을 2로 나눈 나머지 값으로 0과 1로 분기됩니다
@time = (Graphics.frame_count / Graphics.frame_rate) % 2
end
#--------------------------------------------------------------------------
# * 눈보라 생성
#--------------------------------------------------------------------------
def weather_update
@weather.type = :snow
@weather.power = 3
@weather.ox = $game_map.display_x * 32
@weather.oy = $game_map.display_y * 32
@weather.update
end
#--------------------------------------------------------------------------
# * 그림 변경 하기
#--------------------------------------------------------------------------
def change_sprite
@icon.visible = true
@menu_command_sprite.bitmap = case @command_window.index
when 0
Cache.picture(RS::CustomTitle::IMAGE[:START])
when 1
Cache.picture(RS::CustomTitle::IMAGE[:CONTINUE])
when 2
Cache.picture(RS::CustomTitle::IMAGE[:SHUTDOWN])
end
# 매 프레임마다 0과 4로 분기되는 값입니다
@temp_x = @time * 4
set_icon(
@command_window.x + @temp_x,
@command_window.y + @command_window.index * @command_window.line_height
)
end
#--------------------------------------------------------------------------
# * 윈도우 기본 생성
#--------------------------------------------------------------------------
def create_command_window
menu_command_bitmap = Cache.picture(RS::CustomTitle::IMAGE[:BASE])
line_height = (menu_command_bitmap.height / 3).floor
@command_window = RS::Window_TitleCommand.new(line_height)
@command_window.set_handler(:new_game, method(:command_new_game))
@command_window.set_handler(:continue, method(:command_continue))
@command_window.set_handler(:shutdown, method(:command_shutdown))
create_sprite_menu
end
end
class RS::Window_TitleCommand < Window_TitleCommand
alias old_initialize initialize
def initialize(value)
old_initialize
@remain_line_height = value
@remain_window_width = 160
self.opacity = 0
self.padding = 0
self.contents_opacity = 0
self.arrows_visible = false
end
def set_line_height(value)
@remain_line_height = value
end
def update_placement
case RS::CustomTitle::DEFAULT_ANCHOR
when :RIGHT
self.x = (Graphics.width - width) - 20
when :LEFT
self.x = 20
else
self.x = (Graphics.width - width) / 2
end
self.y = (Graphics.height * 1.3 - height) / 2
end
def window_width
return @remain_window_width || 160
end
def line_height
return @remain_line_height || 45
end
end