home *** CD-ROM | disk | FTP | other *** search
/ GameSpot.it / GameSpot Italia (2001).bin / demo / severancedemo / data1.cab / Program_Files / Lib / TutorialScorer.py < prev    next >
Encoding:
Text File  |  2000-10-13  |  6.5 KB  |  238 lines

  1. import BUIx
  2. import Scorer
  3. import ScorerWidgets
  4. import string
  5. import Bladex
  6. import GameText
  7. import BInput
  8.  
  9. WidgetName = "TutoriaMessage"
  10. LastText   = None
  11.  
  12. def ActivateTutorialScorer(FontFile = "../../Data/Mapa de letras.bmp"):
  13.     global wMultiText
  14.     wMultiText=BUIx.B_TextWidget(Scorer.wFrame,WidgetName,"\n\n\n\n\n",ScorerWidgets.font_server,FontFile)
  15.     wMultiText.SetAlpha(1)
  16.     wMultiText.SetColor(255,255,255)
  17.     wMultiText.SetSolid(1)
  18.     wMultiText.SetBackgroundAlpha(0.5)
  19.     wMultiText.SetBackgroundColor(0,0,0)
  20.  
  21. FlashCicles = 2
  22.  
  23.  
  24. def GetAction(ActionName):
  25.     IAction = BInput.GetInputManager().GetInputActions().Find(ActionName)
  26.     
  27.     for idx in range(IAction.nInputEvents()):
  28.         IEvent  = IAction.GetnInputEvent(idx)
  29.         if(IEvent.GetDevice()=="Keyboard" or IEvent.GetDevice()=="Mouse"):
  30.             return "["+IEvent.GetKey()+"]"
  31.     return "???"
  32.  
  33.  
  34. def ParseText(TextIdx):
  35.     txt = GameText.Textos[TextIdx]
  36.     res = []
  37.     for ln in txt:
  38.         start = 0
  39.         while 1:
  40.             start = string.find(ln,"%",start)
  41.             if start == -1: break
  42.             end = string.find(ln,"%",start+1)
  43.             if end   == -1: break
  44.             ln = string.replace(ln,ln[start:end+1],GetAction(ln[start+1:end]))
  45.         res.append(ln)
  46.     return res
  47.     
  48.  
  49. #
  50. ## LIFE AND LEVEL
  51. #######################
  52. def ShowUL(texto,fs=1):
  53.     global FlashCicles
  54.     global LastText
  55.     SPACES = 50
  56.     FlashCicles = fs
  57.     if LastText == texto:
  58.         return
  59.     LastText = texto
  60.     
  61.     texto = ParseText(texto)
  62.     Scorer.wFrame.RemoveWidget(WidgetName,0)
  63.     cad = "\n"
  64.     for t in texto:
  65.         cad = cad+string.rjust("",SPACES) +t+"  \n"
  66.     
  67.     wMultiText.SetText(cad+"  \n")
  68.     wMultiText.SetJustification(BUIx.B_TextWidget.B_TEXT_Left)
  69.     wMultiText.SetBackgroundAlpha(0.5)
  70.     wMultiText.SetBackgroundColor(0,0,0)
  71.     wMultiText.SetAlpha(0)
  72.     Scorer.wFrame.AddWidget(wMultiText,0.0,0,
  73.             BUIx.B_FrameWidget.B_FR_AbsoluteLeft,
  74.             BUIx.B_FrameWidget.B_FR_AbsoluteTop,
  75.             BUIx.B_FrameWidget.B_FR_Left,
  76.             BUIx.B_FrameWidget.B_FR_Top)
  77.     CiclicAppears(0)
  78.  
  79. #
  80. ## Center Down
  81. #######################
  82. def ShowBC(texto,fs=1):
  83.     global FlashCicles
  84.     SPACES = 50
  85.     FlashCicles = fs
  86.     global LastText
  87.  
  88.     if LastText == texto:
  89.         return
  90.     LastText = texto
  91.     
  92.     texto = ParseText(texto)
  93.     Scorer.wFrame.RemoveWidget(WidgetName,0)
  94.     cad = "\n"
  95.     for t in texto:
  96.         cad = cad+"  "+t+"  \n"
  97.     
  98.     wMultiText.SetText(cad)
  99.     wMultiText.SetJustification(BUIx.B_TextWidget.B_TEXT_HCenter)
  100.     wMultiText.SetBackgroundAlpha(0.5)
  101.     wMultiText.SetBackgroundColor(0,0,0)
  102.     wMultiText.SetAlpha(0)
  103.  
  104.     Scorer.wFrame.AddWidget(wMultiText,0.5,50,
  105.                 BUIx.B_FrameWidget.B_FR_HRelative,
  106.                 BUIx.B_FrameWidget.B_FR_HCenter,
  107.                 BUIx.B_FrameWidget.B_FR_AbsoluteBottom,
  108.                 BUIx.B_FrameWidget.B_FR_Bottom)
  109.     CiclicAppears(0)
  110.  
  111. #
  112. ## Enemy icons
  113. #######################
  114. def ShowUR(texto,fs=1):
  115.     global FlashCicles
  116.     SPACES = 30
  117.     FlashCicles = fs
  118.     global LastText
  119.  
  120.     if LastText == texto:
  121.         return
  122.     LastText = texto
  123.  
  124.     texto = ParseText(texto)
  125.     Scorer.wFrame.RemoveWidget(WidgetName,0)
  126.     cad = "\n"
  127.     for t in texto:
  128.         cad = cad+"  "+t+string.rjust("",SPACES)+"\n"
  129.     
  130.     wMultiText.SetText(cad+"  \n")
  131.     wMultiText.SetJustification(BUIx.B_TextWidget.B_TEXT_Left)
  132.     wMultiText.SetBackgroundAlpha(0.5)
  133.     wMultiText.SetBackgroundColor(0,0,0)
  134.     wMultiText.SetAlpha(0)
  135.     Scorer.wFrame.AddWidget(wMultiText,0.5,0,
  136.                 BUIx.B_FrameWidget.B_FR_AbsoluteRight,
  137.                 BUIx.B_FrameWidget.B_FR_Right,
  138.                 BUIx.B_FrameWidget.B_FR_AbsoluteTop,
  139.                 BUIx.B_FrameWidget.B_FR_Top)
  140.     CiclicAppears(0)
  141.  
  142. #
  143. ## Inventory
  144. #######################
  145. def ShowUC(texto,fs=1):
  146.     global FlashCicles
  147.     SPACES = 30
  148.     FlashCicles = fs
  149.     global LastText
  150.  
  151.     if LastText == texto:
  152.         return
  153.     LastText = texto
  154.  
  155.     texto = ParseText(texto)
  156.     Scorer.wFrame.RemoveWidget(WidgetName,0)
  157.     cad = "\n"
  158.     for t in texto:
  159.         cad = cad+"  "+t+"  \n"
  160.     
  161.     wMultiText.SetText(cad)
  162.     wMultiText.SetJustification(BUIx.B_TextWidget.B_TEXT_HCenter)
  163.     wMultiText.SetBackgroundAlpha(0.5)
  164.     wMultiText.SetBackgroundColor(0,0,0)
  165.     wMultiText.SetAlpha(0)
  166.     Scorer.wFrame.AddWidget(wMultiText,0.5,70,
  167.                 BUIx.B_FrameWidget.B_FR_HRelative,
  168.                 BUIx.B_FrameWidget.B_FR_HCenter,
  169.                 BUIx.B_FrameWidget.B_FR_AbsoluteTop,
  170.                 BUIx.B_FrameWidget.B_FR_Top)
  171.     CiclicAppears(0)
  172.     
  173.     
  174.  
  175. def CiclicAppears(id):
  176.     global FlashCicles
  177.     if(id <= 1.0):
  178.         wMultiText.SetAlpha(id)
  179.     elif(id <= FlashCicles*2+1.0):
  180.         c = (id -int(id))
  181.         if int(id)%2==0:
  182.             c = 1.0-c
  183.         c = c*64
  184.         wMultiText.SetBackgroundColor(c,c,c)
  185.     else:
  186.         wMultiText.SetBackgroundColor(0,0,0)
  187.         wMultiText.SetBackgroundAlpha(0.5)
  188.         return
  189.     Bladex.AddScheduledFunc(Bladex.GetTime()+0.01,CiclicAppears,(id+0.08,))
  190.  
  191. def SimpleDisappears(id):
  192.     global LastText
  193.     LastText = ""
  194.  
  195.     if(id <= 1.0):
  196.         wMultiText.SetAlpha(1-id)
  197.         Bladex.AddScheduledFunc(Bladex.GetTime()+0.01,SimpleDisappears,(id+0.02,))
  198.     else:
  199.         Scorer.wFrame.RemoveWidget(WidgetName,0)
  200.     
  201. # "Select Enemy"
  202. """
  203.  
  204. GameText.Textos["Demo1"] = ["Four playable characters with individual skills.",
  205.                             "","",
  206.                             "An advanced combat system enabling characters to fight",
  207.                             "with weapons, surronding objects and even severed limbs.",
  208.                             "","",
  209.                             "A compelling mixture of fighting and adventuring.",
  210.                             "","",
  211.                             "A huge variety of awesome, intelligent monsters.",
  212.                             "","",
  213.                             "Thrilling multi-player arena combat.",
  214.                            ]
  215.  
  216. GameText.Textos["Demo2"] = ["An ultra-powerfull 3D engine rendering superb",
  217.                             "animation and stunning environments.",
  218.                             "","",
  219.                             "An incredible physic system allowing objects to be thrown, ",
  220.                             "knocked and bounced off walls.",
  221.                             "","",
  222.                             "Destructible Objects which can be burnt or hacked to pieces.",
  223.                             "","",
  224.                             "Unique real-time shadow casting, flickering lights and flames.",
  225.                             "","",
  226.                             "Realistic reflecting and transparent surfaces.",
  227.                            ]
  228. TutorialScorer.wMultiText.SetColor(255,0,0)
  229. """
  230. # TutorialScorer.ActivateTutorialScorer("../../Data/Letras menu med.bmp")
  231. # TutorialScorer.ShowBC("enemigos2",2)
  232. # TutorialScorer.ShowUL("enemigos2",2)
  233. # TutorialScorer.ShowUR("enemigos2")
  234. # TutorialScorer.ShowUC("Demo1",0)
  235. # TutorialScorer.ShowUC("Demo2",0)
  236. # TutorialScorer.SimpleDisappears(0)
  237.