home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Lib / GameText.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-10-27  |  5.4 KB  |  144 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import Scorer
  5. import Bladex
  6. import os
  7. import Interpolator
  8. import string
  9. Textos = { }
  10. MapList = { }
  11. ComboNames = {
  12.     'Knight_N': { },
  13.     'Barbarian_N': { },
  14.     'Amazon_N': { },
  15.     'Dwarf_N': { },
  16.     'Default': { } }
  17. FADE_TIME = 1.0
  18. current_language = None
  19.  
  20. def SetLanguage(lang):
  21.     global current_language
  22.     if lang != current_language:
  23.         current_language = lang
  24.         print 'Setting language', lang
  25.         l_path = '../../Data/Text/' + lang
  26.         if not os.path.exists(l_path):
  27.             return None
  28.         
  29.         files = os.listdir(l_path)
  30.         for i in files:
  31.             file = l_path + '/' + str(i)
  32.         
  33.     
  34.  
  35.  
  36. def MapDescriptor(map):
  37.     if MapList.has_key(string.upper(map)):
  38.         return MapList[string.upper(map)]
  39.     else:
  40.         return map
  41.  
  42.  
  43. class FadeText(Interpolator.LinearInt):
  44.     
  45.     def __init__(self, init_val, end_val):
  46.         Interpolator.LinearInt.__init__(self, init_val, end_val)
  47.         self.Interpolator = Interpolator.Interp('FadeText')
  48.         time = Bladex.GetTime()
  49.         self.Interpolator.AddAction(time, time + FADE_TIME, self)
  50.         self.end_val = end_val
  51.  
  52.     
  53.     def Execute(self, value):
  54.         ret = Interpolator.LinearInt.Execute(self, value)
  55.         Scorer.wGameText.SetAlpha(ret)
  56.  
  57.     
  58.     def EndExecute(self):
  59.         self.Interpolator.Kill()
  60.         Scorer.wGameText.SetAlpha(self.end_val)
  61.         if self.end_val == 0:
  62.             Scorer.wGameText.SetText('')
  63.         
  64.  
  65.  
  66.  
  67. def ClearText():
  68.     FadeText(1, 0)
  69.  
  70.  
  71. def AbortText():
  72.     Bladex.RemoveScheduledFunc('ClearText')
  73.     Bladex.RemoveScheduledFunc('NextText')
  74.     Scorer.wGameText.SetAlpha(0)
  75.     Scorer.wGameText.SetText('')
  76.  
  77.  
  78. def WriteTextAux(txt, duration, init_r, init_g, init_b, next_text):
  79.     Scorer.wGameText.SetColor(init_r, init_g, init_b)
  80.     Scorer.wGameText.SetText(txt)
  81.     Scorer.wFrame.RecalcLayout()
  82.     FadeText(0, 1)
  83.     now = Bladex.GetTime()
  84.     if next_text == []:
  85.         Bladex.AddScheduledFunc(now + duration, ClearText, (), 'ClearText')
  86.     else:
  87.         Bladex.AddScheduledFunc(now + duration, ClearText, (), 'ClearText')
  88.         Bladex.AddScheduledFunc(now + duration + FADE_TIME, WriteTextAux, (next_text[0], duration, init_r, init_g, init_b, next_text[1:]), 'NextText')
  89.  
  90.  
  91. def WriteText(txt_id):
  92.     
  93.     try:
  94.         _txt = Textos[txt_id]
  95.         txt = _txt[4]
  96.     except:
  97.         print "Error: can't print message", txt_id
  98.         return None
  99.  
  100.     nLines = string.count(txt, '\n') + 1
  101.     nParagraphs = nLines / 5 + 1
  102.     paragraphs = []
  103.     if nParagraphs > 1:
  104.         l = string.split(txt, '\n')
  105.         counter = 0
  106.         t_str = ''
  107.         for i in l:
  108.             t_str = t_str + i + '\n'
  109.             counter = counter + 1
  110.         
  111.         if t_str != '':
  112.             paragraphs.append(t_str)
  113.         
  114.         WriteTextAux(paragraphs[0], _txt[0], _txt[1], _txt[2], _txt[3], paragraphs[1:])
  115.     else:
  116.         WriteTextAux(txt, _txt[0], _txt[1], _txt[2], _txt[3], [])
  117.  
  118.  
  119. def ShowMessage(message = '', r = 255, g = 255, b = 255):
  120.     Scorer.wGameText.SetText(message)
  121.     Scorer.wGameText.SetAlpha(1.0)
  122.     Scorer.wGameText.SetColor(r, g, b)
  123.     Scorer.wFrame.RecalcLayout()
  124.  
  125.  
  126. def HideMessage():
  127.     ShowMessage()
  128.  
  129.  
  130. def GetComboName(EntityName, ComboId):
  131.     kindName = Bladex.GetEntity(EntityName).Kind
  132.     
  133.     try:
  134.         return ComboNames[kindName][ComboId]
  135.     except:
  136.         
  137.         try:
  138.             return ComboNames['Default'][ComboId]
  139.         except:
  140.             return None
  141.  
  142.  
  143.  
  144.