Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- [GENERAL]
- by Dax Soft
- www.dax-soft.weebly.com
- &beta
- Requeriments: Ligni Core
- [DESCRIPTION]
- Dual Screen system, makes your rpg maker game look like a nintendo ds game.
- [VERSION]
- 0.3 :
- default UI to DSi UI
- Mouse system
- Setup map to DSi
- Menu
- Message System
- 0.32 :
- default cursor to selectable window
- [COMMAND TO CALL SCRIPT]
- $game_system.default_background = ""
- picture at graphics/system. Submenu background picture
- $game_system.smdbp = ""
- picture at graphics/system. Button submenu picture
- $game_system.smdbs = "SceneManager.call(Scene_Name)"
- Default scene that shall go when hit the button
- $game_system.cursor_window = true/false
- true to enable/false to disable
- $game_system.cursor_visible = true/false
- true to on/false to off
- [CTRL+F : LOCATE]
- :module
- :submenu
- :graphic
- :bitmap
- :game_temp
- :game_system
- :game_map
- :game_player
- :default_submenu_picture
- :window_base
- :window_selectable
- :window_command
- :scene_base
- :scene_menubase
- :scene_map
- :sprite_picture
- :window_message
- :window_choice
- =end
- Ligni.register(:dsi, "dax", 0.32) {
- # [DEFAULT FONT SETTING]
- Font.default_size = 16
- Font.default_bold = false
- Font.default_italic = false
- Font.default_outline = false
- Font.default_shadow = true
- # [MODULE] :module
- module DS; extend self
- # [version]
- VERSION = "0.32 ~ beta"
- # [SETUP OF CONSTANT]
- SETUP = {
- # setup of menu
- MENU: {
- # Default background picture
- BACKGROUND: "MenuBackground",
- # Default cursor icon menu
- CURSOR: {
- # picture at graphics/system
- PICTURE: "cursor",
- # Additional position to cursor
- POS: [-4, 0],
- # Speed of move
- SPEED: 0.25,
- },
- },
- # setup of submenu
- SUBMENU: {
- # DEFAULT PICTURE TO SUBMENU
- DF: "Grassland",
- # Default button function on submenu at map
- DBT: {
- # picture of button || default | change with $game_system.smdbp = "nome"
- PICTURE: "savebutton",
- # scene that when hit the button, shall go || default | change with $game_system.smdbs
- SCENE: "SceneManager.call(Scene_Menu)",
- # switch that can on/off. True to off
- SWITCH: 1,
- # position
- POS: [8, (Graphics.height / 2) + 16],
- # hit keyboard key.
- KEY: :Q,
- },
- },
- # setup of message system
- MESSAGE: {
- # NUMBER OF VISIBLE LINE ON MESSAGE BOX
- VL: 2,
- # DEFAULT PICTURE TO BACKGROUND OF MESSAGE BOX. IF YOU DON'T WANNA JUST
- # KEEP IT EMPTY
- DBACK: "",
- },
- # setup of title screen
- TITLE: {
- # the background picture of up part
- BACKGROUND_UP: "Title/backup",
- # the background picture of down part
- BACKGROUND_DOWN: "Title/backdown",
- # the title logo picture
- LOGO: "Title/logo",
- },
- }
- # [GET THE VALUE OF SCREEN and the DEFAULT Z] [:STRUCT]
- def screen
- screen = Struct.new(:DSI_ScreenValue, :width, :sheight, :z, :height).new()
- screen.width, screen.sheight, screen.z, screen.height = 284, 432, 9999, 216
- screen
- end
- end
- # [RESIZE SCREEN]
- Graphics.resize_screen(DS.screen.width, DS.screen.sheight)
- # [GRAPHIC] :graphic
- class << Graphics
- # get width screen value
- def width; DS.screen.width; end;
- # get height screen value
- def height; DS.screen.sheight; end;
- end
- # [BITMAP] :bitmap
- class Bitmap
- #--------------------------------------------------------------------------
- # * Desenho do gráfico de rosto
- # face_name : nome do gráfico de face
- # face_index : índice do gráfico de face
- # x : coordenada X
- # y : coordenada Y
- # enabled : habilitar flag, translucido quando false
- #--------------------------------------------------------------------------
- def draw_face(face_name, face_index, x, y, enabled = true, w=96, h=96)
- bitmap = Cache.face(face_name)
- j = (96 - w) / 2 rescue 0
- rect = Rect.new(face_index % 4 * (96 + j), face_index / 4 * 96, w, h)
- self.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
- bitmap.dispose
- end
- #--------------------------------------------------------------------------
- # * Desenho do gráfico de face do herói
- # actor : herói
- # x : coordenada X
- # y : coordenada Y
- # enabled : habilitar flag, translucido quando false
- #--------------------------------------------------------------------------
- def draw_actor_face(actor, x, y, enabled = true, w=96, h=96)
- draw_face(actor.face_name, actor.face_index, x, y, enabled, w, h)
- end
- end
- # [Game_System] :game_system
- class Game_System
- alias :dsi_init :initialize
- #--------------------------------------------------------------------------
- # * Variáveis públicas
- #--------------------------------------------------------------------------
- attr_accessor :default_background # Imagem padrão do mapa.
- attr_accessor :smdbp
- attr_accessor :smdbs
- attr_accessor :cursor_menu
- attr_accessor :cursor_visible
- #--------------------------------------------------------------------------
- # * Inicialização dos objetos.
- #--------------------------------------------------------------------------
- def initialize
- dsi_init
- @map_img = nil
- @default_background = nil
- @smdbp = DS::SETUP[:SUBMENU][:DBT][:PICTURE]
- @smdbs = DS::SETUP[:SUBMENU][:DBT][:SCENE]
- @cursor_menu = true
- @cursor_visible = true
- end
- end
- # [Game_Temp] :game_temp
- class Game_Temp
- # vars
- attr_accessor :map_img
- # init
- alias :dsi_init :initialize
- def initialize(*args)
- dsi_init(*args)
- @map_img = nil
- end
- end
- # [Game_Map] :game_map
- class Game_Map
- #----------------------------------------------------------------------------
- # • Variável do mapa.
- #----------------------------------------------------------------------------
- def map
- return @map
- end
- #--------------------------------------------------------------------------
- # * Altura do mapa
- #--------------------------------------------------------------------------
- def height
- @map.height - 1
- end
- #--------------------------------------------------------------------------
- # * Aquisição do números de tiles verticais na tela
- #--------------------------------------------------------------------------
- def screen_tile_y
- DS.screen.height / 32
- end
- #--------------------------------------------------------------------------
- # • Definição de coordenada válida
- # x : coordenada X
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def valid?(x, y)
- x >= 0 && x < width && y >= 0 && y < (height + 1)
- end
- end
- # [GAME_PLAYER] :game_player
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # * Variáveis públicas
- #--------------------------------------------------------------------------
- attr_accessor :no_movable
- #--------------------------------------------------------------------------
- # * Inicialização do objeto
- #--------------------------------------------------------------------------
- alias :dsi_init :initialize
- def initialize(*args)
- dsi_init(*args)
- @no_movable = false
- end
- #--------------------------------------------------------------------------
- # • Coordenada X do centro da tela
- #--------------------------------------------------------------------------
- def center_x
- (Graphics.width / 32 - 1) / 1.75
- end
- #--------------------------------------------------------------------------
- # • Coordenada Y do centro da tela
- #--------------------------------------------------------------------------
- def center_y
- (DS.screen.height / 32 - 1) / 1.75
- end
- #--------------------------------------------------------------------------
- # * Definição de mobilidade
- #--------------------------------------------------------------------------
- alias :dsi_movable? :movable?
- def movable?
- return false if @no_movable
- dsi_movable?
- end
- end
- # [DS::Sub::DMF] :default_submenu_picture
- class DMF < Sprite
- # initialize
- def initialize
- super([DS.screen.width, DS.screen.height, 0, DS.screen.height, DS.screen.z])
- @old_background = $game_system.default_background
- unless $game_system.default_background.nil? or $game_system.default_background.empty?
- self.bitmap = Cache.system($game_system.default_background)
- else
- self.bitmap.fill_rect(self.rect, "000000".color)
- end
- Ligni::Position[1, self]
- end
- # dispose
- def dispose
- self.bitmap.dispose
- super
- end
- # update
- def update
- unless @old_background == $game_system.default_background
- unless $game_system.default_background.nil? or $game_system.default_background.empty?
- self.bitmap.clear
- blt = Cache.system($game_system.default_background)
- self.bitmap.blt(0, 0, blt, Rect.new(0, 0, blt.width, blt.height))
- else
- self.bitmap.clear
- self.bitmap.fill_rect(self.rect, "000000".color)
- end
- @old_background = $game_system.default_background
- end
- # ...
- end
- end
- # [Window_Base] :window_base
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # * Desenho do gráfico de rosto
- # face_name : nome do gráfico de face
- # face_index : índice do gráfico de face
- # x : coordenada X
- # y : coordenada Y
- # enabled : habilitar flag, translucido quando false
- #--------------------------------------------------------------------------
- def draw_face(face_name, face_index, x, y, enabled = true, w=96, h=96, zoom=1.0)
- bitmap = Cache.face(face_name)
- j = (96 - w) / 2 rescue 0
- rect = Rect.new(face_index % 4 * (96 + j), face_index / 4 * 96, w, h)
- dltrect = Rect.new(x, y, w*zoom, h*zoom)
- #stretch_blt(dest_rect, src_bitmap, src_rect[, opacity])
- #contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
- contents.stretch_blt(dltrect, bitmap, rect, enabled ? 255 : translucent_alpha)
- bitmap.dispose
- end
- #--------------------------------------------------------------------------
- # * Desenho do gráfico de face do herói
- # actor : herói
- # x : coordenada X
- # y : coordenada Y
- # enabled : habilitar flag, translucido quando false
- #--------------------------------------------------------------------------
- def draw_actor_face(actor, x, y, enabled = true, w=96, h=96, zoom=1.0)
- draw_face(actor.face_name, actor.face_index, x, y, enabled, w, h, zoom)
- end
- def exp_gauge_color1; text_color(21); end;
- def exp_gauge_color2; text_color(17); end;
- #--------------------------------------------------------------------------
- # • Desenho do EXP
- # actor : herói
- # x : coordenada X
- # y : coordenada Y
- # width : largura
- #--------------------------------------------------------------------------
- def draw_actor_exp(actor, x, y, width = 115)
- draw_gauge(x, y, width, actor.exp.to_f / actor.next_level_exp.to_f, exp_gauge_color1, exp_gauge_color2)
- change_color(system_color)
- draw_text(x, y, 30, line_height,"EXP:")
- draw_current_and_max_values(x, y, width, actor.exp, actor.next_level_exp,
- normal_color, normal_color)
- end
- #--------------------------------------------------------------------------
- # * Desenho dos atributos básicos
- # actor : herói
- # x : coordenada X
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def draw_actor_simple_status(actor, x, y)
- draw_actor_name(actor, x, y)
- draw_actor_level(actor, x, y + line_height * 1)
- draw_actor_icons(actor, x, y + line_height * 2)
- draw_actor_class(actor, x + 120, y)
- draw_actor_hp(actor, x + 120, y + line_height * 1, 64)
- draw_actor_mp(actor, x + 120, y + line_height * 2, 64)
- end
- end
- # [Window_Selectable] :window_selectable
- class Window_Selectable < Window_Base
- #--------------------------------------------------------------------------
- # * Definição de controle de confirmação e cancelamento
- #--------------------------------------------------------------------------
- def process_handling
- return unless open? && active
- return process_ok if ok_enabled? && (trigger?(:C) or trigger?(0x01))
- return process_cancel if cancel_enabled? && (trigger?(:B) or trigger?(0x02))
- return process_pagedown if handle?(:pagedown) && Input.trigger?(:R)
- return process_pageup if handle?(:pageup) && Input.trigger?(:L)
- end
- #--------------------------------------------------------------------------
- # * Atualização da tela
- #--------------------------------------------------------------------------
- alias :dsi_mouse_update :update
- def update
- dsi_mouse_update
- process_mouse_handling if self.active && self.open
- end
- #--------------------------------------------------------------------------
- # * Configuração do processo de movimento do Mouse.
- #--------------------------------------------------------------------------
- def process_mouse_handling
- @delay = @delay ? @delay + 1 : 0
- return if @delay % 3 > 0
- mx, my = Ligni::Mouse.x, Ligni::Mouse.y
- vx = self.viewport ? self.x - self.viewport.ox + self.viewport.rect.x : self.x
- vy = self.viewport ? self.y - self.viewport.oy + self.viewport.rect.y : self.y
- if mx.between?(vx, vx + self.width) && my.between?(vy, vy + self.height)
- mx -= vx + padding
- my -= vy + padding
- my += oy
- (0...item_max).each { |i|
- rect = item_rect(i)
- next unless mx.between?(rect.x, rect.x + rect.width) && my.between?(rect.y, rect.y + rect.height)
- last_index = @index
- select(i)
- Sound.play_cursor unless @index == last_index
- break
- }
- end
- end
- end
- # [Window_Command] :window_command
- class Window_Command < Window_Selectable
- #--------------------------------------------------------------------------
- # * Inicialização do objeto
- # x : coordenada X
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def initialize(x, y, width=nil, line=nil)
- clear_command_list
- make_command_list
- super(x, y, width || window_width, line.nil? ? window_height : fitting_height(line))
- refresh
- select(0)
- activate
- end
- end
- # [Scene_Base] :scene_base
- class Scene_Base
- alias :dsi_start :start
- alias :dsi_update :update
- alias :dsi_terminate :terminate
- #--------------------------------------------------------------------------
- # * Inicialização do processo
- #--------------------------------------------------------------------------
- def start
- dsi_start
- $game_temp.map_img = DMF.new
- end
- #--------------------------------------------------------------------------
- # * Atualização da tela
- #--------------------------------------------------------------------------
- def update
- dsi_update
- $game_temp.map_img.update rescue nil
- end
- #--------------------------------------------------------------------------
- # * Finalização do processo
- #--------------------------------------------------------------------------
- def terminate
- dsi_terminate
- $game_temp.map_img.dispose rescue nil
- end
- end
- # [Scene_MenuBase] :scene_menubase
- class Scene_MenuBase < Scene_Base
- #--------------------------------------------------------------------------
- # * Criação do plano de fundo
- #--------------------------------------------------------------------------
- def create_background
- @background_sprite = Sprite.new
- @background_sprite.bitmap = SceneManager.background_bitmap
- @background_sprite.color.set(0, 0, 0, 0)
- end
- #--------------------------------------------------------------------------
- # * Criação da janela de ajuda.
- #--------------------------------------------------------------------------
- def create_help_window
- @help_window = Window_Help.new
- end
- end
- # [Scene_Map] :scene_map
- class Scene_Map < Scene_Base
- alias :dsi_start3 :start
- #--------------------------------------------------------------------------
- # * Inicialização do processo
- #--------------------------------------------------------------------------
- def start
- $game_system.default_background = DS::SETUP[:SUBMENU][:DF]
- dsi_start3
- end
- end
- # [Sprite_Picture] :sprite_picture
- class Sprite_Picture < Sprite
- #----------------------------------------------------------------------------
- # • Atualização dos objetos.
- #----------------------------------------------------------------------------
- def update
- super
- unless @picture.name == ""
- update_bitmap
- update_origin
- update_position
- update_zoom
- update_other
- else
- self.bitmap.dispose unless self.bitmap.nil?
- end
- end
- end
- # [Window_Message] :window_message
- class Window_Message < Window_Base
- #--------------------------------------------------------------------------
- # * Inicialização do objeto
- #--------------------------------------------------------------------------
- alias :dsi_msg_init :initialize
- def initialize(*args)
- dsi_msg_init
- unless DS::SETUP[:MESSAGE][:DBACK].empty?
- @background_msgbox = Sprite.new("S: #{DS::SETUP[:MESSAGE][:DBACK]}")
- @background_msgbox.visible = false
- end
- end
- #--------------------------------------------------------------------------
- # * Aquisição do número de linhas exibidas
- #--------------------------------------------------------------------------
- def visible_line_number
- return DS::SETUP[:MESSAGE][:VL]
- end
- #--------------------------------------------------------------------------
- # * Disposição
- #--------------------------------------------------------------------------
- alias :dsi_msg_dispose :dispose
- def dispose
- dsi_msg_dispose
- @background_msgbox.dispose rescue nil
- end
- #--------------------------------------------------------------------------
- # * Atualização da tela
- #--------------------------------------------------------------------------
- alias :dsi_msg_update :update
- def update
- dsi_msg_update
- unless DS::SETUP[:MESSAGE][:DBACK].empty?
- @background_msgbox.x, @background_msgbox.y, @background_msgbox.z = self.x, self.y, self.z-1
- self.opacity = 0
- @background_msgbox.visible = $game_message.visible
- end
- end
- #--------------------------------------------------------------------------
- # * Atualização da posição da janela
- #--------------------------------------------------------------------------
- def update_placement
- self.z = DS.screen.z
- @position = $game_message.position
- self.y = @position * (DS.screen.height - height) / 2
- @gold_window.y = y > 0 ? 0 : Graphics.height - @gold_window.height
- end
- #--------------------------------------------------------------------------
- # * Execução de espera de entrada
- #--------------------------------------------------------------------------
- def input_pause
- self.pause = true
- wait(10)
- Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C) || trigger?(0x02) || trigger?(0x01)
- Input.update
- self.pause = false
- end
- #--------------------------------------------------------------------------
- # * Definição de quebra de página
- # text : texto
- # pos : posição
- #--------------------------------------------------------------------------
- def new_page(text, pos)
- contents.clear
- draw_face($game_message.face_name, $game_message.face_index, 0, 5, true, 96, 96, 0.4)
- reset_font_settings
- pos[:x] = new_line_x
- pos[:y] = 0
- pos[:new_x] = new_line_x
- pos[:height] = calc_line_height(text)
- clear_flags
- end
- #--------------------------------------------------------------------------
- # * Definição de quebra de linha
- #--------------------------------------------------------------------------
- def new_line_x
- $game_message.face_name.empty? ? 0 : 32 + 16
- end
- end
- # [Window_ChoiceList] :window_choice
- class Window_ChoiceList < Window_Command
- #--------------------------------------------------------------------------
- # * Inicialização do objeto
- # message_window : janela de mensagem
- #--------------------------------------------------------------------------
- def initialize(message_window)
- @message_window = message_window
- super(0, DS.screen.height + 6)
- self.z = DS.screen.z + 10
- self.openness = 0
- deactivate
- end
- #--------------------------------------------------------------------------
- # * Atualização da posição da janela
- #--------------------------------------------------------------------------
- def update_placement
- self.width = [max_choice_width + 12, 164].max + padding * 2
- self.width = [width, Graphics.width].min
- self.height = fitting_height($game_message.choices.size)
- Ligni::Position[1, self]
- self.y = DS.screen.height + ((DS.screen.height - (self.height)) / 2)
- end
- end
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement