All pastes #382713 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-03-05 21:15 UTC
rendered paste body
#=============================
# CMS MADE BY PREFIX
# FOR THE USE OF NECRILE ONLY
# NO SUPPORT FOR ANYOTHER USER
# v 1.0
#=============================
#_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
# \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
# /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#=================================================================================================
# ** Scene_Load2
#-------------------------------------------------------------------------------------------------
#  This class performs load screen processing.
#  Edited By Prefix So That When Used From Menu If Esc It Pressed It Goes To Menu Instead Of Title
#=================================================================================================

class Scene_Load2 < Scene_File
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Remake temporary object
    $game_temp = Game_Temp.new
    # Timestamp selects new file
    $game_temp.last_file_index = 0
    latest_time = Time.at(0)
    for i in 0..3
      filename = make_filename(i)
      if FileTest.exist?(filename)
        file = File.open(filename, "r")
        if file.mtime > latest_time
          latest_time = file.mtime
          $game_temp.last_file_index = i
        end
        file.close
      end
    end
    super("Which file would you like to load?")
  end
  #--------------------------------------------------------------------------
  # * Decision Processing
  #--------------------------------------------------------------------------
  def update
   if Input.trigger?(Input::B)
     # Call method: on_cancel (defined by the subclasses)
     $scene = Scene_Menu.new
     return
   end
 end
 
  def on_decision(filename)
    # If file doesn't exist
    unless FileTest.exist?(filename)
      # Play buzzer SE
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    # Play load SE
    $game_system.se_play($data_system.load_se)
    # Read save data
    file = File.open(filename, "rb")
    read_save_data(file)
    file.close
    # Restore BGM and BGS
    $game_system.bgm_play($game_system.playing_bgm)
    $game_system.bgs_play($game_system.playing_bgs)
    # Update map (run parallel process event)
    $game_map.update
    # Switch to map screen
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # * Cancel Processing
  #--------------------------------------------------------------------------
  def on_cancel
    # Play cancel SE
    $game_system.se_play($data_system.cancel_se)
    # Switch to title screen
    $scene = Scene_Title.new
  end
  #--------------------------------------------------------------------------
  # * Read Save Data
  #     file : file object for reading (opened)
  #--------------------------------------------------------------------------
  def read_save_data(file)
    # Read character data for drawing save file
    characters = Marshal.load(file)
    # Read frame count for measuring play time
    Graphics.frame_count = Marshal.load(file)
    # Read each type of game object
    $game_system        = Marshal.load(file)
    $game_switches      = Marshal.load(file)
    $game_variables     = Marshal.load(file)
    $game_self_switches = Marshal.load(file)
    $game_screen        = Marshal.load(file)
    $game_actors        = Marshal.load(file)
    $game_party         = Marshal.load(file)
    $game_troop         = Marshal.load(file)
    $game_map           = Marshal.load(file)
    $game_player        = Marshal.load(file)
    # If magic number is different from when saving
    # (if editing was added with editor)
    if $game_system.magic_number != $data_system.magic_number
      # Load map
      $game_map.setup($game_map.map_id)
      $game_player.center($game_player.x, $game_player.y)
    end
    # Refresh party members
    $game_party.refresh
  end
end

#_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
# \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
# /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ** Window_Gold
#------------------------------------------------------------------------------
#  This window displays amount of Currency.
#==============================================================================

class Window_Gold < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 160, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0, 5, 120, 32, $data_system.words.gold + ": " + $game_party.gold.to_s)
  end
end

#_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
# \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
# /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ** Window_Variables
#------------------------------------------------------------------------------
#  Displays variables 100 - 120
#==============================================================================

#
class Window_Variables < Window_Base
  def initialize
    super(5, 74, 355, 401)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
 
  def refresh
    self.contents.clear
    self.contents.draw_text(0, 10, 320, 32, "TextHere:  " + $game_variables[100].to_s)
    self.contents.draw_text(0, 42, 320, 32, "TextHere:  " + $game_variables[101].to_s)
    self.contents.draw_text(0, 74, 320, 32, "TextHere:  " + $game_variables[102].to_s)
    self.contents.draw_text(0, 106, 320, 32, "TextHere:  " + $game_variables[103].to_s)
    self.contents.draw_text(0, 138, 320, 32, "TextHere:  " + $game_variables[104].to_s)
    self.contents.draw_text(0, 170, 320, 32, "TextHere:  " + $game_variables[105].to_s)
    self.contents.draw_text(0, 202, 320, 32, "TextHere:  " + $game_variables[106].to_s)
    self.contents.draw_text(0, 234, 320, 32, "TextHere:  " + $game_variables[107].to_s)
    self.contents.draw_text(0, 266, 320, 32, "TextHere:  " + $game_variables[108].to_s)
    self.contents.draw_text(0, 298, 320, 32, "TextHere:  " + $game_variables[109].to_s)
    self.contents.draw_text(170, 10, 320, 32, "TextHere:  " + $game_variables[110].to_s)
    self.contents.draw_text(170, 42, 320, 32, "TextHere:  " + $game_variables[111].to_s)
    self.contents.draw_text(170, 74, 320, 32, "TextHere:  " + $game_variables[112].to_s)
    self.contents.draw_text(170, 106, 320, 32, "TextHere:  " + $game_variables[113].to_s)
    self.contents.draw_text(170, 138, 320, 32, "TextHere:  " + $game_variables[114].to_s)
    self.contents.draw_text(170, 170, 320, 32, "TextHere:  " + $game_variables[115].to_s)
    self.contents.draw_text(170, 202, 320, 32, "TextHere:  " + $game_variables[116].to_s)
    self.contents.draw_text(170, 234, 320, 32, "TextHere:  " + $game_variables[117].to_s)
    self.contents.draw_text(170, 266, 320, 32, "TextHere:  " + $game_variables[118].to_s)
    self.contents.draw_text(170, 298, 320, 32, "TextHere:  " + $game_variables[119].to_s)
    self.contents.draw_text(170, 298, 320, 32, "TextHere:  " + $game_variables[120].to_s)
  end
end

 

#_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
# \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
# /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ** Window_Menucommand
#------------------------------------------------------------------------------
#  Command Window For CMS
#==============================================================================

class Window_Menucommand < Window_Selectable

  def initialize
    super(5, 5, 630, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @item_max = 4
    @column_max = 4
    @commands = ["Save", "Load", "Prayers", "Exit"]
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    x = 4 + index * 157.5
    self.contents.draw_text(x, 0, 128, 32, @commands[index])
  end
end

#_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
# \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
# /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#==============================================================================
# ** Window_Base 
#------------------------------------------------------------------------------
#  Slight Change So Bars Are Supported
#==============================================================================

  class Window_Base < Window    
  def draw_actor_battler(actor, x, y)
    bitmap = RPG::Cache.battler(actor.character_name, actor.character_hue)
    src_rect = Rect.new(0, 0, 640, 480)
    self.contents.blt(0,0, bitmap, src_rect)
  end
     def draw_normal_barz(x, y, type, length, thick, e1, e2, c1 = Color.new(153,238,153,255), c2 = Color.new(0,0,0,255))
   if type == "horizontal"
     width = length
     height = thick
     self.contents.fill_rect(x-1, y - 1, width+2, height + 3, Color.new(255, 255, 255, 255))
     self.contents.fill_rect(x, y, width, height + 1, Color.new(0, 0, 0, 255))
     w = width * e1 / e2
     for i in 0..height
     r = c1.red + (c2.red - c1.red)   * (height -i)/height  + 0   * i/height
     g = c1.green + (c2.green - c1.green) * (height -i)/height  + 0 * i/height
     b = c1.blue + (c2.blue - c1.blue)  * (height -i)/height  + 0 * i/height
     a = c1.alpha + (c2.alpha - c1.alpha)* (height -i)/height  + 255 * i/height
     self.contents.fill_rect(x, y+i, w, 1, Color.new(r, g, b, a))
   end
 elsif type == "vertical"
   width = thick
   height = length
     self.contents.fill_rect(x-1, y - 1, width+3, height + 2, Color.new(255, 255, 255, 255))
     self.contents.fill_rect(x, y, width+1, height , Color.new(0, 0, 0, 255))
   h = height * e1 / e2
   for i in 0..width
     r = c1.red + (c2.red - c1.red)   * (width -i)/width  + 0   * i/width
     g = c1.green + (c2.green - c1.green) * (width -i)/width  + 0 * i/width
     b = c1.blue + (c2.blue - c1.blue)  * (width -i)/width  + 0 * i/width
     a = c1.alpha + (c2.alpha - c1.alpha)* (width -i)/width  + 255 * i/width
     self.contents.fill_rect(x+i, y, 1, h, Color.new(r, g, b, a))
   end
 end
end
def draw_actor_barz(actor,x, y, type, length, thick, e1, e2, c1 = Color.new(255,0,0,255), c2 = Color.new(0,0,0,255))
   if type == "horizontal"
     width = length
     height = thick
     self.contents.fill_rect(x-1, y - 1, width+2, height + 3, Color.new(255, 255, 255, 255))
     self.contents.fill_rect(x, y, width, height + 1, Color.new(0, 0, 0, 255))
     w = width * e1 / e2
     for i in 0..height
     r = c1.red + (c2.red - c1.red)   * (height -i)/height  + 0   * i/height
     g = c1.green + (c2.green - c1.green) * (height -i)/height  + 0 * i/height
     b = c1.blue + (c2.blue - c1.blue)  * (height -i)/height  + 0 * i/height
     a = c1.alpha + (c2.alpha - c1.alpha)* (height -i)/height  + 255 * i/height
     self.contents.fill_rect(x, y+i, w, 1, Color.new(r, g, b, a))
   end
 elsif type == "vertical"
   width = thick
   height = length
     self.contents.fill_rect(x-1, y - 1, width+3, height + 2, Color.new(255, 255, 255, 255))
     self.contents.fill_rect(x, y, width+1, height , Color.new(0, 0, 0, 255))
   h = height * e1 / e2
   for i in 0..width
     r = c1.red + (c2.red - c1.red)   * (width -i)/width  + 0   * i/width
     g = c1.green + (c2.green - c1.green) * (width -i)/width  + 0 * i/width
     b = c1.blue + (c2.blue - c1.blue)  * (width -i)/width  + 0 * i/width
     a = c1.alpha + (c2.alpha - c1.alpha)* (width -i)/width  + 255 * i/width
     self.contents.fill_rect(x+i, y, 1, h, Color.new(r, g, b, a))
   end
 end
end
end

#_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
# \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
# /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
#  This window displays party member status on the menu screen.
#==============================================================================
class Window_MenuStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 270, 250)
    self.contents = Bitmap.new(width - 32, height - 32)
    @selected_player = $game_actors[1]
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      x = 0
      y = i * 0
      actor = $game_party.actors[0]
      self.contents.font.size = 22
      self.contents.font.color = system_color
      draw_normal_barz(1, 60, "horizontal", 230, 15, $game_actors[1].hp.to_i, $game_actors[1].maxhp.to_i, Color.new (225, 0, 0, 225))
      draw_normal_barz(1, 116, "horizontal", 230, 15, $game_actors[1].sp.to_i, $game_actors[1].maxsp.to_i, Color.new (0,0,255,255))
      self.contents.font.color = normal_color
      self.contents.draw_text(100, -5, 320, 32, @selected_player.name.to_s + ":")
      self.contents.draw_text(0, 73, 320, 32, @selected_player.hp.to_s + " / " + @selected_player.maxhp.to_s + "  Hp")
      self.contents.draw_text(0, 129, 320, 32, @selected_player.sp.to_s + " / " + @selected_player.maxsp.to_s + "  Sp")
      self.contents.draw_text(170, -5, 320, 32, @selected_player.class_name)
    end
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
    end
  end
end
#_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
# \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
# /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  The Menu
#==============================================================================

class Scene_Menu
  # Pose Names
  POSES = ['down','left','right','up']
  # Number of Frames Per Pose
  FRAMES = 4
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make command window
    @sprite = Sprite_ActorCharGraphic.new($game_actors[1], 395, 85, 10, 0, 'left')
    @sprite.animate = true
    @spriteset = Sprite.new
    @spriteset.bitmap = RPG::Cache.title($data_system.title_name)
    @command_window = Window_Menucommand.new
    @command_window.index = @menu_index
    # If number of party members is 0
    if $game_party.actors.size == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
    end
    # If save is forbidden
    if $game_system.save_disabled
      # Disable save
      @command_window.disable_item(4)
    end
    # Make status window
    @status_window = Window_MenuStatus.new
    @status_window.x = 640 - @status_window.width - 5
    @status_window.y = @command_window.height + 10
    # Make gold window
    @gold_window = Window_Gold.new
    @gold_window.x = 640 - @status_window.width - 5
    @gold_window.y = @command_window.height + @status_window.height + 15
    @gold_window.width = @status_window.width
    @gold_window.height = 480 - 64 - 250 - 20
    @variable_window = Window_Variables.new
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @sprite.dispose
    @spriteset.dispose
    @variable_window.dispose
    @command_window.dispose
    @gold_window.dispose
    @status_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @spriteset.update
    @sprite.update
    @variable_window.update
    @command_window.update
    @gold_window.update
    @status_window.update
    # If command window is active: call update_command
    if @command_window.active
      update_command
      return
    end
    # If status window is active: call update_status
    if @status_window.active
      update_status
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
      when 0  # save
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Save.new
      when 1  # load
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Load2.new
      when 2  # exit
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Quests.new
      when 3  # exit
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_End.new
      end
      return
    end
  end
end