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
| #==============================================================================
# ** TDS Pause Screen
# Ver: 1.1
#------------------------------------------------------------------------------
# * Description:
# This script lets you pause the game by pressing a key.
#------------------------------------------------------------------------------
# * Features:
# Pause the game.
#------------------------------------------------------------------------------
# * Instructions:
# To change the look, text, settings of the script go to the editable settings
# area below and change it to your liking.
#
# To call the pause menu press the pause key you set in the settings.
#
# To disable the pause screen use this in a call script from an event:
#
# disable_pause_screen
#
# To enable the pause screen use this in a call script from an event:
#
# enable_pause_screen
#------------------------------------------------------------------------------
# List of Keys:
# Any of the keys below can be used as a paused key.
#
# :DOWN :LEFT :RIGHT :UP
#
# :A :B :C :X :Y :Z :L :R
#
# :SHIFT :CTRL :ALT
#
# :F5 :F6 :F7 :F8 :F9
#------------------------------------------------------------------------------
# * Notes:
# None.
#------------------------------------------------------------------------------
# WARNING:
#
# Do not release, distribute or change my work without my expressed written
# consent, doing so violates the terms of use of this work.
#
# If you really want to share my work please just post a link to the original
# site.
#
# * Not Knowing English or understanding these terms will not excuse you in any
# way from the consequenses.
#==============================================================================
# * Import to Global Hash *
#==============================================================================
($imported ||= {})[:TDS_Pause_Screen] = true
#==============================================================================
# ** TDS
#------------------------------------------------------------------------------
# A module containing TDS data structures, mostly script settings.
#==============================================================================
module TDS
#============================================================================
# ** Pause_Screen_Settings
#----------------------------------------------------------------------------
# This Module contains Pause Screen Settings & Methods.
#============================================================================
module Pause_Screen_Settings
#--------------------------------------------------------------------------
# * Constants (Settings)
#--------------------------------------------------------------------------
# Pause Key
Pause_Key = :ALT
# Scenes in which the game cannot be paused.
#Pause_Scene_Disabled = [Scene_Title]
# If True you can pause the game even if an event is running.
Ignore_Interpreter = true
# Pause Text
Pause_Text = "Pause"
# Pause Text Font Size
Pause_Text_Font_Size = 40
# Pause Text Font Name
Pause_Text_Font_Name = Font.default_name
# Pause Text Font Color
Pause_Text_Font_Color = Font.default_color
# Pause Text Font Bold Flag
Pause_Text_Font_Bold = false
# Pause Text Font Italic Flag
Pause_Text_Font_Italic = false
# Blur Pause Image
Blur_Pause_Image = true
# Pause Image Tone
Pause_Image_Tone = Tone.new(-30, -30, -30)
#--------------------------------------------------------------------------
# * Determine if Game can be Paused
#--------------------------------------------------------------------------
def self.can_pause_game?
# Return false if Scene cannot be paused
#return false if Pause_Scene_Disabled.include?(SceneManager.scene.class)
# Return false if Game Pause is disabled
return false if $game_system.game_pause_disabled?
# Return false if Interpreter is running and not ignoring it
return false if Ignore_Interpreter == false and $game_map.interpreter.running?
# Return true
return true
end
#--------------------------------------------------------------------------
# * Apply Pause Settings on Sprite
#--------------------------------------------------------------------------
def self.apply_pause_sprite_settings(sprite)
# Blur Sprite Bitmap
sprite.bitmap.blur if Blur_Pause_Image
# Set Sprite Bitmap Tone
sprite.tone.set(Pause_Image_Tone)
# Set Sprite Bitmap Font Size
sprite.bitmap.font.size = Pause_Text_Font_Size
# Set Sprite Bitmap Font Name
sprite.bitmap.font.name = Pause_Text_Font_Name
# Set Sprite Bitmap Font Color
sprite.bitmap.font.color = Pause_Text_Font_Color
# Set Sprite Bitmap Font Bold Flag
sprite.bitmap.font.bold = Pause_Text_Font_Bold
# Set Sprite Bitmap Font Italic Flag
sprite.bitmap.font.italic = Pause_Text_Font_Italic
# Draw Pause Text
sprite.bitmap.draw_text(sprite.bitmap.rect, Pause_Text, 1)
end
end
end
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
# This class handles temporary data that is not included with save data.
# The instance of this class is referenced by $game_temp.
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :game_paused # Game Paused Flag
attr_accessor :pause_frame_count # On Pause Frame Count
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias tds_pause_screen_game_temp_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(*args, &block)
# Run Original Method
tds_pause_screen_game_temp_initialize(*args, &block)
# Set Game Paused Flag & Pause Frame Count
@game_paused = false ; @pause_frame_count = 0
end
#--------------------------------------------------------------------------
# * Determine if Game has been paused
#--------------------------------------------------------------------------
def game_paused? ; @game_paused end
#--------------------------------------------------------------------------
# * On Game Pause Start Processing
#--------------------------------------------------------------------------
def on_game_pause_start
# Set Game Paused Flag & Pause Frame Count
@game_paused = true ; @pause_frame_count = Graphics.frame_count
end
#--------------------------------------------------------------------------
# * On Game Pause Ending Processing
#--------------------------------------------------------------------------
def on_game_pause_end
# Set Game Paused Flag & Graphics Frame Count
@game_paused = false ; Graphics.frame_count = @pause_frame_count
end
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles system data. It saves the disable state of saving and
# menus. Instances of this class are referenced by $game_system.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :game_pause_disabled # Game Pause Disabled Flag
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias tds_pause_screen_game_system_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(*args, &block)
# Run Original Method
tds_pause_screen_game_system_initialize(*args, &block)
# Set Game Pause Disabled Flag
@game_pause_disabled = false
end
#--------------------------------------------------------------------------
# * Determine if Game Pause is disabled
#--------------------------------------------------------------------------
def game_pause_disabled? ; @game_pause_disabled end
#--------------------------------------------------------------------------
# * Disable Game Pause
#--------------------------------------------------------------------------
def disable_game_pause ; @game_pause_disabled = true end
#--------------------------------------------------------------------------
# * Enable Game Pause
#--------------------------------------------------------------------------
def enable_game_pause ; @game_pause_disabled = false end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# * Disable Pause Screen
#--------------------------------------------------------------------------
def disable_pause_screen ; $game_system.disable_game_pause end
#--------------------------------------------------------------------------
# * Enable Pause Screen
#--------------------------------------------------------------------------
def enable_pause_screen ; $game_system.enable_game_pause end
end
#==============================================================================
# ** Graphics
#------------------------------------------------------------------------------
# The module that carries out graphics processing.
#==============================================================================
class << Graphics
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias tds_pause_screen_graphics_update update
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update(*args, &block)
# Update Game Pause Input
update_game_pause_input
# Run Original Method
tds_pause_screen_graphics_update(*args, &block)
end
#--------------------------------------------------------------------------
# * Update Game Pause Input
#--------------------------------------------------------------------------
def update_game_pause_input
# If Input Trigger (Pause Key)
if Input.trigger?(TDS::Pause_Screen_Settings::Pause_Key)
# Return if Game cannot be paused
return if !TDS::Pause_Screen_Settings.can_pause_game?
# Play OK Sound & Start Game Pause
Sound.play_ok ; start_game_pause
end
end
#--------------------------------------------------------------------------
# * Start Game Pause
#--------------------------------------------------------------------------
def start_game_pause
# Process on Game Pause Start
$game_temp.on_game_pause_start
# Make Pause Cover Sprite
@pause_cover = Sprite.new
@pause_cover.bitmap = snap_to_bitmap
@pause_cover.opacity = 0
@pause_cover.z = 5000
# Apply Pause Settings to Pause Cover Sprite
TDS::Pause_Screen_Settings.apply_pause_sprite_settings(@pause_cover)
# Fade In Pause Cover
15.times { tds_pause_screen_graphics_update ; @pause_cover.opacity += 17}
# Update Loop While Game is Paused
while $game_temp.game_paused? do
# Update Graphics & Input
tds_pause_screen_graphics_update ; Input.update
# Go Through Inputs
[TDS::Pause_Screen_Settings::Pause_Key, :B].each {|key|
# If Input Trigger
if Input.trigger?(key)
# Play Sound
key == TDS::Pause_Screen_Settings::Pause_Key ? Sound.play_ok : Sound.play_cancel
# Process Game Temp On Game Pause End
$game_temp.on_game_pause_end
end
}
end
# Fade Out Pause Cover
10.times { tds_pause_screen_graphics_update ; @pause_cover.opacity -= 26}
# Dispose of Pause Cover Sprite
@pause_cover.bitmap.dispose ; @pause_cover.dispose ; @pause_cover = nil
end
end |