RPGVX.net

  RPG-Maker VX => VX Skripte [Fertiger Code] => Thema gestartet von: Ðeity am Januar 09, 2010, 17:17:46

Titel: Notebook VX
Beitrag von: Ðeity am Januar 09, 2010, 17:17:46
Notebook VX

Updates
10.01.2010
[/list]
11.01.2010

Was macht das Script?
Mit diesem Script kannst du ein Notizbuch in dein Spiel einbauen, welches es dem Spieler erlaubt zu schreiben und zu malen!
Es gibt eine Anzahl an Seiten, die gespeichert und geladen werden können.
Die Bedinung ist recht simpel und es gibt viele Möglichkeiten.


Wie nutze ich das Script?
Ich würde euch empfehlen, erstmal alle Settings nach Bedarf zu verändern. Um das Notizbuch aufzuruffen, müsst Ihr nur folgende Zeile z.B. per Call Script aufruffen:
$scene = Scene_Notebook.new(zeichnen?)
Für das zeichnen? kann man true oder false einsetzen jenachdem, ob man schreiben oder zeichnen will. Lässt man es aus, startet es mit dem Zeichnen.

Demo
n/A


Screenshots
Denke es wird kein Screenshot gebraucht.

Das Script
Version 2.0
[/list]#----------------------------------------------------------------#
# Script:  Notebook VX                                           #
# by Deity                                                       #
# Mouse module by Near Fantastica                                #
# Keyboard module by ????(translated by Deity)                  #
#----------------------------------------------------------------#
# Description:                                                 #
# Dieses Script erlaubt es dem Benutzer ein Notizbuch in sein    #
# Spiel einzubauen. Das Notizbuch kann bei bedarf entweder mit   #
# der Maus oder der Tastatur "bemalt" werden.                    #
#----------------------------------------------------------------#
# Instructions:                                                  #
# Es sollten möglichst alle Settings dem Wunschaussehen angepasst#
# werden. Sobald dies erledigt ist, muss man nur noch das        #
# Notizbuch aufruffen. Dies geschieht mit folgendem Script:      #
# $scene = Scene_Notebook.new()                                  #
#?------------------------ Settings ----------------------------?#
#                   true = yes / false = no                      #
module Notebook
  USE_MOUSE = false # Soll die Maus benutzbar sein?
  KEY_TO_DRAW = Input::Z # Freie Knöpfe: X(A),Y(S),Z(D),L(Q),R(Q)
                         # Bei Z muss also D gedrückt werden.
  BGM = [
  "Town2", # Hintergrundmusik für das Notizbuch
  100, # Lautstärke
  100, # Geschwindigkeit
  ] # <= Nicht löschen!
  PAGE_TITLE = "Seite"
  MAX_PAGES = 6
  # Wähle die Farben für das Notizbuch
  # Um eine Farbe zu verändern, muss man die 4 Werte
  # in den Klammern verändern. Diese müssen zwischen
  # 0 und 255 sein.
  # (Rotanteil,Grünanteil,Blauanteil,Sichtbarkeit)
  COLORS = [
  Color.new(0,0,0,255), #Schwarz
  Color.new(255,255,255,255), # Weiß
  Color.new(255,0,0,255), # Rot
  Color.new(0,255,0,255), # Grün
  Color.new(0,0,255,255), # Blau
  Color.new(255,255,0,255), # Gelb
  ] # <= Nicht löschen!
  # Wähle die Namen für das Auswahlfenster
  COMMANDS_DRAW = [
  "Zeichnen", #Zeichnen
  "Farbe", #Farbe auswählen
  "Größe", #Größe auswählen
  "Speichern",
  "Laden",
  "Schreiben",
  "Löschen",
  ] # <= Nicht löschen!
  COMMANDS_TEXT = [
  "Schreiben", # Schreiben
  "Speichern",
  "Laden",
  "Zeichnen", # Zum Zeichnen
  "Löschen", # Alles löschen
  ] # <= Nicht löschen!
  # Namen für die Hintergrundbilder, falls nicht gewollt
  # einfach leer lassen sprich ""
  BACKGROUNDIMAGES = [
  "", # Drawing background
  "" # Writing background
  ] # <= Nicht löschen!
  TEXT_COLOR = Color.new(0,0,0,220) # Farbe für das Schreiben
  TEXT_SHADOW = true # Use Shadow?
  RAND = 16 # Rand schreiben
  RAND_DRAW = 5 # Rand Zeichnen
  # Kommentar für das untere Fenster beim Zeichnen.
  DRAW_TEXT = "[D: Zeichnen] [B: Zurück] [Shift: Beschleunigen]"
  # Komentar für das untere Fenster beim schreiben.
  WRITE_TEXT = "[Esc: Zurück]"
  # Anfangsfarbe für den Hintergrund
  BACKGROUND_START_COLOR = Color.new(255,255,255,255)
  # Anfangseinstellungen für den "cursor"
  CURSOR_START_VALUES = [
  80, #X-Koordinate
  80, #Y-Koordinate
  Color.new(0,0,0,255), #Farbe
  4, # Breite / Höhe
  ]
end
# Alles was ab jetzt folgt, sollte nur dann geändert werden,    #
# wenn man weis was man tut!                                    #
#?-------------------------------------------------------------?#
include Notebook
class Scene_Notebook < Scene_Base
  def initialize(draw = true)
    @draw = draw
    @mouse = USE_MOUSE
    @file = ""
    @text = []
    @lines = 0
    @text[0] = []
  end
  def start
    create_windows
    create_cursor
    create_background
    Audio.bgm_play("Audio/BGM/"+BGM[0],BGM[1],BGM[2])
  end
  def create_windows
    @command_draw = Window_Command.new(160,COMMANDS_DRAW)
    @command_text = Window_Command.new(160,COMMANDS_TEXT)
    pages = []
    for i in 0...MAX_PAGES
      i += 1
      string = PAGE_TITLE + " " + i.to_s
      pages.push(string)
    end
    @command_pages = Window_Command.new(160,pages)
    @command_pages.x = 160
    @command_pages.active = false
    @command_pages.visible = false
    @color = Window_ChooseColor.new(544,["","","","","",""],6)
    @help = Window_Help.new()
    @help.y = 416 - @help.height    
    @number = Window_NumberInput.new()
    @number.x = 160
    @number.y = 48
    @number.width = 62
    @number.visible = false
    @number.active = false
    @number.digits_max = 2
    if @draw == true
      @command_draw.active = true
      @command_draw.visible = true
      @command_text.active = false
      @command_text.visible = false
      @help.set_text(DRAW_TEXT)
    else
      @command_text.active = true
      @command_text.visible = true
      @command_draw.active = false
      @command_draw.visible = false
      @help.set_text(WRITE_TEXT)
    end
  end
  def create_cursor
    @cursor = Sprite.new
    if @draw
      @cursor.x = CURSOR_START_VALUES[0]
      @cursor.y = CURSOR_START_VALUES[1]
      @cursor.bitmap = Bitmap.new(CURSOR_START_VALUES[3],CURSOR_START_VALUES[3])
      @cursor.bitmap.fill_rect(0,0,CURSOR_START_VALUES[0],CURSOR_START_VALUES[1],CURSOR_START_VALUES[2])
    end
  end
  def create_background
    @background = Sprite.new
    @working_sprite = Sprite.new
    if @draw == true
      image = 0
    else
      image = 1
    end
    if BACKGROUNDIMAGES[image] == ""
      @background.bitmap = Bitmap.new(544,416)    
      @background.bitmap.fill_rect(0,0,544,416,BACKGROUND_START_COLOR)
    else
      @background.bitmap = Cache.system(BACKGROUNDIMAGES[image])
    end
    @working_sprite.bitmap = Bitmap.new(544,416)
    @working_sprite.z = @background.z + 1
    @working_sprite.bitmap.font.color = TEXT_COLOR
    @working_sprite.bitmap.font.shadow = TEXT_SHADOW
  end
  def refresh
    @working_sprite.bitmap.clear_rect(0,(24 * @lines) + RAND,544,24) if @text[@lines].size != 0
    string = ""
    if @text[@lines].size != 0
      for i in @text[@lines]
        string += i
      end
    end
    @working_sprite.bitmap.draw_text(RAND,(24 *@lines) + RAND,512,24,@text[@lines]) if @text[@lines].size != 0
  end
  def clear_errors
    for i in 0...@text.size
      if @text[i].size == 0
        @working_sprite.bitmap.clear_rect(0,(24 * i) + RAND,544,24)
      end
    end
  end      
  def delete_correctly
    if @text[@lines] != nil && @text[@lines].size == 0
      @working_sprite.bitmap.clear_rect(0,(24 * @lines) + RAND,544,24)
      @lines -= 1 if @lines > 0
      @text[@lines].delete_at(@text[@lines].size-1)  if @text[@lines].size != 0
    else
      @text[@lines].delete_at(@text[@lines].size-1)  if @text[@lines].size != 0
    end
  end
  def update_symbols_input
    if Input.press?(Input::Shift)
      if Input.trigger?(Input::Equal)
        @text[@lines].push("*")
      elsif Input.trigger?(Input::Comma)
        @text[@lines].push(";")
      elsif Input.trigger?(Input::Underscore)
        @text[@lines].push("_")
      elsif Input.trigger?(Input::Dot)
        @text[@lines].push(":")
      elsif Input.trigger?(Input::Backslash)
        @text[@lines].push("'")
      elsif Input.trigger?(Input::Forwardslash)
        @text[@lines].push("°")
      elsif Input.trigger?(Input::Numbers[0])
        @text[@lines].push("=")
      elsif Input.trigger?(Input::Numbers[1])
        @text[@lines].push("!")
      elsif Input.trigger?(Input::Numbers[2])
        @text[@lines].push('"')
      elsif Input.trigger?(Input::Numbers[3])
        @text[@lines].push("§")
      elsif Input.trigger?(Input::Numbers[4])
        @text[@lines].push("$")
      elsif Input.trigger?(Input::Numbers[5])
        @text[@lines].push("%")
      elsif Input.trigger?(Input::Numbers[6])
        @text[@lines].push("&")
      elsif Input.trigger?(Input::Numbers[7])
        @text[@lines].push("/")
      elsif Input.trigger?(Input::Numbers[8])
        @text[@lines].push("(")
      elsif Input.trigger?(Input::Numbers[9])
        @text[@lines].push(")")
      elsif Input.trigger?(Input::Lb)
        @text[@lines].push("?")
      end
    end
    if not Input.press?(Input::Shift)
      if Input.trigger?(Input::Equal)
        @text[@lines].push("+")
      elsif Input.trigger?(Input::Comma)
        @text[@lines].push(",")
      elsif Input.trigger?(Input::Underscore)
        @text[@lines].push("-")
      elsif Input.trigger?(Input::Dot)
        @text[@lines].push(".")
      elsif Input.trigger?(Input::Backslash)
        @text[@lines].push("#")
      elsif Input.trigger?(Input::Forwardslash)
        @text[@lines].push("°")
      elsif Input.trigger?(Input::Lb)
        @text[@lines].push("ß")
      end
    end
  end
  def update_keyboard
    if @text[@lines] != nil
      if @text[@lines].size * 13 >= 544 - RAND*2
        @lines += 1 if @lines != (((416 - 2*RAND)/24)-1).to_i
        @text[@lines] = []
      end
    end
    for i in 'A'...'Z'
      if Input.trigger?(Input::Letters[i])
        if Input.press?(Input::Shift)
          @text[@lines].push(i.upcase)
        else
          @text[@lines].push(i.downcase)
        end
      end
    end
    if Input.trigger?(Input::Letters['Z'])
      if Input.press?(Input::Shift)
        @text[@lines].push('Z'.upcase)
      else
        @text[@lines].push('Z'.downcase)
      end
    end
    if Input.trigger?(Input::Collon)
      if Input.press?(Input::Shift)
        @text[@lines].push('Ü'.upcase)
      else
        @text[@lines].push('ü'.downcase)
      end
    end
    if Input.trigger?(Input::Tilde)
      if Input.press?(Input::Shift)
        @text[@lines].push('Ö'.upcase)
      else
        @text[@lines].push('ö'.downcase)
      end
    end
    if Input.trigger?(Input::Quote)
      if Input.press?(Input::Shift)
        @text[@lines].push('Ä'.upcase)
      else
        @text[@lines].push('ä'.downcase)
      end
    end
    for i in 0...Input::Numbers.size
      if Input.trigger?(Input::Numbers[i])
        @text[@lines].push(i.to_s)
      end
    end
    if Input.trigger?(Input::Space)
      @text[@lines].push(" ")
    elsif Input.trigger?(Input::Back)
      delete_correctly
    elsif Input.trigger?(Input::Enter)
      @lines += 1 if @lines != (((416 - 2*RAND)/24)-1).to_i
      @text[@lines] = []
    end
    refresh
  end
  def set_cursor_color(color)
    Sound.play_decision
    @cursor.bitmap.fill_rect(0,0,@cursor.width,@cursor.height,color)
  end
  def set_cursor_size(w)
    if w != 0
      Sound.play_decision
      @cursor.bitmap.dispose
      @cursor.bitmap = Bitmap.new(w,w)
      @cursor.bitmap.fill_rect(0,0,w,w,COLORS[@color.index])
    else
      Sound.play_buzzer
    end
  end
  def update_windows
    @command_draw.update if @command_draw.active == true
    @command_text.update if @command_text.active == true
    @command_pages.update if @command_pages.active == true
    @color.update if @color.active == true  
    @number.update if @number.active == true
  end
  def active_window
    return true if @command_draw.active == false && @command_text.active == false && @number.active == false && @color.active == false && @command_pages.active == false
    return false
  end
  def draw_text_array
    for i in 0...@text.size
      string = ""
      for o in @text[i]
        for u in o
          string += u
        end
        @working_sprite.bitmap.draw_text(16,(24 *i)+ 16,512,24,string)
      end
    end
  end
  def update_cursor
    Mouse.update
    if @mouse && @draw
      @cursor.x,@cursor.y =Mouse.pos
    end
    if active_window && @mouse == false
      if Input.press?(Input::Shift)
        speed = 2
      else
        speed = 1
      end
      case Input.dir8
        when 1;  @cursor.y += speed
                       @cursor.x -= speed
        when 2;  @cursor.y += speed
        when 3;  @cursor.y += speed
                       @cursor.x += speed
        when 4;  @cursor.x -= speed
        when 7;  @cursor.y -= speed
                       @cursor.x -= speed
        when 6;  @cursor.x += speed
        when 9;  @cursor.y -= speed
                       @cursor.x += speed
        when 8;  @cursor.y -= speed
      end
      if @cursor.y < RAND_DRAW
        @cursor.y = RAND_DRAW
      end
      if @cursor.y + @cursor.height > 416 - RAND_DRAW
        @cursor.y = 416 - @cursor.height - RAND_DRAW
      end
      if @cursor.x < RAND_DRAW
        @cursor.x = RAND_DRAW
      end
      if @cursor.x + @cursor.width > 544 - RAND_DRAW
        @cursor.x = 544 - @cursor.width - RAND_DRAW
      end
    end
    if Input.press?(KEY_TO_DRAW) && active_window && @mouse == false
      @working_sprite.bitmap.fill_rect(@cursor.x,@cursor.y,@cursor.bitmap.width,@cursor.bitmap.height,@cursor.bitmap.get_pixel(0,0))
    end
    if @mouse && Mouse.press?(1) && active_window
      @working_sprite.bitmap.fill_rect(@cursor.x,@cursor.y,@cursor.bitmap.width,@cursor.bitmap.height,@cursor.bitmap.get_pixel(0,0))
    end
  end
  def update_helpwindow
    if @draw
      @help.visible = @command_draw.visible
    else
      @help.visible = @command_text.visible
    end
    if @help.visible == true
      if @draw
        @help.set_text(DRAW_TEXT)
      else
        @help.set_text(WRITE_TEXT)
      end
    end
  end    
  def close_all
    @command_draw.dispose
    @command_text.dispose
    @command_pages.dispose
    @number.dispose
    @help.dispose
    @color.dispose
    @background.dispose
    @working_sprite.dispose
    @cursor.dispose
  end
  def update
    update_windows if not active_window
    update_cursor if @draw
    update_symbols_input if not @draw && active_window
    update_keyboard if not @draw && active_window
    update_helpwindow
    refresh if @draw == false && active_window
    clear_errors if not @draw && active_window
    if Input.trigger?(Input::C)
      Sound.play_decision
      if @command_draw.active == true
        case @command_draw.index
        when 0
          @command_draw.active = false
          @command_draw.visible = false
        when 1
          @command_draw.active = false
          @command_draw.visible = false
          @color.active = true
          @color.visible = true
        when 2
          @command_draw.active = false
          @number.active = true
          @number.visible = true
        when 3
          @file = "save"
          @command_draw.active = false
          @command_pages.active = true
          @command_pages.visible = true
        when 4
          @file = "load"
          @command_draw.active = false
          @command_pages.active = true
          @command_pages.visible = true
        when 5
          close_all
          $scene = Scene_Notebook.new(false)
        when 6
          @working_sprite.bitmap.clear
        end
      elsif @command_text.active == true
        case @command_text.index
        when 0
          @command_text.active = false
          @command_text.visible = false
        when 1
          @file = "save"
          @command_text.active = false
          @command_pages.active = true
          @command_pages.visible = true
        when 2
          @file = "load"
          @command_text.active = false
          @command_pages.active = true
          @command_pages.visible = true
        when 3
          close_all
          $scene = Scene_Notebook.new(true)
        when 4
          @working_sprite.bitmap.clear
          @text = []
          @text[0] = []
          @lines = 0
        end
      elsif @color.active == true
        set_cursor_color(COLORS[@color.index])
      elsif @number.active == true
        set_cursor_size(@number.number)
      elsif @command_pages.active == true
        if @file == "save"
          if @draw == true
            $game_system.dump_bitmap(@command_pages.index,@working_sprite.bitmap)
          else
            $game_system.change_notetext(@command_pages.index,@text)
          end
        elsif @file == "load"
          if @draw == true
            @working_sprite.bitmap = $game_system.gimme_bitmap(@command_pages.index)
          elsif @draw == false
            @working_sprite.bitmap.clear
            @text = $game_system.notetext[@command_pages.index]
            @lines = $game_system.notetext[@command_pages.index].size - 1
            if @lines < 0
              @lines = 0
            end
            draw_text_array
          end
       end
     end
   end
   if Input.trigger?(Input::Esc)
     Sound.play_cancel
     if @command_draw.active == true
       close_all
       return_scene
     elsif @command_text.active == true
       close_all
       return_scene
     elsif active_window
      if @draw == true
        @command_draw.active = true
        @command_draw.visible = true
      elsif @draw == false
        @command_text.active = true
        @command_text.visible = true
      end
     elsif @color.active == true
       @color.active = false
       @color.visible = false
       @command_draw.active = true
       @command_draw.visible = true
     elsif @number.active == true
       @command_draw.active = true
       @number.active = false
       @number.visible = false
     elsif @command_pages.active == true
       @command_pages.active = false
       @command_pages.visible = false
       if @draw
         @command_draw.active = true
       else
         @command_text.active = true
       end
     end    
   end
 end
  def return_scene
    $scene = Scene_Map.new
  end
end  
# Author of the Mouse module
# Near Fantastica (special thanks)
module Mouse
  GetAsyncKeyState=Win32API.new("user32","GetAsyncKeyState",'i','i')
  GetKeyState=Win32API.new("user32","GetKeyState",'i','i')
  SetCursorPos=Win32API.new('user32','SetCursorPos','nn','n')
  GetCursorPo=Win32API.new('user32','GetCursorPos','p','i')
  ScreenToClient=Win32API.new('user32','ScreenToClient','lp','i')
  GetPrivateProfileStringA=Win32API.new('kernel32','GetPrivateProfileStringA','pppplp','l')
  FindWindowA=Win32API.new('user32','FindWindowA','pp','l')
  GetClientRect=Win32API.new('user32','GetClientRect','lp','i')
  GetWindowRect=Win32API.new('user32','GetWindowRect','lp','i')
  game_name="\0"*256
  GetPrivateProfileStringA.call('Game','Title','',game_name,255,".\\Game.ini")
  game_name.delete!("\0")
  @handle=FindWindowA.call('RGSS Player',game_name)
  module_function
  def click?(button)
    return true if @keys.include?(button)
    return false
  end  
  def press?(button)
    return true if @press.include?(button)
    return false
  end
  def set_pos(x_pos=0,y_pos=0)
    width,height=client_size
    if (x_pos.between?(0,width)&&y_pos.between?(0,height))
      SetCursorPos.call(client_pos[0]+x_pos,client_pos[1]+y_pos)
    end
  end
  def update
    @pos=Mouse.pos
    @keys,@press=[],[]
    @keys.push(1)if GetAsyncKeyState.call(1)&0x01==1
    @keys.push(2)if GetAsyncKeyState.call(2)&0x01==1
    @keys.push(3)if GetAsyncKeyState.call(4)&0x01==1
    @press.push(1)if pressed?(1)
    @press.push(2)if pressed?(2)
    @press.push(3)if pressed?(4)
  end  
  def pressed?(key)
    return true unless GetKeyState.call(key).between?(0,1)
    return false
  end
  def global_pos
    pos=[0,0].pack('ll')
    GetCursorPo.call(pos)!=0 ? (return pos.unpack('ll')):(return nil)
  end
  def pos
    x,y=screen_to_client(*global_pos)
    width,height=client_size
    begin
      x=0 if x<=0;y=0 if y<=0
      x=width if x>=width;y=height if y>=height
      return x,y
    end
  end
  def screen_to_client(x,y)
    return nil unless x&&y
    pos=[x,y].pack('ll')
    ScreenToClient.call(@handle,pos)!=0?(return pos.unpack('ll')):(return nil)
  end
  def client_size
    rect=[0,0,0,0].pack('l4')
    GetClientRect.call(@handle,rect)
    right,bottom=rect.unpack('l4')[2..3]
    return right,bottom
  end
  def client_pos
    rect=[0,0,0,0].pack('l4')
    GetWindowRect.call(@handle,rect)
    left,upper=rect.unpack('l4')[0..1]
    return left+4,upper+30
  end  
  def grid
    return nil if @pos.nil?
    return [(@pos[0]+$game_map.display_x/8)/32,(@pos[1]+$game_map.display_y/8)/32]
  end
end
class << Input  
  # * Alias List
  unless self.method_defined? (:oz_key_press)
    alias oz_key_press press?
    alias oz_key_trigger trigger?
    alias oz_key_repeat repeat?
    alias og_key_update update
  end
end
module Input  
  # Numbers not in the numpad
  Numbers      = []          
  Numbers[0]   = 48
  Numbers[1]   = 49
  Numbers[2]   = 50
  Numbers[3]   = 51
  Numbers[4]   = 52
  Numbers[5]   = 53
  Numbers[6]   = 54
  Numbers[7]   = 55
  Numbers[8]   = 56
  Numbers[9]   = 57  
  # Letters
  Letters         = {}        
  Letters['A']    = 65
  Letters['B']    = 66        
  Letters['C']    = 67
  Letters['D']    = 68        
  Letters['E']    = 69
  Letters['F']    = 70        
  Letters['G']    = 71
  Letters['H']    = 72        
  Letters['I']    = 73
  Letters['J']    = 74        
  Letters['K']    = 75
  Letters['L']    = 76        
  Letters['M']    = 77
  Letters['N']    = 78        
  Letters['O']    = 79
  Letters['P']    = 80        
  Letters['Q']    = 81
  Letters['R']    = 82        
  Letters['S']    = 83
  Letters['T']    = 84        
  Letters['U']    = 85
  Letters['V']    = 86        
  Letters['W']    = 87
  Letters['X']    = 88        
  Letters['Y']    = 89
  Letters['Z']    = 90
  # Other keys
  Back            = 138      
  Tab             = 139
  Enter           = 143      
  Shift           = 146
  Ctrl            = 147      
  Alt             = 148
  Capslock        = 150      
  Esc             = 157
  Space           = 32        
  End             = 35
  Home            = 36        
  Left            = 37
  Right           = 39        
  Del             = 46      
  Collon          = 186      
  Quote           = 222
  Equal           = 187      
  Comma           = 188
  Underscore      = 189      
  Dot             = 190
  Backslash       = 191      
  Tilde           = 192
  Lb              = 219      
  Rb              = 221
  Forwardslash    = 220  
  # Api
  State = Win32API.new("user32", "GetAsyncKeyState", ["i"], "i")
  PressDuration = {} # A hash for pressed keys and their durations
  #=============================================================================
  module_function
  #============================================================================
  # Update
  def update
    og_key_update
    for key in PressDuration.keys
      (State.call(key).abs & 0x8000 == 0x8000) ? PressDuration[key] +=
      1 : PressDuration.delete(key)
    end
  end
  def key_pressed?(key)
    if (State.call(key).abs & 0x8000 == 0x8000)
      PressDuration[key] = 0
      return true
    else
      return false
    end
  end
  def comp_fix(numkey)
    numkey -= 130 if numkey.between?(130, 158)
    return numkey
  end
  def press?(numkey)
    return oz_key_press(numkey) if numkey < 30
    realkey = comp_fix(numkey)
    return true unless PressDuration[realkey].nil?
    return key_pressed?(realkey)
  end
  def trigger?(numkey)
    return oz_key_trigger(numkey) if numkey < 30
    realkey = comp_fix(numkey)
    count = PressDuration[realkey]
    return ((count == 0) or (count.nil? ? key_pressed?(realkey) : false))
  end
  def repeat?(numkey)
    return oz_key_repeat(numkey) if numkey < 30
    realkey = comp_fix(numkey)
    count = PressDuration[realkey]
    return true if count == 0
    return (count.nil? ? key_pressed?(realkey) : (count >= 23 and
      (count - 23) % 6 == 0))
  end
end
class Window_ChooseColor < Window_Selectable
  def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
    if row_max == 0
      row_max = (commands.size + column_max - 1) / column_max
    end
    super(0, 0, width, row_max * WLH + 32, spacing)
    @commands = commands
    @item_max = commands.size
    @column_max = column_max
    refresh
    self.index = 0
    self.visible = false
    self.active = false
  end
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i)
    end
  end
  def item_rect(index)
    rect = Rect.new(0, 0, 0, 0)
    rect.width = (contents.width + @spacing) / @column_max - @spacing
    rect.height = WLH + 8
    rect.x = index % @column_max * (rect.width + @spacing) + 13
    rect.width = 32
    rect.y = (index / @column_max * WLH)  - 4
    return rect
  end
  def item_rect2(index)
    rect = Rect.new(0, 0, 0, 0)
    rect.width = (contents.width + @spacing) / @column_max - @spacing
    rect.height = WLH
    rect.x = index % @column_max * (rect.width + @spacing)
    rect.y = index / @column_max * WLH
    return rect
  end
  def draw_item(i, enabled = true)
    rect = item_rect2(i)
    rect.x += 4
    rect.width -= 8
    self.contents.clear_rect(rect)
    self.contents.font.color = COLORS[i]
    self.contents.draw_text(rect.x+13,rect.y,24,24,@commands[i].to_s)
    self.contents.fill_rect(rect.x+13,rect.y,24,24,COLORS[i])
  end
end
class Game_System
  attr_reader  :notebookbitmap
  attr_reader  :notetext
  alias initialize_notebook initialize
  def initialize
    initialize_notebook
    if @notebookbitmap == nil
      create_arrays
    end
  end
  def create_arrays
    @notetext = []
    @notebookbitmap = []
    for i in 0...MAX_PAGES
      @notebookbitmap[i] = []
      @notetext[i] = []
    end
  end
  def change_notetext(index,array)
    @notetext[index].clear if @notetext[index] != nil
    @notetext[index] = array
  end
  # Convert Bitmap in Array (Colors)
  def dump_bitmap(index,bitmap)
    @notebookbitmap[index].clear if @notebookbitmap[index] != nil
    @notebookbitmap[index] = [] if @notebookbitmap[index] == nil
    for i in 0...bitmap.height
      n = []
      for o in 0...bitmap.width
        n.push(bitmap.get_pixel(o,i))
      end
      @notebookbitmap[index].push(n)
    end
  end
  # Convert Array (Colors) in Bitmap
  def gimme_bitmap(index)
    return if @notebookbitmap[index].size == 0
    bit = Bitmap.new(@notebookbitmap[index][0].size,@notebookbitmap.size)
      for i in 0...@notebookbitmap[index].size
        for o in 0...@notebookbitmap[index][i].size
          bit.set_pixel(o,i,@notebookbitmap[index][i][o])
        end
      end
    return bit
  end
end

Version: 1.0
#----------------------------------------------------------------#
# Script:  Notebook VX                                           #
# by Deity                                                       #
# Mouse module by Near Fantastica                                #
#----------------------------------------------------------------#
# Description:                                                 #
# Dieses Script erlaubt es dem Benutzer ein Notizbuch in sein    #
# Spiel einzubauen. Das Notizbuch kann bei bedarf entweder mit   #
# der Maus oder der Tastatur "bemalt" werden.                    #
#----------------------------------------------------------------#
# Instructions:                                                  #
# Es sollten möglichst alle Settings dem Wunschaussehen angepasst#
# werden. Sobald dies erledigt ist, muss man nur noch das        #
# Notizbuch aufruffen. Dies geschieht mit folgendem Script:      #
# $scene = Scene_Notebook.new()                                  #
#?------------------------ Settings ----------------------------?#
#                   true = yes / false = no                      #
module Notebook
  USE_MOUSE = false # Soll die Maus benutzbar sein?
  KEY_TO_DRAW = Input::Z # Freie Knöpfe: X(A),Y(S),Z(D),L(Q),R(Q)
                         # Bei Z muss also D gedrückt werden.
  BGM = [
  "Town2", # Hintergrundmusik für das Notizbuch
  100, # Lautstärke
  100, # Geschwindigkeit  
  ] # <= Nicht löschen!
  # Wähle die Farben für das Notizbuch
  # Um eine Farbe zu verändern, muss man die 4 Werte
  # in den Klammern verändern. Diese müssen zwischen
  # 0 und 255 sein.
  # (Rotanteil,Grünanteil,Blauanteil,Sichtbarkeit)
  COLORS = [
  Color.new(0,0,0,255), #Schwarz
  Color.new(255,255,255,255), # Weiß
  Color.new(255,0,0,255), # Rot
  Color.new(0,255,0,255), # Grün
  Color.new(0,0,255,255), # Blau
  Color.new(255,255,0,255), # Gelb
  ] # <= Nicht löschen!
  # Wähle die Namen für das Auswahlfenster
  COMMANDS = [
  "Zeichnen", #Zeichnen
  "Farbe", #Farbe auswählen
  "Größe", #Größe auswählen
  "Löschen", #Alles löschen
  ] # <= Nicht löschen!
  # Kommentar für das untere Fenster.
  HELP_TEXT = "[D: Zeichnen] [B: Zurück] [Shift: Beschleunigen]"
  # Anfangsfarbe für den Hintergrund
  BACKGROUND_START_COLOR = Color.new(255,255,255,255)
  # Anfangseinstellungen für den "cursor"
  CURSOR_START_VALUES = [
  80, #X-Koordinate
  80, #Y-Koordinate
  Color.new(0,0,0,255), #Farbe
  4, # Breite / Höhe
  ]
end
# Alles was ab jetzt folgt, sollte nur dann geändert werden,    #
# wenn man weis was man tut!                                    #
#?-------------------------------------------------------------?#
include Notebook
# Author of the Mouse module
# Near Fantastica (special thanks)
module Mouse
  GetAsyncKeyState=Win32API.new("user32","GetAsyncKeyState",'i','i')
  GetKeyState=Win32API.new("user32","GetKeyState",'i','i')
  SetCursorPos=Win32API.new('user32','SetCursorPos','nn','n')
  GetCursorPo=Win32API.new('user32','GetCursorPos','p','i')
  ScreenToClient=Win32API.new('user32','ScreenToClient','lp','i')
  GetPrivateProfileStringA=Win32API.new('kernel32','GetPrivateProfileStringA','pppplp','l')
  FindWindowA=Win32API.new('user32','FindWindowA','pp','l')
  GetClientRect=Win32API.new('user32','GetClientRect','lp','i')
  GetWindowRect=Win32API.new('user32','GetWindowRect','lp','i')
  game_name="\0"*256
  GetPrivateProfileStringA.call('Game','Title','',game_name,255,".\\Game.ini")
  game_name.delete!("\0")
  @handle=FindWindowA.call('RGSS Player',game_name)
  module_function
  def click?(button)
    return true if @keys.include?(button)
    return false
  end  
  def press?(button)
    return true if @press.include?(button)
    return false
  end
  def set_pos(x_pos=0,y_pos=0)
    width,height=client_size
    if (x_pos.between?(0,width)&&y_pos.between?(0,height))
      SetCursorPos.call(client_pos[0]+x_pos,client_pos[1]+y_pos)
    end
  end
  def update
    @pos=Mouse.pos
    @keys,@press=[],[]
    @keys.push(1)if GetAsyncKeyState.call(1)&0x01==1
    @keys.push(2)if GetAsyncKeyState.call(2)&0x01==1
    @keys.push(3)if GetAsyncKeyState.call(4)&0x01==1
    @press.push(1)if pressed?(1)
    @press.push(2)if pressed?(2)
    @press.push(3)if pressed?(4)
  end  
  def pressed?(key)
    return true unless GetKeyState.call(key).between?(0,1)
    return false
  end
  def global_pos
    pos=[0,0].pack('ll')
    GetCursorPo.call(pos)!=0 ? (return pos.unpack('ll')):(return nil)
  end
  def pos
    x,y=screen_to_client(*global_pos)
    width,height=client_size
    begin
      x=0 if x<=0;y=0 if y<=0
      x=width if x>=width;y=height if y>=height
      return x,y
    end
  end
  def screen_to_client(x,y)
    return nil unless x&&y
    pos=[x,y].pack('ll')
    ScreenToClient.call(@handle,pos)!=0?(return pos.unpack('ll')):(return nil)
  end
  def client_size
    rect=[0,0,0,0].pack('l4')
    GetClientRect.call(@handle,rect)
    right,bottom=rect.unpack('l4')[2..3]
    return right,bottom
  end
  def client_pos
    rect=[0,0,0,0].pack('l4')
    GetWindowRect.call(@handle,rect)
    left,upper=rect.unpack('l4')[0..1]
    return left+4,upper+30
  end  
  def grid
    return nil if @pos.nil?
    return [(@pos[0]+$game_map.display_x/8)/32,(@pos[1]+$game_map.display_y/8)/32]
  end
end
class Window_ChooseColor < Window_Selectable
  def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
    if row_max == 0
      row_max = (commands.size + column_max - 1) / column_max
    end
    super(0, 0, width, row_max * WLH + 32, spacing)
    @commands = commands
    @item_max = commands.size
    @column_max = column_max
    refresh
    self.index = 0
    self.visible = false
    self.active = false
  end
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i)
    end
  end
  def item_rect(index)
    rect = Rect.new(0, 0, 0, 0)
    rect.width = (contents.width + @spacing) / @column_max - @spacing
    rect.height = WLH + 8
    rect.x = index % @column_max * (rect.width + @spacing) + 13
    rect.width = 32
    rect.y = (index / @column_max * WLH)  - 4
    return rect
  end
  def item_rect2(index)
    rect = Rect.new(0, 0, 0, 0)
    rect.width = (contents.width + @spacing) / @column_max - @spacing
    rect.height = WLH
    rect.x = index % @column_max * (rect.width + @spacing)
    rect.y = index / @column_max * WLH
    return rect
  end
  def draw_item(i, enabled = true)
    rect = item_rect2(i)
    rect.x += 4
    rect.width -= 8
    self.contents.clear_rect(rect)
    self.contents.font.color = COLORS[i]
    self.contents.draw_text(rect.x+13,rect.y,24,24,@commands[i].to_s)
    self.contents.fill_rect(rect.x+13,rect.y,24,24,COLORS[i])
  end
end
class Scene_Notebook < Scene_Base
  def start
    @color = Window_ChooseColor.new(544,["","","","","",""],6)
    @commands = Window_Command.new(544,COMMANDS,4)
    create_background
    create_cursor
    @size = Window_NumberInput.new
    @size.visible = false
    @size.opacity = 255
    @size.digits_max = 2
    @size.number = @cursor.width
    @help = Window_Help.new
    @help.y = 416 - @help.height
    Audio.bgm_play("Audio/BGM/"+BGM[0],BGM[1],BGM[2])
    @mouse = USE_MOUSE
  end
  def create_background
    @background = Sprite.new
    if $game_system.notebookbitmap.empty?
      @background.bitmap = Bitmap.new(544,416)    
      @background.bitmap.fill_rect(0,0,544,416,BACKGROUND_START_COLOR)
    else
      @background.bitmap = $game_system.gimme_bitmap
    end
  end
  def create_cursor
    @cursor = Sprite.new
    @cursor.x = CURSOR_START_VALUES[0]
    @cursor.y = CURSOR_START_VALUES[1]
    @cursor.bitmap = Bitmap.new(CURSOR_START_VALUES[3],CURSOR_START_VALUES[3])
    @cursor.bitmap.fill_rect(0,0,CURSOR_START_VALUES[0],CURSOR_START_VALUES[1],CURSOR_START_VALUES[2])
  end
  def active_window
    return true if @color.active == false && @commands.active == false && @size.active == false
    return false
  end
  def set_cursor_color(color)
    Sound.play_decision
    @cursor.bitmap.fill_rect(0,0,@cursor.width,@cursor.height,color)
  end
  def set_cursor_size(w)
    if w != 0
      Sound.play_decision
      @cursor.bitmap.dispose
      @cursor.bitmap = Bitmap.new(w,w)
      @cursor.bitmap.fill_rect(0,0,w,w,COLORS[@color.index])
    else
      Sound.play_buzzer
    end
  end
  def close_all
    @color.dispose
    @commands.dispose
    @cursor.dispose
    @background.dispose
    @size.dispose
    @help.dispose
  end
  def update
    Mouse.update
    if @mouse      
      @cursor.x,@cursor.y =Mouse.pos
    end
    if active_window && @mouse == false
      if Input.press?(Input::A)
        speed = 2
      else
        speed = 1
      end
      case Input.dir8
        when 1;  @cursor.y += speed
                       @cursor.x -= speed
        when 2;  @cursor.y += speed
        when 3;  @cursor.y += speed
                       @cursor.x += speed
        when 4;  @cursor.x -= speed
        when 7;  @cursor.y -= speed
                       @cursor.x -= speed
        when 6;  @cursor.x += speed
        when 9;  @cursor.y -= speed
                       @cursor.x += speed
        when 8;  @cursor.y -= speed
      end
      if @cursor.y < 0
        @cursor.y = 0
      end
      if @cursor.y + @cursor.height > 416
        @cursor.y = 416 - @cursor.height
      end
      if @cursor.x < 0
        @cursor.x = 0
      end
      if @cursor.x + @cursor.width > 544
        @cursor.x = 544 - @cursor.width
      end
    end
    if active_window
      @help.visible = false
    else
      @help.visible = true
      @help.set_text(HELP_TEXT,1)
    end
    if Input.press?(KEY_TO_DRAW) && active_window && @mouse == false
      @background.bitmap.fill_rect(@cursor.x,@cursor.y,@cursor.bitmap.width,@cursor.bitmap.height,@cursor.bitmap.get_pixel(0,0))
    end
    if @mouse && Mouse.press?(1) && active_windo
Titel: Re: Notebook VX
Beitrag von: Colonios am Januar 10, 2010, 11:28:56
Hey Deity,

Habs mal ausprobiert und muss echt sagen, dass ich es gut finde!

Jedoch finde ich eine Sache etwas schade: Wieso kann man nicht Notizen "aufschreiben", also mit der Tastatur eintippen?
Das fände ich noch sehr nützlich als zusätzliche Funktion, da das malen der Buchstaben doch schnell stressig wird ;)
Also fänd ich es gut, wenn man zwischen "Zeichnen" und "Schreiben" hin und her wechseln könnte ;)

Zudem ist das Zeichenen mit der Maus ja leider etwas unakurat und "löchrig".
Aber schön, dass das neue Jahr uns alle schon im Januar mit so tollen sachen beschenkt :3

Weiter so!

MfG
Titel: Re: Notebook VX
Beitrag von: Jmaster2009 am Januar 10, 2010, 12:59:35
Ich bin noch nicht so lange beim scripten dabei desshalb hab ich jetzt null ahnung wo ich das einfügen soll !!!Hilfe!!!
Titel: Re: Notebook VX
Beitrag von: tobiasruf am Januar 10, 2010, 13:03:51
F11 drücken und runterscrollen bis (Insert Here) rechtsklick und auf Insert dann in die neue seite den Code Kopieren .
http://www.rpgvx.net/index.php/topic,186.0.html (http://www.rpgvx.net/index.php/topic,186.0.html)
Titel: Re: Notebook VX
Beitrag von: Ðeity am Januar 10, 2010, 15:27:47
@Jmaster2009
Ich hoffe die Beschreibung von tobiasruf reicht ansonsten erkläre ich es noch einmal per PM etc.

@Colonios
Vielen Dank!
Ich bin bereits daran Texte einzufügen allerdings brauche ich dafür ein module was ich noch nicht geschrieben habe bzw. noch kein gefunden habe, welches mir gefällt. ^^
Das Problem mit der Maus ist, dass der Maker nicht so schnell updatet wie ein Mensch die Maus bewegen kann, was zu fehlern führt. :(
Ich überlege ob es etwas gibt um das zu verändern, falls ja mache ich es, ansonsten gibt es da recht wenig zu tun.

Ich arbeite gerade an zwei weiteren Funktionen und zwar:
1. Mehere Seiten ich denke an 2 für Texte und 2 für Zeichnungen.
2. Bilderkennung das heißt: Das Script erkennt Linien und Kreise etc. und bestätigt dann. (Wie in den NDS Zelda Teilen)

MfG
Deity
Titel: Re: Notebook VX
Beitrag von: Jisatsu am Januar 10, 2010, 15:49:35
Hey ^^
Sehr schönes und nützliches Skript *_*
Ich denke, das findet sicher Verwendung bei mir xD

Dass mit dem Texte schreiben per Tastatur wurde ja schon genannt ^^
Ansonsten fände ich es praktisch, dass man Bilder die man gemalt hat noch mal sozusagen übermalen kann o.o
zB habe ich jetzt einen Kreis gemalt c.c
Den ahb ich dann auch gespeichert ^^
Später will ich noch mal was zeichnen, mach den Kreis weg und nen Dreieck hin xD"
Wenn ich dann aus dem Skript raus gehe und nochmal rein, ist nur der Kries gespeichert und nich das Dreieck .__.

Oder mach ich da iwas Falsch xD?
Titel: Re: Notebook VX
Beitrag von: Ðeity am Januar 10, 2010, 16:18:21
@Jisatsu
Desto mehr Verwender ein Script findet, desto glücklicher bin ich. xD
Nein du hast nichts falsch gemacht, das war ich. ^^
Ich habe den Fehler aber schon nach dem Komentar zu Colonois behoben und ich denke es sollte jetzt klappen. :D
Nimm also die neue Version. ^^

MfG
Deity
Titel: Re: Notebook VX
Beitrag von: PDM am Januar 15, 2010, 12:33:53
Erstmal super Script, aber ich habe leider ein paar Fehler entdeckt.
Wenn ich etwas zeichne und dann ESC drücke, wird ein Teil der Zeichnung weggenommen.
Beim schreiben gibt es bei mir auch ein Problem: Wenn ich Speichern drücke, wird es gespeichert, aber wenn ich dann nochmal darauf klicke, stürzt das Spiel ab.
Ansonsten super Script!!!!
Titel: Re: Notebook VX
Beitrag von: Ðeity am Januar 15, 2010, 16:23:54
Ich werde mich um die Fehler kümmern, danke für die Bewertung und das Lob!

MfG
Deity
Titel: Re: Notebook VX
Beitrag von: Jmaster2009 am Januar 16, 2010, 11:03:51
F11 drücken und runterscrollen bis (Insert Here) rechtsklick und auf Insert dann in die neue seite den Code Kopieren .
[url]http://www.rpgvx.net/index.php/topic,186.0.html[/url] ([url]http://www.rpgvx.net/index.php/topic,186.0.html[/url])
Jo danke das wird mir helfen
Titel: Re: Notebook VX
Beitrag von: AngeL am Januar 31, 2010, 13:44:03
Uiuiui Super Skript :]
Aber das meiste wurde ja wiedermal von menien Vorgängern genannt.
Diesmal war es PDM, der die gleichen Fehler fand wie ich.
Sobald die Fehler behoben sind, schenkt auch dieses Skript einem glücklichen Menschen wieder einen Credits-Eintrag ;-)
Gute Arbeit :D
Titel: Re: Notebook VX
Beitrag von: darklight am April 09, 2010, 15:30:37
Ich habe ein  PROBLEM!!
(http://img691.imageshack.us/img691/8026/probmq.jpg)
Titel: Re: Notebook VX
Beitrag von: Ðeity am April 09, 2010, 15:36:12
Ja im Script sind 2 Fehler drinnen, die ich bereits kenne. Sobald ich Zeit und Lust habe mich wieder mit dem Inhalt aussernander zu setzen, werde ich diese dann korrigieren.
Sorry.

MfG
Deity
Titel: Re: Notebook VX
Beitrag von: darklight am April 09, 2010, 15:51:17
hm...hoffentlich schnell...nya... -.-'
Titel: Re: Notebook VX
Beitrag von: Hellkai am April 09, 2010, 18:15:03
    Notebook VX

    Updates
    10.01.2010
    • Kleinen Fehler behoben.
    [/list]
    11.01.2010
    • Textinput eingebaut!
    • Speichern verbessert.
    • Hintergrund eingefügt.
    • Achtung ein Fehler, der zurzeit nicht zu beheben ist!

    Was macht das Script?
    Mit diesem Script kannst du ein Notizbuch in dein Spiel einbauen, welches es dem Spieler erlaubt zu schreiben und zu malen!
    Es gibt eine Anzahl an Seiten, die gespeichert und geladen werden können.
    Die Bedinung ist recht simpel und es gibt viele Möglichkeiten.


    Wie nutze ich das Script?
    Ich würde euch empfehlen, erstmal alle Settings nach Bedarf zu verändern. Um das Notizbuch aufzuruffen, müsst Ihr nur folgende Zeile z.B. per Call Script aufruffen:
    $scene = Scene_Notebook.new(zeichnen?)
    Für das zeichnen? kann man true oder false einsetzen jenachdem, ob man schreiben oder zeichnen will. Lässt man es aus, startet es mit dem Zeichnen.

    Demo
    n/A


    Screenshots
    Denke es wird kein Screenshot gebraucht.

    Das Script
    Version 2.0
    [/list]#----------------------------------------------------------------#
    # Script:  Notebook VX                                           #
    # by Deity                                                       #
    # Mouse module by Near Fantastica                                #
    # Keyboard module by ????(translated by Deity)                  #
    #----------------------------------------------------------------#
    # Description:                                                 #
    # Dieses Script erlaubt es dem Benutzer ein Notizbuch in sein    #
    # Spiel einzubauen. Das Notizbuch kann bei bedarf entweder mit   #
    # der Maus oder der Tastatur "bemalt" werden.                    #
    #----------------------------------------------------------------#
    # Instructions:                                                  #
    # Es sollten möglichst alle Settings dem Wunschaussehen angepasst#
    # werden. Sobald dies erledigt ist, muss man nur noch das        #
    # Notizbuch aufruffen. Dies geschieht mit folgendem Script:      #
    # $scene = Scene_Notebook.new()                                  #
    #?------------------------ Settings ----------------------------?#
    #                   true = yes / false = no                      #
    module Notebook
      USE_MOUSE = false # Soll die Maus benutzbar sein?
      KEY_TO_DRAW = Input::Z # Freie Knöpfe: X(A),Y(S),Z(D),L(Q),R(Q)
                             # Bei Z muss also D gedrückt werden.
      BGM = [
      "Town2", # Hintergrundmusik für das Notizbuch
      100, # Lautstärke
      100, # Geschwindigkeit
      ] # <= Nicht löschen!
      PAGE_TITLE = "Seite"
      MAX_PAGES = 6
      # Wähle die Farben für das Notizbuch
      # Um eine Farbe zu verändern, muss man die 4 Werte
      # in den Klammern verändern. Diese müssen zwischen
      # 0 und 255 sein.
      # (Rotanteil,Grünanteil,Blauanteil,Sichtbarkeit)
      COLORS = [
      Color.new(0,0,0,255), #Schwarz
      Color.new(255,255,255,255), # Weiß
      Color.new(255,0,0,255), # Rot
      Color.new(0,255,0,255), # Grün
      Color.new(0,0,255,255), # Blau
      Color.new(255,255,0,255), # Gelb
      ] # <= Nicht löschen!
      # Wähle die Namen für das Auswahlfenster
      COMMANDS_DRAW = [
      "Zeichnen", #Zeichnen
      "Farbe", #Farbe auswählen
      "Größe", #Größe auswählen
      "Speichern",
      "Laden",
      "Schreiben",
      "Löschen",
      ] # <= Nicht löschen!
      COMMANDS_TEXT = [
      "Schreiben", # Schreiben
      "Speichern",
      "Laden",
      "Zeichnen", # Zum Zeichnen
      "Löschen", # Alles löschen
      ] # <= Nicht löschen!
      # Namen für die Hintergrundbilder, falls nicht gewollt
      # einfach leer lassen sprich ""
      BACKGROUNDIMAGES = [
      "", # Drawing background
      "" # Writing background
      ] # <= Nicht löschen!
      TEXT_COLOR = Color.new(0,0,0,220) # Farbe für das Schreiben
      TEXT_SHADOW = true # Use Shadow?
      RAND = 16 # Rand schreiben
      RAND_DRAW = 5 # Rand Zeichnen
      # Kommentar für das untere Fenster beim Zeichnen.
      DRAW_TEXT = "[D: Zeichnen] [B: Zurück] [Shift: Beschleunigen]"
      # Komentar für das untere Fenster beim schreiben.
      WRITE_TEXT = "[Esc: Zurück]"
      # Anfangsfarbe für den Hintergrund
      BACKGROUND_START_COLOR = Color.new(255,255,255,255)
      # Anfangseinstellungen für den "cursor"
      CURSOR_START_VALUES = [
      80, #X-Koordinate
      80, #Y-Koordinate
      Color.new(0,0,0,255), #Farbe
      4, # Breite / Höhe
      ]
    end
    # Alles was ab jetzt folgt, sollte nur dann geändert werden,    #
    # wenn man weis was man tut!                                    #
    #?-------------------------------------------------------------?#
    include Notebook
    class Scene_Notebook < Scene_Base
      def initialize(draw = true)
        @draw = draw
        @mouse = USE_MOUSE
        @file = ""
        @text = []
        @lines = 0
        @text[0] = []
      end
      def start
        create_windows
        create_cursor
        create_background
        Audio.bgm_play("Audio/BGM/"+BGM[0],BGM[1],BGM[2])
      end
      def create_windows
        @command_draw = Window_Command.new(160,COMMANDS_DRAW)
        @command_text = Window_Command.new(160,COMMANDS_TEXT)
        pages = []
        for i in 0...MAX_PAGES
          i += 1
          string = PAGE_TITLE + " " + i.to_s
          pages.push(string)
        end
        @command_pages = Window_Command.new(160,pages)
        @command_pages.x = 160
        @command_pages.active = false
        @command_pages.visible = false
        @color = Window_ChooseColor.new(544,["","","","","",""],6)
        @help = Window_Help.new()
        @help.y = 416 - @help.height    
        @number = Window_NumberInput.new()
        @number.x = 160
        @number.y = 48
        @number.width = 62
        @number.visible = false
        @number.active = false
        @number.digits_max = 2
        if @draw == true
          @command_draw.active = true
          @command_draw.visible = true
          @command_text.active = false
          @command_text.visible = false
          @help.set_text(DRAW_TEXT)
        else
          @command_text.active = true
          @command_text.visible = true
          @command_draw.active = false
          @command_draw.visible = false
          @help.set_text(WRITE_TEXT)
        end
      end
      def create_cursor
        @cursor = Sprite.new
        if @draw
          @cursor.x = CURSOR_START_VALUES[0]
          @cursor.y = CURSOR_START_VALUES[1]
          @cursor.bitmap = Bitmap.new(CURSOR_START_VALUES[3],CURSOR_START_VALUES[3])
          @cursor.bitmap.fill_rect(0,0,CURSOR_START_VALUES[0],CURSOR_START_VALUES[1],CURSOR_START_VALUES[2])
        end
      end
      def create_background
        @background = Sprite.new
        @working_sprite = Sprite.new
        if @draw == true
          image = 0
        else
          image = 1
        end
        if BACKGROUNDIMAGES[image] == ""
          @background.bitmap = Bitmap.new(544,416)    
          @background.bitmap.fill_rect(0,0,544,416,BACKGROUND_START_COLOR)
        else
          @background.bitmap = Cache.system(BACKGROUNDIMAGES[image])
        end
        @working_sprite.bitmap = Bitmap.new(544,416)
        @working_sprite.z = @background.z + 1
        @working_sprite.bitmap.font.color = TEXT_COLOR
        @working_sprite.bitmap.font.shadow = TEXT_SHADOW
      end
      def refresh
        @working_sprite.bitmap.clear_rect(0,(24 * @lines) + RAND,544,24) if @text[@lines].size != 0
        string = ""
        if @text[@lines].size != 0
          for i in @text[@lines]
            string += i
          end
        end
        @working_sprite.bitmap.draw_text(RAND,(24 *@lines) + RAND,512,24,@text[@lines]) if @text[@lines].size != 0
      end
      def clear_errors
        for i in 0...@text.size
          if @text[i].size == 0
            @working_sprite.bitmap.clear_rect(0,(24 * i) + RAND,544,24)
          end
        end
      end      
      def delete_correctly
        if @text[@lines] != nil && @text[@lines].size == 0
          @working_sprite.bitmap.clear_rect(0,(24 * @lines) + RAND,544,24)
          @lines -= 1 if @lines > 0
          @text[@lines].delete_at(@text[@lines].size-1)  if @text[@lines].size != 0
        else
          @text[@lines].delete_at(@text[@lines].size-1)  if @text[@lines].size != 0
        end
      end
      def update_symbols_input
        if Input.press?(Input::Shift)
          if Input.trigger?(Input::Equal)
            @text[@lines].push("*")
          elsif Input.trigger?(Input::Comma)
            @text[@lines].push(";")
          elsif Input.trigger?(Input::Underscore)
            @text[@lines].push("_")
          elsif Input.trigger?(Input::Dot)
            @text[@lines].push(":")
          elsif Input.trigger?(Input::Backslash)
            @text[@lines].push("'")
          elsif Input.trigger?(Input::Forwardslash)
            @text[@lines].push("°")
          elsif Input.trigger?(Input::Numbers[0])
            @text[@lines].push("=")
          elsif Input.trigger?(Input::Numbers[1])
            @text[@lines].push("!")
          elsif Input.trigger?(Input::Numbers[2])
            @text[@lines].push('"')
          elsif Input.trigger?(Input::Numbers[3])
            @text[@lines].push("§")
          elsif Input.trigger?(Input::Numbers[4])
            @text[@lines].push("$")
          elsif Input.trigger?(Input::Numbers[5])
            @text[@lines].push("%")
          elsif Input.trigger?(Input::Numbers[6])
            @text[@lines].push("&")
          elsif Input.trigger?(Input::Numbers[7])
            @text[@lines].push("/")
          elsif Input.trigger?(Input::Numbers[8])
            @text[@lines].push("(")
          elsif Input.trigger?(Input::Numbers[9])
            @text[@lines].push(")")
          elsif Input.trigger?(Input::Lb)
            @text[@lines].push("?")
          end
        end
        if not Input.press?(Input::Shift)
          if Input.trigger?(Input::Equal)
            @text[@lines].push("+")
          elsif Input.trigger?(Input::Comma)
            @text[@lines].push(",")
          elsif Input.trigger?(Input::Underscore)
            @text[@lines].push("-")
          elsif Input.trigger?(Input::Dot)
            @text[@lines].push(".")
          elsif Input.trigger?(Input::Backslash)
            @text[@lines].push("#")
          elsif Input.trigger?(Input::Forwardslash)
            @text[@lines].push("°")
          elsif Input.trigger?(Input::Lb)
            @text[@lines].push("ß")
          end
        end
      end
      def update_keyboard
        if @text[@lines] != nil
          if @text[@lines].size * 13 >= 544 - RAND*2
            @lines += 1 if @lines != (((416 - 2*RAND)/24)-1).to_i
            @text[@lines] = []
          end
        end
        for i in 'A'...'Z'
          if Input.trigger?(Input::Letters[i])
            if Input.press?(Input::Shift)
              @text[@lines].push(i.upcase)
            else
              @text[@lines].push(i.downcase)
            end
          end
        end
        if Input.trigger?(Input::Letters['Z'])
          if Input.press?(Input::Shift)
            @text[@lines].push('Z'.upcase)
          else
            @text[@lines].push('Z'.downcase)
          end
        end
        if Input.trigger?(Input::Collon)
          if Input.press?(Input::Shift)
            @text[@lines].push('Ü'.upcase)
          else
            @text[@lines].push('ü'.downcase)
          end
        end
        if Input.trigger?(Input::Tilde)
          if Input.press?(Input::Shift)
            @text[@lines].push('Ö'.upcase)
          else
            @text[@lines].push('ö'.downcase)
          end
        end
        if Input.trigger?(Input::Quote)
          if Input.press?(Input::Shift)
            @text[@lines].push('Ä'.upcase)
          else
            @text[@lines].push('ä'.downcase)
          end
        end
        for i in 0...Input::Numbers.size
          if Input.trigger?(Input::Numbers[i])
            @text[@lines].push(i.to_s)
          end
        end
        if Input.trigger?(Input::Space)
          @text[@lines].push(" ")
        elsif Input.trigger?(Input::Back)
          delete_correctly
        elsif Input.trigger?(Input::Enter)
          @lines += 1 if @lines != (((416 - 2*RAND)/24)-1).to_i
          @text[@lines] = []
        end
        refresh
      end
      def set_cursor_color(color)
        Sound.play_decision
        @cursor.bitmap.fill_rect(0,0,@cursor.width,@cursor.height,color)
      end
      def set_cursor_size(w)
        if w != 0
          Sound.play_decision
          @cursor.bitmap.dispose
          @cursor.bitmap = Bitmap.new(w,w)
          @cursor.bitmap.fill_rect(0,0,w,w,COLORS[@color.index])
        else
          Sound.play_buzzer
        end
      end
      def update_windows
        @command_draw.update if @command_draw.active == true
        @command_text.update if @command_text.active == true
        @command_pages.update if @command_pages.active == true
        @color.update if @color.active == true  
        @number.update if @number.active == true
      end
      def active_window
        return true if @command_draw.active == false && @command_text.active == false && @number.active == false && @color.active == false && @command_pages.active == false
        return false
      end
      def draw_text_array
        for i in 0...@text.size
          string = ""
          for o in @text[i]
            for u in o
              string += u
            end
            @working_sprite.bitmap.draw_text(16,(24 *i)+ 16,512,24,string)
          end
        end
      end
      def update_cursor
        Mouse.update
        if @mouse && @draw
          @cursor.x,@cursor.y =Mouse.pos
        end
        if active_window && @mouse == false
          if Input.press?(Input::Shift)
            speed = 2
          else
            speed = 1
          end
          case Input.dir8
            when 1;  @cursor.y += speed
                           @cursor.x -= speed
            when 2;  @cursor.y += speed
            when 3;  @cursor.y += speed
                           @cursor.x += speed
            when 4;  @cursor.x -= speed
            when 7;  @cursor.y -= speed
                           @cursor.x -= speed
            when 6;  @cursor.x += speed
            when 9;  @cursor.y -= speed
                           @cursor.x += speed
            when 8;  @cursor.y -= speed
          end
          if @cursor.y < RAND_DRAW
            @cursor.y = RAND_DRAW
          end
          if @cursor.y + @cursor.height > 416 - RAND_DRAW
            @cursor.y = 416 - @cursor.height - RAND_DRAW
          end
          if @cursor.x < RAND_DRAW
            @cursor.x = RAND_DRAW
          end
          if @cursor.x + @cursor.width > 544 - RAND_DRAW
            @cursor.x = 544 - @cursor.width - RAND_DRAW
          end
        end
        if Input.press?(KEY_TO_DRAW) && active_window && @mouse == false
          @working_sprite.bitmap.fill_rect(@cursor.x,@cursor.y,@cursor.bitmap.width,@cursor.bitmap.height,@cursor.bitmap.get_pixel(0,0))
        end
        if @mouse && Mouse.press?(1) && active_window
          @working_sprite.bitmap.fill_rect(@cursor.x,@cursor.y,@cursor.bitmap.width,@cursor.bitmap.height,@cursor.bitmap.get_pixel(0,0))
        end
      end
      def update_helpwindow
        if @draw
          @help.visible = @command_draw.visible
        else
          @help.visible = @command_text.visible
        end
        if @help.visible == true
          if @draw
            @help.set_text(DRAW_TEXT)
          else
            @help.set_text(WRITE_TEXT)
          end
        end
      end    
      def close_all
        @command_draw.dispose
        @command_text.dispose
        @command_pages.dispose
        @number.dispose
        @help.dispose
        @color.dispose
        @background.dispose
        @working_sprite.dispose
        @cursor.dispose
      end
      def update
        update_windows if not active_window
        update_cursor if @draw
        update_symbols_input if not @draw && active_window
        update_keyboard if not @draw && active_window
        update_helpwindow
        refresh if @draw == false && active_window
        clear_errors if not @draw && active_window
        if Input.trigger?(Input::C)
          Sound.play_decision
          if @command_draw.active == true
            case @command_draw.index
            when 0
              @command_draw.active = false
              @command_draw.visible = false
            when 1
              @command_draw.active = false
              @command_draw.visible = false
              @color.active = true
              @color.visible = true
            when 2
              @command_draw.active = false
              @number.active = true
              @number.visible = true
            when 3
              @file = "save"
              @command_draw.active = false
              @command_pages.active = true
              @command_pages.visible = true
            when 4
              @file = "load"
              @command_draw.active = false
              @command_pages.active = true
              @command_pages.visible = true
            when 5
              close_all
              $scene = Scene_Notebook.new(false)
            when 6
              @working_sprite.bitmap.clear
            end
          elsif @command_text.active == true
            case @command_text.index
            when 0
              @command_text.active = false
              @command_text.visible = false
            when 1
              @file = "save"
              @command_text.active = false
              @command_pages.active = true
              @command_pages.visible = true
            when 2
              @file = "load"
              @command_text.active = false
              @command_pages.active = true
              @command_pages.visible = true
            when 3
              close_all
              $scene = Scene_Notebook.new(true)
            when 4
              @working_sprite.bitmap.clear
              @text = []
              @text[0] = []
              @lines = 0
            end
          elsif @color.active == true
            set_cursor_color(COLORS[@color.index])
          elsif @number.active == true
            set_cursor_size(@number.number)
          elsif @command_pages.active == true
            if @file == "save"
              if @draw == true
                $game_system.dump_bitmap(@command_pages.index,@working_sprite.bitmap)
              else
                $game_system.change_notetext(@command_pages.index,@text)
              end
            elsif @file == "load"
              if @draw == true
                @working_sprite.bitmap = $game_system.gimme_bitmap(@command_pages.index)
              elsif @draw == false
                @working_sprite.bitmap.clear
                @text = $game_system.notetext[@command_pages.index]
                @lines = $game_system.notetext[@command_pages.index].size - 1
                if @lines < 0
                  @lines = 0
                end
                draw_text_array
              end
           end
         end
       end
       if Input.trigger?(Input::Esc)
         Sound.play_cancel
         if @command_draw.active == true
           close_all
           return_scene
         elsif @command_text.active == true
           close_all
           return_scene
         elsif active_window
          if @draw == true
            @command_draw.active = true
            @command_draw.visible = true
          elsif @draw == false
            @command_text.active = true
            @command_text.visible = true
          end
         elsif @color.active == true
           @color.active = false
           @color.visible = false
           @command_draw.active = true
           @command_draw.visible = true
         elsif @number.active == true
           @command_draw.active = true
           @number.active = false
           @number.visible = false
         elsif @command_pages.active == true
           @command_pages.active = false
           @command_pages.visible = false
           if @draw
             @command_draw.active = true
           else
             @command_text.active = true
           end
         end    
       end
     end
      def return_scene
        $scene = Scene_Map.new
      end
    end  
    # Author of the Mouse module
    # Near Fantastica (special thanks)
    module Mouse
      GetAsyncKeyState=Win32API.new("user32","GetAsyncKeyState",'i','i')
      GetKeyState=Win32API.new("user32","GetKeyState",'i','i')
      SetCursorPos=Win32API.new('user32','SetCursorPos','nn','n')
      GetCursorPo=Win32API.new('user32','GetCursorPos','p','i')
      ScreenToClient=Win32API.new('user32','ScreenToClient','lp','i')
      GetPrivateProfileStringA=Win32API.new('kernel32','GetPrivateProfileStringA','pppplp','l')
      FindWindowA=Win32API.new('user32','FindWindowA','pp','l')
      GetClientRect=Win32API.new('user32','GetClientRect','lp','i')
      GetWindowRect=Win32API.new('user32','GetWindowRect','lp','i')
      game_name="\0"*256
      GetPrivateProfileStringA.call('Game','Title','',game_name,255,".\\Game.ini")
      game_name.delete!("\0")
      @handle=FindWindowA.call('RGSS Player',game_name)
      module_function
      def click?(button)
        return true if @keys.include?(button)
        return false
      end  
      def press?(button)
        return true if @press.include?(button)
        return false
      end
      def set_pos(x_pos=0,y_pos=0)
        width,height=client_size
        if (x_pos.between?(0,width)&&y_pos.between?(0,height))
          SetCursorPos.call(client_pos[0]+x_pos,client_pos[1]+y_pos)
        end
      end
      def update
        @pos=Mouse.pos
        @keys,@press=[],[]
        @keys.push(1)if GetAsyncKeyState.call(1)&0x01==1
        @keys.push(2)if GetAsyncKeyState.call(2)&0x01==1
        @keys.push(3)if GetAsyncKeyState.call(4)&0x01==1
        @press.push(1)if pressed?(1)
        @press.push(2)if pressed?(2)
        @press.push(3)if pressed?(4)
      end  
      def pressed?(key)
        return true unless GetKeyState.call(key).between?(0,1)
        return false
      end
      def global_pos
        pos=[0,0].pack('ll')
        GetCursorPo.call(pos)!=0 ? (return pos.unpack('ll')):(return nil)
      end
      def pos
        x,y=screen_to_client(*global_pos)
        width,height=client_size
        begin
          x=0 if x<=0;y=0 if y<=0
          x=width if x>=width;y=height if y>=height
          return x,y
        end
      end
      def screen_to_client(x,y)
        return nil unless x&&y
        pos=[x,y].pack('ll')
        ScreenToClient.call(@handle,pos)!=0?(return pos.unpack('ll')):(return nil)
      end
      def client_size
        rect=[0,0,0,0].pack('l4')
        GetClientRect.call(@handle,rect)
        right,bottom=rect.unpack('l4')[2..3]
        return right,bottom
      end
      def client_pos
        rect=[0,0,0,0].pack('l4')
        GetWindowRect.call(@handle,rect)
        left,upper=rect.unpack('l4')[0..1]
        return left+4,upper+30
      end  
      def grid
        return nil if @pos.nil?
        return [(@pos[0]+$game_map.display_x/8)/32,(@pos[1]+$game_map.display_y/8)/32]
      end
    end
    class << Input  
      # * Alias List
      unless self.method_defined? (:oz_key_press)
        alias oz_key_press press?
        alias oz_key_trigger trigger?
        alias oz_key_repeat repeat?
        alias og_key_update update
      end
    end
    module Input  
      # Numbers not in the numpad
      Numbers      = []          
      Numbers[0]   = 48
      Numbers[1]   = 49
      Numbers[2]   = 50
      Numbers[3]   = 51
      Numbers[4]   = 52
      Numbers[5]   = 53
      Numbers[6]   = 54
      Numbers[7]   = 55
      Numbers[8]   = 56
      Numbers[9]   = 57  
      # Letters
      Letters         = {}        
      Letters['A']    = 65
      Letters['B']    = 66        
      Letters['C']    = 67
      Letters['D']    = 68        
      Letters['E']    = 69
      Letters['F']    = 70        
      Letters['G']    = 71
      Letters['H']    = 72        
      Letters['I']    = 73
      Letters['J']    = 74        
      Letters['K']    = 75
      Letters['L']    = 76        
      Letters['M']    = 77
      Letters['N']    = 78        
      Letters['O']    = 79
      Letters['P']    = 80        
      Letters['Q']    = 81
      Letters['R']    = 82        
      Letters['S']    = 83
      Letters['T']    = 84        
      Letters['U']    = 85
      Letters['V']    = 86        
      Letters['W']    = 87
      Letters['X']    = 88        
      Letters['Y']    = 89
      Letters['Z']    = 90
      # Other keys
      Back            = 138      
      Tab             = 139
      Enter           = 143      
      Shift           = 146
      Ctrl            = 147      
      Alt             = 148
      Capslock        = 150      
      Esc             = 157
      Space           = 32        
      End             = 35
      Home            = 36        
      Left            = 37
      Right           = 39        
      Del             = 46      
      Collon          = 186      
      Quote           = 222
      Equal           = 187      
      Comma           = 188
      Underscore      = 189      
      Dot             = 190
      Backslash       = 191      
      Tilde           = 192
      Lb              = 219      
      Rb              = 221
      Forwardslash    = 220  
      # Api
      State = Win32API.new("user32", "GetAsyncKeyState", ["i"], "i")
      PressDuration = {} # A hash for pressed keys and their durations
      #=============================================================================
      module_function
      #============================================================================
      # Update
      def update
        og_key_update
        for key in PressDuration.keys
          (State.call(key).abs & 0x8000 == 0x8000) ? PressDuration[key] +=
          1 : PressDuration.delete(key)
        end
      end
      def key_pressed?(key)
        if (State.call(key).abs & 0x8000 == 0x8000)
          PressDuration[key] = 0
          return true
        else
          return false
        end
      end
      def comp_fix(numkey)
        numkey -= 130 if numkey.between?(130, 158)
        return numkey
      end
      def press?(numkey)
        return oz_key_press(numkey) if numkey < 30
        realkey = comp_fix(numkey)
        return true unless PressDuration[realkey].nil?
        return key_pressed?(realkey)
      end
      def trigger?(numkey)
        return oz_key_trigger(numkey) if numkey < 30
        realkey = comp_fix(numkey)
        count = PressDuration[realkey]
        return ((count == 0) or (count.nil? ? key_pressed?(realkey) : false))
      end
      def repeat?(numkey)
        return oz_key_repeat(numkey) if numkey < 30
        realkey = comp_fix(numkey)
        count = PressDuration[realkey]
        return true if count == 0
        return (count.nil? ? key_pressed?(realkey) : (count >= 23 and
          (count - 23) % 6 == 0))
      end
    end
    class Window_ChooseColor < Window_Selectable
      def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
        if row_max == 0
          row_max = (commands.size + column_max - 1) / column_max
        end
        super(0, 0, width, row_max * WLH + 32, spacing)
        @commands = commands
        @item_max = commands.size
        @column_max = column_max
        refresh
        self.index = 0
        self.visible = false
        self.active = false
      end
      def refresh
        self.contents.clear
        for i in 0...@item_max
          draw_item(i)
        end
      end
      def item_rect(index)
        rect = Rect.new(0, 0, 0, 0)
        rect.width = (contents.width + @spacing) / @column_max - @spacing
        rect.height = WLH + 8
        rect.x = index % @column_max * (rect.width + @spacing) + 13
        rect.width = 32
        rect.y = (index / @column_max * WLH)  - 4
        return rect
      end
      def item_rect2(index)
        rect = Rect.new(0, 0, 0, 0)
        rect.width = (contents.width + @spacing) / @column_max - @spacing
        rect.height = WLH
        rect.x = index % @column_max * (rect.width + @spacing)
        rect.y = index / @column_max * WLH
        return rect
      end
      def draw_item(i, enabled = true)
        rect = item_rect2(i)
        rect.x += 4
        rect.width -= 8
        self.contents.clear_rect(rect)
        self.contents.font.color = COLORS[i]
        self.contents.draw_text(rect.x+13,rect.y,24,24,@commands[i].to_s)
        self.contents.fill_rect(rect.x+13,rect.y,24,24,COLORS[i])
      end
    end
    class Game_System
      attr_reader  :notebookbitmap
      attr_reader  :notetext
      alias initialize_notebook initialize
      def initialize
        initialize_notebook
        if @notebookbitmap == nil
          create_arrays
        end
      end
      def create_arrays
        @notetext = []
        @notebookbitmap = []
        for i in 0...MAX_PAGES
          @notebookbitmap[i] = []
          @notetext[i] = []
        end
      end
      def change_notetext(index,array)
        @notetext[index].clear if @notetext[index] != nil
        @notetext[index] = array
      end
      # Convert Bitmap in Array (Colors)
      def dump_bitmap(index,bitmap)
        @notebookbitmap[index].clear if @notebookbitmap[index] != nil
        @notebookbitmap[index] = [] if @notebookbitmap[index] == nil
        for i in 0...bitmap.height
          n = []
          for o in 0...bitmap.width
            n.push(bitmap.get_pixel(o,i))
          end
          @notebookbitmap[index].push(n)
        end
      end
      # Convert Array (Colors) in Bitmap
      def gimme_bitmap(index)
        return if @notebookbitmap[index].size == 0
        bit = Bitmap.new(@notebookbitmap[index][0].size,@notebookbitmap.size)
          for i in 0...@notebookbitmap[index].size
            for o in 0...@notebookbitmap[index][i].size
              bit.set_pixel(o,i,@notebookbitmap[index][i][o])
            end
          end
        return bit
      end
    end
    Version: 1.0
    #----------------------------------------------------------------#
    # Script:  Notebook VX                                           #
    # by Deity                                                       #
    # Mouse module by Near Fantastica                                #
    #----------------------------------------------------------------#
    # Description:                                                 #
    # Dieses Script erlaubt es dem Benutzer ein Notizbuch in sein    #
    # Spiel einzubauen. Das Notizbuch kann bei bedarf entweder mit   #
    # der Maus oder der Tastatur "bemalt" werden.                    #
    #----------------------------------------------------------------#
    # Instructions:                                                  #
    # Es sollten möglichst alle Settings dem Wunschaussehen angepasst#
    # werden. Sobald dies erledigt ist, muss man nur noch das        #
    # Notizbuch aufruffen. Dies geschieht mit folgendem Script:      #
    # $scene = Scene_Notebook.new()                                  #
    #?------------------------ Settings ----------------------------?#
    #                   true = yes / false = no                      #
    module Notebook
      USE_MOUSE = false # Soll die Maus benutzbar sein?
      KEY_TO_DRAW = Input::Z # Freie Knöpfe: X(A),Y(S),Z(D),L(Q),R(Q)
                             # Bei Z muss also D gedrückt werden.
      BGM = [
      "Town2", # Hintergrundmusik für das Notizbuch
      100, # Lautstärke
      100, # Geschwindigkeit  
      ] # <= Nicht löschen!
      # Wähle die Farben für das Notizbuch
      # Um eine Farbe zu verändern, muss man die 4 Werte
      # in den Klammern verändern. Diese müssen zwischen
      # 0 und 255 sein.
      # (Rotanteil,Grünanteil,Blauanteil,Sichtbarkeit)
      COLORS = [
      Color.new(0,0,0,255), #Schwarz
      Color.new(255,255,255,255), # Weiß
      Color.new(255,0,0,255), # Rot
      Color.new(0,255,0,255), # Grün
      Color.new(0,0,255,255), # Blau
      Color.new(255,255,0,255), # Gelb
      ] # <= Nicht löschen!
      # Wähle die Namen für das Auswahlfenster
      COMMANDS = [
      "Zeichnen", #Zeichnen
      "Farbe", #Farbe auswählen
      "Größe", #Größe auswählen
      "Löschen", #Alles löschen
      ] # <= Nicht löschen!
      # Kommentar für das untere Fenster.
      HELP_TEXT = "[D: Zeichnen] [B: Zurück] [Shift: Beschleunigen]"
      # Anfangsfarbe für den Hintergrund
      BACKGROUND_START_COLOR = Color.new(255,255,255,255)
      # Anfangseinstellungen für den "cursor"
      CURSOR_START_VALUES = [
      80, #X-Koordinate
      80, #Y-Koordinate
      Color.new(0,0,0,255), #Farbe
      4, # Breite / Höhe
      ]
    end
    # Alles was ab jetzt folgt, sollte nur dann geändert werden,    #
    # wenn man weis was man tut!                                    #
    #?-------------------------------------------------------------?#
    include Notebook
    # Author of the Mouse module
    # Near Fantastica (special thanks)
    module Mouse
      GetAsyncKeyState=Win32API.new("user32","GetAsyncKeyState",'i','i')
      GetKeyState=Win32API.new("user32","GetKeyState",'i','i')
      SetCursorPos=Win32API.new('user32','SetCursorPos','nn','n')
      GetCursorPo=Win32API.new('user32','GetCursorPos','p','i')
      ScreenToClient=Win32API.new('user32','ScreenToClient','lp','i')
      GetPrivateProfileStringA=Win32API.new('kernel32','GetPrivateProfileStringA','pppplp','l')
      FindWindowA=Win32API.new('user32','FindWindowA','pp','l')
      GetClientRect=Win32API.new('user32','GetClientRect','lp','i')
      GetWindowRect=Win32API.new('user32','GetWindowRect','lp','i')
      game_name="\0"*256
      GetPrivateProfileStringA.call('Game','Title','',game_name,255,".\\Game.ini")
      game_name.delete!("\0")
      @handle=FindWindowA.call('RGSS Player',game_name)
      module_function
      def click?(button)
        return true if @keys.include?(button)
        return false
      end  
      def press?(button)
        return true if @press.include?(button)
        return false
      end
      def set_pos(x_pos=0,y_pos=0)
        width,height=client_size
        if (x_pos.between?(0,width)&&y_pos.between?(0,height))
          SetCursorPos.call(client_pos[0]+x_pos,client_pos[1]+y_pos)
        end
      end
      def update
        @pos=Mouse.pos
        @keys,@press=[],[]
        @keys.push(1)if GetAsyncKeyState.call(1)&0x01==1
        @keys.push(2)if GetAsyncKeyState.call(2)&0x01==1
        @keys.push(3)if GetAsyncKeyState.call(4)&0x01==1
        @press.push(1)if pressed?(1)
        @press.push(2)if pressed?(2)
        @press.push(3)if pressed?(4)
      end  
      def pressed?(key)
        return true unless GetKeyState.call(key).between?(0,1)
        return false
      end
      def global_pos
        pos=[0,0].pack('ll')
        GetCursorPo.call(pos)!=0 ? (return pos.unpack('ll')):(return nil)
      end
      def pos
        x,y=screen_to_client(*global_pos)
        width,height=client_size
        begin
          x=0 if x<=0;y=0 if y<=0
          x=width if x>=width;y=height if y>=height
          return x,y
        end
      end
      def screen_to_client(x,y)
        return nil unless x&&y
        pos=[x,y].pack('ll')
        ScreenToClient.call(@handle,pos)!=0?(return pos.unpack('ll')):(return nil)
      end
      def client_size
        rect=[0,0,0,0].pack('l4')
        GetClientRect.call(@handle,rect)
        right,bottom=rect.unpack('l4')[2..3]
        return right,bottom
      end
      def client_pos
        rect=[0,0,0,0].pack('l4')
        GetWindowRect.call(@handle,rect)
        left,upper=rect.unpack('l4')[0..1]
        return left+4,upper+30
      end  
      def grid
        return nil if @pos.nil?
        return [(@pos[0]+$game_map.display_x/8)/32,(@pos[1]+$game_map.display_y/8)/32]
      end
    end
    class Window_ChooseColor < Window_Selectable
      def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
        if row_max == 0
          row_max = (commands.size + column_max - 1) / column_max
        end
        super(0, 0, width, row_max * WLH + 32, spacing)
        @commands = commands
        @item_max = commands.size
        @column_max = column_max
        refresh
        self.index = 0
        self.visible = false
        self.active = false
      end
      def refresh
        self.contents.clear
        for i in 0...@item_max
          draw_item(i)
        end
      end
      def item_rect(index)
        rect = Rect.new(0, 0, 0, 0)
        rect.width = (contents.width + @spacing) / @column_max - @spacing
        rect.height = WLH + 8
        rect.x = index % @column_max * (rect.width + @spacing) + 13
        rect.width = 32
        rect.y = (index / @column_max * WLH)  - 4
        return rect
      end
      def item_rect2(index)
        rect = Rect.new(0, 0, 0, 0)
        rect.width = (contents.width + @spacing) / @column_max - @spacing
        rect.height = WLH
        rect.x = index % @column_max * (rect.width + @spacing)
        rect.y = index / @column_max * WLH
        return rect
      end
      def draw_item(i, enabled = true)
        rect = item_rect2(i)
        rect.x += 4
        rect.width -= 8
        self.contents.clear_rect(rect)
        self.contents.font.color = COLORS[i]
        self.contents.draw_text(rect.x+13,rect.y,24,24,@commands[i].to_s)
        self.contents.fill_rect(rect.x+13,rect.y,24,24,COLORS[i])
      end
    end
    class Scene_Notebook < Scene_Base
      def start
        @color = Window_ChooseColor.new(544,["","","","","",""],6)
        @commands = Window_Command.new(544,COMMANDS,4)
        create_background
        create_cursor
        @size = Window_NumberInput.new
        @size.visible = false
        @size.opacity = 255
        @size.digits_max = 2
        @size.number = @cursor.width
        @help = Window_Help.new
        @help.y = 416 - @help.height
        Audio.bgm_play("Audio/BGM/"+BGM[0],BGM[1],BGM[2])
        @mouse = USE_MOUSE
      end
      def create_background
        @background = Sprite.new
        if $game_system.notebookbitmap.empty?
          @background.bitmap = Bitmap.new(544,416)    
          @background.bitmap.fill_rect(0,0,544,416,BACKGROUND_START_COLOR)
        else
          @background.bitmap = $game_system.gimme_bitmap
        end
      end
      def create_cursor
        @cursor = Sprite.new
        @cursor.x = CURSOR_START_VALUES[0]
        @cursor.y = CURSOR_START_VALUES[1]
        @cursor.bitmap = Bitmap.new(CURSOR_START_VALUES[3],CURSOR_START_VALUES[3])
        @cursor.bitmap.fill_rect(0,0,CURSOR_START_VALUES[0],CURSOR_START_VALUES[1],CURSOR_START_VALUES[2])
      end
      def active_window
        return true if @color.active == false && @commands.active == false && @size.active == false
        return false
      end
      def set_cursor_color(color)
        Sound.play_decision
        @cursor.bitmap.fill_rect(0,0,@cursor.width,@cursor.height,color)
      end
      def set_cursor_size(w)
        if w != 0
          Sound.play_decision
          @cursor.bitmap.dispose
          @cursor.bitmap = Bitmap.new(w,w)
          @cursor.bitmap.fill_rect(0,0,w,w,COLORS[@color.index])
        else
          Sound.play_buzzer
        end
      end
      def close_all
        @color.dispose
        @commands.dispose
        @cursor.dispose
        @background.dispose
        @size.dispose
        @help.dispose
      end
      def update
        Mouse.update
        if @mouse      
          @cursor.x,@cursor.y =Mouse.pos
        end
        if active_window && @mouse == false
          if Input.press?(Input::A)
            speed = 2
          else
            speed = 1
          end
          case Input.dir8
            when 1;  @cursor.y += speed
                           @cursor.x -= speed
            when 2;  @cursor.y += speed
            when 3;  @cursor.y += speed
                           @cursor.x += speed
            when 4;  @cursor.x -= speed
            when 7;  @cursor.y -= speed
                           @cursor.x -= speed
            when 6;  @cursor.x += speed
            when 9;  @cursor.y -= speed
                           @cursor.x += speed
            when 8;  @cursor.y -= speed
          end
          if @cursor.y < 0
            @cursor.y = 0
          end
          if @cursor.y + @cursor.height > 416
            @cursor.y = 416 - @cursor.height
          end
          if @cursor.x < 0
            @cursor.x = 0
          end
          if @cursor.x + @cursor.width > 544
            @cursor.x = 544 - @cursor.width
          end
        end
        if active_window
          @help.visible = false
        else
          @help.visible = true
          @help.set_text(HELP_TEXT,1)
        end
        if Input.press?(KEY_TO_DRAW) && active_window && @mouse == false
          @background.bitmap.fill_rect(@cursor.x,@cursor.y,@cursor.bitmap.width,@cursor.bitmap.height,@cursor.bitmap.get_pixel(0,0))
        end
        if @mouse && Mouse.press?(1) && active_windo
    [/quote]
    SimplePortal 2.3.3 © 2008-2010, SimplePortal