Szyu

Simple Factions

Sep 8th, 2015
582
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 27.03 KB | None | 1 0
  1. #~ #== Szyu Scripts presents =====================================================
  2. # * Szyu Scripts' Simple Factions
  3. # Version 1.1
  4. # by Szyu
  5. #
  6. #== Download ==================================================================
  7. # * pastebin:
  8. # http://adf.ly/4920670/simple-factions
  9. #
  10. #== About =====================================================================
  11. # * This script adds categorized factions to your game, which can be tracked
  12. #   and used for advanced event and script flow control.
  13. #   You can define event pages to be of a certain faction with simple access.
  14. #
  15. #== How to Use ================================================================
  16. # * Define your reputation levels, factions and faction categories in the module
  17. #   SZS_Factions.
  18. #
  19. # * To access a faction, use '$game_factions[index]'
  20. #   !The first faction has ID/index 0!
  21. #
  22. # * To add reputation to a faction, use
  23. #   '$game_factions.gain_reputation(id, amount)' to add reputation for a faction
  24. #   or
  25. #   '$game_factions.lose_reputation(id, amount)' to remove reputation for a faction
  26. #   If the reputation was not visible, it now will be displayed in the
  27. #   factions list.
  28. #
  29. # * To define an event page to be from a certain faction, use a comment including
  30. #   following line: '<faction: x>' where x is the index of the faction in the
  31. #   module's Factions-list
  32. #
  33. # * You can check if an event page is from faction with following script call:
  34. #   event.faction
  35. #   This will return the index (id) of the event's faction.
  36. #   If no faction is assigned, this will return nil.
  37. #
  38. # * With a Script-Condition like
  39. #   if event.faction && $game_factions[event.faction].reputation > x
  40. #   you can create a conditional branch, where you check for the players
  41. #   reputation with the event page's faction to be higher than a specific value.
  42. #
  43. #== Terms of Use ==============================================================
  44. # * You are free to use this script for commercial and non-commercial projects.
  45. # However I'd like you to inform me of the projects you are planning to use it
  46. # in, so I can keep track of where my scripts are used.
  47. #
  48. #== Import ====================================================================
  49. $imported = {} if $imported.nil?
  50. $imported["SZ-FACTIONS"] = true
  51. #==============================================================================
  52. module SZS_Factions
  53.   # Define Reputation Levels:
  54.   #   :name       - name of a level
  55.   #   :rep_min    - minimum reputation for a level
  56.   #   :bar_color1 - first color of the status bar
  57.   #                 Default_BarColor1 if nil or not defined
  58.   #   :bar_color2 - second color of the status bar,
  59.   #                 Default_BarColor2 if nil or not defined
  60.   Levels = [
  61.     {:name => "Hated", :rep_min => 0,
  62.           :bar_color1 => Color.new(220, 20,18),
  63.           :bar_color2 => Color.new(140, 5,30)},
  64.          
  65.     {:name => "Neutral", :rep_min =>  1000,
  66.           :bar_color1 => Color.new(40, 32, 218)},
  67.          
  68.     {:name => "Respected", :rep_min => 1800},
  69.    
  70.     {:name => "Loved", :rep_min => 2400,
  71.           :bar_color1 => Color.new(52, 242, 32)}
  72.   ]
  73.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74.   # Categories for factions. Add new factions to use in faction scene:
  75.   #   :faction  - identifier symbol, used as :type
  76.   #     => bla  - name of the type, used as vocab term
  77.   FactionType = {
  78.       :faction => "Faction",
  79.       :individual => "Individual"
  80.   }
  81.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  82.   # List of all factions:
  83.   #   :name           - name of the faction
  84.   #   :type           - category of the faction
  85.   #   :initial_value  - reputation value when first discovered
  86.   #   :discovered     - flag whether the faction is visible from game start or not
  87.   #   :graphic        - displayed graphic if description option is on
  88.   #   :description    - displayed description if description option is on
  89.   Factions = [
  90.     {:name => "Nemesis", :type => :faction, :initial_value => 1250, :discovered => true,
  91.       :graphic => "logo",:description => "Absolute faction, always winning. Loyalty is one of its members principles. Do not take them lightly when facing them..."},
  92.     {:name => "Genesis", :type => :faction, :initial_value => 1000},
  93.     {:name => "Ghosty", :type => :individual, :initial_value => 0},
  94.   ]
  95.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  96.   # Term displayed in menu
  97.   UseInMenu = true
  98.   MenuTerm = "Factions"
  99.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  100.   # Term displayed in menu
  101.   UseDescriptions = false
  102.   UseGraphics = false
  103.   DescriptionAlignment = 1
  104.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  105.   # Max value for a faction's reputation
  106.   MaxReputation = 2500
  107.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  108.   # Default colors for reputation status gauge
  109.   Default_BarColor1 = Color.new(172,196,36)
  110.   Default_BarColor2 = Color.new(82,106,16)
  111. end
  112.  
  113. #==============================================================================
  114. # ** Game Faction
  115. #==============================================================================
  116. class Game_Faction
  117.   attr_reader :id
  118.   attr_reader :name
  119.   attr_reader :reputation
  120.   attr_reader :type
  121.   attr_reader :level
  122.   #--------------------------------------------------------------------------
  123.   # * Initialize
  124.   #--------------------------------------------------------------------------
  125.   def initialize(id)
  126.     @id = id
  127.     fac = SZS_Factions::Factions[id]
  128.     @name = fac[:name]
  129.     @type = fac[:type]
  130.     @reputation = fac[:initial_value]
  131.     check_level
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # * Gain Reputation
  135.   #--------------------------------------------------------------------------
  136.   def gain_reputation(amount)
  137.     @reputation += amount
  138.     check_level
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # * Lose Reputation
  142.   #--------------------------------------------------------------------------
  143.   def lose_reputation(amount)
  144.     gain_reputation(-amount)
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # * Check Reputation Level
  148.   #--------------------------------------------------------------------------
  149.   def check_level
  150.     lv = -1
  151.     SZS_Factions::Levels.each do |rlv|
  152.       lv += 1 if @reputation >= rlv[:rep_min]
  153.     end
  154.     @level = lv
  155.   end
  156. end
  157.  
  158. #==============================================================================
  159. # ** Game Factions
  160. #==============================================================================
  161. class Game_Factions
  162.   #--------------------------------------------------------------------------
  163.   # * Object Initialization
  164.   #--------------------------------------------------------------------------
  165.   def initialize
  166.     @data = []
  167.   end
  168.   #--------------------------------------------------------------------------
  169.   # * Get Actor
  170.   #--------------------------------------------------------------------------
  171.   def [](fac_id)
  172.     return nil unless SZS_Factions::Factions[fac_id]
  173.     @data[fac_id] ||= Game_Faction.new(fac_id)
  174.   end
  175.   #--------------------------------------------------------------------------
  176.   # * Get All Factions not nil
  177.   #--------------------------------------------------------------------------
  178.   def all_factions
  179.     return @data.select{|f| !f.nil?}
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # * Get All Factions of a certain type
  183.   #--------------------------------------------------------------------------
  184.   def factions_of(type)
  185.     return @data.select{|f| !f.nil? && f.type == type}
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # * Gain Reputation
  189.   #--------------------------------------------------------------------------
  190.   def gain_reputation(fac_id, amount)
  191.     return nil unless SZS_Factions::Factions[fac_id]
  192.     @data[fac_id] ||= Game_Faction.new(fac_id)
  193.     @data[fac_id].gain_reputation(amount)
  194.   end
  195.   #--------------------------------------------------------------------------
  196.   # * Lose Reputation
  197.   #--------------------------------------------------------------------------
  198.   def lose_reputation(fac_id, amount)
  199.     gain_reputation(fac_id, -amount)
  200.   end
  201. end
  202.  
  203. #==============================================================================
  204. # ** Game_Event
  205. #==============================================================================
  206. class Game_Event < Game_Character
  207.   #--------------------------------------------------------------------------
  208.   # * Get Faction ID of the event's current page
  209.   #--------------------------------------------------------------------------
  210.   def faction
  211.     @page.list.map{|l| l.parameters}.each do |line|
  212.       next if line[0].nil?
  213.       if line[0] =~ /<faction:\s*(\d+)\s*>/i
  214.         fac_id = $1.to_i
  215.         return fac_id if SZS_Factions::Factions[fac_id]
  216.       end
  217.     end
  218.     return nil
  219.   end
  220. end
  221.  
  222. #==============================================================================
  223. # ** Game_Interpreter
  224. #==============================================================================
  225. class Game_Interpreter
  226.   #--------------------------------------------------------------------------
  227.   # * Get Current event
  228.   #--------------------------------------------------------------------------
  229.   def event
  230.     $game_map.events[@event_id] || nil
  231.   end
  232. end
  233.  
  234. #==============================================================================
  235. # ** DataManager
  236. #==============================================================================
  237. class << DataManager
  238.   alias :szs_factions_create_game_objects :create_game_objects
  239.   alias :szs_factions_make_save_contents :make_save_contents
  240.   alias :szs_factions_extract_save_contents :extract_save_contents
  241.   alias :szs_factions_setup_new_game :setup_new_game
  242.   #--------------------------------------------------------------------------
  243.   # * Create Game Objects
  244.   #--------------------------------------------------------------------------
  245.   def create_game_objects
  246.     szs_factions_create_game_objects
  247.     $game_factions = Game_Factions.new
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # * Create Save Contents
  251.   #--------------------------------------------------------------------------
  252.   def make_save_contents
  253.     contents = szs_factions_make_save_contents
  254.     contents[:factions]        = $game_factions
  255.     contents
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # * Extract Save Contents
  259.   #--------------------------------------------------------------------------
  260.   def extract_save_contents(contents)
  261.     szs_factions_extract_save_contents(contents)
  262.     $game_factions        = contents[:factions]
  263.   end
  264.   #--------------------------------------------------------------------------
  265.   # * Set Up New Game
  266.   #--------------------------------------------------------------------------
  267.   def setup_new_game
  268.     szs_factions_setup_new_game
  269.     SZS_Factions::Factions.select{|f| f[:discovered]}.each do |f|
  270.       $game_factions[SZS_Factions::Factions.index(f)]
  271.     end
  272.   end
  273. end
  274.  
  275. #==============================================================================
  276. # ** Scene FactionList
  277. #==============================================================================
  278. class Scene_FactionList < Scene_Base
  279.   #--------------------------------------------------------------------------
  280.   # * Start
  281.   #--------------------------------------------------------------------------
  282.   def start
  283.     super
  284.     create_category_window
  285.     create_help_window
  286.     create_fac_list_window
  287.     create_desc_window if SZS_Factions::UseDescriptions
  288.   end
  289.   #--------------------------------------------------------------------------
  290.   # * Create Category Window
  291.   #--------------------------------------------------------------------------
  292.   def create_category_window
  293.     @category_win = Window_FactionCategory.new
  294.     @category_win.set_handler(:ok,     method(:on_category_ok))
  295.     @category_win.set_handler(:cancel, method(:return_scene))
  296.   end
  297.   #--------------------------------------------------------------------------
  298.   # * Create Status Window
  299.   #--------------------------------------------------------------------------
  300.   def create_help_window
  301.     @help_window = Window_FactionStatus.new
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   # * Create List Window
  305.   #--------------------------------------------------------------------------
  306.   def create_fac_list_window
  307.     y = @category_win.height
  308.     w = Graphics.width
  309.     h = Graphics.height-y-@help_window.height
  310.     w /= 2 if SZS_Factions::UseDescriptions
  311.     @fac_list_win = Window_FactionList.new(0,y,w,h)
  312.     @fac_list_win.help_window = @help_window
  313.     @fac_list_win.set_handler(:cancel, method(:on_faction_cancel))
  314.     @category_win.reputation_window = @fac_list_win
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # * Create Description Window
  318.   #--------------------------------------------------------------------------
  319.   def create_desc_window
  320.     y = @category_win.height
  321.     h = Graphics.height-y-@help_window.height
  322.     x = @fac_list_win.width
  323.     w = Graphics.width - x
  324.     @desc_window = Window_FactionDescription.new(x,y,w,h)
  325.     @fac_list_win.description_window = @desc_window
  326.   end
  327.   #--------------------------------------------------------------------------
  328.   # * Terminate
  329.   #--------------------------------------------------------------------------
  330.   def terminate
  331.     super
  332.     @category_win.dispose
  333.     @fac_list_win.dispose
  334.     @help_window.dispose
  335.     @desc_window.dispose if @desc_window
  336.   end
  337.   #--------------------------------------------------------------------------
  338.   # * On Category selected
  339.   #--------------------------------------------------------------------------
  340.   def on_category_ok
  341.     @fac_list_win.activate.select(0)
  342.   end
  343.   #--------------------------------------------------------------------------
  344.   # * On List cancel
  345.   #--------------------------------------------------------------------------
  346.   def on_faction_cancel
  347.     @fac_list_win.deactivate.select(-1)
  348.     @help_window.faction = nil
  349.     @desc_window.faction = nil if @desc_window
  350.     @category_win.activate
  351.   end
  352. end
  353.  
  354. #==============================================================================
  355. # ** Scene_Menu
  356. #==============================================================================
  357. class Scene_Menu < Scene_MenuBase
  358.   alias :szs_factions_create_command_window :create_command_window
  359.   #--------------------------------------------------------------------------
  360.   # * Create Command Window
  361.   #--------------------------------------------------------------------------
  362.   def create_command_window
  363.     szs_factions_create_command_window
  364.     @command_window.set_handler(:factions, method(:command_factions))
  365.   end
  366.   #--------------------------------------------------------------------------
  367.   # * Command Factions
  368.   #--------------------------------------------------------------------------
  369.   def command_factions
  370.     SceneManager.call(Scene_FactionList)
  371.   end
  372. end
  373.  
  374. #==============================================================================
  375. # ** Window_FactionCategory
  376. #==============================================================================
  377. class Window_FactionCategory < Window_HorzCommand
  378.   #--------------------------------------------------------------------------
  379.   # * Public Instance Variables
  380.   #--------------------------------------------------------------------------
  381.   attr_reader   :reputation_window
  382.   #--------------------------------------------------------------------------
  383.   # * Object Initialization
  384.   #--------------------------------------------------------------------------
  385.   def initialize
  386.     super(0, 0)
  387.   end
  388.   #--------------------------------------------------------------------------
  389.   # * Get Window Width
  390.   #--------------------------------------------------------------------------
  391.   def window_width
  392.     Graphics.width
  393.   end
  394.   #--------------------------------------------------------------------------
  395.   # * Get Digit Count
  396.   #--------------------------------------------------------------------------
  397.   def col_max
  398.     return SZS_Factions::FactionType.size
  399.   end
  400.   #--------------------------------------------------------------------------
  401.   # * Frame Update
  402.   #--------------------------------------------------------------------------
  403.   def update
  404.     super
  405.     @reputation_window.category = current_symbol if @reputation_window
  406.   end
  407.   #--------------------------------------------------------------------------
  408.   # * Create Command List
  409.   #--------------------------------------------------------------------------
  410.   def make_command_list
  411.     SZS_Factions::FactionType.each do |k, v|
  412.       add_command(v,k)
  413.     end
  414.   end
  415.   #--------------------------------------------------------------------------
  416.   # * Set Item Window
  417.   #--------------------------------------------------------------------------
  418.   def reputation_window=(reputation_window)
  419.     @reputation_window = reputation_window
  420.     update
  421.   end
  422. end
  423.  
  424. #==============================================================================
  425. # ** Window_FactionList
  426. #==============================================================================
  427. class Window_FactionList < Window_Selectable
  428.   attr_reader :description_window
  429.   #--------------------------------------------------------------------------
  430.   # * Object Initialization
  431.   #--------------------------------------------------------------------------
  432.   def initialize(x, y, width, height)
  433.     super
  434.     @category = :none
  435.     @data = []
  436.   end
  437.   #--------------------------------------------------------------------------
  438.   # * Set Category
  439.   #--------------------------------------------------------------------------
  440.   def category=(category)
  441.     return if @category == category
  442.     @category = category
  443.     refresh
  444.     self.oy = 0
  445.   end
  446.   #--------------------------------------------------------------------------
  447.   # * Set Description Window
  448.   #--------------------------------------------------------------------------
  449.   def description_window=(dw)
  450.     @description_window = dw
  451.     refresh
  452.   end
  453.   #--------------------------------------------------------------------------
  454.   # * Get Digit Count
  455.   #--------------------------------------------------------------------------
  456.   def col_max
  457.     return SZS_Factions::UseDescriptions ? 1 : 2
  458.   end
  459.   #--------------------------------------------------------------------------
  460.   # * Get Number of Items
  461.   #--------------------------------------------------------------------------
  462.   def item_max
  463.     @data ? @data.size : 1
  464.   end
  465.   #--------------------------------------------------------------------------
  466.   # * Get Item
  467.   #--------------------------------------------------------------------------
  468.   def item
  469.     @data && index >= 0 ? @data[index] : nil
  470.   end
  471.   #--------------------------------------------------------------------------
  472.   # * Get Activation State of Selection Item
  473.   #--------------------------------------------------------------------------
  474.   def current_item_enabled?
  475.     return true
  476.   end
  477.   #--------------------------------------------------------------------------
  478.   # * Create Item List
  479.   #--------------------------------------------------------------------------
  480.   def make_item_list
  481.     @data = $game_factions.factions_of(@category)
  482.   end
  483.   #--------------------------------------------------------------------------
  484.   # * Restore Previous Selection Position
  485.   #--------------------------------------------------------------------------
  486.   def select_last
  487.     select(@data.index($game_party.last_item.object) || 0)
  488.   end
  489.   #--------------------------------------------------------------------------
  490.   # * Draw Item
  491.   #--------------------------------------------------------------------------
  492.   def draw_item(index)
  493.     item = @data[index]
  494.     if item
  495.       rect = item_rect(index)
  496.       rect.width -= 4
  497.       draw_text_ex(rect.x,rect.y, item.name)
  498.     end
  499.   end
  500.   #--------------------------------------------------------------------------
  501.   # * Update Help Text
  502.   #--------------------------------------------------------------------------
  503.   def update_help
  504.     @help_window.faction = item if @help_window
  505.     @description_window.faction = item if @description_window
  506.   end
  507.   #--------------------------------------------------------------------------
  508.   # * Refresh
  509.   #--------------------------------------------------------------------------
  510.   def refresh
  511.     make_item_list
  512.     create_contents
  513.     draw_all_items
  514.   end
  515. end
  516.  
  517. #==============================================================================
  518. # ** Window_FactionStatus
  519. #==============================================================================
  520. class Window_FactionStatus < Window_Base
  521.   attr_reader :faction
  522.   #--------------------------------------------------------------------------
  523.   # * Initialize
  524.   #--------------------------------------------------------------------------
  525.   def initialize
  526.     h = fitting_height(1)
  527.     super(0,Graphics.height-h,Graphics.width, h)
  528.   end
  529.   #--------------------------------------------------------------------------
  530.   # * Set Faction
  531.   #--------------------------------------------------------------------------
  532.   def faction=(faction)
  533.     @faction=faction
  534.     refresh
  535.   end
  536.   #--------------------------------------------------------------------------
  537.   # * Refresh
  538.   #--------------------------------------------------------------------------
  539.   def refresh
  540.     contents.clear
  541.     return unless @faction
  542.     draw_reputation
  543.     draw_reputation_text
  544.   end
  545.   #--------------------------------------------------------------------------
  546.   # * Draw Reputation
  547.   #--------------------------------------------------------------------------
  548.   def draw_reputation
  549.     draw_rep_gauge(0, 0, contents.width/3*2,line_height-8,
  550.       @faction.reputation.to_f/SZS_Factions::MaxReputation,
  551.       hp_gauge_color1, hp_gauge_color2)
  552.     change_color(system_color)
  553.     draw_current_and_max_values(96, 0, 132,
  554.       @faction.reputation, SZS_Factions::MaxReputation,
  555.       normal_color, normal_color)
  556.   end
  557.   #--------------------------------------------------------------------------
  558.   # * Draw Reputation Gauge
  559.   #--------------------------------------------------------------------------
  560.   def draw_rep_gauge(x, y, width,height, rate, color1, color2)
  561.     fill_w = (width * rate).to_i
  562.     gauge_y = y+(line_height-height)/2
  563.     contents.fill_rect(x, gauge_y, width, height, gauge_back_color)
  564.     contents.gradient_fill_rect(x, gauge_y, fill_w, height,
  565.     SZS_Factions::Levels[faction.level][:bar_color1] || SZS_Factions::Default_BarColor1,
  566.     SZS_Factions::Levels[faction.level][:bar_color2] || SZS_Factions::Default_BarColor2)
  567.   end
  568.   #--------------------------------------------------------------------------
  569.   # * Draw Reputation Text
  570.   #--------------------------------------------------------------------------
  571.   def draw_reputation_text
  572.     x = contents.width/3*2+8
  573.     txt = SZS_Factions::Levels[faction.level][:name]
  574.     fc = Color.new(0,0,0,96)
  575.     contents.fill_rect(x,0,contents.width-x,line_height, fc)
  576.     draw_text(x,0,contents.width-x,line_height, txt,1)
  577.   end
  578. end
  579.  
  580. #==============================================================================
  581. # ** Window_FactionDescription
  582. #==============================================================================
  583. class Window_FactionDescription < Window_Base
  584.   attr_reader :faction
  585.   #--------------------------------------------------------------------------
  586.   # * Initialize
  587.   #--------------------------------------------------------------------------
  588.   def initialize(x,y,w,h)
  589.     super(x,y,w,h)
  590.   end
  591.   #--------------------------------------------------------------------------
  592.   # * Set Faction
  593.   #--------------------------------------------------------------------------
  594.   def faction=(faction)
  595.     @faction=faction
  596.     refresh
  597.   end
  598.   #--------------------------------------------------------------------------
  599.   # * Refresh
  600.   #--------------------------------------------------------------------------
  601.   def refresh
  602.     contents.clear
  603.     return unless @faction
  604.     draw_faction_graphic if SZS_Factions::UseGraphics
  605.     draw_faction_desc if SZS_Factions::UseDescriptions
  606.   end
  607.   #--------------------------------------------------------------------------
  608.   # * Draw Faction Graphic
  609.   #--------------------------------------------------------------------------
  610.   def draw_faction_graphic
  611.     return unless SZS_Factions::Factions[@faction.id][:graphic]
  612.     gr = Cache.picture(SZS_Factions::Factions[@faction.id][:graphic])
  613.     aspect = gr.width.to_f / gr.height.to_f
  614.     h = contents.width * aspect
  615.     contents.stretch_blt(Rect.new(0,(contents.height-h),contents.width, h),
  616.         gr, Rect.new(0,0,gr.width, gr.height))
  617.   end
  618.   #--------------------------------------------------------------------------
  619.   # * Draw Faction Description
  620.   #--------------------------------------------------------------------------
  621.   def draw_faction_desc
  622.     return unless SZS_Factions::Factions[@faction.id][:description]
  623.     i = 0
  624.     split_text(SZS_Factions::Factions[@faction.id][:description]).each do |line|
  625.       draw_line_back(0, line_height*i, contents.width, line_height)
  626.       draw_text(0, line_height * i, contents.width, line_height, line, SZS_Factions::DescriptionAlignment)
  627.       i += 1
  628.     end
  629.   end
  630.   #--------------------------------------------------------------------------
  631.   # * Draw Line Back
  632.   #--------------------------------------------------------------------------
  633.   def draw_line_back(x,y,w,h)
  634.     contents.fill_rect(x,y+1,w,h-2, Color.new(0,0,0,96))
  635.   end
  636.   #--------------------------------------------------------------------------
  637.   # * Split Text
  638.   #--------------------------------------------------------------------------
  639.   def split_text(txt)
  640.     txt_splits = []
  641.     line = ""
  642.     txt.split.each do |word|
  643.       line += word + " "
  644.       if contents.text_size(line).width > width
  645.         txt_splits << line
  646.         line = ""
  647.       end
  648.     end
  649.     txt_splits << line if line.size > 0
  650.     txt_splits
  651.   end
  652. end
  653.  
  654. #==============================================================================
  655. # ** Window_MenuCommand
  656. #==============================================================================
  657. class Window_MenuCommand < Window_Command
  658.   alias :szs_factions_add_original_commands :add_original_commands
  659.   #--------------------------------------------------------------------------
  660.   # * For Adding Original Commands
  661.   #--------------------------------------------------------------------------
  662.   def add_original_commands
  663.     szs_factions_add_original_commands
  664.     add_command(SZS_Factions::MenuTerm,   :factions) if SZS_Factions::UseInMenu
  665.   end
  666. end
Advertisement
Add Comment
Please, Sign In to add comment