class Ear(DirectObject.DirectObject): notify = DirectNotifyGlobal.directNotify.newCategory('Ear') def __init__(self, main=None): self.main = main.main self._parent = main._parent self.avatar = main.avatar self.mode = None self.load() return def enter(self): self.notify.debug('enter') self.showEarCollections() self.loadExtraArgs() if self.mode == None: self.mode = -1 return def exit(self): self.hide() def load(self): self.notify.debug('loading ear') self.setupButtons() self.loadGUI() self.loadExtraArgs() def loadGUI(self): global sliderRange customRange = (-1.0, 1.0) if self.main.wantMarketingViewer: sliderRange = (-1.0, 1.0) self.pgs1 = CharGuiSlider(self.main, parent=self.earFrame, text=PLocalizer.EarScale, range=sliderRange, command=self.updateControlShape) self.pgs1.setPos(-0.4, 0, -0.3) self.pgs2 = CharGuiSlider(self.main, parent=self.earFrame, text=PLocalizer.EarFlapAngle, range=sliderRange, command=self.updateControlShape) self.pgs2.setPos(-0.4, 0, -0.55) self.pgs3 = CharGuiSlider(self.main, parent=self.earFrame, text=PLocalizer.EarPosition, range=sliderRange, command=self.updateControlShape) self.pgs3.setPos(-0.4, 0, -0.8) self.pgs = [self.pgs1, self.pgs2, self.pgs3] def unload(self): self.notify.debug('called ear unload') del self.main del self._parent del self.avatar def loadExtraArgs(self): self.pgs1['extraArgs'] = [self.pgs1, 'earScale'] self.pgs2['extraArgs'] = [self.pgs2, 'earFlap'] self.pgs3['extraArgs'] = [self.pgs3, 'earPosition'] def showEarCollections(self): self.earFrame.show() def hideEarCollections(self): self.earFrame.hide() def hide(self): self.hideEarCollections() self.saveDNA() def setupButtons(self): self.earFrame = DirectFrame(parent=self._parent, relief=None, text=PLocalizer.EarFrameTitle, text_fg=(1, 1, 1, 1), text_scale=0.18, text_pos=(0, -0.05), pos=(0, 0, 0), scale=0.7) self.earFrame.hide() return def saveDNA(self): self.avatar.pirate.setEarScale(self.pgs1.node().getValue()) self.avatar.pirate.setEarFlapAngle(self.pgs2.node().getValue()) self.avatar.pirate.setEarPosition(self.pgs3.node().getValue()) def restore(self): self.pgs1.node().setValue(self.avatar.dna.getEarScale()) self.pgs2.node().setValue(self.avatar.dna.getEarFlapAngle()) self.pgs3.node().setValue(self.avatar.dna.getEarPosition()) def reset(self): for i in xrange(0, len(self.pgs)): self.resetSlider(self.pgs[i]) self.saveDNA() def resetSlider(self, slider): slider.node().setValue(0.0) def randomPick(self): global damper damper = 1.0 for i in xrange(0, len(self.pgs)): slider = self.pgs[i] self.resetSlider(slider) if random.choice([0, 1]): value = random.random() * damper toss = 0 if slider['range'][0] < 0: toss = random.choice([0, 1]) if toss: slider.node().setValue(-value) else: slider.node().setValue(value) self.saveDNA() def updateControlShape(self, pgs, extraArgs1=None, extraArgs2=None): if extraArgs1 != None: self.avatar.pirate.setControlValue(pgs.node().getValue(), extraArgs1) self.main.handleQuarterView(extraArgs2) return
class Eyes(DirectObject.DirectObject): __module__ = __name__ notify = DirectNotifyGlobal.directNotify.newCategory('Eyes') def __init__(self, main=None): self.main = main.main self.parent = main.parent self.avatar = main.avatar self.mode = None self.load() return def enter(self): self.notify.debug('enter') self.showEyesCollections() self.loadExtraArgs() if self.mode == None: self.mode = -1 return def exit(self): self.hide() def load(self): self.notify.debug('loading eyes') self.setupButtons() self.loadGUI() self.loadExtraArgs() def loadGUI(self): customRrange = (-1.0, 1.0) self.pgs1 = CharGuiSlider(self.main, parent=self.browFrame, text=PLocalizer.EyeBrowProtruding, range=(0.0, 1.0), command=self.updateControlShape) self.pgs1.setPos(-0.4, 0, -0.3) self.pgs6 = CharGuiSlider(self.main, parent=self.eyeFrame, text=PLocalizer.EyeCorner, command=self.updateControlShape, range=(-0.25, 0.25)) self.pgs6.setPos(-0.4, 0, -0.3) self.pgs7 = CharGuiSlider(self.main, parent=self.eyeFrame, text=PLocalizer.EyeOpeningSize, range=(-1, 1), command=self.updateControlShape) self.pgs7.setPos(-0.4, 0, -0.55) self.pgs8 = CharGuiSlider(self.main, parent=self.eyeFrame, text=PLocalizer.EyeSpacing, range=(-1, 1), command=self.updateControlShape) self.pgs8.setPos(-0.4, 0, -0.8) self.pgs = [self.pgs1, self.pgs6, self.pgs7, self.pgs8] def unload(self): self.notify.debug('called eyes unload') del self.main del self.parent del self.avatar def loadExtraArgs(self): self.pgs1['extraArgs'] = [self.pgs1, 'browProtruding', 135] self.pgs6['extraArgs'] = [self.pgs6, 'eyeCorner'] self.pgs7['extraArgs'] = [self.pgs7, 'eyeOpeningSize'] self.pgs8['extraArgs'] = [self.pgs8, 'eyeSpacing'] def showEyesCollections(self): self.browFrame.show() self.eyeFrame.show() self.colorPicker.show() def hideEyesCollections(self): self.browFrame.hide() self.eyeFrame.hide() self.colorPicker.hide() def hide(self): self.hideEyesCollections() self.saveDNA() def setupButtons(self): self.browFrame = DirectFrame(parent=self.parent, relief=None, text=PLocalizer.EyeBrowFrameTitle, text_fg=(1, 1, 1, 1), text_scale=0.18, text_pos=(0, -0.05), pos=(0, 0, -0.1), scale=0.7) self.browFrame.hide() self.eyeFrame = DirectFrame(parent=self.parent, relief=None, text=PLocalizer.EyeFrameTitle, text_fg=(1, 1, 1, 1), text_scale=0.18, text_pos=(0, -0.05), pos=(0, 0, -1.1), scale=0.7) self.eyeFrame.hide() self.colorPicker = CharGuiPicker(self.main, parent=self.parent, text=PLocalizer.EyesColorFrameTitle, nextCommand=self.handleNextColor, backCommand=self.handleLastColor) self.colorPicker.setPos(0, 0, 0.2) self.colorPicker.hide() return def saveDNA(self): self.avatar.pirate.setBrowProtruding(self.pgs1.node().getValue()) self.avatar.pirate.setEyeCorner(self.pgs6.node().getValue()) self.avatar.pirate.setEyeOpeningSize(self.pgs7.node().getValue()) self.avatar.pirate.setEyeBulge(self.pgs8.node().getValue()) def restore(self): self.pgs1.node().setValue(self.avatar.dna.getBrowProtruding()) self.pgs6.node().setValue(self.avatar.dna.getEyeCorner()) self.pgs7.node().setValue(self.avatar.dna.getEyeOpeningSize()) self.pgs8.node().setValue(self.avatar.dna.getEyeBulge()) def reset(self): for i in xrange(0, len(self.pgs)): self.resetSlider(self.pgs[i]) self.avatar.eyesColorIdx = 0 self.avatar.pirate.setEyesColor(self.avatar.eyesColorIdx) self.avatar.pirate.generateEyesTexture() self.saveDNA() def resetSlider(self, slider): slider.node().setValue(0.0) def randomPick(self): global damper damper = 1.0 for i in xrange(0, len(self.pgs)): slider = self.pgs[i] self.resetSlider(slider) if self.avatar.pirate.gender == 'f': if slider == self.pgs6: continue if random.choice([0, 1]): value = random.random() * damper toss = 0 if slider['range'][0] < 0: toss = random.choice([0, 1]) if toss: slider.node().setValue(-value) else: slider.node().setValue(value) self.saveDNA() choice = random.choice(range(0, self.avatar.numEyeColors)) self.avatar.eyesColorIdx = choice self.avatar.pirate.setEyesColor(self.avatar.eyesColorIdx) self.avatar.pirate.generateEyesTexture() def handleNextColor(self): self.avatar.eyesColorIdx = (self.avatar.eyesColorIdx + 1) % self.avatar.numEyeColors self.notify.debug('new color idx %s' % self.avatar.eyesColorIdx) self.avatar.pirate.setEyesColor(self.avatar.eyesColorIdx) self.avatar.pirate.generateEyesTexture() def handleLastColor(self): self.avatar.eyesColorIdx = (self.avatar.eyesColorIdx - 1) % self.avatar.numEyeColors self.notify.debug('new color idx %s' % self.avatar.eyesColorIdx) self.avatar.pirate.setEyesColor(self.avatar.eyesColorIdx) self.avatar.pirate.generateEyesTexture() def updateControlShape(self, pgs, extraArgs1=None, extraArgs2=None): if extraArgs1 != None: self.avatar.pirate.setControlValue(pgs.node().getValue(), extraArgs1) self.main.handleQuarterView(extraArgs2) return
class Nose(DirectObject.DirectObject): notify = DirectNotifyGlobal.directNotify.newCategory('Nose') def __init__(self, main = None): self.main = main.main self.parent = main.parent self.avatar = main.avatar self.mode = None self.load() def enter(self): self.notify.debug('enter') self.showNoseCollections() self.loadExtraArgs() if self.mode == None: self.mode = -1 def exit(self): self.hide() def load(self): self.notify.debug('loading nose') self.setupButtons() self.loadGUI() self.loadExtraArgs() def loadGUI(self): customRange = (-1.0, 1.0) self.pgs1 = CharGuiSlider(self.main, parent = self.noseFrame, text = PLocalizer.NoseBridgeWidth, range = customRange, command = self.updateControlShape) self.pgs1.setPos(-0.40000000000000002, 0, -0.29999999999999999) self.pgs2 = CharGuiSlider(self.main, parent = self.noseFrame, text = PLocalizer.NoseNostrilWidth, range = customRange, command = self.updateControlShape) self.pgs2.setPos(-0.40000000000000002, 0, -0.55000000000000004) self.pgs3 = CharGuiSlider(self.main, parent = self.noseFrame, text = PLocalizer.NoseLength, range = customRange, command = self.updateControlShape) self.pgs3.setPos(-0.40000000000000002, 0, -0.80000000000000004) self.pgs4 = CharGuiSlider(self.main, parent = self.noseFrame, text = PLocalizer.NoseBump, range = customRange, command = self.updateControlShape) self.pgs4.setPos(-0.40000000000000002, 0, -1.05) self.pgs5 = CharGuiSlider(self.main, parent = self.noseFrame, text = PLocalizer.NoseNostrilAngle, range = customRange, command = self.updateControlShape) self.pgs5.setPos(-0.40000000000000002, 0, -1.3) self.pgs6 = CharGuiSlider(self.main, parent = self.noseFrame, text = PLocalizer.NoseNostrilHeight, range = customRange, command = self.updateControlShape) self.pgs6.setPos(-0.40000000000000002, 0, -1.55) self.pgs7 = CharGuiSlider(self.main, parent = self.noseFrame, text = PLocalizer.NoseBridgeBroke, range = customRange, command = self.updateControlShape) self.pgs7.setPos(-0.40000000000000002, 0, -1.8) self.pgs8 = CharGuiSlider(self.main, parent = self.noseFrame, text = PLocalizer.NoseNostrilBroke, range = customRange, command = self.updateControlShape) self.pgs8.setPos(-0.40000000000000002, 0, -2.0499999999999998) self.pgs = [ self.pgs1, self.pgs2, self.pgs3, self.pgs4, self.pgs5, self.pgs6, self.pgs7, self.pgs8] def unload(self): self.notify.debug('called Nose unload') del self.main del self.parent del self.avatar def loadExtraArgs(self): self.pgs1['extraArgs'] = [ self.pgs1, 'noseBridgeWidth'] self.pgs2['extraArgs'] = [ self.pgs2, 'noseNostrilWidth'] self.pgs3['extraArgs'] = [ self.pgs3, 'noseLength', 135] self.pgs4['extraArgs'] = [ self.pgs4, 'noseBump', 135] self.pgs5['extraArgs'] = [ self.pgs5, 'noseNostrilAngle', 135] self.pgs6['extraArgs'] = [ self.pgs6, 'noseNostrilHeight', 135] self.pgs7['extraArgs'] = [ self.pgs7, 'noseBridgeBroke'] self.pgs8['extraArgs'] = [ self.pgs8, 'noseNostrilBroke'] def showNoseCollections(self): self.noseFrame.show() def hideNoseCollections(self): self.noseFrame.hide() def hide(self): self.hideNoseCollections() self.saveDNA() def setupButtons(self): self.noseFrame = DirectFrame(parent = self.parent, relief = None, text = PLocalizer.NoseFrameTitle, text_fg = (1, 1, 1, 1), text_scale = 0.17999999999999999, text_pos = (0, -0.050000000000000003), pos = (0, 0, 0.20000000000000001), scale = 0.69999999999999996) self.noseFrame.hide() def saveDNA(self): self.avatar.pirate.setNoseBridgeWidth(self.pgs1.node().getValue()) self.avatar.pirate.setNoseNostrilWidth(self.pgs2.node().getValue()) self.avatar.pirate.setNoseLength(self.pgs3.node().getValue()) self.avatar.pirate.setNoseBump(self.pgs4.node().getValue()) self.avatar.pirate.setNoseNostrilAngle(self.pgs5.node().getValue()) self.avatar.pirate.setNoseNostrilHeight(self.pgs6.node().getValue()) self.avatar.pirate.setNoseBridgeBroke(self.pgs7.node().getValue()) self.avatar.pirate.setNoseNostrilBroke(self.pgs8.node().getValue()) def restore(self): self.pgs1.node().setValue(self.avatar.dna.getNoseBridgeWidth()) self.pgs2.node().setValue(self.avatar.dna.getNoseNostrilWidth()) self.pgs3.node().setValue(self.avatar.dna.getNoseLength()) self.pgs4.node().setValue(self.avatar.dna.getNoseBump()) self.pgs5.node().setValue(self.avatar.dna.getNoseNostrilAngle()) self.pgs6.node().setValue(self.avatar.dna.getNoseNostrilHeight()) self.pgs7.node().setValue(self.avatar.dna.getNoseBridgeBroke()) self.pgs8.node().setValue(self.avatar.dna.getNoseNostrilBroke()) def reset(self): for i in xrange(0, len(self.pgs)): self.resetSlider(self.pgs[i]) self.saveDNA() def resetSlider(self, slider): slider.node().setValue(0.0) def randomPick(self): global damper damper = 1.0 for i in xrange(0, len(self.pgs)): slider = self.pgs[i] self.resetSlider(slider) if self.avatar.pirate.gender == 'f': if slider == self.pgs4: continue elif slider == self.pgs7: continue elif slider == self.pgs8: continue if random.choice([ 0, 1]): value = random.random() * damper toss = 0 if slider['range'][0] < 0: toss = random.choice([ 0, 1]) if toss: slider.node().setValue(-value) else: slider.node().setValue(value) self.saveDNA() def weightedRandomPick(self): if self.avatar.pirate.gender == 'f': noseRanges = MakeAPirateGlobals.FEMALE_NOSE_RANGES else: noseRanges = MakeAPirateGlobals.MALE_NOSE_RANGES for i in xrange(0, len(self.pgs)): slider = self.pgs[i] self.resetSlider(slider) coinFlip = random.choice([ 0, 1, 1]) if slider in [ self.pgs7, self.pgs8] and coinFlip: value = 0 else: minValue = noseRanges[i][0] maxValue = noseRanges[i][1] variation = maxValue - minValue value = minValue + random.random() * variation slider.node().setValue(value) self.saveDNA() def updateControlShape(self, pgs, extraArgs1 = None, extraArgs2 = None): if extraArgs1 != None: self.avatar.pirate.setControlValue(pgs.node().getValue(), extraArgs1) self.main.handleQuarterView(extraArgs2)
class Shape(DirectObject.DirectObject): notify = DirectNotifyGlobal.directNotify.newCategory('Shape') def __init__(self, main=None): self.main = main.main self.parent = main.parent self.avatar = main.avatar self.mode = None self.once = False self.load() def enter(self): self.notify.debug('enter') self.showShapeCollections() self.loadExtraArgs() if self.mode == None: self.mode = -1 def exit(self): self.hide() def load(self): self.notify.debug('loading shape') self.setupButtons() self.loadGUI() self.loadExtraArgs() def loadGUI(self): global sliderRange customRange = (-0.5, 0.5) if self.main.wantMarketingViewer: sliderRange = (-1.0, 1.0) self.pgsScale = CharGuiSlider(self.main, parent=self.headFrame, text=PLocalizer.BodyHeadScale, command=self.updateHeadSlider, range=sliderRange) self.pgsScale.setPos(-0.40000000000000002, 0, -0.20000000000000001) self.pgsScale['extraArgs'] = [self.pgsScale, 0, 0] self.pgs1 = CharGuiSlider(self.main, parent=self.headFrame, text=PLocalizer.ShapeHeadWidth, command=self.updateControlShape, range=sliderRange) self.pgs1.setPos(-0.40000000000000002, 0, -0.45000000000000001) self.pgs2 = CharGuiSlider(self.main, parent=self.headFrame, text=PLocalizer.ShapeHeadHeight, command=self.updateControlShape, range=sliderRange) self.pgs2.setPos(-0.40000000000000002, 0, -0.69999999999999996) customRange = (0.0, 1.0) self.pgs3 = CharGuiSlider(self.main, parent=self.headFrame, text=PLocalizer.ShapeHeadRoundness, command=self.updateControlShape, range=customRange) self.pgs3.setPos(-0.40000000000000002, 0, -0.94999999999999996) self.pgs = [self.pgs1, self.pgs2, self.pgs3, self.pgsScale] def unload(self): self.notify.debug('called Shape unload') del self.main del self.parent del self.avatar def loadExtraArgs(self): self.pgs1['extraArgs'] = [self.pgs1, 'headWidth'] self.pgs2['extraArgs'] = [self.pgs2, 'headHeight'] self.pgs3['extraArgs'] = [self.pgs3, 'headRoundness'] def showShapeCollections(self): self.headFrame.show() self.texturePicker.show() def hideShapeCollections(self): self.headFrame.hide() self.texturePicker.hide() def hide(self): self.hideShapeCollections() self.saveDNA() if self.main.inRandomAll: return None if self.once: idx = 0 if self.main.pirate.gender == 'f': idx = 1 optionsLeft = len(self.main.JSD_FACE[idx]) if optionsLeft: choice = random.choice(range(0, optionsLeft)) if self.main.lastDialog: self.main.lastDialog.stop() dialog = self.main.JSD_FACE[idx][choice] base.playSfx(dialog, node=self.avatar.pirate) self.main.lastDialog = dialog self.main.JSD_FACE[idx].remove(dialog) else: self.once = True def setupButtons(self): self.texturePicker = CharGuiPicker( self.main, parent=self.parent, text=PLocalizer.ShapeTextureFrameTitle, nextCommand=self.handleNextTexture, backCommand=self.handleLastTexture) self.texturePicker.setPos(0, 0, 0) self.texturePicker.hide() self.headFrame = DirectFrame(parent=self.parent, relief=None, pos=(0, 0, -0.29999999999999999), scale=0.69999999999999996) self.headFrame.hide() def saveDNA(self): self.avatar.pirate.setHeadWidth(self.pgs1.node().getValue()) self.avatar.pirate.setHeadHeight(self.pgs2.node().getValue()) self.avatar.pirate.setHeadRoundness(self.pgs3.node().getValue()) self.avatar.pirate.setHeadTexture(self.avatar.faceTextureIdx) def restore(self): self.pgs1.node().setValue(self.avatar.dna.getHeadWidth()) self.pgs2.node().setValue(self.avatar.dna.getHeadHeight()) self.pgs3.node().setValue(self.avatar.dna.getHeadRoundness()) self.pgsScale.node().setValue(self.avatar.dna.getHeadSize()) def reset(self): for i in xrange(0, len(self.pgs)): self.resetSlider(self.pgs[i]) self.avatar.faceTextureIdx = 0 self.avatar.pirate.setHeadTexture(self.avatar.faceTextureIdx) self.avatar.pirate.generateFaceTexture() self.saveDNA() def resetSlider(self, slider): slider.node().setValue(0.0) if slider == self.pgsScale: self.updateHeadSlider(slider) def randomPick(self): global damper damper = 1.0 for i in xrange(0, len(self.pgs)): slider = self.pgs[i] self.resetSlider(slider) if self.avatar.pirate.gender == 'f': if slider == self.pgs3: continue if random.choice([0, 1]): value = random.random() * damper toss = 0 if slider['range'][0] < 0: toss = random.choice([0, 1]) if toss: slider.node().setValue(-value) else: slider.node().setValue(value) if slider == self.pgsScale: self.updateHeadSlider(slider) slider == self.pgsScale self.avatar.faceTextureIdx = random.choice(self.avatar.choices['FACE']) self.saveDNA() self.avatar.pirate.generateFaceTexture() def updateControlShape(self, pgs, extraArgs1=None, extraArgs2=None): if extraArgs1 != None: self.avatar.pirate.setControlValue(pgs.node().getValue(), extraArgs1) self.main.handleQuarterView(extraArgs2) def updateHeadSlider(self, pgs, extraArgs1=None, extraArgs2=None): value = pgs.node().getValue() mappedValue = 0.90000000000000002 + (1 + value) * 0.10000000000000001 if extraArgs1 == 0: self.avatar.pirate.setHeadSize(value) self.notify.debug('head slider value %s' % value) self.notify.debug('mapped value %s' % mappedValue) cjExtra = self.avatar.pirate.findAllMatches('**/def_extra_jt') if not cjExtra.isEmpty(): prevScale = cjExtra[0].getScale() if extraArgs1 == 0: cjExtra[0].setScale(2 - mappedValue, mappedValue, prevScale[2]) def handleNextTexture(self): currIdx = self.avatar.choices['FACE'].index(self.avatar.faceTextureIdx) currIdx += 1 if currIdx >= len(self.avatar.choices['FACE']): currIdx = 0 self.avatar.faceTextureIdx = self.avatar.choices['FACE'][currIdx] self.avatar.pirate.setHeadTexture(self.avatar.faceTextureIdx) self.avatar.pirate.generateFaceTexture() def handleLastTexture(self): currIdx = self.avatar.choices['FACE'].index(self.avatar.faceTextureIdx) currIdx -= 1 if currIdx < 0: currIdx = len(self.avatar.choices['FACE']) - 1 self.avatar.faceTextureIdx = self.avatar.choices['FACE'][currIdx] self.avatar.pirate.setHeadTexture(self.avatar.faceTextureIdx) self.avatar.pirate.generateFaceTexture()
class Mouth(DirectObject.DirectObject): notify = DirectNotifyGlobal.directNotify.newCategory('Mouth') def __init__(self, main = None): self.main = main.main self.parent = main.parent self.avatar = main.avatar self.mode = None self.load() def enter(self): self.notify.debug('enter') self.showMouthCollections() self.loadExtraArgs() if self.mode == None: self.mode = -1 def exit(self): self.hide() def load(self): self.notify.debug('loading mouth') self.setupButtons() self.loadGUI() self.loadExtraArgs() def loadGUI(self): customRange = (-1.0, 1.0) self.pgs1 = CharGuiSlider(self.main, parent = self.jawFrame, text = PLocalizer.MouthJawWidth, command = self.updateControlShape, range = customRange) self.pgs1.setPos(-0.40000000000000002, 0, -0.29999999999999999) self.pgs2 = CharGuiSlider(self.main, parent = self.jawFrame, text = PLocalizer.MouthJawLength, command = self.updateControlShape, range = customRange) self.pgs2.setPos(-0.40000000000000002, 0, -0.55000000000000004) self.pgs3 = CharGuiSlider(self.main, parent = self.jawFrame, text = PLocalizer.MouthJawChinAngle, command = self.updateControlShape, range = customRange) self.pgs3.setPos(-0.40000000000000002, 0, -0.80000000000000004) self.pgs4 = CharGuiSlider(self.main, parent = self.jawFrame, text = PLocalizer.MouthJawChinSize, command = self.updateControlShape, range = customRange) self.pgs4.setPos(-0.40000000000000002, 0, -1.05) self.pgs5 = CharGuiSlider(self.main, parent = self.lipFrame, text = PLocalizer.MouthWidth, command = self.updateControlShape, range = (-1.0, 0.0)) self.pgs5.setPos(-0.40000000000000002, 0, -0.29999999999999999) self.pgs6 = CharGuiSlider(self.main, parent = self.lipFrame, text = PLocalizer.MouthThickness, command = self.updateControlShape, range = customRange) self.pgs6.setPos(-0.40000000000000002, 0, -0.55000000000000004) self.pgs8 = CharGuiSlider(self.main, parent = self.cheekFrame, text = PLocalizer.CheekFat, command = self.updateControlShape, range = customRange) self.pgs8.setPos(-0.40000000000000002, 0, -0.29999999999999999) self.pgs = [ self.pgs1, self.pgs2, self.pgs3, self.pgs4, self.pgs5, self.pgs6, self.pgs8] def unload(self): self.notify.debug('called Mouth unload') del self.main del self.parent del self.avatar def loadExtraArgs(self): self.pgs1['extraArgs'] = [ self.pgs1, 'jawWidth'] self.pgs2['extraArgs'] = [ self.pgs2, 'jawLength'] self.pgs3['extraArgs'] = [ self.pgs3, 'jawChinAngle', 135] self.pgs4['extraArgs'] = [ self.pgs4, 'jawChinSize'] self.pgs5['extraArgs'] = [ self.pgs5, 'mouthWidth'] self.pgs6['extraArgs'] = [ self.pgs6, 'mouthLipThickness'] self.pgs8['extraArgs'] = [ self.pgs8, 'cheekFat'] def showMouthCollections(self): self.jawFrame.show() self.lipFrame.show() self.cheekFrame.show() def hideMouthCollections(self): self.jawFrame.hide() self.lipFrame.hide() self.cheekFrame.hide() self.teethPicker.hide() def hide(self): self.hideMouthCollections() self.saveDNA() def setupButtons(self): self.jawFrame = DirectFrame(parent = self.parent, relief = None, text = PLocalizer.MouthJawFrameTitle, text_fg = (1, 1, 1, 1), text_scale = 0.17999999999999999, text_pos = (0, -0.050000000000000003), pos = (0, 0, 0.40000000000000002), scale = 0.69999999999999996) self.jawFrame.hide() self.lipFrame = DirectFrame(parent = self.parent, relief = None, text = PLocalizer.MouthFrameTitle, text_fg = (1, 1, 1, 1), text_scale = 0.17999999999999999, text_pos = (0, -0.050000000000000003), pos = (0, 0, -0.55000000000000004), scale = 0.69999999999999996) self.lipFrame.hide() self.cheekFrame = DirectFrame(parent = self.parent, relief = None, text = PLocalizer.MouthCheekFrameTitle, text_fg = (1, 1, 1, 1), text_scale = 0.17999999999999999, text_pos = (0, -0.050000000000000003), pos = (0, 0, -1.3999999999999999), scale = 0.69999999999999996) self.cheekFrame.hide() self.teethPicker = CharGuiPicker(self.main, parent = self.parent, text = PLocalizer.MouthTeethFrame, nextCommand = self.handleNextTeeth, backCommand = self.handleLastTeeth) self.teethPicker.setPos(0, 0, -0.29999999999999999) self.teethPicker.hide() def saveDNA(self): self.avatar.pirate.setJawWidth(self.pgs1.node().getValue()) self.avatar.pirate.setJawLength(self.pgs2.node().getValue()) self.avatar.pirate.setJawAngle(self.pgs3.node().getValue()) self.avatar.pirate.setJawRoundness(self.pgs4.node().getValue()) self.avatar.pirate.setMouthWidth(self.pgs5.node().getValue()) self.avatar.pirate.setMouthLipThickness(self.pgs6.node().getValue()) self.avatar.pirate.setCheekFat(self.pgs8.node().getValue()) def restore(self): self.pgs1.node().setValue(self.avatar.dna.getJawWidth()) self.pgs2.node().setValue(self.avatar.dna.getJawLength()) self.pgs3.node().setValue(self.avatar.dna.getJawAngle()) self.pgs4.node().setValue(self.avatar.dna.getJawRoundness()) self.pgs5.node().setValue(self.avatar.dna.getMouthWidth()) self.pgs6.node().setValue(self.avatar.dna.getMouthLipThickness()) self.pgs8.node().setValue(self.avatar.dna.getCheekFat()) def reset(self): for i in xrange(0, len(self.pgs)): self.resetSlider(self.pgs[i]) self.saveDNA() def resetSlider(self, slider): slider.node().setValue(0.0) def randomPick(self): global damper damper = 1.0 for i in xrange(0, len(self.pgs)): slider = self.pgs[i] self.resetSlider(slider) if random.choice([ 0, 1]): value = random.random() * damper toss = 0 if slider['range'][0] < 0: toss = random.choice([ 0, 1]) if toss: slider.node().setValue(-value) else: slider.node().setValue(value) self.saveDNA() def updateControlShape(self, pgs, extraArgs1 = None, extraArgs2 = None): if extraArgs1 != None: self.avatar.pirate.setControlValue(pgs.node().getValue(), extraArgs1) self.main.handleQuarterView(extraArgs2) def handleNextTeeth(self): if not self.avatar.tooths[self.avatar.toothIdx].isEmpty(): self.avatar.tooths[self.avatar.toothIdx][0].hide() self.avatar.toothIdx += 1 if self.avatar.toothIdx >= len(self.avatar.tooths): self.avatar.toothIdx = 0 if not self.avatar.tooths[self.avatar.toothIdx].isEmpty(): self.avatar.tooths[self.avatar.toothIdx][0].show() def handleLastTeeth(self): if not self.avatar.tooths[self.avatar.toothIdx].isEmpty(): self.avatar.tooths[self.avatar.toothIdx][0].hide() self.avatar.toothIdx -= 1 if self.avatar.toothIdx < 0: self.avatar.toothIdx = len(self.avatar.tooths) - 1 if not self.avatar.tooths[self.avatar.toothIdx].isEmpty(): self.avatar.tooths[self.avatar.toothIdx][0].show()
class BodyGUI(DirectFrame, StateData.StateData): __module__ = __name__ maleShapeButtonIcons = [] maleShapeButtonIconsOver = [] femaleShapeButtonIcons = [] femaleShapeButtonIconsOver = [] notify = DirectNotifyGlobal.directNotify.newCategory('BodyGUI') bodyHeights = {} bodyHeights['m'] = Human.BodyScales[0] bodyHeights['f'] = Human.BodyScales[1] bodyHeights['n'] = Human.BodyScales[0] def __init__(self, main=None): self.main = main self.parent = main.bookModel self.avatar = main.avatar self.mode = None self.entered = False return def enter(self): self.notify.debug('enter') self.entered = True if self.mode == None: self.load() self.mode = -1 self.show() return def exit(self): self.entered = False self.notify.debug('called bodyGUI exit') self.hide() def save(self): if self.mode == -1: pass def assignAvatar(self, avatar): self.avatar = avatar self.heightSlider.setValue(self.avatar.pirate.getStyle().getBodyHeight()) def load(self): self.notify.debug('loading BodyGUI') self.loadShapeGUI() self.loadHeightGUI() self.loadColorGUI() self.setupButtons() def loadShapeGUI(self): self.maleShapeButtonIcons = [ self.main.charGui.find('**/chargui_male_a'), self.main.charGui.find('**/chargui_male_b'), self.main.charGui.find('**/chargui_male_c'), self.main.charGui.find('**/chargui_male_d'), self.main.charGui.find('**/chargui_male_e')] self.maleShapeButtonIconsOver = [ self.main.charGui.find('**/chargui_male_a_over'), self.main.charGui.find('**/chargui_male_b_over'), self.main.charGui.find('**/chargui_male_c_over'), self.main.charGui.find('**/chargui_male_d_over'), self.main.charGui.find('**/chargui_male_e_over')] self.femaleShapeButtonIcons = [ self.main.charGui.find('**/chargui_female_a'), self.main.charGui.find('**/chargui_female_b'), self.main.charGui.find('**/chargui_female_c'), self.main.charGui.find('**/chargui_female_d'), self.main.charGui.find('**/chargui_female_e')] self.femaleShapeButtonIconsOver = [ self.main.charGui.find('**/chargui_female_a_over'), self.main.charGui.find('**/chargui_female_b_over'), self.main.charGui.find('**/chargui_female_c_over'), self.main.charGui.find('**/chargui_female_d_over'), self.main.charGui.find('**/chargui_female_e_over')] self.shapeFrameTitle = DirectFrame(parent=self.parent, relief=None, text=PLocalizer.BodyShapeFrameTitle, text_fg=(1, 1, 1, 1), text_scale=0.18, text_pos=(0, 0), pos=(0, 0, -0.1), scale=0.7) self.shapeFrameTitle.hide() return def loadHeightGUI(self): self.heightSlider = CharGuiSlider(self.main, parent=self.parent, text=PLocalizer.BodyHeightFrameTitle, command=self.updateHeightSlider, range=(-0.2, 0.2)) self.heightSlider.setPos(-0.3, 0, -0.7) self.heightSlider.setScale(0.7) self.heightSlider['extraArgs'] = [self.heightSlider, 0, 0] self.pgs = [self.heightSlider] def loadColorGUI(self): idx = 0 self.maleColorFrameTitle = DirectFrame(parent=self.parent, relief=None, image=self.main.charGui.find('**/chargui_frame05'), image_pos=(0, 0, -0.6), image_scale=(1.5, 1, 1.25), text=PLocalizer.BodyColorFrameTitle, text_fg=(1, 1, 1, 1), text_scale=0.18, text_pos=(0, -0.04), pos=(0, 0, -1.0), scale=0.7) self.maleColorFrameTitle.hide() self.maleColorButtons = [] xOffset = -0.4 yOffset = -0.3 whiteSkinTone = (1.0, 1.0, 1.0) for i in range(0, len(HumanDNA.skinColors)): if i and i % 5 == 0: xOffset = -0.4 yOffset -= 0.2 skinColor = HumanDNA.skinColors[i] skinTone = (skinColor[0] * whiteSkinTone[0], skinColor[1] * whiteSkinTone[1], skinColor[2] * whiteSkinTone[2], 1.0) self.maleColorButtons.append(DirectButton(parent=self.maleColorFrameTitle, relief=DGG.RAISED, pos=(xOffset, 0, yOffset), frameSize=(-0.1, 0.1, -0.1, 0.1), borderWidth=(0.008, 0.008), frameColor=skinTone, command=self.handleSetColor, extraArgs=[i])) xOffset += 0.2 idx = 1 self.femaleColorFrameTitle = DirectFrame(parent=self.parent, relief=None, image=self.main.charGui.find('**/chargui_frame05'), image_pos=(0, 0, -0.6), image_scale=(1.5, 1, 1.25), text=PLocalizer.BodyColorFrameTitle, text_fg=(1, 1, 1, 1), text_scale=0.18, text_pos=(0, -0.04), pos=(0, 0, -1.0), scale=0.7) self.femaleColorFrameTitle.hide() self.femaleColorButtons = [] xOffset = -0.4 yOffset = -0.3 whiteSkinTone = (1.0, 1.0, 1.0) for i in range(0, len(HumanDNA.skinColors)): if i and i % 5 == 0: xOffset = -0.4 yOffset -= 0.2 skinColor = HumanDNA.skinColors[i] skinTone = (skinColor[0] * whiteSkinTone[0], skinColor[1] * whiteSkinTone[1], skinColor[2] * whiteSkinTone[2], 1.0) self.femaleColorButtons.append(DirectButton(parent=self.femaleColorFrameTitle, relief=DGG.RAISED, pos=(xOffset, 0, yOffset), frameSize=(-0.1, 0.1, -0.1, 0.1), borderWidth=(0.008, 0.008), frameColor=skinTone, command=self.handleSetColor, extraArgs=[i])) xOffset += 0.2 return def unload(self): self.notify.debug('called bodyGUI unload') del self.main del self.parent del self.avatar def showShapeCollections(self): if self.entered: self.shapeFrameTitle.show() if self.main.pirate.style.body.shape in BodyDefs.BodyChoiceGenderDict[self.main.pirate.style.gender]: shapebuttonIndex = BodyDefs.BodyChoiceGenderDict[self.main.pirate.style.gender].index(self.main.pirate.style.body.shape) else: shapebuttonIndex = 2 self.shapeButtons[shapebuttonIndex].setColor(1, 1, 0, 1) def showHeightCollections(self): if self.entered: self.heightSlider.show() def showColorCollections(self): if self.entered: if self.main.pirate.style.gender == 'f': self.femaleColorFrameTitle.show() self.femaleColorButtons[self.main.pirate.style.body.color]['relief'] = DGG.SUNKEN else: self.maleColorFrameTitle.show() self.maleColorButtons[self.main.pirate.style.body.color]['relief'] = DGG.SUNKEN def hideShapeCollections(self): self.shapeFrameTitle.hide() def hideHeightCollections(self): self.heightSlider.hide() def hideColorCollections(self): self.maleColorFrameTitle.hide() self.femaleColorFrameTitle.hide() def show(self): self.showShapeCollections() self.showHeightCollections() self.showColorCollections() def hide(self): self.hideShapeCollections() self.hideHeightCollections() self.hideColorCollections() def setupButtons(self): self.texturePicker = CharGuiPicker(self.main, parent=self.parent, text=PLocalizer.BodyHairFrameTitle, nextCommand=self.handleNextTexture, backCommand=self.handleLastTexture) self.texturePicker.setPos(0, 0, -1) self.texturePicker.hide() shapeButtonTexts = [ PLocalizer.BodyShortFat, PLocalizer.BodyMediumSkinny, PLocalizer.BodyMediumIdeal, PLocalizer.BodyTallPear, PLocalizer.BodyTallMuscular] self.shapeButtons = [] xOffset = -1.1 yOffset = -0.4 for i in range(0, len(self.maleShapeButtonIcons)): self.shapeButtons.append(DirectButton(parent=self.shapeFrameTitle, relief=None, geom=(self.maleShapeButtonIcons[i], self.maleShapeButtonIconsOver[i], self.maleShapeButtonIconsOver[i]), geom_scale=2, pos=(xOffset, 0, yOffset), command=self.handleShape, extraArgs=[i])) xOffset += 0.55 return def restore(self, needToRefresh=True): self.heightSlider.node().setValue(self.main.pirate.style.body.height) findShape = BodyDefs.BodyChoiceGenderDict[self.main.pirate.style.gender].index(self.main.pirate.style.body.shape) self.handleShape(findShape, needToRefresh) self.hideColorCollections() self.showColorCollections() self.handleSetColor(self.main.pirate.style.body.color) self.toggleBodyShapes(self.main.pirate.style.gender) def reset(self): for i in xrange(0, len(self.pgs)): self.resetSlider(self.pgs[i]) self.handleShape(2) self.handleSetColor(0) def resetSlider(self, slider): slider.node().setValue(0.0) self.updateHeightSlider(slider) def randomPick(self): for i in xrange(0, len(self.pgs)): slider = self.pgs[i] self.resetSlider(slider) if random.choice([0, 1]): value = random.random() * 0.1 toss = 0 if slider['range'][0] < 0: toss = random.choice([0, 1]) if toss: slider.node().setValue(-value) else: slider.node().setValue(value) self.updateHeightSlider(slider, slider['extraArgs'][1]) cList = range(0, 5) bodyShapeIndex = BodyDefs.BodyChoiceGenderDict[self.main.pirate.style.gender].index(self.main.pirate.style.body.shape) cList.remove(bodyShapeIndex) choice = random.choice(cList) self.handleShape(choice) idx = 0 if self.main.pirate.style.gender == 'f': idx = 1 choice = random.choice(range(1, len(HumanDNA.skinColors))) self.handleSetColor(choice) def weightedRandomPick(self): for i in xrange(0, len(self.pgs)): slider = self.pgs[i] self.resetSlider(slider) if random.choice([0, 1]): value = random.random() * 0.1 toss = 0 if slider['range'][0] < 0: toss = random.choice([0, 1, 2]) if toss == 1: slider.node().setValue(-value) else: if toss == 0: slider.node().setValue(value) else: if toss == 2: slider.node().setValue(0) self.updateHeightSlider(slider, slider['extraArgs'][1]) if self.main.pirate.style.gender == 'f': bodyChoiceList = MakeAPirateGlobals.FEMALE_BODYTYPE_SELECTIONS else: bodyChoiceList = MakeAPirateGlobals.MALE_BODYTYPE_SELECTIONS bodyShapeIndex = BodyDefs.BodyChoiceGenderDict[self.main.pirate.style.gender].index(self.main.pirate.style.body.shape) choice = random.choice(bodyChoiceList) if choice == bodyShapeIndex: choice = random.choice(bodyChoiceList) self.handleShape(choice) colorSetChoice = random.choice(MakeAPirateGlobals.COMPLECTIONTYPES.keys()) choice = random.choice(MakeAPirateGlobals.COMPLECTIONTYPES[colorSetChoice][0]) self.handleSetColor(choice) def handleShape(self, index, needToRefresh=True): for i in range(0, len(self.shapeButtons)): self.shapeButtons[i].setColor(0.6, 0.8, 1.0, 1.0) bodyShapeIndex = BodyDefs.BodyChoiceGenderDict[self.main.pirate.style.gender][index] self.shapeButtons[index].setColor(1.0, 1.0, 0, 1.0) self.main.pirate.style.setBodyShape(bodyShapeIndex) self.updateHeightSlider(self.heightSlider, 0, 0) self.main.pirate.refreshBody() self.main.pirate.generateSkinTexture() if not self.main.isNPCEditor: if not self.main.wantNPCViewer: self.main.pirate.loop('idle') base.config.GetBool('want-idle-centered', 0) and self.main.pirate.loop('idle_centered') else: self.main.refreshAnim(needToRefresh) self.main.setupCamera(self.main.pirate) if self.main.inRandomAll: return optionsLeft = hasattr(self.main, 'JSD_BODY') and len(self.main.JSD_BODY[index]) choice = optionsLeft and not random.randint(0, 4) and random.choice(range(0, optionsLeft)) if self.main.lastDialog: if self.main.lastDialog.status() == AudioSound.PLAYING: return dialog = self.main.JSD_BODY[index][choice] base.playSfx(dialog, node=self.avatar.pirate) self.main.lastDialog = dialog if self.main.pirate.style.gender == 'm': if dialog == self.main.jsd_body_ms_1: dialog.stop() elif self.main.pirate.style.gender == 'f': if dialog == self.main.jsd_body_tm_1: dialog.stop() else: self.main.JSD_BODY[index].remove(dialog) def handleSetColor(self, colorIdx): colorButtons = self.maleColorButtons if self.main.pirate.style.gender == 'f': colorButtons = self.femaleColorButtons for i in range(0, len(colorButtons)): colorButtons[i]['relief'] = DGG.RAISED colorButtons[colorIdx]['relief'] = DGG.SUNKEN self.avatar.skinColorIdx = colorIdx self.avatar.pirate.setBodyColor(self.avatar.skinColorIdx) self.avatar.pirate.generateSkinColor() def updateHeightSlider(self, pgs, extraArgs1=None, extraArgs2=None): value = pgs.node().getValue() self.avatar.pirate.setBodyHeight(value) self.avatar.pirate.setGlobalScale(self.avatar.pirate.calcBodyScale()) def handleNextTexture(self): self.avatar.bodyTextureIdx = (self.avatar.bodyTextureIdx + 1) % self.avatar.numBodys self.avatar.pirate.setBodySkin(self.avatar.bodyTextureIdx) self.avatar.pirate.generateSkinTexture() def handleLastTexture(self): self.avatar.bodyTextureIdx = (self.avatar.bodyTextureIdx - 1) % self.avatar.numBodys self.avatar.pirate.setBodySkin(self.avatar.bodyTextureIdx) self.avatar.pirate.generateSkinTexture() def toggleBodyShapes(self, gender): if gender == 'f': self.notify.debug('gender is female') for i in range(0, len(self.femaleShapeButtonIcons)): self.shapeButtons[i]['geom'] = ( self.femaleShapeButtonIcons[i], self.femaleShapeButtonIconsOver[i], self.femaleShapeButtonIconsOver[i]) self.notify.debug('gender is male') for i in range(0, len(self.maleShapeButtonIcons)): self.shapeButtons[i]['geom'] = ( self.maleShapeButtonIcons[i], self.maleShapeButtonIconsOver[i], self.maleShapeButtonIconsOver[i])
class Nose(DirectObject.DirectObject): notify = DirectNotifyGlobal.directNotify.newCategory("Nose") def __init__(self, main=None): self.main = main.main self.parent = main.parent self.avatar = main.avatar self.mode = None self.load() def enter(self): self.notify.debug("enter") self.showNoseCollections() self.loadExtraArgs() if self.mode == None: self.mode = -1 def exit(self): self.hide() def load(self): self.notify.debug("loading nose") self.setupButtons() self.loadGUI() self.loadExtraArgs() def loadGUI(self): customRange = (-1.0, 1.0) self.pgs1 = CharGuiSlider( self.main, parent=self.noseFrame, text=PLocalizer.NoseBridgeWidth, range=customRange, command=self.updateControlShape, ) self.pgs1.setPos(-0.40000000000000002, 0, -0.29999999999999999) self.pgs2 = CharGuiSlider( self.main, parent=self.noseFrame, text=PLocalizer.NoseNostrilWidth, range=customRange, command=self.updateControlShape, ) self.pgs2.setPos(-0.40000000000000002, 0, -0.55000000000000004) self.pgs3 = CharGuiSlider( self.main, parent=self.noseFrame, text=PLocalizer.NoseLength, range=customRange, command=self.updateControlShape, ) self.pgs3.setPos(-0.40000000000000002, 0, -0.80000000000000004) self.pgs4 = CharGuiSlider( self.main, parent=self.noseFrame, text=PLocalizer.NoseBump, range=customRange, command=self.updateControlShape, ) self.pgs4.setPos(-0.40000000000000002, 0, -1.05) self.pgs5 = CharGuiSlider( self.main, parent=self.noseFrame, text=PLocalizer.NoseNostrilAngle, range=customRange, command=self.updateControlShape, ) self.pgs5.setPos(-0.40000000000000002, 0, -1.3) self.pgs6 = CharGuiSlider( self.main, parent=self.noseFrame, text=PLocalizer.NoseNostrilHeight, range=customRange, command=self.updateControlShape, ) self.pgs6.setPos(-0.40000000000000002, 0, -1.55) self.pgs7 = CharGuiSlider( self.main, parent=self.noseFrame, text=PLocalizer.NoseBridgeBroke, range=customRange, command=self.updateControlShape, ) self.pgs7.setPos(-0.40000000000000002, 0, -1.8) self.pgs8 = CharGuiSlider( self.main, parent=self.noseFrame, text=PLocalizer.NoseNostrilBroke, range=customRange, command=self.updateControlShape, ) self.pgs8.setPos(-0.40000000000000002, 0, -2.0499999999999998) self.pgs = [self.pgs1, self.pgs2, self.pgs3, self.pgs4, self.pgs5, self.pgs6, self.pgs7, self.pgs8] def unload(self): self.notify.debug("called Nose unload") del self.main del self.parent del self.avatar def loadExtraArgs(self): self.pgs1["extraArgs"] = [self.pgs1, "noseBridgeWidth"] self.pgs2["extraArgs"] = [self.pgs2, "noseNostrilWidth"] self.pgs3["extraArgs"] = [self.pgs3, "noseLength", 135] self.pgs4["extraArgs"] = [self.pgs4, "noseBump", 135] self.pgs5["extraArgs"] = [self.pgs5, "noseNostrilAngle", 135] self.pgs6["extraArgs"] = [self.pgs6, "noseNostrilHeight", 135] self.pgs7["extraArgs"] = [self.pgs7, "noseBridgeBroke"] self.pgs8["extraArgs"] = [self.pgs8, "noseNostrilBroke"] def showNoseCollections(self): self.noseFrame.show() def hideNoseCollections(self): self.noseFrame.hide() def hide(self): self.hideNoseCollections() self.saveDNA() def setupButtons(self): self.noseFrame = DirectFrame( parent=self.parent, relief=None, text=PLocalizer.NoseFrameTitle, text_fg=(1, 1, 1, 1), text_scale=0.17999999999999999, text_pos=(0, -0.050000000000000003), pos=(0, 0, 0.20000000000000001), scale=0.69999999999999996, ) self.noseFrame.hide() def saveDNA(self): self.avatar.pirate.setNoseBridgeWidth(self.pgs1.node().getValue()) self.avatar.pirate.setNoseNostrilWidth(self.pgs2.node().getValue()) self.avatar.pirate.setNoseLength(self.pgs3.node().getValue()) self.avatar.pirate.setNoseBump(self.pgs4.node().getValue()) self.avatar.pirate.setNoseNostrilAngle(self.pgs5.node().getValue()) self.avatar.pirate.setNoseNostrilHeight(self.pgs6.node().getValue()) self.avatar.pirate.setNoseBridgeBroke(self.pgs7.node().getValue()) self.avatar.pirate.setNoseNostrilBroke(self.pgs8.node().getValue()) def restore(self): self.pgs1.node().setValue(self.avatar.dna.getNoseBridgeWidth()) self.pgs2.node().setValue(self.avatar.dna.getNoseNostrilWidth()) self.pgs3.node().setValue(self.avatar.dna.getNoseLength()) self.pgs4.node().setValue(self.avatar.dna.getNoseBump()) self.pgs5.node().setValue(self.avatar.dna.getNoseNostrilAngle()) self.pgs6.node().setValue(self.avatar.dna.getNoseNostrilHeight()) self.pgs7.node().setValue(self.avatar.dna.getNoseBridgeBroke()) self.pgs8.node().setValue(self.avatar.dna.getNoseNostrilBroke()) def reset(self): for i in xrange(0, len(self.pgs)): self.resetSlider(self.pgs[i]) self.saveDNA() def resetSlider(self, slider): slider.node().setValue(0.0) def randomPick(self): global damper damper = 1.0 for i in xrange(0, len(self.pgs)): slider = self.pgs[i] self.resetSlider(slider) if self.avatar.pirate.gender == "f": if slider == self.pgs4: continue elif slider == self.pgs7: continue elif slider == self.pgs8: continue if random.choice([0, 1]): value = random.random() * damper toss = 0 if slider["range"][0] < 0: toss = random.choice([0, 1]) if toss: slider.node().setValue(-value) else: slider.node().setValue(value) self.saveDNA() def weightedRandomPick(self): if self.avatar.pirate.gender == "f": noseRanges = MakeAPirateGlobals.FEMALE_NOSE_RANGES else: noseRanges = MakeAPirateGlobals.MALE_NOSE_RANGES for i in xrange(0, len(self.pgs)): slider = self.pgs[i] self.resetSlider(slider) coinFlip = random.choice([0, 1, 1]) if slider in [self.pgs7, self.pgs8] and coinFlip: value = 0 else: minValue = noseRanges[i][0] maxValue = noseRanges[i][1] variation = maxValue - minValue value = minValue + random.random() * variation slider.node().setValue(value) self.saveDNA() def updateControlShape(self, pgs, extraArgs1=None, extraArgs2=None): if extraArgs1 != None: self.avatar.pirate.setControlValue(pgs.node().getValue(), extraArgs1) self.main.handleQuarterView(extraArgs2)
class Shape(DirectObject.DirectObject): notify = DirectNotifyGlobal.directNotify.newCategory('Shape') def __init__(self, main = None): self.main = main.main self.parent = main.parent self.avatar = main.avatar self.mode = None self.once = False self.load() def enter(self): self.notify.debug('enter') self.showShapeCollections() self.loadExtraArgs() if self.mode == None: self.mode = -1 def exit(self): self.hide() def load(self): self.notify.debug('loading shape') self.setupButtons() self.loadGUI() self.loadExtraArgs() def loadGUI(self): global sliderRange customRange = (-0.5, 0.5) if self.main.wantMarketingViewer: sliderRange = (-1.0, 1.0) self.pgsScale = CharGuiSlider(self.main, parent = self.headFrame, text = PLocalizer.BodyHeadScale, command = self.updateHeadSlider, range = sliderRange) self.pgsScale.setPos(-0.40000000000000002, 0, -0.20000000000000001) self.pgsScale['extraArgs'] = [ self.pgsScale, 0, 0] self.pgs1 = CharGuiSlider(self.main, parent = self.headFrame, text = PLocalizer.ShapeHeadWidth, command = self.updateControlShape, range = sliderRange) self.pgs1.setPos(-0.40000000000000002, 0, -0.45000000000000001) self.pgs2 = CharGuiSlider(self.main, parent = self.headFrame, text = PLocalizer.ShapeHeadHeight, command = self.updateControlShape, range = sliderRange) self.pgs2.setPos(-0.40000000000000002, 0, -0.69999999999999996) customRange = (0.0, 1.0) self.pgs3 = CharGuiSlider(self.main, parent = self.headFrame, text = PLocalizer.ShapeHeadRoundness, command = self.updateControlShape, range = customRange) self.pgs3.setPos(-0.40000000000000002, 0, -0.94999999999999996) self.pgs = [ self.pgs1, self.pgs2, self.pgs3, self.pgsScale] def unload(self): self.notify.debug('called Shape unload') del self.main del self.parent del self.avatar def loadExtraArgs(self): self.pgs1['extraArgs'] = [ self.pgs1, 'headWidth'] self.pgs2['extraArgs'] = [ self.pgs2, 'headHeight'] self.pgs3['extraArgs'] = [ self.pgs3, 'headRoundness'] def showShapeCollections(self): self.headFrame.show() self.texturePicker.show() def hideShapeCollections(self): self.headFrame.hide() self.texturePicker.hide() def hide(self): self.hideShapeCollections() self.saveDNA() if self.main.inRandomAll: return None if self.once: idx = 0 if self.main.pirate.gender == 'f': idx = 1 optionsLeft = len(self.main.JSD_FACE[idx]) if optionsLeft: choice = random.choice(range(0, optionsLeft)) if self.main.lastDialog: self.main.lastDialog.stop() dialog = self.main.JSD_FACE[idx][choice] base.playSfx(dialog, node = self.avatar.pirate) self.main.lastDialog = dialog self.main.JSD_FACE[idx].remove(dialog) else: self.once = True def setupButtons(self): self.texturePicker = CharGuiPicker(self.main, parent = self.parent, text = PLocalizer.ShapeTextureFrameTitle, nextCommand = self.handleNextTexture, backCommand = self.handleLastTexture) self.texturePicker.setPos(0, 0, 0) self.texturePicker.hide() self.headFrame = DirectFrame(parent = self.parent, relief = None, pos = (0, 0, -0.29999999999999999), scale = 0.69999999999999996) self.headFrame.hide() def saveDNA(self): self.avatar.pirate.setHeadWidth(self.pgs1.node().getValue()) self.avatar.pirate.setHeadHeight(self.pgs2.node().getValue()) self.avatar.pirate.setHeadRoundness(self.pgs3.node().getValue()) self.avatar.pirate.setHeadTexture(self.avatar.faceTextureIdx) def restore(self): self.pgs1.node().setValue(self.avatar.dna.getHeadWidth()) self.pgs2.node().setValue(self.avatar.dna.getHeadHeight()) self.pgs3.node().setValue(self.avatar.dna.getHeadRoundness()) self.pgsScale.node().setValue(self.avatar.dna.getHeadSize()) def reset(self): for i in xrange(0, len(self.pgs)): self.resetSlider(self.pgs[i]) self.avatar.faceTextureIdx = 0 self.avatar.pirate.setHeadTexture(self.avatar.faceTextureIdx) self.avatar.pirate.generateFaceTexture() self.saveDNA() def resetSlider(self, slider): slider.node().setValue(0.0) if slider == self.pgsScale: self.updateHeadSlider(slider) def randomPick(self): global damper damper = 1.0 for i in xrange(0, len(self.pgs)): slider = self.pgs[i] self.resetSlider(slider) if self.avatar.pirate.gender == 'f': if slider == self.pgs3: continue if random.choice([ 0, 1]): value = random.random() * damper toss = 0 if slider['range'][0] < 0: toss = random.choice([ 0, 1]) if toss: slider.node().setValue(-value) else: slider.node().setValue(value) if slider == self.pgsScale: self.updateHeadSlider(slider) slider == self.pgsScale self.avatar.faceTextureIdx = random.choice(self.avatar.choices['FACE']) self.saveDNA() self.avatar.pirate.generateFaceTexture() def updateControlShape(self, pgs, extraArgs1 = None, extraArgs2 = None): if extraArgs1 != None: self.avatar.pirate.setControlValue(pgs.node().getValue(), extraArgs1) self.main.handleQuarterView(extraArgs2) def updateHeadSlider(self, pgs, extraArgs1 = None, extraArgs2 = None): value = pgs.node().getValue() mappedValue = 0.90000000000000002 + (1 + value) * 0.10000000000000001 if extraArgs1 == 0: self.avatar.pirate.setHeadSize(value) self.notify.debug('head slider value %s' % value) self.notify.debug('mapped value %s' % mappedValue) cjExtra = self.avatar.pirate.findAllMatches('**/def_extra_jt') if not cjExtra.isEmpty(): prevScale = cjExtra[0].getScale() if extraArgs1 == 0: cjExtra[0].setScale(2 - mappedValue, mappedValue, prevScale[2]) def handleNextTexture(self): currIdx = self.avatar.choices['FACE'].index(self.avatar.faceTextureIdx) currIdx += 1 if currIdx >= len(self.avatar.choices['FACE']): currIdx = 0 self.avatar.faceTextureIdx = self.avatar.choices['FACE'][currIdx] self.avatar.pirate.setHeadTexture(self.avatar.faceTextureIdx) self.avatar.pirate.generateFaceTexture() def handleLastTexture(self): currIdx = self.avatar.choices['FACE'].index(self.avatar.faceTextureIdx) currIdx -= 1 if currIdx < 0: currIdx = len(self.avatar.choices['FACE']) - 1 self.avatar.faceTextureIdx = self.avatar.choices['FACE'][currIdx] self.avatar.pirate.setHeadTexture(self.avatar.faceTextureIdx) self.avatar.pirate.generateFaceTexture()
class TattooGUI(DirectFrame, StateData.StateData): notify = DirectNotifyGlobal.directNotify.newCategory('TattooGUI') def __init__(self, main = None): self.main = main self.parent = main.bookModel self.avatar = main.avatar self.mode = None self.shownMale = None self.shownFemale = None self.vTattoos = [ 1, 2, 3, 4, 5, 6, 7, 8] self.currTattoo = -1 self.cStage = TextureStage('cardstage') factory = CardMaker('fact') factory.setFrame(-0.5, 0.5, -0.5, 0.5) self.map = NodePath(factory.generate()) def enter(self): self.notify.debug('enter') if self.mode == None: self.load() self.mode = -1 self.show() def exit(self): self.hide() def save(self): if self.mode == -1: pass 1 self.saveDNA() def assignAvatar(self, avatar): self.avatar = avatar self.applyBaseTexture(self.avatar.getTattooBaseTexture()) def load(self): self.loadTabs() self.loadZone1GUI() self.map.reparentTo(self.zone1Frame) self.map.setPos(1.5, 0, -0.59999999999999998) self.map.setScale(1.3999999999999999) self.setupButtons() def loadZone1GUI(self): self.zone1FrameTitle = DirectFrame(parent = self.parent, relief = DGG.FLAT, frameColor = (1, 1, 0, 1), text = 'Chest Tattoo', text_scale = 0.17999999999999999, text_pos = (0, 0), pos = (0.0, 0, 0.69999999999999996), scale = (0.66000000000000003, 0.40000000000000002, 0.53000000000000003)) self.zone1FrameTitle.hide() self.zone1Frame = DirectFrame(parent = self.zone1FrameTitle, relief = DGG.FLAT, frameSize = (-0.20000000000000001, 0.20000000000000001, -0.050000000000000003, 0.050000000000000003), frameColor = (0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 0), text = 'Blank', text_scale = 0.14000000000000001, text_pos = (0, -0.02), text_align = TextNode.ACenter, text_fg = (1, 1, 1, 1), text_shadow = (0, 0, 0, 1), pos = (-1.0, 0.0, -0.20000000000000001)) self.zone1Frame.hide() self.zone2FrameTitle = DirectFrame(parent = self.parent, relief = DGG.FLAT, frameColor = (1, 1, 0, 1), text = 'LeftArm Tattoo', text_scale = 0.17999999999999999, text_pos = (0, 0), pos = (0.0, 0, 0.69999999999999996), scale = (0.66000000000000003, 0.40000000000000002, 0.53000000000000003)) self.zone2FrameTitle.hide() self.zone2Frame = DirectFrame(parent = self.zone2FrameTitle, relief = DGG.FLAT, frameSize = (-0.20000000000000001, 0.20000000000000001, -0.050000000000000003, 0.050000000000000003), frameColor = (0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 0), text = 'Blank', text_scale = 0.14000000000000001, text_pos = (0, -0.02), text_align = TextNode.ACenter, text_fg = (1, 1, 1, 1), text_shadow = (0, 0, 0, 1), pos = (-1.0, 0.0, -0.20000000000000001)) self.zone2Frame.hide() self.zone3FrameTitle = DirectFrame(parent = self.parent, relief = DGG.FLAT, frameColor = (1, 1, 0, 1), text = 'RightArm Tattoo', text_scale = 0.17999999999999999, text_pos = (0, 0), pos = (0.0, 0, 0.69999999999999996), scale = (0.66000000000000003, 0.40000000000000002, 0.53000000000000003)) self.zone3FrameTitle.hide() self.zone3Frame = DirectFrame(parent = self.zone3FrameTitle, relief = DGG.FLAT, frameSize = (-0.20000000000000001, 0.20000000000000001, -0.050000000000000003, 0.050000000000000003), frameColor = (0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 0), text = 'Blank', text_scale = 0.14000000000000001, text_pos = (0, -0.02), text_align = TextNode.ACenter, text_fg = (1, 1, 1, 1), text_shadow = (0, 0, 0, 1), pos = (-1.0, 0.0, -0.20000000000000001)) self.zone3Frame.hide() self.zone4FrameTitle = DirectFrame(parent = self.parent, relief = DGG.FLAT, frameColor = (1, 1, 0, 1), text = 'Face Tattoo', text_scale = 0.17999999999999999, text_pos = (0, 0), pos = (0.0, 0, 0.69999999999999996), scale = (0.66000000000000003, 0.40000000000000002, 0.53000000000000003)) self.zone4FrameTitle.hide() self.zone4Frame = DirectFrame(parent = self.zone4FrameTitle, relief = DGG.FLAT, frameSize = (-0.20000000000000001, 0.20000000000000001, -0.050000000000000003, 0.050000000000000003), frameColor = (0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 0), text = 'Blank', text_scale = 0.14000000000000001, text_pos = (0, -0.02), text_align = TextNode.ACenter, text_fg = (1, 1, 1, 1), text_shadow = (0, 0, 0, 1), pos = (-1.0, 0.0, -0.20000000000000001)) self.zone4Frame.hide() self.zone5FrameTitle = DirectFrame(parent = self.parent, relief = DGG.FLAT, frameColor = (1, 1, 0, 1), text = 'Zone5 Tattoo', text_scale = 0.17999999999999999, text_pos = (0, 0), pos = (0.0, 0, 0.69999999999999996), scale = (0.66000000000000003, 0.40000000000000002, 0.53000000000000003)) self.zone5FrameTitle.hide() self.zone5Frame = DirectFrame(parent = self.zone5FrameTitle, relief = DGG.FLAT, frameSize = (-0.20000000000000001, 0.20000000000000001, -0.050000000000000003, 0.050000000000000003), frameColor = (0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 0), text = 'Blank', text_scale = 0.14000000000000001, text_pos = (0, -0.02), text_align = TextNode.ACenter, text_fg = (1, 1, 1, 1), text_shadow = (0, 0, 0, 1), pos = (-1.0, 0.0, -0.20000000000000001)) self.zone5Frame.hide() self.zone6FrameTitle = DirectFrame(parent = self.parent, relief = DGG.FLAT, frameColor = (1, 1, 0, 1), text = 'Zone6 Tattoo', text_scale = 0.17999999999999999, text_pos = (0, 0), pos = (0.0, 0, 0.69999999999999996), scale = (0.66000000000000003, 0.40000000000000002, 0.53000000000000003)) self.zone6FrameTitle.hide() self.zone6Frame = DirectFrame(parent = self.zone6FrameTitle, relief = DGG.FLAT, frameSize = (-0.20000000000000001, 0.20000000000000001, -0.050000000000000003, 0.050000000000000003), frameColor = (0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 0), text = 'Blank', text_scale = 0.14000000000000001, text_pos = (0, -0.02), text_align = TextNode.ACenter, text_fg = (1, 1, 1, 1), text_shadow = (0, 0, 0, 1), pos = (-1.0, 0.0, -0.20000000000000001)) self.zone6Frame.hide() self.zone7FrameTitle = DirectFrame(parent = self.parent, relief = DGG.FLAT, frameColor = (1, 1, 0, 1), text = 'Zone7 Tattoo', text_scale = 0.17999999999999999, text_pos = (0, 0), pos = (0.0, 0, 0.69999999999999996), scale = (0.66000000000000003, 0.40000000000000002, 0.53000000000000003)) self.zone7FrameTitle.hide() self.zone7Frame = DirectFrame(parent = self.zone7FrameTitle, relief = DGG.FLAT, frameSize = (-0.20000000000000001, 0.20000000000000001, -0.050000000000000003, 0.050000000000000003), frameColor = (0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 0), text = 'Blank', text_scale = 0.14000000000000001, text_pos = (0, -0.02), text_align = TextNode.ACenter, text_fg = (1, 1, 1, 1), text_shadow = (0, 0, 0, 1), pos = (-1.0, 0.0, -0.20000000000000001)) self.zone7Frame.hide() self.zone8FrameTitle = DirectFrame(parent = self.parent, relief = DGG.FLAT, frameColor = (1, 1, 0, 1), text = 'Zone8 Tattoo', text_scale = 0.17999999999999999, text_pos = (0, 0), pos = (0.0, 0, 0.69999999999999996), scale = (0.66000000000000003, 0.40000000000000002, 0.53000000000000003)) self.zone8FrameTitle.hide() self.zone8Frame = DirectFrame(parent = self.zone8FrameTitle, relief = DGG.FLAT, frameSize = (-0.20000000000000001, 0.20000000000000001, -0.050000000000000003, 0.050000000000000003), frameColor = (0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 0), text = 'Blank', text_scale = 0.14000000000000001, text_pos = (0, -0.02), text_align = TextNode.ACenter, text_fg = (1, 1, 1, 1), text_shadow = (0, 0, 0, 1), pos = (-1.0, 0.0, -0.20000000000000001)) self.zone8Frame.hide() self.oXSlider = CharGuiSlider(self.main, parent = self.zone1FrameTitle, text = 'OffsetX', command = self.handleOxSlider, range = (0.0, 1.0)) self.oXSlider['extraArgs'] = [ self.oXSlider] self.oXSlider.setPos(-0.5, 0, -2.0) self.oYSlider = CharGuiSlider(self.main, parent = self.zone1FrameTitle, text = 'OffsetY', command = self.handleOySlider, range = (0.0, 1.0)) self.oYSlider['extraArgs'] = [ self.oYSlider] self.oYSlider.setPos(-0.5, 0, -2.2999999999999998) self.scaleSlider = CharGuiSlider(self.main, parent = self.zone1FrameTitle, text = 'Scale', command = self.handleScaleSlider, range = (0.01, 1)) self.scaleSlider['extraArgs'] = [ self.scaleSlider] self.scaleSlider.setPos(-0.5, 0, -2.6000000000000001) self.rotateSlider = CharGuiSlider(self.main, parent = self.zone1FrameTitle, text = 'Rotate', command = self.handleRotateSlider, range = (0, 360)) self.rotateSlider['extraArgs'] = [ self.rotateSlider] self.rotateSlider.setPos(-0.5, 0, -2.8999999999999999) self.editZone1 = DirectButton(parent = self.zone1FrameTitle, relief = DGG.RAISED, frameSize = (-0.29999999999999999, 0.29999999999999999, -0.14999999999999999, 0.14999999999999999), borderWidth = (0.025000000000000001, 0.025000000000000001), text = 'Edit', text_scale = 0.14999999999999999, text_align = TextNode.ACenter, text_pos = (0, -0.025000000000000001), command = self.setEdit, extraArgs = [ Zone1_Tab], pos = (-0.80000000000000004, 0, -1.0)) self.editZone2 = DirectButton(parent = self.zone2FrameTitle, relief = DGG.RAISED, frameSize = (-0.29999999999999999, 0.29999999999999999, -0.14999999999999999, 0.14999999999999999), borderWidth = (0.025000000000000001, 0.025000000000000001), text = 'Edit', text_scale = 0.14999999999999999, text_align = TextNode.ACenter, text_pos = (0, -0.025000000000000001), command = self.setEdit, extraArgs = [ Zone2_Tab], pos = (-0.80000000000000004, 0, -1.0)) self.editZone3 = DirectButton(parent = self.zone3FrameTitle, relief = DGG.RAISED, frameSize = (-0.29999999999999999, 0.29999999999999999, -0.14999999999999999, 0.14999999999999999), borderWidth = (0.025000000000000001, 0.025000000000000001), text = 'Edit', text_scale = 0.14999999999999999, text_align = TextNode.ACenter, text_pos = (0, -0.025000000000000001), command = self.setEdit, extraArgs = [ Zone3_Tab], pos = (-0.80000000000000004, 0, -1.0)) self.editZone4 = DirectButton(parent = self.zone4FrameTitle, relief = DGG.RAISED, frameSize = (-0.29999999999999999, 0.29999999999999999, -0.14999999999999999, 0.14999999999999999), borderWidth = (0.025000000000000001, 0.025000000000000001), text = 'Edit', text_scale = 0.14999999999999999, text_align = TextNode.ACenter, text_pos = (0, -0.025000000000000001), command = self.setEdit, extraArgs = [ Zone4_Tab], pos = (-0.80000000000000004, 0, -1.0)) self.editZone5 = DirectButton(parent = self.zone5FrameTitle, relief = DGG.RAISED, frameSize = (-0.29999999999999999, 0.29999999999999999, -0.14999999999999999, 0.14999999999999999), borderWidth = (0.025000000000000001, 0.025000000000000001), text = 'Edit', text_scale = 0.14999999999999999, text_align = TextNode.ACenter, text_pos = (0, -0.025000000000000001), command = self.setEdit, extraArgs = [ Zone5_Tab], pos = (-0.80000000000000004, 0, -1.0)) self.editZone5.hide() self.editButtons = [ self.editZone1, self.editZone2, self.editZone3, self.editZone4, self.editZone5, self.editZone5, self.editZone5, self.editZone5] def loadTabs(self): self.zone1Tab = DirectButton(parent = self.parent, relief = DGG.RAISED, frameSize = (-0.13, 0.13, -0.040000000000000001, 0.040000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = 'Chest', text_scale = 0.070000000000000007, text_align = TextNode.ACenter, text_pos = (0, -0.014999999999999999), command = self.setMode, extraArgs = [ Zone1_Tab], pos = (-0.96999999999999997, 0, 1.02)) self.zone1Tab.hide() self.zone2Tab = DirectButton(parent = self.parent, relief = DGG.RAISED, frameSize = (-0.13, 0.13, -0.040000000000000001, 0.040000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = 'LeftArm', text_scale = 0.070000000000000007, text_align = TextNode.ACenter, text_pos = (0, -0.014999999999999999), command = self.setMode, extraArgs = [ Zone2_Tab], pos = (-0.71999999999999997, 0, 1.02)) self.zone2Tab.hide() self.zone3Tab = DirectButton(parent = self.parent, relief = DGG.RAISED, frameSize = (-0.13, 0.13, -0.040000000000000001, 0.040000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = 'RightArm', text_scale = 0.070000000000000007, text_align = TextNode.ACenter, text_pos = (0, -0.014999999999999999), command = self.setMode, extraArgs = [ Zone3_Tab], pos = (-0.46999999999999997, 0, 1.02)) self.zone3Tab.hide() self.zone4Tab = DirectButton(parent = self.parent, relief = DGG.RAISED, frameSize = (-0.13, 0.13, -0.040000000000000001, 0.040000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = 'Face', text_scale = 0.070000000000000007, text_align = TextNode.ACenter, text_pos = (0, -0.014999999999999999), command = self.setMode, extraArgs = [ Zone4_Tab], pos = (-0.22, 0, 1.02)) self.zone4Tab.hide() self.zone5Tab = DirectButton(parent = self.parent, relief = DGG.RAISED, frameSize = (-0.13, 0.13, -0.040000000000000001, 0.040000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = 'Zone5', text_scale = 0.070000000000000007, text_align = TextNode.ACenter, text_pos = (0, -0.014999999999999999), command = self.setMode, extraArgs = [ Zone5_Tab], pos = (0.029999999999999999, 0, 1.02)) self.zone5Tab.hide() self.zone6Tab = DirectButton(parent = self.parent, relief = DGG.RAISED, frameSize = (-0.13, 0.13, -0.040000000000000001, 0.040000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = 'Zone6', text_scale = 0.070000000000000007, text_align = TextNode.ACenter, text_pos = (0, -0.014999999999999999), command = self.setMode, extraArgs = [ Zone6_Tab], pos = (0.28000000000000003, 0, 1.02)) self.zone6Tab.hide() self.zone7Tab = DirectButton(parent = self.parent, relief = DGG.RAISED, frameSize = (-0.13, 0.13, -0.040000000000000001, 0.040000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = 'Zone7', text_scale = 0.070000000000000007, text_align = TextNode.ACenter, text_pos = (0, -0.014999999999999999), command = self.setMode, extraArgs = [ Zone7_Tab], pos = (0.53000000000000003, 0, 1.02)) self.zone7Tab.hide() self.zone8Tab = DirectButton(parent = self.parent, relief = DGG.RAISED, frameSize = (-0.13, 0.13, -0.040000000000000001, 0.040000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = 'Zone8', text_scale = 0.070000000000000007, text_align = TextNode.ACenter, text_pos = (0, -0.014999999999999999), command = self.setMode, extraArgs = [ Zone8_Tab], pos = (0.78000000000000003, 0, 1.02)) self.zone8Tab.hide() def unload(self): del self.main del self.parent del self.avatar def setMode(self, mode, updateAnyways = 0): messenger.send('wakeup') if not updateAnyways: if self.mode == mode: return None else: self.mode = mode self.currTattoo = mode if mode == Zone1_Tab: self.zone1Tab['state'] = DGG.DISABLED self.zone1Tab['relief'] = DGG.SUNKEN self.showZone1TattooCollections() self.zone2Tab['state'] = DGG.NORMAL self.zone2Tab['relief'] = DGG.RAISED self.hideZone2TattooCollections() self.zone3Tab['state'] = DGG.NORMAL self.zone3Tab['relief'] = DGG.RAISED self.hideZone3TattooCollections() self.zone4Tab['state'] = DGG.NORMAL self.zone4Tab['relief'] = DGG.RAISED self.hideZone4TattooCollections() self.zone5Tab['state'] = DGG.NORMAL self.zone5Tab['relief'] = DGG.RAISED self.hideZone5TattooCollections() self.zone6Tab['state'] = DGG.NORMAL self.zone6Tab['relief'] = DGG.RAISED self.hideZone6TattooCollections() self.zone7Tab['state'] = DGG.NORMAL self.zone7Tab['relief'] = DGG.RAISED self.hideZone7TattooCollections() self.zone8Tab['state'] = DGG.NORMAL self.zone8Tab['relief'] = DGG.RAISED self.hideZone8TattooCollections() self.reparentCommonGui(self.zone1Frame, self.zone1FrameTitle) elif mode == Zone2_Tab: self.zone1Tab['state'] = DGG.NORMAL self.zone1Tab['relief'] = DGG.RAISED self.hideZone1TattooCollections() self.zone2Tab['state'] = DGG.DISABLED self.zone2Tab['relief'] = DGG.SUNKEN self.showZone2TattooCollections() self.zone3Tab['state'] = DGG.NORMAL self.zone3Tab['relief'] = DGG.RAISED self.hideZone3TattooCollections() self.zone4Tab['state'] = DGG.NORMAL self.zone4Tab['relief'] = DGG.RAISED self.hideZone4TattooCollections() self.zone5Tab['state'] = DGG.NORMAL self.zone5Tab['relief'] = DGG.RAISED self.hideZone5TattooCollections() self.zone6Tab['state'] = DGG.NORMAL self.zone6Tab['relief'] = DGG.RAISED self.hideZone6TattooCollections() self.zone7Tab['state'] = DGG.NORMAL self.zone7Tab['relief'] = DGG.RAISED self.hideZone7TattooCollections() self.zone8Tab['state'] = DGG.NORMAL self.zone8Tab['relief'] = DGG.RAISED self.hideZone8TattooCollections() self.reparentCommonGui(self.zone2Frame, self.zone2FrameTitle) elif mode == Zone3_Tab: self.zone1Tab['state'] = DGG.NORMAL self.zone1Tab['relief'] = DGG.RAISED self.hideZone1TattooCollections() self.zone2Tab['state'] = DGG.NORMAL self.zone2Tab['relief'] = DGG.RAISED self.hideZone2TattooCollections() self.zone3Tab['state'] = DGG.DISABLED self.zone3Tab['relief'] = DGG.SUNKEN self.showZone3TattooCollections() self.zone4Tab['state'] = DGG.NORMAL self.zone4Tab['relief'] = DGG.RAISED self.hideZone4TattooCollections() self.zone5Tab['state'] = DGG.NORMAL self.zone5Tab['relief'] = DGG.RAISED self.hideZone5TattooCollections() self.zone6Tab['state'] = DGG.NORMAL self.zone6Tab['relief'] = DGG.RAISED self.hideZone6TattooCollections() self.zone7Tab['state'] = DGG.NORMAL self.zone7Tab['relief'] = DGG.RAISED self.hideZone7TattooCollections() self.zone8Tab['state'] = DGG.NORMAL self.zone8Tab['relief'] = DGG.RAISED self.hideZone8TattooCollections() self.reparentCommonGui(self.zone3Frame, self.zone3FrameTitle) elif mode == Zone4_Tab: self.zone1Tab['state'] = DGG.NORMAL self.zone1Tab['relief'] = DGG.RAISED self.hideZone1TattooCollections() self.zone2Tab['state'] = DGG.NORMAL self.zone2Tab['relief'] = DGG.RAISED self.hideZone2TattooCollections() self.zone3Tab['state'] = DGG.NORMAL self.zone3Tab['relief'] = DGG.RAISED self.hideZone3TattooCollections() self.zone4Tab['state'] = DGG.DISABLED self.zone4Tab['relief'] = DGG.SUNKEN self.showZone4TattooCollections() self.zone5Tab['state'] = DGG.NORMAL self.zone5Tab['relief'] = DGG.RAISED self.hideZone5TattooCollections() self.zone6Tab['state'] = DGG.NORMAL self.zone6Tab['relief'] = DGG.RAISED self.hideZone6TattooCollections() self.zone7Tab['state'] = DGG.NORMAL self.zone7Tab['relief'] = DGG.RAISED self.hideZone7TattooCollections() self.zone8Tab['state'] = DGG.NORMAL self.zone8Tab['relief'] = DGG.RAISED self.hideZone8TattooCollections() self.reparentCommonGui(self.zone4Frame, self.zone4FrameTitle) elif mode == Zone5_Tab: self.zone1Tab['state'] = DGG.NORMAL self.zone1Tab['relief'] = DGG.RAISED self.hideZone1TattooCollections() self.zone2Tab['state'] = DGG.NORMAL self.zone2Tab['relief'] = DGG.RAISED self.hideZone2TattooCollections() self.zone3Tab['state'] = DGG.NORMAL self.zone3Tab['relief'] = DGG.RAISED self.hideZone3TattooCollections() self.zone4Tab['state'] = DGG.NORMAL self.zone4Tab['relief'] = DGG.RAISED self.hideZone4TattooCollections() self.zone5Tab['state'] = DGG.DISABLED self.zone5Tab['relief'] = DGG.SUNKEN self.showZone5TattooCollections() self.zone6Tab['state'] = DGG.NORMAL self.zone6Tab['relief'] = DGG.RAISED self.hideZone6TattooCollections() self.zone7Tab['state'] = DGG.NORMAL self.zone7Tab['relief'] = DGG.RAISED self.hideZone7TattooCollections() self.zone8Tab['state'] = DGG.NORMAL self.zone8Tab['relief'] = DGG.RAISED self.hideZone8TattooCollections() self.reparentCommonGui(self.zone5Frame, self.zone5FrameTitle) elif mode == Zone6_Tab: self.zone1Tab['state'] = DGG.NORMAL self.zone1Tab['relief'] = DGG.RAISED self.hideZone1TattooCollections() self.zone2Tab['state'] = DGG.NORMAL self.zone2Tab['relief'] = DGG.RAISED self.hideZone2TattooCollections() self.zone3Tab['state'] = DGG.NORMAL self.zone3Tab['relief'] = DGG.RAISED self.hideZone3TattooCollections() self.zone4Tab['state'] = DGG.NORMAL self.zone4Tab['relief'] = DGG.RAISED self.hideZone4TattooCollections() self.zone5Tab['state'] = DGG.NORMAL self.zone5Tab['relief'] = DGG.RAISED self.hideZone5TattooCollections() self.zone6Tab['state'] = DGG.DISABLED self.zone6Tab['relief'] = DGG.SUNKEN self.showZone6TattooCollections() self.zone7Tab['state'] = DGG.NORMAL self.zone7Tab['relief'] = DGG.RAISED self.hideZone7TattooCollections() self.zone8Tab['state'] = DGG.NORMAL self.zone8Tab['relief'] = DGG.RAISED self.hideZone8TattooCollections() self.reparentCommonGui(self.zone6Frame, self.zone6FrameTitle) elif mode == Zone7_Tab: self.zone1Tab['state'] = DGG.NORMAL self.zone1Tab['relief'] = DGG.RAISED self.hideZone1TattooCollections() self.zone2Tab['state'] = DGG.NORMAL self.zone2Tab['relief'] = DGG.RAISED self.hideZone2TattooCollections() self.zone3Tab['state'] = DGG.NORMAL self.zone3Tab['relief'] = DGG.RAISED self.hideZone3TattooCollections() self.zone4Tab['state'] = DGG.NORMAL self.zone4Tab['relief'] = DGG.RAISED self.hideZone4TattooCollections() self.zone5Tab['state'] = DGG.NORMAL self.zone5Tab['relief'] = DGG.RAISED self.hideZone5TattooCollections() self.zone6Tab['state'] = DGG.NORMAL self.zone6Tab['relief'] = DGG.RAISED self.hideZone6TattooCollections() self.zone7Tab['state'] = DGG.DISABLED self.zone7Tab['relief'] = DGG.SUNKEN self.showZone7TattooCollections() self.zone8Tab['state'] = DGG.NORMAL self.zone8Tab['relief'] = DGG.RAISED self.hideZone8TattooCollections() self.reparentCommonGui(self.zone7Frame, self.zone7FrameTitle) elif mode == Zone8_Tab: self.zone1Tab['state'] = DGG.NORMAL self.zone1Tab['relief'] = DGG.RAISED self.hideZone1TattooCollections() self.zone2Tab['state'] = DGG.NORMAL self.zone2Tab['relief'] = DGG.RAISED self.hideZone2TattooCollections() self.zone3Tab['state'] = DGG.NORMAL self.zone3Tab['relief'] = DGG.RAISED self.hideZone3TattooCollections() self.zone4Tab['state'] = DGG.NORMAL self.zone4Tab['relief'] = DGG.RAISED self.hideZone4TattooCollections() self.zone5Tab['state'] = DGG.NORMAL self.zone5Tab['relief'] = DGG.RAISED self.hideZone5TattooCollections() self.zone6Tab['state'] = DGG.NORMAL self.zone6Tab['relief'] = DGG.RAISED self.hideZone6TattooCollections() self.zone7Tab['state'] = DGG.NORMAL self.zone7Tab['relief'] = DGG.RAISED self.hideZone7TattooCollections() self.zone8Tab['state'] = DGG.DISABLED self.zone8Tab['relief'] = DGG.SUNKEN self.showZone8TattooCollections() self.reparentCommonGui(self.zone8Frame, self.zone8FrameTitle) def setEdit(self, mode): print 'editing %s' % mode self.guiNextTattooButton.show() self.guiLastTattooButton.show() self.oXSlider.show() self.oYSlider.show() self.rotateSlider.show() self.scaleSlider.show() self.editButtons[mode]['state'] = DGG.DISABLED self.editButtons[mode]['relief'] = DGG.SUNKEN if self.avatar.pirate.style.gender == 'f': self.avatar.tattoos[mode] = PirateFemale.vector_tattoos[mode][:] else: self.avatar.tattoos[mode] = PirateMale.vector_tattoos[mode][:] if mode == Zone1_Tab: idx = self.avatar.pirate.style.getTattooChest()[0] elif mode == Zone2_Tab: idx = self.avatar.pirate.style.getTattooZone2()[0] elif mode == Zone3_Tab: idx = self.avatar.pirate.style.getTattooZone3()[0] elif mode == Zone4_Tab: idx = self.avatar.pirate.style.getTattooZone4()[0] elif mode == Zone5_Tab: idx = self.avatar.pirate.style.getTattooZone5()[0] elif mode == Zone6_Tab: idx = self.avatar.pirate.style.getTattooZone6()[0] elif mode == Zone7_Tab: idx = self.avatar.pirate.style.getTattooZone7()[0] elif mode == Zone8_Tab: idx = self.avatar.pirate.style.getTattooZone8()[0] self.avatar.tattoos[mode][0] = idx self.vTattoos[mode] = self.avatar.tattoos[mode][:] self.restore() def reparentCommonGui(self, currTattoo, currTattooFrame): self.guiNextTattooButton.reparentTo(currTattoo) self.guiLastTattooButton.reparentTo(currTattoo) self.map.reparentTo(currTattoo) self.oXSlider.reparentTo(currTattooFrame) self.oYSlider.reparentTo(currTattooFrame) self.scaleSlider.reparentTo(currTattooFrame) self.rotateSlider.reparentTo(currTattooFrame) self.guiNextTattooButton.hide() self.guiLastTattooButton.hide() self.oXSlider.hide() self.oYSlider.hide() self.scaleSlider.hide() self.rotateSlider.hide() def showZone1TattooCollections(self): self.zone1FrameTitle.show() self.zone1Frame.show() def hideZone1TattooCollections(self): self.zone1FrameTitle.hide() self.zone1Frame.hide() self.editZone1['state'] = DGG.NORMAL self.editZone1['relief'] = DGG.RAISED def showZone2TattooCollections(self): self.zone2FrameTitle.show() self.zone2Frame.show() def hideZone2TattooCollections(self): self.zone2FrameTitle.hide() self.zone2Frame.hide() self.editZone2['state'] = DGG.NORMAL self.editZone2['relief'] = DGG.RAISED def showZone3TattooCollections(self): self.zone3FrameTitle.show() self.zone3Frame.show() def hideZone3TattooCollections(self): self.zone3FrameTitle.hide() self.zone3Frame.hide() self.editZone3['state'] = DGG.NORMAL self.editZone3['relief'] = DGG.RAISED def showZone4TattooCollections(self): self.zone4FrameTitle.show() self.zone4Frame.show() def hideZone4TattooCollections(self): self.zone4FrameTitle.hide() self.zone4Frame.hide() self.editZone4['state'] = DGG.NORMAL self.editZone4['relief'] = DGG.RAISED def showZone5TattooCollections(self): self.zone5FrameTitle.show() self.zone5Frame.show() def hideZone5TattooCollections(self): self.zone5FrameTitle.hide() self.zone5Frame.hide() def showZone6TattooCollections(self): self.zone6FrameTitle.show() self.zone6Frame.show() def hideZone6TattooCollections(self): self.zone6FrameTitle.hide() self.zone6Frame.hide() def showZone7TattooCollections(self): self.zone7FrameTitle.show() self.zone7Frame.show() def hideZone7TattooCollections(self): self.zone7FrameTitle.hide() self.zone7Frame.hide() def showZone8TattooCollections(self): self.zone8FrameTitle.show() self.zone8Frame.show() def hideZone8TattooCollections(self): self.zone8FrameTitle.hide() self.zone8Frame.hide() def show(self): self.zone1Tab.show() self.zone2Tab.show() self.zone3Tab.show() self.zone4Tab.show() self.zone5Tab.show() self.zone6Tab.show() self.zone7Tab.show() self.zone8Tab.show() def hide(self): self.mode = -1 self.hideZone1TattooCollections() self.zone1Tab.hide() self.zone1Tab['state'] = DGG.NORMAL self.hideZone2TattooCollections() self.zone2Tab.hide() self.zone2Tab['state'] = DGG.NORMAL self.hideZone3TattooCollections() self.zone3Tab.hide() self.zone3Tab['state'] = DGG.NORMAL self.hideZone4TattooCollections() self.zone4Tab.hide() self.zone4Tab['state'] = DGG.NORMAL self.hideZone5TattooCollections() self.zone5Tab.hide() self.zone5Tab['state'] = DGG.NORMAL self.hideZone6TattooCollections() self.zone6Tab.hide() self.zone6Tab['state'] = DGG.NORMAL self.hideZone7TattooCollections() self.zone7Tab.hide() self.zone7Tab['state'] = DGG.NORMAL self.hideZone8TattooCollections() self.zone8Tab.hide() self.zone8Tab['state'] = DGG.NORMAL self.saveDNA() def setupButtons(self): self.guiNextTattooButton = DirectButton(parent = self.zone1Frame, relief = DGG.RAISED, pos = (0.29999999999999999, 0.0, -0.5), scale = (2.0, 2.0, 2.0), command = self.handleNextTattoo, frameSize = (-0.089999999999999997, 0.089999999999999997, -0.050000000000000003, 0.050000000000000003), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = '>>', text_pos = (0, -0.014999999999999999), text_scale = 0.10000000000000001) self.guiLastTattooButton = DirectButton(parent = self.zone1Frame, relief = DGG.RAISED, pos = (-0.29999999999999999, 0.0, -0.5), scale = (2.0, 2.0, 2.0), command = self.handleLastTattoo, frameSize = (-0.089999999999999997, 0.089999999999999997, -0.050000000000000003, 0.050000000000000003), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = '<<', text_pos = (0, -0.014999999999999999), text_scale = 0.10000000000000001) def reset(self): if self.avatar.pirate.style.gender == 'f': for i in range(0, 8): self.avatar.tattoos[i] = PirateFemale.vector_tattoos[i][:] else: for i in range(0, 8): self.avatar.tattoos[i] = PirateMale.vector_tattoos[i][:] for i in range(0, 8): self.vTattoos[i] = self.avatar.tattoos[i][:] val = self.avatar.tattoos[ZONE1] self.avatar.pirate.setTattooChest(val[TYPE], val[OFFSETX], val[OFFSETY], val[SCALE], val[ROTATE], val[COLOR]) val = self.avatar.tattoos[ZONE2] self.avatar.pirate.setTattooZone2(val[TYPE], val[OFFSETX], val[OFFSETY], val[SCALE], val[ROTATE], val[COLOR]) val = self.avatar.tattoos[ZONE3] self.avatar.pirate.setTattooZone3(val[TYPE], val[OFFSETX], val[OFFSETY], val[SCALE], val[ROTATE], val[COLOR]) val = self.avatar.tattoos[ZONE4] self.avatar.pirate.setTattooZone4(val[TYPE], val[OFFSETX], val[OFFSETY], val[SCALE], val[ROTATE], val[COLOR]) val = self.avatar.tattoos[ZONE5] self.avatar.pirate.setTattooZone5(val[TYPE], val[OFFSETX], val[OFFSETY], val[SCALE], val[ROTATE], val[COLOR]) val = self.avatar.tattoos[ZONE6] self.avatar.pirate.setTattooZone6(val[TYPE], val[OFFSETX], val[OFFSETY], val[SCALE], val[ROTATE], val[COLOR]) val = self.avatar.tattoos[ZONE7] self.avatar.pirate.setTattooZone7(val[TYPE], val[OFFSETX], val[OFFSETY], val[SCALE], val[ROTATE], val[COLOR]) val = self.avatar.tattoos[ZONE8] self.avatar.pirate.setTattooZone8(val[TYPE], val[OFFSETX], val[OFFSETY], val[SCALE], val[ROTATE], val[COLOR]) self.avatar.handleTattooMapping() self.updateCard() self.restore() def saveDNA(self): tattoo = self.avatar.tattoos[ZONE1] self.avatar.pirate.setTattooChest(tattoo[TYPE], tattoo[OFFSETX], tattoo[OFFSETY], tattoo[SCALE], tattoo[ROTATE], tattoo[COLOR]) tattoo = self.avatar.tattoos[ZONE2] self.avatar.pirate.setTattooZone2(tattoo[TYPE], tattoo[OFFSETX], tattoo[OFFSETY], tattoo[SCALE], tattoo[ROTATE], tattoo[COLOR]) tattoo = self.avatar.tattoos[ZONE3] self.avatar.pirate.setTattooZone3(tattoo[TYPE], tattoo[OFFSETX], tattoo[OFFSETY], tattoo[SCALE], tattoo[ROTATE], tattoo[COLOR]) tattoo = self.avatar.tattoos[ZONE4] self.avatar.pirate.setTattooZone4(tattoo[TYPE], tattoo[OFFSETX], tattoo[OFFSETY], tattoo[SCALE], tattoo[ROTATE], tattoo[COLOR]) tattoo = self.avatar.tattoos[ZONE5] self.avatar.pirate.setTattooZone5(tattoo[TYPE], tattoo[OFFSETX], tattoo[OFFSETY], tattoo[SCALE], tattoo[ROTATE], tattoo[COLOR]) tattoo = self.avatar.tattoos[ZONE6] self.avatar.pirate.setTattooZone6(tattoo[TYPE], tattoo[OFFSETX], tattoo[OFFSETY], tattoo[SCALE], tattoo[ROTATE], tattoo[COLOR]) tattoo = self.avatar.tattoos[ZONE7] self.avatar.pirate.setTattooZone7(tattoo[TYPE], tattoo[OFFSETX], tattoo[OFFSETY], tattoo[SCALE], tattoo[ROTATE], tattoo[COLOR]) tattoo = self.avatar.tattoos[ZONE8] self.avatar.pirate.setTattooZone8(tattoo[TYPE], tattoo[OFFSETX], tattoo[OFFSETY], tattoo[SCALE], tattoo[ROTATE], tattoo[COLOR]) def loadFromDNA(self): if self.avatar.pirate.style.gender == 'f': for i in range(0, 8): self.avatar.tattoos[i] = PirateFemale.vector_tattoos[i][:] else: for i in range(0, 8): self.avatar.tattoos[i] = PirateMale.vector_tattoos[i][:] self.avatar.tattoos[0][0] = self.avatar.pirate.style.getTattooChest()[0] self.avatar.tattoos[1][0] = self.avatar.pirate.style.getTattooZone2()[0] self.avatar.tattoos[2][0] = self.avatar.pirate.style.getTattooZone3()[0] self.avatar.tattoos[3][0] = self.avatar.pirate.style.getTattooZone4()[0] self.avatar.tattoos[4][0] = self.avatar.pirate.style.getTattooZone5()[0] self.avatar.tattoos[5][0] = self.avatar.pirate.style.getTattooZone6()[0] self.avatar.tattoos[6][0] = self.avatar.pirate.style.getTattooZone7()[0] self.avatar.tattoos[7][0] = self.avatar.pirate.style.getTattooZone8()[0] for i in range(0, 8): self.vTattoos[i] = self.avatar.tattoos[i][:] def restore(self): val = self.vTattoos[self.currTattoo] self.oXSlider.node().setValue(val[OFFSETX]) self.oYSlider.node().setValue(val[OFFSETY]) self.scaleSlider.node().setValue(val[SCALE]) self.rotateSlider.node().setValue(val[ROTATE]) def randomPick(self): pass def applyBaseTexture(self, textureName = 'male_tattoomap'): t1 = loader.loadTexture('maps/' + textureName + '.jpg') self.map.setTexture(t1) def handleNextTattoo(self): tattoo = self.vTattoos[self.currTattoo] tattoo[TYPE] += 1 if tattoo[TYPE] >= len(TattooGlobals.tattooNames): tattoo[TYPE] = 0 self.avatar.tattoos[self.currTattoo][TYPE] = tattoo[TYPE] self.mapTexture(self.currTattoo, tattoo[OFFSETX], tattoo[OFFSETY], tattoo[SCALE], tattoo[ROTATE]) self.updateCard() self.avatar.updateTattoo(self.currTattoo) self.notify.info('Current Tattoo: %s' % TattooGlobals.tattooNames[self.avatar.tattoos[self.currTattoo][TYPE]]) def handleLastTattoo(self): tattoo = self.vTattoos[self.currTattoo] tattoo[TYPE] -= 1 if tattoo[TYPE] < 0: tattoo[TYPE] = len(TattooGlobals.tattooNames) - 1 self.avatar.tattoos[self.currTattoo][TYPE] = tattoo[TYPE] self.mapTexture(self.currTattoo, tattoo[OFFSETX], tattoo[OFFSETY], tattoo[SCALE], tattoo[ROTATE]) self.updateCard() self.avatar.updateTattoo(self.currTattoo) self.notify.info('Current Tattoo: %s' % TattooGlobals.tattooNames[self.avatar.tattoos[self.currTattoo][TYPE]]) def updateCard(self): tattooFrame = [ self.zone1Frame, self.zone2Frame, self.zone3Frame, self.zone4Frame, self.zone5Frame, self.zone6Frame, self.zone7Frame, self.zone8Frame] tattoo = self.avatar.tattoos[self.currTattoo] (tex, scale) = TattooGlobals.getTattooImage(tattoo[0]) t = TransformState.makePosRotateScale2d(Vec2(tattoo[OFFSETX], tattoo[OFFSETY]), tattoo[ROTATE], Vec2(tattoo[SCALE] * scale, tattoo[SCALE])) self.map.setTexTransform(self.cStage, t) self.map.setTexture(self.cStage, tex) tattooFrame[self.currTattoo]['text'] = TattooGlobals.tattooNames[self.avatar.tattoos[self.currTattoo][TYPE]] def mapTexture(self, index, offsetx, offsety, scale, rotate): S = Vec2(1 / float(scale), 1 / float(scale)) Iv = Vec2(offsetx, offsety) Vm = Vec2(sin(rotate * pi / 180.0), cos(rotate * pi / 180.0)) Vms = Vec2(Vm[0] * S[0], Vm[1] * S[1]) Vn = Vec2(Vm[1], -Vm[0]) Vns = Vec2(Vn[0] * S[0], Vn[1] * S[1]) F = Vec2(-Vns.dot(Iv) + 0.5, -Vms.dot(Iv) + 0.5) self.avatar.tattoos[index][1] = F[0] self.avatar.tattoos[index][2] = F[1] self.avatar.tattoos[index][3] = S[0] self.avatar.tattoos[index][4] = rotate self.vTattoos[index] = [ self.vTattoos[index][TYPE], offsetx, offsety, scale, rotate, self.vTattoos[index][COLOR]] def handleOxSlider(self, pgs): if self.currTattoo < 0: return None value = pgs['value'] tattoo = self.vTattoos[self.currTattoo] self.mapTexture(self.currTattoo, value, tattoo[OFFSETY], tattoo[SCALE], tattoo[ROTATE]) self.updateCard() self.avatar.updateTattoo(self.currTattoo) def handleOySlider(self, pgs): if self.currTattoo < 0: return None value = pgs['value'] tattoo = self.vTattoos[self.currTattoo] self.mapTexture(self.currTattoo, tattoo[OFFSETX], value, tattoo[SCALE], tattoo[ROTATE]) self.updateCard() self.avatar.updateTattoo(self.currTattoo) def handleScaleSlider(self, pgs): if self.currTattoo < 0: return None value = pgs['value'] tattoo = self.vTattoos[self.currTattoo] self.mapTexture(self.currTattoo, tattoo[OFFSETX], tattoo[OFFSETY], value, tattoo[ROTATE]) self.updateCard() self.avatar.updateTattoo(self.currTattoo) def handleRotateSlider(self, pgs): if self.currTattoo < 0: return None value = pgs['value'] tattoo = self.vTattoos[self.currTattoo] self.mapTexture(self.currTattoo, tattoo[OFFSETX], tattoo[OFFSETY], tattoo[SCALE], value) self.updateCard() self.avatar.updateTattoo(self.currTattoo)
class Eyes(DirectObject.DirectObject): notify = DirectNotifyGlobal.directNotify.newCategory('Eyes') def __init__(self, main = None): self.main = main.main self.parent = main.parent self.avatar = main.avatar self.mode = None self.load() def enter(self): self.notify.debug('enter') self.showEyesCollections() self.loadExtraArgs() if self.mode == None: self.mode = -1 def exit(self): self.hide() def load(self): self.notify.debug('loading eyes') self.setupButtons() self.loadGUI() self.loadExtraArgs() def loadGUI(self): customRrange = (-1.0, 1.0) self.pgs1 = CharGuiSlider(self.main, parent = self.browFrame, text = PLocalizer.EyeBrowProtruding, range = (0.0, 1.0), command = self.updateControlShape) self.pgs1.setPos(-0.40000000000000002, 0, -0.29999999999999999) self.pgs6 = CharGuiSlider(self.main, parent = self.eyeFrame, text = PLocalizer.EyeCorner, command = self.updateControlShape, range = (-0.25, 0.25)) self.pgs6.setPos(-0.40000000000000002, 0, -0.29999999999999999) self.pgs7 = CharGuiSlider(self.main, parent = self.eyeFrame, text = PLocalizer.EyeOpeningSize, range = (-1, 1), command = self.updateControlShape) self.pgs7.setPos(-0.40000000000000002, 0, -0.55000000000000004) self.pgs8 = CharGuiSlider(self.main, parent = self.eyeFrame, text = PLocalizer.EyeSpacing, range = (-1, 1), command = self.updateControlShape) self.pgs8.setPos(-0.40000000000000002, 0, -0.80000000000000004) self.pgs = [ self.pgs1, self.pgs6, self.pgs7, self.pgs8] def unload(self): self.notify.debug('called eyes unload') del self.main del self.parent del self.avatar def loadExtraArgs(self): self.pgs1['extraArgs'] = [ self.pgs1, 'browProtruding', 135] self.pgs6['extraArgs'] = [ self.pgs6, 'eyeCorner'] self.pgs7['extraArgs'] = [ self.pgs7, 'eyeOpeningSize'] self.pgs8['extraArgs'] = [ self.pgs8, 'eyeSpacing'] def showEyesCollections(self): self.browFrame.show() self.eyeFrame.show() self.colorPicker.show() def hideEyesCollections(self): self.browFrame.hide() self.eyeFrame.hide() self.colorPicker.hide() def hide(self): self.hideEyesCollections() self.saveDNA() def setupButtons(self): self.browFrame = DirectFrame(parent = self.parent, relief = None, text = PLocalizer.EyeBrowFrameTitle, text_fg = (1, 1, 1, 1), text_scale = 0.17999999999999999, text_pos = (0, -0.050000000000000003), pos = (0, 0, -0.10000000000000001), scale = 0.69999999999999996) self.browFrame.hide() self.eyeFrame = DirectFrame(parent = self.parent, relief = None, text = PLocalizer.EyeFrameTitle, text_fg = (1, 1, 1, 1), text_scale = 0.17999999999999999, text_pos = (0, -0.050000000000000003), pos = (0, 0, -1.1000000000000001), scale = 0.69999999999999996) self.eyeFrame.hide() self.colorPicker = CharGuiPicker(self.main, parent = self.parent, text = PLocalizer.EyesColorFrameTitle, nextCommand = self.handleNextColor, backCommand = self.handleLastColor) self.colorPicker.setPos(0, 0, 0.20000000000000001) self.colorPicker.hide() def saveDNA(self): self.avatar.pirate.setBrowProtruding(self.pgs1.node().getValue()) self.avatar.pirate.setEyeCorner(self.pgs6.node().getValue()) self.avatar.pirate.setEyeOpeningSize(self.pgs7.node().getValue()) self.avatar.pirate.setEyeBulge(self.pgs8.node().getValue()) def restore(self): self.pgs1.node().setValue(self.avatar.dna.getBrowProtruding()) self.pgs6.node().setValue(self.avatar.dna.getEyeCorner()) self.pgs7.node().setValue(self.avatar.dna.getEyeOpeningSize()) self.pgs8.node().setValue(self.avatar.dna.getEyeBulge()) def reset(self): for i in xrange(0, len(self.pgs)): self.resetSlider(self.pgs[i]) self.avatar.eyesColorIdx = 0 self.avatar.pirate.setEyesColor(self.avatar.eyesColorIdx) self.avatar.pirate.generateEyesTexture() self.saveDNA() def resetSlider(self, slider): slider.node().setValue(0.0) def randomPick(self): global damper damper = 1.0 for i in xrange(0, len(self.pgs)): slider = self.pgs[i] self.resetSlider(slider) if self.avatar.pirate.gender == 'f': if slider == self.pgs6: continue if random.choice([ 0, 1]): value = random.random() * damper toss = 0 if slider['range'][0] < 0: toss = random.choice([ 0, 1]) if toss: slider.node().setValue(-value) else: slider.node().setValue(value) self.saveDNA() choice = random.choice(range(0, self.avatar.numEyeColors)) self.avatar.eyesColorIdx = choice self.avatar.pirate.setEyesColor(self.avatar.eyesColorIdx) self.avatar.pirate.generateEyesTexture() def handleNextColor(self): self.avatar.eyesColorIdx = (self.avatar.eyesColorIdx + 1) % self.avatar.numEyeColors self.notify.debug('new color idx %s' % self.avatar.eyesColorIdx) self.avatar.pirate.setEyesColor(self.avatar.eyesColorIdx) self.avatar.pirate.generateEyesTexture() def handleLastColor(self): self.avatar.eyesColorIdx = (self.avatar.eyesColorIdx - 1) % self.avatar.numEyeColors self.notify.debug('new color idx %s' % self.avatar.eyesColorIdx) self.avatar.pirate.setEyesColor(self.avatar.eyesColorIdx) self.avatar.pirate.generateEyesTexture() def updateControlShape(self, pgs, extraArgs1 = None, extraArgs2 = None): if extraArgs1 != None: self.avatar.pirate.setControlValue(pgs.node().getValue(), extraArgs1) self.main.handleQuarterView(extraArgs2)
class Ear(DirectObject.DirectObject): notify = DirectNotifyGlobal.directNotify.newCategory('Ear') def __init__(self, main = None): self.main = main.main self.parent = main.parent self.avatar = main.avatar self.mode = None self.load() def enter(self): self.notify.debug('enter') self.showEarCollections() self.loadExtraArgs() if self.mode == None: self.mode = -1 def exit(self): self.hide() def load(self): self.notify.debug('loading ear') self.setupButtons() self.loadGUI() self.loadExtraArgs() def loadGUI(self): global sliderRange customRange = (-1.0, 1.0) if self.main.wantMarketingViewer: sliderRange = (-1.0, 1.0) self.pgs1 = CharGuiSlider(self.main, parent = self.earFrame, text = PLocalizer.EarScale, range = sliderRange, command = self.updateControlShape) self.pgs1.setPos(-0.40000000000000002, 0, -0.29999999999999999) self.pgs2 = CharGuiSlider(self.main, parent = self.earFrame, text = PLocalizer.EarFlapAngle, range = sliderRange, command = self.updateControlShape) self.pgs2.setPos(-0.40000000000000002, 0, -0.55000000000000004) self.pgs3 = CharGuiSlider(self.main, parent = self.earFrame, text = PLocalizer.EarPosition, range = sliderRange, command = self.updateControlShape) self.pgs3.setPos(-0.40000000000000002, 0, -0.80000000000000004) self.pgs = [ self.pgs1, self.pgs2, self.pgs3] def unload(self): self.notify.debug('called ear unload') del self.main del self.parent del self.avatar def loadExtraArgs(self): self.pgs1['extraArgs'] = [ self.pgs1, 'earScale'] self.pgs2['extraArgs'] = [ self.pgs2, 'earFlap'] self.pgs3['extraArgs'] = [ self.pgs3, 'earPosition'] def showEarCollections(self): self.earFrame.show() def hideEarCollections(self): self.earFrame.hide() def hide(self): self.hideEarCollections() self.saveDNA() def setupButtons(self): self.earFrame = DirectFrame(parent = self.parent, relief = None, text = PLocalizer.EarFrameTitle, text_fg = (1, 1, 1, 1), text_scale = 0.17999999999999999, text_pos = (0, -0.050000000000000003), pos = (0, 0, 0), scale = 0.69999999999999996) self.earFrame.hide() def saveDNA(self): self.avatar.pirate.setEarScale(self.pgs1.node().getValue()) self.avatar.pirate.setEarFlapAngle(self.pgs2.node().getValue()) self.avatar.pirate.setEarPosition(self.pgs3.node().getValue()) def restore(self): self.pgs1.node().setValue(self.avatar.dna.getEarScale()) self.pgs2.node().setValue(self.avatar.dna.getEarFlapAngle()) self.pgs3.node().setValue(self.avatar.dna.getEarPosition()) def reset(self): for i in xrange(0, len(self.pgs)): self.resetSlider(self.pgs[i]) self.saveDNA() def resetSlider(self, slider): slider.node().setValue(0.0) def randomPick(self): global damper damper = 1.0 for i in xrange(0, len(self.pgs)): slider = self.pgs[i] self.resetSlider(slider) if random.choice([ 0, 1]): value = random.random() * damper toss = 0 if slider['range'][0] < 0: toss = random.choice([ 0, 1]) if toss: slider.node().setValue(-value) else: slider.node().setValue(value) self.saveDNA() def updateControlShape(self, pgs, extraArgs1 = None, extraArgs2 = None): if extraArgs1 != None: self.avatar.pirate.setControlValue(pgs.node().getValue(), extraArgs1) self.main.handleQuarterView(extraArgs2)
class BodyGUI(DirectFrame, StateData.StateData): maleShapeButtonIcons = [] maleShapeButtonIconsOver = [] femaleShapeButtonIcons = [] femaleShapeButtonIconsOver = [] notify = DirectNotifyGlobal.directNotify.newCategory('BodyGUI') bodyHeights = { } bodyHeights['m'] = Human.BodyScales[0] bodyHeights['f'] = Human.BodyScales[1] bodyHeights['n'] = Human.BodyScales[0] def __init__(self, main = None): self.main = main self.parent = main.bookModel self.avatar = main.avatar self.mode = None self.entered = False def enter(self): self.notify.debug('enter') self.entered = True if self.mode == None: self.load() self.mode = -1 self.show() def exit(self): self.entered = False self.notify.debug('called bodyGUI exit') self.hide() def save(self): if self.mode == -1: pass 1 def assignAvatar(self, avatar): self.avatar = avatar self.heightSlider.setValue(self.avatar.pirate.getStyle().getBodyHeight()) def load(self): self.notify.debug('loading BodyGUI') self.loadShapeGUI() self.loadHeightGUI() self.loadColorGUI() self.setupButtons() def loadShapeGUI(self): self.maleShapeButtonIcons = [ self.main.charGui.find('**/chargui_male_a'), self.main.charGui.find('**/chargui_male_b'), self.main.charGui.find('**/chargui_male_c'), self.main.charGui.find('**/chargui_male_d'), self.main.charGui.find('**/chargui_male_e')] self.maleShapeButtonIconsOver = [ self.main.charGui.find('**/chargui_male_a_over'), self.main.charGui.find('**/chargui_male_b_over'), self.main.charGui.find('**/chargui_male_c_over'), self.main.charGui.find('**/chargui_male_d_over'), self.main.charGui.find('**/chargui_male_e_over')] self.femaleShapeButtonIcons = [ self.main.charGui.find('**/chargui_female_a'), self.main.charGui.find('**/chargui_female_b'), self.main.charGui.find('**/chargui_female_c'), self.main.charGui.find('**/chargui_female_d'), self.main.charGui.find('**/chargui_female_e')] self.femaleShapeButtonIconsOver = [ self.main.charGui.find('**/chargui_female_a_over'), self.main.charGui.find('**/chargui_female_b_over'), self.main.charGui.find('**/chargui_female_c_over'), self.main.charGui.find('**/chargui_female_d_over'), self.main.charGui.find('**/chargui_female_e_over')] self.shapeFrameTitle = DirectFrame(parent = self.parent, relief = None, text = PLocalizer.BodyShapeFrameTitle, text_fg = (1, 1, 1, 1), text_scale = 0.17999999999999999, text_pos = (0, 0), pos = (0, 0, -0.10000000000000001), scale = 0.69999999999999996) self.shapeFrameTitle.hide() def loadHeightGUI(self): self.heightSlider = CharGuiSlider(self.main, parent = self.parent, text = PLocalizer.BodyHeightFrameTitle, command = self.updateHeightSlider, range = (-0.20000000000000001, 0.20000000000000001)) self.heightSlider.setPos(-0.29999999999999999, 0, -0.69999999999999996) self.heightSlider.setScale(0.69999999999999996) self.heightSlider['extraArgs'] = [ self.heightSlider, 0, 0] self.pgs = [ self.heightSlider] def loadColorGUI(self): idx = 0 self.maleColorFrameTitle = DirectFrame(parent = self.parent, relief = None, image = self.main.charGui.find('**/chargui_frame05'), image_pos = (0, 0, -0.59999999999999998), image_scale = (1.5, 1, 1.25), text = PLocalizer.BodyColorFrameTitle, text_fg = (1, 1, 1, 1), text_scale = 0.17999999999999999, text_pos = (0, -0.040000000000000001), pos = (0, 0, -1.0), scale = 0.69999999999999996) self.maleColorFrameTitle.hide() self.maleColorButtons = [] xOffset = -0.40000000000000002 yOffset = -0.29999999999999999 whiteSkinTone = (1.0, 1.0, 1.0) for i in range(0, len(HumanDNA.skinColors)): if i and i % 5 == 0: xOffset = -0.40000000000000002 yOffset -= 0.20000000000000001 skinColor = HumanDNA.skinColors[i] skinTone = (skinColor[0] * whiteSkinTone[0], skinColor[1] * whiteSkinTone[1], skinColor[2] * whiteSkinTone[2], 1.0) self.maleColorButtons.append(DirectButton(parent = self.maleColorFrameTitle, relief = DGG.RAISED, pos = (xOffset, 0, yOffset), frameSize = (-0.10000000000000001, 0.10000000000000001, -0.10000000000000001, 0.10000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), frameColor = skinTone, command = self.handleSetColor, extraArgs = [ i])) xOffset += 0.20000000000000001 idx = 1 self.femaleColorFrameTitle = DirectFrame(parent = self.parent, relief = None, image = self.main.charGui.find('**/chargui_frame05'), image_pos = (0, 0, -0.59999999999999998), image_scale = (1.5, 1, 1.25), text = PLocalizer.BodyColorFrameTitle, text_fg = (1, 1, 1, 1), text_scale = 0.17999999999999999, text_pos = (0, -0.040000000000000001), pos = (0, 0, -1.0), scale = 0.69999999999999996) self.femaleColorFrameTitle.hide() self.femaleColorButtons = [] xOffset = -0.40000000000000002 yOffset = -0.29999999999999999 whiteSkinTone = (1.0, 1.0, 1.0) for i in range(0, len(HumanDNA.skinColors)): if i and i % 5 == 0: xOffset = -0.40000000000000002 yOffset -= 0.20000000000000001 skinColor = HumanDNA.skinColors[i] skinTone = (skinColor[0] * whiteSkinTone[0], skinColor[1] * whiteSkinTone[1], skinColor[2] * whiteSkinTone[2], 1.0) self.femaleColorButtons.append(DirectButton(parent = self.femaleColorFrameTitle, relief = DGG.RAISED, pos = (xOffset, 0, yOffset), frameSize = (-0.10000000000000001, 0.10000000000000001, -0.10000000000000001, 0.10000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), frameColor = skinTone, command = self.handleSetColor, extraArgs = [ i])) xOffset += 0.20000000000000001 def unload(self): self.notify.debug('called bodyGUI unload') del self.main del self.parent del self.avatar def showShapeCollections(self): if self.entered: self.shapeFrameTitle.show() if self.main.pirate.style.body.shape in BodyDefs.BodyChoiceGenderDict[self.main.pirate.style.gender]: shapebuttonIndex = BodyDefs.BodyChoiceGenderDict[self.main.pirate.style.gender].index(self.main.pirate.style.body.shape) else: shapebuttonIndex = 2 self.shapeButtons[shapebuttonIndex].setColor(1, 1, 0, 1) def showHeightCollections(self): if self.entered: self.heightSlider.show() def showColorCollections(self): if self.entered: if self.main.pirate.style.gender == 'f': self.femaleColorFrameTitle.show() self.femaleColorButtons[self.main.pirate.style.body.color]['relief'] = DGG.SUNKEN else: self.maleColorFrameTitle.show() self.maleColorButtons[self.main.pirate.style.body.color]['relief'] = DGG.SUNKEN def hideShapeCollections(self): self.shapeFrameTitle.hide() def hideHeightCollections(self): self.heightSlider.hide() def hideColorCollections(self): self.maleColorFrameTitle.hide() self.femaleColorFrameTitle.hide() def show(self): self.showShapeCollections() self.showHeightCollections() self.showColorCollections() def hide(self): self.hideShapeCollections() self.hideHeightCollections() self.hideColorCollections() def setupButtons(self): self.texturePicker = CharGuiPicker(self.main, parent = self.parent, text = PLocalizer.BodyHairFrameTitle, nextCommand = self.handleNextTexture, backCommand = self.handleLastTexture) self.texturePicker.setPos(0, 0, -1) self.texturePicker.hide() shapeButtonTexts = [ PLocalizer.BodyShortFat, PLocalizer.BodyMediumSkinny, PLocalizer.BodyMediumIdeal, PLocalizer.BodyTallPear, PLocalizer.BodyTallMuscular] self.shapeButtons = [] xOffset = -1.1000000000000001 yOffset = -0.40000000000000002 for i in range(0, len(self.maleShapeButtonIcons)): self.shapeButtons.append(DirectButton(parent = self.shapeFrameTitle, relief = None, geom = (self.maleShapeButtonIcons[i], self.maleShapeButtonIconsOver[i], self.maleShapeButtonIconsOver[i]), geom_scale = 2, pos = (xOffset, 0, yOffset), command = self.handleShape, extraArgs = [ i])) xOffset += 0.55000000000000004 def restore(self, needToRefresh = True): self.heightSlider.node().setValue(self.main.pirate.style.body.height) findShape = BodyDefs.BodyChoiceGenderDict[self.main.pirate.style.gender].index(self.main.pirate.style.body.shape) self.handleShape(findShape, needToRefresh) self.hideColorCollections() self.showColorCollections() self.handleSetColor(self.main.pirate.style.body.color) self.toggleBodyShapes(self.main.pirate.style.gender) def reset(self): for i in xrange(0, len(self.pgs)): self.resetSlider(self.pgs[i]) self.handleShape(2) self.handleSetColor(0) def resetSlider(self, slider): slider.node().setValue(0.0) self.updateHeightSlider(slider) def randomPick(self): for i in xrange(0, len(self.pgs)): slider = self.pgs[i] self.resetSlider(slider) if random.choice([ 0, 1]): value = random.random() * 0.10000000000000001 toss = 0 if slider['range'][0] < 0: toss = random.choice([ 0, 1]) if toss: slider.node().setValue(-value) else: slider.node().setValue(value) self.updateHeightSlider(slider, slider['extraArgs'][1]) continue cList = range(0, 5) bodyShapeIndex = BodyDefs.BodyChoiceGenderDict[self.main.pirate.style.gender].index(self.main.pirate.style.body.shape) cList.remove(bodyShapeIndex) choice = random.choice(cList) self.handleShape(choice) idx = 0 if self.main.pirate.style.gender == 'f': idx = 1 choice = random.choice(range(1, len(HumanDNA.skinColors))) self.handleSetColor(choice) def weightedRandomPick(self): for i in xrange(0, len(self.pgs)): slider = self.pgs[i] self.resetSlider(slider) if random.choice([ 0, 1]): value = random.random() * 0.10000000000000001 toss = 0 if slider['range'][0] < 0: toss = random.choice([ 0, 1, 2]) if toss == 1: slider.node().setValue(-value) elif toss == 0: slider.node().setValue(value) elif toss == 2: slider.node().setValue(0) self.updateHeightSlider(slider, slider['extraArgs'][1]) continue if self.main.pirate.style.gender == 'f': bodyChoiceList = MakeAPirateGlobals.FEMALE_BODYTYPE_SELECTIONS else: bodyChoiceList = MakeAPirateGlobals.MALE_BODYTYPE_SELECTIONS bodyShapeIndex = BodyDefs.BodyChoiceGenderDict[self.main.pirate.style.gender].index(self.main.pirate.style.body.shape) choice = random.choice(bodyChoiceList) if choice == bodyShapeIndex: choice = random.choice(bodyChoiceList) self.handleShape(choice) colorSetChoice = random.choice(MakeAPirateGlobals.COMPLECTIONTYPES.keys()) choice = random.choice(MakeAPirateGlobals.COMPLECTIONTYPES[colorSetChoice][0]) self.handleSetColor(choice) def handleShape(self, index, needToRefresh = True): for i in range(0, len(self.shapeButtons)): self.shapeButtons[i].setColor(0.59999999999999998, 0.80000000000000004, 1.0, 1.0) bodyShapeIndex = BodyDefs.BodyChoiceGenderDict[self.main.pirate.style.gender][index] self.shapeButtons[index].setColor(1.0, 1.0, 0, 1.0) self.main.pirate.style.setBodyShape(bodyShapeIndex) self.updateHeightSlider(self.heightSlider, 0, 0) self.main.pirate.refreshBody() self.main.pirate.generateSkinTexture() if not (self.main.isNPCEditor) and not (self.main.wantNPCViewer): self.main.pirate.loop('idle') if base.config.GetBool('want-idle-centered', 0): self.main.pirate.loop('idle_centered') else: self.main.refreshAnim(needToRefresh) self.main.setupCamera(self.main.pirate) if self.main.inRandomAll: return None if hasattr(self.main, 'JSD_BODY'): optionsLeft = len(self.main.JSD_BODY[index]) if optionsLeft and not random.randint(0, 4): choice = random.choice(range(0, optionsLeft)) if self.main.lastDialog: if self.main.lastDialog.status() == AudioSound.PLAYING: return None dialog = self.main.JSD_BODY[index][choice] base.playSfx(dialog, node = self.avatar.pirate) self.main.lastDialog = dialog if self.main.pirate.style.gender == 'm' and dialog == self.main.jsd_body_ms_1: dialog.stop() elif self.main.pirate.style.gender == 'f' and dialog == self.main.jsd_body_tm_1: dialog.stop() else: self.main.JSD_BODY[index].remove(dialog) def handleSetColor(self, colorIdx): colorButtons = self.maleColorButtons if self.main.pirate.style.gender == 'f': colorButtons = self.femaleColorButtons for i in range(0, len(colorButtons)): colorButtons[i]['relief'] = DGG.RAISED colorButtons[colorIdx]['relief'] = DGG.SUNKEN self.avatar.skinColorIdx = colorIdx self.avatar.pirate.setBodyColor(self.avatar.skinColorIdx) self.avatar.pirate.generateSkinColor() def updateHeightSlider(self, pgs, extraArgs1 = None, extraArgs2 = None): value = pgs.node().getValue() self.avatar.pirate.setBodyHeight(value) self.avatar.pirate.setGlobalScale(self.avatar.pirate.calcBodyScale()) def handleNextTexture(self): self.avatar.bodyTextureIdx = (self.avatar.bodyTextureIdx + 1) % self.avatar.numBodys self.avatar.pirate.setBodySkin(self.avatar.bodyTextureIdx) self.avatar.pirate.generateSkinTexture() def handleLastTexture(self): self.avatar.bodyTextureIdx = (self.avatar.bodyTextureIdx - 1) % self.avatar.numBodys self.avatar.pirate.setBodySkin(self.avatar.bodyTextureIdx) self.avatar.pirate.generateSkinTexture() def toggleBodyShapes(self, gender): if gender == 'f': self.notify.debug('gender is female') for i in range(0, len(self.femaleShapeButtonIcons)): self.shapeButtons[i]['geom'] = (self.femaleShapeButtonIcons[i], self.femaleShapeButtonIconsOver[i], self.femaleShapeButtonIconsOver[i]) else: self.notify.debug('gender is male') for i in range(0, len(self.maleShapeButtonIcons)): self.shapeButtons[i]['geom'] = (self.maleShapeButtonIcons[i], self.maleShapeButtonIconsOver[i], self.maleShapeButtonIconsOver[i])