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 | #============================================================================== # ■ Window_Message #------------------------------------------------------------------------------ # 顯示文章的訊息息窗口。 #============================================================================== # ●文章字體放大及顯示臉圖.名字.文字速度控制簡易型腳本 BY 愚零鬥武多 #============================================================================== # 使用方法:在Main之前插入此腳本 # 在Graphics\pictures內再新增一個資料夾"face",所有臉圖的檔案都放在其中 # 臉圖圖檔大小:120*120相素 # ■■■■■■■■■■■■■■■■■■■■■■■■■■■ # 在事件中顯示文章之前以"◆腳本:"指令控制對話框 # ◆腳本:$game_system.message_type = # ["圖檔名",臉圖位置("左"."右"),不透明度,"人名",臉圖翻轉("反")] # 臉圖顯示功能在文章選項.數值輸入.金錢數量.戰鬥中都能正常執行 # 臉圖會自動跟隨文章選項的上中下位置調整位置,無須設定 # 顯示臉圖時文章寫到箭頭處就要換下一行才文字能正常顯示(和2003一樣) # 圖檔名必須在Graphics\pictures\face裡存在,否則會出現找不到文件的ERROR. # --------------------------------------------------------------- # 要改變名字的顯示色,請在第207行修改(預設為黃色) # --------------------------------------------------------------- # 文字速度控制碼為\s[n],n值範圍0到50,數值越大越慢,可製作斷氣效果 # 開關1開啟狀態在顯示文字時若連打確定鍵可加快顯示速度 # --------------------------------------------------------------- # ■■■■■■■■■■■■■■■■■■■■■■■■■■■ # 實例說明: # --------------------------------------------------------------- # ◆更改文章選項:中,顯示 # ◆腳本:$game_system.message_type = # :[0,0,120] # ◆文章:此為正常狀態,臉圖不顯示,不透明度120 # --------------------------------------------------------------- # ◆更改文章選項:下,顯示 # ◆腳本:$game_system.message_type = # :["男主角","左",160] # ◆文章:此為男主角臉圖在左邊的狀態,不透明度160 # --------------------------------------------------------------- # ◆更改文章選項:上,顯示 # ◆腳本:$game_system.message_type = # :["女主角","右",255] # ◆文章:此為女主角臉圖在右邊的狀態,不透明度255 # --------------------------------------------------------------- # ◆更改文章選項:下,顯示 # ◆腳本:$game_system.message_type = # :["男主角","左",255,"張國痔"] # ◆文章:此為男主角臉圖在左邊的狀態,顯示人名(張國痔),不透明度255 # --------------------------------------------------------------- # ◆腳本:$game_system.message_type = # :["女主角","右",255,"如花","反"] # ◆文章:此為女主角臉圖在右邊的狀態,顯示人名(如花)並反轉臉圖 #============================================================================== #============================================================================== class Game_System #-------------------------------------------------------------------------- # ● 定義實例變量 #-------------------------------------------------------------------------- attr_accessor :message_type # 對話框形式 alias window_message_initialize initialize # message_type初始化 def initialize window_message_initialize @message_type = [0,0,255] end end class Window_Message < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化 #-------------------------------------------------------------------------- def initialize super(0, 304, 640, 160) self.contents = Bitmap.new(width-32 , height-32 ) self.visible = false self.z = 9998 @fade_in = false @fade_out = false @contents_showing = false @cursor_width = 0 self.active = false self.index = -1 # 初始化 @face = nil @message_count = 0 @message_wait = false @speed = 0 @fast = false end #-------------------------------------------------------------------------- # ● 釋放 #-------------------------------------------------------------------------- def dispose terminate_message $game_temp.message_window_showing = false if @input_number_window != nil @input_number_window.dispose end super end #-------------------------------------------------------------------------- # ● 處理訊息結束 #-------------------------------------------------------------------------- def terminate_message # 清除顯示中標誌 @contents_showing = false # 呼叫信息調用 if $game_temp.message_proc != nil $game_temp.message_proc.call end # 清除文章、選擇項、輸入數值的相關變量 $game_temp.message_text = nil $game_temp.message_proc = nil $game_temp.choice_start = 99 $game_temp.choice_max = 0 $game_temp.choice_cancel_type = 0 $game_temp.choice_proc = nil $game_temp.num_input_start = 99 $game_temp.num_input_variable_id = 0 $game_temp.num_input_digits_max = 0 # 關閉金錢窗口 if @gold_window != nil @gold_window.dispose @gold_window = nil end # 關閉名字窗口 if @name_text != nil @name_text.dispose @name_text = nil end # 釋放資源 if @face != nil @face.bitmap.clear @face = nil end # 初始化 @message_count = 0 @message_wait = false @speed = 0 @fast = false end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh # 變數代入 @face_name = $game_system.message_type[0] @face_type = $game_system.message_type[1] # 根據@face_name內的檔案名顯示臉圖與座標建立 if @face_name != 0 @face = Sprite.new @face.bitmap = Bitmap.new("Graphics/pictures/face/#{@face_name}") @face.ox = @face.bitmap.width / 2 @face.oy = @face.bitmap.height / 2 @face.z = 9999 case @face_type when "左" @face.x = 80 when "右" @face.x = 560 end @face.y = self.y + 70 else # @face_name=0時清除臉圖 if @face != nil @face.bitmap.clear @face = nil end end # 臉圖的左右座標建立 self.x = 0 case @face_type when 0 self.width = 640 @move = 36 name_x = 0 # @face_type=0時清除臉圖 if @face != nil @face.bitmap.clear @face = nil end when "左" self.width = 640 @move = 165 name_x = 0 when "右" self.width = 640 @move = 5 name_x = 480 end # 臉圖的正反轉 if @face != nil && $game_system.message_type[4] != nil if $game_system.message_type[4] == "反" @face.mirror = true end elsif @face != nil @face.mirror = false end # 名字視窗的建立 if $game_system.message_type[3] != nil && @face != nil if @name_text == nil name = $game_system.message_type[3] @name_text = Window_Base.new(name_x,self.y+110,160,64) @name_text.contents = Bitmap.new(@name_text.width-32 , @name_text.height-32 ) # 名字的顏色可在Color.new(255, 255, 0, 255)中修改相關參數 @name_text.contents.font.color = Color.new(90,250, 70, 255) @name_text.contents.font.size = 25 @name_text.contents.draw_text(0, 0, 128, 32, name, 1) @name_text.z = 9999 @name_text.opacity = 0 @name_text.back_opacity = 0 end end @x = 8 @y = 0 @cursor_width = 0 # 到選擇項的下一行字 if $game_temp.choice_start == 0 @x = 8 case @face_type when 0 @move = 120 when "左" @move = 220 when "右" @move = 60 end end # 輸入數值的情形 if $game_temp.num_input_variable_id > 0 digits_max = $game_temp.num_input_digits_max number = $game_variables[$game_temp.num_input_variable_id] @input_number_window = Window_InputNumber.new(digits_max) @input_number_window.number = number @input_number_window.x = @move @input_number_window.y = self.y + $game_temp.num_input_start * 32 end end #-------------------------------------------------------------------------- # ● 設置窗口位置與不透明度 #-------------------------------------------------------------------------- def reset_window if $game_temp.in_battle self.y = 0 else case $game_system.message_position when 0 # 上 self.y = 0 when 1 # 中 self.y = 160 when 2 # 下 self.y = 320 end end if $game_system.message_frame == 0 self.opacity = 255 else self.opacity = 0 end self.back_opacity = $game_system.message_type[2] end #-------------------------------------------------------------------------- # ● 刷新畫面 #-------------------------------------------------------------------------- def update super # 漸變的情形下 if @fade_in self.contents_opacity += 24 if @input_number_window != nil @input_number_window.contents_opacity += 24 end if self.contents_opacity == 255 @fade_in = false end return end # 輸入數值的情形下 if @input_number_window != nil && @message_wait == false @input_number_window.update # 確定 if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) $game_variables[$game_temp.num_input_variable_id] = @input_number_window.number $game_map.need_refresh = true # 釋放輸入數值窗口 @input_number_window.dispose @input_number_window = nil terminate_message end return end # 顯示訊息中的情形下 if @contents_showing && @message_wait == false # 如果不是在顯示選擇項中就顯示暫停標誌 if $game_temp.choice_max == 0 self.pause = true end # 取消 if Input.trigger?(Input::B) if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0 $game_system.se_play($data_system.cancel_se) $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1) terminate_message end end # 確定 if Input.trigger?(Input::C) if $game_temp.choice_max > 0 $game_system.se_play($data_system.decision_se) $game_temp.choice_proc.call(self.index) end terminate_message end return end # 在漸變以外等待顯示的訊息與選擇項的場合 if @fade_out == false && $game_temp.message_text != nil @contents_showing = true $game_temp.message_window_showing = true # 等待訊息計數 if @message_count > 0 @message_count -= 1 # 連打確定鍵加速功能(開關1開啟時才生效) if Input.repeat?(Input::C) && $game_switches[1] @message_count = 0 @message_wait = false @fast = true else @fast = false return end end # 等待訊息關閉時 if @message_wait == false && @fast == false reset_window refresh end # 文字等待處理 update_text(@fast) @fast = false Graphics.frame_reset self.visible = true return end # 沒有可以顯示的訊息、但是窗口為可見的情形下 if self.visible && @message_wait == false @fade_out = true self.opacity -= 48 if self.opacity == 0 self.visible = false @fade_out = false $game_temp.message_window_showing = false end return end end #-------------------------------------------------------------------------- # ● 刷新光標矩形 #-------------------------------------------------------------------------- def update_cursor_rect if @index >= 0 n = $game_temp.choice_start + @index self.cursor_rect.set(@move+2, n * 32, @cursor_width, 32) else self.cursor_rect.empty end end #-------------------------------------------------------------------------- # ● 文字等待處理 #-------------------------------------------------------------------------- def update_text(fast) # 等待訊息關閉時 if @message_wait == false && fast == false self.contents.clear self.contents = Bitmap.new(width-32 , height-32 ) self.contents.font.color = normal_color end # 等待顯示的文字的情形下 if $game_temp.message_text != nil text = $game_temp.message_text # 限制文字處理 begin last_text = text.clone text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] } end until text == last_text text.gsub!(/\\[Nn]\[([0-9]+)\]/) do $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : "" end # 為了方便、? "\\\\" 變換為 "\000" text.gsub!(/\\\\/) { "\000" } # "\\C" 變為 "\001" 、"\\G" 變為 "\002" text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" } text.gsub!(/\\[Gg]/) { "\002" } # "\\S" 變為 "\003" text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" } # c 讀取 1 個字 (如果不能取得文字就循環) while ((c = text.slice!(/./m)) != nil) # \\ 的情形下 if c == "\000" # 還原為本來的文字 c = "\\" end # \C[n] 的情形下 if c == "\001" # 更改文字色 text.sub!(/\[([0-9]+)\]/, "") color = $1.to_i if color >= 0 and color <= 7 self.contents.font.color = text_color(color) end # 下面的文字 next end # \G 的情形下 if c == "\002" # 生成金錢窗口 if @gold_window == nil @gold_window = Window_Gold.new @gold_window.x = 560 - @gold_window.width if $game_temp.in_battle @gold_window.y = 192 else @gold_window.y = self.y >= 128 ? 32 : 384 end @gold_window.opacity = self.opacity @gold_window.back_opacity = self.back_opacity end # 下面的文字 next end # 另起一行文字的情形下 if c == "\n" # 刷新選擇項及光標的高 if y >= $game_temp.choice_start @cursor_width = [@cursor_width, @x].max end # y 加 1 @y += 1 @x = 8 # 移動到選擇項的下一行 if y >= $game_temp.choice_start @x = 8 end # 下面的文字 next end # \s[n]的情形(文字速度,n值為0到50,值越大速度越慢) if c == "\003" text.sub!(/\[([0-9]+)\]/, "") speed = $1.to_i if speed >= 0 && speed <= 50 @speed = speed end @message_wait = true $game_temp.message_text = text # 下面的文字 next end # 描繪文字 self.contents.font.size = 25 self.contents.draw_text(@move + @x, 32 * @y, 40, 32, c) # x 要描繪文字的加法運算 @x += self.contents.text_size(c).width if @message_wait break end end # 等待訊息開啟以及文字顯示完畢 if @message_wait && text.slice(/./m) == nil $game_temp.message_text = nil @message_count = 0 @message_wait = false # 文字未顯示完畢 elsif @message_wait $game_temp.message_text = text @message_count = @speed # 等待文字訊息關閉時 else self.contents_opacity = 0 @fade_in = true if @input_number_window != nil @input_number_window.contents_opacity = 0 end end end # 選擇項的情形 if $game_temp.choice_max > 0 && @message_wait == false @item_max = $game_temp.choice_max self.active = true self.index = 0 end end end |
Direct link: https://paste.plurk.com/show/1612277