Example #1
0
 def openDialog(self, name):
     self.dialogGui = DialogGui(name)
Example #2
0
	def openDialog(self, name):
		self.dialogGui = DialogGui(name)
Example #3
0
class GameGui:
    def __init__(self, mapManager):
        self.mapManager = mapManager
        self.playerState = self.mapManager.playerState

        self.infoLabel = makeMsg(-0.95 * RATIO, 0.95, "")
        self.objectLabel = makeMsg(-0.95 * RATIO, -0.85, "")
        self.inventory = InventoryGui(self.mapManager)
        i = 0

        #for slot in self.inventory.slots:
        #	slot.bind(DGG.B1PRESS, self.onSelectItem, [i])
        #	i += 1

        #self.pickedItem = InventorySlot(0,0,"pickedItem",0.1)
        #self.pickedItem.hide()
        #self.pickedItem.setBin("gui-popup", 50)

        self.objectMenu = ActionMenu(0, 0)
        self.objectMenu.rebuild(["look", "talk", "attack"])

        self.dialogGui = None

        self.size = 0.09
        self.invButton = DirectButton(
            frameSize=(-self.size, self.size, -self.size, self.size),
            pos=(0.92 * RATIO, 1, -0.9),
            pad=(0, 0),
            borderWidth=(0.008, 0.008),
            frameColor=(0.0, 0.0, 0.0, 0.0),
            relief=DGG.GROOVE,
            rolloverSound=None,
            clickSound=None,
            sortOrder=-100,
            #image = "img/items/backpack6.png",
            #image_scale=0.08,
        )
        self.bagImg = makeImg(0.95 * RATIO, -0.92, "img/items/bag.png", 0.08)
        self.invButton.bind(DGG.B1PRESS, self.inventory.toggle)

        #self.hpBar = Barre(0.12,0.01,-0.95,-0.85,30, color1 = (0.1, 0.4, 0.25, 1.0), color2 = (0.30, 0.85, 0.45, 0.9), text = "HP")
        #self.spBar = Barre(0.12,0.01,-0.95,-0.90,30, color1 = (0.1, 0.25, 0.4, 1.0), color2 = (0.30, 0.45, 0.85, 0.9), text = "SP")
        #self.spBar.setHp(20)

    def openDialog(self, name):
        self.dialogGui = DialogGui(name)

    def closeDialog(self):
        self.dialogGui.destroy()
        self.dialogGui = None

    def startFollowMouse(self, extraArgs=[]):
        #self.pickedItem["sortOrder"] = 101
        #self.pickedItem.show()
        print "starting follow, slot %s has sortOrder %s" % (
            self.pickedItem.name, self.pickedItem["sortOrder"])
        self.task = taskMgr.add(self.followTask, "follow")

    def followTask(self, task):
        if base.mouseWatcherNode.hasMouse():
            mpos = base.mouseWatcherNode.getMouse()
            #self.pickedItem.setPos(mpos.getX()*RATIO, 1, mpos.getY())

            m = self.inventory.getMouseSlot()
            if m is not None:
                x, y = m
                #msg = "Mouse slot : " + str(round(x, 2)) + ", " + str(round(y, 2))
                msg = "Mouse slot : " + str(x) + ", " + str(y)
                self.setInfo(msg)
            else:
                self.setInfo("")

        return task.cont

    def stopFollowMouse(self, extraArgs=[]):

        taskMgr.remove(self.task)
        #self.pickedItem["sortOrder"] = 100
        #self.pickedItem.setBin("fixed", 100)
        #self.pickedItem.hide()
        print "stopped follow, slot %s has sortOrder %s" % (
            self.pickedItem.name, self.pickedItem["sortOrder"])

    def hide(self):
        self.infoLabel.hide()
        self.objectLabel.hide()
        self.inventory.hide()
        self.objectMenu.hide()
        self.invButton.hide()
        self.bagImg.hide()

        #self.hpBar.hide()
        #self.spBar.hide()

        self.visible = False

    def show(self):
        self.infoLabel.show()
        self.objectLabel.show()
        self.invButton.show()
        self.bagImg.show()
        #self.inventory.show()
        #self.objectMenu.show()

        #self.hpBar.show()
        #self.spBar.show()
        self.visible = True

    def setInfo(self, info):
        self.infoLabel.setText(str(info))

    def clearInfo(self):
        self.infoLabel.setText("")

    def setObjInfo(self, mpos, info):
        self.objectLabel.setPos(mpos.getX() * RATIO + 0.1, mpos.getY() + 0.02)
        self.objectLabel.setText(str(info))

    def clearObjInfo(self):
        self.objectLabel.setText("")

    def closeMenu(self):
        self.objectMenu.retract()
Example #4
0
class GameGui:
	def __init__(self, mapManager):
		self.mapManager = mapManager
		self.playerState = self.mapManager.playerState
		
		self.infoLabel = makeMsg(-0.95*RATIO,0.95,"")
		self.objectLabel = makeMsg(-0.95*RATIO,-0.85,"")
		self.inventory = InventoryGui(self.mapManager)
		i = 0
		
		#for slot in self.inventory.slots:
		#	slot.bind(DGG.B1PRESS, self.onSelectItem, [i])
		#	i += 1
			
		#self.pickedItem = InventorySlot(0,0,"pickedItem",0.1)
		#self.pickedItem.hide()
		#self.pickedItem.setBin("gui-popup", 50)
		
		self.objectMenu = ActionMenu(0,0)
		self.objectMenu.rebuild(["look", "talk", "attack"])
		
		self.dialogGui = None
		
		self.size = 0.09
		self.invButton = DirectButton(
			frameSize = (-self.size,self.size,-self.size,self.size),
			pos = (0.92*RATIO, 1, -0.9),
			pad = (0,0),
			borderWidth=(0.008,0.008),
			frameColor=(0.0,0.0,0.0,0.0),
			relief = DGG.GROOVE,
			rolloverSound = None,
			clickSound = None,
			sortOrder=-100,
			#image = "img/items/backpack6.png",
			#image_scale=0.08,
		)
		self.bagImg = makeImg(0.95*RATIO, -0.92, "img/items/bag.png", 0.08)
		self.invButton.bind(DGG.B1PRESS, self.inventory.toggle)
		
		#self.hpBar = Barre(0.12,0.01,-0.95,-0.85,30, color1 = (0.1, 0.4, 0.25, 1.0), color2 = (0.30, 0.85, 0.45, 0.9), text = "HP")
		#self.spBar = Barre(0.12,0.01,-0.95,-0.90,30, color1 = (0.1, 0.25, 0.4, 1.0), color2 = (0.30, 0.45, 0.85, 0.9), text = "SP")
		#self.spBar.setHp(20)
		
	def openDialog(self, name):
		self.dialogGui = DialogGui(name)
		
	def closeDialog(self):
		self.dialogGui.destroy()
		self.dialogGui = None
		
		
	def startFollowMouse(self, extraArgs=[]):
		#self.pickedItem["sortOrder"] = 101
		#self.pickedItem.show()
		print "starting follow, slot %s has sortOrder %s" % (self.pickedItem.name, self.pickedItem["sortOrder"])
		self.task = taskMgr.add(self.followTask, "follow")
		
	def followTask(self, task):
		if base.mouseWatcherNode.hasMouse():
			mpos = base.mouseWatcherNode.getMouse()
			#self.pickedItem.setPos(mpos.getX()*RATIO, 1, mpos.getY())
			
			m = self.inventory.getMouseSlot()
			if m is not None:
				x, y = m
				#msg = "Mouse slot : " + str(round(x, 2)) + ", " + str(round(y, 2))
				msg = "Mouse slot : " + str(x) + ", " + str(y)
				self.setInfo(msg)
			else:
				self.setInfo("")
				
		return task.cont
		
	def stopFollowMouse(self, extraArgs=[]):
		
		taskMgr.remove(self.task)
		#self.pickedItem["sortOrder"] = 100
		#self.pickedItem.setBin("fixed", 100)
		#self.pickedItem.hide()
		print "stopped follow, slot %s has sortOrder %s" % (self.pickedItem.name, self.pickedItem["sortOrder"])
		
	def hide(self):
		self.infoLabel.hide()
		self.objectLabel.hide()
		self.inventory.hide()
		self.objectMenu.hide()
		self.invButton.hide()
		self.bagImg.hide()
		
		#self.hpBar.hide()
		#self.spBar.hide()
		
		self.visible = False
		
	def show(self):
		self.infoLabel.show()
		self.objectLabel.show()
		self.invButton.show()
		self.bagImg.show()
		#self.inventory.show()
		#self.objectMenu.show()
		
		#self.hpBar.show()
		#self.spBar.show()
		self.visible = True
		
	def setInfo(self, info):
		self.infoLabel.setText(str(info))
		
	def clearInfo(self):
		self.infoLabel.setText("")
		
	def setObjInfo(self, mpos, info):
		self.objectLabel.setPos(mpos.getX()*RATIO+0.1, mpos.getY()+0.02)
		self.objectLabel.setText(str(info))
		
	def clearObjInfo(self):
		self.objectLabel.setText("")
	
	def closeMenu(self):
		self.objectMenu.retract()