def _create_text_fields(self, radius, width): test_letter = 'W' # the larger back side text field x, z = 0, 0 y = (width / 2.0 + Hexagon.text_distance) text = TextNode('') #font = loader.loadFont("cmss12.egg") #text.setFont(font) text.setGlyphScale(1.1 * radius) text.setTextColor(0, 0, 0, 1) self.back_side_text = self.root_node_path.attachNewNode(text) self.back_side_text.node().setText(test_letter) self.back_side_text.setH(180) center_node_on_xyz(self.back_side_text, x, y, z) self.back_side_text_z = self.back_side_text.getZ() # the six front side text fields self.front_side_text_coordinates = [] for _i, phi in enumerate(range(0, 360, 60)): text = TextNode('') #text.setFont(font) text.setGlyphScale(0.45 * radius) text.setTextColor(0, 0, 0, 1) text_path = self.root_node_path.attachNewNode(text) self.front_side_text.append(text_path) x, z = rotate_phi_degrees_clockwise(phi, (0, radius / 1.6)) text_path.node().setText(test_letter) center_node_on_xyz(text_path, x, -y, z) self.front_side_text_coordinates.append((x, -y, z))
def __init__(self, description, needed, icon): NodePath.__init__(self, 'objective-%s' % id(self)) self.needed = needed self.visible = False self.fadeInTrack = None self.fadeOutTrack = None gui = loader.loadModel( 'phase_5/models/cogdominium/tt_m_gui_csa_flyThru') self.background = gui.find('**/*background').copyTo(self) self.background.setScale(2.5) gui.removeNode() self.icon = icon.copyTo(self.background) self.icon.setScale(0.08) self.icon.setPos(-0.167, 0, -0.002) text = TextNode('challenge') text.setText('Challenge') text.setFont(ToontownGlobals.getSignFont()) text.setTextColor(0.95, 0.95, 0, 1) self.objText = self.background.attachNewNode(text) self.objText.setScale(0.03) self.objText.setPos(-0.04, 0.0, 0.02) text = TextNode('description') text.setText(description) text.setFont(ToontownGlobals.getSignFont()) text.setTextColor(0.95, 0.95, 0, 1) text.setAlign(TextNode.ACenter) self.objText = self.background.attachNewNode(text) self.objText.setScale(0.015) self.objText.setPos(0.048, 0.0, -0.009) self.progressBar = DirectWaitBar(guiId='ChallengeProgressBar', parent=self.background, frameSize=(-0.11, 0.11, -0.007, 0.007), pos=(0.048, 0, -0.0338), text='') self.progressBar['range'] = needed self.progressText = DirectLabel( guiId='ChallengeProgressText', parent=self.progressBar, relief=None, pos=(0, 0, -0.0048), text='', textMayChange=1, text_scale=0.014, text_fg=(0.03, 0.83, 0, 1), text_align=TextNode.ACenter, text_font=ToontownGlobals.getSignFont()) self.updateProgress(0) self.reparentTo(base.a2dBottomLeft) self.stash()
def __init__(self): self.avatar = None self.panel = None self.icon = None self.chatBalloon = None self.chatButton = NametagGlobals.noButton self.chatReversed = False self.font = None self.chatFont = None self.chatType = NametagGlobals.CHAT self.chatBalloonType = NametagGlobals.CHAT_BALLOON self.nametagColor = NametagGlobals.NametagColors[NametagGlobals.CCNormal] self.chatColor = NametagGlobals.ChatColors[NametagGlobals.CCNormal] self.speedChatColor = self.chatColor[0][1] self.nametagHidden = False self.chatHidden = False self.thoughtHidden = False self.textNode = TextNode('text') self.textNode.setWordwrap(self.TEXT_WORD_WRAP) self.textNode.setAlign(TextNode.ACenter) self.chatTextNode = TextNode('chatText') self.chatTextNode.setWordwrap(self.CHAT_TEXT_WORD_WRAP) self.chatTextNode.setGlyphScale(ChatBalloon.TEXT_GLYPH_SCALE) self.chatTextNode.setGlyphShift(ChatBalloon.TEXT_GLYPH_SHIFT) self.tickTaskName = self.getUniqueName() + '-tick' self.tickTask = taskMgr.add(self.tick, self.tickTaskName, sort=45)
def load(self, loadModels=1, arenaModel='partyCatchTree'): self.notify.info('load()') DistributedPartyCatchActivity.notify.debug('PartyCatch: load') self.activityFSM = CatchActivityFSM(self) self.defineConstants() self.treesAndFence = loader.loadModel('phase_13/models/parties/%s' % arenaModel) self.treesAndFence.setScale(0.9) self.treesAndFence.find('**/fence_floor').setPos(0.0, 0.0, 0.1) self.treesAndFence.reparentTo(self.root) ground = self.treesAndFence.find('**/groundPlane') ground.setBin('ground', 1) DistributedPartyActivity.load(self) exitText = TextNode('PartyCatchExitText') exitText.setCardAsMargin(0.1, 0.1, 0.1, 0.1) exitText.setCardDecal(True) exitText.setCardColor(1.0, 1.0, 1.0, 0.0) exitText.setText(TTLocalizer.PartyCatchActivityExit) exitText.setTextColor(0.0, 8.0, 0.0, 0.9) exitText.setAlign(exitText.ACenter) exitText.setFont(ToontownGlobals.getBuildingNametagFont()) exitText.setShadowColor(0, 0, 0, 1) exitText.setBin('fixed') if TTLocalizer.BuildingNametagShadow: exitText.setShadow(*TTLocalizer.BuildingNametagShadow) exitTextLoc = self.treesAndFence.find('**/loc_exitSignText') exitTextNp = exitTextLoc.attachNewNode(exitText) exitTextNp.setDepthWrite(0) exitTextNp.setScale(4) exitTextNp.setZ(-.5) self.sign.reparentTo(self.treesAndFence.find('**/loc_eventSign')) self.sign.wrtReparentTo(self.root) self.avatarNodePath = NodePath('PartyCatchAvatarNodePath') self.avatarNodePath.reparentTo(self.root) self._avatarNodePathParentToken = 3 base.cr.parentMgr.registerParent(self._avatarNodePathParentToken, self.avatarNodePath) self.toonSDs = {} self.dropShadow = loader.loadModelOnce( 'phase_3/models/props/drop_shadow') self.dropObjModels = {} if loadModels: self.__loadDropModels() self.sndGoodCatch = base.loader.loadSfx( 'phase_4/audio/sfx/SZ_DD_treasure.ogg') self.sndOof = base.loader.loadSfx( 'phase_4/audio/sfx/MG_cannon_hit_dirt.ogg') self.sndAnvilLand = base.loader.loadSfx( 'phase_4/audio/sfx/AA_drop_anvil_miss.ogg') self.sndPerfect = base.loader.loadSfx( 'phase_4/audio/sfx/ring_perfect.ogg') self.__textGen = TextNode('partyCatchActivity') self.__textGen.setFont(ToontownGlobals.getSignFont()) self.__textGen.setAlign(TextNode.ACenter) self.activityFSM.request('Idle')
def newGame(self): ''' The select vehicle screen ''' base.enableParticles() self.countdown = COUNTDOWN_START # the countdown, when its over the game can be started self._notify.info("Initializing new game") # GlobPattern if we need a Panda Class self.vehicle_list = glob.glob("data/models/vehicles/*.egg") for index in range(len(self.vehicle_list)): self.vehicle_list[index] = Filename.fromOsSpecific( self.vehicle_list[index]).getFullpath() self._notify.debug("Vehicle list: %s" % (self.vehicle_list)) self.platform = loader.loadModel("data/models/platform.egg") # Loading-Text that gets displayed when loading a model text = TextNode("Loading") text.setFont(self.font) text.setText(_("Loading...")) text.setAlign(TextProperties.ACenter) self.loading = NodePath("LoadingNode") self.loading.attachNewNode(text) self.loading.setPos(0, 0, 2) # The countdown, its possible to start the game when its 0 text = TextNode("Countdown") text.setFont(self.font) text.setAlign(TextProperties.ACenter) text.setText(_(str(COUNTDOWN_START))) self.countdown_node = NodePath("Countdown") self.countdown_node.attachNewNode(text) self.countdown_node.setPos(0, 0, 4) # PreLoad the description that gets displayed when loading a model text = TextNode("name") text.setFont(self.font) text.setText(_("Loading...")) text.setAlign(TextProperties.ACenter) self.attributes = NodePath("AttributeNode") self.attributes.attachNewNode(text) self.unusedDevices = self._devices.devices[:] taskMgr.add(self.collectPlayer, "collectPlayer") # taskMgr.add(self.collectWii, "collectWii") self.screens = [] taskMgr.add(self.selectVehicle, "selectVehicle") self.color_red = Vec4(1, 0, 0, 0) self.color_green = Vec4(0, 1, 0, 0) self._notify.info("New game initialized")
def __createCurrentModeLabel(self): self.text = TextNode('node name') self.text.setText("Current mode: None") self.textNodePath = aspect2d.attachNewNode(self.text) self.textNodePath.setScale(0.03) self.textNodePath.setX(-base.getAspectRatio() - 0.2) self.textNodePath.setZ(-0.95)
def __init__(self, bat_np, t, x, y, col): rate = 2 z = 20 scale = 12 scale_up = 15 text_node = TextNode("battle_text") text_node.setText(t) text_node_path = bat_np.attachNewNode(text_node) text_node_path.reparentTo(render) text_node_path.setPos(x, y, 0) text_node_path.setHpr(0, -90, 0) text_node_path.setScale(scale) text_node_path.setTransparency(TransparencyAttrib.MAlpha) text_node.setTextColor(col) text_node.setAlign(TextNode.ACenter) node_scl_up = text_node_path.scaleInterval( rate, Point3(scale_up, scale_up, scale_up)) node_z_up = text_node_path.posInterval(rate, Point3(x, y, z * 2)) node_z_up2 = text_node_path.posInterval(rate, Point3(x, y, z * 2)) node_fade_down = text_node_path.colorScaleInterval( rate, (col[0], col[1], col[2], 0)) node_func_death = Func(self.destroy) t_para = Parallel(node_scl_up, node_z_up, node_fade_down) t_seq = Sequence(t_para, node_func_death) t_seq.start() self.tnp = text_node_path
def addPicture(self, x, y, h, row, col): if not probability(self.picturesConcentration): return i = random.randint(0, len(self.pictures) - 1) pictureText = self.pictures[i] if (row, col) in self.solution: pictureText = addMessage(pictureText, "you're on the right track!") else: pictureText = addMessage(pictureText, "looks like you took a wrong turn!") z = 66 text = TextNode('node name') text.setCardColor(1, 1, 1, 1) # white text.setCardAsMargin(0, 0, 0, 0) text.setCardDecal(True) #contentsRead = readFile("mickeyText.txt") text.setText(pictureText) text.setAlign(TextNode.ALeft) font = loader.loadFont( 'Menlo.ttf' ) # font dowloaded from : "http://www.onlinewebfonts.com" text.setFont(font) text.setFrameColor(0, 0, 0, 1) # black, and not transparent text.setTextColor(0, 0, 0, 1) # black, and not transparent text.setFrameAsMargin(0.2, 0.2, 0.1, 0.1) #specifying margins for frame text.setShadow(0.05, 0.05) text.setShadowColor(0, 0, 0, 1) textNodePath = self.render.attachNewNode(text) textNodePath.setPos(x, y, z) textNodePath.setHpr(h, 0, 0) textNodePath.setScale(0.6)
def loadSign(self): actNameForSign = self.activityName if self.activityId == PartyGlobals.ActivityIds.PartyJukebox40: actNameForSign = PartyGlobals.ActivityIds.getString( PartyGlobals.ActivityIds.PartyJukebox) elif self.activityId == PartyGlobals.ActivityIds.PartyDance20: actNameForSign = PartyGlobals.ActivityIds.getString( PartyGlobals.ActivityIds.PartyDance) self.sign = self.root.attachNewNode('%sSign' % self.activityName) self.signModel = self.party.defaultSignModel.copyTo(self.sign) self.signFlat = self.signModel.find('**/sign_flat') self.signFlatWithNote = self.signModel.find('**/sign_withNote') self.signTextLocator = self.signModel.find('**/signText_locator') textureNodePath = getPartyActivityIcon(self.party.activityIconsModel, actNameForSign) textureNodePath.setPos(0.0, -0.02, 2.2) textureNodePath.setScale(2.35) textureNodePath.copyTo(self.signFlat) textureNodePath.copyTo(self.signFlatWithNote) text = TextNode('noteText') text.setTextColor(0.2, 0.1, 0.7, 1.0) text.setAlign(TextNode.ACenter) text.setFont(OTPGlobals.getInterfaceFont()) text.setWordwrap(10.0) text.setText('') self.noteText = self.signFlatWithNote.attachNewNode(text) self.noteText.setPosHpr(self.signTextLocator, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0) self.noteText.setScale(0.2) self.signFlatWithNote.stash() self.signTextLocator.stash()
def attachHostNameToSign(self, locator): if self.hostName == '': return nameText = TextNode('nameText') nameText.setCardAsMargin(0.1, 0.1, 0.1, 0.1) nameText.setCardDecal(True) nameText.setCardColor(1.0, 1.0, 1.0, 0.0) r = 232.0 / 255.0 g = 169.0 / 255.0 b = 23.0 / 255.0 nameText.setTextColor(r, g, b, 1) nameText.setAlign(nameText.ACenter) nameText.setFont(ToontownGlobals.getBuildingNametagFont()) nameText.setShadowColor(0, 0, 0, 1) nameText.setBin('fixed') if TTLocalizer.BuildingNametagShadow: nameText.setShadow(*TTLocalizer.BuildingNametagShadow) nameWordWrap = 11.0 nameText.setWordwrap(nameWordWrap) scaleMult = 0.48 houseName = self.hostName nameText.setText(houseName) textWidth = nameText.getWidth() xScale = 1.0 * scaleMult if textWidth > nameWordWrap: xScale = nameWordWrap / textWidth * scaleMult sign_origin = locator namePlate = sign_origin.attachNewNode(nameText) namePlate.setDepthWrite(0) namePlate.setPos(0, 0, 0) namePlate.setScale(xScale)
def loadGUI(self): self.gui = loader.loadModel('phase_13/models/parties/trampolineGUI') self.gui.reparentTo(base.a2dTopLeft) self.gui.setPos(0.115, 0, -1) self.gui.hide() self.toonIndicator = self.gui.find('**/trampolineGUI_MovingBar') jumpLineLocator = self.gui.find('**/jumpLine_locator') guiBean = self.gui.find('**/trampolineGUI_GreenJellyBean') self.gui.find('**/trampolineGUI_GreenJellyBean').stash() self.guiBeans = [ guiBean.instanceUnderNode(jumpLineLocator, self.uniqueName('guiBean%d' % i)) for i in xrange(self.numJellyBeans) ] self.guiBeans[-1].setScale(1.5) heightTextNode = TextNode(self.uniqueName('TrampolineActivity.heightTextNode')) heightTextNode.setFont(ToontownGlobals.getSignFont()) heightTextNode.setAlign(TextNode.ALeft) heightTextNode.setText('0.0') heightTextNode.setShadow(0.05, 0.05) heightTextNode.setShadowColor(0.0, 0.0, 0.0, 1.0) heightTextNode.setTextColor(1.0, 1.0, 1.0, 1.0) self.heightText = jumpLineLocator.attachNewNode(heightTextNode) self.heightText.setX(0.15) self.heightText.setScale(0.1) self.heightText.setAlphaScale(0.0) self.quitEarlyButtonModels = loader.loadModel('phase_3.5/models/gui/inventory_gui') quitEarlyUp = self.quitEarlyButtonModels.find('**//InventoryButtonUp') quitEarlyDown = self.quitEarlyButtonModels.find('**/InventoryButtonDown') quitEarlyRollover = self.quitEarlyButtonModels.find('**/InventoryButtonRollover') self.quitEarlyButton = DirectButton(parent=base.a2dTopRight, relief=None, text=TTLocalizer.PartyTrampolineQuitEarlyButton, text_fg=(1, 1, 0.65, 1), text_pos=(0, -0.23), text_scale=0.7, image=(quitEarlyUp, quitEarlyDown, quitEarlyRollover), image_color=(1, 0, 0, 1), image_scale=(20, 1, 11), pos=(-0.183, 0, -0.4), scale=0.09, command=self.leaveTrampoline) self.quitEarlyButton.stash() self.flashText = OnscreenText(text='', pos=(0.0, -0.45), scale=0.2, fg=(1.0, 1.0, 0.65, 1.0), align=TextNode.ACenter, font=ToontownGlobals.getSignFont(), mayChange=True) self.timer = PartyUtils.getNewToontownTimer() self.timer.posInTopRightCorner() return
def fontHasCharacters(name, font=font): if font: tn = TextNode('NameCheck') tn.setFont(font) for c in name: if not tn.hasCharacter(ord(c)): notify.info('name contains bad char: %s' % TextEncoder().encodeWtext(c)) return OTPLocalizer.NCBadCharacter % TextEncoder().encodeWtext(c)
def printText(name, message, color): text = TextNode(name) text.setText(message) x, y, z = color text.setTextColor(x, y, z, 1) text3d = NodePath(text) text3d.reparentTo(render) return text3d
def printText(self, name, message, color, parent=render): text = TextNode(name) # create a TextNode. Note that 'name' is not the text, rather it is a name that identifies the object. text.setText(message) # Here we set the text of the TextNode x,y,z = color # break apart the color tuple text.setTextColor(x,y,z, 1) # Set the text color from the color tuple text3d = NodePath(text) # Here we create a NodePath from the TextNode, so that we can manipulate it 'in world' text3d.reparentTo(parent) return text3d # return the NodePath for further use
def genTextNode(T): global aspect2d txt = TextNode(T) txt.setText(T) txtNode = aspect2d.attachNewNode(txt) txtNode.setScale(0.1) txtNode.setPos(Vec3(-1.0, 0, 0.92)) txt.setTextColor(1,0,0,1) return txt
def splashScreenCreate(self, number): text1a = " Urgent message from ur PC:" text1b = "XyzBugz234VirusThingamajig, a very competent virus has taken over your computer..." text1c = " It has also managed to put you in a virtual ASCII maze in your computer! " text1d = " (because thats a thing that can happen) " text2a = "But dont worry, the antivirus software installed on your computer 'BFREE4EVR' will help you escape..." text2b = "Drag your favorite pictures (preferably jpeg) to the 'pictures' folder in the directory of the game. " text2c = "You'll see these pictures in ASCII format in the maze. BFREE4EVR will add messages in these pictures to help guide you." text2d = "Look for the hidden message in each picture you see; it will tell you whether you're om the right track or not." text2e = "if you're not on the right track, you should 'backtrack' to the last turn (hint ;) )" text3a = "Find the flag to complete the maze! (the flag is the only object thats not in black and white)" text3b = "Press 'h' at any time to toggle the help mini-sreen once the game starts." text3c = "There is also a helpful mini-map in the bottom right corner of ur screen, that shows the cells of the maze you've visited" text3d = "Be sure to solve the maze within the time limit indicated in the top left corner, or ur pc will b compromised." text3e = "However, the first level does not have a timer, so you can get comfortable with the controls" text3f = "The pictures may look glitchy because of the virus. You have to search them from a close distance. Good luck!" subtext = "[press q to continue]" text4a = "This is a buffer screen. Please dont panic. 'BFREE4EVR' is doing its thing. " text4b = "This may take anywhere from 30 seconds (regular case) to an eternity depending on how shitty ur pc is." text4d = "Oh! Almost forgot, policy requires that u provide BFREE4EVR consent to run on ur pc " text4c = "...\n...\n...\n...\n...\n...\n..." text4e = "[press q to provide consent and agree to terms and conditions etc and continue with loading game]" text4f = "...................This is another buffer screen................." text4g = "press q to start loading model, and then wait a while" if number == 1: splashText = "\n".join([text1a, text1b, text1c, text1d, subtext]) if number == 2: splashText = "\n".join( [text2a, text2b, text2c, text2d, text2e, subtext]) if number == 3: splashText = "\n".join( [text3a, text3b, text3c, text3d, text3e, text3f, subtext]) #if number ==4:splashText = "\n".join([text4a,text4b]) if number == 4: if self.instance == 0: splashText = "\n".join( [text4a, text4b, text4c, text4d, text4e]) else: splashText = "\n".join([text4f, text4g]) text = TextNode('meh') text.setCardColor(1, 1, 1, 1) # white text.setCardAsMargin(0.2, 0.2, 20, 0.2) text.setCardDecal(True) text.setText(splashText) text.setAlign(TextNode.ALeft) text.setFrameColor(0, 0, 0, 1) # black, and not transparent text.setTextColor(0, 0, 0, 1) # black, and not transparent text.setFrameAsMargin(0.2, 0.2, 20, 0.2) #specifying margins for frame text.setShadow(0.05, 0.05) text.setShadowColor(0, 0, 0, 1) textNodePath = self.aspect2d.attachNewNode(text) self.splashTextObject = textNodePath textNodePath.setPos(-1.1, 0, 0.8) textNodePath.setScale(0.1) text.setWordwrap(22)
def _createPartyEditorPage(self): page = DirectFrame(self.frame) page.setName('PartyPlannerEditorPage') self.LayoutTitleLabel = DirectLabel(parent=page, relief=None, text=TTLocalizer.PartyPlannerEditorTitle, pos=self.gui.find('**/title_locator').getPos() + Point3(0.0, 0.0, 0.075), scale=self.titleScale) self.costLabel = DirectLabel(parent=page, pos=(-0.74, 0.0, 0.17), relief=None, text=TTLocalizer.PartyPlannerTotalCost % 0, text_align=TextNode.ACenter, scale=TTLocalizer.PPcostLabel, textMayChange=True) self.partyGridBackground = DirectFrame(parent=page, relief=None, geom=self.gui.find('**/partyGrid_flat')) self.partyGroundsLabel = DirectLabel(parent=page, relief=None, text=TTLocalizer.PartyPlannerPartyGrounds, text_font=ToontownGlobals.getSignFont(), text_fg=VBase4(1.0, 0.0, 0.0, 1.0), text_scale=TTLocalizer.PPpartyGroundsLabel, pos=self.gui.find('**/step_05_partyGrounds_text_locator').getPos(), scale=0.1) self.activityBackground = DirectFrame(parent=page, relief=None, geom=self.gui.find('**/activitiesDecorations_flat1'), pos=(0.0, 0.0, 0.04)) pos = self.gui.find('**/step_05_instructions_locator').getPos() self.instructionLabel = DirectLabel(parent=page, relief=None, text=' ', text_pos=(pos[0], pos[2]), text_scale=TTLocalizer.PPinstructionLabel, textMayChange=True, geom=self.gui.find('**/instructions_flat')) self.elementTitleLabel = DirectLabel(parent=page, relief=None, text=' ', pos=self.gui.find('**/step_05_activitiesName_text_locator').getPos() + Point3(0.0, 0.0, 0.04), text_scale=TTLocalizer.PPelementTitleLabel, textMayChange=True) self.elementPriceNode = TextNode('ElementPrice') self.elementPriceNode.setAlign(TextNode.ALeft) self.elementPriceNode.setTextColor(0.0, 0.0, 0.0, 1.0) self.elementPriceNode.setFont(ToontownGlobals.getToonFont()) self.elementPrice = page.attachNewNode(self.elementPriceNode) self.elementPrice.setScale(TTLocalizer.PPelementPriceNode) self.elementPrice.setPos(self.gui.find('**/step_05_activityPrice_text_locator').getPos() + Point3(-0.02, 0.0, 0.04)) self.elementDescriptionNode = TextNode('ElementDescription') self.elementDescriptionNode.setAlign(TextNode.ACenter) self.elementDescriptionNode.setWordwrap(8) self.elementDescriptionNode.setFont(ToontownGlobals.getToonFont()) self.elementDescriptionNode.setTextColor(0.0, 0.0, 0.0, 1.0) self.elementDescription = page.attachNewNode(self.elementDescriptionNode) self.elementDescription.setScale(TTLocalizer.PPelementDescription) self.elementDescription.setPos(self.gui.find('**/step_05_activityDescription_text_locator').getPos() + Point3(0.0, 0.0, 0.04)) self.totalMoney = base.localAvatar.getTotalMoney() catalogGui = loader.loadModel('phase_5.5/models/gui/catalog_gui') self.beanBank = DirectLabel(parent=page, relief=None, text=str(self.totalMoney), text_align=TextNode.ARight, text_scale=0.075, text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1), text_pos=(0.495, -0.53), text_font=ToontownGlobals.getSignFont(), textMayChange=True, image=catalogGui.find('**/bean_bank'), image_scale=(0.65, 0.65, 0.65), scale=0.9, pos=(-0.75, 0.0, 0.6)) catalogGui.removeNode() del catalogGui self.accept(localAvatar.uniqueName('moneyChange'), self.__moneyChange) self.accept(localAvatar.uniqueName('bankMoneyChange'), self.__moneyChange) self.partyEditor = PartyEditor(self, page) self.partyEditor.request('Hidden') pos = self.gui.find('**/step_05_add_text_locator').getPos() self.elementBuyButton = DirectButton(parent=page, relief=None, text=TTLocalizer.PartyPlannerBuy, text_pos=(pos[0], pos[2]), text_scale=TTLocalizer.PPelementBuyButton, geom=(self.gui.find('**/add_up'), self.gui.find('**/add_down'), self.gui.find('**/add_rollover')), geom3_color=VBase4(0.5, 0.5, 0.5, 1.0), textMayChange=True, pos=(0.0, 0.0, 0.04), command=self.partyEditor.buyCurrentElement) self.okWithPartyGroundsLayoutEvent = 'okWithPartyGroundsLayoutEvent' self.accept(self.okWithPartyGroundsLayoutEvent, self.okWithPartyGroundsLayout) self.okWithGroundsGui = TTDialog.TTGlobalDialog(dialogName=self.uniqueName('PartyEditorOkGui'), doneEvent=self.okWithPartyGroundsLayoutEvent, message=TTLocalizer.PartyPlannerOkWithGroundsLayout, style=TTDialog.YesNo, okButtonText=OTPLocalizer.DialogYes, cancelButtonText=OTPLocalizer.DialogNo) self.okWithGroundsGui.doneStatus = '' self.okWithGroundsGui.hide() return page
def createDistanceLabel(self, number, color): text = TextNode('distanceText-%d' % number) text.setAlign(TextNode.ACenter) text.setTextColor(color) text.setFont(ToontownGlobals.getSignFont()) text.setText('10 ft') node = self.root.attachNewNode(text) node.setBillboardPointEye() node.setScale(2.5) node.setZ(5.0) return node, text
def createText(self, number, position, color): text = TextNode('winText%d' % number) text.setAlign(TextNode.ACenter) text.setTextColor(color) text.setFont(ToontownGlobals.getSignFont()) text.setText('') noteText = aspect2d.attachNewNode(text) noteText.setScale(0.2) noteText.setPos(position) noteText.stash() return text, noteText
def writeTextToScreen(self, x, y, z, wordwrap=10): """Write the text""" self.myText = TextNode(self.text) self.myText.setText(self.text) myFont = loader.loadFont(self.font) self.myText.setFont(myFont) self.myText.setWordwrap(wordwrap) self.textNodePath = self.parent.attachNewNode(self.myText) self.textNodePath.setScale(self.scale) #self.textNodePath.setBillboardPointEye() self.setMyPosition(x, y, z) self.textNodePath.setTransparency(1)
def addOption(self, name, function): ''' Add one option to the menu Node ''' text = TextNode(name) text.setFont(self.font) text.setText(name) self.options.append((name, function)) self.optionsModells.append( NodePath("test").attachNewNode(text)) # setPos fehlt self.optionsModells[-1].setColor(self.colorA) self.optionsModells[-1].setPos(0, 0, -len(self.optionsModells)) self.menuNode.attachNewNode(text)
def createMessage(self): """Write the text""" self.myText = TextNode(self.text) self.myText.setText(self.text) myFont = loader.loadFont(self.font) self.myText.setFont(myFont) self.myText.setWordwrap(40) self.textNodePath = aspect2d.attachNewNode(self.myText) self.textNodePath.setScale(self.scale) self.textNodePath.setPos(Vec3(self.x, 0, self.y)) self.textNodePath.setTransparency(1) self.textNodePath.setColor(globals.colors['guiyellow']) taskMgr.add(self.fadeMessage, 'fadeMessageTask')
def createTextCard(self): """Text Card stored current Scroll Value""" self.myText = TextNode('scrollValue') self.setCurrentValue(0) self.myText.setFont(self.font) self.myText.setCardColor(globals.colors['guiblue3']) self.myText.setFrameColor(globals.colors['guiblue2']) self.myText.setFrameAsMargin(0, 0, 0, 0) self.myText.setFrameLineWidth(3) self.myText.setCardAsMargin(.1, .1, .1, .1) textNodePath = aspect2d.attachNewNode(self.myText) textNodePath.setScale(0.09) textNodePath.setPos(self.posInitX - 0.04, 0, self.posInitY + 0.175) self.myWidgets.append(textNodePath)
def load(self): from toontown.toonbase import ToontownGlobals from pandac.PandaModules import TextNode textNode = TextNode('moviedialogue') textNode.setTextColor(0, 0, 0, 1) textNode.setCardColor(1, 1, 1, 1) textNode.setCardAsMargin(0, 0, 0, 0) textNode.setCardDecal(True) textNode.setWordwrap(27.0) textNode.setAlign(TextNode.ACenter) textNode.setFont(ToontownGlobals.getToonFont()) self._dialogueLabel = aspect2d.attachNewNode(textNode) self._dialogueLabel.setScale(0.06, 0.06, 0.06) self._dialogueLabel.setPos(0.32, 0, -0.75) self._dialogueLabel.reparentTo(hidden)
def createTitleCard(self, name, text, wordwrap, x, z, scale=0.025): """Default Title label for gui controls""" self.myTitle = TextNode(name) self.myTitle.setFont(self.font) self.myTitle.setText(text) self.myTitle.setWordwrap(wordwrap) self.myTitle.setTextColor(globals.colors['guiwhite']) self.myTitle.setCardColor(globals.colors['guiblue3']) self.myTitle.setFrameColor(globals.colors['guiblue2']) self.myTitle.setFrameAsMargin(.3, .5, .5, .5) self.myTitle.setFrameLineWidth(3) self.myTitle.setCardAsMargin(.3, .5, .5, .5) textNodePath = aspect2d.attachNewNode(self.myTitle) textNodePath.setScale(scale) textNodePath.setPos(x, 0, z) self.myWidgets.append(textNodePath)
def generatePage(self): pageText = '%s - %s' % (self.category, self.pageNum) self.textNode = TextNode(pageText) self.textNode.setText(pageText) self.textNode.setFont(ToontownGlobals.getInterfaceFont()) self.textNode = self.attachNewNode(self.textNode) self.textNode.setPos(*CatalogGlobals.ItemPageTextLoc) self.textNode.setScale(CatalogGlobals.ItemPageTextScale) self.textNode.setColor(0, 0, 0, 1) for (x, item) in enumerate(self.catalogItems): itemFrame = CatalogItemPanel(parent=self, parentCatalogScreen=self.parent, item=item) itemFrame.load() itemFrame.setPos(*CatalogGlobals.CatalogPropPos[x]) self.itemFrames.append(itemFrame)
def chat_create(self, n, scl): self.chat_labels = [] self.chat_nps = [] gap = 0.00 for l in range(n): #lbl = DirectLabel(text = "chatline"+str(l), text_fg = (1,1,1,1),text_mayChange = True, # pos=(0.05,0,-0.3+(0.5*l*(scl+0.08))), scale=scl, frameColor=(1,1,1,0), text_align = TextNode.ALeft) lbl = TextNode('node name') lbl.setText("") textNodePath = aspect2d.attachNewNode(lbl) textNodePath.setScale(scl) textNodePath.setColor(1, 1, 1, 1) textNodePath.setPos(0.05, 0, -0.3 + (0.5 * l * (scl + 0.08))) self.chat_nps.append(textNodePath) self.chat_labels.append(lbl) print "Chatbox created"
def __init__(self, name, parent, pos = (0.0, 0.0, -0.5), scale = 0.09, color = (1.0, 1.0, 0, 1), sfx = None): self.color = color self._displaySfx = sfx textNode = TextNode('messageLabel.' + name) textNode.setTextColor(self.color) textNode.setAlign(TextNode.ACenter) textNode.setFont(ToontownGlobals.getSignFont()) textNode.setShadow(0.06, 0.06) textNode.setShadowColor(0.5, 0.5, 0.5, 1.0) self.pos = pos self.scale = scale self.messageLabel = parent.attachNewNode(textNode) self.messageLabel.setPos(self.pos) self.messageLabel.setScale(self.scale) self.messageLabel.stash() self.transitionInterval = Sequence(name='%s.transitionInterval' % self.__class__.__name__)
def __init__(self, cr): DistributedMinigame.__init__(self, cr) self.gameFSM = ClassicFSM.ClassicFSM('DistributedCogThiefGame', [State.State('off', self.enterOff, self.exitOff, ['play']), State.State('play', self.enterPlay, self.exitPlay, ['cleanup']), State.State('cleanup', self.enterCleanup, self.exitCleanup, [])], 'off', 'cleanup') self.addChildGameFSM(self.gameFSM) self.cameraTopView = (0, 0, 55, 0, -90.0, 0) self.barrels = [] self.cogInfo = {} self.lastTimeControlPressed = 0 self.stolenBarrels = [] self.useOrthoWalk = base.config.GetBool('cog-thief-ortho', 1) self.resultIval = None self.gameIsEnding = False self.__textGen = TextNode('cogThiefGame') self.__textGen.setFont(ToontownGlobals.getSignFont()) self.__textGen.setAlign(TextNode.ACenter) return
def attachHostNameToSign(self, locator): if (self.hostName == ""): # don't bother putting an empty string up return nameText = TextNode('nameText') nameText.setCardAsMargin(0.1, 0.1, 0.1, 0.1) nameText.setCardDecal(True) nameText.setCardColor(1.0, 1.0, 1.0, 0.0) r = 232.0 /255.0 #self.randomGenerator.random() g = 169.0 / 255.0 #self.randomGenerator.random() b = 23.0 / 255.0 #self.randomGenerator.random() nameText.setTextColor(r,g,b,1) nameText.setAlign(nameText.ACenter) nameText.setFont(ToontownGlobals.getBuildingNametagFont()) nameText.setShadowColor(0, 0, 0, 1) nameText.setBin('fixed') if TTLocalizer.BuildingNametagShadow: nameText.setShadow(*TTLocalizer.BuildingNametagShadow) nameWordWrap = 11.0 nameText.setWordwrap(nameWordWrap) scaleMult = 0.48 #xScale = 1.0 * scaleMult #numLines = 0 houseName = self.hostName nameText.setText(houseName) #self.nameText = nameText # Since the text is wordwrapped, it may flow over more # than one line. Try to adjust the scale and position of # the sign accordingly. #textHeight = nameText.getHeight() - 2 textWidth = nameText.getWidth() xScale = 1.0 * scaleMult if textWidth > nameWordWrap: xScale = nameWordWrap / textWidth * scaleMult sign_origin = locator # self.house.find("**/sign_origin") #pos = sign_origin.getPos() #sign_origin.setPosHpr(pos[0],pos[1],pos[2]+.15*textHeight,90,0,0) namePlate = sign_origin.attachNewNode(nameText) namePlate.setDepthWrite(0) namePlate.setPos(0,0,0) namePlate.setScale(xScale)