Advertisement
TroyZ

TroyZ - Theo Dual Language Chooser

May 22nd, 2015
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.05 KB | None | 0 0
  1. # ==============================================================================
  2. # ▼▼▼▼▼▼              TroyZ - Theo Dual Language Chooser                  ▼▼▼▼▼▼
  3. # ==============================================================================
  4. # Script by : Agung Prasetyo(TroyZ)
  5. # Contact me by : - Email agung.endisnear.xyz@gmail.com
  6. #                 - Forum RPGMakerID, username TroyZ
  7. #                 - Forum RPGMakerWeb.com, username TroyZ
  8. #                 - Forum RPGMakerVXAce.net, username TroyZ
  9. #                 - Forum rmrk.net, username TroyZ
  10. # Engine : VXAce
  11. # Level : Easy
  12. # Version : 1.0
  13. # ------------------------------------------------------------------------------
  14. # Change Logs :
  15. # 23 May 2015 : Version 1.0 released
  16. # ------------------------------------------------------------------------------
  17. # How this work :
  18. # Addon for Theo Script, TheoAllen - Dual Language. Now you can switch language
  19. # at the very beginning of the game, right before the title screen popup. This
  20. # also work for his Dual Command and Dual Terms script (you can use it together
  21. # with this script).
  22. # ------------------------------------------------------------------------------
  23. # How to use :
  24. # Place it between material and main. Notice the right order of the script or
  25. # it won't work :
  26. #
  27. # Theo - Dual Language
  28. # Theo - Dual Command
  29. # Theo - Dual Terms
  30. # TroyZ - Theo Dual Language Chooser
  31. #
  32. # Also, if you use it together with Theo - Splash Screen, the script order will
  33. # be like this :
  34. #
  35. # Theo - Dual Language
  36. # Theo - Dual Command
  37. # Theo - Dual Terms
  38. # Theo - Splash Screen
  39. # TroyZ - Theo Dual Language Chooser
  40. # ------------------------------------------------------------------------------
  41. # Compatibility issues :
  42. # None yet. If you found some, let me know, and bug fixes will come out soon.
  43. # ------------------------------------------------------------------------------
  44. # Who to credit :
  45. # - Allah swt. : For the chance of living that he has given to me.
  46. # - Nabi Muhammad saw. : As a leader and messenger and prophet of Muslim.
  47. #                        I'm proud to be your follower. :)
  48. # - Theo Allen : It's his script, credit him.
  49. # - Agung Prasetyo(TroyZ) : Thats me, of course, the ones that made this script. :P
  50. # ------------------------------------------------------------------------------
  51. # License :
  52. # - Free Game : For this script, just credit those names above. For Theo's
  53. #               Script, follow his credit rules
  54. # - Commercial Game : Same as free game's license.
  55. # ------------------------------------------------------------------------------
  56. $imported = {} if $imported.nil?
  57. $imported[:TroyZ_TheoDualLanguageChooser] = true
  58. # ------------------------------------------------------------------------------
  59. # Configuration of scripts start here
  60. # ------------------------------------------------------------------------------
  61. module AGUNG
  62.   module DUAL_LANG_CHOOSER
  63.     DEFAULT_LANG = "English" # set to this language when the switch is OFF
  64.     SECOND_LANG = "Indonesia" # set to this language when this switch is ON
  65.     HELP_TEXT = "Pilih bahasa / Choose language" # description of language chooser
  66.   end
  67. # ------------------------------------------------------------------------------
  68. # End of Configuration
  69. # ------------------------------------------------------------------------------
  70.  
  71. # ------------------------------------------------------------------------------
  72. # There is nothing to config beyond this line
  73. # ------------------------------------------------------------------------------
  74.   @var = false
  75.  
  76.   def self.var=(var)
  77.     @var = var
  78.   end
  79.  
  80.   def self.check_var
  81.     return @var
  82.   end
  83.  
  84.   def self.set_dual_lang_switches
  85.     $game_switches[Theo::DualLang::Switch_ID] = true
  86.     $game_switches[Theo::Dual_Switch] = true if $imported[:Theo_DualCMD]
  87.     $game_switches[THEO::BASEITEM::DUAL_SWITCH] = true if $imported[:Theo_DualTerms]
  88.   end
  89.  
  90.   def self.set_title_lang
  91.     $game_switches      = Game_Switches.new
  92.     $game_switches[THEO::BASEITEM::DUAL_SWITCH] = true if $imported[:Theo_DualTerms]
  93.   end  
  94. end
  95.  
  96. module SceneManager
  97.   def self.first_scene_class
  98.     $BTEST ? Scene_Battle : Scene_Lang_Chooser
  99.   end
  100. end
  101.  
  102. module DataManager  
  103.   class << self
  104.     alias dual_setup_new_game setup_new_game
  105.   end
  106.  
  107.   def self.setup_new_game
  108.     dual_setup_new_game
  109.     AGUNG.set_dual_lang_switches if AGUNG.check_var
  110.   end
  111. end
  112.  
  113. class Window_DualLang < Window_Command
  114.   include AGUNG::DUAL_LANG_CHOOSER
  115.  
  116.   def initialize(x,y)
  117.     super(x, y)
  118.     self.openness = 0
  119.     open
  120.   end
  121.  
  122.   def window_width
  123.     return 160
  124.   end
  125.  
  126.   def make_command_list
  127.     add_command(DEFAULT_LANG, :default_lang)
  128.     add_command(SECOND_LANG, :second_lang)
  129.   end
  130. end
  131.  
  132. class Window_DualLang_Help < Window_Base
  133.   include AGUNG::DUAL_LANG_CHOOSER
  134.  
  135.   def initialize(x, y)
  136.     super(x, y, 300, fitting_height(1))
  137.     refresh
  138.   end
  139.  
  140.   def refresh
  141.     draw_text(5,0,contents.width,contents.height,HELP_TEXT)
  142.   end  
  143. end
  144.  
  145. class Scene_Lang_Chooser < Scene_Base
  146.   def start
  147.     super    
  148.     SceneManager.clear    
  149.     create_dual_lang_window
  150.     create_dual_lang_help
  151.   end
  152.  
  153.   def create_dual_lang_window
  154.     @command_window = Window_DualLang.new(190, 200)
  155.     @command_window.set_handler(:default_lang, method(:default_lang))
  156.     @command_window.set_handler(:second_lang, method(:second_lang))
  157.   end
  158.  
  159.   def create_dual_lang_help
  160.     @duallang_help_window = Window_DualLang_Help.new(130,0)
  161.   end
  162.  
  163.   def default_lang
  164.     close_command_window    
  165.     AGUNG.var = false
  166.     return SceneManager.goto(Splash_Screen) if $imported[:Theo_Splash]
  167.     return SceneManager.goto(Scene_Title)
  168.   end
  169.  
  170.   def second_lang
  171.     close_command_window
  172.     AGUNG.var = true
  173.     AGUNG.set_title_lang
  174.     return SceneManager.goto(Splash_Screen) if $imported[:Theo_Splash]
  175.     return SceneManager.goto(Scene_Title)
  176.   end
  177.  
  178.   def close_command_window
  179.     @command_window.close
  180.     update until @command_window.close?
  181.   end
  182.  
  183.   def terminate
  184.     @duallang_help_window.dispose
  185.   end  
  186. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement