finish project support
This commit is contained in:
parent
5d01b2c047
commit
15f4b500c2
|
@ -31,8 +31,10 @@ class Project(Ownable):
|
|||
self.user = user
|
||||
self.rgboard = []
|
||||
self.rgscript = []
|
||||
def NewBoard(self, user):
|
||||
self.rgboard.append(Board(self, "Board " + len(self.rgboard), user))
|
||||
def NewBoard(self, stName, user):
|
||||
board = Board(self, stName, user)
|
||||
self.rgboard.insert(0, board)
|
||||
return board
|
||||
def BoardTouched(self, board):
|
||||
if board != self.rgboard[0]:
|
||||
self.rgboard.remove(board)
|
||||
|
@ -44,7 +46,7 @@ class Project(Ownable):
|
|||
boardLast = None
|
||||
for board in self.rgboard:
|
||||
if boardLast == None or board.dtLastModified > boardLast.dtLastModified:
|
||||
board = boardLast
|
||||
boardLast = board
|
||||
if boardLast != None:
|
||||
return boardLast.StLastModified()
|
||||
return "never"
|
||||
|
@ -565,13 +567,18 @@ class Lobby(TokenClient):
|
|||
self.lobbyCurrent = LobbyProject(self, client)
|
||||
|
||||
def SwitchToLobby(self, lobbyNew):
|
||||
self.lobbyCurrent.die()
|
||||
lobbyOld = self.lobbyCurrent
|
||||
self.lobbyCurrent = lobbyNew
|
||||
lobbyOld.die()
|
||||
|
||||
class LobbyI(TokenClient):
|
||||
def InitPersistent(self, owner, client):
|
||||
def InitPersistent(self, owner, client, *rgmiListTop):
|
||||
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),
|
||||
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)
|
||||
|
@ -603,7 +610,7 @@ class LobbyI(TokenClient):
|
|||
class LobbyBoard(LobbyI):
|
||||
def InitPersistent(self, owner, client, project):
|
||||
self.project = project
|
||||
LobbyI.InitPersistent(self, owner, client)
|
||||
LobbyI.InitPersistent(self, owner, client, MiButton("<-- Back to projects", self.Back), None)
|
||||
|
||||
def StNewObj(self):
|
||||
return "New Board"
|
||||
|
@ -612,9 +619,13 @@ class LobbyBoard(LobbyI):
|
|||
def OnObjSelected(self, board):
|
||||
self.client.leaveGame(board)
|
||||
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):
|
||||
if board != None:
|
||||
return board.StLastModified()
|
||||
return self.project.StLastModified()
|
||||
def Back(self):
|
||||
self.owner.SwitchToLobby(LobbyProject(self.owner, self.client))
|
||||
|
||||
class LobbyProject(LobbyI):
|
||||
def StNewObj(self):
|
||||
|
@ -678,7 +689,16 @@ class GameLobby(Game):
|
|||
def StNameBoard(self, 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):
|
||||
project = board.owner
|
||||
if project != self.rgproject[0]:
|
||||
self.rgproject.remove(project)
|
||||
self.rgproject.insert(0, project)
|
||||
#haaaack
|
||||
self.ensureRun() # redraw
|
||||
|
||||
|
|
Loading…
Reference in a new issue