home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2001 May / maximum-cd-2001-05.iso / Blade of Darkness / data1.cab / Program_Executable_Files / Lib / TutorialScorer.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-11-16  |  9.0 KB  |  219 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import BUIx
  5. import Scorer
  6. import ScorerWidgets
  7. import string
  8. import Bladex
  9. import GameText
  10. import BInput
  11. WidgetName = 'TutoriaMessage'
  12. LastText = None
  13. wTraveBookBmp1 = None
  14. wTraveBookBmp2 = None
  15. FadeTutorialScorer = 0
  16.  
  17. def LoopFadeTutorialScorer(FadeIdx):
  18.     if FadeTutorialScorer:
  19.         if FadeIdx > 0:
  20.             if FadeIdx >= 1:
  21.                 wTraveBookBmp1.SetAlpha(FadeIdx - 1)
  22.             else:
  23.                 wTraveBookBmp1.SetAlpha(0)
  24.         elif FadeIdx <= -1:
  25.             wTraveBookBmp1.SetAlpha(1)
  26.         else:
  27.             wTraveBookBmp1.SetAlpha(-FadeIdx)
  28.         if FadeIdx <= -2.0:
  29.             Bladex.AddScheduledFunc(Bladex.GetTime() + 0.01, LoopFadeTutorialScorer, (2,))
  30.         else:
  31.             Bladex.AddScheduledFunc(Bladex.GetTime() + 0.01, LoopFadeTutorialScorer, (FadeIdx - 0.01,))
  32.     else:
  33.         wTraveBookBmp1.SetVisible(0)
  34.         wTraveBookBmp2.SetVisible(0)
  35.         Scorer.TBookSword.SetVisible(0)
  36.  
  37.  
  38. def LoadTBSamples():
  39.     global wTraveBookBmp1, wTraveBookBmp2, FadeTutorialScorer
  40.     if not wTraveBookBmp1:
  41.         wTraveBookBmp1 = BUIx.B_BitmapWidget(Scorer.wFrame, 'TravelZero', 256, 192, 'TravelZero', '../../Data/tb_0.bmp')
  42.         wTraveBookBmp1.SetColor(255, 255, 255)
  43.         wTraveBookBmp1.SetAlpha(1.0)
  44.         Scorer.wFrame.AddWidget(wTraveBookBmp1, 0.5, 0.5, BUIx.B_Widget.B_FR_HRelative, BUIx.B_Widget.B_FR_HCenter, BUIx.B_Widget.B_FR_VRelative, BUIx.B_Widget.B_FR_VCenter)
  45.         wTraveBookBmp1.SetAutoScale(1)
  46.     
  47.     if not wTraveBookBmp2:
  48.         wTraveBookBmp2 = BUIx.B_BitmapWidget(Scorer.wFrame, 'TravelNone', 256, 192, 'TravelNone', '../../Data/tb_1.bmp')
  49.         wTraveBookBmp2.SetColor(255, 255, 255)
  50.         wTraveBookBmp2.SetAlpha(1.0)
  51.         Scorer.wFrame.AddWidget(wTraveBookBmp2, 0.5, 0.5, BUIx.B_Widget.B_FR_HRelative, BUIx.B_Widget.B_FR_HCenter, BUIx.B_Widget.B_FR_VRelative, BUIx.B_Widget.B_FR_VCenter)
  52.         wTraveBookBmp2.SetAutoScale(1)
  53.     
  54.     wTraveBookBmp1.SetVisible(1)
  55.     wTraveBookBmp2.SetVisible(1)
  56.     FadeTutorialScorer = 1
  57.     LoopFadeTutorialScorer(2)
  58.  
  59.  
  60. def ActivateTutorialScorer(FontFile = '../../Data/Mapa de letras.bmp'):
  61.     global wMultiText
  62.     wMultiText = BUIx.B_TextWidget(Scorer.wFrame, WidgetName, '\n\n\n\n\n', ScorerWidgets.font_server, FontFile)
  63.     wMultiText.SetAlpha(1)
  64.     wMultiText.SetColor(255, 255, 255)
  65.     wMultiText.SetSolid(1)
  66.     wMultiText.SetBackgroundAlpha(0.5)
  67.     wMultiText.SetBackgroundColor(0, 0, 0)
  68.     wMultiText.SetAutoScale(1)
  69.  
  70. FlashCicles = 2
  71.  
  72. def GetAction(ActionName):
  73.     IAction = BInput.GetInputManager().GetInputActions().Find(ActionName)
  74.     for idx in range(IAction.nInputEvents()):
  75.         IEvent = IAction.GetnInputEvent(idx)
  76.     
  77.     return '???'
  78.  
  79.  
  80. def ParseText(TextIdx):
  81.     txt = GameText.Textos[TextIdx]
  82.     res = []
  83.     for ln in txt:
  84.         start = 0
  85.         while 1:
  86.             start = string.find(ln, '%', start)
  87.             end = string.find(ln, '%', start + 1)
  88.             if end == -1:
  89.                 break
  90.             
  91.             ln = string.replace(ln, ln[start:end + 1], GetAction(ln[start + 1:end]))
  92.         res.append(ln)
  93.     
  94.     return res
  95.  
  96.  
  97. def ShowUL(texto, fs = 1):
  98.     global FlashCicles, LastText, FadeTutorialScorer
  99.     SPACES = 50
  100.     FlashCicles = fs
  101.     if LastText == texto:
  102.         return None
  103.     
  104.     LastText = texto
  105.     texto = ParseText(texto)
  106.     Scorer.wFrame.RemoveWidget(WidgetName, 0)
  107.     cad = '\n'
  108.     for t in texto:
  109.         cad = cad + string.rjust('', SPACES) + t + '  \n'
  110.     
  111.     wMultiText.SetText(cad + '  \n')
  112.     wMultiText.SetJustification(BUIx.B_TextWidget.B_TEXT_Left)
  113.     wMultiText.SetBackgroundAlpha(0.5)
  114.     wMultiText.SetBackgroundColor(0, 0, 0)
  115.     wMultiText.SetAlpha(0)
  116.     Scorer.wFrame.AddWidget(wMultiText, 0.0, 0, BUIx.B_FrameWidget.B_FR_AbsoluteLeft, BUIx.B_FrameWidget.B_FR_AbsoluteTop, BUIx.B_FrameWidget.B_FR_Left, BUIx.B_FrameWidget.B_FR_Top)
  117.     CiclicAppears(0)
  118.     FadeTutorialScorer = 0
  119.  
  120.  
  121. def ShowBC(texto, fs = 1):
  122.     global FlashCicles, LastText, FadeTutorialScorer
  123.     SPACES = 50
  124.     FlashCicles = fs
  125.     if LastText == texto:
  126.         return None
  127.     
  128.     LastText = texto
  129.     texto = ParseText(texto)
  130.     Scorer.wFrame.RemoveWidget(WidgetName, 0)
  131.     cad = '\n'
  132.     for t in texto:
  133.         cad = cad + '  ' + t + '  \n'
  134.     
  135.     wMultiText.SetText(cad)
  136.     wMultiText.SetJustification(BUIx.B_TextWidget.B_TEXT_HCenter)
  137.     wMultiText.SetBackgroundAlpha(0.5)
  138.     wMultiText.SetBackgroundColor(0, 0, 0)
  139.     wMultiText.SetAlpha(0)
  140.     Scorer.wFrame.AddWidget(wMultiText, 0.5, 50, BUIx.B_FrameWidget.B_FR_HRelative, BUIx.B_FrameWidget.B_FR_HCenter, BUIx.B_FrameWidget.B_FR_AbsoluteBottom, BUIx.B_FrameWidget.B_FR_Bottom)
  141.     CiclicAppears(0)
  142.     FadeTutorialScorer = 0
  143.  
  144.  
  145. def ShowUR(texto, fs = 1):
  146.     global FlashCicles, LastText, FadeTutorialScorer
  147.     SPACES = 30
  148.     FlashCicles = fs
  149.     if LastText == texto:
  150.         return None
  151.     
  152.     LastText = texto
  153.     texto = ParseText(texto)
  154.     Scorer.wFrame.RemoveWidget(WidgetName, 0)
  155.     cad = '\n'
  156.     for t in texto:
  157.         cad = cad + '  ' + t + string.rjust('', SPACES) + '\n'
  158.     
  159.     wMultiText.SetText(cad + '  \n')
  160.     wMultiText.SetJustification(BUIx.B_TextWidget.B_TEXT_Left)
  161.     wMultiText.SetBackgroundAlpha(0.5)
  162.     wMultiText.SetBackgroundColor(0, 0, 0)
  163.     wMultiText.SetAlpha(0)
  164.     Scorer.wFrame.AddWidget(wMultiText, 0.5, 0, BUIx.B_FrameWidget.B_FR_AbsoluteRight, BUIx.B_FrameWidget.B_FR_Right, BUIx.B_FrameWidget.B_FR_AbsoluteTop, BUIx.B_FrameWidget.B_FR_Top)
  165.     CiclicAppears(0)
  166.     FadeTutorialScorer = 0
  167.  
  168.  
  169. def ShowUC(texto, fs = 1):
  170.     global FlashCicles, LastText, FadeTutorialScorer
  171.     SPACES = 30
  172.     FlashCicles = fs
  173.     if LastText == texto:
  174.         return None
  175.     
  176.     LastText = texto
  177.     texto = ParseText(texto)
  178.     Scorer.wFrame.RemoveWidget(WidgetName, 0)
  179.     cad = '\n'
  180.     for t in texto:
  181.         cad = cad + '  ' + t + '  \n'
  182.     
  183.     wMultiText.SetText(cad)
  184.     wMultiText.SetJustification(BUIx.B_TextWidget.B_TEXT_HCenter)
  185.     wMultiText.SetBackgroundAlpha(0.5)
  186.     wMultiText.SetBackgroundColor(0, 0, 0)
  187.     wMultiText.SetAlpha(0)
  188.     Scorer.wFrame.AddWidget(wMultiText, 0.5, 70, BUIx.B_FrameWidget.B_FR_HRelative, BUIx.B_FrameWidget.B_FR_HCenter, BUIx.B_FrameWidget.B_FR_AbsoluteTop, BUIx.B_FrameWidget.B_FR_Top)
  189.     CiclicAppears(0)
  190.     FadeTutorialScorer = 0
  191.  
  192.  
  193. def CiclicAppears(id):
  194.     if id <= 1.0:
  195.         wMultiText.SetAlpha(id)
  196.     elif id <= FlashCicles * 2 + 1.0:
  197.         c = id - int(id)
  198.         if int(id) % 2 == 0:
  199.             c = 1.0 - c
  200.         
  201.         c = c * 64
  202.         wMultiText.SetBackgroundColor(c, c, c)
  203.     else:
  204.         wMultiText.SetBackgroundColor(0, 0, 0)
  205.         wMultiText.SetBackgroundAlpha(0.5)
  206.         return None
  207.     Bladex.AddScheduledFunc(Bladex.GetTime() + 0.01, CiclicAppears, (id + 0.08,))
  208.  
  209.  
  210. def SimpleDisappears(id):
  211.     global LastText
  212.     LastText = ''
  213.     if id <= 1.0:
  214.         wMultiText.SetAlpha(1 - id)
  215.         Bladex.AddScheduledFunc(Bladex.GetTime() + 0.01, SimpleDisappears, (id + 0.02,))
  216.     else:
  217.         Scorer.wFrame.RemoveWidget(WidgetName, 0)
  218.  
  219.