Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # =============================================================================
- # TheoAllen - Moving Cursor
- # Version : 1.0
- # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
- # (This script documentation is written in informal indonesian language)
- # -----------------------------------------------------------------------------
- # Requires :
- # >> Theo - Core Movement (Basic Modules)
- # =============================================================================
- ($imported ||= {})[:Theo_MovingCursor] = true
- # =============================================================================
- # CHANGE LOGS:
- # -----------------------------------------------------------------------------
- # 2013.08.17 - Finished script
- # =============================================================================
- =begin
- Perkenalan :
- Script ini ngebikin cursor dalam window bergerak pindah
- Cara penggunaan :
- Pasang script ini dibawah Theo - Basic Module
- Pastikan $imported[:Theo_Movement] diset ke true di basic modul gw
- Edit konfignya kalo perlu
- Terms of Use :
- Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
- keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
- dipake buat komersil, jangan lupa, gw dibagi gratisannya.
- =end
- # =============================================================================
- # Sedikit Konfig
- # =============================================================================
- CursorMove_Duration = 5
- # Durasi dalam satuan frame. Dimana 60 frame sama dengan 1 detik
- # =============================================================================
- # Akhir dari konfig
- # =============================================================================
- # ----------------------------------------------------------------------------
- # Altered Rect Class
- # ----------------------------------------------------------------------------
- class Rect
- include THEO::Movement
- def empty?
- width <= 0 && height <= 0
- end
- def update
- set_obj(self) unless obj_defined?
- update_move
- end
- end
- # ----------------------------------------------------------------------------
- # Altered Window Selectable
- # ----------------------------------------------------------------------------
- class Window_Selectable < Window_Base
- # --------------------------------------------------------------------------
- # Overwrite update cursor
- # --------------------------------------------------------------------------
- def update_cursor
- if @cursor_all
- cursor_rect.set(0, 0, contents.width, row_max * item_height)
- self.top_row = 0
- elsif @index < 0
- cursor_rect.empty
- else
- ensure_cursor_visible
- if cursor_rect.empty?
- cursor_rect.set(item_rect(@index))
- else
- cursor_rect.set_obj(cursor_rect) unless cursor_rect.obj_defined?
- target_rect = item_rect(@index)
- xpos = target_rect.x
- ypos = target_rect.y
- cursor_rect.goto(xpos,ypos,CursorMove_Duration)
- end
- end
- end
- alias moving_cursor_update update
- def update
- moving_cursor_update
- cursor_rect.update
- end
- # --------------------------------------------------------------------------
- # Overwrite Cursor Index Movement
- # --------------------------------------------------------------------------
- def cursor_down(wrap = false)
- if index < item_max - col_max || (wrap && col_max == 1)
- select((index + col_max) % item_max,false)
- end
- end
- def cursor_up(wrap = false)
- if index >= col_max || (wrap && col_max == 1)
- select((index - col_max + item_max) % item_max,false)
- end
- end
- def cursor_right(wrap = false)
- if col_max >= 2 && (index < item_max - 1 || (wrap && horizontal?))
- select((index + 1) % item_max,false)
- end
- end
- def cursor_left(wrap = false)
- if col_max >= 2 && (index > 0 || (wrap && horizontal?))
- select((index - 1 + item_max) % item_max,false)
- end
- end
- def cursor_pagedown
- if top_row + page_row_max < row_max
- self.top_row += page_row_max
- select([@index + page_item_max, item_max - 1].min,false)
- end
- end
- def cursor_pageup
- if top_row > 0
- self.top_row -= page_row_max
- select([@index - page_item_max, 0].max,false)
- end
- end
- # --------------------------------------------------------------------------
- # Aliased Index Select
- # --------------------------------------------------------------------------
- alias moving_cursor_select select
- def select(index, instant = true)
- moving_cursor_select(index)
- if instant && index > 0 && !@cursor_all
- cursor_rect.set(item_rect(@index))
- end
- end
- end
- module THEO
- module Movement
- def obj_defined?
- !@move_obj.nil?
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment