def createPartyListAndLabel(self, typeString, numItems): list = DirectScrolledList( parent=self, relief=None, incButton_image=(self.gui.find('**/%sButtonDown_up' % typeString), self.gui.find('**/%sButtonDown_down' % typeString), self.gui.find('**/%sButtonDown_rollover' % typeString), self.gui.find('**/%sButtonDown_inactive' % typeString)), incButton_relief=None, decButton_image=(self.gui.find('**/%sButtonUp_up' % typeString), self.gui.find('**/%sButtonUp_down' % typeString), self.gui.find('**/%sButtonUp_rollover' % typeString), self.gui.find('**/%sButtonUp_inactive' % typeString)), decButton_relief=None, itemFrame_pos=self.gui.find('**/%s_locator' % typeString).getPos(), itemFrame_relief=None, numItemsVisible=numItems, forceHeight=0.055) strings = { 'activities': TTLocalizer.EventsPageHostingTabActivityListTitle, 'parties': TTLocalizer.PartyGatePartiesListTitle } hostPos = self.gui.find('**/%sText_locator' % typeString).getPos() label = DirectLabel(parent=self, text_align=TextNode.ALeft, relief=None, text=strings[typeString], text_scale=0.06, pos=hostPos) curPos = label.getPos() curPos.setX(curPos.getX() + 0.5) if not self.gui.find('**/partiesText_locator1').isEmpty(): curPos = self.gui.find('**/partiesText_locator1').getPos() hpr = Point3(0, 0, -40) toonsLabel = DirectLabel(parent=self, text_align=TextNode.ALeft, relief=None, text=TTLocalizer.PartyGatesPartiesListToons, text_scale=TTLocalizer.PPGtoonsLabel, pos=curPos, hpr=hpr) curPos.setX(curPos.getX() + 0.1) if not self.gui.find('**/partiesText_locator2').isEmpty(): curPos = self.gui.find('**/partiesText_locator2').getPos() activitiesLabel = DirectLabel( parent=self, text_align=TextNode.ALeft, relief=None, text=TTLocalizer.PartyGatesPartiesListActivities, text_scale=TTLocalizer.PPGactivitiesLabel, pos=curPos, hpr=hpr) curPos.setX(curPos.getX() + 0.1) if not self.gui.find('**/partiesText_locator3').isEmpty(): curPos = self.gui.find('**/partiesText_locator3').getPos() minLeftLabel = DirectLabel( parent=self, text_align=TextNode.ALeft, relief=None, text=TTLocalizer.PartyGatesPartiesListMinLeft, text_scale=TTLocalizer.PPGminLeftLabel, pos=curPos, hpr=hpr) return (list, label)
def createGuiObjects(self): self.dayButton = DirectButton(parent=self.dayButtonLocator, image=self.selectedFrame, relief=None, command=self.__clickedOnDay, pressEffect=1, rolloverSound=None, clickSound=None) self.numberWidget = DirectLabel( parent=self.numberLocator, relief=None, text=str(self.myDate.day), text_scale=0.04, text_align=TextNode.ACenter, text_font=ToontownGlobals.getInterfaceFont(), text_fg=Vec4(110 / 255.0, 126 / 255.0, 255 / 255.0, 1)) self.attachMarker(self.numberLocator) self.listXorigin = 0 self.listFrameSizeX = self.scrollBottomRightLocator.getX( ) - self.scrollLocator.getX() self.scrollHeight = self.scrollLocator.getZ( ) - self.scrollBottomRightLocator.getZ() self.listZorigin = self.scrollBottomRightLocator.getZ() self.listFrameSizeZ = self.scrollLocator.getZ( ) - self.scrollBottomRightLocator.getZ() self.arrowButtonXScale = 1 self.arrowButtonZScale = 1 self.itemFrameXorigin = 0 self.itemFrameZorigin = 0 self.buttonXstart = self.itemFrameXorigin + 0.21 self.gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui') buttonOffSet = -0.01 incButtonPos = (0.0, 0, 0) decButtonPos = (0.0, 0, 0) itemFrameMinZ = self.listZorigin itemFrameMaxZ = self.listZorigin + self.listFrameSizeZ arrowUp = self.find('**/downScroll_up') arrowDown = self.find('**/downScroll_down') arrowHover = self.find('**/downScroll_hover') self.scrollList = DirectScrolledList( parent=self.scrollLocator, relief=None, pos=(0, 0, 0), incButton_image=(arrowUp, arrowDown, arrowHover, arrowUp), incButton_relief=None, incButton_scale=(self.arrowButtonXScale, 1, self.arrowButtonZScale), incButton_pos=incButtonPos, incButton_image3_color=(1, 1, 1, 0.2), decButton_image=(arrowUp, arrowDown, arrowHover, arrowUp), decButton_relief=None, decButton_scale=(self.arrowButtonXScale, 1, -self.arrowButtonZScale), decButton_pos=decButtonPos, decButton_image3_color=(1, 1, 1, 0.2), itemFrame_pos=(self.itemFrameXorigin, 0, -0.03), numItemsVisible=4, incButtonCallback=self.scrollButtonPressed, decButtonCallback=self.scrollButtonPressed) itemFrameParent = self.scrollList.itemFrame.getParent() self.scrollList.incButton.reparentTo(self.scrollDownLocator) self.scrollList.decButton.reparentTo(self.scrollUpLocator) arrowUp.removeNode() arrowDown.removeNode() arrowHover.removeNode() clipper = PlaneNode('clipper') clipper.setPlane(Plane((-1, 0, 0), (0.23, 0, 0))) clipNP = self.scrollList.component('itemFrame').attachNewNode(clipper) self.scrollList.component('itemFrame').setClipPlane(clipNP) return
def createGuiObjects(self): """Create the other gui objects in the month, assumes we have proper locators.""" self.monthLabel = DirectLabel( parent=self.monthLocator, relief=None, text=TTLocalizer.Months[self.startDate.month], text_scale=0.075, text_font=ToontownGlobals.getMinnieFont(), text_fg=(40 / 255.0, 140 / 255.0, 246 / 255.0, 1.0), ) self.yearLabel = DirectLabel( parent=self.yearLocator, relief=None, text=str(self.startDate.year), text_scale=0.03, text_font=ToontownGlobals.getMinnieFont(), #text_fg = (40/255.0, 140/255.0, 246/255.0, 1.0), text_fg=(140 / 255.0, 140 / 255.0, 246 / 255.0, 1.0), ) self.weekdayLabels = [] for posIndex in range(7): # Sunday is the usual first day of the week, but # self.startDate.weekDay() reports 0 for Monday adjustedNameIndex = (posIndex - 1) % 7 self.weekdayLabels.append( DirectLabel(parent=self.weekDayLocators[posIndex], relief=None, text=TTLocalizer.DayNamesAbbrev[adjustedNameIndex], text_font=ToontownGlobals.getInterfaceFont(), text_fg=(255 / 255.0, 146 / 255.0, 113 / 255.0, 1.0), text_scale=0.05)) self.createGuiDays() arrowUp = self.find("**/month_arrowR_up") arrowDown = self.find("**/month_arrowR_down") arrowHover = self.find("**/month_arrowR_hover") self.monthLeftArrow = DirectButton( parent=self.monthLeftLocator, relief=None, image=( arrowUp, arrowDown, arrowHover, arrowUp, ), # make the disabled color more transparent image3_color=Vec4(1, 1, 1, 0.5), scale=(-1.0, 1.0, 1.0), # make the arrow point left #pos = (0.25, 0, buttonbase_ycoord - textRowHeight * 4), command=self.__doMonthLeft, ) if self.onlyFutureDaysClickable: self.monthLeftArrow.hide() self.monthRightArrow = DirectButton( parent=self.monthRightLocator, relief=None, image=( arrowUp, arrowDown, arrowHover, arrowUp, ), # make the disabled color more transparent image3_color=Vec4(1, 1, 1, 0.5), #pos = (0.65, 0, buttonbase_ycoord - textRowHeight * 4), command=self.__doMonthRight, ) def makeLabel(itemName, itemNum, *extraArgs): return DirectLabel( text=itemName, frameColor=(0, 0, 0, 0), #scale = 0.1, #relief = DGG.RAISED, #frameSize = (-3.5, 3.5, -0.2, 0.8), text_scale=0.04) gui = loader.loadModel( 'phase_4/models/parties/tt_m_gui_sbk_calendar_box') arrowUp = gui.find("**/downScroll_up") arrowDown = gui.find("**/downScroll_down") arrowHover = gui.find("**/downScroll_hover") filterLocatorUpPos = self.filterLocatorArrowUp.getPos( self.filterLocator) filterLocatorDownPos = self.filterLocatorArrowDown.getPos( self.filterLocator) self.filterList = DirectScrolledList( parent=self.filterLocator, relief=None, pos=(0, 0, 0), #(0.65, 0, 0.7), image=None, #DGG.getDefaultDialogGeom(), text_scale=0.025, incButton_image=( arrowUp, arrowDown, arrowHover, arrowUp, ), incButton_relief=None, incButton_pos=filterLocatorDownPos, #(0.0, 0.0, -0.035), # Make the disabled button fade out incButton_image3_color=Vec4(1, 1, 1, 0.2), incButtonCallback=self.filterChanged, # Same for the decrement button decButton_image=( arrowUp, arrowDown, arrowHover, arrowUp, ), decButton_relief=None, decButton_pos=filterLocatorUpPos, #(0.0, 0.0, 0.07), decButton_scale=(1, 1, -1), # Make the disabled button fade out decButton_image3_color=Vec4(1, 1, 1, 0.2), decButtonCallback=self.filterChanged, # each item is a button with text on it numItemsVisible=1, itemMakeFunction=makeLabel, # note ordering is very important, should match ToontownGlobals items=[ TTLocalizer.CalendarShowAll, TTLocalizer.CalendarShowOnlyHolidays, TTLocalizer.CalendarShowOnlyParties, ], # itemFrame is a DirectFrame itemFrame_frameSize=(-.2, .2, -.02, .05), itemFrame_frameColor=(0, 0, 0, 0), ) gui.removeNode()
def createGuiObjects(self): self.monthLabel = DirectLabel( parent=self.monthLocator, relief=None, text=TTLocalizer.Months[self.startDate.month], text_scale=0.075, text_font=ToontownGlobals.getMinnieFont(), text_fg=(40 / 255.0, 140 / 255.0, 246 / 255.0, 1.0)) self.yearLabel = DirectLabel(parent=self.yearLocator, relief=None, text=str(self.startDate.year), text_scale=0.03, text_font=ToontownGlobals.getMinnieFont(), text_fg=(140 / 255.0, 140 / 255.0, 246 / 255.0, 1.0)) self.weekdayLabels = [] for posIndex in xrange(7): adjustedNameIndex = (posIndex - 1) % 7 self.weekdayLabels.append( DirectLabel(parent=self.weekDayLocators[posIndex], relief=None, text=TTLocalizer.DayNamesAbbrev[adjustedNameIndex], text_font=ToontownGlobals.getInterfaceFont(), text_fg=(255 / 255.0, 146 / 255.0, 113 / 255.0, 1.0), text_scale=0.05)) self.createGuiDays() arrowUp = self.find('**/month_arrowR_up') arrowDown = self.find('**/month_arrowR_down') arrowHover = self.find('**/month_arrowR_hover') self.monthLeftArrow = DirectButton(parent=self.monthLeftLocator, relief=None, image=(arrowUp, arrowDown, arrowHover, arrowUp), image3_color=Vec4(1, 1, 1, 0.5), scale=(-1.0, 1.0, 1.0), command=self.__doMonthLeft) if self.onlyFutureMonthsClickable: self.monthLeftArrow.hide() self.monthRightArrow = DirectButton(parent=self.monthRightLocator, relief=None, image=(arrowUp, arrowDown, arrowHover, arrowUp), image3_color=Vec4(1, 1, 1, 0.5), command=self.__doMonthRight) def makeLabel(itemName, itemNum, *extraArgs): return DirectLabel(text=itemName, frameColor=(0, 0, 0, 0), text_scale=0.04) gui = loader.loadModel( 'phase_4/models/parties/tt_m_gui_sbk_calendar_box') arrowUp = gui.find('**/downScroll_up') arrowDown = gui.find('**/downScroll_down') arrowHover = gui.find('**/downScroll_hover') filterLocatorUpPos = self.filterLocatorArrowUp.getPos( self.filterLocator) filterLocatorDownPos = self.filterLocatorArrowDown.getPos( self.filterLocator) self.filterList = DirectScrolledList( parent=self.filterLocator, relief=None, pos=(0, 0, 0), image=None, text_scale=0.025, incButton_image=(arrowUp, arrowDown, arrowHover, arrowUp), incButton_relief=None, incButton_pos=filterLocatorDownPos, incButton_image3_color=Vec4(1, 1, 1, 0.2), incButtonCallback=self.filterChanged, decButton_image=(arrowUp, arrowDown, arrowHover, arrowUp), decButton_relief=None, decButton_pos=filterLocatorUpPos, decButton_scale=(1, 1, -1), decButton_image3_color=Vec4(1, 1, 1, 0.2), decButtonCallback=self.filterChanged, numItemsVisible=1, itemMakeFunction=makeLabel, items=[ TTLocalizer.CalendarShowAll, TTLocalizer.CalendarShowOnlyHolidays, TTLocalizer.CalendarShowOnlyParties ], itemFrame_frameSize=(-0.2, 0.2, -0.02, 0.05), itemFrame_frameColor=(0, 0, 0, 0)) gui.removeNode() return
def __init__(self, showbase): self.showbase = showbase self.status = OnscreenText(text="", pos=Vec3(0, -0.35, 0), scale=0.05, fg=(1, 0, 0, 1), align=TextNode.ACenter, mayChange=True) self.background = DirectFrame( frameSize=(-1, 1, -1, 1), frameTexture='media/gui/mainmenu/menu.png', parent=self.showbase.render2d, ) self.title = OnscreenText(text='Main Menu', fg=(1, 1, 1, 1), parent=self.background, pos=(-0.6, 0.1), scale=0.06) self.ip = '127.0.0.1' # Should make this write to file... so that the user can save ip's... # yep thats a good idea, there will be a few things i guess that need to be done like this # like settings and keys and whatnot # Buttons self.buttons = [] serverButtons = Vec3(-0.60, 0, -0.79) # Host self.params = ['3', '8'] p = serverButtons + Vec3(-0.25, 0, 0) self.hostButton = DirectButton(text='Host', pos=p, scale=0.048, relief=DGG.GROOVE, command=self.showbase.hostGame, extraArgs=[self.params]) self.buttons.append(self.hostButton) # Join p = serverButtons + Vec3(0.0, 0.0, 0.0) self.joinButton = DirectButton(text='Join', pos=p, scale=0.048, relief=DGG.GROOVE, command=self.joinServer) self.buttons.append(self.joinButton) # Refresh if self.showbase.online: p = serverButtons + Vec3(0.25, 0, 0) self.refreshButton = DirectButton(text="Refresh", pos=p, scale=0.048, relief=DGG.GROOVE, command=self.refreshStart) self.buttons.append(self.refreshButton) self.refreshStart() chatFrameCenter = (0.0, 0.325) chatFrameSize = (2.5, 1.2) self.chat = DirectFrame( frameColor=(0, 0, 0, 1), frameSize=(chatFrameSize[0] / 2, -chatFrameSize[0] / 2, chatFrameSize[1] / 2, -chatFrameSize[1] / 2), pos=(chatFrameCenter[0], 0, chatFrameCenter[1])) channelFrameSize = (chatFrameSize[0] / 4, chatFrameSize[1]) channelFrameCenter = (-chatFrameSize[0] / 2 + channelFrameSize[0] / 2, 0) numItemsVisible = 8 itemHeight = channelFrameSize[1] / (numItemsVisible + 1) self.channels = DirectScrolledList( parent=self.chat, pos=(channelFrameCenter[0], 0, channelFrameCenter[1]), frameSize=(-channelFrameSize[0] / 2, channelFrameSize[0] / 2, channelFrameSize[1] / 2, -channelFrameSize[1] / 2), frameColor=(1, 0, 0, 0.5), numItemsVisible=numItemsVisible, forceHeight=itemHeight, #itemFrame_frameSize = (-channelFrameSize[0] / 2.1, channelFrameSize[0] / 2.1, itemHeight, -channelFrameSize[1] + itemHeight), itemFrame_pos=(0, 0, channelFrameSize[1] / 2 - itemHeight), decButton_pos=(-0.2, 0, channelFrameCenter[1] - channelFrameSize[1] / 2 + itemHeight / 4), decButton_text='Prev', decButton_text_scale=0.05, decButton_borderWidth=(0.005, 0.005), incButton_pos=(0.2, 0, channelFrameCenter[1] - channelFrameSize[1] / 2 + itemHeight / 4), incButton_text='Next', incButton_text_scale=0.05, incButton_borderWidth=(0.005, 0.005), ) b1 = DirectButton(text=("Button1", "click!", "roll", "disabled"), text_scale=0.1, borderWidth=(0.01, 0.01), relief=2) b2 = DirectButton(text=("Button2", "click!", "roll", "disabled"), text_scale=0.1, borderWidth=(0.01, 0.01), relief=2) l1 = DirectLabel(text="Test1", text_scale=0.1) l2 = DirectLabel(text="Test2", text_scale=0.1) l3 = DirectLabel(text="Test3", text_scale=0.1) self.channels.addItem(b1) self.channels.addItem(b2) self.channels.addItem(l1) self.channels.addItem(l2) self.channels.addItem(l3) for fruit in [ 'apple', 'pear', 'banana', 'orange', 'cake', 'chocolate' ]: l = DirectLabel(text=fruit, text_scale=0.1) self.channels.addItem(l) # need to add the chat stuff # i guess have like a chat manager which will hold an array of 'chat_instances' # and the chat manager can sort out which is displayed and which channel the text is sent from/received to # a bit more thinking needs to be done i guess # can discuss sometime (not really that important now :P) # also i guess the layout and shit will need to be sorted (for whoever is doing the designing) # current games list (need to implement this) # it should send a query to the master server to get the current list (just ip's atmo i guess) # options shit aswell needs to be sorted # maybe just an overlay or something # functionality for the host button (popup an overlay that will be able to set options and then 'start_game' button # then should auto connect and go to lobby (will be same as for all clients, except have a couple of different buttons i guess) # close game instead of disconnect, start game instead of ready (greyed until all others are ready), kick button i suppose # once the options are set the 'server_inst' should be started on the local computer (which will broadcast to master server, once host can successfully connect) # then game client will move to pregame state (connect to the server, and wait for others and ready) else: self.entry = DirectEntry( focusInCommand=self.clearText, frameSize=(-3, 3, -.5, 1), initialText=self.ip, parent=self.buttons[0], pos=(0, -0.6, -1.5), text_align=TextNode.ACenter, ) self.hide()
def createPartyListAndLabel(self, typeString, numItems): """ Create a DirectScrolledList for different specificall for public parties """ list = DirectScrolledList( parent=self, relief=None, incButton_image=( self.gui.find("**/%sButtonDown_up" % typeString), self.gui.find("**/%sButtonDown_down" % typeString), self.gui.find("**/%sButtonDown_rollover" % typeString), self.gui.find("**/%sButtonDown_inactive" % typeString), ), incButton_relief=None, decButton_image=( self.gui.find("**/%sButtonUp_up" % typeString), self.gui.find("**/%sButtonUp_down" % typeString), self.gui.find("**/%sButtonUp_rollover" % typeString), self.gui.find("**/%sButtonUp_inactive" % typeString), ), decButton_relief=None, itemFrame_pos=self.gui.find("**/%s_locator" % typeString).getPos(), itemFrame_relief=None, numItemsVisible=numItems, # need to set height of each entry to avoid list text running off end of listbox forceHeight=0.055, ) strings = { "activities": TTLocalizer.EventsPageHostingTabActivityListTitle, "parties": TTLocalizer.PartyGatePartiesListTitle, } hostPos = self.gui.find("**/%sText_locator" % typeString).getPos() label = DirectLabel(parent=self, text_align=TextNode.ALeft, relief=None, text=strings[typeString], text_scale=0.06, pos=hostPos) curPos = label.getPos() curPos.setX(curPos.getX() + 0.5) if not self.gui.find("**/partiesText_locator1").isEmpty(): curPos = self.gui.find("**/partiesText_locator1").getPos() hpr = Point3(0, 0, -40) toonsLabel = DirectLabel( parent=self, text_align=TextNode.ALeft, relief=None, text=TTLocalizer.PartyGatesPartiesListToons, text_scale=TTLocalizer.PPGcreatePartyListAndLabel, pos=curPos, hpr=hpr) curPos.setX(curPos.getX() + 0.1) if not self.gui.find("**/partiesText_locator2").isEmpty(): curPos = self.gui.find("**/partiesText_locator2").getPos() activitiesLabel = DirectLabel( parent=self, text_align=TextNode.ALeft, relief=None, text=TTLocalizer.PartyGatesPartiesListActivities, text_scale=TTLocalizer.PPGcreatePartyListAndLabel, pos=curPos, hpr=hpr) curPos.setX(curPos.getX() + 0.1) if not self.gui.find("**/partiesText_locator3").isEmpty(): curPos = self.gui.find("**/partiesText_locator3").getPos() minLeftLabel = DirectLabel( parent=self, text_align=TextNode.ALeft, relief=None, text=TTLocalizer.PartyGatesPartiesListMinLeft, text_scale=TTLocalizer.PPGcreatePartyListAndLabel, pos=curPos, hpr=hpr) return (list, label)
def initElementList(self): self.activityIconsModel = loader.loadModel( 'phase_4/models/parties/eventSignIcons') self.decorationModels = loader.loadModel( 'phase_4/models/parties/partyDecorations') pos = self.partyPlanner.gui.find( '**/step_05_activitiesIcon_locator').getPos() self.elementList = DirectScrolledList( parent=self.parent, relief=None, decButton_image=( self.partyPlanner.gui.find('**/activitiesButtonUp_up'), self.partyPlanner.gui.find('**/activitiesButtonUp_down'), self.partyPlanner.gui.find('**/activitiesButtonUp_rollover'), self.partyPlanner.gui.find('**/activitiesButtonUp_inactive')), decButton_relief=None, decButton_pos=(-0.050000000000000003, 0.0, -0.38), incButton_image=( self.partyPlanner.gui.find('**/activitiesButtonDown_up'), self.partyPlanner.gui.find('**/activitiesButtonDown_down'), self.partyPlanner.gui.find('**/activitiesButtonDown_rollover'), self.partyPlanner.gui.find('**/activitiesButtonDown_inactive') ), incButton_relief=None, incButton_pos=(-0.050000000000000003, 0.0, -0.93999999999999995), itemFrame_pos=(pos[0], pos[1], pos[2] + 0.040000000000000001), itemFrame_relief=None, numItemsVisible=1, items=[]) holidayIds = base.cr.newsManager.getHolidayIdList() if not ToontownGlobals.WINTER_DECORATIONS in holidayIds: pass isWinter = ToontownGlobals.WACKY_WINTER_DECORATIONS in holidayIds isVictory = ToontownGlobals.VICTORY_PARTY_HOLIDAY in holidayIds isValentine = ToontownGlobals.VALENTINES_DAY in holidayIds for activityId in PartyGlobals.PartyEditorActivityOrder: if not not isVictory or activityId in PartyGlobals.VictoryPartyActivityIds: if (not isWinter or activityId in PartyGlobals.WinterPartyActivityIds or not isValentine ) and activityId in PartyGlobals.ValentinePartyActivityIds: continue if not isVictory or activityId in PartyGlobals.VictoryPartyReplacementActivityIds: if ( isWinter or activityId in PartyGlobals.WinterPartyReplacementActivityIds or isValentine ) and activityId in PartyGlobals.ValentinePartyReplacementActivityIds: continue pele = PartyEditorListElement(self, activityId) self.elementList.addItem(pele) if activityId == PartyGlobals.ActivityIds.PartyClock: self.partyClockElement = pele continue for decorationId in PartyGlobals.DecorationIds: if not not isVictory or decorationId in PartyGlobals.VictoryPartyDecorationIds: if ( not isWinter or decorationId in PartyGlobals.WinterPartyDecorationIds or not isValentine ) and decorationId in PartyGlobals.ValentinePartyDecorationIds: continue if ( isVictory or decorationId in PartyGlobals.VictoryPartyReplacementDecorationIds or isValentine ) and decorationId in PartyGlobals.ValentinePartyReplacementDecorationIds: continue pele = PartyEditorListElement(self, decorationId, isDecoration=True) self.elementList.addItem(pele) self.elementList.refresh() self.elementList['command'] = self.scrollItemChanged
def createGuiObjects(self): """Create the other gui objects in the month, assumes we have proper locators.""" # we create an invisible button so the day can be clicked on self.dayButton = DirectButton( parent=self.dayButtonLocator, image=self.selectedFrame, relief=None, command=self.__clickedOnDay, # next three settings are for debug pressEffect=1, rolloverSound=None, clickSound=None) self.numberWidget = DirectLabel( parent=self.numberLocator, relief=None, text=str(self.myDate.day), text_scale=0.04, text_align=TextNode.ACenter, text_font=ToontownGlobals.getInterfaceFont(), text_fg=Vec4(110 / 255.0, 126 / 255.0, 255 / 255.0, 1), ) self.attachMarker(self.numberLocator) self.listXorigin = 0 self.listFrameSizeX = self.scrollBottomRightLocator.getX( ) - self.scrollLocator.getX() self.scrollHeight = self.scrollLocator.getZ( ) - self.scrollBottomRightLocator.getZ() self.listZorigin = self.scrollBottomRightLocator.getZ() self.listFrameSizeZ = self.scrollLocator.getZ( ) - self.scrollBottomRightLocator.getZ() self.arrowButtonXScale = 1 self.arrowButtonZScale = 1 self.itemFrameXorigin = 0 self.itemFrameZorigin = 0 self.buttonXstart = self.itemFrameXorigin + 0.21 self.gui = loader.loadModel("phase_3.5/models/gui/friendslist_gui") buttonOffSet = -0.01 # these settings put the arrow buttons on the top incButtonPos = (0.0, 0, 0) decButtonPos = (0.0, 0, 0) # these settings put the arrow buttons on the right side # incButtonPos = (self.buttonXstart,0,self.listZorigin - buttonOffSet) # decButtonPos = (self.buttonXstart, 0, self.listZorigin + self.listFrameSizeZ + buttonOffSet) itemFrameMinZ = self.listZorigin itemFrameMaxZ = self.listZorigin + self.listFrameSizeZ arrowUp = self.find("**/downScroll_up") arrowDown = self.find("**/downScroll_down") arrowHover = self.find("**/downScroll_hover") self.scrollList = DirectScrolledList( parent=self.scrollLocator, relief=None, pos=(0, 0, 0), # inc and dec are DirectButtons # incButton is on the bottom of page, decButton is on the top! incButton_image=( arrowUp, arrowDown, arrowHover, arrowUp, ), incButton_relief=None, incButton_scale=(self.arrowButtonXScale, 1, self.arrowButtonZScale), incButton_pos=incButtonPos, # Make the disabled button fade out incButton_image3_color=Vec4(1, 1, 1, 0.2), decButton_image=( arrowUp, arrowDown, arrowHover, arrowUp, ), decButton_relief=None, decButton_scale=(self.arrowButtonXScale, 1, -self.arrowButtonZScale), decButton_pos=decButtonPos, # Make the disabled button fade out decButton_image3_color=Vec4(1, 1, 1, 0.2), # itemFrame is a DirectFrame, shift it down a bit to match top left scroll itemFrame_pos=(self.itemFrameXorigin, 0, -0.03), # each item is a button with text on it numItemsVisible=4, # so we select the day when we click on a scroll button incButtonCallback=self.scrollButtonPressed, decButtonCallback=self.scrollButtonPressed, ) # make sure the arrow buttons appear over item frame itemFrameParent = self.scrollList.itemFrame.getParent() self.scrollList.incButton.reparentTo(self.scrollDownLocator) self.scrollList.decButton.reparentTo(self.scrollUpLocator) arrowUp.removeNode() arrowDown.removeNode() arrowHover.removeNode() # Set up a clipping plane to truncate names that would extend # off the right end of the scrolled list. clipper = PlaneNode('clipper') clipper.setPlane(Plane(Vec3(-1, 0, 0), Point3(0.23, 0, 0))) clipNP = self.scrollList.component('itemFrame').attachNewNode(clipper) self.scrollList.component('itemFrame').setClipPlane(clipNP)
def __init__(self): DirectFrame.__init__(self, parent=base.a2dTopRight, pos=(-0.25, 0.0, -0.46)) gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui.bam') self['image'] = gui.find('**/FriendsBox_Open') self.headingText = OnscreenText(text='', parent=self, pos=(0.01, 0.2), fg=(0.1, 0.1, 0.4, 1.0), scale=0.04) self.frameForNames = DirectScrolledList( frameSize=(0.0, 0.35, 0, 0.35), incButton_geom=(gui.find('**/FndsLst_ScrollUp'), gui.find('**/FndsLst_ScrollDN'), gui.find('**/FndsLst_ScrollUp_Rllvr'), gui.find('**/FndsLst_ScrollUp')), incButton_relief=None, incButton_hpr=(0, 0, 180), incButton_pos=(0.17, 0, -0.04), decButton_geom=(gui.find('**/FndsLst_ScrollUp'), gui.find('**/FndsLst_ScrollDN'), gui.find('**/FndsLst_ScrollUp_Rllvr'), gui.find('**/FndsLst_ScrollUp')), decButton_relief=None, decButton_pos=(0.17, 0, 0.395), pos=(-0.1625, 0.0, -0.27), parent=self, numItemsVisible=9, forceHeight=0.04, itemFrame_frameSize=(-0.15, 0.15, 0, -0.35), itemFrame_pos=(0, 0, 0.3275), itemFrame_relief=None, relief=None) self.fwdBtn = DirectButton(geom=(gui.find('**/Horiz_Arrow_UP'), gui.find('**/Horiz_Arrow_DN'), gui.find('**/Horiz_Arrow_Rllvr'), gui.find('**/Horiz_Arrow_UP')), relief=None, parent=self, pos=(0.17, 0.0, -0.38), command=self.doState) self.backBtn = DirectButton(geom=(gui.find('**/Horiz_Arrow_UP'), gui.find('**/Horiz_Arrow_DN'), gui.find('**/Horiz_Arrow_Rllvr'), gui.find('**/Horiz_Arrow_UP')), relief=None, parent=self, pos=(-0.15, 0.0, -0.38), hpr=(180, 0, 0), command=self.doState) self.closeBtn = DirectButton(geom=CIGlobals.getCancelBtnGeom(), relief=None, parent=self, command=self.exitClicked) self.closeBtn.setPos(0.015, 0.0, -0.375) gui.removeNode() del gui self.hide() self.friends = {} self.onlineFriends = {} self.fsm = ClassicFSM.ClassicFSM('FriendsList', [ State.State('off', self.enterOff, self.exitOff), State.State('onlineFriendsList', self.enterOnlineFriendsList, self.exitOnlineFriendsList), State.State('allFriendsList', self.enterAllFriendsList, self.exitAllFriendsList) ], 'off', 'off') self.fsm.enterInitialState() self.accept('gotFriendsList', self.handleFriendsList) return
def initElementList(self): self.activityIconsModel = loader.loadModel("phase_4/models/parties/eventSignIcons") self.decorationModels = loader.loadModel("phase_4/models/parties/partyDecorations") pos = self.partyPlanner.gui.find("**/step_05_activitiesIcon_locator").getPos() self.elementList = DirectScrolledList( parent = self.parent, relief = None, # inc and dec are DirectButtons decButton_image = (self.partyPlanner.gui.find("**/activitiesButtonUp_up"), self.partyPlanner.gui.find("**/activitiesButtonUp_down"), self.partyPlanner.gui.find("**/activitiesButtonUp_rollover"), self.partyPlanner.gui.find("**/activitiesButtonUp_inactive"), ), decButton_relief = None, decButton_pos = (-0.05, 0.0, -0.38), incButton_image = (self.partyPlanner.gui.find("**/activitiesButtonDown_up"), self.partyPlanner.gui.find("**/activitiesButtonDown_down"), self.partyPlanner.gui.find("**/activitiesButtonDown_rollover"), self.partyPlanner.gui.find("**/activitiesButtonDown_inactive"), ), incButton_relief = None, incButton_pos = (-0.05, 0.0, -0.94), # itemFrame is a DirectFrame itemFrame_pos = (pos[0], pos[1], pos[2]+0.04), itemFrame_relief = None, # each item is a button with text on it numItemsVisible = 1, items = [], ) for activityId in PartyGlobals.PartyEditorActivityOrder: if activityId in PartyGlobals.VictoryPartyActivityIds: holidayIds = base.cr.newsManager.getHolidayIdList() if ToontownGlobals.VICTORY_PARTY_HOLIDAY in holidayIds: pele = PartyEditorListElement(self, activityId) self.elementList.addItem(pele) elif activityId in PartyGlobals.VictoryPartyReplacementActivityIds: holidayIds = base.cr.newsManager.getHolidayIdList() if not ToontownGlobals.VICTORY_PARTY_HOLIDAY in holidayIds: pele = PartyEditorListElement(self, activityId) self.elementList.addItem(pele) else: pele = PartyEditorListElement(self, activityId) self.elementList.addItem(pele) if activityId == PartyGlobals.ActivityIds.PartyClock: self.partyClockElement = pele for decorationId in PartyGlobals.DecorationIds: decorName = PartyGlobals.DecorationIds.getString(decorationId) if (decorName == "HeartTarget") \ or (decorName == "HeartBanner") \ or (decorName == "FlyingHeart"): holidayIds = base.cr.newsManager.getHolidayIdList() if ToontownGlobals.VALENTINES_DAY in holidayIds: pele = PartyEditorListElement(self, decorationId, isDecoration=True) self.elementList.addItem(pele) elif decorationId in PartyGlobals.VictoryPartyDecorationIds: holidayIds = base.cr.newsManager.getHolidayIdList() if ToontownGlobals.VICTORY_PARTY_HOLIDAY in holidayIds: pele = PartyEditorListElement(self, decorationId, isDecoration=True) self.elementList.addItem(pele) elif decorationId in PartyGlobals.VictoryPartyReplacementDecorationIds: holidayIds = base.cr.newsManager.getHolidayIdList() if not ToontownGlobals.VICTORY_PARTY_HOLIDAY in holidayIds: pele = PartyEditorListElement(self, decorationId, isDecoration=True) self.elementList.addItem(pele) else: pele = PartyEditorListElement(self, decorationId, isDecoration=True) self.elementList.addItem(pele) self.elementList.refresh() self.elementList['command'] = self.scrollItemChanged
def load(self): base.cr.renderFrame() base.camLens.setMinFov(CIGlobals.DefaultCameraFov / (4./3.)) self.__setupStageToon() holidayMgr = base.cr.holidayManager self.props = [] self.world = loader.loadModel('phase_9/models/cogHQ/SellbotHQExterior.bam') self.world.reparentTo(base.render) self.world.setPos(0, 227.09, -25.36) self.sky = loader.loadModel('phase_9/models/cogHQ/cog_sky.bam') self.sky.setScale(1) self.sky.reparentTo(base.render) self.sky.find('**/InnerGroup').removeNode() self.fog = Fog('charSelectFog') self.fog.setColor(0.2, 0.2, 0.2) self.fog.setExpDensity(0.003) base.render.setFog(self.fog) # Let's fix the flickering doors. doors = self.world.find('**/doors').getChildren() for door in doors: for frameHole in door.findAllMatches('**/doorFrameHole*'): frameHole.removeNode() if holidayMgr.getHoliday() == HolidayType.CHRISTMAS: piles = { 'half' : {'pos' : (57.28, 86.47, -25.00), 'hpr' : (46.79, 0, 0)}, 'full' : {'pos' : (71.23, 85.2, -25.00), 'hpr' : (290.82, 0, 0)}, 'half_2' : {'pos' : (-15, 128.69, -25), 'hpr' : (60.26, 0, 0)} } for pileType, info in piles.items(): if '_' in pileType: pileType = pileType[:-2] pile = loader.loadModel('phase_8/models/props/snow_pile_%s.bam' % (pileType)) pile.reparentTo(render) pile.setPos(info['pos']) pile.setHpr(info['hpr']) self.props.append(pile) self.world.find('**/TopRocks').removeNode() snowTxt = loader.loadTexture('winter/maps/sbhq_snow.png') self.world.find('**/Ground').setTexture(snowTxt, 1) self.particles = ParticleLoader.loadParticleEffect('phase_8/etc/snowdisk.ptf') self.particles.setPos(0, 0, 5) self.particlesRender = self.world.attachNewNode('snowRender') self.particlesRender.setDepthWrite(0) self.particlesRender.setBin('fixed', 1) self.particles.start(parent = camera, renderParent = self.particlesRender) self.fog.setColor(0.486, 0.784, 1) self.fog.setExpDensity(0.006) base.render.setFog(self.fog) self.title = DirectLabel(text=self.TITLE, text_font=CIGlobals.getMickeyFont(), text_fg=(1, 0.9, 0.1, 1), relief=None, text_scale=0.13, pos=(0, 0, 0.82)) self.charNameLabel = OnscreenText(text = "", font = CIGlobals.getMickeyFont(), pos = (-0.25, 0.5, 0), fg = (1, 0.9, 0.1, 1.0)) self.charNameLabel.hide() self.frame = DirectFrame() self.frame['image'] = DGG.getDefaultDialogGeom() self.frame['image_color'] = CIGlobals.DialogColor self.frame['image_scale'] = (-0.9, -0.9, 0.8) self.frame['image_pos'] = (0.82, 0, -0.125) self.playOrCreateButton = DirectButton(text = "", pos = (0.8125, 0, -0.35), command = self.__action, geom = CIGlobals.getDefaultBtnGeom(), text_scale = 0.06, relief = None, text_pos = (0, -0.01)) self.playOrCreateButton.hide() self.deleteButton = DirectButton(text = "Delete", pos = (0.8125, 0, -0.45), command = self.__action, extraArgs = ['delete'], geom = CIGlobals.getDefaultBtnGeom(), text_scale = 0.06, relief = None, text_pos = (0, -0.01)) self.deleteButton.hide() self.quitButton = DirectButton(text = "Quit", pos = (-1.10, 0, -0.925), command = self.__action, extraArgs = ['quit'], text_scale = 0.06, geom = CIGlobals.getDefaultBtnGeom(), relief = None, text_pos = (0, -0.01)) textRolloverColor = Vec4(1, 1, 0, 1) textDownColor = Vec4(0.5, 0.9, 1, 1) textDisabledColor = Vec4(0.4, 0.8, 0.4, 1) for slot in range(6): if self.avChooser.hasToonInSlot(slot): choice = self.avChooser.getAvChoiceBySlot(slot) text = choice.name else: text = self.NO_TOON btn = DirectButton( relief=None, text = text, text_scale=0.06, text_align=TextNode.ALeft, text1_bg=textDownColor, text2_bg=textRolloverColor, text3_fg=textDisabledColor, textMayChange=0, command=self.__handleCharButton, extraArgs=[slot], text_pos = (0, 0, 0.0) ) btn.setPythonTag('slot', slot) self.charButtons.append(btn) btn['state'] = DGG.NORMAL gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui.bam') listXorigin = -0.02 listFrameSizeX = 0.625 listZorigin = -0.43 listFrameSizeZ = 0.51 arrowButtonScale = 0.0 itemFrameXorigin = -0.237 itemFrameZorigin = 0.365 buttonXstart = itemFrameXorigin + 0.293 self.charList = DirectScrolledList( relief=None, pos=(0.75, 0, -0.225), incButton_image=None, #incButton_relief=None, incButton_scale=(arrowButtonScale, arrowButtonScale, -arrowButtonScale), #incButton_pos=(buttonXstart, 0, itemFrameZorigin - 0.999), #incButton_image3_color=Vec4(1, 1, 1, 0.2), decButton_image=None, #decButton_relief=None, decButton_scale=(arrowButtonScale, arrowButtonScale, arrowButtonScale), #decButton_pos=(buttonXstart, 0, itemFrameZorigin + 0.125), #decButton_image3_color=Vec4(1, 1, 1, 0.2), itemFrame_pos=(itemFrameXorigin, 0, itemFrameZorigin), itemFrame_scale=1.0, itemFrame_relief=DGG.SUNKEN, itemFrame_frameSize=(listXorigin, listXorigin + listFrameSizeX, listZorigin, listZorigin + listFrameSizeZ), itemFrame_frameColor=(0.85, 0.95, 1, 1), itemFrame_borderWidth=(0.01, 0.01), numItemsVisible=15, forceHeight=0.075, items=self.charButtons, parent = self.frame ) base.camera.setPos(75.12, 63.22, -23) base.camera.setHpr(26.57, 9.62, 0)