Woratana Screen&Tone Tester - LuZi -  07-08-2012
 
 
Woratana Screen&Tone Tester 
 
สคริปต์เขียนโดย : Woratana  
ลิงค์ต้นฉบับ : http://community.thaiware.com/index.php/topic/336208-xp-script-screen-fog-tone-tester-eaouieiaeoiaaadheaia/ 
 
 
รายละเอียด : 
สคริปต์นี้มีไว้สำหรับ Mapper (นักวาดแมพ) และคนที่สนใจตกแต่งบรรยากาศแมพครับ โดยมันจะช่วยให้ตอนเรากำลังเลือกหาโทนสีที่เข้ากับแมพ  
ไม่ต้องคอยปิดเกมแล้วมาแก้ทุกครั้ง เราสามารถแก้ไขค่าสีต่าง ๆ ในโทนได้ในเกม แล้วดูผลลัพธ์ได้ทันทีครับ 
 
นอกจากนั้นยังใช้เทสโทนสีสำหรับหมอกได้ด้วย~ 
เตือนนิด ว่าอย่าจำสลับกันระหว่างค่า hue ของหมอก กับโทนสีหมอกนะครับ 
(โทนสีหมอกเราใช้คำสั่งอีเว้นท์กำหนดโทนสีหมอกโดยเฉพาะ ส่วนค่า hue เรากำหนดในหน้าต่างที่เลือกรูปหมอก กำหนดขนาด ความเร็วการขยับ)- แก้ไขโทนสีแมพ และโทนสีหมอกได้อิสระในเกม และจะเห็นผลการแก้ไขทันที
 
 
- ปรับปุ่มสำหรับบังคับสคริปต์นี้เองได้
 
 
- ถ้ายังไม่ใช้ สามารถตั้งให้สคริปต์นี้ไม่ทำงานได้ ไม่จำเป็นต้องลบสคริปต์ออกจาก Script Editor หรือเอาไปไว้ใต้ Main
 
 
- สามารถซ่อนอินเตอร์เฟซของ Tone Tester ขณะกำลังใช้งานอยู่ได้ เรายังบังคับแก้ไขโทนสีได้ตามปกติ แต่จะมองไม่เห็นอินเตอร์เฟซเท่านั้น
 
 
 
 
สกรีนช๊อต : 
![[Image: 2ahe6o4.jpg]](http://i25.tinypic.com/2ahe6o4.jpg)  
 
วิธีการใช้งาน :  
วิธีใช้แบบละเอียดมีอยู่ในสคริปต์ครับ มีทั้งภาษาไทยและภาษาอังกฤษ 
 
วิธีใช้แบบย่อ ๆ ก็คือ... 
- ให้เลือกสีที่เราต้องการแก้ไข (แดง เขียว เหลือง หรือเทา) แล้วก็กดปุ่มเพื่อเพิ่ม/ลดค่าสีในสีนั้น 
- เลือกได้ว่าจะเปลี่ยนค่าสีในโทนสีแมพ หรือโทนสีหมอก โดยการเปลี่ยนโหมด 
- ซ่อนหน้าต่าง Tone Tester ได้ ถ้ามันบังให้เรามองเห็นแมพเต็ม ๆ ไม่ชัด 
 
 
โค๊ดสคริปต์ 
Code: #=============================================================== 
# ? [XP] ? Screen & Fog Tone Tester ? ? 
#-------------------------------------------------------------- 
# ? by Woratana [[email protected]] 
# ? Thaiware RPG Maker Community 
# ? Released on: 03/05/2008 
# ? Version: 1.0 
#-------------------------------------------------------------- 
# ? Special Thanks: Shun's Input Script 
#-------------------------------------------------------------- 
 
WORA_SFTT_TURN_ON = true # (true/false) 
# Do you want to run this script in game? 
# (Change to 'false' when you don't want to use this script) 
# คุณต้องการรันสคริปต์นี้ในเกมหรือไม่? (เปลี่ยนเป็น false ถ้าคุณยังไม่ต้องการใช้) 
 
#=============================================================== 
# ** HOW TO USE : วิธีการใช้ 
#-------------------------------------------------------------- 
# [ENGLISH ภาษาอังกฤษ] 
# ? You can turn this off when not using it by set constant above, 
# WORA_SFTT_TURN_ON = false 
# ? Interface of Tone Tester will be like this 
#----------------------------------------------------------------- 
# R: ... G: ... B : ... GRAY: ...                      Mode: ... 
#----------------------------------------------------------------- 
# R: Amount of RED Color in tone 
# G: Amount of GREEN Color in tone 
# B: Amount of BLUE Color in tone 
# GRAY: Amount of GRAY in tone 
# 
# Mode: Mode you are controlling: 
# - MAP for Map Tone 
# - FOG for Fog Tone 
# >> Text color of 'Mode' will tell you what color you're controlling 
# 
# ? You can change color you want to control by press following button on keyboard: 
# - 'R' for Red 
# - 'G' for Green 
# - 'B' for Blue 
# - 'V' for Gray 
# ? You can change amount in color you're controlling by press: 
# - 'Y' to +1 
# - 'N' to -1 
# - 'U' to +10 
# - 'M' to -10 
# ? You can hide/unhide Tone Tester by press 'H' 
# (Tone Tester will still running, you just can't see its interface) 
# ? You can change mode from MAP <=> FOG by press 'J' 
# 
# ? If you don't like the default button that use to control any part, 
# you can change them in setup part below 
 
#=================================================================== 
# [THAI ภาษาไทย] 
# ? ถ้าคุณไม่ต้องการใช้สคริปต์นี้ในเกม  ให้ไปตั้งค่าที่บรรทัดด้านบน ดังนี้: 
# WORA_SFTT_TURN_ON = false 
# ? อินเตอร์เฟซของ Tone Tester จะเป็นแบบนี้~ 
#----------------------------------------------------------------- 
# R: ... G: ... B : ... GRAY: ...                      Mode: ... 
#----------------------------------------------------------------- 
# R: ค่าสีของสีแดงในโทน 
# G: ค่าสีของสีเขียวในโทน 
# B: ค่าสีของสีฟ้าในโทน 
# GRAY: ค่าของสีเทาในโทน 
# 
# Mode: โหมดที่คุณกำลังควบคุมอยู่ ซึ่งมีโหมดดังนี้: 
# - MAP ถ้าคุณกำลังควบคุมโทนสีของแผนที 
# - FOG ถ้าคุณกำลังควบคุมโทนสีของหมอก 
# >> สีตัวอักษรของ Mode จะบอกคุณว่าคุณกำลังควบคุมสีอะไรอยู่ 
# 
# ? คุณสามารถเลือกสีที่คุณต้องการควบคุม โดยกดปุ่มต่อไปนี้บนคีย์บอร์ด: 
# - 'R' สำหรับสีแดง 
# - 'G' สำหรับสีเขียว 
# - 'B' สำหรับสีฟ้า 
# - 'V' สำหรับสีเทา 
# ? คุณสามารถเพิ่ม/ลดค่าสีของสีที่กำลังควบคุมอยู่ได้ โดยกดปุ่มต่อไปนี้: 
# - 'Y' เพื่อ +1 
# - 'N' เพื่อ -1 
# - 'U' เพื่อ +10 
# - 'M' เพื่อ -10 
# ? คุณสามารถซ่อน/เลิกซ่อน Tone Tester โดยกดปุ่ม 'H' 
# (Tone Tester ยังทำงานอยู่ แต่คุณจะมองไม่เห็นอินเตอร์เฟซของมันเท่านั้น) 
# ? คุณสามารถเปลี่ยนโหมดที่ต้องการควบคุม ระหว่าง MAP กับ FOG โดยกดปุ่ม 'J' 
# 
# ? ถ้าคุณไม่ถนัดใช้ปุ่มต่าง ๆ ข้างต้นในการควบคุม คุณสามารถเปลี่ยนเป็นปุ่มที่ต้องการได้ 
# โดยใช้ส่วนเซ็ตอัพสคริปต์ด้านล่าง 
#=============================================================== 
 
if WORA_SFTT_TURN_ON 
class Tone_Tester 
  #============================================================= 
  # START +++++ INPUT BUTTON SETUP +++++  
  #============================================================= 
  # put capital letter of alphabet on the button you want to use 
  # e.g. 'R' means button 'R' on keyboard 
  # ใส่ตัวอักษรภาษาอังกฤษตัวใหญ่ ของปุ่มที่คุณต้องการใช้ 
  # เช่น 'R' หมายถึง คุณเซ็ตให้ใช้ปุ่ม 'R' (หรือ 'พ/ฑ') บนคีย์บร์ด 
  #-------------------------------------------------------- 
  # Button to change controlling color to following color 
  # ปุ่มสำหรับเลือกสีที่ต้องการควบคุม 
  RED = 'R' 
  GREEN = 'G' 
  BLUE = 'B' 
  GRAY = 'V' 
   
  # Button to increase / Decrease controlling color 
  # ปุ่มสำหรับ เพิ่ม/ลด ค่าสีในสีที่เรากำลังควบคุมอยู่ 
  PLUS_1 = 'Y' # +1 
  MINUS_1 = 'N' # -1 
  PLUS_10 = 'U' # +10 
  MINUS_10 = 'M' # -10 
   
  # Button to show/hide screen tone tester 
  # (You can still increase/decrease tone even though the interface is hiding) 
  # ปุ่มสำหรับ แสดง/ซ่อน Tone Tester 
  # (คุณยังสามารถ เพิ่ม/ลด ค่าสีของโทนได้ตามปกติ แม้ว่าจะอินเตอร์เฟซสคริปต์จะไม่แสดงบนหน้าจอ) 
  HIDE = 'H' 
   
  # Button to switch mode from Map Tone <=> Fog Tone 
  # ปุ่มสำหรับเปลี่ยนโหมด ระหว่าง โทนสีของแมพ <=> โทนสีของหมอก 
  MODE = 'J' 
  #=============================================================== 
  # END +++++ INPUT BUTTON SETUP +++++  
  #=============================================================== 
   
  attr_accessor :control 
  def initialize 
    @text = Sprite.new 
    @text.z = 100000 
    @text.bitmap = Bitmap.new(640, 32) 
    @text2 = Sprite.new 
    @text2.z = 100001 
    @text.opacity = @text2.opacity = 160 
    @text2.bitmap = Bitmap.new(640, 32) 
    @text.bitmap.font.name = @text2.bitmap.font.name = 'Arial' 
    @text.bitmap.font.size = @text2.bitmap.font.size = 22 
    @last_tone = $last_tone = Tone.new(0,0,0,0) 
    @control = @new_control = 0 
    @mode = @new_mode = 1 
    @mode_max = 2 
    draw_text_rgb 
    draw_text_controlling 
  end 
   
  def draw_text_rgb 
    @text.bitmap.clear 
    @text.bitmap.fill_rect(0,0,@text.bitmap.width,@text.bitmap.height, Color.new(0,0,0)) 
    textr = 'R: ' + @last_tone.red.to_s 
    textg = 'G: ' + @last_tone.green.to_s 
    textb = 'B: ' + @last_tone.blue.to_s 
    textgg = 'Gray: ' + @last_tone.gray.to_s 
    @text.bitmap.font.color = Color.new(255,0,0) 
    @text.bitmap.draw_text(0,0,640,32, textr) 
    @text.bitmap.font.color = Color.new(0,140,0) 
    @text.bitmap.draw_text(@text.bitmap.text_size(textr).width + 8,0,640,32, textg) 
    @text.bitmap.font.color = Color.new(0,0,255) 
    @text.bitmap.draw_text(@text.bitmap.text_size(textr).width + @text.bitmap.text_size(textg).width + 16,0,640,32, textb) 
    @text.bitmap.font.color = Color.new(255,255,255) 
    @text.bitmap.draw_text(@text.bitmap.text_size(textr).width + @text.bitmap.text_size(textg).width + @text.bitmap.text_size(textb).width + 24,0,640,32, textgg) 
  end 
 
  def draw_text_controlling 
    @text2.bitmap.clear 
    case @control 
    when 0; @text2.bitmap.font.color = Color.new(255,0,0) 
    when 1; @text2.bitmap.font.color = Color.new(0,140,0) 
    when 2; @text2.bitmap.font.color = Color.new(0,0,255) 
    when 3; @text2.bitmap.font.color = Color.new(255,255,255) 
    end 
    case @mode 
    when 1; textco = 'MAP  ' 
    when 2; textco = 'FOG  ' 
    end 
    textco = 'Mode: ' + textco 
    @text2.bitmap.draw_text(0,0,640,32, textco, 2) 
  end 
   
  def update 
    if Input.trigger?(Input::A_Z[HIDE]) # Hide 
      @text.visible = @text2.visible = [email protected] 
    elsif Input.trigger?(Input::A_Z[MODE]) # Switch Mode 
      @new_mode = @new_mode + 1 > @mode_max ? 1 : @new_mode + 1 
    end 
    if @mode != @new_mode 
      @mode = @new_mode 
      draw_text_controlling 
    end 
    case @mode 
    when 1 # Map 
      tone_old = 
      [$last_tone.red, $last_tone.green, $last_tone.blue, $last_tone.gray] 
    when 2 # Fog 
      tone_old = 
      [$game_map.fog_tone.red, $game_map.fog_tone.green, $game_map.fog_tone.blue, 
      $game_map.fog_tone.gray] 
    end 
    if Input.trigger?(Input::A_Z[RED]); @new_control = 0 
    elsif Input.trigger?(Input::A_Z[GREEN]); @new_control = 1 
    elsif Input.trigger?(Input::A_Z[BLUE]); @new_control = 2 
    elsif Input.trigger?(Input::A_Z[GRAY]); @new_control = 3 
    end 
    if @control != @new_control 
      @control = @new_control 
      draw_text_controlling 
    end 
    if Input.trigger?(Input::A_Z[PLUS_1]) # Increase 1 
      tone_old[@control] += 1 
    elsif Input.trigger?(Input::A_Z[MINUS_1]) # Decrease 1 
      tone_old[@control] -= 1 
    elsif Input.trigger?(Input::A_Z[PLUS_10]) # Increase 10 
      tone_old[@control] += 10 
    elsif Input.trigger?(Input::A_Z[MINUS_10]) # Decrease 10 
      tone_old[@control] -= 10 
    end 
    case @mode 
    when 1 # Map 
      $last_tone = Tone.new(tone_old[0],tone_old[1],tone_old[2],tone_old[3])  
    when 2 # Fog 
      $game_map.fog_tone = Tone.new(tone_old[0],tone_old[1],tone_old[2],tone_old[3]) 
    end 
    if (@mode == 1 and @last_tone != $last_tone) or 
      (@mode == 2 and @last_tone != $game_map.fog_tone) 
      if @mode == 1 
        @last_tone = $last_tone 
        $game_screen.start_tone_change(@last_tone, 0) 
      elsif @mode == 2 
        @last_tone = $game_map.fog_tone 
        $game_map.start_fog_tone_change(@last_tone, 0) 
      end 
      draw_text_rgb 
    end 
  end 
end 
 
$worale = {} if $worale.nil? 
$worale['ToneTester'] = true 
$tone_test = Tone_Tester.new 
 
class Interpreter 
  alias wora_interpret_com223_tonet command_223 
  def command_223 
    $last_tone = @parameters[0] 
    wora_interpret_com223_tonet 
  end 
end 
 
class Scene_Map 
  alias wora_scemap_upd_tint update 
  def update 
    $tone_test.update 
    wora_scemap_upd_tint 
  end 
end 
 
class Game_Map; attr_accessor :fog_tone; end 
 
#========================================== 
# SHUN's INPUT SCRIPT 
#========================================== 
unless $@ 
  class << Input 
    alias :__orig_press? :press? 
    alias :__orig_trigger? :trigger? 
    alias :__orig_repeat? :repeat? 
    alias :__orig_update :update 
  end 
end 
module Input 
  NUM = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109] 
  A_Z = { 
    "A" => 110, "B" => 111, "C" => 112, "D" => 113, "E" => 114, 
    "F" => 115, "G" => 116, "H" => 117, "I" => 118, "J" => 119, 
    "K" => 120, "L" => 121, "M" => 122, "N" => 123, "O" => 124, 
    "P" => 125, "Q" => 126, "R" => 127, "S" => 128, "T" => 129, 
    "U" => 130, "V" => 131, "W" => 132, "X" => 133, "Y" => 134, "Z" => 135 
  } 
  CLICK = {"L" => 136, "R" => 137, "M" => 139} 
  VK = [0x70, 0x30, 0x41, 0x01] 
   
  @@get_keystate = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i') 
  @@get_cursor_pos = Win32API.new('user32', 'GetCursorPos', 'p', 'i') 
  @@press_count = {} 
  module_function 
 
  def vkey(num) 
    case num 
    when 100..109 
      return VK[1] + num - 100 
    when 110..135  
      return VK[2] + num - 110 
    when 136..139 
      return VK[3] + num - 136 
    end 
  end 
  def key_state(vk_code) 
    state = @@get_keystate.call(vk_code) 
    return (state.abs == 0x8000 or state.abs == 0x8001) 
  end 
  def trigger?(num) 
    return __orig_trigger?(num) if num < 85 
    count = @@press_count[vkey(num)] 
    return true if count == 0 
    return (count.nil? and press?(num)) 
  end 
  def press?(num) 
    return __orig_press?(num) if num < 85 
    vk = vkey(num) 
    if @@press_count[vk].nil? 
      if key_state(vk) 
        @@press_count[vk] = 0 
        return true 
      else 
        return false 
      end 
    else 
      return true 
    end 
  end 
  def trigger?(num) 
    return __orig_trigger?(num) if num < 85 
    count = @@press_count[vkey(num)] 
    return true if count == 0 
    return (count.nil? and press?(num)) 
  end 
  def repeat?(num) 
    return __orig_repeat?(num) if num < 85 
    return true if trigger?(num) 
    count = @@press_count[vkey(num)] 
    return false if count.nil? 
    return (count >= 15 and (count - 15) % 4 == 0) 
  end 
  def update 
    __orig_update 
    @@press_count.each {|vk, count| 
      next if count.nil? 
      @@press_count[vk] = (key_state(vk) ? count + 1 : nil) 
    } 
  end 
end 
end # Turn ON? 
#======================================================================== 
# [END] XP Screen & Fog Tone Tester by Woratana [[email protected]] 
#======================================================================== 
 
 
 
 |