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.py < prev    next >
Encoding:
Text File  |  2000-11-16  |  8.5 KB  |  315 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. wTraveBookBmp1 = None
  12. wTraveBookBmp2 = None
  13.  
  14. FadeTutorialScorer = 0
  15.  
  16. def LoopFadeTutorialScorer(FadeIdx):
  17.     global FadeTutorialScorer
  18.     global wTraveBookBmp1
  19.     
  20.     if FadeTutorialScorer:
  21.         if FadeIdx>0:
  22.             if FadeIdx>=1:
  23.                 wTraveBookBmp1.SetAlpha(FadeIdx-1)
  24.             else:
  25.                 wTraveBookBmp1.SetAlpha(0)
  26.         else:
  27.             if FadeIdx<=-1:
  28.                 wTraveBookBmp1.SetAlpha(1)
  29.             else:
  30.                 wTraveBookBmp1.SetAlpha(-FadeIdx)
  31.     
  32.         if FadeIdx<=-2.0:
  33.             Bladex.AddScheduledFunc(Bladex.GetTime()+0.01,LoopFadeTutorialScorer,(2,))
  34.         else:
  35.             Bladex.AddScheduledFunc(Bladex.GetTime()+0.01,LoopFadeTutorialScorer,(FadeIdx-0.01,))
  36.     else:
  37.         wTraveBookBmp1.SetVisible(0)
  38.         wTraveBookBmp2.SetVisible(0)
  39.         Scorer.TBookSword.SetVisible(0)
  40.  
  41.  
  42. def LoadTBSamples():
  43.     global wTraveBookBmp1
  44.     global wTraveBookBmp2
  45.     global FadeTutorialScorer
  46.  
  47.     if not wTraveBookBmp1:
  48.         wTraveBookBmp1 = BUIx.B_BitmapWidget(Scorer.wFrame,"TravelZero",256,192,"TravelZero","../../Data/tb_0.bmp")
  49.         wTraveBookBmp1.SetColor(255,255,255)
  50.         wTraveBookBmp1.SetAlpha(1.0)
  51.         Scorer.wFrame.AddWidget(wTraveBookBmp1,0.5,0.5,
  52.                     BUIx.B_Widget.B_FR_HRelative, BUIx.B_Widget.B_FR_HCenter,
  53.                     BUIx.B_Widget.B_FR_VRelative, BUIx.B_Widget.B_FR_VCenter
  54.                     )
  55.         wTraveBookBmp1.SetAutoScale(1)
  56.  
  57.     if not wTraveBookBmp2:
  58.         wTraveBookBmp2 = BUIx.B_BitmapWidget(Scorer.wFrame,"TravelNone",256,192,"TravelNone","../../Data/tb_1.bmp")
  59.         wTraveBookBmp2.SetColor(255,255,255)
  60.         wTraveBookBmp2.SetAlpha(1.0)
  61.         Scorer.wFrame.AddWidget(
  62.                     wTraveBookBmp2,0.5,0.5,
  63.                     BUIx.B_Widget.B_FR_HRelative, BUIx.B_Widget.B_FR_HCenter,
  64.                     BUIx.B_Widget.B_FR_VRelative, BUIx.B_Widget.B_FR_VCenter
  65.                     )
  66.         wTraveBookBmp2.SetAutoScale(1)
  67.         
  68.     wTraveBookBmp1.SetVisible(1)
  69.     wTraveBookBmp2.SetVisible(1)
  70.     
  71.     FadeTutorialScorer = 1
  72.     LoopFadeTutorialScorer(2)
  73.  
  74. def ActivateTutorialScorer(FontFile = "../../Data/Mapa de letras.bmp"):
  75.     global wMultiText
  76.     
  77.     
  78.     wMultiText=BUIx.B_TextWidget(Scorer.wFrame,WidgetName,"\n\n\n\n\n",ScorerWidgets.font_server,FontFile)
  79.     wMultiText.SetAlpha(1)
  80.     wMultiText.SetColor(255,255,255)
  81.     wMultiText.SetSolid(1)
  82.     wMultiText.SetBackgroundAlpha(0.5)
  83.     wMultiText.SetBackgroundColor(0,0,0)
  84.     wMultiText.SetAutoScale(1)
  85.  
  86. FlashCicles = 2
  87.  
  88.  
  89. def GetAction(ActionName):
  90.     IAction = BInput.GetInputManager().GetInputActions().Find(ActionName)
  91.     
  92.     for idx in range(IAction.nInputEvents()):
  93.         IEvent  = IAction.GetnInputEvent(idx)
  94.         if(IEvent.GetDevice()=="Keyboard" or IEvent.GetDevice()=="Mouse"):
  95.             return "["+IEvent.GetKey()+"]"
  96.     return "???"
  97.  
  98.  
  99. def ParseText(TextIdx):
  100.     txt = GameText.Textos[TextIdx]
  101.     res = []
  102.     for ln in txt:
  103.         start = 0
  104.         while 1:
  105.             start = string.find(ln,"%",start)
  106.             if start == -1: break
  107.             end = string.find(ln,"%",start+1)
  108.             if end   == -1: break
  109.             ln = string.replace(ln,ln[start:end+1],GetAction(ln[start+1:end]))
  110.         res.append(ln)
  111.     return res
  112.     
  113.  
  114. #
  115. ## LIFE AND LEVEL
  116. #######################
  117. def ShowUL(texto,fs=1):
  118.     global FlashCicles
  119.     global LastText
  120.     SPACES = 50
  121.     FlashCicles = fs
  122.     if LastText == texto:
  123.         return
  124.     LastText = texto
  125.     
  126.     texto = ParseText(texto)
  127.     Scorer.wFrame.RemoveWidget(WidgetName,0)
  128.     cad = "\n"
  129.     for t in texto:
  130.         cad = cad+string.rjust("",SPACES) +t+"  \n"
  131.     
  132.     wMultiText.SetText(cad+"  \n")
  133.     wMultiText.SetJustification(BUIx.B_TextWidget.B_TEXT_Left)
  134.     wMultiText.SetBackgroundAlpha(0.5)
  135.     wMultiText.SetBackgroundColor(0,0,0)
  136.     wMultiText.SetAlpha(0)
  137.     Scorer.wFrame.AddWidget(wMultiText,0.0,0,
  138.             BUIx.B_FrameWidget.B_FR_AbsoluteLeft,
  139.             BUIx.B_FrameWidget.B_FR_AbsoluteTop,
  140.             BUIx.B_FrameWidget.B_FR_Left,
  141.             BUIx.B_FrameWidget.B_FR_Top)
  142.     CiclicAppears(0)
  143.     global FadeTutorialScorer
  144.     FadeTutorialScorer = 0
  145.  
  146.  
  147. #
  148. ## Center Down
  149. #######################
  150. def ShowBC(texto,fs=1):
  151.     global FlashCicles
  152.     SPACES = 50
  153.     FlashCicles = fs
  154.     global LastText
  155.  
  156.     if LastText == texto:
  157.         return
  158.     LastText = texto
  159.     
  160.     texto = ParseText(texto)
  161.     Scorer.wFrame.RemoveWidget(WidgetName,0)
  162.     cad = "\n"
  163.     for t in texto:
  164.         cad = cad+"  "+t+"  \n"
  165.     
  166.     wMultiText.SetText(cad)
  167.     wMultiText.SetJustification(BUIx.B_TextWidget.B_TEXT_HCenter)
  168.     wMultiText.SetBackgroundAlpha(0.5)
  169.     wMultiText.SetBackgroundColor(0,0,0)
  170.     wMultiText.SetAlpha(0)
  171.  
  172.     Scorer.wFrame.AddWidget(wMultiText,0.5,50,
  173.                 BUIx.B_FrameWidget.B_FR_HRelative,
  174.                 BUIx.B_FrameWidget.B_FR_HCenter,
  175.                 BUIx.B_FrameWidget.B_FR_AbsoluteBottom,
  176.                 BUIx.B_FrameWidget.B_FR_Bottom)
  177.     CiclicAppears(0)
  178.     global FadeTutorialScorer
  179.     FadeTutorialScorer = 0
  180.  
  181.  
  182. #
  183. ## Enemy icons
  184. #######################
  185. def ShowUR(texto,fs=1):
  186.     global FlashCicles
  187.     SPACES = 30
  188.     FlashCicles = fs
  189.     global LastText
  190.  
  191.     if LastText == texto:
  192.         return
  193.     LastText = texto
  194.  
  195.     texto = ParseText(texto)
  196.     Scorer.wFrame.RemoveWidget(WidgetName,0)
  197.     cad = "\n"
  198.     for t in texto:
  199.         cad = cad+"  "+t+string.rjust("",SPACES)+"\n"
  200.     
  201.     wMultiText.SetText(cad+"  \n")
  202.     wMultiText.SetJustification(BUIx.B_TextWidget.B_TEXT_Left)
  203.     wMultiText.SetBackgroundAlpha(0.5)
  204.     wMultiText.SetBackgroundColor(0,0,0)
  205.     wMultiText.SetAlpha(0)
  206.     Scorer.wFrame.AddWidget(wMultiText,0.5,0,
  207.                 BUIx.B_FrameWidget.B_FR_AbsoluteRight,
  208.                 BUIx.B_FrameWidget.B_FR_Right,
  209.                 BUIx.B_FrameWidget.B_FR_AbsoluteTop,
  210.                 BUIx.B_FrameWidget.B_FR_Top)
  211.     CiclicAppears(0)
  212.     global FadeTutorialScorer
  213.     FadeTutorialScorer = 0
  214.  
  215.  
  216. #
  217. ## Inventory
  218. #######################
  219. def ShowUC(texto,fs=1):
  220.     global FlashCicles
  221.     SPACES = 30
  222.     FlashCicles = fs
  223.     global LastText
  224.  
  225.     if LastText == texto:
  226.         return
  227.     LastText = texto
  228.  
  229.     texto = ParseText(texto)
  230.     Scorer.wFrame.RemoveWidget(WidgetName,0)
  231.     cad = "\n"
  232.     for t in texto:
  233.         cad = cad+"  "+t+"  \n"
  234.     
  235.     wMultiText.SetText(cad)
  236.     wMultiText.SetJustification(BUIx.B_TextWidget.B_TEXT_HCenter)
  237.     wMultiText.SetBackgroundAlpha(0.5)
  238.     wMultiText.SetBackgroundColor(0,0,0)
  239.     wMultiText.SetAlpha(0)
  240.     Scorer.wFrame.AddWidget(wMultiText,0.5,70,
  241.                 BUIx.B_FrameWidget.B_FR_HRelative,
  242.                 BUIx.B_FrameWidget.B_FR_HCenter,
  243.                 BUIx.B_FrameWidget.B_FR_AbsoluteTop,
  244.                 BUIx.B_FrameWidget.B_FR_Top)
  245.     CiclicAppears(0)
  246.     global FadeTutorialScorer
  247.     FadeTutorialScorer = 0
  248.  
  249.     
  250.     
  251.  
  252. def CiclicAppears(id):
  253.     global FlashCicles
  254.     if(id <= 1.0):
  255.         wMultiText.SetAlpha(id)
  256.     elif(id <= FlashCicles*2+1.0):
  257.         c = (id -int(id))
  258.         if int(id)%2==0:
  259.             c = 1.0-c
  260.         c = c*64
  261.         wMultiText.SetBackgroundColor(c,c,c)
  262.     else:
  263.         wMultiText.SetBackgroundColor(0,0,0)
  264.         wMultiText.SetBackgroundAlpha(0.5)
  265.         return
  266.     Bladex.AddScheduledFunc(Bladex.GetTime()+0.01,CiclicAppears,(id+0.08,))
  267.  
  268. def SimpleDisappears(id):
  269.     global LastText
  270.     LastText = ""
  271.  
  272.     if(id <= 1.0):
  273.         wMultiText.SetAlpha(1-id)
  274.         Bladex.AddScheduledFunc(Bladex.GetTime()+0.01,SimpleDisappears,(id+0.02,))
  275.     else:
  276.         Scorer.wFrame.RemoveWidget(WidgetName,0)
  277.     
  278. # "Select Enemy"
  279. """
  280.  
  281. GameText.Textos["Demo1"] = ["Four playable characters with individual skills.",
  282.                             "","",
  283.                             "An advanced combat system enabling characters to fight",
  284.                             "with weapons, surronding objects and even severed limbs.",
  285.                             "","",
  286.                             "A compelling mixture of fighting and adventuring.",
  287.                             "","",
  288.                             "A huge variety of awesome, intelligent monsters.",
  289.                             "","",
  290.                             "Thrilling multi-player arena combat.",
  291.                            ]
  292.  
  293. GameText.Textos["Demo2"] = ["An ultra-powerfull 3D engine rendering superb",
  294.                             "animation and stunning environments.",
  295.                             "","",
  296.                             "An incredible physic system allowing objects to be thrown, ",
  297.                             "knocked and bounced off walls.",
  298.                             "","",
  299.                             "Destructible Objects which can be burnt or hacked to pieces.",
  300.                             "","",
  301.                             "Unique real-time shadow casting, flickering lights and flames.",
  302.                             "","",
  303.                             "Realistic reflecting and transparent surfaces.",
  304.                            ]
  305. TutorialScorer.wMultiText.SetColor(255,0,0)
  306. """
  307. # TutorialScorer.ActivateTutorialScorer("../../Data/Letras menu med.bmp")
  308. # TutorialScorer.ShowBC("enemigos2",2)
  309. # TutorialScorer.ShowUL("enemigos2",2)
  310. # TutorialScorer.ShowUR("enemigos2")
  311. # TutorialScorer.ShowUC("Demo1",0)
  312. # TutorialScorer.ShowUC("Demo2",0)
  313. # TutorialScorer.SimpleDisappears(0)
  314.