Guest User

Traduttore Albhed ~ Correzione

a guest
Jul 17th, 2014
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.14 KB | None | 0 0
  1. =begin
  2. Albhed Translator
  3. by Fomar0153
  4. Version 1.1
  5. ----------------------
  6. Notes
  7. ----------------------
  8. Adds an Albhed style language to your game.
  9. ----------------------
  10. Instructions
  11. ----------------------
  12. Follow the instructions in the Albhed module
  13. turn your chosen switch on to have people speak
  14. Albhed.
  15. ----------------------
  16. Change Log
  17. ----------------------
  18. 1.0 -> 1.1 Added the ability to not translate sections
  19.            of a message. Use { and } to keep part of the message untranslated.
  20.            Added the ability to have the translated text appear in another
  21.            colour.
  22. ----------------------
  23. Known bugs
  24. ----------------------
  25. None
  26. =end
  27. module Albhed
  28.  
  29.   # Id of the switch to translate the text to Albhed
  30.   ALBHED_SWITCH = 5
  31.   ALBHED_COLOR = 14 # Colore per le lettere Albhed
  32.   ALBHED_TRANSLATED_COLOR = 0 # Colore per le lettere TRADOTTE
  33.  
  34.   ALBHED_CHARS = {}
  35.   # ALBHED_CHARS['letter'] = ['replacementletter', itemid to translate]
  36.     ALBHED_CHARS['a'] = ['y', 33]
  37.     ALBHED_CHARS['b'] = ['p', 34]
  38.     ALBHED_CHARS['c'] = ['l', 35]
  39.     ALBHED_CHARS['d'] = ['t', 36]
  40.     ALBHED_CHARS['e'] = ['a', 37]
  41.     ALBHED_CHARS['f'] = ['v', 38]
  42.     ALBHED_CHARS['g'] = ['k', 39]
  43.     ALBHED_CHARS['h'] = ['r', 40]
  44.     ALBHED_CHARS['i'] = ['e', 41]
  45.     ALBHED_CHARS['j'] = ['z', 42]
  46.     ALBHED_CHARS['k'] = ['g', 43]
  47.     ALBHED_CHARS['l'] = ['m', 44]
  48.     ALBHED_CHARS['m'] = ['s', 45]
  49.     ALBHED_CHARS['n'] = ['h', 46]
  50.     ALBHED_CHARS['o'] = ['u', 47]
  51.     ALBHED_CHARS['p'] = ['b', 48]
  52.     ALBHED_CHARS['q'] = ['x', 49]
  53.     ALBHED_CHARS['r'] = ['n', 50]
  54.     ALBHED_CHARS['s'] = ['c', 51]
  55.     ALBHED_CHARS['t'] = ['d', 52]
  56.     ALBHED_CHARS['u'] = ['i', 53]
  57.     ALBHED_CHARS['v'] = ['j', 54]
  58.     ALBHED_CHARS['w'] = ['f', 55]
  59.     ALBHED_CHARS['x'] = ['q', 56]
  60.     ALBHED_CHARS['y'] = ['o', 57]
  61.     ALBHED_CHARS['z'] = ['w', 58]
  62.    
  63.   def self.translate(c)
  64.     return c, false if ALBHED_CHARS[c.downcase].nil?
  65.     return c, true if $game_party.has_item?($data_items[ALBHED_CHARS[c.downcase][1]])
  66.     return ALBHED_CHARS[c.downcase][0].downcase, false if c.downcase!.nil?
  67.     return ALBHED_CHARS[c.downcase][0].upcase, false
  68.   end
  69.  
  70. end
  71.  
  72. class Window_Base < Window
  73.   #--------------------------------------------------------------------------
  74.   # ● 通常文字の処理
  75.   #--------------------------------------------------------------------------
  76.   alias albhed_process_normal_character process_normal_character
  77.   def process_normal_character(c, pos)
  78.     if @trans.nil?
  79.       @trans = true
  80.     end
  81.     return albhed_process_normal_character(c, pos) unless $game_switches[Albhed::ALBHED_SWITCH]
  82.     if c == "{"
  83.       @trans = false
  84.       return
  85.     end
  86.     if c == "}"
  87.       @trans = true
  88.       return
  89.     end
  90.     c, translated = Albhed.translate(c) if @trans
  91.     if translated
  92.       change_color(text_color(Albhed::ALBHED_TRANSLATED_COLOR)) if @trans
  93.     else
  94.       change_color(text_color(Albhed::ALBHED_COLOR)) if @trans
  95.     end
  96.     text_width = text_size(c).width
  97.     draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c)
  98.     change_color(normal_color)
  99.     pos[:x] += text_width
  100.   end
  101. end
Add Comment
Please, Sign In to add comment