Pumamori

Hime's Large Choices - German Version

Jun 1st, 2015
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.80 KB | None | 0 0
  1. =begin
  2. #==============================================================================
  3.  Titel: Large Choices ("Größere Auswahlmöglichkeiten")
  4.  Autor: Hime
  5.  Übersetzung: Puma
  6.  Datum: Nov 18, 2013
  7.  URL: http://himeworks.com/2012/12/large-choices-built-in-multiple-choices/
  8. ------------------------------------------------------------------------------
  9.  ** Change log
  10.  Nov 18, 2013
  11.    - geupdated um die eventseite der originalen liste beizubehalten
  12.  Apr 10, 2013
  13.    - option zum ausschalten des automatischen kombinierens hinzugefügt
  14.  Mär 26, 2013
  15.    - bug gefixt, bei dem die abbruch-auswahl nicht richtig geupdated wurde
  16.  Jän 12, 2013
  17.    - bug gefixt, bei dem der erste satz der optionen falsch nummeriert wurde
  18.  Dez 7, 2012
  19.    - richtiger zweig-abbruch eingebaut
  20.  Dez 6, 2012
  21.    - ursprünglicher release
  22. ------------------------------------------------------------------------------  
  23.  ** Nutzungsbedingungen
  24.  * Kostenlos für nicht-kommerzielle Projekte
  25.  * Kontaktiert mich für kommerzielle Nutzung
  26.  * Keine richtige Unterstützung. Das Skript wird so wie es ist zur Verfügung gestellt
  27.  * Bugs werden behoben, aber keine Kompatibilitätsprobleme
  28.  * Nach Features kann gefragt werden, aber es gibt keine Garantie, dass sie auch
  29.    umgesetzt werden, besonders bei unnötigen Änderungen
  30.  * Credits gehen in eurem Projekt an Hime Works
  31.  * Dieser Teil muss erhalten bleiben
  32. ------------------------------------------------------------------------------
  33.  ** Beschreibung
  34.  
  35.  Dieses Skript kombiniert Gruppen von "Show Choice" Optionen als einen großen
  36.  Befehl. Das erlaubt es euch mehr als 4 Auswahlmöglichkeiten zu haben, indem ihr
  37.  einfach mehrere "Show Choice" Befehle nutzt.
  38. ------------------------------------------------------------------------------
  39.  ** Installation
  40.  
  41.  Platziert das Skript im Skripteditor unter Materials und über Main.
  42.  
  43. ------------------------------------------------------------------------------
  44.  ** Nutzung
  45.  
  46.  Fügt einen "Show Choice" Befehl hinzu.
  47.  Wollt ihr mehr Befehle, fügt einen weiteren hinzu, füllt diesen wie gewohnt
  48.  aus. Eine Nebenbemerkung, ihr solltet nur eine "Cancel" (Abbruch) Option wählen,
  49.  nehmt ihr mehrere, wird vom Skript die letzte genommen.
  50.  
  51.  Für "Zweig-Abbrechen", solltet ihr beachten, dass *alle* Abbruch Zweige
  52.  durchgeführt werden. Ihr solltet nur im letzten Set von Auswahlmöglichkeiten
  53.  ein Zweig-Abbrechen durchführen.
  54.  
  55.  Ihr könnt das automatische Kombinieren ausschalten, indem ihr "Manual Combine"
  56.  auf "true" setzt und damit anmacht. Ist die Option an, müsst ihr folgenden
  57.  Script Call vor dem ersten "Show Choice" Befehl machen
  58.  
  59.     combine_choices
  60.    
  61.  um die folgenden zu kombinieren.
  62. #==============================================================================
  63. =end
  64. $imported = {} if $imported.nil?
  65. $imported["TH_LargeChoices"] = true
  66. #==============================================================================
  67. # ** Configuration
  68. #==============================================================================
  69. module TH
  70.   module Large_Choices
  71.    
  72.     # Macht ihr diese Option an (true), wird es nötig, das Kombinieren manuell
  73.     # durchzuführen.
  74.     Manual_Combine = false
  75.    
  76. #==============================================================================
  77. # ** Rest of the script
  78. #==============================================================================    
  79.     Code_Filter = [402, 403, 404]
  80.     Regex = /<large choices>/i
  81.   end
  82. end
  83.  
  84. class Game_Temp
  85.  
  86.   # temp solution to get this working
  87.   attr_accessor :branch_choice
  88.  
  89.   def branch_choice
  90.     @branch_choice || 5
  91.   end
  92. end
  93.  
  94. class Game_Interpreter
  95.  
  96.   #-----------------------------------------------------------------------------
  97.   # Clean up
  98.   #-----------------------------------------------------------------------------
  99.   alias :th_large_choices_clear :clear
  100.   def clear
  101.     th_large_choices_clear
  102.     @first_choice_cmd = nil
  103.     @choice_search = 0
  104.     @combine_choices = false
  105.   end
  106.  
  107.   #-----------------------------------------------------------------------------
  108.   # Prepare for more choices
  109.   #-----------------------------------------------------------------------------
  110.   alias :th_large_choices_setup_choices :setup_choices
  111.   def setup_choices(params)
  112.    
  113.     # Make a copy of our list so we don't modify the original
  114.     @list = Marshal.load(Marshal.dump(@list))
  115.    
  116.     # start with our original choices
  117.     th_large_choices_setup_choices(params)
  118.    
  119.     return if TH::Large_Choices::Manual_Combine && !@combine_choices
  120.    
  121.     # store our "first" choice in the sequence
  122.     @first_choice_cmd = @list[@index]
  123.    
  124.     # reset branch choice
  125.     $game_temp.branch_choice = @first_choice_cmd.parameters[1]
  126.    
  127.     # Start searching for more choices
  128.     @num_choices = $game_message.choices.size
  129.     @choice_search = @index + 1
  130.     search_more_choices
  131.   end
  132.  
  133.   def combine_choices
  134.     @combine_choices = true
  135.   end
  136.  
  137.   #-----------------------------------------------------------------------------
  138.   # New. Check whether the next command (after all branches) is another choice
  139.   # command. If so, merge it with the first choice command.
  140.   #-----------------------------------------------------------------------------
  141.   def search_more_choices
  142.     skip_choice_branches
  143.     next_cmd = @list[@choice_search]
  144.    
  145.     # Next command isn't a "show choice" so we're done
  146.     return if next_cmd.code != 102
  147.    
  148.     @choice_search += 1
  149.     # Otherwise, push the choices into the first choice command to merge
  150.     # the commands.
  151.     @first_choice_cmd.parameters[0].concat(next_cmd.parameters[0])
  152.    
  153.     # Update all cases to reflect merged choices
  154.     update_show_choices(next_cmd.parameters)
  155.     update_cancel_choice(next_cmd.parameters)
  156.     update_choice_numbers
  157.    
  158.     # delete the command to effectively merge the branches
  159.     @list.delete(next_cmd)
  160.    
  161.     # Now search for more
  162.     search_more_choices
  163.   end
  164.  
  165.   #-----------------------------------------------------------------------------
  166.   # New. Update the options for the first "show choice" command
  167.   #-----------------------------------------------------------------------------
  168.   def update_show_choices(params)
  169.     params[0].each {|s| $game_message.choices.push(s) }
  170.   end
  171.  
  172.   #-----------------------------------------------------------------------------
  173.   # New. If cancel specified, update it to reflect merged choice numbers
  174.   # The last one is taken if multiple cancel choices are specified
  175.   #-----------------------------------------------------------------------------
  176.   def update_cancel_choice(params)
  177.    
  178.     # disallow, just ignore
  179.     return if params[1] == 0    
  180.    
  181.     # branch on cancel
  182.     return update_branch_choice if params[1] == 5
  183.    
  184.     # num_choices is not one-based
  185.     cancel_choice = params[1] + (@num_choices)
  186.     # update cancel choice, as well as the first choice command
  187.     $game_message.choice_cancel_type = cancel_choice
  188.     @first_choice_cmd.parameters[1] = cancel_choice
  189.   end
  190.  
  191.   #-----------------------------------------------------------------------------
  192.   # New. Set the initial choice command to "branch cancel"
  193.   #-----------------------------------------------------------------------------
  194.   def update_branch_choice
  195.     branch_choice = $game_message.choices.size + 1
  196.     $game_message.choice_cancel_type = branch_choice
  197.     $game_temp.branch_choice = branch_choice
  198.     @first_choice_cmd.parameters[1] = branch_choice
  199.   end
  200.  
  201.   def command_403
  202.     command_skip if @branch[@indent] != $game_temp.branch_choice - 1
  203.   end
  204.  
  205.   #-----------------------------------------------------------------------------
  206.   # New. For each branch, update it to reflect the merged choice numbers.
  207.   #-----------------------------------------------------------------------------
  208.   def update_choice_numbers
  209.    
  210.     # Begin searching immediately after cmd 102 (show choice)
  211.     i = @choice_search
  212.    
  213.     # Rough search for "When" commands. The search must skip nested commands
  214.     while TH::Large_Choices::Code_Filter.include?(@list[i].code) || @list[i].indent != @indent
  215.       if @list[i].code == 402 && @list[i].indent == @indent
  216.         @list[i].parameters[0] = @num_choices
  217.         @num_choices += 1
  218.       end
  219.       i += 1
  220.     end
  221.   end
  222.  
  223.   #-----------------------------------------------------------------------------
  224.   # New. Returns the next command after our choice branches
  225.   #-----------------------------------------------------------------------------
  226.   def skip_choice_branches
  227.     # start search at the next command
  228.     # skip all choice branch-related commands and any branches
  229.     while TH::Large_Choices::Code_Filter.include?(@list[@choice_search].code) || @list[@choice_search].indent != @indent
  230.       @choice_search += 1
  231.     end
  232.     return @choice_search
  233.   end
  234. end
Advertisement
Add Comment
Please, Sign In to add comment