Actual color picker

This commit is contained in:
John 2015-08-04 21:57:39 +03:00
parent 86223ef6df
commit 8acb336dae
6 changed files with 121 additions and 83 deletions

View file

@ -165,14 +165,6 @@ class BodyShop(StateData.StateData):
del self.legRButton del self.legRButton
self.shuffleButton.unload() self.shuffleButton.unload()
self.ignore('MAT-newToonCreated') self.ignore('MAT-newToonCreated')
def checkColors(self):
if self.dna.armColor not in ToonDNA.allColorsList:
self.dna.armColor = ToonDNA.allColorsList[0]
if self.dna.legColor not in ToonDNA.allColorsList:
self.dna.legColor = ToonDNA.allColorsList[0]
if self.dna.headColor not in ToonDNA.allColorsList:
self.dna.headColor = ToonDNA.allColorsList[0]
def __swapTorso(self, offset): def __swapTorso(self, offset):
gender = self.toon.style.getGender() gender = self.toon.style.getGender()
@ -182,7 +174,6 @@ class BodyShop(StateData.StateData):
elif gender == 'm': elif gender == 'm':
length = len(ToonDNA.toonTorsoTypes[:3]) length = len(ToonDNA.toonTorsoTypes[:3])
torsoOffset = 0 torsoOffset = 0
self.checkColors()
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
@ -200,7 +191,6 @@ class BodyShop(StateData.StateData):
torsoOffset = 3 torsoOffset = 3
else: else:
torsoOffset = 0 torsoOffset = 0
self.checkColors()
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

@ -3,9 +3,9 @@ from toontown.toon import ToonDNA
from direct.fsm import StateData from direct.fsm import StateData
from direct.gui.DirectGui import * from direct.gui.DirectGui import *
from MakeAToonGlobals import * from MakeAToonGlobals import *
from toontown.toonbase import TTLocalizer from toontown.toonbase import TTLocalizer, ToontownGlobals
import ShuffleButton import ShuffleButton
import random import random, colorsys
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
class ColorShop(StateData.StateData): class ColorShop(StateData.StateData):
@ -25,22 +25,13 @@ class ColorShop(StateData.StateData):
self.toon = toon self.toon = toon
self.dna = toon.getStyle() self.dna = toon.getStyle()
colorList = self.getColorList() colorList = self.getColorList()
print str(self.dna) self.allParts = (TTLocalizer.ColorAll, TTLocalizer.ColorShopHead, TTLocalizer.ColorShopBody, TTLocalizer.ColorShopGloves, TTLocalizer.ColorShopLegs)
try: if not hasattr(self, 'headChoice'):
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)
self.gloveChoice = colorList.index(self.dna.gloveColor) self.gloveChoice = colorList.index(self.dna.gloveColor)
self.legChoice = colorList.index(self.dna.legColor) self.legChoice = colorList.index(self.dna.legColor)
except Exception as e: self.partChoice = 0
raise e
self.headChoice = random.choice(colorList)
self.armChoice = self.headChoice
self.gloveChoice = self.gloveChoice
self.legChoice = self.headChoice
self.__swapHeadColor(0)
self.__swapArmColor(0)
self.__swapGloveColor(0)
self.__swapLegColor(0)
self.startColor = 0 self.startColor = 0
self.acceptOnce('last', self.__handleBackward) self.acceptOnce('last', self.__handleBackward)
@ -55,6 +46,7 @@ class ColorShop(StateData.StateData):
def hideButtons(self): def hideButtons(self):
self.parentFrame.hide() self.parentFrame.hide()
self.advancedFrame.hide()
def exit(self): def exit(self):
self.ignore('last') self.ignore('last')
@ -75,67 +67,47 @@ class ColorShop(StateData.StateData):
guiRArrowDown = self.gui.find('**/tt_t_gui_mat_arrowDown') guiRArrowDown = self.gui.find('**/tt_t_gui_mat_arrowDown')
guiRArrowDisabled = self.gui.find('**/tt_t_gui_mat_arrowDisabled') guiRArrowDisabled = self.gui.find('**/tt_t_gui_mat_arrowDisabled')
shuffleFrame = self.gui.find('**/tt_t_gui_mat_shuffleFrame') shuffleFrame = self.gui.find('**/tt_t_gui_mat_shuffleFrame')
shuffleArrowUp = self.gui.find('**/tt_t_gui_mat_shuffleArrowUp') shuffleUp = self.gui.find('**/tt_t_gui_mat_shuffleUp')
shuffleArrowDown = self.gui.find('**/tt_t_gui_mat_shuffleArrowDown') shuffleDown = self.gui.find('**/tt_t_gui_mat_shuffleDown')
shuffleArrowRollover = self.gui.find('**/tt_t_gui_mat_shuffleArrowUp') shuffleImage = (self.gui.find('**/tt_t_gui_mat_shuffleArrowUp'), self.gui.find('**/tt_t_gui_mat_shuffleArrowDown'), self.gui.find('**/tt_t_gui_mat_shuffleArrowUp'), self.gui.find('**/tt_t_gui_mat_shuffleArrowDisabled'))
shuffleArrowDisabled = self.gui.find('**/tt_t_gui_mat_shuffleArrowDisabled') self.parentFrame = self.getNewFrame()
self.parentFrame = DirectFrame(relief=DGG.RAISED, pos=(0.98, 0, 0.416), frameColor=(1, 0, 0, 0)) self.advancedFrame = self.getNewFrame()
self.parentFrame.setPos(-0.36, 0, -0.5)
self.parentFrame.reparentTo(base.a2dTopRight)
self.toonFrame = DirectFrame(parent=self.parentFrame, image=shuffleFrame, image_scale=halfButtonInvertScale, relief=None, pos=(0, 0, 0.1), hpr=(0, 0, 0), scale=1.3, frameColor=(1, 1, 1, 1), text=TTLocalizer.ColorShopToon, text_scale=TTLocalizer.CStoonFrame, text_pos=(-0.001, -0.015), text_fg=(1, 1, 1, 1)) self.toonFrame = DirectFrame(parent=self.parentFrame, image=shuffleFrame, image_scale=halfButtonInvertScale, relief=None, pos=(0, 0, 0.1), hpr=(0, 0, 0), scale=1.3, frameColor=(1, 1, 1, 1), text=TTLocalizer.ColorShopToon, text_scale=TTLocalizer.CStoonFrame, text_pos=(-0.001, -0.015), text_fg=(1, 1, 1, 1))
self.allLButton = DirectButton(parent=self.toonFrame, relief=None, image=(shuffleArrowUp, self.allLButton = DirectButton(parent=self.toonFrame, relief=None, image=shuffleImage, image_scale=halfButtonScale, image1_scale=halfButtonHoverScale, image2_scale=halfButtonHoverScale, pos=(-0.2, 0, 0), command=self.__swapAllColor, extraArgs=[-1])
shuffleArrowDown, self.allRButton = DirectButton(parent=self.toonFrame, relief=None, image=shuffleImage, image_scale=halfButtonInvertScale, image1_scale=halfButtonInvertHoverScale, image2_scale=halfButtonInvertHoverScale, pos=(0.2, 0, 0), command=self.__swapAllColor, extraArgs=[1])
shuffleArrowRollover,
shuffleArrowDisabled), image_scale=halfButtonScale, image1_scale=halfButtonHoverScale, image2_scale=halfButtonHoverScale, pos=(-0.2, 0, 0), command=self.__swapAllColor, extraArgs=[-1])
self.allRButton = DirectButton(parent=self.toonFrame, relief=None, image=(shuffleArrowUp,
shuffleArrowDown,
shuffleArrowRollover,
shuffleArrowDisabled), image_scale=halfButtonInvertScale, image1_scale=halfButtonInvertHoverScale, image2_scale=halfButtonInvertHoverScale, pos=(0.2, 0, 0), command=self.__swapAllColor, extraArgs=[1])
self.headFrame = DirectFrame(parent=self.parentFrame, image=shuffleFrame, image_scale=halfButtonInvertScale, relief=None, pos=(0, 0, -0.15), hpr=(0, 0, 2), scale=0.9, frameColor=(1, 1, 1, 1), text=TTLocalizer.ColorShopHead, text_scale=0.0625, text_pos=(-0.001, -0.015), text_fg=(1, 1, 1, 1)) self.headFrame = DirectFrame(parent=self.parentFrame, image=shuffleFrame, image_scale=halfButtonInvertScale, relief=None, pos=(0, 0, -0.15), hpr=(0, 0, 2), scale=0.9, frameColor=(1, 1, 1, 1), text=TTLocalizer.ColorShopHead, text_scale=0.0625, text_pos=(-0.001, -0.015), text_fg=(1, 1, 1, 1))
self.headLButton = DirectButton(parent=self.headFrame, relief=None, image=(shuffleArrowUp, self.headLButton = DirectButton(parent=self.headFrame, relief=None, image=shuffleImage, image_scale=halfButtonScale, image1_scale=halfButtonHoverScale, image2_scale=halfButtonHoverScale, pos=(-0.2, 0, 0), command=self.__swapHeadColor, extraArgs=[-1])
shuffleArrowDown, self.headRButton = DirectButton(parent=self.headFrame, relief=None, image=shuffleImage, image_scale=halfButtonInvertScale, image1_scale=halfButtonInvertHoverScale, image2_scale=halfButtonInvertHoverScale, pos=(0.2, 0, 0), command=self.__swapHeadColor, extraArgs=[1])
shuffleArrowRollover,
shuffleArrowDisabled), image_scale=halfButtonScale, image1_scale=halfButtonHoverScale, image2_scale=halfButtonHoverScale, pos=(-0.2, 0, 0), command=self.__swapHeadColor, extraArgs=[-1])
self.headRButton = DirectButton(parent=self.headFrame, relief=None, image=(shuffleArrowUp,
shuffleArrowDown,
shuffleArrowRollover,
shuffleArrowDisabled), image_scale=halfButtonInvertScale, image1_scale=halfButtonInvertHoverScale, image2_scale=halfButtonInvertHoverScale, pos=(0.2, 0, 0), command=self.__swapHeadColor, extraArgs=[1])
self.bodyFrame = DirectFrame(parent=self.parentFrame, image=shuffleFrame, image_scale=halfButtonScale, relief=None, pos=(0, 0, -0.35), hpr=(0, 0, -2), scale=0.9, frameColor=(1, 1, 1, 1), text=TTLocalizer.ColorShopBody, text_scale=0.0625, text_pos=(-0.001, -0.015), text_fg=(1, 1, 1, 1)) self.bodyFrame = DirectFrame(parent=self.parentFrame, image=shuffleFrame, image_scale=halfButtonScale, relief=None, pos=(0, 0, -0.35), hpr=(0, 0, -2), scale=0.9, frameColor=(1, 1, 1, 1), text=TTLocalizer.ColorShopBody, text_scale=0.0625, text_pos=(-0.001, -0.015), text_fg=(1, 1, 1, 1))
self.armLButton = DirectButton(parent=self.bodyFrame, relief=None, image=(shuffleArrowUp, self.armLButton = DirectButton(parent=self.bodyFrame, relief=None, image=shuffleImage, image_scale=halfButtonScale, image1_scale=halfButtonHoverScale, image2_scale=halfButtonHoverScale, pos=(-0.2, 0, 0), command=self.__swapArmColor, extraArgs=[-1])
shuffleArrowDown, self.armRButton = DirectButton(parent=self.bodyFrame, relief=None, image=shuffleImage, image_scale=halfButtonInvertScale, image1_scale=halfButtonInvertHoverScale, image2_scale=halfButtonInvertHoverScale, pos=(0.2, 0, 0), command=self.__swapArmColor, extraArgs=[1])
shuffleArrowRollover,
shuffleArrowDisabled), image_scale=halfButtonScale, image1_scale=halfButtonHoverScale, image2_scale=halfButtonHoverScale, pos=(-0.2, 0, 0), command=self.__swapArmColor, extraArgs=[-1])
self.armRButton = DirectButton(parent=self.bodyFrame, relief=None, image=(shuffleArrowUp,
shuffleArrowDown,
shuffleArrowRollover,
shuffleArrowDisabled), image_scale=halfButtonInvertScale, image1_scale=halfButtonInvertHoverScale, image2_scale=halfButtonInvertHoverScale, pos=(0.2, 0, 0), command=self.__swapArmColor, extraArgs=[1])
self.gloveFrame = DirectFrame(parent=self.parentFrame, image=shuffleFrame, image_scale=halfButtonInvertScale, relief=None, pos=(0, 0, -0.55), hpr=(0, 0, 2), scale=0.9, frameColor=(1, 1, 1, 1), text=TTLocalizer.ColorShopGloves, text_scale=0.0625, text_pos=(-0.001, -0.015), text_fg=(1, 1, 1, 1)) self.gloveFrame = DirectFrame(parent=self.parentFrame, image=shuffleFrame, image_scale=halfButtonInvertScale, relief=None, pos=(0, 0, -0.55), hpr=(0, 0, 2), scale=0.9, frameColor=(1, 1, 1, 1), text=TTLocalizer.ColorShopGloves, text_scale=0.0625, text_pos=(-0.001, -0.015), text_fg=(1, 1, 1, 1))
self.gloveLButton = DirectButton(parent=self.gloveFrame, relief=None, image=(shuffleArrowUp, self.gloveLButton = DirectButton(parent=self.gloveFrame, relief=None, image=shuffleImage, image_scale=halfButtonScale, image1_scale=halfButtonHoverScale, image2_scale=halfButtonHoverScale, pos=(-0.2, 0, 0), command=self.__swapGloveColor, extraArgs=[-1])
shuffleArrowDown, self.gloveRButton = DirectButton(parent=self.gloveFrame, relief=None, image=shuffleImage, image_scale=halfButtonInvertScale, image1_scale=halfButtonInvertHoverScale, image2_scale=halfButtonInvertHoverScale, pos=(0.2, 0, 0), command=self.__swapGloveColor, extraArgs=[1])
shuffleArrowRollover,
shuffleArrowDisabled), image_scale=halfButtonScale, image1_scale=halfButtonHoverScale, image2_scale=halfButtonHoverScale, pos=(-0.2, 0, 0), command=self.__swapGloveColor, extraArgs=[-1])
self.gloveRButton = DirectButton(parent=self.gloveFrame, relief=None, image=(shuffleArrowUp,
shuffleArrowDown,
shuffleArrowRollover,
shuffleArrowDisabled), image_scale=halfButtonInvertScale, image1_scale=halfButtonInvertHoverScale, image2_scale=halfButtonInvertHoverScale, pos=(0.2, 0, 0), command=self.__swapGloveColor, extraArgs=[1])
self.legsFrame = DirectFrame(parent=self.parentFrame, image=shuffleFrame, image_scale=halfButtonInvertScale, relief=None, pos=(0, 0, -0.75), hpr=(0, 0, -2), scale=0.9, frameColor=(1, 1, 1, 1), text=TTLocalizer.ColorShopLegs, text_scale=0.0625, text_pos=(-0.001, -0.015), text_fg=(1, 1, 1, 1)) self.legsFrame = DirectFrame(parent=self.parentFrame, image=shuffleFrame, image_scale=halfButtonInvertScale, relief=None, pos=(0, 0, -0.75), hpr=(0, 0, -2), scale=0.9, frameColor=(1, 1, 1, 1), text=TTLocalizer.ColorShopLegs, text_scale=0.0625, text_pos=(-0.001, -0.015), text_fg=(1, 1, 1, 1))
self.legLButton = DirectButton(parent=self.legsFrame, relief=None, image=(shuffleArrowUp, self.legLButton = DirectButton(parent=self.legsFrame, relief=None, image=shuffleImage, image_scale=halfButtonScale, image1_scale=halfButtonHoverScale, image2_scale=halfButtonHoverScale, pos=(-0.2, 0, 0), command=self.__swapLegColor, extraArgs=[-1])
shuffleArrowDown, self.legRButton = DirectButton(parent=self.legsFrame, relief=None, image=shuffleImage, image_scale=halfButtonInvertScale, image1_scale=halfButtonInvertHoverScale, image2_scale=halfButtonInvertHoverScale, pos=(0.2, 0, 0), command=self.__swapLegColor, extraArgs=[1])
shuffleArrowRollover, self.advancedButton = DirectButton(parent=self.parentFrame, relief=None, image=(shuffleUp, shuffleDown, shuffleUp), image_scale=(-0.8, 0.6, 0.6), image1_scale=(-0.83, 0.6, 0.6), image2_scale=(-0.83, 0.6, 0.6), text=TTLocalizer.ColorAdvanced, text_font=ToontownGlobals.getInterfaceFont(), text_scale=TTLocalizer.SBshuffleBtn, text_pos=(0, -0.02), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), pos=(0, 0, -1.15), command=self.popupAdvancedMenu)
shuffleArrowDisabled), image_scale=halfButtonScale, image1_scale=halfButtonHoverScale, image2_scale=halfButtonHoverScale, pos=(-0.2, 0, 0), command=self.__swapLegColor, extraArgs=[-1]) self.basicButton = DirectButton(parent=self.advancedFrame, relief=None, image=(shuffleUp, shuffleDown, shuffleUp), image_scale=(-0.8, 0.6, 0.6), image1_scale=(-0.83, 0.6, 0.6), image2_scale=(-0.83, 0.6, 0.6), text=TTLocalizer.ColorBasic, text_font=ToontownGlobals.getInterfaceFont(), text_scale=TTLocalizer.SBshuffleBtn, text_pos=(0, -0.02), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), pos=(0, 0, -1.15), command=self.popupBasicMenu)
self.legRButton = DirectButton(parent=self.legsFrame, relief=None, image=(shuffleArrowUp, self.pickContainer = DirectFrame(parent=self.advancedFrame, relief=None, pos=(-0.4, 0, -0.5), image='phase_3/maps/color_picker_container.png', scale=(0.7, 0.5, 0.55))
shuffleArrowDown, self.pickContainer.setTransparency(True)
shuffleArrowRollover, self.pickImage = PNMImage(int((ToontownGlobals.COLOR_SATURATION_MAX - ToontownGlobals.COLOR_SATURATION_MIN) * 100), int((ToontownGlobals.COLOR_VALUE_MAX - ToontownGlobals.COLOR_VALUE_MIN) * 100))
shuffleArrowDisabled), image_scale=halfButtonInvertScale, image1_scale=halfButtonInvertHoverScale, image2_scale=halfButtonInvertHoverScale, pos=(0.2, 0, 0), command=self.__swapLegColor, extraArgs=[1]) self.hueSlider = DirectSlider(parent=self.advancedFrame, relief=None, image='phase_3/maps/color_picker_hue.jpg', scale=0.3, pos=(-0.05, 0, -0.43), image_scale=(0.1, 1.0, 1.0), pageSize=5, orientation=DGG.VERTICAL, command=self.__chooseHue)
self.pickButton = DirectButton(parent=self.advancedFrame, relief=None, image='phase_3/maps/color_picker_empty.png', scale=0.3, pos=(-0.45, 0, -0.43), frameColor=(1, 1, 1, 0.1), pressEffect=0)
self.pickButton.bind(DGG.B1CLICK, self.__pickColor)
self.partsFrame = DirectFrame(parent=self.advancedFrame, image=shuffleFrame, image_scale=halfButtonInvertScale, relief=None, pos=(-0.395, 0, -0.85), hpr=(0, 0, -2), scale=0.9, frameColor=(1, 1, 1, 1), text=TTLocalizer.ColorAll, text_scale=0.0625, text_pos=(-0.001, -0.015), text_fg=(1, 1, 1, 1))
self.partLButton = DirectButton(parent=self.partsFrame, relief=None, image=shuffleImage, image_scale=halfButtonScale, image1_scale=halfButtonHoverScale, image2_scale=halfButtonHoverScale, pos=(-0.2, 0, 0), state=DGG.DISABLED, command=self.__swapPart, extraArgs=[-1])
self.partRButton = DirectButton(parent=self.partsFrame, relief=None, image=shuffleImage, image_scale=halfButtonInvertScale, image1_scale=halfButtonInvertHoverScale, image2_scale=halfButtonInvertHoverScale, pos=(0.2, 0, 0), command=self.__swapPart, extraArgs=[1])
self.parentFrame.hide() self.parentFrame.hide()
self.advancedFrame.hide()
self.shuffleFetchMsg = 'ColorShopShuffle' self.shuffleFetchMsg = 'ColorShopShuffle'
self.shuffleButton = ShuffleButton.ShuffleButton(self, self.shuffleFetchMsg) self.shuffleButton = ShuffleButton.ShuffleButton(self, self.shuffleFetchMsg)
return
def unload(self): def unload(self):
self.gui.removeNode() self.gui.removeNode()
del self.gui del self.gui
self.parentFrame.destroy() self.parentFrame.destroy()
self.advancedFrame.destroy()
self.toonFrame.destroy() self.toonFrame.destroy()
self.headFrame.destroy() self.headFrame.destroy()
self.bodyFrame.destroy() self.bodyFrame.destroy()
@ -150,7 +122,16 @@ class ColorShop(StateData.StateData):
self.legRButton.destroy() self.legRButton.destroy()
self.allLButton.destroy() self.allLButton.destroy()
self.allRButton.destroy() self.allRButton.destroy()
self.advancedButton.destroy()
self.basicButton.destroy()
self.pickContainer.destroy()
self.hueSlider.destroy()
self.pickButton.destroy()
self.partsFrame.destroy()
self.partLButton.destroy()
self.partRButton.destroy()
del self.parentFrame del self.parentFrame
del self.advancedFrame
del self.toonFrame del self.toonFrame
del self.headFrame del self.headFrame
del self.bodyFrame del self.bodyFrame
@ -165,9 +146,74 @@ class ColorShop(StateData.StateData):
del self.legRButton del self.legRButton
del self.allLButton del self.allLButton
del self.allRButton del self.allRButton
del self.advancedButton
del self.basicButton
del self.pickContainer
del self.hueSlider
del self.pickButton
del self.partsFrame
del self.partLButton
del self.partRButton
self.shuffleButton.unload() self.shuffleButton.unload()
self.ignore('MAT-newToonCreated') self.ignore('MAT-newToonCreated')
def getNewFrame(self):
frame = DirectFrame(relief=DGG.RAISED, pos=(0.98, 0, 0.416), frameColor=(1, 0, 0, 0))
frame.setPos(-0.36, 0, -0.5)
frame.reparentTo(base.a2dTopRight)
return frame
def popupAdvancedMenu(self):
self.parentFrame.hide()
self.advancedFrame.show()
def popupBasicMenu(self):
self.parentFrame.show()
self.advancedFrame.hide()
def calcRelative(self, value, baseMin, baseMax, limitMin, limitMax):
return ((limitMax - limitMin) * (value - baseMin) / (baseMax - baseMin)) + limitMin
def __chooseHue(self):
for x in xrange(self.pickImage.getXSize()):
for y in xrange(self.pickImage.getYSize()):
self.pickImage.setXel(x, y, colorsys.hsv_to_rgb(self.hueSlider['value'], (x / 100.0) + ToontownGlobals.COLOR_SATURATION_MIN, (y / 100.0) + ToontownGlobals.COLOR_VALUE_MIN))
texture = Texture()
texture.load(self.pickImage)
self.pickButton['image'] = texture
def __pickColor(self, pos):
x, y = pos.getMouse()
win_w, win_h = base.win.getSize()
if win_w < win_h:
y *= 1. * win_h / win_w
else:
x *= 1. * win_w / win_h
x -= self.pickButton.getX(aspect2d)
y -= self.pickButton.getZ(aspect2d)
image_scale = self.pickButton['image_scale']
x = (.5 + x / (2. * self.pickButton.getSx(aspect2d) * image_scale[0]))
y = (.5 + y / -(2. * self.pickButton.getSz(aspect2d) * image_scale[2]))
rgb = colorsys.hsv_to_rgb(self.hueSlider['value'], self.calcRelative(x, 0.0, 1.0, 0.36, 0.7), self.calcRelative(y, 0.0, 1.0, 0.5, 0.8)) + (1,)
if self.partChoice in (0, 1):
self.dna.headColor = rgb
if self.partChoice in (0, 2):
self.dna.armColor = rgb
if self.partChoice in (0, 3):
self.dna.gloveColor = rgb
if self.partChoice in (0, 4):
self.dna.legColor = rgb
self.toon.swapToonColor(self.dna)
def __swapPart(self, offset):
self.partChoice += offset
self.partLButton['state'] = DGG.DISABLED if self.partChoice <= 0 else DGG.NORMAL
self.partRButton['state'] = DGG.DISABLED if self.partChoice >= len(self.allParts) - 1 else DGG.NORMAL
self.partsFrame['text'] = self.allParts[self.partChoice]
def __swapAllColor(self, offset): def __swapAllColor(self, offset):
colorList = self.getColorList() colorList = self.getColorList()
length = len(colorList) length = len(colorList)

View file

@ -68,7 +68,6 @@ class ShuffleButton:
del self.shuffleBtn del self.shuffleBtn
del self.incBtn del self.incBtn
del self.decBtn del self.decBtn
return
def showButtons(self): def showButtons(self):
self.shuffleFrame.show() self.shuffleFrame.show()

View file

@ -1,8 +1,9 @@
import random, colorsys, ast import random, colorsys
from panda3d.core import * from panda3d.core import *
from direct.directnotify.DirectNotifyGlobal import * from direct.directnotify.DirectNotifyGlobal import *
from direct.distributed.PyDatagram import PyDatagram from direct.distributed.PyDatagram import PyDatagram
from direct.distributed.PyDatagramIterator import PyDatagramIterator from direct.distributed.PyDatagramIterator import PyDatagramIterator
from toontown.toonbase import ToontownGlobals
notify = directNotify.newCategory('ToonDNA') notify = directNotify.newCategory('ToonDNA')
mergeMATTailor = config.GetBool('want-mat-all-tailors', 0) mergeMATTailor = config.GetBool('want-mat-all-tailors', 0)
toonSpeciesTypes = ['d', toonSpeciesTypes = ['d',
@ -2408,8 +2409,6 @@ class ToonDNA:
self.newToonFromProperties(*dna.asTuple()) self.newToonFromProperties(*dna.asTuple())
else: else:
self.type = 'u' self.type = 'u'
self.cache = ()
return
def __str__(self): def __str__(self):
string = 'type = toon\n' string = 'type = toon\n'
@ -2504,16 +2503,12 @@ class ToonDNA:
if botTexColor >= len(ClothesColors): if botTexColor >= len(ClothesColors):
return False return False
if not self.isValid(armColor): if not self.isValid(armColor):
print 'arm'
return False return False
if not self.isValid(gloveColor): if not self.isValid(gloveColor):
print 'glove'
return False return False
if not self.isValid(legColor): if not self.isValid(legColor):
print 'leg'
return False return False
if not self.isValid(headColor): if not self.isValid(headColor):
print 'head'
return False return False
return True return True
@ -2522,7 +2517,7 @@ class ToonDNA:
return True return True
hsv = colorsys.rgb_to_hsv(*color[:-1]) hsv = colorsys.rgb_to_hsv(*color[:-1])
return 0.36 <= hsv[1] <= 0.7 and 0.5 <= hsv[2] <= 0.8 return ToontownGlobals.COLOR_SATURATION_MIN <= hsv[1] <= ToontownGlobals.COLOR_SATURATION_MAX and ToontownGlobals.COLOR_VALUE_MIN <= hsv[2] <= ToontownGlobals.COLOR_VALUE_MAX
def makeFromNetString(self, string): def makeFromNetString(self, string):
dg = PyDatagram(string) dg = PyDatagram(string)

View file

@ -8723,7 +8723,10 @@ TVPacks = ['QuackityHQ']
GagPopup = '%s: %s\nGags: %s' GagPopup = '%s: %s\nGags: %s'
ColorfulToon = 'Colorful' ColorfulToon = 'Vibrant'
ColorAdvanced = 'Advanced'
ColorBasic = 'Basic'
ColorAll = 'All'
Blacklist = [ Blacklist = [
"$1ut", "$1ut",

View file

@ -1692,4 +1692,9 @@ TOONUP_FREQUENCY = 30
TV_NOT_OWNER = 0 TV_NOT_OWNER = 0
TV_INVALID_VIDEO = 1 TV_INVALID_VIDEO = 1
TV_OK = 2 TV_OK = 2
COLOR_SATURATION_MIN = 0.36
COLOR_SATURATION_MAX = 0.8
COLOR_VALUE_MIN = 0.5
COLOR_VALUE_MAX = 0.9