def refresh(self, partyInfoTupleList): PublicPartyGui.notify.debug('refresh : partyInfoTupleList = %s' % partyInfoTupleList) self.selectedItem = None self.partyList.removeAndDestroyAllItems() self.activityList.removeAndDestroyAllItems() self.partyStartButton['state'] = DirectGuiGlobals.DISABLED sortedList = partyInfoTupleList[:] def cmp(left, right): if left[2] < right[2]: return -1 elif left[2] == right[2]: if len(left[4]) < len(right[4]): return -1 elif len(left[4]) == len(right[4]): return 0 else: return 1 else: return 1 sortedList.sort(cmp, reverse=True) indexToCut = -1 for index, partyTuple in enumerate(sortedList): numberOfGuests = partyTuple[2] if numberOfGuests < PartyGlobals.MaxToonsAtAParty: indexToCut = index break if indexToCut > 0: sortedList = sortedList[indexToCut:] + sortedList[:indexToCut] for index, partyTuple in enumerate(sortedList): shardId = partyTuple[0] zoneId = partyTuple[1] numberOfGuests = partyTuple[2] hostName = partyTuple[3] activityIds = partyTuple[4] minLeft = partyTuple[5] item = DirectButton(relief=DGG.RIDGE, borderWidth=(0.01, 0.01), frameSize=(-0.01, 0.45, -0.015, 0.04), frameColor=self.normalFrameColor, text=hostName, text_align=TextNode.ALeft, text_bg=Vec4(0.0, 0.0, 0.0, 0.0), text_scale=0.045, command=self.partyClicked) otherInfoWidth = 0.08 numActivities = len(activityIds) PartyUtils.truncateTextOfLabelBasedOnWidth(item, hostName, PartyGlobals.EventsPageGuestNameMaxWidth) num = DirectLabel(relief=DGG.RIDGE, borderWidth=(0.01, 0.01), frameSize=(0.0, otherInfoWidth, -0.015, 0.04), frameColor=self.normalFrameColor, text='%d' % numberOfGuests, text_align=TextNode.ALeft, text_scale=0.045, text_pos=(0.01, 0, 0), pos=(0.45, 0.0, 0.0)) num.reparentTo(item) item.numLabel = num actLabelPos = num.getPos() actLabelPos.setX(actLabelPos.getX() + otherInfoWidth) actLabel = DirectLabel(relief=DGG.RIDGE, borderWidth=(0.01, 0.01), frameSize=(0.0, otherInfoWidth, -0.015, 0.04), frameColor=self.normalFrameColor, text='%d' % numActivities, text_align=TextNode.ALeft, text_scale=0.045, text_pos=(0.01, 0, 0), pos=actLabelPos) actLabel.reparentTo(item) item.actLabel = actLabel minLabelPos = actLabel.getPos() minLabelPos.setX(minLabelPos.getX() + otherInfoWidth) minLabel = DirectLabel(relief=DGG.RIDGE, borderWidth=(0.01, 0.01), frameSize=(0.0, otherInfoWidth, -0.015, 0.04), frameColor=self.normalFrameColor, text='%d' % minLeft, text_align=TextNode.ALeft, text_scale=0.045, text_pos=(0.01, 0, 0), pos=minLabelPos) minLabel.reparentTo(item) item.minLabel = minLabel item['extraArgs'] = [item] item.setPythonTag('shardId', shardId) item.setPythonTag('zoneId', zoneId) item.setPythonTag('activityIds', activityIds) self.partyList.addItem(item) return
def refresh(self, partyInfoTupleList): PublicPartyGui.notify.debug('refresh : partyInfoTupleList = %s' % partyInfoTupleList) self.selectedItem = None self.partyList.removeAndDestroyAllItems() self.activityList.removeAndDestroyAllItems() self.partyStartButton['state'] = DirectGuiGlobals.DISABLED sortedList = partyInfoTupleList[:] def cmp(left, right): if left[2] < right[2]: return -1 if left[2] == right[2]: if len(left[4]) < len(right[4]): return -1 elif len(left[4]) == len(right[4]): return 0 else: return 1 else: return 1 sortedList.sort(cmp, reverse=True) indexToCut = -1 for index, partyTuple in enumerate(sortedList): numberOfGuests = partyTuple[2] if numberOfGuests < PartyGlobals.MaxToonsAtAParty: indexToCut = index break if indexToCut > 0: sortedList = sortedList[indexToCut:] + sortedList[:indexToCut] for index, partyTuple in enumerate(sortedList): shardId = partyTuple[0] zoneId = partyTuple[1] numberOfGuests = partyTuple[2] hostName = partyTuple[3] activityIds = partyTuple[4] minLeft = partyTuple[5] item = DirectButton(relief=DGG.RIDGE, borderWidth=(0.01, 0.01), frameSize=(-0.01, 0.45, -0.015, 0.04), frameColor=self.normalFrameColor, text=hostName, text_align=TextNode.ALeft, text_bg=Vec4(0.0, 0.0, 0.0, 0.0), text_scale=0.045, command=self.partyClicked) otherInfoWidth = 0.08 numActivities = len(activityIds) PartyUtils.truncateTextOfLabelBasedOnWidth( item, hostName, PartyGlobals.EventsPageGuestNameMaxWidth) num = DirectLabel(relief=DGG.RIDGE, borderWidth=(0.01, 0.01), frameSize=(0.0, otherInfoWidth, -0.015, 0.04), frameColor=self.normalFrameColor, text='%d' % numberOfGuests, text_align=TextNode.ALeft, text_scale=0.045, text_pos=(0.01, 0, 0), pos=(0.45, 0.0, 0.0)) num.reparentTo(item) item.numLabel = num actLabelPos = num.getPos() actLabelPos.setX(actLabelPos.getX() + otherInfoWidth) actLabel = DirectLabel(relief=DGG.RIDGE, borderWidth=(0.01, 0.01), frameSize=(0.0, otherInfoWidth, -0.015, 0.04), frameColor=self.normalFrameColor, text='%d' % numActivities, text_align=TextNode.ALeft, text_scale=0.045, text_pos=(0.01, 0, 0), pos=actLabelPos) actLabel.reparentTo(item) item.actLabel = actLabel minLabelPos = actLabel.getPos() minLabelPos.setX(minLabelPos.getX() + otherInfoWidth) minLabel = DirectLabel(relief=DGG.RIDGE, borderWidth=(0.01, 0.01), frameSize=(0.0, otherInfoWidth, -0.015, 0.04), frameColor=self.normalFrameColor, text='%d' % minLeft, text_align=TextNode.ALeft, text_scale=0.045, text_pos=(0.01, 0, 0), pos=minLabelPos) minLabel.reparentTo(item) item.minLabel = minLabel item['extraArgs'] = [item] item.setPythonTag('shardId', shardId) item.setPythonTag('zoneId', zoneId) item.setPythonTag('activityIds', activityIds) self.partyList.addItem(item)
def refresh(self, partyInfoTupleList): """ Called when the public party gui is shown. partyInfoTupleList is a list of tuples of the form: ( shardId, zoneId, numberOfGuests, hostName, activityIds, lane ) """ PublicPartyGui.notify.debug("refresh : partyInfoTupleList = %s" % partyInfoTupleList) self.selectedItem = None self.partyList.removeAndDestroyAllItems() self.activityList.removeAndDestroyAllItems() self.partyStartButton["state"] = DirectGuiGlobals.DISABLED # put parties with most toons at the top sortedList = partyInfoTupleList[:] #for i in xrange(20): # sortedList.append((202000000, 61000, i+2, "Good ol' Knuckles CrunchenGrooven", [0, 1, 2, 4, 5, 7], 30-i)) def cmp(left, right): if left[2] < right[2]: return -1 elif left[2] == right[2]: if len(left[4]) < len(right[4]): return -1 elif len(left[4]) == len(right[4]): return 0 else: return 1 else: return 1 sortedList.sort(cmp, reverse=True) # put parties with 20 or more toons on the bottom indexToCut = -1 for index, partyTuple in enumerate(sortedList): numberOfGuests = partyTuple[2] if numberOfGuests < PartyGlobals.MaxToonsAtAParty: indexToCut = index break if indexToCut > 0: sortedList = sortedList[indexToCut:] + sortedList[:indexToCut] for index, partyTuple in enumerate(sortedList): shardId = partyTuple[0] zoneId = partyTuple[1] numberOfGuests = partyTuple[2] hostName = partyTuple[3] if GMUtils.testGMIdentity(hostName): hostName = GMUtils.handleGMName(hostName) activityIds = partyTuple[4] minLeft = partyTuple[5] item = DirectButton( relief=DGG.RIDGE, borderWidth=(0.01, 0.01), frameSize=(-0.01, 0.45, -0.015, 0.04), frameColor=self.normalFrameColor, text=hostName, text_align=TextNode.ALeft, text_bg=Vec4(0.0, 0.0, 0.0, 0.0), text_scale=0.045, command=self.partyClicked, ) otherInfoWidth = 0.08 numActivities = len(activityIds) PartyUtils.truncateTextOfLabelBasedOnWidth( item, hostName, PartyGlobals.EventsPageGuestNameMaxWidth) num = DirectLabel( relief=DGG.RIDGE, borderWidth=(0.01, 0.01), frameSize=(0., otherInfoWidth, -0.015, 0.04), frameColor=self.normalFrameColor, text="%d" % numberOfGuests, text_align=TextNode.ALeft, text_scale=0.045, text_pos=(0.01, 0, 0), pos=(0.45, 0.0, 0.0), ) num.reparentTo(item) item.numLabel = num actLabelPos = num.getPos() actLabelPos.setX(actLabelPos.getX() + otherInfoWidth) actLabel = DirectLabel( relief=DGG.RIDGE, borderWidth=(0.01, 0.01), frameSize=(0.0, otherInfoWidth, -0.015, 0.04), frameColor=self.normalFrameColor, text="%d" % numActivities, text_align=TextNode.ALeft, text_scale=0.045, text_pos=(0.01, 0, 0), pos=actLabelPos, ) actLabel.reparentTo(item) item.actLabel = actLabel minLabelPos = actLabel.getPos() minLabelPos.setX(minLabelPos.getX() + otherInfoWidth) minLabel = DirectLabel( relief=DGG.RIDGE, borderWidth=(0.01, 0.01), frameSize=(0.0, otherInfoWidth, -0.015, 0.04), frameColor=self.normalFrameColor, text="%d" % minLeft, text_align=TextNode.ALeft, text_scale=0.045, text_pos=(0.01, 0, 0), pos=minLabelPos, ) minLabel.reparentTo(item) item.minLabel = minLabel item["extraArgs"] = [item] item.setPythonTag("shardId", shardId) item.setPythonTag("zoneId", zoneId) item.setPythonTag("activityIds", activityIds) self.partyList.addItem(item)