def loadGUI(self):
     self.hairPicker = CharGuiPicker(self.main, parent = self.parent, text = PLocalizer.MakeAPirateHairHair, nextCommand = self.handleNextHair, backCommand = self.handleLastHair)
     self.hairPicker.setPos(0, 0, 0.10000000000000001)
     self.beardPicker = CharGuiPicker(self.main, parent = self.parent, text = PLocalizer.MakeAPirateHairBeard, nextCommand = self.handleNextBeard, backCommand = self.handleLastBeard)
     self.beardPicker.setPos(0, 0, -0.10000000000000001)
     self.mustachePicker = CharGuiPicker(self.main, parent = self.parent, text = PLocalizer.MakeAPirateHairMustache, nextCommand = self.handleNextMustache, backCommand = self.handleLastMustache)
     self.mustachePicker.setPos(0, 0, -0.29999999999999999)
     self.eyeBrowPicker = CharGuiPicker(self.main, parent = self.parent, text = PLocalizer.MakeAPirateHairEyeBrow, nextCommand = self.handleNextEyeBrow, backCommand = self.handleLastEyeBrow)
     self.eyeBrowPicker.setPos(0, 0, -0.5)
     self.hairPicker.hide()
     self.beardPicker.hide()
     self.mustachePicker.hide()
     self.eyeBrowPicker.hide()
Esempio n. 2
0
 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 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()
Esempio n. 4
0
 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()
Esempio n. 5
0
 def setupButtons(self):
     self.jawFrame = DirectFrame(parent=self.parent,
                                 relief=None,
                                 text=PLocalizer.MouthJawFrameTitle,
                                 text_fg=(1, 1, 1, 1),
                                 text_scale=0.18,
                                 text_pos=(0, -0.05),
                                 pos=(0, 0, 0.4),
                                 scale=0.7)
     self.jawFrame.hide()
     self.lipFrame = DirectFrame(parent=self.parent,
                                 relief=None,
                                 text=PLocalizer.MouthFrameTitle,
                                 text_fg=(1, 1, 1, 1),
                                 text_scale=0.18,
                                 text_pos=(0, -0.05),
                                 pos=(0, 0, -0.55),
                                 scale=0.7)
     self.lipFrame.hide()
     self.cheekFrame = DirectFrame(parent=self.parent,
                                   relief=None,
                                   text=PLocalizer.MouthCheekFrameTitle,
                                   text_fg=(1, 1, 1, 1),
                                   text_scale=0.18,
                                   text_pos=(0, -0.05),
                                   pos=(0, 0, -1.4),
                                   scale=0.7)
     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.3)
     self.teethPicker.hide()
     return
 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 setupButtons(self):
     self.zone1Frame = DirectFrame(parent = self.parent, relief = DGG.FLAT, pos = (0.0, 0, 0.69999999999999996))
     self.zone1Frame.hide()
     self.zoneFrames.append(self.zone1Frame)
     self.jewelry1Picker = CharGuiPicker(self.main, parent = self.zone1Frame, text = PLocalizer.ShapeJewelryLEarFrameTitle, nextCommand = Functor(self.handleNextJewelry, jewelry_keys[Zone1_Tab]), backCommand = Functor(self.handleLastJewelry, jewelry_keys[Zone1_Tab]))
     self.jewelry1Picker.setPos(0, 0, -0.5)
     self.zone2Frame = DirectFrame(parent = self.parent, relief = DGG.FLAT, pos = (0.0, 0, 0.69999999999999996))
     self.zone2Frame.hide()
     self.zoneFrames.append(self.zone2Frame)
     self.jewelry2Picker = CharGuiPicker(self.main, parent = self.zone2Frame, text = PLocalizer.ShapeJewelryREarFrameTitle, nextCommand = Functor(self.handleNextJewelry, jewelry_keys[Zone2_Tab]), backCommand = Functor(self.handleLastJewelry, jewelry_keys[Zone2_Tab]))
     self.jewelry2Picker.setPos(0, 0, -0.5)
     self.zone3Frame = DirectFrame(parent = self.parent, relief = DGG.FLAT, pos = (0.0, 0, 0.69999999999999996))
     self.zone3Frame.hide()
     self.zoneFrames.append(self.zone3Frame)
     self.jewelry3Picker = CharGuiPicker(self.main, parent = self.zone3Frame, text = PLocalizer.ShapeJewelryLBrowFrameTitle, nextCommand = Functor(self.handleNextJewelry, jewelry_keys[Zone3_Tab]), backCommand = Functor(self.handleLastJewelry, jewelry_keys[Zone3_Tab]))
     self.jewelry3Picker.setPos(0, 0, -0.5)
     self.zone4Frame = DirectFrame(parent = self.parent, relief = DGG.FLAT, pos = (0.0, 0, 0.69999999999999996))
     self.zone4Frame.hide()
     self.zoneFrames.append(self.zone4Frame)
     self.jewelry4Picker = CharGuiPicker(self.main, parent = self.zone4Frame, text = PLocalizer.ShapeJewelryRBrowFrameTitle, nextCommand = Functor(self.handleNextJewelry, jewelry_keys[Zone4_Tab]), backCommand = Functor(self.handleLastJewelry, jewelry_keys[Zone4_Tab]))
     self.jewelry4Picker.setPos(0, 0, -0.5)
     self.zone5Frame = DirectFrame(parent = self.parent, relief = DGG.FLAT, pos = (0.0, 0, 0.69999999999999996))
     self.zone5Frame.hide()
     self.zoneFrames.append(self.zone5Frame)
     self.jewelry5Picker = CharGuiPicker(self.main, parent = self.zone5Frame, text = PLocalizer.ShapeJewelryNoseFrameTitle, nextCommand = Functor(self.handleNextJewelry, jewelry_keys[Zone5_Tab]), backCommand = Functor(self.handleLastJewelry, jewelry_keys[Zone5_Tab]))
     self.jewelry5Picker.setPos(0, 0, -0.5)
     self.zone6Frame = DirectFrame(parent = self.parent, relief = DGG.FLAT, pos = (0.0, 0, 0.69999999999999996))
     self.zone6Frame.hide()
     self.zoneFrames.append(self.zone6Frame)
     self.jewelry6Picker = CharGuiPicker(self.main, parent = self.zone6Frame, text = PLocalizer.ShapeJewelryMouthFrameTitle, nextCommand = Functor(self.handleNextJewelry, jewelry_keys[Zone6_Tab]), backCommand = Functor(self.handleLastJewelry, jewelry_keys[Zone6_Tab]))
     self.jewelry6Picker.setPos(0, 0, -0.5)
     self.zone7Frame = DirectFrame(parent = self.parent, relief = DGG.FLAT, pos = (0.0, 0, 0.69999999999999996))
     self.zone7Frame.hide()
     self.zoneFrames.append(self.zone7Frame)
     self.jewelry7Picker = CharGuiPicker(self.main, parent = self.zone7Frame, text = PLocalizer.ShapeJewelryLHandFrameTitle, nextCommand = Functor(self.handleNextJewelry, jewelry_keys[Zone7_Tab]), backCommand = Functor(self.handleLastJewelry, jewelry_keys[Zone7_Tab]))
     self.jewelry7Picker.setPos(0, 0, -0.5)
     self.zone8Frame = DirectFrame(parent = self.parent, relief = DGG.FLAT, pos = (0.0, 0, 0.69999999999999996))
     self.zone8Frame.hide()
     self.zoneFrames.append(self.zone8Frame)
     self.jewelry8Picker = CharGuiPicker(self.main, parent = self.zone8Frame, text = PLocalizer.ShapeJewelryRHandFrameTitle, nextCommand = Functor(self.handleNextJewelry, jewelry_keys[Zone8_Tab]), backCommand = Functor(self.handleLastJewelry, jewelry_keys[Zone8_Tab]))
     self.jewelry8Picker.setPos(0, 0, -0.5)
     self.loadColorGUI()
class JewelryGUI(DirectFrame, StateData.StateData):
    notify = DirectNotifyGlobal.directNotify.newCategory('JewelryGUI')
    
    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.zoneTabs = []
        self.zoneFrames = []
        self.load()

    
    def enter(self):
        self.notify.debug('enter')
        self.show()
        if self.mode == None:
            self.load()
            self.mode = -1
        

    
    def exit(self):
        self.hide()

    
    def save(self):
        if self.mode == -1:
            pass
        1
        self.saveDNA()

    
    def load(self):
        self.loadTabs()
        self.setupButtons()

    
    def assignAvatar(self, avatar):
        self.avatar = avatar

    
    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 = 'L Ear', 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.zoneTabs.append(self.zone1Tab)
        self.zone2Tab = DirectButton(parent = self.parent, relief = DGG.RAISED, frameSize = (-0.13, 0.13, -0.040000000000000001, 0.040000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = 'R Ear', 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.zoneTabs.append(self.zone2Tab)
        self.zone3Tab = DirectButton(parent = self.parent, relief = DGG.RAISED, frameSize = (-0.13, 0.13, -0.040000000000000001, 0.040000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = 'L Brow', 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.zoneTabs.append(self.zone3Tab)
        self.zone4Tab = DirectButton(parent = self.parent, relief = DGG.RAISED, frameSize = (-0.13, 0.13, -0.040000000000000001, 0.040000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = 'R Brow', 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.zoneTabs.append(self.zone4Tab)
        self.zone5Tab = DirectButton(parent = self.parent, relief = DGG.RAISED, frameSize = (-0.13, 0.13, -0.040000000000000001, 0.040000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = 'Nose', 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.zoneTabs.append(self.zone5Tab)
        self.zone6Tab = DirectButton(parent = self.parent, relief = DGG.RAISED, frameSize = (-0.13, 0.13, -0.040000000000000001, 0.040000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = 'Mouth', 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.zoneTabs.append(self.zone6Tab)
        self.zone7Tab = DirectButton(parent = self.parent, relief = DGG.RAISED, frameSize = (-0.13, 0.13, -0.040000000000000001, 0.040000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = 'L Hand', 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.zoneTabs.append(self.zone7Tab)
        self.zone8Tab = DirectButton(parent = self.parent, relief = DGG.RAISED, frameSize = (-0.13, 0.13, -0.040000000000000001, 0.040000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), text = 'R Hand', 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()
        self.zoneTabs.append(self.zone8Tab)

    
    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
        for i in range(0, len(self.zoneTabs)):
            self.zoneTabs[i]['state'] = DGG.NORMAL
            self.zoneTabs[i]['relief'] = DGG.RAISED
            self.zoneFrames[i].hide()
        
        self.zoneTabs[mode]['state'] = DGG.DISABLED
        self.zoneTabs[mode]['relief'] = DGG.SUNKEN
        self.zoneFrames[mode].show()
        if mode < Zone7_Tab:
            self.main.pgsZoom['value'] = 1.0
        else:
            self.main.pgsZoom['value'] = 0.5
        if mode in [
            Zone1_Tab,
            Zone7_Tab]:
            self.main.pgsRotate['value'] = -0.29999999999999999
        elif mode in [
            Zone2_Tab,
            Zone8_Tab]:
            self.main.pgsRotate['value'] = 0.29999999999999999
        else:
            self.main.pgsRotate['value'] = 0.0
        self.reparentCommonGui(mode)

    
    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
        for i in range(0, len(self.zoneTabs)):
            self.zoneTabs[i]['state'] = DGG.NORMAL
            self.zoneTabs[i].hide()
            self.zoneFrames[i].hide()
        
        self.saveDNA()

    
    def setupButtons(self):
        self.zone1Frame = DirectFrame(parent = self.parent, relief = DGG.FLAT, pos = (0.0, 0, 0.69999999999999996))
        self.zone1Frame.hide()
        self.zoneFrames.append(self.zone1Frame)
        self.jewelry1Picker = CharGuiPicker(self.main, parent = self.zone1Frame, text = PLocalizer.ShapeJewelryLEarFrameTitle, nextCommand = Functor(self.handleNextJewelry, jewelry_keys[Zone1_Tab]), backCommand = Functor(self.handleLastJewelry, jewelry_keys[Zone1_Tab]))
        self.jewelry1Picker.setPos(0, 0, -0.5)
        self.zone2Frame = DirectFrame(parent = self.parent, relief = DGG.FLAT, pos = (0.0, 0, 0.69999999999999996))
        self.zone2Frame.hide()
        self.zoneFrames.append(self.zone2Frame)
        self.jewelry2Picker = CharGuiPicker(self.main, parent = self.zone2Frame, text = PLocalizer.ShapeJewelryREarFrameTitle, nextCommand = Functor(self.handleNextJewelry, jewelry_keys[Zone2_Tab]), backCommand = Functor(self.handleLastJewelry, jewelry_keys[Zone2_Tab]))
        self.jewelry2Picker.setPos(0, 0, -0.5)
        self.zone3Frame = DirectFrame(parent = self.parent, relief = DGG.FLAT, pos = (0.0, 0, 0.69999999999999996))
        self.zone3Frame.hide()
        self.zoneFrames.append(self.zone3Frame)
        self.jewelry3Picker = CharGuiPicker(self.main, parent = self.zone3Frame, text = PLocalizer.ShapeJewelryLBrowFrameTitle, nextCommand = Functor(self.handleNextJewelry, jewelry_keys[Zone3_Tab]), backCommand = Functor(self.handleLastJewelry, jewelry_keys[Zone3_Tab]))
        self.jewelry3Picker.setPos(0, 0, -0.5)
        self.zone4Frame = DirectFrame(parent = self.parent, relief = DGG.FLAT, pos = (0.0, 0, 0.69999999999999996))
        self.zone4Frame.hide()
        self.zoneFrames.append(self.zone4Frame)
        self.jewelry4Picker = CharGuiPicker(self.main, parent = self.zone4Frame, text = PLocalizer.ShapeJewelryRBrowFrameTitle, nextCommand = Functor(self.handleNextJewelry, jewelry_keys[Zone4_Tab]), backCommand = Functor(self.handleLastJewelry, jewelry_keys[Zone4_Tab]))
        self.jewelry4Picker.setPos(0, 0, -0.5)
        self.zone5Frame = DirectFrame(parent = self.parent, relief = DGG.FLAT, pos = (0.0, 0, 0.69999999999999996))
        self.zone5Frame.hide()
        self.zoneFrames.append(self.zone5Frame)
        self.jewelry5Picker = CharGuiPicker(self.main, parent = self.zone5Frame, text = PLocalizer.ShapeJewelryNoseFrameTitle, nextCommand = Functor(self.handleNextJewelry, jewelry_keys[Zone5_Tab]), backCommand = Functor(self.handleLastJewelry, jewelry_keys[Zone5_Tab]))
        self.jewelry5Picker.setPos(0, 0, -0.5)
        self.zone6Frame = DirectFrame(parent = self.parent, relief = DGG.FLAT, pos = (0.0, 0, 0.69999999999999996))
        self.zone6Frame.hide()
        self.zoneFrames.append(self.zone6Frame)
        self.jewelry6Picker = CharGuiPicker(self.main, parent = self.zone6Frame, text = PLocalizer.ShapeJewelryMouthFrameTitle, nextCommand = Functor(self.handleNextJewelry, jewelry_keys[Zone6_Tab]), backCommand = Functor(self.handleLastJewelry, jewelry_keys[Zone6_Tab]))
        self.jewelry6Picker.setPos(0, 0, -0.5)
        self.zone7Frame = DirectFrame(parent = self.parent, relief = DGG.FLAT, pos = (0.0, 0, 0.69999999999999996))
        self.zone7Frame.hide()
        self.zoneFrames.append(self.zone7Frame)
        self.jewelry7Picker = CharGuiPicker(self.main, parent = self.zone7Frame, text = PLocalizer.ShapeJewelryLHandFrameTitle, nextCommand = Functor(self.handleNextJewelry, jewelry_keys[Zone7_Tab]), backCommand = Functor(self.handleLastJewelry, jewelry_keys[Zone7_Tab]))
        self.jewelry7Picker.setPos(0, 0, -0.5)
        self.zone8Frame = DirectFrame(parent = self.parent, relief = DGG.FLAT, pos = (0.0, 0, 0.69999999999999996))
        self.zone8Frame.hide()
        self.zoneFrames.append(self.zone8Frame)
        self.jewelry8Picker = CharGuiPicker(self.main, parent = self.zone8Frame, text = PLocalizer.ShapeJewelryRHandFrameTitle, nextCommand = Functor(self.handleNextJewelry, jewelry_keys[Zone8_Tab]), backCommand = Functor(self.handleLastJewelry, jewelry_keys[Zone8_Tab]))
        self.jewelry8Picker.setPos(0, 0, -0.5)
        self.loadColorGUI()

    
    def loadColorGUI(self):
        self.primaryColorFrame = DirectFrame(parent = self.zone1Frame, relief = None, image = self.main.charGui.find('**/chargui_frame01'), image_pos = (0, 0, -0.29999999999999999), image_scale = (2.4300000000000002, 1.6000000000000001, 1.6000000000000001), text = 'Pirmary Color', text_fg = (1, 1, 1, 1), text_scale = 0.17999999999999999, text_pos = (0, -0.050000000000000003), pos = (0, 0, -0.80000000000000004), scale = 0.69999999999999996)
        self.primaryColorButtons = []
        xOffset = -0.80000000000000004
        yOffset = -0.29999999999999999
        for i in range(0, len(HumanDNA.jewelryColors)):
            if i and i % 9 == 0:
                xOffset = -0.5
                yOffset -= 0.29999999999999999
            
            jewelryColor = HumanDNA.jewelryColors[i]
            if jewelryColor is None:
                jewelryColor = VBase4(0, 0, 0, 1)
            
            self.primaryColorButtons.append(DirectButton(parent = self.primaryColorFrame, relief = DGG.RAISED, pos = (xOffset, 0, yOffset), frameSize = (-0.10000000000000001, 0.10000000000000001, -0.10000000000000001, 0.10000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), frameColor = jewelryColor, command = self.handleSetPrimaryColor, extraArgs = [
                i]))
            xOffset += 0.20000000000000001
        
        self.secondaryColorFrame = DirectFrame(parent = self.zone1Frame, relief = None, image = self.main.charGui.find('**/chargui_frame01'), image_pos = (0, 0, -0.29999999999999999), image_scale = (2.4300000000000002, 1.6000000000000001, 1.6000000000000001), text = 'Secondary Color', text_fg = (1, 1, 1, 1), text_scale = 0.17999999999999999, text_pos = (0, -0.050000000000000003), pos = (0, 0, -1.3999999999999999), scale = 0.69999999999999996)
        self.secondaryColorButtons = []
        xOffset = -0.80000000000000004
        yOffset = -0.29999999999999999
        for i in range(0, len(HumanDNA.jewelryColors)):
            if i and i % 9 == 0:
                xOffset = -0.5
                yOffset -= 0.29999999999999999
            
            jewelryColor = HumanDNA.jewelryColors[i]
            if jewelryColor is None:
                jewelryColor = VBase4(0, 0, 0, 1)
            
            self.secondaryColorButtons.append(DirectButton(parent = self.secondaryColorFrame, relief = DGG.RAISED, pos = (xOffset, 0, yOffset), frameSize = (-0.10000000000000001, 0.10000000000000001, -0.10000000000000001, 0.10000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), frameColor = jewelryColor, command = self.handleSetSecondaryColor, extraArgs = [
                i]))
            xOffset += 0.20000000000000001
        

    
    def reset(self):
        self.avatar.hideAllJewelry()
        self.saveDNA()

    
    def saveDNA(self):
        self.avatar.pirate.setJewelryZone1(self.avatar.currentJewelry['LEar'][0], self.avatar.currentJewelry['LEar'][1], self.avatar.currentJewelry['LEar'][2])
        self.avatar.pirate.setJewelryZone2(self.avatar.currentJewelry['REar'][0], self.avatar.currentJewelry['REar'][1], self.avatar.currentJewelry['REar'][2])
        self.avatar.pirate.setJewelryZone3(self.avatar.currentJewelry['LBrow'][0], self.avatar.currentJewelry['LBrow'][1], self.avatar.currentJewelry['LBrow'][2])
        self.avatar.pirate.setJewelryZone4(self.avatar.currentJewelry['RBrow'][0], self.avatar.currentJewelry['RBrow'][1], self.avatar.currentJewelry['RBrow'][2])
        self.avatar.pirate.setJewelryZone5(self.avatar.currentJewelry['Nose'][0], self.avatar.currentJewelry['Nose'][1], self.avatar.currentJewelry['Nose'][2])
        self.avatar.pirate.setJewelryZone6(self.avatar.currentJewelry['Mouth'][0], self.avatar.currentJewelry['Mouth'][1], self.avatar.currentJewelry['Mouth'][2])
        self.avatar.pirate.setJewelryZone7(self.avatar.currentJewelry['LHand'][0], self.avatar.currentJewelry['LHand'][1], self.avatar.currentJewelry['LHand'][2])
        self.avatar.pirate.setJewelryZone8(self.avatar.currentJewelry['RHand'][0], self.avatar.currentJewelry['RHand'][1], self.avatar.currentJewelry['RHand'][2])

    
    def randomPick(self):
        pass

    
    def reparentCommonGui(self, mode):
        self.primaryColorFrame.reparentTo(self.zoneFrames[mode])
        self.secondaryColorFrame.reparentTo(self.zoneFrames[mode])
        for i in range(0, len(self.primaryColorButtons)):
            self.primaryColorButtons[i]['relief'] = DGG.RAISED
        
        for i in range(0, len(self.secondaryColorButtons)):
            self.secondaryColorButtons[i]['relief'] = DGG.RAISED
        

    
    def handleNextJewelry(self, key):
        self.avatar.handleJewelryOptions(key, True)
        print self.avatar.currentJewelry

    
    def handleLastJewelry(self, key):
        self.avatar.handleJewelryOptions(key, False)

    
    def handleSetPrimaryColor(self, colorIdx):
        for i in range(0, len(self.primaryColorButtons)):
            self.primaryColorButtons[i]['relief'] = DGG.RAISED
        
        self.primaryColorButtons[colorIdx]['relief'] = DGG.SUNKEN
        primaryColor = HumanDNA.jewelryColors[colorIdx]
        if primaryColor:
            key = jewelry_keys[self.mode]
            idx = self.avatar.currentJewelry[key][0]
            self.avatar.jewelrySets[key][idx][0].setColor(primaryColor)
            self.avatar.currentJewelry[key][1] = colorIdx
        

    
    def handleSetSecondaryColor(self, colorIdx):
        for i in range(0, len(self.secondaryColorButtons)):
            self.secondaryColorButtons[i]['relief'] = DGG.RAISED
        
        self.secondaryColorButtons[colorIdx]['relief'] = DGG.SUNKEN
        secondaryColor = HumanDNA.jewelryColors[colorIdx]
        if secondaryColor:
            key = jewelry_keys[self.mode]
            idx = self.avatar.currentJewelry[key][0]
            self.avatar.jewelrySets[key][idx][1].setColor(secondaryColor)
            self.avatar.currentJewelry[key][2] = colorIdx
class HairGUI(DirectFrame, StateData.StateData):
    notify = DirectNotifyGlobal.directNotify.newCategory('HairGUI')
    
    def __init__(self, main = None):
        self.main = main
        self.parent = main.bookModel
        self.avatar = main.avatar
        self.mode = None
        self.load()

    
    def enter(self):
        self.notify.debug('enter')
        self.showHairCollections()
        self.showColorCollections()
        if self.mode == None:
            self.mode = -1
        

    
    def exit(self):
        self.notify.debug('called HairGUI exit')
        self.hide()
        self.mode = None

    
    def save(self):
        if self.mode == -1:
            pass
        1

    
    def assignAvatar(self, avatar):
        self.avatar = avatar

    
    def load(self):
        self.notify.debug('loading HairGui')
        self.loadGUI()
        self.loadColorGUI()

    
    def loadGUI(self):
        self.hairPicker = CharGuiPicker(self.main, parent = self.parent, text = PLocalizer.MakeAPirateHairHair, nextCommand = self.handleNextHair, backCommand = self.handleLastHair)
        self.hairPicker.setPos(0, 0, 0.10000000000000001)
        self.beardPicker = CharGuiPicker(self.main, parent = self.parent, text = PLocalizer.MakeAPirateHairBeard, nextCommand = self.handleNextBeard, backCommand = self.handleLastBeard)
        self.beardPicker.setPos(0, 0, -0.10000000000000001)
        self.mustachePicker = CharGuiPicker(self.main, parent = self.parent, text = PLocalizer.MakeAPirateHairMustache, nextCommand = self.handleNextMustache, backCommand = self.handleLastMustache)
        self.mustachePicker.setPos(0, 0, -0.29999999999999999)
        self.eyeBrowPicker = CharGuiPicker(self.main, parent = self.parent, text = PLocalizer.MakeAPirateHairEyeBrow, nextCommand = self.handleNextEyeBrow, backCommand = self.handleLastEyeBrow)
        self.eyeBrowPicker.setPos(0, 0, -0.5)
        self.hairPicker.hide()
        self.beardPicker.hide()
        self.mustachePicker.hide()
        self.eyeBrowPicker.hide()

    
    def loadColorGUI(self):
        self.baseColorFrameTitle = DirectFrame(parent = self.parent, relief = None, image = self.main.charGui.find('**/chargui_frame01'), image_pos = (0, 0, -0.29999999999999999), image_scale = (2.1299999999999999, 1.6000000000000001, 1.6000000000000001), text = PLocalizer.HairColorFrameTitle, text_fg = (1, 1, 1, 1), text_scale = 0.17999999999999999, text_pos = (0, -0.050000000000000003), pos = (0, 0, -0.59999999999999998), scale = 0.69999999999999996)
        self.baseColorFrameTitle.hide()
        self.baseColorButtons = []
        xOffset = -0.69999999999999996
        yOffset = -0.29999999999999999
        for i in HumanDNA.availableHairColors:
            if i and i % 8 == 0:
                xOffset = -0.5
                yOffset -= 0.29999999999999999
            
            hairColor = HumanDNA.hairColors[i]
            hairTone = (hairColor[0], hairColor[1], hairColor[2], 1.0)
            self.baseColorButtons.append(DirectButton(parent = self.baseColorFrameTitle, relief = DGG.RAISED, pos = (xOffset, 0, yOffset), frameSize = (-0.10000000000000001, 0.10000000000000001, -0.10000000000000001, 0.10000000000000001), borderWidth = (0.0080000000000000002, 0.0080000000000000002), frameColor = hairTone, command = self.handleSetBaseColor, extraArgs = [
                i]))
            xOffset += 0.20000000000000001
        

    
    def unload(self):
        self.notify.debug('called HairGui unload')
        del self.main
        del self.parent
        del self.avatar

    
    def showHairCollections(self):
        self.hairPicker.show()
        if self.main.pirate.style.gender == 'f':
            self.beardPicker.hide()
            self.mustachePicker.hide()
        else:
            self.beardPicker.show()
            self.mustachePicker.show()

    
    def hideHairCollections(self):
        self.hairPicker.hide()
        self.beardPicker.hide()
        self.mustachePicker.hide()

    
    def showColorCollections(self):
        self.baseColorFrameTitle.show()
        self.baseColorButtons[self.main.pirate.style.head.hair.color]['relief'] = DGG.SUNKEN

    
    def hideColorCollections(self):
        self.baseColorFrameTitle.hide()

    
    def hide(self):
        self.hideHairCollections()
        self.hideColorCollections()

    
    def reset(self):
        self.avatar.hideHair()
        self.avatar.hairIdx = 0
        self.avatar.pirate.setHairHair(0)
        self.avatar.pirate.setHairColor(0)
        self.avatar.handleHeadHiding()
        if self.main.pirate.style.gender == 'm':
            self.avatar.beardIdx = 0
            self.avatar.pirate.setHairBeard(0)
            self.avatar.mustacheIdx = 0
            self.avatar.pirate.setHairMustache(0)
            self.avatar.showFacialHair()
        

    
    def randomPick(self):
        self.avatar.hairIdx = random.choice(self.avatar.choices['HAIR'])
        self.avatar.pirate.setHairHair(self.avatar.hairIdx)
        choice = random.choice(HumanDNA.availableHairColors)
        for i in range(0, len(self.baseColorButtons)):
            self.baseColorButtons[i]['relief'] = DGG.RAISED
        
        self.baseColorButtons[choice]['relief'] = DGG.SUNKEN
        self.avatar.hairColorIdx = choice
        self.avatar.pirate.setHairColor(choice)
        self.avatar.handleHeadHiding()
        if self.main.pirate.style.gender == 'm':
            roll = int(random.random() * 10.0)
            for i in range(roll):
                self.handleNextBeard()
            
            if choice == 0 or choice > 3:
                roll = int(random.random() * 10.0)
                for i in range(roll):
                    self.handleNextMustache()
                
            
            self.avatar.showFacialHair()
        

    
    def weightedRandomPick(self):
        if self.main.pirate.style.gender == 'm':
            self.avatar.hairIdx = random.choice(self.avatar.choices['HAIR'] + MakeAPirateGlobals.PREFERRED_MALE_HAIR_SELECTIONS)
        else:
            self.avatar.hairIdx = random.choice(self.avatar.choices['HAIR'] + MakeAPirateGlobals.PREFERRED_FEMALE_HAIR_SELECTIONS)
        self.avatar.pirate.setHairHair(self.avatar.hairIdx)
        colorSkew = []
        for key in MakeAPirateGlobals.COMPLECTIONTYPES:
            entrySkin = MakeAPirateGlobals.COMPLECTIONTYPES[key][0]
            if self.avatar.dna.getBodyColor() in entrySkin:
                colorSkew = MakeAPirateGlobals.COMPLECTIONTYPES[key][1]
                continue
        
        coinFlip = random.choice([
            0,
            1])
        if coinFlip:
            choice = random.choice(colorSkew)
        else:
            choice = random.choice(HumanDNA.availableHairColors + colorSkew)
        for i in range(0, len(self.baseColorButtons)):
            self.baseColorButtons[i]['relief'] = DGG.RAISED
        
        self.baseColorButtons[choice]['relief'] = DGG.SUNKEN
        self.avatar.hairColorIdx = choice
        self.avatar.pirate.setHairColor(choice)
        self.avatar.handleHeadHiding()
        if self.main.pirate.style.gender == 'm':
            choice = random.choice(self.avatar.choices['BEARD'] + MakeAPirateGlobals.PREFERRED_MALE_BEARD_SELECTIONS)
            self.avatar.beardIdx = choice
            self.avatar.pirate.setHairBeard(choice)
            if choice == 0 or choice > 3:
                roll = int(random.random() * 10.0)
                for i in range(roll):
                    self.handleNextMustache()
                
            
            self.avatar.showFacialHair()
        

    
    def handleNextHair(self):
        self.notify.debug('--------------------------current hair---------------------')
        self.avatar.hideHair()
        currIdx = self.avatar.choices['HAIR'].index(self.avatar.hairIdx)
        currIdx += 1
        if currIdx >= len(self.avatar.choices['HAIR']):
            currIdx = 0
        
        self.avatar.hairIdx = self.avatar.choices['HAIR'][currIdx]
        self.avatar.pirate.setHairHair(self.avatar.hairIdx)
        self.avatar.handleHeadHiding()
        self.playJackDialog()

    
    def handleLastHair(self):
        self.notify.debug('--------------------------current hair---------------------')
        self.avatar.hideHair()
        currIdx = self.avatar.choices['HAIR'].index(self.avatar.hairIdx)
        currIdx -= 1
        if currIdx < 0:
            currIdx = len(self.avatar.choices['HAIR']) - 1
        
        self.avatar.hairIdx = self.avatar.choices['HAIR'][currIdx]
        self.avatar.pirate.setHairHair(self.avatar.hairIdx)
        self.avatar.handleHeadHiding()
        self.playJackDialog()

    
    def handleNextBeard(self):
        if self.main.wantNPCViewer:
            self.avatar.beardIdx += 1
            if self.avatar.beardIdx >= len(self.avatar.beards):
                self.avatar.beardIdx = 0
            
        else:
            currIdx = self.avatar.choices['BEARD'].index(self.avatar.beardIdx)
            currIdx += 1
            if currIdx >= len(self.avatar.choices['BEARD']):
                currIdx = 0
            
            self.avatar.beardIdx = self.avatar.choices['BEARD'][currIdx]
        self.avatar.showFacialHair()
        self.avatar.pirate.setHairBeard(self.avatar.beardIdx)

    
    def handleLastBeard(self):
        if self.main.wantNPCViewer:
            self.avatar.beardIdx -= 1
            if self.avatar.beardIdx < 0:
                self.avatar.beardIdx = len(self.avatar.beards) - 1
            
        else:
            currIdx = self.avatar.choices['BEARD'].index(self.avatar.beardIdx)
            currIdx -= 1
            if currIdx < 0:
                currIdx = len(self.avatar.choices['BEARD']) - 1
            
            self.avatar.beardIdx = self.avatar.choices['BEARD'][currIdx]
        self.avatar.showFacialHair()
        self.avatar.pirate.setHairBeard(self.avatar.beardIdx)

    
    def handleNextMustache(self):
        if self.main.wantNPCViewer:
            self.avatar.mustacheIdx += 1
            if self.avatar.mustacheIdx >= len(self.avatar.mustaches):
                self.avatar.mustacheIdx = 0
            
        else:
            currIdx = self.avatar.choices['MUSTACHE'].index(self.avatar.mustacheIdx)
            currIdx += 1
            if currIdx >= len(self.avatar.choices['MUSTACHE']):
                currIdx = 0
            
            self.avatar.mustacheIdx = self.avatar.choices['MUSTACHE'][currIdx]
        self.avatar.showFacialHair()
        self.avatar.pirate.setHairMustache(self.avatar.mustacheIdx)

    
    def handleLastMustache(self):
        if self.main.wantNPCViewer:
            self.avatar.mustacheIdx -= 1
            if self.avatar.mustacheIdx < 0:
                self.avatar.mustacheIdx = len(self.avatar.mustaches) - 1
            
        else:
            currIdx = self.avatar.choices['MUSTACHE'].index(self.avatar.mustacheIdx)
            currIdx -= 1
            if currIdx < 0:
                currIdx = len(self.avatar.choices['MUSTACHE']) - 1
            
            self.avatar.mustacheIdx = self.avatar.choices['MUSTACHE'][currIdx]
        self.avatar.showFacialHair()
        self.avatar.pirate.setHairMustache(self.avatar.mustacheIdx)

    
    def handleNextEyeBrow(self):
        if not self.avatar.eyeBrows[self.avatar.eyeBrowIdx].isEmpty():
            self.avatar.eyeBrows[self.avatar.eyeBrowIdx].hide()
        
        self.avatar.eyeBrowIdx += 1
        if self.avatar.eyeBrowIdx >= len(self.avatar.eyeBrows):
            self.avatar.eyeBrowIdx = 0
        
        if not self.avatar.eyeBrows[self.avatar.eyeBrowIdx].isEmpty():
            self.avatar.eyeBrows[self.avatar.eyeBrowIdx].show()
        

    
    def handleLastEyeBrow(self):
        if not self.avatar.eyeBrows[self.avatar.eyeBrowIdx].isEmpty():
            self.avatar.eyeBrows[self.avatar.eyeBrowIdx].hide()
        
        self.avatar.eyeBrowIdx -= 1
        if self.avatar.eyeBrowIdx < 0:
            self.avatar.eyeBrowIdx = len(self.avatar.eyeBrows) - 1
        
        if not self.avatar.eyeBrows[self.avatar.eyeBrowIdx].isEmpty():
            self.avatar.eyeBrows[self.avatar.eyeBrowIdx].show()
        

    
    def handleSetBaseColor(self, colorIdx):
        for i in range(0, len(self.baseColorButtons)):
            self.baseColorButtons[i]['relief'] = DGG.RAISED
        
        self.baseColorButtons[colorIdx]['relief'] = DGG.SUNKEN
        self.avatar.hairColorIdx = colorIdx
        self.avatar.pirate.setHairColor(self.avatar.hairColorIdx)
        self.avatar.setHairBaseColor()

    
    def playJackDialog(self):
        if self.main.inRandomAll:
            return None
        
        choice = random.choice([
            0,
            1,
            2])
        if choice != 0:
            return None
        
        idx = 0
        if self.main.pirate.gender == 'f':
            idx = 1
        
        optionsLeft = len(self.main.JSD_HAIR[idx])
        if optionsLeft:
            if self.main.lastDialog:
                self.main.lastDialog.stop()
            
            choice = random.choice(range(0, optionsLeft))
            dialog = self.main.JSD_HAIR[idx][choice]
            base.playSfx(dialog, node = self.avatar.pirate)
            self.main.lastDialog = dialog
            self.main.JSD_HAIR[idx].remove(dialog)
Esempio n. 10
0
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])
Esempio n. 11
0
class JewelryGUI(DirectFrame, StateData.StateData):
    notify = DirectNotifyGlobal.directNotify.newCategory('JewelryGUI')

    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.zoneTabs = []
        self.zoneFrames = []
        self.load()

    def enter(self):
        self.notify.debug('enter')
        self.show()
        if self.mode == None:
            self.load()
            self.mode = -1

    def exit(self):
        self.hide()

    def save(self):
        if self.mode == -1:
            pass
        1
        self.saveDNA()

    def load(self):
        self.loadTabs()
        self.setupButtons()

    def assignAvatar(self, avatar):
        self.avatar = avatar

    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='L Ear',
                                     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.zoneTabs.append(self.zone1Tab)
        self.zone2Tab = DirectButton(parent=self.parent,
                                     relief=DGG.RAISED,
                                     frameSize=(-0.13, 0.13,
                                                -0.040000000000000001,
                                                0.040000000000000001),
                                     borderWidth=(0.0080000000000000002,
                                                  0.0080000000000000002),
                                     text='R Ear',
                                     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.zoneTabs.append(self.zone2Tab)
        self.zone3Tab = DirectButton(parent=self.parent,
                                     relief=DGG.RAISED,
                                     frameSize=(-0.13, 0.13,
                                                -0.040000000000000001,
                                                0.040000000000000001),
                                     borderWidth=(0.0080000000000000002,
                                                  0.0080000000000000002),
                                     text='L Brow',
                                     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.zoneTabs.append(self.zone3Tab)
        self.zone4Tab = DirectButton(parent=self.parent,
                                     relief=DGG.RAISED,
                                     frameSize=(-0.13, 0.13,
                                                -0.040000000000000001,
                                                0.040000000000000001),
                                     borderWidth=(0.0080000000000000002,
                                                  0.0080000000000000002),
                                     text='R Brow',
                                     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.zoneTabs.append(self.zone4Tab)
        self.zone5Tab = DirectButton(parent=self.parent,
                                     relief=DGG.RAISED,
                                     frameSize=(-0.13, 0.13,
                                                -0.040000000000000001,
                                                0.040000000000000001),
                                     borderWidth=(0.0080000000000000002,
                                                  0.0080000000000000002),
                                     text='Nose',
                                     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.zoneTabs.append(self.zone5Tab)
        self.zone6Tab = DirectButton(parent=self.parent,
                                     relief=DGG.RAISED,
                                     frameSize=(-0.13, 0.13,
                                                -0.040000000000000001,
                                                0.040000000000000001),
                                     borderWidth=(0.0080000000000000002,
                                                  0.0080000000000000002),
                                     text='Mouth',
                                     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.zoneTabs.append(self.zone6Tab)
        self.zone7Tab = DirectButton(parent=self.parent,
                                     relief=DGG.RAISED,
                                     frameSize=(-0.13, 0.13,
                                                -0.040000000000000001,
                                                0.040000000000000001),
                                     borderWidth=(0.0080000000000000002,
                                                  0.0080000000000000002),
                                     text='L Hand',
                                     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.zoneTabs.append(self.zone7Tab)
        self.zone8Tab = DirectButton(parent=self.parent,
                                     relief=DGG.RAISED,
                                     frameSize=(-0.13, 0.13,
                                                -0.040000000000000001,
                                                0.040000000000000001),
                                     borderWidth=(0.0080000000000000002,
                                                  0.0080000000000000002),
                                     text='R Hand',
                                     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()
        self.zoneTabs.append(self.zone8Tab)

    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
        for i in range(0, len(self.zoneTabs)):
            self.zoneTabs[i]['state'] = DGG.NORMAL
            self.zoneTabs[i]['relief'] = DGG.RAISED
            self.zoneFrames[i].hide()

        self.zoneTabs[mode]['state'] = DGG.DISABLED
        self.zoneTabs[mode]['relief'] = DGG.SUNKEN
        self.zoneFrames[mode].show()
        if mode < Zone7_Tab:
            self.main.pgsZoom['value'] = 1.0
        else:
            self.main.pgsZoom['value'] = 0.5
        if mode in [Zone1_Tab, Zone7_Tab]:
            self.main.pgsRotate['value'] = -0.29999999999999999
        elif mode in [Zone2_Tab, Zone8_Tab]:
            self.main.pgsRotate['value'] = 0.29999999999999999
        else:
            self.main.pgsRotate['value'] = 0.0
        self.reparentCommonGui(mode)

    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
        for i in range(0, len(self.zoneTabs)):
            self.zoneTabs[i]['state'] = DGG.NORMAL
            self.zoneTabs[i].hide()
            self.zoneFrames[i].hide()

        self.saveDNA()

    def setupButtons(self):
        self.zone1Frame = DirectFrame(parent=self.parent,
                                      relief=DGG.FLAT,
                                      pos=(0.0, 0, 0.69999999999999996))
        self.zone1Frame.hide()
        self.zoneFrames.append(self.zone1Frame)
        self.jewelry1Picker = CharGuiPicker(
            self.main,
            parent=self.zone1Frame,
            text=PLocalizer.ShapeJewelryLEarFrameTitle,
            nextCommand=Functor(self.handleNextJewelry,
                                jewelry_keys[Zone1_Tab]),
            backCommand=Functor(self.handleLastJewelry,
                                jewelry_keys[Zone1_Tab]))
        self.jewelry1Picker.setPos(0, 0, -0.5)
        self.zone2Frame = DirectFrame(parent=self.parent,
                                      relief=DGG.FLAT,
                                      pos=(0.0, 0, 0.69999999999999996))
        self.zone2Frame.hide()
        self.zoneFrames.append(self.zone2Frame)
        self.jewelry2Picker = CharGuiPicker(
            self.main,
            parent=self.zone2Frame,
            text=PLocalizer.ShapeJewelryREarFrameTitle,
            nextCommand=Functor(self.handleNextJewelry,
                                jewelry_keys[Zone2_Tab]),
            backCommand=Functor(self.handleLastJewelry,
                                jewelry_keys[Zone2_Tab]))
        self.jewelry2Picker.setPos(0, 0, -0.5)
        self.zone3Frame = DirectFrame(parent=self.parent,
                                      relief=DGG.FLAT,
                                      pos=(0.0, 0, 0.69999999999999996))
        self.zone3Frame.hide()
        self.zoneFrames.append(self.zone3Frame)
        self.jewelry3Picker = CharGuiPicker(
            self.main,
            parent=self.zone3Frame,
            text=PLocalizer.ShapeJewelryLBrowFrameTitle,
            nextCommand=Functor(self.handleNextJewelry,
                                jewelry_keys[Zone3_Tab]),
            backCommand=Functor(self.handleLastJewelry,
                                jewelry_keys[Zone3_Tab]))
        self.jewelry3Picker.setPos(0, 0, -0.5)
        self.zone4Frame = DirectFrame(parent=self.parent,
                                      relief=DGG.FLAT,
                                      pos=(0.0, 0, 0.69999999999999996))
        self.zone4Frame.hide()
        self.zoneFrames.append(self.zone4Frame)
        self.jewelry4Picker = CharGuiPicker(
            self.main,
            parent=self.zone4Frame,
            text=PLocalizer.ShapeJewelryRBrowFrameTitle,
            nextCommand=Functor(self.handleNextJewelry,
                                jewelry_keys[Zone4_Tab]),
            backCommand=Functor(self.handleLastJewelry,
                                jewelry_keys[Zone4_Tab]))
        self.jewelry4Picker.setPos(0, 0, -0.5)
        self.zone5Frame = DirectFrame(parent=self.parent,
                                      relief=DGG.FLAT,
                                      pos=(0.0, 0, 0.69999999999999996))
        self.zone5Frame.hide()
        self.zoneFrames.append(self.zone5Frame)
        self.jewelry5Picker = CharGuiPicker(
            self.main,
            parent=self.zone5Frame,
            text=PLocalizer.ShapeJewelryNoseFrameTitle,
            nextCommand=Functor(self.handleNextJewelry,
                                jewelry_keys[Zone5_Tab]),
            backCommand=Functor(self.handleLastJewelry,
                                jewelry_keys[Zone5_Tab]))
        self.jewelry5Picker.setPos(0, 0, -0.5)
        self.zone6Frame = DirectFrame(parent=self.parent,
                                      relief=DGG.FLAT,
                                      pos=(0.0, 0, 0.69999999999999996))
        self.zone6Frame.hide()
        self.zoneFrames.append(self.zone6Frame)
        self.jewelry6Picker = CharGuiPicker(
            self.main,
            parent=self.zone6Frame,
            text=PLocalizer.ShapeJewelryMouthFrameTitle,
            nextCommand=Functor(self.handleNextJewelry,
                                jewelry_keys[Zone6_Tab]),
            backCommand=Functor(self.handleLastJewelry,
                                jewelry_keys[Zone6_Tab]))
        self.jewelry6Picker.setPos(0, 0, -0.5)
        self.zone7Frame = DirectFrame(parent=self.parent,
                                      relief=DGG.FLAT,
                                      pos=(0.0, 0, 0.69999999999999996))
        self.zone7Frame.hide()
        self.zoneFrames.append(self.zone7Frame)
        self.jewelry7Picker = CharGuiPicker(
            self.main,
            parent=self.zone7Frame,
            text=PLocalizer.ShapeJewelryLHandFrameTitle,
            nextCommand=Functor(self.handleNextJewelry,
                                jewelry_keys[Zone7_Tab]),
            backCommand=Functor(self.handleLastJewelry,
                                jewelry_keys[Zone7_Tab]))
        self.jewelry7Picker.setPos(0, 0, -0.5)
        self.zone8Frame = DirectFrame(parent=self.parent,
                                      relief=DGG.FLAT,
                                      pos=(0.0, 0, 0.69999999999999996))
        self.zone8Frame.hide()
        self.zoneFrames.append(self.zone8Frame)
        self.jewelry8Picker = CharGuiPicker(
            self.main,
            parent=self.zone8Frame,
            text=PLocalizer.ShapeJewelryRHandFrameTitle,
            nextCommand=Functor(self.handleNextJewelry,
                                jewelry_keys[Zone8_Tab]),
            backCommand=Functor(self.handleLastJewelry,
                                jewelry_keys[Zone8_Tab]))
        self.jewelry8Picker.setPos(0, 0, -0.5)
        self.loadColorGUI()

    def loadColorGUI(self):
        self.primaryColorFrame = DirectFrame(
            parent=self.zone1Frame,
            relief=None,
            image=self.main.charGui.find('**/chargui_frame01'),
            image_pos=(0, 0, -0.29999999999999999),
            image_scale=(2.4300000000000002, 1.6000000000000001,
                         1.6000000000000001),
            text='Pirmary Color',
            text_fg=(1, 1, 1, 1),
            text_scale=0.17999999999999999,
            text_pos=(0, -0.050000000000000003),
            pos=(0, 0, -0.80000000000000004),
            scale=0.69999999999999996)
        self.primaryColorButtons = []
        xOffset = -0.80000000000000004
        yOffset = -0.29999999999999999
        for i in range(0, len(HumanDNA.jewelryColors)):
            if i and i % 9 == 0:
                xOffset = -0.5
                yOffset -= 0.29999999999999999

            jewelryColor = HumanDNA.jewelryColors[i]
            if jewelryColor is None:
                jewelryColor = VBase4(0, 0, 0, 1)

            self.primaryColorButtons.append(
                DirectButton(
                    parent=self.primaryColorFrame,
                    relief=DGG.RAISED,
                    pos=(xOffset, 0, yOffset),
                    frameSize=(-0.10000000000000001, 0.10000000000000001,
                               -0.10000000000000001, 0.10000000000000001),
                    borderWidth=(0.0080000000000000002, 0.0080000000000000002),
                    frameColor=jewelryColor,
                    command=self.handleSetPrimaryColor,
                    extraArgs=[i]))
            xOffset += 0.20000000000000001

        self.secondaryColorFrame = DirectFrame(
            parent=self.zone1Frame,
            relief=None,
            image=self.main.charGui.find('**/chargui_frame01'),
            image_pos=(0, 0, -0.29999999999999999),
            image_scale=(2.4300000000000002, 1.6000000000000001,
                         1.6000000000000001),
            text='Secondary Color',
            text_fg=(1, 1, 1, 1),
            text_scale=0.17999999999999999,
            text_pos=(0, -0.050000000000000003),
            pos=(0, 0, -1.3999999999999999),
            scale=0.69999999999999996)
        self.secondaryColorButtons = []
        xOffset = -0.80000000000000004
        yOffset = -0.29999999999999999
        for i in range(0, len(HumanDNA.jewelryColors)):
            if i and i % 9 == 0:
                xOffset = -0.5
                yOffset -= 0.29999999999999999

            jewelryColor = HumanDNA.jewelryColors[i]
            if jewelryColor is None:
                jewelryColor = VBase4(0, 0, 0, 1)

            self.secondaryColorButtons.append(
                DirectButton(
                    parent=self.secondaryColorFrame,
                    relief=DGG.RAISED,
                    pos=(xOffset, 0, yOffset),
                    frameSize=(-0.10000000000000001, 0.10000000000000001,
                               -0.10000000000000001, 0.10000000000000001),
                    borderWidth=(0.0080000000000000002, 0.0080000000000000002),
                    frameColor=jewelryColor,
                    command=self.handleSetSecondaryColor,
                    extraArgs=[i]))
            xOffset += 0.20000000000000001

    def reset(self):
        self.avatar.hideAllJewelry()
        self.saveDNA()

    def saveDNA(self):
        self.avatar.pirate.setJewelryZone1(
            self.avatar.currentJewelry['LEar'][0],
            self.avatar.currentJewelry['LEar'][1],
            self.avatar.currentJewelry['LEar'][2])
        self.avatar.pirate.setJewelryZone2(
            self.avatar.currentJewelry['REar'][0],
            self.avatar.currentJewelry['REar'][1],
            self.avatar.currentJewelry['REar'][2])
        self.avatar.pirate.setJewelryZone3(
            self.avatar.currentJewelry['LBrow'][0],
            self.avatar.currentJewelry['LBrow'][1],
            self.avatar.currentJewelry['LBrow'][2])
        self.avatar.pirate.setJewelryZone4(
            self.avatar.currentJewelry['RBrow'][0],
            self.avatar.currentJewelry['RBrow'][1],
            self.avatar.currentJewelry['RBrow'][2])
        self.avatar.pirate.setJewelryZone5(
            self.avatar.currentJewelry['Nose'][0],
            self.avatar.currentJewelry['Nose'][1],
            self.avatar.currentJewelry['Nose'][2])
        self.avatar.pirate.setJewelryZone6(
            self.avatar.currentJewelry['Mouth'][0],
            self.avatar.currentJewelry['Mouth'][1],
            self.avatar.currentJewelry['Mouth'][2])
        self.avatar.pirate.setJewelryZone7(
            self.avatar.currentJewelry['LHand'][0],
            self.avatar.currentJewelry['LHand'][1],
            self.avatar.currentJewelry['LHand'][2])
        self.avatar.pirate.setJewelryZone8(
            self.avatar.currentJewelry['RHand'][0],
            self.avatar.currentJewelry['RHand'][1],
            self.avatar.currentJewelry['RHand'][2])

    def randomPick(self):
        pass

    def reparentCommonGui(self, mode):
        self.primaryColorFrame.reparentTo(self.zoneFrames[mode])
        self.secondaryColorFrame.reparentTo(self.zoneFrames[mode])
        for i in range(0, len(self.primaryColorButtons)):
            self.primaryColorButtons[i]['relief'] = DGG.RAISED

        for i in range(0, len(self.secondaryColorButtons)):
            self.secondaryColorButtons[i]['relief'] = DGG.RAISED

    def handleNextJewelry(self, key):
        self.avatar.handleJewelryOptions(key, True)
        print self.avatar.currentJewelry

    def handleLastJewelry(self, key):
        self.avatar.handleJewelryOptions(key, False)

    def handleSetPrimaryColor(self, colorIdx):
        for i in range(0, len(self.primaryColorButtons)):
            self.primaryColorButtons[i]['relief'] = DGG.RAISED

        self.primaryColorButtons[colorIdx]['relief'] = DGG.SUNKEN
        primaryColor = HumanDNA.jewelryColors[colorIdx]
        if primaryColor:
            key = jewelry_keys[self.mode]
            idx = self.avatar.currentJewelry[key][0]
            self.avatar.jewelrySets[key][idx][0].setColor(primaryColor)
            self.avatar.currentJewelry[key][1] = colorIdx

    def handleSetSecondaryColor(self, colorIdx):
        for i in range(0, len(self.secondaryColorButtons)):
            self.secondaryColorButtons[i]['relief'] = DGG.RAISED

        self.secondaryColorButtons[colorIdx]['relief'] = DGG.SUNKEN
        secondaryColor = HumanDNA.jewelryColors[colorIdx]
        if secondaryColor:
            key = jewelry_keys[self.mode]
            idx = self.avatar.currentJewelry[key][0]
            self.avatar.jewelrySets[key][idx][1].setColor(secondaryColor)
            self.avatar.currentJewelry[key][2] = colorIdx
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()
Esempio n. 13
0
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 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()
Esempio n. 15
0
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()
Esempio n. 16
0
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()
Esempio n. 17
0
 def setupButtons(self):
     self.zone1Frame = DirectFrame(parent=self.parent,
                                   relief=DGG.FLAT,
                                   pos=(0.0, 0, 0.69999999999999996))
     self.zone1Frame.hide()
     self.zoneFrames.append(self.zone1Frame)
     self.jewelry1Picker = CharGuiPicker(
         self.main,
         parent=self.zone1Frame,
         text=PLocalizer.ShapeJewelryLEarFrameTitle,
         nextCommand=Functor(self.handleNextJewelry,
                             jewelry_keys[Zone1_Tab]),
         backCommand=Functor(self.handleLastJewelry,
                             jewelry_keys[Zone1_Tab]))
     self.jewelry1Picker.setPos(0, 0, -0.5)
     self.zone2Frame = DirectFrame(parent=self.parent,
                                   relief=DGG.FLAT,
                                   pos=(0.0, 0, 0.69999999999999996))
     self.zone2Frame.hide()
     self.zoneFrames.append(self.zone2Frame)
     self.jewelry2Picker = CharGuiPicker(
         self.main,
         parent=self.zone2Frame,
         text=PLocalizer.ShapeJewelryREarFrameTitle,
         nextCommand=Functor(self.handleNextJewelry,
                             jewelry_keys[Zone2_Tab]),
         backCommand=Functor(self.handleLastJewelry,
                             jewelry_keys[Zone2_Tab]))
     self.jewelry2Picker.setPos(0, 0, -0.5)
     self.zone3Frame = DirectFrame(parent=self.parent,
                                   relief=DGG.FLAT,
                                   pos=(0.0, 0, 0.69999999999999996))
     self.zone3Frame.hide()
     self.zoneFrames.append(self.zone3Frame)
     self.jewelry3Picker = CharGuiPicker(
         self.main,
         parent=self.zone3Frame,
         text=PLocalizer.ShapeJewelryLBrowFrameTitle,
         nextCommand=Functor(self.handleNextJewelry,
                             jewelry_keys[Zone3_Tab]),
         backCommand=Functor(self.handleLastJewelry,
                             jewelry_keys[Zone3_Tab]))
     self.jewelry3Picker.setPos(0, 0, -0.5)
     self.zone4Frame = DirectFrame(parent=self.parent,
                                   relief=DGG.FLAT,
                                   pos=(0.0, 0, 0.69999999999999996))
     self.zone4Frame.hide()
     self.zoneFrames.append(self.zone4Frame)
     self.jewelry4Picker = CharGuiPicker(
         self.main,
         parent=self.zone4Frame,
         text=PLocalizer.ShapeJewelryRBrowFrameTitle,
         nextCommand=Functor(self.handleNextJewelry,
                             jewelry_keys[Zone4_Tab]),
         backCommand=Functor(self.handleLastJewelry,
                             jewelry_keys[Zone4_Tab]))
     self.jewelry4Picker.setPos(0, 0, -0.5)
     self.zone5Frame = DirectFrame(parent=self.parent,
                                   relief=DGG.FLAT,
                                   pos=(0.0, 0, 0.69999999999999996))
     self.zone5Frame.hide()
     self.zoneFrames.append(self.zone5Frame)
     self.jewelry5Picker = CharGuiPicker(
         self.main,
         parent=self.zone5Frame,
         text=PLocalizer.ShapeJewelryNoseFrameTitle,
         nextCommand=Functor(self.handleNextJewelry,
                             jewelry_keys[Zone5_Tab]),
         backCommand=Functor(self.handleLastJewelry,
                             jewelry_keys[Zone5_Tab]))
     self.jewelry5Picker.setPos(0, 0, -0.5)
     self.zone6Frame = DirectFrame(parent=self.parent,
                                   relief=DGG.FLAT,
                                   pos=(0.0, 0, 0.69999999999999996))
     self.zone6Frame.hide()
     self.zoneFrames.append(self.zone6Frame)
     self.jewelry6Picker = CharGuiPicker(
         self.main,
         parent=self.zone6Frame,
         text=PLocalizer.ShapeJewelryMouthFrameTitle,
         nextCommand=Functor(self.handleNextJewelry,
                             jewelry_keys[Zone6_Tab]),
         backCommand=Functor(self.handleLastJewelry,
                             jewelry_keys[Zone6_Tab]))
     self.jewelry6Picker.setPos(0, 0, -0.5)
     self.zone7Frame = DirectFrame(parent=self.parent,
                                   relief=DGG.FLAT,
                                   pos=(0.0, 0, 0.69999999999999996))
     self.zone7Frame.hide()
     self.zoneFrames.append(self.zone7Frame)
     self.jewelry7Picker = CharGuiPicker(
         self.main,
         parent=self.zone7Frame,
         text=PLocalizer.ShapeJewelryLHandFrameTitle,
         nextCommand=Functor(self.handleNextJewelry,
                             jewelry_keys[Zone7_Tab]),
         backCommand=Functor(self.handleLastJewelry,
                             jewelry_keys[Zone7_Tab]))
     self.jewelry7Picker.setPos(0, 0, -0.5)
     self.zone8Frame = DirectFrame(parent=self.parent,
                                   relief=DGG.FLAT,
                                   pos=(0.0, 0, 0.69999999999999996))
     self.zone8Frame.hide()
     self.zoneFrames.append(self.zone8Frame)
     self.jewelry8Picker = CharGuiPicker(
         self.main,
         parent=self.zone8Frame,
         text=PLocalizer.ShapeJewelryRHandFrameTitle,
         nextCommand=Functor(self.handleNextJewelry,
                             jewelry_keys[Zone8_Tab]),
         backCommand=Functor(self.handleLastJewelry,
                             jewelry_keys[Zone8_Tab]))
     self.jewelry8Picker.setPos(0, 0, -0.5)
     self.loadColorGUI()
Esempio n. 18
0
 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()
Esempio n. 19
0
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 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])