Ogłoszenie 

Uwaga! To forum jest w trybie offline.
Wszelką pomoc uzyskasz pod adresem
forum.ultimateam.pl


Administracja Forum


Poprzedni temat «» Następny temat
Skryp na painta
Autor Wiadomość
Loki 




Preferowany:
RPG Maker VX

Pomógł: 12 razy
Dołączył: 25 Kwi 2012
Posty: 162
Wysłany: Pią 03 Sie, 2012 20:56
Skryp na painta
~ Notebook VX ~


Krótki opis:
Skrypt pozwala na rysowanie w paincie w rpg makerze vx.

Autor:
Deity

Kompatybilność:
RPG Maker VX

Skrypt:
Spoiler:

Kod:
#????????????????????????????????????????????????????????????????#
# 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


Screeny:
Spoiler:



Dodatkowe informacje:
Skrypt pozwala na:

- Wybor 6 kolorów
- Wybór zwiększania i pomniejszania pędzla (ołówka?)
- Wyczyszczenie strony (jeśli ktoś chce jeszcze raz malować/rysować.

Żeby szybciej poruszać się pędzlem (ołówkiem?) trzeba przytrzymać ,,SHIFT''
Malowanie/rysowanie automatycznie się zapisuje po wyłączeniu painta.

Żeby wywołać skrypt:

$scene = Scene_Notebook.new()
 
 
Etam 




Preferowany:
RPG Maker VX

Dołączył: 23 Lip 2012
Posty: 44
Wysłany: Pią 03 Sie, 2012 21:19
Skrypt jest fajny, oryginalny> :mrgreen:
Chociaż z drugiej strony RPG Maker + Paint ??
Takie głupie skrypty mi się podobają !
 
 
makerowiec64 




Preferowany:
RPG Maker 95

Pomógł: 2 razy
Dołączył: 02 Wrz 2012
Posty: 181
Skąd: się tu wziąłem?
Wysłany: Sob 03 Lis, 2012 15:13
Cytat:
Skrypt jest fajny, oryginalny>

Właśnie!Ciekawe wymyślenie!
________________________
99 % świrów czyta mój podpis z ręką na myszce.
Nie odchylaj ręki - jest już za późno :haha:

Wiem,to mogłem zrobić w większym rozmiarze.Przypatrz się bardziej!
 
 
 
Nex 




Preferowany:
RPG Maker XP

Pomógł: 15 razy
Dołączył: 27 Paź 2012
Posty: 145
Wysłany: Nie 04 Lis, 2012 16:06
Ale do czego to się może przydać?
:?:
 
 
DonMateo07 




Preferowany:
RPG Maker VX

Pomógł: 3 razy
Dołączył: 28 Paź 2012
Posty: 22
Skąd: Bydgoszcz
Wysłany: Nie 04 Lis, 2012 17:31
@up Na przykład robisz komputer w swojej grze a na nim różne możliwości, w tym również paint :P
________________________

Mój kanał na YT ~ Moja strona WWW
Spoiler:

Projekt "Mafioso"
Fabuła: 2%
Misje poboczne: 1%
Tekstury: 15%
Skrypty: 0%
Mapa: 5%
Dzwieki: 5%
Dubbing: 0% (brak pewności, że będzie)
Ogółem: 4,6%



 
 
Wyświetl posty z ostatnich:   
Odpowiedz do tematu
Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Nie możesz załączać plików na tym forum
Możesz ściągać załączniki na tym forum
Dodaj temat do Ulubionych
Wersja do druku

Skocz do:  

Powered by phpBB modified by Przemo © 2003 phpBB Group | Template Klam by Ayene