Advertisement
Guest User

Untitled

a guest
Oct 1st, 2011
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.04 KB | None | 0 0
  1. #==============================================================
  2. #
  3. # HSTC - Total Window Maker V 1.0
  4. #
  5. # This is a script which lets the user make a custom window. The user
  6. # can choose to use the window as an HUD or as an option in the Menu.
  7. #
  8. #
  9. # How to use:
  10. #
  11. # 1) Set-up the config
  12. # 2) Switch the Switch_ID In-Game ON
  13. # 3) Finished
  14. #
  15. # Credit:
  16. #
  17. # HungrySnake
  18. #
  19. #==============================================================
  20.  
  21. module WM
  22.   module Config
  23.    
  24. #==============================================================
  25. #
  26. #                        Start Config
  27. #
  28. #==============================================================
  29.  
  30.     # WLH ----------------------------------------------------------------------
  31.       WLH = 24 # When you change the WLH in Window_Base, change this to that
  32.                # value too.
  33.     # ------------------------------------------------------------------------
  34.    
  35.     # Switch -------------------------------------------------------------------
  36.       SWITCH_ID = 20 # Switch ID to turn your Custom Window ON
  37.     # --------------------------------------------------------------------------
  38.    
  39.     # Visual -------------------------------------------------------------------
  40.       WINDOW_X = 0 # Your custom window's  X Coordinate
  41.       WINDOW_Y = 0 # Your custom window's  Y Coordinate
  42.       WINDOW_WIDTH = Graphics.width # Your custom window's  width
  43.       WINDOW_HEIGHT = Graphics.height # Your custom window's  height
  44.      
  45.       SHOW_MAP = false    # Set this to true, to show the window as an HUD.
  46.                          
  47.       MENU_TEXT = "Window" # Text to show in the menu
  48.     # --------------------------------------------------------------------------
  49.        
  50.       # ------------------------------------------------------------------------                  
  51.       # For which actor does the window to draw
  52.       # the things beneath?
  53.       #
  54.       # Options:
  55.       #
  56.       # 0 = Current active actor
  57.       # 1 = Second party member
  58.       # 2 = Third party member
  59.       # 4 = Fourth party member
  60.       # false = All the members of the party
  61.         DRAW_WHICH_ACTOR = 0
  62.       # ------------------------------------------------------------------------
  63.      
  64.       # ------------------------------------------------------------------------
  65.         DRAW_PARAMETER = [ # << Don't delete
  66.      
  67.         true, # Draw Attack
  68.         true, # Draw Defence
  69.         true, # Draw Agility
  70.         true, # Draw Spirit
  71.      
  72.         ] # << Don't delete
  73.      
  74.         PARA_ATK_X = 250 # X coordinate to draw the Attack
  75.         PARA_ATK_Y = WLH * 0 # Y coordinate to draw the Attack
  76.      
  77.         PARA_DEF_X = 250 # X coordinate to draw the Defence
  78.         PARA_DEF_Y = WLH * 1 # Y coordinate to draw the Defence
  79.        
  80.         PARA_AGI_X = 250 # X coordinate to draw the Agility
  81.         PARA_AGI_Y = WLH * 2 # Y coordinate to draw the Agility
  82.      
  83.         PARA_SPI_X = 250 # X coordinate to draw the Spirit
  84.         PARA_SPI_Y = WLH * 3 # Y coordinate to draw the Spirit
  85.       # ------------------------------------------------------------------------
  86.      
  87.       # ------------------------------------------------------------------------
  88.         DRAW_STUFF = [
  89.      
  90.           true, # << draw_actor_face
  91.           true, # << draw_actor_name
  92.           true, # << draw_actor_graphic
  93.           true, # << draw_actor_level
  94.           true, # << draw_actor_hp
  95.           true, # << draw_actor_mp
  96.           true, # << draw_actor_class
  97.           true, # << draw_actor_state
  98.      
  99.         ]
  100.      
  101.           ACTOR_FACE_X = 2 # Actor Face X coordinate
  102.           ACTOR_FACE_Y = 0 # Actor Face Y coordinate
  103.      
  104.           ACTOR_NAME_X = 184 # Actor Name X coordinate
  105.           ACTOR_NAME_Y = 0 # -15 # Actor Name Y coordinate
  106.      
  107.           ACTOR_GRAPHIC_X = 50 # Actor Graphic X coordinate
  108.           ACTOR_GRAPHIC_Y = 80 # Actor Graphic Y coordinate
  109.      
  110.           ACTOR_LEVEL_X = 104 # Actor Level X coordinate
  111.           ACTOR_LEVEL_Y = WLH # Actor Level Y coordinate  
  112.      
  113.           ACTOR_HP_X = 104 # Actor HP X coordinate
  114.           ACTOR_HP_Y = WLH * 2 # Actor HP Y coordinate
  115.      
  116.           ACTOR_MP_X = 104 # Actor MP X coordinate
  117.           ACTOR_MP_Y = WLH * 3 # Actor MP Y coordinate
  118.      
  119.           ACTOR_CLASS_X = 104 # Actor Class X coordinate
  120.           ACTOR_CLASS_Y = 0 # Actor Class Y coordinate
  121.      
  122.           ACTOR_STATE_X = 104 # Actor State X coordinate
  123.           ACTOR_STATE_Y = 45 # Actor State Y coordinate
  124.      
  125.           DRAW_TEXT1 = "Test Window" # String of the text
  126.           DRAW_TEXT1_X = 0 # X coordinate to draw the text
  127.           DRAW_TEXT1_Y = WLH * 4 # Y coordinate to draw the text
  128.        
  129.           DRAW_TEXT2 = "Hi" # String of the text
  130.           DRAW_TEXT2_X = 0 # X coordinate to draw the text
  131.           DRAW_TEXT2_Y = WLH * 5 # Y coordinate to draw the text
  132.          
  133.           DRAW_TEXT3 = "" # When not used, leave it like this.
  134.           DRAW_TEXT3_X = 0 # When not used, leave it like this.
  135.           DRAW_TEXT3_Y = 0 # When not used, leave it like this.
  136.          
  137.           DRAW_TEXT4 = "" # When not used, leave it like this.
  138.           DRAW_TEXT4_X = 0 # When not used, leave it like this.
  139.           DRAW_TEXT4_Y = 0 # When not used, leave it like this.
  140.        
  141.       # ------------------------------------------------------------------------        
  142.   end
  143. end
  144.  
  145. #==============================================================
  146. #
  147. #                        End Config
  148. #
  149. #==============================================================
  150.  
  151.  
  152. class Window_CustomWindow < Window_Base
  153.   include WM::Config
  154.  
  155.   def initialize
  156.     super(WINDOW_X,WINDOW_Y,WINDOW_WIDTH,WINDOW_HEIGHT)
  157.     self.visible = $game_switches[SWITCH_ID]
  158.     refresh
  159.   end
  160.  
  161.   def refresh
  162.     self.contents.clear
  163.     determine_actor
  164.   end
  165.  
  166.   def update
  167.     super
  168.     self.visible = $game_switches[SWITCH_ID]
  169.   end
  170.  
  171.   def determine_actor
  172.     if DRAW_WHICH_ACTOR == false
  173.       for actor in $game_party.members
  174.         draw_contents(actor)
  175.       end
  176.     else
  177.       actor = $game_party.members[DRAW_WHICH_ACTOR]
  178.       draw_contents(actor)
  179.     end
  180.   end
  181.  
  182.   def draw_contents(actor)
  183.       y = actor.index * 96 + WLH / 2
  184.       self.contents.draw_text(DRAW_TEXT1_X,DRAW_TEXT1_Y,180,WLH,DRAW_TEXT1)
  185.       self.contents.draw_text(DRAW_TEXT2_X,DRAW_TEXT2_Y,180,WLH,DRAW_TEXT2)
  186.       self.contents.draw_text(DRAW_TEXT3_X,DRAW_TEXT3_Y,180,WLH,DRAW_TEXT3)
  187.       self.contents.draw_text(DRAW_TEXT4_X,DRAW_TEXT4_Y,180,WLH,DRAW_TEXT4)
  188.       if DRAW_STUFF[0]
  189.         draw_actor_face(actor, ACTOR_FACE_X, actor.index * 96 + 2 + ACTOR_FACE_Y, 92)
  190.       end
  191.       if DRAW_STUFF[1]
  192.         draw_actor_name(actor, ACTOR_NAME_X, y + ACTOR_NAME_Y)          
  193.       end
  194.       if DRAW_STUFF[2]
  195.         draw_actor_graphic(actor,ACTOR_GRAPHIC_X, y + ACTOR_GRAPHIC_Y)
  196.       end
  197.       if DRAW_STUFF[3]
  198.         draw_actor_level(actor,ACTOR_LEVEL_X, y + ACTOR_LEVEL_Y)
  199.       end
  200.       if DRAW_STUFF[4]
  201.         draw_actor_hp(actor,ACTOR_HP_X, y + ACTOR_HP_Y)
  202.       end
  203.       if DRAW_STUFF[5]
  204.         draw_actor_mp(actor,ACTOR_MP_X, y + ACTOR_MP_Y)
  205.       end
  206.       if DRAW_STUFF[6]
  207.         draw_actor_class(actor,ACTOR_CLASS_X, y + ACTOR_CLASS_Y)
  208.       end
  209.       if DRAW_STUFF[7]
  210.         draw_actor_state(actor,ACTOR_STATE_X, y + ACTOR_STATE_Y)
  211.       end
  212.       if DRAW_PARAMETER[0]
  213.         draw_actor_parameter(actor, PARA_ATK_X, y + PARA_ATK_Y, 0)
  214.       end
  215.       if DRAW_PARAMETER[1]
  216.         draw_actor_parameter(actor, PARA_DEF_X, y + PARA_DEF_Y, 1)
  217.       end
  218.       if DRAW_PARAMETER[2]
  219.         draw_actor_parameter(actor, PARA_AGI_X, y + PARA_AGI_Y, 2)
  220.       end
  221.       if DRAW_PARAMETER[3]
  222.         draw_actor_parameter(actor, PARA_SPI_X, y + PARA_SPI_Y, 3)
  223.       end
  224.     end
  225.   end
  226.  
  227. class Scene_CustomWindow < Scene_Base
  228.   def start
  229.     super
  230.     create_menu_background
  231.     @customwindow = Window_CustomWindow.new
  232.   end
  233.  
  234.   def update
  235.     @customwindow.update
  236.     if @customwindow.active = true
  237.       update_customscreen
  238.     end
  239.   end
  240.  
  241.   def update_customscreen
  242.     if Input.trigger?(Input::B)
  243.       Sound.play_cancel
  244.       return_scene
  245.     end
  246.   end
  247.  
  248.   def terminate
  249.     @customwindow.dispose
  250.   end
  251.  
  252.   def return_scene
  253.     $scene = Scene_Menu.new(0)
  254.   end
  255.  
  256. end
  257.  
  258.  
  259. class Scene_Map < Scene_Base
  260.   include WM::Config
  261.  
  262.   alias hsnake_wa_start start unless $@
  263.   def start(*args,&block)
  264.     if SHOW_MAP
  265.       @customwindow = Window_CustomWindow.new
  266.     end
  267.     hsnake_wa_start(*args,&block)
  268.   end
  269.  
  270.   alias hsnake_wa_update update unless $@
  271.   def update(*args,&block)
  272.     if SHOW_MAP
  273.       @customwindow.update
  274.     end
  275.     hsnake_wa_update(*args,&block)
  276.   end
  277.  
  278.   alias hsnake_wa_terminate terminate unless $@
  279.   def terminate(*args,&block)
  280.     if SHOW_MAP
  281.       @customwindow.dispose
  282.     end
  283.     hsnake_wa_terminate(*args,&block)
  284.   end
  285. end
  286.  
  287. class Scene_Menu < Scene_Base
  288.   include WM::Config
  289.  
  290.   #--------------------------------------------------------------------------
  291.   # * Create Command Window
  292.   #--------------------------------------------------------------------------
  293.   def create_command_window
  294.     s1 = Vocab::item
  295.     s2 = Vocab::skill
  296.     s3 = Vocab::equip
  297.     s4 = Vocab::status
  298.     s5 = Vocab::save
  299.     s6 = Vocab::game_end
  300.     if SHOW_MAP == false and $game_switches[SWITCH_ID]
  301.       s7 = MENU_TEXT      
  302.       @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s7, s6])
  303.     else
  304.       @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
  305.     end    
  306.     @command_window.index = @menu_index
  307.     if $game_party.members.size == 0          # If number of party members is 0
  308.       @command_window.draw_item(0, false)     # Disable item
  309.       @command_window.draw_item(1, false)     # Disable skill
  310.       @command_window.draw_item(2, false)     # Disable equipment
  311.       @command_window.draw_item(3, false)     # Disable status
  312.     end
  313.     if $game_system.save_disabled             # If save is forbidden
  314.       @command_window.draw_item(4, false)     # Disable save
  315.     end
  316.   end
  317.  
  318.   #--------------------------------------------------------------------------
  319.   # * Update Command Selection
  320.   #--------------------------------------------------------------------------
  321.   def update_command_selection
  322.     if Input.trigger?(Input::B)
  323.       Sound.play_cancel
  324.       $scene = Scene_Map.new
  325.     elsif Input.trigger?(Input::C)
  326.       if $game_party.members.size == 0 and @command_window.index < 4
  327.         Sound.play_buzzer
  328.         return
  329.       elsif $game_system.save_disabled and @command_window.index == 4
  330.         Sound.play_buzzer
  331.         return
  332.       end
  333.       Sound.play_decision
  334.       case @command_window.index
  335.       when 0      # Item
  336.         $scene = Scene_Item.new
  337.       when 1,2,3  # Skill, equipment, status
  338.         start_actor_selection
  339.       when 4      # Save
  340.         $scene = Scene_File.new(true, false, false)
  341.       when 5      # Window
  342.         $scene = Scene_CustomWindow.new
  343.       when 6      # End Game
  344.         $scene = Scene_End.new
  345.       end
  346.     end
  347.   end
  348. end
  349.  
  350.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement