Basic Moving Windows (Version: Alpha 2)

View previous topic View next topic Go down

Basic Moving Windows (Version: Alpha 2)

Post  Fantasist on Tue Jan 22, 2008 8:03 pm

Basic Moving Windows
Version: Alpha-2
Type: Graphical Enhancement



Introduction

Moves a window with a 'decelerating' effect (think STCMS)


Features

  • Moves windows with a 'decelerating' effect rather than plain motion
  • Can handle movement in any direction, just give the window a destination and it will move there



Screenshots

N/A


Demo

Paste this in a new slot just below Scene_Menu and you have your demo (after installing the script of course)

Script:
Spoiler:
Code:
class Scene_Menu

  def main
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = 'Status'
    s5 = 'Save'
    s6 = 'End Game'
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
    @command_window.index = @menu_index
    @command_window.y = -224
    if $game_party.actors.size == 0
      (0..3).each {|i| @command_window.disable_item(i)}
    end
    @command_window.disable_item(4) if $game_system.save_disabled
    # Make play time window
    @playtime_window = Window_PlayTime.new
    @playtime_window.x = -160
    @playtime_window.y = 224
    # Make steps window
    @steps_window = Window_Steps.new
    @steps_window.x = -160
    @steps_window.y = 320
    # Make gold window
    @gold_window = Window_Gold.new
    @gold_window.x = -160
    @gold_window.y = 416
    # Make status window
    @status_window = Window_MenuStatus.new
    @status_window.x = 640
    @status_window.y = 0
    Graphics.transition
    loop {
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    }
    Graphics.freeze
    @command_window.dispose
    @playtime_window.dispose
    @steps_window.dispose
    @gold_window.dispose
    @status_window.dispose
  end
 
  alias moving_wins_test_menu_upd update
  def update
    @command_window.move(0, 0)
    @playtime_window.move(0, 224)
    @steps_window.move(0, 320)
    @gold_window.move(0, 416)
    @status_window.move(160, 0)
    moving_wins_test_menu_upd
  end
 
end



Script

Paste in a new script slot above main.

Script:
Spoiler:
Code:

#==============================================================================
# Moving windows (Alpha 2)
# by Fantasist
#------------------------------------------------------------------------------
#  This adds the 'move' function to windows. Syntax is
#    @window.move(dest_x, dest_y)
#  where
#      @window :The window you want to move
#      dest_x    :Destination x coordinate
#      dest_y    :Destination y coordinate
#==============================================================================

class Window_Base < Window
 #--------------------------------------------------------------------------
 # * Initialize
 #--------------------------------------------------------------------------
 alias moving_win_base_init initialize
 def initialize(x, y, w, h)
  moving_win_base_init(x, y, w, h)
  @dest_x, @dest_y = x, y
  @tot_x = @tot_y = 0
  end
 #--------------------------------------------------------------------------
 # * moving? - checks if the window needs moving
 #--------------------------------------------------------------------------
 def moving?
  return self.x != @dest_x || self.y != @dest_y
 end
 #--------------------------------------------------------------------------
 # * Move - prepares variables and sets off the moving process
 #-------------------------------------------------------------------------- 
 def move(dest_x, dest_y)
  @dest_x = dest_x
  @dest_y = dest_y
  @tot_x = (dest_x - self.x).abs
  @tot_y = (dest_y - self.y).abs
 end
 #--------------------------------------------------------------------------
 # Move Windows - the actual processing of movement
 #-------------------------------------------------------------------------- 
 def move_wins
  x = self.x
  y = self.y
  dist_x = [((@dest_x-x).abs/3.0).ceil, (@tot_x/3.0).ceil].min
  dist_y = [((@dest_y-y).abs/3.0).ceil, (@tot_y/3.0).ceil].min
  @dest_x > x ? self.x += dist_x : self.x -= dist_x
  @dest_y > y ? self.y += dist_y : self.y -= dist_y
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 alias upd_win_base_move update
 def update
  upd_win_base_move
  move_wins if moving?
 end
end


Instructions

# This adds the 'move' function to windows. Syntax is
# @window.move(dest_x, dest_y)
# where
# @window :The window you want to move
# dest_x :Destination x coordinate
# dest_y :Destination y coordinate


Compatibility

No issues, not compatible with other window moving scripts.


Credits and Thanks

Credit Fantasist (me) for making it.


Author's Notes

This is just a quick addon I've came up with. Enjoy ^_^


Last edited by on Wed Jan 23, 2008 8:01 pm; edited 1 time in total

Fantasist
Admin

Posts : 53
Join date : 2008-01-13

View user profile http://quantumcore.forumotion.com

Back to top Go down

Re: Basic Moving Windows (Version: Alpha 2)

Post  Nortos on Wed Jan 23, 2008 6:27 am

love this little small addon Smile

Nortos

Posts : 32
Join date : 2008-01-22

View user profile

Back to top Go down

Re: Basic Moving Windows (Version: Alpha 2)

Post  Fantasist on Wed Jan 23, 2008 7:59 pm

Thnx Smile

*fixes 'Basic Movind Windows' in title*

Fantasist
Admin

Posts : 53
Join date : 2008-01-13

View user profile http://quantumcore.forumotion.com

Back to top Go down

Re: Basic Moving Windows (Version: Alpha 2)

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum