home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Lib / TrvBookLib.py < prev    next >
Encoding:
Python Source  |  2000-10-27  |  4.3 KB  |  151 lines

  1.  
  2.  
  3.  
  4. import string
  5. # Para las pruebas fuera de Blade
  6. import sys
  7. sys.path.append("C:\\Blade\\Lib")
  8.  
  9.  
  10. import BHTMLLib
  11. import shutil
  12.  
  13.  
  14.  
  15. class B_TrvBMenu(BHTMLLib.B_HTMLDocBody):
  16.   def __init__(self,filename,title,depends_race=0,submenu_path="",background=None):
  17.     BHTMLLib.B_HTMLDocBody.__init__(self,filename,title)
  18.     self.Places=[]
  19.     self.BackGround=background
  20.     self.DependsOnRace=depends_race
  21.     self.SubMenuPath=submenu_path
  22.  
  23.  
  24.   def CreateHTML(self):
  25.     self.GenerateHeader()
  26.     self.GenerateBody(background=self.BackGround,watermark=1)
  27.  
  28.     for i in self.Places:
  29.       self.Paragraph(self._WriteHyperLink(i[0],i[1],"MainArea"),"CENTER")
  30.  
  31.     self.CloseBody()
  32.     self.CloseHTML()
  33.  
  34.  
  35.   def AddPlace(self,placename,filename):
  36.     for i in self.Places:
  37.       if i==i[0]:
  38.         return
  39.  
  40.     if self.DependsOnRace==0:
  41.       self.Places.append((placename,"C:/Blade/Data/TravelBook/"+
  42.                                     BHTMLLib.GetEnvValue("Language")+self.SubMenuPath+filename))
  43.     else:
  44.       self.Places.append((placename,"C:/Blade/Data/TravelBook/"+
  45.                                     BHTMLLib.GetEnvValue("Language")+self.SubMenuPath+
  46.                                     BHTMLLib.GetEnvValue("Character")+"/"+filename))
  47.  
  48.  
  49. class B_TrvBText(BHTMLLib.B_HTMLDocBody):
  50.   def __init__(self,filename="C:\\Blade\\Data\\TravelBook\\CreationText.html",title="Historia del reino",background=None):
  51.     BHTMLLib.B_HTMLDocBody.__init__(self,filename,title)
  52.     self.Places=[]
  53.     self.BackGround=background
  54.  
  55.   def CreateHTML(self):
  56.     self.GenerateHeader()
  57.     self.GenerateBody(background=self.BackGround,watermark=1)
  58.  
  59.     self.Paragraph(self._WriteHyperLink("Caracterφsticas personaje","C:/"),"CENTER")
  60.     self.CloseBody()
  61.     self.CloseHTML()
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68. class B_TrvBMain(BHTMLLib.B_HTMLDocFrames):
  69.   def __init__(self,filename,title,background,submenu_path,depends_race=0):
  70.     BHTMLLib.B_HTMLDocFrames.__init__(self,filename,title)
  71.     self.Places=[]
  72.     self.Background=background
  73.     self.DependsRace=depends_race
  74.     self.SubMenuPath=submenu_path
  75.  
  76.   def CreateHTML(self):
  77.     # Primero creo los frames para el tφtulo, principal y botones de navegaci≤n
  78.     self.GenerateHeader()
  79.     self.GenerateFrameSet("ROWS",["64","*","64"],0,0,0)
  80.     #self.GenerateFrameSet("ROWS",["%10","%80","%10"],0)
  81.  
  82.     idx=string.rfind(self.FileName,'.htm')
  83.     BasePath=self.FileName[:idx]
  84.  
  85.     idx=string.rfind(self.Background,'.bmp')
  86.     BaseBackground=self.Background[:idx]
  87.     
  88.     Title=BHTMLLib.B_HTMLDocBody(BasePath+"Titulo.html","Titulo")
  89.     Title.GenerateHeader()
  90.     Title.GenerateBody(scroll="no",background=BaseBackground+"_up.bmp")
  91.     Title.Paragraph(self.Title)
  92.     Title.CloseBody()
  93.     Title.CloseHTML()
  94.     Title.WriteHTMLFile()
  95.  
  96.     Foot=BHTMLLib.B_HTMLDocBody(BasePath+"Foot.html","Foot")
  97.     Foot.GenerateHeader()
  98.     Foot.GenerateBody(scroll="no",background=BaseBackground+"_down.bmp")
  99.     #Foot.Paragraph("Foot")
  100.     Foot.Paragraph(Foot._WriteHyperLink("Volver","C:/Blade/Data/TravelBook/TravelBook.html","_top"),"RIGHT")
  101.     Foot.CloseBody()
  102.     Foot.CloseHTML()
  103.     Foot.WriteHTMLFile()    
  104.  
  105.     Main=BHTMLLib.B_HTMLDocFrames(BasePath+"Main.html","Main")
  106.     Main.GenerateHeader()
  107.     Main.GenerateFrameSet("COLS",["*","128"],0,0,0)
  108.     #Main.GenerateFrameSet("COLS",["%80","%20"],0)
  109.  
  110.     # Creo el frame con el men·:
  111.     CreationMenu=B_TrvBMenu(BasePath+"Menu.html","Menu",self.DependsRace,self.SubMenuPath,background=BaseBackground+"_right.bmp")
  112.     for i in self.Places:
  113.       CreationMenu.AddPlace(i[0],i[1])
  114.     CreationMenu.CreateHTML()
  115.     CreationMenu.WriteHTMLFile()
  116.  
  117.     # Ahora creo las distintas pßginas:
  118.     for i in self.Places:
  119.       CreationElement=B_TrvBText(i[1],background=BaseBackground+"_left.bmp")
  120.       CreationElement.CreateHTML()
  121.       CreationElement.WriteHTMLFile()
  122.  
  123.     Main.Frame("c:/tmp/FileName.html","MainArea",frameborder="no",scrolling="no")
  124.     Main.Frame(CreationMenu)
  125.     Main.CloseFrameSet()
  126.     Main.CloseHTML()
  127.     Main.WriteHTMLFile()
  128.  
  129.     self.Frame(Title,frameborder="no",scrolling="no",)
  130.     self.Frame(Main,frameborder="no",scrolling="no")
  131.     self.Frame(Foot,frameborder="no",scrolling="no")
  132.  
  133.     self.CloseFrameSet()
  134.     self.CloseHTML()
  135.  
  136.   def AddPlace(self,place,filename):
  137.     self.Places.append((place,filename))
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.