Deity Notebook VX

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Notebook VX
Version: 1.0
Author: Deity
Date: January 9, 2010

Description


This script permits the game player to have a notebook to jot down reminders of a quest or draw special symbols or any number of cool things. It allows complete user input on a canvas, in addition to shoosing a larger size for the pencil or a different colour. Can make for a great tool for the player to take notes to remind him/herself of their objectives or as simply a way to pass the time!

It also supports mouse input in addition to key input

Features

  • Allows the player to draw in a notebook
  • Lots of customizability, from what colours can be used to the words describing each action
  • Can be used to keep notes by the player or as a fun minigame

Screenshots



Instructions

Please see the header of the script

Script


Code: [Select]
#????????????????????????????????????????????????????????????????#
# Script:  Notebook VX                                           #
#  by Deity [translated to English by modern algebra (rmrk.net)] #
# Mouse module by Near Fantastica                                #
#????????????????????????????????????????????????????????????????#
# Description:                                                 #
#  This script permits the game player to have a notebook to jot #
# down reminders of a quest or draw special symbols or any       #
# number of cool things. It allows complete user input on a      #
# canvas, in addition to shoosing a larger size for the pencil   #
# or a different colour. Can make for a great tool for the       #
# player to take notes to remind him/herself of their objectives #
# or as simply a way to pass the time!                           #
#  It also supports mouse input in addition to key input         #
#????????????????????????????????????????????????????????????????#
# Instructions:                                                  #
# Choose the settings for the appearance that you want below the #
#  Settings headed. Once that is done, all you need to do is use #
#  the following code in a call script:                          #
#                                                                #
#     $scene = Scene_Notebook.new()                              #
#????????????????????????? Settings ?????????????????????????????#
#                   true = yes / false = no                      #
module Notebook
  USE_MOUSE = false # Use the mouse to draw with?
  KEY_TO_DRAW = Input::Z # Unused buttons: X(A),Y(S),Z(D),L(Q),
                         # R(Q). If you use Z, it is the D key
  BGM = [
  "Town2", # Filename of BGM to play
  100,     # Volume
  100,     # Pitch
  ] # <= Do not delete!
  # Select the drawing colours for the note book. These are of
  # the (Red, Green, Blue, Alpha) form. All numbers must be
  # between 0 and 255.
  COLORS = [
  Color.new(0,0,0,255),       # Black
  Color.new(255,255,255,255), # White
  Color.new(255,0,0,255),     # Red
  Color.new(0,255,0,255),     # Green
  Color.new(0,0,255,255),     # Blue
  Color.new(255,255,0,255),   # Yellow
  ] # <= Do not delete!
  # Select the names for the commands of the selection window
  COMMANDS = [
  "Draw",      # Draw
  "Color",     # The color to draw in
  "Size",      # Size of Pencil
  "Erase", # Erase All
  ] # <= Do not delete!
  # Comment for the lower help window
  HELP_TEXT = "[D: Draw] [B: Back] [Shift: Accelerate]"
  # Colour of background
  BACKGROUND_START_COLOR = Color.new(255,255,255,255)
  # Starting settings for the cursor
  CURSOR_START_VALUES = [
  80, # X-coordinate of cursor start position
  80, # Y-coordinate of cursor start position
  Color.new(0,0,0,255), # Color of cursor on startup
  4, # Size of cursor on startup
  ] # <= Do not delete!
end
#  You should edit nothing beyond this point unless you are a   #
# scripter and know what you're doing                           #
#???????????????????????????????????????????????????????????????#
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_window
      @background.bitmap.fill_rect(@cursor.x,@cursor.y,@cursor.bitmap.width,@cursor.bitmap.height,@cursor.bitmap.get_pixel(0,0))
    end
    @color.update if @color.active == true
    @commands.update if @commands.active == true
    @size.update if @size.active == true
    if Input.trigger?(Input::C)
      if @commands.active == true
        Sound.play_decision
        case @commands.index
        when 0
          @commands.active = false
          @commands.visible = false
        when 1
          @commands.active = false
          @commands.visible = false
          @color.active = true
          @color.visible = true
        when 2
          @commands.active = false
          @commands.visible = false
          @size.active = true
          @size.visible = true
        when 3
          @background.bitmap.fill_rect(0,0,544,416,Notebook::BACKGROUND_START_COLOR)
        end
      elsif @color.active == true
        set_cursor_color(COLORS[@color.index])
      elsif @size.active == true
        set_cursor_size(@size.number)
      end
    end
    if Input.trigger?(Input::B)
      Sound.play_cancel
      if @commands.active == true
        $game_system.dump_bitmap(@background.bitmap)
        close_all
        Audio.bgm_stop
        $game_map.autoplay
        return_scene
      elsif @color.active == true
        @commands.active = true
        @commands.visible = true
        @color.active = false
        @color.visible = false
      elsif @size.active == true
        @commands.active = true
        @commands.visible = true
        @size.active = false
        @size.visible = false
      elsif active_window
        @commands.active = true
        @commands.visible = true
      end
    end
  end
  def return_scene
    $scene = Scene_Map.new
  end
end
class Game_System
  attr_reader  :notebookbitmap
  alias initialize_notebook initialize
  def initialize
    initialize_notebook
    @notebookbitmap = []
  end
  # Convert Bitmap in Array (Colors)
  def dump_bitmap(bitmap)
    @notebookbitmap.clear
    for i in 0...bitmap.height
      n = []
      for o in 0...bitmap.width
        n.push(bitmap.get_pixel(o,i))
      end
      @notebookbitmap.push(n)
    end
  end
  # Convert Array (Colors) in Bitmap
  def gimme_bitmap
    bit = Bitmap.new(@notebookbitmap[0].size,@notebookbitmap.size)
      for i in 0...@notebookbitmap.size
        for o in 0...@notebookbitmap[i].size
          bit.set_pixel(o,i,@notebookbitmap[i][o])
        end
      end
    return bit
  end
end

Credit


  • Deity

Thanks

  • Near Fantastica, for the Mouse Module

Support


Please post in this topic at rmrk.net for support and I will either try to answer it myself or forward it to Deity.

Known Compatibility Issues

None known.

Demo


No demo should be necessary.

Translator's Notes


Again, all credit goes to Deity, with Thanks to Near Fantastica for the mouse module Deity uses in this script

« Last Edit: January 09, 2010, 10:23:21 PM by modern algebra »

****
Rep:
Level 83
3...2...1...
Is there any way to save the notes, for later?  For example.  You're character is told to remember a certain number, so he writes it down in the notebook.  How would he save that note so that he can look at it later when he needs that number?

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Mmn, I mentioned that to Deity after I translated, but he hasn't gotten back to me.

Currently, he would just have to be sure to not erase over it. Everytime you open the notebook, it saves what has already been drawn. It's not very much, which is why I mentioned he should make multiple pages. For now that's all there is though :)

****
Rep:
Level 83
3...2...1...
Hmm, thanks.  I never noticed it saved that little bit.  If he does get back to you, do you want to let me know?  That would be greatly appreciated.

**
Rep: +0/-0Level 82
Wow, these Deity scripts are amazing!  Are there anymore to come?

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Yeah, there are at least two others already written that I haven't translated yet, and I know of at least one more that he's working on that sounds very cool.

***
Rep:
Level 82
aka DigiDeity
Hi @ all
Now when I read the replys I have to register and say
Thanks. :D

Greets
Deity
Greetings
DigiDeity

├Work┤
├Contact┤


**
Rep:
Level 82
Eternally bloody...
You're an amazing scripter, Deity; this looks really cool!


Btw can you change the background to a picture (of fx. a piece of paper) instead of just plain white?

***
Rep:
Level 82
aka DigiDeity
Well thanks a lot!
Yes in the update you willl be able to write and draw. You're also able to choose a pictrue as a background.
I hope it will be finished in the near future. :D

Greets
Deity
Greetings
DigiDeity

├Work┤
├Contact┤


****
Rep:
Level 83
3...2...1...
Hey, Deity, you should make it so that you can save notes with this thing.  That would be awesome!

***
Rep:
Level 82
aka DigiDeity
What do you mean? The Bitmap saves if you close the Notebook and next time if you use the Notebook you can continue draw on the last picture.
Maybe I just understand something wrong.

Greets
Deity
Greetings
DigiDeity

├Work┤
├Contact┤


****
Rep:
Level 83
3...2...1...
No that's fine.  I didn't really explain it well. What I'm trying to get at is to make it so that it will save a picture so that you can save the picture, erase it, and exit the notebook.  When you enter the notebook again you have the option to load it to see and edit it again so that you don't end up with this page loaded full of pictures and stuff, you could save one, make a new one, save it, load the first one, etc. So that it would look neater.  And example is the Pictograph on The Legend of Zelda Wind Waker (except it is a camera, not a notebook).

***
Rep:
Level 82
aka DigiDeity
I send the update to modern algebra.
So if he have the time and want to have some extra work, maybe he will translate it.
The update took so long becuase I have to translate the Input module a bit to the english and to the german keyboard.

In the update was an error so it have to be fixxed, but I don't have time jet so it takes a bit. :(

Greets
Deity
« Last Edit: February 11, 2010, 04:22:11 PM by Deity »
Greetings
DigiDeity

├Work┤
├Contact┤


**
Rep:
Level 82
Eternally bloody...
I can't wait xD

****
Rep:
Level 83
3...2...1...
Can I get rid of the BGM that plays in the Notebook so that the map's music plays instead?

**
Rep: +0/-0Level 75
RMRK Junior
GOOD notebook :)

**
Rep: +0/-0Level 75
RMRK Junior
<a href="http://www.youtube.com/watch?v=cCpMyCrdNyA" target="_blank">http://www.youtube.com/watch?v=cCpMyCrdNyA</a>
Very Good and Here we are the video on youtube
:yourmom: :headtoss: :kashii:

***
Rep:
Level 71
RMRK Junior
Not that I'm one to necropost, because that would be kind of a dick move, but after 20 years since the last post, I must say I agree and second the motion to allow for saving and loading capabilities.

*
i am satin die lol
Rep:
Level 96
welcom to hel
GIAW 14: 2nd Place (Hard Mode)2013 Biggest Drama Whore2013 Zero to HeroParticipant - GIAW 11Secret Santa 2013 ParticipantFor taking arms in the name of your breakfast.
2008 was 10 years ago
where does time go? :(

*
i am satin die lol
Rep:
Level 96
welcom to hel
GIAW 14: 2nd Place (Hard Mode)2013 Biggest Drama Whore2013 Zero to HeroParticipant - GIAW 11Secret Santa 2013 ParticipantFor taking arms in the name of your breakfast.
also 1973 was 50 years ago

*
i am satin die lol
Rep:
Level 96
welcom to hel
GIAW 14: 2nd Place (Hard Mode)2013 Biggest Drama Whore2013 Zero to HeroParticipant - GIAW 11Secret Santa 2013 ParticipantFor taking arms in the name of your breakfast.
the world is going to end soon, it's ending in 2012
that's only 2 years away D:

***
Rep:
Level 82
aka DigiDeity
Not that I'm one to necropost, because that would be kind of a dick move, but after 20 years since the last post, I must say I agree and second the motion to allow for saving and loading capabilities.
2008 was 10 years ago
where does time go? :(
also 1973 was 50 years ago
the world is going to end soon, it's ending in 2012
that's only 2 years away D:


Maybe English has to be my native language to undertsand that or its an insider but I really don't know what you're talking about! :D

Greets
Greetings
DigiDeity

├Work┤
├Contact┤