finish project support

This commit is contained in:
Jeremy Penner 2011-09-16 08:57:31 -04:00
parent 5d01b2c047
commit 15f4b500c2

View file

@ -31,8 +31,10 @@ class Project(Ownable):
self.user = user self.user = user
self.rgboard = [] self.rgboard = []
self.rgscript = [] self.rgscript = []
def NewBoard(self, user): def NewBoard(self, stName, user):
self.rgboard.append(Board(self, "Board " + len(self.rgboard), user)) board = Board(self, stName, user)
self.rgboard.insert(0, board)
return board
def BoardTouched(self, board): def BoardTouched(self, board):
if board != self.rgboard[0]: if board != self.rgboard[0]:
self.rgboard.remove(board) self.rgboard.remove(board)
@ -44,7 +46,7 @@ class Project(Ownable):
boardLast = None boardLast = None
for board in self.rgboard: for board in self.rgboard:
if boardLast == None or board.dtLastModified > boardLast.dtLastModified: if boardLast == None or board.dtLastModified > boardLast.dtLastModified:
board = boardLast boardLast = board
if boardLast != None: if boardLast != None:
return boardLast.StLastModified() return boardLast.StLastModified()
return "never" return "never"
@ -565,13 +567,18 @@ class Lobby(TokenClient):
self.lobbyCurrent = LobbyProject(self, client) self.lobbyCurrent = LobbyProject(self, client)
def SwitchToLobby(self, lobbyNew): def SwitchToLobby(self, lobbyNew):
self.lobbyCurrent.die() lobbyOld = self.lobbyCurrent
self.lobbyCurrent = lobbyNew self.lobbyCurrent = lobbyNew
lobbyOld.die()
class LobbyI(TokenClient): class LobbyI(TokenClient):
def InitPersistent(self, owner, client): def InitPersistent(self, owner, client, *rgmiListTop):
TokenClient.InitPersistent(self, owner, client) TokenClient.InitPersistent(self, owner, client)
self.miDrawings = MiMenu(RgmiProjected(self.RgObj(), DgProjectMiButton(self.OnObjSelected)))
rgmiList = RgmiProjected(self.RgObj(), DgProjectMiButton(self.OnObjSelected))
if rgmiListTop != None:
rgmiList = Rgseq(rgmiListTop, rgmiList)
self.miDrawings = MiMenu(rgmiList)
self.miCmds = MiMenu([None, None, MiTypein(self.NewI, "ObjectName"), MiButton(self.StNewObj(), self.NewI), self.miCmds = MiMenu([None, None, MiTypein(self.NewI, "ObjectName"), MiButton(self.StNewObj(), self.NewI),
None, None, None, None, None, None, None, None, MiStatic("Last modified:"), MiDgText(self.StLastModifiedI)]) None, None, None, None, None, None, None, None, MiStatic("Last modified:"), MiDgText(self.StLastModifiedI)])
OvMenu(self, client, MiMenuHoriz([self.miDrawings, self.miCmds], [65, 35]), OvMenu.FILL) OvMenu(self, client, MiMenuHoriz([self.miDrawings, self.miCmds], [65, 35]), OvMenu.FILL)
@ -603,7 +610,7 @@ class LobbyI(TokenClient):
class LobbyBoard(LobbyI): class LobbyBoard(LobbyI):
def InitPersistent(self, owner, client, project): def InitPersistent(self, owner, client, project):
self.project = project self.project = project
LobbyI.InitPersistent(self, owner, client) LobbyI.InitPersistent(self, owner, client, MiButton("<-- Back to projects", self.Back), None)
def StNewObj(self): def StNewObj(self):
return "New Board" return "New Board"
@ -612,10 +619,14 @@ class LobbyBoard(LobbyI):
def OnObjSelected(self, board): def OnObjSelected(self, board):
self.client.leaveGame(board) self.client.leaveGame(board)
def New(self, stName): def New(self, stName):
self.project.NewBoard(stName, self.client.cld.user) self.OnObjSelected(self.project.NewBoard(stName, self.client.cld.user))
def StLastModified(self, board): def StLastModified(self, board):
return board.StLastModified() if board != None:
return board.StLastModified()
return self.project.StLastModified()
def Back(self):
self.owner.SwitchToLobby(LobbyProject(self.owner, self.client))
class LobbyProject(LobbyI): class LobbyProject(LobbyI):
def StNewObj(self): def StNewObj(self):
return "New Project" return "New Project"
@ -677,8 +688,17 @@ class GameLobby(Game):
def StNameBoard(self, board): def StNameBoard(self, board):
return board.stName + " (by " + board.user + ") [" + str(self.CclientBoard(board)) + "]" return board.stName + " (by " + board.user + ") [" + str(self.CclientBoard(board)) + "]"
def NewProject(self, stName, user):
proj = Project(self, stName, user)
self.rgproject.insert(0, proj)
return proj
def BoardTouched(self, board): def BoardTouched(self, board):
project = board.owner
if project != self.rgproject[0]:
self.rgproject.remove(project)
self.rgproject.insert(0, project)
#haaaack #haaaack
self.ensureRun() # redraw self.ensureRun() # redraw