def LoadReltoPages(): if haveUamPlugin: return #Read any updated pages ReadPageInfo() #Do tasks given from other Ages: The player collected a Relto page, enable it if AmInMyRelto(): tasksstr = uam._GetPlayerChronicle("UamTasks") tasks = _StringToList(tasksstr) numtasks = len(tasks) for task in tasks: #print "task to do: "+task if task.startswith("EnableReltoPage="): page = task[len("EnableReltoPage="):] #enable the page pages = _StringToDict(uam.GetAgeChronicle("UamReltoPages")) pages[ page] = "on" #whether it was unset or on or off or unattained, it is on now! uam.SetAgeChronicle("UamReltoPages", _DictToString(pages)) #remove from task list tasks.remove(task) if numtasks != len(tasks): #removed some, so save uam._SetPlayerChronicle("UamTasks", _ListToString(tasks)) #Load pages PagesToLoad = {} #set() #Sets don't exist in Python 2.2 :P ObjectsToHide = {} #set() #Sets don't exist in Python 2.2 :P print "xCustomReltoPages: Loading Uam pages..." chronstr = uam.GetAgeChronicle("UamReltoPages") #on, off, or unattained pages = _StringToDict(chronstr) #print "UamReltoPages: "+chronstr for pagename in pages: status = pages[pagename] if not pagename in ReltoPages: print "xCustomReltoPages: You collected a Relto page which is not installed: %s" % pagename elif status == "on": PagesToLoad[pagename] = None #we're using this dict as a set for hideitem in ReltoPages[pagename]["hide"]: ObjectsToHide[hideitem] = None #we're using this dict as a set #Turn into sorted lists PagesToLoad = PagesToLoad.keys() ObjectsToHide = ObjectsToHide.keys() PagesToLoad.sort() ObjectsToHide.sort() #Hide the objects for hideitem in ObjectsToHide: #print "Hiding obj: "+hideitem HideObject(hideitem) #Load the pages for pagename in PagesToLoad: #print "Loading page: "+pagename Plasma.PtPageInNode( "UamPage-" + pagename ) #doesn't throw an exception if page not present; simply doesn't load.
def TogglePage(pagenum): #Get page for this pagenum pagedict = FindPage(pagenum) if pagedict == None: return False pagename = pagedict["pagename"] #Get the current status of the pages import uam chronstr = uam.GetAgeChronicle("UamReltoPages") #on, off, or unattained pages = _UamUtils._StringToDict(chronstr) print "chronstr: " + chronstr status = pages.get( pagename, pagedict["default"]) #Get the status or use the default for this page. if status == "on": status = "off" elif status == "off": status = "on" else: raise "Unexpected page state" #save the new status pages[pagename] = status pagesstr = _UamUtils._DictToString(pages) uam.SetAgeChronicle("UamReltoPages", pagesstr) print "chronstr: " + pagesstr return True
def _ParseULMFile(old_method=xCustomReltoShelf.ParseULMFile): old_method( ) #Parses the ULMServerLinkBook.inf file and fills out xULM.ULMBooks and xULM.ULMData #ULMBooks looks like {"Link19":"Bookname",...} where Bookname could be the AgeFilename or just the tag used for the cover. #ULMData looks like {"Link19":[["AgeFilenameOrEmpty", "Desc ription","LinkInPoint","Optional Text","linkTypeWhichCanBeEmpty"], <<other pages>>]} #bookstr should look like "1=Aerie;2=EderRiltahInaltahv" #xLinkMgr.AvailableLinks looks like {"AgeFilename":["Age Name","dataserver","basic"],} #xLinkMgr.AvailableSpawnpoints looks like {"AgeFilename":{"LinkInPointDefault":"SpawnPointName",...},...} print "UamEvents3 ParseULMFile" import uam import xLinkMgr bookstr = uam.GetAgeChronicle( "UamBooks") #Could be "" if not set before. print bookstr if bookstr != "": #Stupid Python behavior where "".split() returns [""] :P books = bookstr.split(";") print "books=" + ` books ` xLinkMgr.ResetAvailableLinks( ) #move this here, so we only do it once :P for book in books: print "book=" + ` book ` parts = book.split("=") print "parts=" + ` parts ` booknum = int(parts[0]) agename = parts[1] #This isn't set yet, so we *could* call xLinkMgr.ResetAvailableLinks #xLinkMgr.ResetAvailableLinks() if agename == "none" or agename == "empty": #Let's empty the entry link = "Link" + str(booknum + 18) #xULM.ULMBooks.pop(link,None) #set the default to None, so that no exception is thrown if it's not in the dict #xULM.ULMData.pop(link,None) #set the default to None, so that no exception is thrown if it's not in the dict #xULM.ULMBooks[link] = None #xULM.ULMData[link] = [] if link in xCustomReltoShelf._Books: del xCustomReltoShelf._Books[link] elif agename == "default": pass #we'll just skip it then and the default will be used. elif _UamUtils._IsRestorationAge(agename): #desc = xLinkMgr._AvailableLinks[agename][0] desc = xLinkMgr._AvailableLinks[agename].displayName link = "Link" + str(booknum + 18) #xULM.ULMBooks[link] = agename #xULM.ULMData[link] = [[agename,desc,"LinkInPointDefault","",""]] #Should we grab a different LinkPoint or linktype? book = xCustomReltoShelf._Book(booknum) book.cover = agename book.addPage( xCustomReltoShelf._LinkPage(agename, "LinkInPointDefault")) xCustomReltoShelf._Books[link] = book else: print "Skipping " + agename
def UamOnKiCommand(command): print "UamModBookshelf.UamOnKiCommand: " + ` command ` if command.startswith("/"): parts = command.split() numparts = len(parts) if parts[0] == "/bookshelf": import Plasma import uam import _UamUtils vault = Plasma.ptVault() if not vault.inMyPersonalAge(): #_ki.IAddRTChat(None, "You can only use /bookshelf from within your own Relto.", 0) uam.PrintKiMessage( "You can only use /bookshelf from within your own Relto.") return True try: booknum = int(parts[1]) agename = parts[2] agename = _UamUtils.GetCorrectFilename(agename) except: #_ki.IAddRTChat(None, "Usage: e.g. to set the 3rd book to Galamay: /bookshelf 3 Galamay", 0) uam.PrintKiMessage( "Usage: e.g. to set the 3rd book to Galamay: /bookshelf 3 Galamay" ) return True if booknum < 1 or booknum > 18: #_ki.IAddRTChat(None, "The book number must be between 1 and 18.", 0) uam.PrintKiMessage("The book number must be between 1 and 18.") return True if not (_UamUtils._IsRestorationAge(agename) or agename == "default" or agename == "none" or agename == "empty"): #_ki.IAddRTChat(None, "The Age must be a fan Age.", 0) uam.PrintKiMessage("The Age must be a fan Age.") return True #add to list #import uam booksstr = uam.GetAgeChronicle("UamBooks") books = _UamUtils._StringToDict(booksstr) print "books: " + ` books ` books[str(booknum)] = agename #save list newbooksstr = _UamUtils._DictToString(books) uam.SetAgeChronicle("UamBooks", newbooksstr) #_ki.IAddRTChat(None, "The book for "+agename+" has been put on the shelf at position "+str(booknum)+" (You won't see it until you relink though.)", 0) uam.PrintKiMessage("The book for " + agename + " has been put on the shelf at position " + str(booknum) + " (You won't see it until you relink though.)") return True
def _IGetYeeshaPageDefs(self, old_method=BlackBarBodyKIHandler.xKI.IGetYeeshaPageDefs ): print "_UamModReltopages._IGetYeeshaPageDefs" result = old_method(self) #Can only change this while in your Relto import Plasma vault = Plasma.ptVault() if not vault.inMyPersonalAge(): result += "<pb><pb><font size=20><p align=center>You can only change the fan-made pages while on your Relto." return result #Get the current status of the pages import uam chronstr = uam.GetAgeChronicle("UamReltoPages") #on, off, or unattained pages = _UamUtils._StringToDict(chronstr) for page in ReltoPages: pagedict = ReltoPages[page] pagenum = int(pagedict["pagenum"]) lang = _UamUtils.GetLanguage() print "language: " + ` lang ` linktext = pagedict["text--" + lang] linknum = pagenum + 200 #just to get it out of Cyan's hair turnedon = 1 #1 or 0 status = pages.get(page, pagedict["default"] ) #Get the status or use the default for this page. print "status: " + status if status == "on": turnedon = 1 else: turnedon = 0 #either off or unattained if status == "on" or status == "off": result += '<pb><font size=20><p align=center>' + linktext + '<pb><img src="xYeeshaPageAlphaSketchFiremarbles*1#0.hsm" align=center check=00ff18,00800c,' + str( turnedon) + ' link=' + str(linknum) + '>' return result
def CustomYeeshaPageDefs(): #print "_UamModReltopages._IGetYeeshaPageDefs" result = '' if haveUamPlugin: return result #Can only change this while in your Relto vault = Plasma.ptVault() if not vault.inMyPersonalAge(): result += "<pb><pb><font size=32 face=Uru><p align=center>You can only change the fan-made pages while on your Relto." return result #Get the current status of the pages chronstr = uam.GetAgeChronicle("UamReltoPages") #on, off, or unattained pages = _StringToDict(chronstr) names = ReltoPages.keys() names.sort() for page in names: pagedict = ReltoPages[page] pagenum = int(pagedict["pagenum"]) lang = GetLanguage() #print "language: "+`lang` linktext = pagedict["text--" + lang] linknum = pagenum + 200 #just to get it out of Cyan's hair turnedon = 1 #1 or 0 status = pages.get(page, pagedict["default"] ) #Get the status or use the default for this page. #print "status: "+status if status == "on": turnedon = 1 else: turnedon = 0 #either off or unattained if status == "on" or status == "off": result += '<pb><font size=32 face=Uru ><p align=center>' + linktext result += '<pb><img src="xYeeshaPageAlphaSketchFiremarbles*1#0.hsm" align=center check=00ff18,00800c,' + str( turnedon) + ' link=' + str(linknum) + '>' return result
def LoadReltoPages(): print "_UamModReltopages.UamOnNewAgeLoaded" import _UamUtils import uam import Plasma if _UamUtils.GetAgeName() == "Personal": #Read any updated pages ReadPageInfo() #Do tasks given from other Ages if _UamUtils.AmInMyRelto(): tasksstr = uam._GetPlayerChronicle("UamTasks") tasks = _UamUtils._StringToList(tasksstr) numtasks = len(tasks) for task in tasks: print "task to do: " + task if task.startswith("EnableReltoPage="): page = task[len("EnableReltoPage="):] #enable the page pages = _UamUtils._StringToDict( uam.GetAgeChronicle("UamReltoPages")) pages[ page] = "on" #whether it was unset or on or off or unattained, it is on now! uam.SetAgeChronicle("UamReltoPages", _UamUtils._DictToString(pages)) #remove from task list tasks.remove(task) if numtasks != len(tasks): #removed some, so save uam._SetPlayerChronicle("UamTasks", _UamUtils._ListToString(tasks)) #Load pages PagesToLoad = {} #set() #Sets don't exist in Python 2.2 :P ObjectsToHide = {} #set() #Sets don't exist in Python 2.2 :P print "Loading Uam pages..." chronstr = uam.GetAgeChronicle( "UamReltoPages") #on, off, or unattained pages = _UamUtils._StringToDict(chronstr) print "UamReltoPages: " + chronstr for pagename in pages: status = pages[pagename] if status == "on": #PagesToLoad.add(pagename) PagesToLoad[pagename] = None #we're using this dict as a set for hideitem in ReltoPages[pagename]["hide"]: #ObjectsToHide.add(hideitem) ObjectsToHide[ hideitem] = None #we're using this dict as a set #Turn into sorted lists PagesToLoad = PagesToLoad.keys() ObjectsToHide = ObjectsToHide.keys() PagesToLoad.sort() ObjectsToHide.sort() #Hide the objects for hideitem in ObjectsToHide: print "Hiding obj: " + hideitem _UamUtils.HideObject(hideitem) #Load the pages for pagename in PagesToLoad: try: print "Loading page: " + pagename Plasma.PtPageInNode( "UamPage-" + pagename ) #doesn't throw an exception if page not present; simply doesn't load. except: import traceback traceback.print_exc()
def SetVar(self, value): prev = uam.GetAgeChronicle(self.varname) next = value if prev != next: #only notify if changed uam.SetAgeChronicle(self.varname, next) self.NotifyListeners(prev, next)
def InitialSetting(self): prev = None next = uam.GetAgeChronicle(self.varname) self.NotifyListeners(prev, next)