Color gender equality

This commit is contained in:
John 2015-08-04 14:46:02 +03:00
parent a4c9d2957c
commit 1f4783607d
4 changed files with 34 additions and 103 deletions

View file

@ -166,6 +166,14 @@ class BodyShop(StateData.StateData):
self.shuffleButton.unload() self.shuffleButton.unload()
self.ignore('MAT-newToonCreated') self.ignore('MAT-newToonCreated')
def checkColors(self):
if self.dna.armColor not in ToonDNA.defaultColorList:
self.dna.armColor = ToonDNA.defaultColorList[0]
if self.dna.legColor not in ToonDNA.defaultColorList:
self.dna.legColor = ToonDNA.defaultColorList[0]
if self.dna.headColor not in ToonDNA.defaultColorList:
self.dna.headColor = ToonDNA.defaultColorList[0]
def __swapTorso(self, offset): def __swapTorso(self, offset):
gender = self.toon.style.getGender() gender = self.toon.style.getGender()
if not self.clothesPicked: if not self.clothesPicked:
@ -174,12 +182,7 @@ class BodyShop(StateData.StateData):
elif gender == 'm': elif gender == 'm':
length = len(ToonDNA.toonTorsoTypes[:3]) length = len(ToonDNA.toonTorsoTypes[:3])
torsoOffset = 0 torsoOffset = 0
if self.dna.armColor not in ToonDNA.defaultBoyColorList: self.checkColors()
self.dna.armColor = ToonDNA.defaultBoyColorList[0]
if self.dna.legColor not in ToonDNA.defaultBoyColorList:
self.dna.legColor = ToonDNA.defaultBoyColorList[0]
if self.dna.headColor not in ToonDNA.defaultBoyColorList:
self.dna.headColor = ToonDNA.defaultBoyColorList[0]
if self.toon.style.topTex not in ToonDNA.MakeAToonBoyShirts: if self.toon.style.topTex not in ToonDNA.MakeAToonBoyShirts:
randomShirt = ToonDNA.getRandomTop(gender, ToonDNA.MAKE_A_TOON) randomShirt = ToonDNA.getRandomTop(gender, ToonDNA.MAKE_A_TOON)
shirtTex, shirtColor, sleeveTex, sleeveColor = randomShirt shirtTex, shirtColor, sleeveTex, sleeveColor = randomShirt
@ -197,12 +200,7 @@ class BodyShop(StateData.StateData):
torsoOffset = 3 torsoOffset = 3
else: else:
torsoOffset = 0 torsoOffset = 0
if self.dna.armColor not in ToonDNA.defaultGirlColorList: self.checkColors()
self.dna.armColor = ToonDNA.defaultGirlColorList[0]
if self.dna.legColor not in ToonDNA.defaultGirlColorList:
self.dna.legColor = ToonDNA.defaultGirlColorList[0]
if self.dna.headColor not in ToonDNA.defaultGirlColorList:
self.dna.headColor = ToonDNA.defaultGirlColorList[0]
if self.toon.style.topTex not in ToonDNA.MakeAToonGirlShirts: if self.toon.style.topTex not in ToonDNA.MakeAToonGirlShirts:
randomShirt = ToonDNA.getRandomTop(gender, ToonDNA.MAKE_A_TOON) randomShirt = ToonDNA.getRandomTop(gender, ToonDNA.MAKE_A_TOON)
shirtTex, shirtColor, sleeveTex, sleeveColor = randomShirt shirtTex, shirtColor, sleeveTex, sleeveColor = randomShirt

View file

@ -17,19 +17,14 @@ class ColorShop(StateData.StateData):
self.colorAll = 1 self.colorAll = 1
return return
def getGenderColorList(self, dna): def getColorList(self):
if self.dna.getGender() == 'm': return ToonDNA.defaultColorList
colorList = ToonDNA.defaultBoyColorList
else:
colorList = ToonDNA.defaultGirlColorList
return colorList
def enter(self, toon, shopsVisited = []): def enter(self, toon, shopsVisited = []):
base.disableMouse() base.disableMouse()
self.toon = toon self.toon = toon
self.dna = toon.getStyle() self.dna = toon.getStyle()
colorList = self.getGenderColorList(self.dna) colorList = self.getColorList()
try: try:
self.headChoice = colorList.index(self.dna.headColor) self.headChoice = colorList.index(self.dna.headColor)
self.armChoice = colorList.index(self.dna.armColor) self.armChoice = colorList.index(self.dna.armColor)
@ -48,7 +43,7 @@ class ColorShop(StateData.StateData):
self.startColor = 0 self.startColor = 0
self.acceptOnce('last', self.__handleBackward) self.acceptOnce('last', self.__handleBackward)
self.acceptOnce('next', self.__handleForward) self.acceptOnce('next', self.__handleForward)
choicePool = [self.getGenderColorList(self.dna), self.getGenderColorList(self.dna), self.getGenderColorList(self.dna), self.getGenderColorList(self.dna)] choicePool = [self.getColorList(), self.getColorList(), self.getColorList(), self.getColorList()]
self.shuffleButton.setChoicePool(choicePool) self.shuffleButton.setChoicePool(choicePool)
self.accept(self.shuffleFetchMsg, self.changeColor) self.accept(self.shuffleFetchMsg, self.changeColor)
self.acceptOnce('MAT-newToonCreated', self.shuffleButton.cleanHistory) self.acceptOnce('MAT-newToonCreated', self.shuffleButton.cleanHistory)
@ -172,7 +167,7 @@ class ColorShop(StateData.StateData):
self.ignore('MAT-newToonCreated') self.ignore('MAT-newToonCreated')
def __swapAllColor(self, offset): def __swapAllColor(self, offset):
colorList = self.getGenderColorList(self.dna) colorList = self.getColorList()
length = len(colorList) length = len(colorList)
choice = (self.headChoice + offset) % length choice = (self.headChoice + offset) % length
self.__updateScrollButtons(choice, length, self.allLButton, self.allRButton) self.__updateScrollButtons(choice, length, self.allLButton, self.allRButton)
@ -185,7 +180,7 @@ class ColorShop(StateData.StateData):
self.__swapLegColor(choice - oldLegColorIndex) self.__swapLegColor(choice - oldLegColorIndex)
def __swapHeadColor(self, offset): def __swapHeadColor(self, offset):
colorList = self.getGenderColorList(self.dna) colorList = self.getColorList()
length = len(colorList) length = len(colorList)
self.headChoice = (self.headChoice + offset) % length self.headChoice = (self.headChoice + offset) % length
self.__updateScrollButtons(self.headChoice, length, self.headLButton, self.headRButton) self.__updateScrollButtons(self.headChoice, length, self.headLButton, self.headRButton)
@ -194,7 +189,7 @@ class ColorShop(StateData.StateData):
self.toon.swapToonColor(self.dna) self.toon.swapToonColor(self.dna)
def __swapArmColor(self, offset): def __swapArmColor(self, offset):
colorList = self.getGenderColorList(self.dna) colorList = self.getColorList()
length = len(colorList) length = len(colorList)
self.armChoice = (self.armChoice + offset) % length self.armChoice = (self.armChoice + offset) % length
self.__updateScrollButtons(self.armChoice, length, self.armLButton, self.armRButton) self.__updateScrollButtons(self.armChoice, length, self.armLButton, self.armRButton)
@ -203,7 +198,7 @@ class ColorShop(StateData.StateData):
self.toon.swapToonColor(self.dna) self.toon.swapToonColor(self.dna)
def __swapGloveColor(self, offset): def __swapGloveColor(self, offset):
colorList = self.getGenderColorList(self.dna) colorList = self.getColorList()
length = len(colorList) length = len(colorList)
self.gloveChoice = (self.gloveChoice + offset) % length self.gloveChoice = (self.gloveChoice + offset) % length
self.__updateScrollButtons(self.gloveChoice, length, self.gloveLButton, self.gloveRButton) self.__updateScrollButtons(self.gloveChoice, length, self.gloveLButton, self.gloveRButton)
@ -212,7 +207,7 @@ class ColorShop(StateData.StateData):
self.toon.swapToonColor(self.dna) self.toon.swapToonColor(self.dna)
def __swapLegColor(self, offset): def __swapLegColor(self, offset):
colorList = self.getGenderColorList(self.dna) colorList = self.getColorList()
length = len(colorList) length = len(colorList)
self.legChoice = (self.legChoice + offset) % length self.legChoice = (self.legChoice + offset) % length
self.__updateScrollButtons(self.legChoice, length, self.legLButton, self.legRButton) self.__updateScrollButtons(self.legChoice, length, self.legLButton, self.legRButton)
@ -240,7 +235,7 @@ class ColorShop(StateData.StateData):
def changeColor(self): def changeColor(self):
self.notify.debug('Entering changeColor') self.notify.debug('Entering changeColor')
colorList = self.getGenderColorList(self.dna) colorList = self.getColorList()
newChoice = self.shuffleButton.getCurrChoice() newChoice = self.shuffleButton.getCurrChoice()
newHeadColorIndex = colorList.index(newChoice[0]) newHeadColorIndex = colorList.index(newChoice[0])
newArmColorIndex = colorList.index(newChoice[1]) newArmColorIndex = colorList.index(newChoice[1])

View file

@ -4755,47 +4755,29 @@ def dna(part, value):
return 'Legs set to: ' + dna.legs return 'Legs set to: ' + dna.legs
if part == 'headcolor': if part == 'headcolor':
if dna.gender not in ('m', 'f'): if value not in ToonDNA.defaultColorList:
return 'Unknown gender.' return 'Invalid head color index: ' + str(value)
if (dna.gender == 'm') and (value not in ToonDNA.defaultBoyColorList):
return 'Invalid male head color index: ' + str(value)
if (dna.gender == 'f') and (value not in ToonDNA.defaultGirlColorList):
return 'Invalid female head color index: ' + str(value)
dna.headColor = value dna.headColor = value
invoker.b_setDNAString(dna.makeNetString()) invoker.b_setDNAString(dna.makeNetString())
return 'Head color index set to: ' + str(dna.headColor) return 'Head color index set to: ' + str(dna.headColor)
if part == 'armcolor': if part == 'armcolor':
if dna.gender not in ('m', 'f'): if value not in ToonDNA.defaultColorList:
return 'Unknown gender.' return 'Invalid arm color index: ' + str(value)
if (dna.gender == 'm') and (value not in ToonDNA.defaultBoyColorList):
return 'Invalid male arm color index: ' + str(value)
if (dna.gender == 'f') and (value not in ToonDNA.defaultGirlColorList):
return 'Invalid female arm color index: ' + str(value)
dna.armColor = value dna.armColor = value
invoker.b_setDNAString(dna.makeNetString()) invoker.b_setDNAString(dna.makeNetString())
return 'Arm color index set to: ' + str(dna.armColor) return 'Arm color index set to: ' + str(dna.armColor)
if part == 'legcolor': if part == 'legcolor':
if dna.gender not in ('m', 'f'): if value not in ToonDNA.defaultColorList:
return 'Unknown gender.' return 'Invalid leg color index: ' + str(value)
if (dna.gender == 'm') and (value not in ToonDNA.defaultBoyColorList):
return 'Invalid male leg color index: ' + str(value)
if (dna.gender == 'f') and (value not in ToonDNA.defaultGirlColorList):
return 'Invalid female leg color index: ' + str(value)
dna.legColor = value dna.legColor = value
invoker.b_setDNAString(dna.makeNetString()) invoker.b_setDNAString(dna.makeNetString())
return 'Leg color index set to: ' + str(dna.legColor) return 'Leg color index set to: ' + str(dna.legColor)
if part == 'color': if part == 'color':
if dna.gender not in ('m', 'f'): if (value not in ToonDNA.defaultColorList) and (value != 0x1a) and (value != 0x00):
return 'Unknown gender.' return 'Invalid color index: ' + str(value)
if (dna.gender == 'm') and (value not in ToonDNA.defaultBoyColorList):
if (value != 0x1a) and (value != 0x00):
return 'Invalid male color index: ' + str(value)
if (dna.gender == 'f') and (value not in ToonDNA.defaultGirlColorList):
if (value != 0x1a) and (value != 0x00):
return 'Invalid female color index: ' + str(value)
if (value == 0x1a) and (dna.getAnimal() != 'cat'): if (value == 0x1a) and (dna.getAnimal() != 'cat'):
return 'Invalid color index for species: ' + dna.getAnimal() return 'Invalid color index for species: ' + dna.getAnimal()
if (value == 0x00) and (dna.getAnimal() != 'bear'): if (value == 0x00) and (dna.getAnimal() != 'bear'):

View file

@ -1931,47 +1931,7 @@ allColorsList = [VBase4(1.0, 1.0, 1.0, 1.0),
VBase4(0.862745, 0.078431, 0.235294, 1.0), VBase4(0.862745, 0.078431, 0.235294, 1.0),
VBase4(0.0, 0.635294, 0.513725, 1.0), VBase4(0.0, 0.635294, 0.513725, 1.0),
VBase4(0.803921, 0.498039, 0.196078, 1.0)] VBase4(0.803921, 0.498039, 0.196078, 1.0)]
defaultBoyColorList = [0, defaultColorList = [0,
1,
32,
2,
3,
4,
5,
6,
7,
29,
8,
37,
35,
9,
10,
33,
11,
12,
30,
13,
14,
15,
39,
27,
28,
16,
17,
18,
19,
20,
21,
38,
36,
22,
23,
24,
25,
34,
31,
26]
defaultGirlColorList = [0,
1, 1,
32, 32,
2, 2,
@ -2012,7 +1972,7 @@ defaultGirlColorList = [0,
31, 31,
26] 26]
allColorsListApproximations = map(lambda x: VBase4(round(x[0], 3), round(x[1], 3), round(x[2], 3), round(x[3], 3)), allColorsList) allColorsListApproximations = map(lambda x: VBase4(round(x[0], 3), round(x[1], 3), round(x[2], 3), round(x[3], 3)), allColorsList)
allowedColors = set(map(lambda x: allColorsListApproximations[x], set([0] + defaultBoyColorList + defaultGirlColorList + [26]))) allowedColors = set(map(lambda x: allColorsListApproximations[x], set([0] + defaultColorList + [26])))
HatModels = [None, HatModels = [None,
'phase_4/models/accessories/tt_m_chr_avt_acc_hat_baseball', 'phase_4/models/accessories/tt_m_chr_avt_acc_hat_baseball',
'phase_4/models/accessories/tt_m_chr_avt_acc_hat_safari', 'phase_4/models/accessories/tt_m_chr_avt_acc_hat_safari',
@ -2715,6 +2675,7 @@ class ToonDNA:
self.head = generator.choice(toonHeadTypes[:22]) self.head = generator.choice(toonHeadTypes[:22])
top, topColor, sleeve, sleeveColor = getRandomTop(gender, generator=generator) top, topColor, sleeve, sleeveColor = getRandomTop(gender, generator=generator)
bottom, bottomColor = getRandomBottom(gender, generator=generator) bottom, bottomColor = getRandomBottom(gender, generator=generator)
color = generator.choice(defaultColorList)
if gender == 'm': if gender == 'm':
self.torso = generator.choice(toonTorsoTypes[:3]) self.torso = generator.choice(toonTorsoTypes[:3])
self.topTex = top self.topTex = top
@ -2723,10 +2684,6 @@ class ToonDNA:
self.sleeveTexColor = sleeveColor self.sleeveTexColor = sleeveColor
self.botTex = bottom self.botTex = bottom
self.botTexColor = bottomColor self.botTexColor = bottomColor
color = generator.choice(defaultBoyColorList)
self.armColor = color
self.legColor = color
self.headColor = color
else: else:
self.torso = generator.choice(toonTorsoTypes[:6]) self.torso = generator.choice(toonTorsoTypes[:6])
self.topTex = top self.topTex = top
@ -2739,7 +2696,6 @@ class ToonDNA:
bottom, bottomColor = getRandomBottom(gender, generator=generator, girlBottomType=SHORTS) bottom, bottomColor = getRandomBottom(gender, generator=generator, girlBottomType=SHORTS)
self.botTex = bottom self.botTex = bottom
self.botTexColor = bottomColor self.botTexColor = bottomColor
color = generator.choice(defaultGirlColorList)
self.armColor = color self.armColor = color
self.legColor = color self.legColor = color
self.headColor = color self.headColor = color