def __init__(self,
                 x=0,
                 y=0,
                 parent=None,
                 size=100,
                 min_value=0,
                 max_value=100,
                 value=50,
                 page_size=1,
                 callback=None,
                 extra_args=None):
        """ Inits the slider """
        RPObject.__init__(self)
        if extra_args is None:
            extra_args = []

        # Scale has to be 2.0, otherwise there will be an error.
        self._node = DirectSlider(
            pos=(size * 0.5 + x, 1, -y),
            parent=parent,
            range=(min_value, max_value),
            value=value,
            pageSize=page_size,
            scale=2.0,
            command=callback,
            extraArgs=extra_args,
            frameColor=(0.0, 0.0, 0.0, 1),
            frameSize=(-size * 0.25, size * 0.25, -5, 5),
            relief=DGG.FLAT,
            thumb_frameColor=(0.35, 0.53, 0.2, 1.0),
            thumb_relief=DGG.FLAT,
            thumb_frameSize=(-2.5, 2.5, -5.0, 5.0),
        )
Пример #2
0
    def __init__(self,
                 x,
                 y,
                 parent,
                 size=100,
                 minValue=0,
                 maxValue=100,
                 value=50,
                 pageSize=1,
                 callback=None,
                 extraArgs=None):
        if extraArgs is None:
            extraArgs = []

        # Scale has to be 2.0, otherwise there will be an error.
        self.node = DirectSlider(pos=(size * 0.5 + x, 1, -y),
                                 parent=parent,
                                 range=(minValue, maxValue),
                                 value=value,
                                 pageSize=pageSize,
                                 scale=2.0,
                                 command=callback,
                                 extraArgs=extraArgs,
                                 frameColor=(0.09, 0.09, 0.09, 0.8),
                                 frameSize=(-size * 0.25, size * 0.25, -5, 5),
                                 thumb_frameColor=(0.35, 0.53, 0.2, 1.0),
                                 thumb_frameSize=(-2.5, 2.5, -5.0, 5.0),
                                 thumb_relief=DGG.FLAT,
                                 relief=DGG.FLAT)
Пример #3
0
    def __init__(self, rootParent=None):

        self.volume = DirectSlider(
            pos=LPoint3f(0.2, 0, 0.325),
            text='Volume',
            text_pos=(-1.05, -0.02),
            text_fg=(1, 1, 1, 1),
            text_scale=0.1,
            text_align=TextNode.ARight,
            parent=rootParent,
            command=base.messenger.send,
            extraArgs=["volumeChange"],
        )
        self.volume.setTransparency(0)

        self.audioMute = DirectCheckButton(
            frameSize=(-2.925000047683716, 3.024999713897705, -0.225,
                       0.8250000238418579),
            pos=LPoint3f(0, 0, 0),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Mute',
            parent=rootParent,
            command=self.toggleMute,
        )
        self.audioMute.setTransparency(0)

        self.btnBack = DirectButton(
            frameSize=(-1.5249999523162843, 1.6499999523162843,
                       -0.21250001192092896, 0.8250000238418579),
            pos=LPoint3f(0, 0, -0.575),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Back',
            parent=rootParent,
            command=base.messenger.send,
            extraArgs=["optionBack"],
            pressEffect=1,
        )
        self.btnBack.setTransparency(0)

        self.fullscreen = DirectCheckButton(
            frameSize=(-3.35, 2.6, -0.213, 0.825),
            pos=LPoint3f(0.045, 0, -0.175),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Fullscreen',
            parent=rootParent,
            command=self.toggleFullscreen,
        )
        self.fullscreen.setTransparency(0)
Пример #4
0
 def loadExposureGUI(self):
     self.numExposure = DirectSlider(
         parent=self,
         value=self.exposure,
         pos=(self.buttonbase_xcoord + 0.1, 0.0,
              (self.buttonbase_ycoord - self.textRowHeight * 2.2)),
         thumb_relief=None,
         range=(0, 5),  # self.SAMPLES_MAX
         thumb_geom=self.circleModel.find(
             '**/tt_t_gui_mat_namePanelCircle'),
         frameTexture=self.barTexture,
         frameSize=(-0.5, 0.5, -0.08, 0.08),
         command=self.__changeExposure)
     self.numExposure.setScale(0.5)
     self.numExposure.setTransparency(True)
     self.numExposureText = OnscreenText(
         pos=(self.buttonbase_xcoord + 0.1,
              self.buttonbase_ycoord - self.textRowHeight * 1.9),
         scale=0.05,
         text="Exposure Amount = {}".format(self.blur),
         style=5,
         mayChange=True)
Пример #5
0
 def loadBlurGUI(self):
     self.numBlur = DirectSlider(
         parent=self,
         value=self.blur,
         # pos=(0.0, 0.0, 0.0), # for new window
         pos=(self.buttonbase_xcoord + 0.1, 0.0,
              (self.buttonbase_ycoord - self.textRowHeight * 0.5)),
         thumb_relief=None,
         range=(-10, 10),  # self.SAMPLES_MAX
         thumb_geom=self.circleModel.find(
             '**/tt_t_gui_mat_namePanelCircle'),
         frameTexture=self.barTexture,
         frameSize=(-0.5, 0.5, -0.08, 0.08),
         command=self.__changeBlur)
     self.numBlur.setScale(0.5)
     self.numBlur.setTransparency(True)
     self.numBlurText = OnscreenText(
         pos=(self.buttonbase_xcoord + 0.1,
              self.buttonbase_ycoord - self.textRowHeight * 0.2),
         scale=0.05,
         text="Blur Amount = {}".format(self.blur),
         style=5,
         mayChange=True)
Пример #6
0
    def __init__(self):

        #Our standard title and instructions text
        self.title = OnscreenText(text="Panda3D: Tutorial - Musicbox(sounds)",
                                  style=1,
                                  fg=(1, 1, 1, 1),
                                  pos=(0.7, -0.95),
                                  scale=.07)
        self.escapeEventText = OnscreenText(text="ESC: Quit",
                                            style=1,
                                            fg=(1, 1, 1, 1),
                                            pos=(-1.3, 0.95),
                                            align=TextNode.ALeft,
                                            scale=.05)

        #Set up the key input
        self.accept('escape', sys.exit)

        #Fix the camera position
        base.disableMouse()

        #Loading sounds is done in a similar way to loading other things
        #Loading the main music box song
        self.musicBoxSound = base.loadMusic('music/musicbox.ogg')
        self.musicBoxSound.setVolume(.5)  #Volume is a percentage from 0 to 1
        self.musicBoxSound.setLoopCount(
            0)  #0 means loop forever, 1 (default) means
        #play once. 2 or higher means play that
        #many times

        #Sound objects do not have a pause function, just play and stop. So we will
        #Use this variable to keep track of where the sound is at when it was stoped
        #to impliment pausing
        self.musicTime = 0

        #Loading the open/close effect
        #loadSFX and loadMusic are identical. They are often used for organization
        #(loadMusic is used for background music, loadSfx is used for other effects)
        self.lidSfx = base.loadSfx('music/openclose.ogg')
        #The open/close file has both effects in it. Fortunatly we can use intervals
        #to easily define parts of a sound file to play
        self.lidOpenSfx = SoundInterval(self.lidSfx, duration=2, startTime=0)
        self.lidCloseSfx = SoundInterval(self.lidSfx, startTime=5)

        #For this tutorial, it seemed appropriate to have on screen controls. The
        #following code creates them
        #This is a label for a slider
        self.sliderText = OnscreenText("Volume",
                                       style=1,
                                       fg=(1, 1, 1, 1),
                                       pos=(0, 0.8),
                                       scale=.07)
        #The slider itself. It calls self.setMusicBoxVolume when changed
        self.slider = DirectSlider(pos=Vec3(0, 0, .7),
                                   value=.50,
                                   command=self.setMusicBoxVolume)
        #A button that calls self.toggleMusicBox when pressed
        self.button = DirectButton(pos=Vec3(.7, 0, .7),
                                   text="Open Box",
                                   scale=.1,
                                   pad=(.5, .5),
                                   rolloverSound=None,
                                   clickSound=None,
                                   command=self.toggleMusicBox)

        #A variable to represent the state of the simulation. It starts closed
        self.boxOpen = False

        #Here we load and set up the music box. It was modeled in a complex way, so
        #setting it up will be complicated
        self.musicBox = loader.loadModel('models/MusicBox')
        self.musicBox.setPos(0, 60, -10)
        self.musicBox.reparentTo(render)
        #Just like the scene graph contains hierarchies of nodes, so can
        #models. You can get the NodePath for the node using the find
        #function, and then you can animate the model by moving its parts
        #To see the hierarchy of a model, use, the ls function
        #self.musicBox.ls() prints out the entire hierarchy of the model

        #Finding pieces of the model
        self.Lid = self.musicBox.find('**/lid')
        self.Panda = self.musicBox.find('**/turningthing')

        #This model was made with the hinge in the wrong place
        #this is here so we have something to turn
        self.HingeNode = self.musicBox.find('**/box').attachNewNode(
            'nHingeNode')
        self.HingeNode.setPos(.8659, 6.5, 5.4)
        #WRT - ie with respect to. Reparents the object without changing
        #its position, size, or orientation
        self.Lid.wrtReparentTo(self.HingeNode)
        self.HingeNode.setHpr(0, 90, 0)

        #This sets up an interval to play the close sound and actually close the box
        #at the same time.
        self.lidClose = Parallel(
            self.lidCloseSfx,
            LerpFunc(self.HingeNode.setP,
                     duration=2,
                     fromData=0,
                     toData=90,
                     blendType='easeInOut'))

        #Same thing for opening the box
        self.lidOpen = Parallel(
            self.lidOpenSfx,
            LerpFunc(self.HingeNode.setP,
                     duration=2,
                     fromData=90,
                     toData=0,
                     blendType='easeInOut'))

        #The interval for turning the panda
        self.PandaTurn = self.Panda.hprInterval(7, Vec3(360, 0, 0))
        #Do a quick loop and pause to set it as a looping interval so it can be
        #started with resume and loop properly
        self.PandaTurn.loop()
        self.PandaTurn.pause()
Пример #7
0

print("starting")
t = BobViz()

def changeColor(colorSlot, group):
    color = list(t.spheroColor)
    color[colorSlot] = slider[group][colorSlot]['value']
    t.spheroColor = tuple(color)
    nodes = render.findAllMatches(group)
    for node in nodes:
        node.getMaterial().setDiffuse(t.spheroColor)

slider = dict()
slider["Spheros"] = []
slider["Spheros"].append(DirectSlider(range=(0,1), value=t.spheroColor[0], scale=0.25, pos=(-1.0, 0.0, -0.85),
                         command=changeColor, extraArgs=(0,"Spheros")))
slider["Spheros"].append(DirectSlider(range=(0,1), value=t.spheroColor[1], scale=0.25, pos=(-1.0, 0.0, -0.90),
                         command=changeColor, extraArgs=(1,"Spheros")))
slider["Spheros"].append(DirectSlider(range=(0,1), value=t.spheroColor[2], scale=0.25, pos=(-1.0, 0.0, -0.95),
                         command=changeColor, extraArgs=(2,"Spheros")))



# Create a unix domain socket
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)

# Connect the socket to the port where the server is listening
server_address = './uds_socket'
print('connecting to {}'.format(server_address))
try:
    sock.connect(server_address)
Пример #8
0
 def loadStartScreen(self):
     self.startBG = OnscreenImage(image='world.jpg', pos=(0, 0, 0), scale=3)
     self.title = OnscreenText(text="Onwards,Term Project",
                               align=TextNode.ACenter,
                               fg=(1, 1, 1, 1),
                               pos=(0, 0.5),
                               scale=.08,
                               shadow=(0, 0, 0, 0.5))
     self.chooseGround = OnscreenText(text="Choose Land:",
                                      align=TextNode.ACenter,
                                      fg=(1, 1, 1, 1),
                                      pos=(-0.8, 0.25),
                                      scale=.08,
                                      shadow=(0, 0, 0, 0.5))
     self.buttonForest = DirectButton(pos=(-0.2, 0, 0.24),
                                      text="Forest",
                                      scale=.1,
                                      pad=(.2, .2),
                                      rolloverSound=None,
                                      clickSound=None,
                                      command=self.selected,
                                      extraArgs=["forest"],
                                      relief=SUNKEN)
     self.buttonDesert = DirectButton(pos=(0.4, 0, 0.24),
                                      text="Desert",
                                      scale=.1,
                                      pad=(.2, .2),
                                      rolloverSound=None,
                                      clickSound=None,
                                      command=self.selected,
                                      extraArgs=["desert"])
     self.chooseMusic = OnscreenText(text="Choose Music:",
                                     align=TextNode.ACenter,
                                     fg=(1, 1, 1, 1),
                                     pos=(-0.8, 0),
                                     scale=.08,
                                     shadow=(0, 0, 0, 0.5))
     self.buttonMusic1 = DirectButton(pos=(-0.2, 0, -0.01),
                                      text="Piano 1",
                                      scale=.1,
                                      pad=(.2, .2),
                                      rolloverSound=None,
                                      clickSound=None,
                                      command=self.selected,
                                      extraArgs=["piano1"],
                                      relief=SUNKEN)
     self.buttonMusic2 = DirectButton(pos=(0.35, 0, -0.01),
                                      text="Piano 2",
                                      scale=.1,
                                      pad=(.2, .2),
                                      rolloverSound=None,
                                      clickSound=None,
                                      command=self.selected,
                                      extraArgs=["piano2"])
     self.buttonMusic3 = DirectButton(pos=(0.8, 0, -0.01),
                                      text="None",
                                      scale=.1,
                                      pad=(.2, .2),
                                      rolloverSound=None,
                                      clickSound=None,
                                      command=self.selected,
                                      extraArgs=["stop"])
     self.volume = OnscreenText(text="Volume:",
                                align=TextNode.ACenter,
                                fg=(1, 1, 1, 1),
                                pos=(-0.8, -0.3),
                                scale=.08,
                                shadow=(0, 0, 0, 0.5))
     self.volumeSlider = DirectSlider(pos=(0.3, 0, -0.3),
                                      scale=0.7,
                                      value=.5,
                                      command=self.setMusicVolume)
     self.enterInstruction = OnscreenText(text="Press 'Enter' to Begin",
                                          align=TextNode.ACenter,
                                          fg=(1, 1, 1, 1),
                                          pos=(0, -0.5),
                                          scale=.08,
                                          shadow=(0, 0, 0, 0.5))
     self.accept("enter", self.loadModels)
Пример #9
0
    def __init__(self, tooltip, grid):
        self.tt = tooltip
        self.grid = grid
        screenWidthPx = base.getSize()[0]
        left = screenWidthPx * 0.25
        barWidth = screenWidthPx * 0.75

        color = (
            (0.25, 0.25, 0.25, 1),  # Normal
            (0.35, 0.35, 1, 1),  # Click
            (0.25, 0.25, 1, 1),  # Hover
            (0.1, 0.1, 0.1, 1))  # Disabled

        #
        # Toolbar
        #
        self.toolBar = DirectBoxSizer(frameColor=(0.25, 0.25, 0.25, 1),
                                      frameSize=(0, barWidth, -24, 24),
                                      autoUpdateFrameSize=False,
                                      pos=(0, 0, 0),
                                      parent=base.pixel2d)

        buttonColor = (
            (0.8, 0.8, 0.8, 1),  # Normal
            (0.9, 0.9, 1, 1),  # Click
            (0.8, 0.8, 1, 1),  # Hover
            (0.5, 0.5, 0.5, 1))  # Disabled
        btn = DirectButton(frameSize=(-24, 24, -24, 24),
                           frameColor=buttonColor,
                           relief=DGG.FLAT,
                           command=base.messenger.send,
                           extraArgs=["newProject"],
                           image="icons/New.png",
                           image_scale=24)
        btn.setTransparency(TransparencyAttrib.M_multisample)
        btn.bind(DGG.ENTER, self.tt.show, ["Create New GUI (Ctrl-N)"])
        btn.bind(DGG.EXIT, self.tt.hide)
        self.toolBar.addItem(btn)

        btn = DirectButton(frameSize=(-24, 24, -24, 24),
                           frameColor=buttonColor,
                           relief=DGG.FLAT,
                           command=base.messenger.send,
                           extraArgs=["saveProject"],
                           image="icons/Save.png",
                           image_scale=24)
        btn.setTransparency(TransparencyAttrib.M_multisample)
        btn.bind(DGG.ENTER, self.tt.show, ["Save GUI as gui Project (Ctrl-S)"])
        btn.bind(DGG.EXIT, self.tt.hide)
        self.toolBar.addItem(btn)

        btn = DirectButton(frameSize=(-24, 24, -24, 24),
                           frameColor=buttonColor,
                           text_scale=0.33,
                           relief=DGG.FLAT,
                           command=base.messenger.send,
                           extraArgs=["exportProject"],
                           image="icons/Export.png",
                           image_scale=24)
        btn.setTransparency(TransparencyAttrib.M_multisample)
        btn.bind(DGG.ENTER, self.tt.show,
                 ["Export GUI as python script (Ctrl-E)"])
        btn.bind(DGG.EXIT, self.tt.hide)
        self.toolBar.addItem(btn)

        btn = DirectButton(frameSize=(-24, 24, -24, 24),
                           frameColor=buttonColor,
                           relief=DGG.FLAT,
                           text_scale=0.33,
                           command=base.messenger.send,
                           extraArgs=["loadProject"],
                           image="icons/Load.png",
                           image_scale=24)
        btn.setTransparency(TransparencyAttrib.M_multisample)
        btn.bind(DGG.ENTER, self.tt.show, ["Load GUI project (Ctrl-O)"])
        btn.bind(DGG.EXIT, self.tt.hide)
        self.toolBar.addItem(btn)

        placeholder = DirectFrame(text="|",
                                  frameSize=(-1, 1, -24, 24),
                                  pad=(4, 0),
                                  frameColor=(0, 0, 0, 1))
        self.toolBar.addItem(placeholder)

        btn = DirectButton(frameSize=(-24, 24, -24, 24),
                           frameColor=buttonColor,
                           relief=DGG.FLAT,
                           text_scale=0.33,
                           command=base.messenger.send,
                           extraArgs=["undo"],
                           image="icons/Undo.png",
                           image_scale=24)
        btn.setTransparency(TransparencyAttrib.M_multisample)
        btn.bind(DGG.ENTER, self.tt.show, ["Undo last action (Ctrl-Z)"])
        btn.bind(DGG.EXIT, self.tt.hide)
        self.toolBar.addItem(btn)

        btn = DirectButton(frameSize=(-24, 24, -24, 24),
                           frameColor=buttonColor,
                           relief=DGG.FLAT,
                           text_scale=0.33,
                           command=base.messenger.send,
                           extraArgs=["redo"],
                           image="icons/Redo.png",
                           image_scale=24)
        btn.setTransparency(TransparencyAttrib.M_multisample)
        btn.bind(DGG.ENTER, self.tt.show, ["Redo last action (Ctrl-Y)"])
        btn.bind(DGG.EXIT, self.tt.hide)
        self.toolBar.addItem(btn)

        btn = DirectButton(frameSize=(-24, 24, -24, 24),
                           frameColor=buttonColor,
                           relief=DGG.FLAT,
                           text_scale=0.33,
                           command=base.messenger.send,
                           extraArgs=["cycleRedo"],
                           image="icons/CycleRedo.png",
                           image_scale=24)
        btn.setTransparency(TransparencyAttrib.M_multisample)
        btn.bind(DGG.ENTER, self.tt.show,
                 ["Cycle through redo branches (Ctrl-Shift-Y)"])
        btn.bind(DGG.EXIT, self.tt.hide)
        self.toolBar.addItem(btn)

        placeholder = DirectFrame(text="|",
                                  frameSize=(-1, 1, -24, 24),
                                  pad=(4, 0),
                                  frameColor=(0, 0, 0, 1))
        self.toolBar.addItem(placeholder)

        btn = DirectButton(frameSize=(-24, 24, -24, 24),
                           frameColor=buttonColor,
                           relief=DGG.FLAT,
                           text_scale=0.33,
                           command=base.messenger.send,
                           extraArgs=["removeElement"],
                           image="icons/Delete.png",
                           image_scale=24)
        btn.setTransparency(TransparencyAttrib.M_multisample)
        btn.bind(DGG.ENTER, self.tt.show, ["Delete selected element (Del)"])
        btn.bind(DGG.EXIT, self.tt.hide)
        self.toolBar.addItem(btn)

        placeholder = DirectFrame(text="|",
                                  frameSize=(-1, 1, -24, 24),
                                  pad=(4, 0),
                                  frameColor=(0, 0, 0, 1))
        self.toolBar.addItem(placeholder)

        self.cb_grid = DirectCheckBox(
            frameSize=(-24, 24, -24, 24),
            frameColor=buttonColor,
            relief=DGG.FLAT,
            text_scale=12,
            image="icons/GridOff.png"
            if self.grid.isHidden() else "icons/GridOn.png",
            uncheckedImage="icons/GridOff.png",
            checkedImage="icons/GridOn.png",
            image_scale=24,
            isChecked=not self.grid.isHidden(),
            command=self.toggleGrid)
        self.cb_grid.setTransparency(TransparencyAttrib.M_multisample)
        self.cb_grid.bind(DGG.ENTER, self.tt.show, ["Toggle Grid (Ctrl-G)"])
        self.cb_grid.bind(DGG.EXIT, self.tt.hide)
        self.toolBar.addItem(self.cb_grid)

        self.cb_scale = DirectCheckBox(frameSize=(-24, 24, -24, 24),
                                       frameColor=buttonColor,
                                       relief=DGG.FLAT,
                                       text_scale=12,
                                       image="icons/Scale1.png",
                                       uncheckedImage="icons/Scale2.png",
                                       checkedImage="icons/Scale1.png",
                                       image_scale=24,
                                       isChecked=True,
                                       command=self.toggleVisualEditorParent)
        self.cb_scale.setTransparency(TransparencyAttrib.M_alpha)
        self.cb_scale.bind(DGG.ENTER, self.tt.show,
                           ["Toggle editor scale (Aspect/Pixel)"])
        self.cb_scale.bind(DGG.EXIT, self.tt.hide)
        self.toolBar.addItem(self.cb_scale)

        placeholder = DirectFrame(text="|",
                                  frameSize=(-1, 1, -24, 24),
                                  pad=(4, 0),
                                  frameColor=(0, 0, 0, 1))
        self.toolBar.addItem(placeholder)

        zoomHolder = DirectFrame(
            frameSize=(-48, 48, -24, 24),
            #pad=(4, 0),
            frameColor=(0, 0, 0, 0))
        self.toolBar.addItem(zoomHolder)
        self.zoomSlider = DirectSlider(zoomHolder,
                                       scale=(48, 1, 96),
                                       pos=(0, 0, 0),
                                       range=(0.1, 1.5),
                                       command=self.zoomSliderChanged)
        self.zoomSlider.bind(DGG.ENTER, self.tt.show, ["Zoom"])
        self.zoomSlider.bind(DGG.EXIT, self.tt.hide)
        #self.toolBar.addItem(self.zoomSlider)

        placeholder = DirectFrame(text="|",
                                  frameSize=(-1, 1, -24, 24),
                                  pad=(4, 0),
                                  frameColor=(0, 0, 0, 1))
        self.toolBar.addItem(placeholder)

        btn = DirectButton(frameSize=(-24, 24, -24, 24),
                           frameColor=buttonColor,
                           relief=DGG.FLAT,
                           text_scale=0.33,
                           command=base.messenger.send,
                           extraArgs=["quitApp"],
                           image="icons/Quit.png",
                           image_scale=24)
        btn.setTransparency(TransparencyAttrib.M_alpha)
        btn.bind(DGG.ENTER, self.tt.show,
                 ["Quit Direct GUI Designer (Ctrl-Q)"])
        btn.bind(DGG.EXIT, self.tt.hide)
        self.toolBar.addItem(btn)

        placeholder = DirectFrame(text="|",
                                  frameSize=(-1, 1, -24, 24),
                                  pad=(4, 0),
                                  frameColor=(0, 0, 0, 1))
        self.toolBar.addItem(placeholder)

        btn = DirectButton(frameSize=(-24, 24, -24, 24),
                           frameColor=buttonColor,
                           relief=DGG.FLAT,
                           text_scale=0.33,
                           command=base.messenger.send,
                           extraArgs=["showHelp"],
                           image="icons/Help.png",
                           image_scale=24)
        btn.setTransparency(TransparencyAttrib.M_multisample)
        btn.bind(DGG.ENTER, self.tt.show, ["Show a help Dialog (F1)"])
        btn.bind(DGG.EXIT, self.tt.hide)
        self.toolBar.addItem(btn)

        btn = DirectButton(frameSize=(-24, 24, -24, 24),
                           frameColor=buttonColor,
                           relief=DGG.FLAT,
                           text_scale=0.33,
                           command=base.messenger.send,
                           extraArgs=["showSettings"],
                           image="icons/Settings.png",
                           image_scale=24)
        btn.setTransparency(TransparencyAttrib.M_multisample)
        btn.bind(DGG.ENTER, self.tt.show, ["Show Designer Settings"])
        btn.bind(DGG.EXIT, self.tt.hide)
        self.toolBar.addItem(btn)

        if not ConfigVariableBool("show-toolbar", True).getValue():
            self.toolBar.hide()

        self.accept("setVisualEditorParent", self.setVisualEditorParent)
        self.accept("toggleGrid", self.setGrid)
Пример #10
0
    def loadAmbientOcclusionGUI(self):
        self.numSamples = DirectSlider(
            parent=self,
            value=self.samples,
            pos=(self.buttonbase_xcoord + 0.1, 0.0,
                 self.buttonbase_ycoord - self.textRowHeight * 3.5),
            thumb_relief=None,
            range=(0, 32),  # self.SAMPLES_MAX
            thumb_geom=self.circleModel.find(
                '**/tt_t_gui_mat_namePanelCircle'),
            frameTexture=self.barTexture,
            frameSize=(-0.5, 0.5, -0.08, 0.08),
            command=self.__changeAOValue)
        # command=self.__changeAOValue(self.samples, self.radius, self.amount, self.strength))
        self.numSamples.setScale(0.5)
        self.numSamples.setTransparency(True)
        self.numSamplesText = OnscreenText(
            pos=(self.buttonbase_xcoord + 0.1,
                 self.buttonbase_ycoord - self.textRowHeight * 3.2),
            scale=0.05,
            text="AO Sample Count = {}".format(self.samples),
            style=5,
            mayChange=True)

        self.numRadius = DirectSlider(
            parent=self,
            value=self.radius,
            pos=(self.buttonbase_xcoord + 0.1, 0.0,
                 (self.buttonbase_ycoord - self.textRowHeight * 4.5)),
            thumb_relief=None,
            range=(0, 1),  # self.SAMPLES_MAX
            thumb_geom=self.circleModel.find(
                '**/tt_t_gui_mat_namePanelCircle'),
            frameTexture=self.barTexture,
            frameSize=(-0.5, 0.5, -0.08, 0.08),
            command=self.__changeAOValue)

        self.numRadius.setScale(0.5)
        self.numRadius.setTransparency(True)
        self.numRadiusText = OnscreenText(
            pos=(self.buttonbase_xcoord + 0.1,
                 self.buttonbase_ycoord - self.textRowHeight * 4.2),
            scale=0.05,
            text="AO Radius = {}".format(str(self.radius)),
            style=5,
            mayChange=True)

        self.numAmount = DirectSlider(
            parent=self,
            value=self.amount,
            pos=(self.buttonbase_xcoord + 0.1, 0.0,
                 (self.buttonbase_ycoord - self.textRowHeight * 5.5)),
            thumb_relief=None,
            range=(0, 64),  # self.SAMPLES_MAX
            thumb_geom=self.circleModel.find(
                '**/tt_t_gui_mat_namePanelCircle'),
            frameTexture=self.barTexture,
            frameSize=(-0.5, 0.5, -0.08, 0.08),
            command=self.__changeAOValue)

        self.numAmount.setScale(0.5)
        self.numAmount.setTransparency(True)
        self.numAmountText = OnscreenText(
            pos=(self.buttonbase_xcoord + 0.1,
                 self.buttonbase_ycoord - self.textRowHeight * 5.2),
            scale=0.05,
            text="AO Amount = {}".format(self.amount),
            style=5,
            mayChange=True)

        self.numStrength = DirectSlider(
            parent=self,
            value=self.strength,
            pos=(self.buttonbase_xcoord + 0.1, 0.0,
                 (self.buttonbase_ycoord - self.textRowHeight * 6.5)),
            thumb_relief=None,
            range=(0, 0.1),  # self.SAMPLES_MAX
            thumb_geom=self.circleModel.find(
                '**/tt_t_gui_mat_namePanelCircle'),
            frameTexture=self.barTexture,
            frameSize=(-0.5, 0.5, -0.08, 0.08),
            command=self.__changeAOValue)

        self.numStrength.setScale(0.5)
        self.numStrength.setTransparency(True)
        self.numStrengthText = OnscreenText(
            pos=(self.buttonbase_xcoord + 0.1,
                 self.buttonbase_ycoord - self.textRowHeight * 6.2),
            scale=0.05,
            text="AO Strength = {}".format(self.strength),
            style=5,
            mayChange=True)
Пример #11
0
    def loadCartoonInkGUI(self):
        self.cSep = DirectSlider(
            parent=self,
            value=self.cartoonSep,
            pos=(-self.buttonbase_xcoord + 0.1, 0.0,
                 self.buttonbase_ycoord - self.textRowHeight * 2.5),
            thumb_relief=None,
            range=(0, 32),  # self.SAMPLES_MAX
            thumb_geom=self.circleModel.find(
                '**/tt_t_gui_mat_namePanelCircle'),
            frameTexture=self.barTexture,
            frameSize=(-0.5, 0.5, -0.08, 0.08),
            command=self.__changeCartoon)
        # command=self.__changeAOValue(self.samples, self.radius, self.amount, self.strength))
        self.cSep.setScale(0.5)
        self.cSep.setTransparency(True)

        self.cRed = DirectSlider(
            parent=self,
            value=self.cartoonR,
            pos=(-self.buttonbase_xcoord + 0.1, 0.0,
                 self.buttonbase_ycoord - self.textRowHeight * 3.5),
            thumb_relief=None,
            range=(0, 1),  # self.SAMPLES_MAX
            thumb_geom=self.circleModel.find(
                '**/tt_t_gui_mat_namePanelCircle'),
            frameTexture=self.barTexture,
            frameSize=(-0.5, 0.5, -0.08, 0.08),
            command=self.__changeCartoon)
        # command=self.__changeAOValue(self.samples, self.radius, self.amount, self.strength))
        self.cRed.setScale(0.5)
        self.cRed.setTransparency(True)

        self.cBlue = DirectSlider(
            parent=self,
            value=self.cartoonB,
            pos=(-self.buttonbase_xcoord + 0.1, 0.0,
                 self.buttonbase_ycoord - self.textRowHeight * 4.5),
            thumb_relief=None,
            range=(0, 1),  # self.SAMPLES_MAX
            thumb_geom=self.circleModel.find(
                '**/tt_t_gui_mat_namePanelCircle'),
            frameTexture=self.barTexture,
            frameSize=(-0.5, 0.5, -0.08, 0.08),
            command=self.__changeCartoon)
        # command=self.__changeAOValue(self.samples, self.radius, self.amount, self.strength))
        self.cBlue.setScale(0.5)
        self.cBlue.setTransparency(True)

        self.cGreen = DirectSlider(
            parent=self,
            value=self.cartoonG,
            pos=(-self.buttonbase_xcoord + 0.1, 0.0,
                 self.buttonbase_ycoord - self.textRowHeight * 5.5),
            thumb_relief=None,
            range=(0, 1),  # self.SAMPLES_MAX
            thumb_geom=self.circleModel.find(
                '**/tt_t_gui_mat_namePanelCircle'),
            frameTexture=self.barTexture,
            frameSize=(-0.5, 0.5, -0.08, 0.08),
            command=self.__changeCartoon)
        # command=self.__changeAOValue(self.samples, self.radius, self.amount, self.strength))
        self.cGreen.setScale(0.5)
        self.cGreen.setTransparency(True)
 def slider(self, pos, scale, value, command):
     return DirectSlider(pos=pos, scale=scale, value=value,
                                 command=command)
Пример #13
0
    def bld_page(self):
        menu_args = self.menu_args
        self.pagewidgets = []

        def add_lab(txt, txt_tr, pos_z):
            lab = DirectLabel(text='',
                              pos=(-.1, 1, pos_z),
                              text_align=TextNode.ARight,
                              **menu_args.label_args)
            PageGui.transl_text(lab, txt, txt_tr)
            self.pagewidgets += [lab]
            return lab

        add_lab('Language', _('Language'), .7)
        self._lang_opt = DirectOptionMenu(text='',
                                          items=eng.languages,
                                          pos=(.49, 1, .7),
                                          initialitem=self.props.lang,
                                          command=self.__change_lang,
                                          **menu_args.option_args)
        add_lab('Volume', _('Volume'), .5)
        self._vol_slider = DirectSlider(pos=(.52, 0, .53),
                                        scale=.49,
                                        value=self.props.volume,
                                        frameColor=menu_args.btn_color,
                                        thumb_frameColor=menu_args.text_fg,
                                        command=self.__on_volume)
        add_lab('Fullscreen', _('Fullscreen'), .3)
        self._fullscreen_cb = DirectCheckButton(
            pos=(.12, 1, .32),
            text='',
            indicatorValue=self.props.fullscreen,
            indicator_frameColor=menu_args.text_fg,
            command=lambda val: eng.toggle_fullscreen(),
            **menu_args.checkbtn_args)
        add_lab('Resolution', _('Resolution'), .1)
        res2vec = lambda res: LVector2i(*[int(val) for val in res.split('x')])
        self._res_opt = DirectOptionMenu(
            text='',
            items=[
                'x'.join([str(el_res) for el_res in res])
                for res in eng.resolutions
            ],
            pos=(.49, 1, .1),
            initialitem='x'.join(str(res) for res in eng.closest_res),
            command=lambda res: eng.set_resolution(res2vec(res)),
            **menu_args.option_args)
        add_lab('Antialiasing', _('Antialiasing'), -.1)
        aa_next_lab = DirectLabel(text='',
                                  pos=(.2, 1, -.1),
                                  text_align=TextNode.ALeft,
                                  **menu_args.label_args)
        PageGui.transl_text(aa_next_lab, '(from the next execution)',
                            _('(from the next execution)'))
        self._aa_cb = DirectCheckButton(pos=(.12, 1, -.07),
                                        text='',
                                        indicatorValue=self.props.aa,
                                        indicator_frameColor=menu_args.text_fg,
                                        **menu_args.checkbtn_args)
        add_lab('Shaders', _('Shaders'), -.3)
        self._shaders_cb = DirectCheckButton(
            pos=(.12, 1, -.27),
            text='',
            indicatorValue=self.props.shaders,
            indicator_frameColor=menu_args.text_fg,
            **menu_args.checkbtn_args)
        # bld_in = lambda: self.menu.logic.push_page(
        #     InputPage(self.menu, self.props.joystick, self.props.keys))
        # it doesn't work if we go forward and back between options and input:
        # we should update keys
        input_btn = DirectButton(text='',
                                 pos=(0, 1, -.5),
                                 command=self.on_input_btn,
                                 **menu_args.btn_args)
        PageGui.transl_text(input_btn, 'Configure input', _('Configure input'))

        self.pagewidgets += [
            self._lang_opt, self._vol_slider, self._fullscreen_cb,
            self._res_opt, self._aa_cb, aa_next_lab, input_btn,
            self._shaders_cb
        ]
        map(self.add_widget, self.pagewidgets)
        idx = LangMgr().lang_codes.index(self.props.lang)
        self.__change_lang(eng.languages[idx])
        ThanksPageGui.bld_page(self)