Esempio n. 1
0
	def SetUpOperationInfoScreen(self, clearSelected=True):
		self.ScreenState = Main.eScreen.EditOp
		op = self.CurretLevelData.OpList[self.OperationSetUpIndex]

		settingToEdit = []
		for index in range(len(op.Setting)):
			setting = op.Setting[index]

			if not setting.IsTempValue:
				settingToEdit += [index]

		if len(settingToEdit) == 0:
			self.SetUpMainScreen()

		else:
			self.SetUpShared(False, clearSelected)

			#backGround
			piece = Piece.UiPiece([10, 370], [360, 220],
							"Popup_BackGround")
			self.Manger.AddPiece(piece, False)


			#row two
			piece = self.MakeGridPiece(0, 1, image="Button")
			piece.SetUpLabel("", op.GetSetting(settingToEdit[0]), xLabelAnchor=0.5, yLabelAnchor=0.5, textUpdatedFunc=self.UpdateSetting1)
			piece.SetupAudio("ButtonDown", "ButtonUp")
			self.Manger.AddPiece(piece, True)

			piece = self.MakeGridPiece(1, 1, image=op.BaseImage)
			piece.SetUpLabel(str(op), None, xLabelAnchor=0.5, yLabelAnchor=0.5, getMessage=op.__str__)
			self.Manger.AddPiece(piece, False)
			
			if len(settingToEdit) == 2:
				piece = self.MakeGridPiece(2, 1, image="Button")
				piece.SetUpLabel("", op.GetSetting(settingToEdit[1]), xLabelAnchor=0.5, yLabelAnchor=0.5, textUpdatedFunc=self.UpdateSetting2)
				piece.SetupAudio("ButtonDown", "ButtonUp")
				self.Manger.AddPiece(piece, True)


			#finsh button
			piece = self.MakeGridPiece(2, 0, image="Button", hoverImage="Button_Hover")
			piece.SetUpButtonClick("Button_Pressed",
					onClick=self.ClickDoneOpSetup,
					enterCanClick=True)
			piece.SetUpLabel("Done", None, xLabelAnchor=0.5, yLabelAnchor=0.5)
			piece.SetupAudio("ButtonDown", "ButtonUp")
			self.Manger.AddPiece(piece, True)

			#Back Button
			piece = self.MakeGridPiece(0, 0, image="Button_Red", hoverImage="Button_Red_Hover")
			piece.SetUpButtonClick("Button_Red_Pressed",
				onClick=self.SetUpOperationSelectScreen,
				onClickData=self.OperationSetUpIndex)
			piece.SetUpLabel("Back", None, xLabelAnchor=0.5, yLabelAnchor=0.5)
			piece.SetupAudio("ButtonDown", "ButtonUp")
			self.Manger.AddPiece(piece, False)
		return
	def __init__(self, uiManger, maxCharacters, pos, size, setFromPortal, setToPortal, getIsFade):
		gap = 10
		subNumberSize = [int((size[0]-(gap*(maxCharacters-1)))/maxCharacters), size[1]]
		subPortalSize = [30, 15]
		xpos = pos[0]
		xPortalPos = pos[0]
		xPortalPos += int((subNumberSize[0] - subPortalSize[0]) / 2)

		self.CharacterList = []
		for loop in range(maxCharacters):
			character = Character()

			index = maxCharacters-(loop+1)


			subNumberPos = [xpos, pos[1]]
			#number
			piece = UiPiece.UiPiece(subNumberPos, subNumberSize, normalImage="Number_Empty")
			piece.SetUpFade(getIsFade=getIsFade)
			uiManger.AddPiece(piece, False)
			character.Number = piece

			if loop > 0:
				subPortalPos = [xPortalPos, pos[1]-(subPortalSize[1]+5)]
				#to portal
				piece = UiPiece.UiPiece(subPortalPos, subPortalSize, normalImage="Portal_False")
				piece.SetUpButtonClick(onClick=setToPortal, onClickData=index)
				piece.SetUpFade(getIsFade=getIsFade)
				uiManger.AddPiece(piece, False)
				character.ToPortal = piece

			if loop < maxCharacters-1:
				subPortalPos = [xPortalPos, pos[1]+size[1]+5]
				#from portal
				piece = UiPiece.UiPiece(subPortalPos, subPortalSize, normalImage="Portal_False")
				piece.SetUpButtonClick(onClick=setFromPortal, onClickData=index)
				piece.SetUpFade(getIsFade=getIsFade)
				uiManger.AddPiece(piece, False)
				character.FromPortal = piece

			self.CharacterList += [character]
			xpos += subNumberSize[0] + gap
			xPortalPos += subNumberSize[0] + gap
		return
Esempio n. 3
0
	def MakeGridPiece(self, xIndex, yIndex, image=None, hoverImage=None, yStart=375):
		xStart = 20
		
		boxWidth = 110
		boxHight = 100
		xSpacing = 5
		ySpacing = 10

		x = (boxWidth+xSpacing) * xIndex + xStart
		y = (boxHight+ySpacing) * yIndex + yStart

		return Piece.UiPiece([x, y], [boxWidth, boxHight], normalImage=image, hoverImage=hoverImage)
Esempio n. 4
0
	def SetUpOperationSelectScreen(self, opIndex):
		self.ScreenState = Main.eScreen.PickOp

		if self.DebugMode:
			print("Setup Operation Screen index: " + str(opIndex))
		self.OperationSetUpIndex = opIndex
		
		self.SetUpShared(False)

		#button Grid
		yStart = 45
		yNumber = 6

		piece = Piece.UiPiece([10, yStart-10], [360, yNumber*110+10],
			"Popup_BackGround")
		self.Manger.AddPiece(piece, False)

		loop = 1
		for y in range(yNumber):
			for x in range(3):
				
				op = Operations.MakeOperation(loop)
				
				if op != None:
					piece = self.MakeGridPiece(x, y, image=op.BaseImage, yStart=yStart)
					piece.SetUpButtonClick(onClick=self.SetOperation, onClickData=loop)
					piece.SetUpLabel(str(op), None, xLabelAnchor=0.5, yLabelAnchor=0.5)
					piece.SetupAudio("ButtonDown", "ButtonUp")
					self.Manger.AddPiece(piece, False)
				else:
					piece = self.MakeGridPiece(x, y, image="Button_Red", hoverImage="Button_Red_Hover", yStart=yStart)
					piece.SetUpButtonClick("Button_Red_Pressed", onClick=self.SetOperation, onClickData=loop)
					piece.SetUpLabel("Back", None, xLabelAnchor=0.5, yLabelAnchor=0.5)
					piece.SetupAudio("ButtonDown", "ButtonUp")
					self.Manger.AddPiece(piece, False)
					return


				loop += 1
		return
Esempio n. 5
0
	def SetUpMainScreen(self):
		self.ScreenState = Main.eScreen.Main

		if self.DebugMode:
			print("Setup Main Screen")
		self.SetUpShared()
		#button Grid
		#row 1
		piece = self.MakeGridPiece(0, 0, image="Button", hoverImage="Button_Hover")
		piece.SetUpButtonClick("Button_Pressed", onClick=self.ClickedSolve, enterCanClick=True)
		piece.SetupAudio("ButtonDown", "ButtonUp")
		piece.SetUpLabel("Solve", None, yLabelAnchor=0.5)
		self.Manger.AddPiece(piece, True)

		op = self.CurretLevelData.OpList[0]
		piece = self.MakeGridPiece(1, 0, image=op.BaseImage)
		piece.SetUpButtonClick(onClick=self.OperationClicked, onClickData=0)
		piece.SetUpButtonHold(onHold=self.OperationHold, onHoldData=0)
		piece.SetUpLabel(str(op), None, xLabelAnchor=0.5, yLabelAnchor=0.5)
		piece.SetupAudio("ButtonDown", "ButtonUp")
		self.Manger.AddPiece(piece, False)

		piece = Piece.UiPiece([166, 450], [80, 25])
		piece.SetUpLabel(self.SolveOrder[0], None, xLabelAnchor=1, yLabelAnchor=0.5)
		self.Manger.AddPiece(piece, False)

		piece = self.MakeGridPiece(2, 0, image="Button_Red", hoverImage="Button_Red_Hover")
		piece.SetUpButtonClick("Button_Red_Pressed", onClick=self.ClearClicked)
		piece.SetUpLabel("Clear", None, xLabelAnchor=0.5, yLabelAnchor=0.5)
		piece.SetupAudio("ButtonDown", "ButtonUp")
		self.Manger.AddPiece(piece, False)

		#row 2

		if self.IsDev:
			toggleButton = "Button_"
			if self.OpDoesAction:
				toggleButton += "Green"
			else:
				toggleButton += "Red"
			piece = self.MakeGridPiece(0, 1, image=toggleButton)
			piece.SetUpButtonClick(onClick=self.ToggleOpClickAction)
			piece.SetupAudio("ButtonDown", "ButtonUp")
			piece.SetUpLabel("Do Action", None, yLabelAnchor=0.5)
			self.Manger.AddPiece(piece, False)

		op = self.CurretLevelData.OpList[1]
		piece = self.MakeGridPiece(1, 1, image=op.BaseImage)
		piece.SetUpButtonClick(onClick=self.OperationClicked, onClickData=1)
		piece.SetUpButtonHold(onHold=self.OperationHold, onHoldData=1)
		piece.SetUpLabel(str(op), None, xLabelAnchor=0.5, yLabelAnchor=0.5)
		piece.SetupAudio("ButtonDown", "ButtonUp")
		self.Manger.AddPiece(piece, False)
		
		piece = Piece.UiPiece([166, 560], [80, 25])
		piece.SetUpLabel(self.SolveOrder[1], None, xLabelAnchor=1, yLabelAnchor=0.5)
		piece.SetupAudio("ButtonDown", "ButtonUp")
		self.Manger.AddPiece(piece, False)

		op = self.CurretLevelData.OpList[2]
		piece = self.MakeGridPiece(2, 1, image=op.BaseImage)
		piece.SetUpButtonClick(onClick=self.OperationClicked, onClickData=2)
		piece.SetUpButtonHold(onHold=self.OperationHold, onHoldData=2)
		piece.SetUpLabel(str(op), None, xLabelAnchor=0.5, yLabelAnchor=0.5)
		piece.SetupAudio("ButtonDown", "ButtonUp")
		self.Manger.AddPiece(piece, False)

		piece = Piece.UiPiece([279, 560], [80, 25])
		piece.SetUpLabel(self.SolveOrder[2], None, xLabelAnchor=1, yLabelAnchor=0.5)
		self.Manger.AddPiece(piece, False)

		#row 3
		piece = self.MakeGridPiece(0, 2, image="Settings_Button", hoverImage="Settings_Hover")
		piece.SetUpButtonClick("Settings_Pressed", onClick=self.SetupSettingsScreen)
		piece.SetupAudio("ButtonDown", "ButtonUp")
		self.Manger.AddPiece(piece, False)

		op = self.CurretLevelData.OpList[3]
		piece = self.MakeGridPiece(1, 2, image=op.BaseImage)
		piece.SetUpButtonClick(onClick=self.OperationClicked, onClickData=3)
		piece.SetUpButtonHold(onHold=self.OperationHold, onHoldData=3)
		piece.SetUpLabel(str(op), None, xLabelAnchor=0.5, yLabelAnchor=0.5)
		piece.SetupAudio("ButtonDown", "ButtonUp")
		self.Manger.AddPiece(piece, False)
		
		piece = Piece.UiPiece([166, 670], [80, 25])
		piece.SetUpLabel(self.SolveOrder[3], None, xLabelAnchor=1, yLabelAnchor=0.5)
		self.Manger.AddPiece(piece, False)

		op = self.CurretLevelData.OpList[4]
		piece = self.MakeGridPiece(2, 2, image=op.BaseImage)
		piece.SetUpButtonClick(onClick=self.OperationClicked, onClickData=4)
		piece.SetUpButtonHold(onHold=self.OperationHold, onHoldData=4)
		piece.SetUpLabel(str(op), None, xLabelAnchor=0.5, yLabelAnchor=0.5)
		piece.SetupAudio("ButtonDown", "ButtonUp")
		self.Manger.AddPiece(piece, False)

		piece = Piece.UiPiece([279, 670], [80, 25])
		piece.SetUpLabel(self.SolveOrder[4], None, xLabelAnchor=1, yLabelAnchor=0.5)
		self.Manger.AddPiece(piece, False)

		return
Esempio n. 6
0
	def SetUpShared(self, selectable=True, clearSelected=True, showPaused=False):
		self.Manger.ClearPieceList(clearSelected)

		piece = Piece.UiPiece([0, 0], [378, 704], "BackGround")
		self.Manger.AddPiece(piece, False)

		piece = Piece.UiPiece([55, 35], [145, 30])
		piece.SetUpLabel("LEVEL:", self.Level)
		self.Manger.AddPiece(piece, False)

		piece = Piece.UiPiece([0, 0], [145, 15])
		piece.SetUpLabel("V M"+str(self.Version) + ", D"+str(self.CurretLevelData.Version), None, labelColour=[0,0,0])
		self.Manger.AddPiece(piece, False)

		piece = Piece.UiPiece([220, 30], [105, 35])
		piece.SetUpButtonHold(onHold=self.SetSolarCovered, minHoldTime=0, maxTimeBetweenHold=0)
		self.Manger.AddPiece(piece, False)

		if showPaused:
			piece = Piece.UiPiece([40, 90], [90, 50], "FunGuy_Faded")
			self.Manger.AddPiece(piece, False)

			piece = Piece.UiPiece([140, 90], [90, 50], "TopStats_Faded")
			self.Manger.AddPiece(piece, selectable)

			piece = Piece.UiPiece([245, 90], [90, 50], "TopStats_Faded")
			self.Manger.AddPiece(piece, selectable)
		else:
			piece = Piece.UiPiece([40, 90], [90, 50], "FunGuy_Normal")
			piece.SetUpFade(self.GetIsFaded, "FunGuy_Faded")
			self.Manger.AddPiece(piece, False)

			piece = Piece.UiPiece([140, 90], [90, 50], "TopStats_Normal")
			piece.SetUpFade(self.GetIsFaded, "TopStats_Faded")
			piece.SetUpLabel("Moves:", self.CurretLevelData.Moves, textUpdatedFunc=self.UpdateMovesNum)
			self.Manger.AddPiece(piece, selectable)

			piece = Piece.UiPiece([245, 90], [90, 50], "TopStats_Normal")
			piece.SetUpFade(self.GetIsFaded, "TopStats_Faded")
			piece.SetUpLabel("Goal:", self.CurretLevelData.Goal, textUpdatedFunc=self.UpdateGoalNum)
			self.Manger.AddPiece(piece, selectable)

		piece = Piece.UiPiece([38 , 180], [302, 75])
		piece.SetUpFade(self.GetIsFaded)

		if showPaused:
			piece.SetUpLabel("PAUSED", None, (0, 0, 0), 0.5, 0.5)

		else:
			piece.SetUpLabel("", self.CurretLevelData.StartingNum, (0, 0, 0), 1, 0.5, textUpdatedFunc=self.UpdateStartingNum, hideLabel=True)
			
		self.Manger.AddPiece(piece, selectable)

		if not showPaused:
			self.SegmentDisplay = UiSegmentDisplay.UiSegmentDisplay(self.Manger, 
				GameSolver.MaxCharacters, [45 , 180], [295, 75], self.SetFromPortal, self.SetToPortal, self.GetIsFaded)


		return
Esempio n. 7
0
	def SetupSettingsScreen(self):
		self.ScreenState = Main.eScreen.Setting

		self.SetUpShared(False, showPaused=True)
		minHoldTime = 0.5
		timeBetweenHold = 0.075

		#volume control row 1
		piece = self.MakeGridPiece(0, 0, image="Button", hoverImage="Button_Hover")
		piece.SetUpButtonClick("Button_Pressed", onClick=self.ChangeVolume, onClickData=-1)
		piece.SetUpButtonHold("Button_Pressed", onHold=self.ChangeVolume, 
			onHoldData=-1, minHoldTime=minHoldTime, maxTimeBetweenHold=timeBetweenHold)
		piece.SetUpLabel("-", None, xLabelAnchor=0.5, yLabelAnchor=0.5)
		piece.SetupAudio("ButtonDown", "ButtonUp")
		self.Manger.AddPiece(piece, False)

		piece = self.MakeGridPiece(1, 0, image="Button_Black")
		piece.SetUpLabel("Volume", None, xLabelAnchor=0.5, yLabelAnchor=0)
		self.Manger.AddPiece(piece, False)

		piece = Piece.UiPiece([133, 395], [113, 80])
		piece.SetUpLabel(str(self.AudioPlayer.Volume), None, xLabelAnchor=0.5, yLabelAnchor=0.5, getMessage=self.GetVolume)
		self.Manger.AddPiece(piece, False)

		piece = self.MakeGridPiece(2, 0, image="Button", hoverImage="Button_Hover")
		piece.SetUpButtonClick("Button_Pressed", onClick=self.ChangeVolume, onClickData=1)
		piece.SetUpButtonHold("Button_Pressed", onHold=self.ChangeVolume, 
			onHoldData=1, minHoldTime=minHoldTime, maxTimeBetweenHold=timeBetweenHold)
		piece.SetUpLabel("+", None, xLabelAnchor=0.5, yLabelAnchor=0.5)
		piece.SetupAudio("ButtonDown", "ButtonUp")
		self.Manger.AddPiece(piece, False)

		#level select row 2
		piece = self.MakeGridPiece(0, 1, image="Button", hoverImage="Button_Hover")
		piece.SetUpButtonClick("Button_Pressed", onClick=self.ChangeLevelSelect, onClickData=-1)
		piece.SetUpButtonHold("Button_Pressed", onHold=self.ChangeLevelSelect, 
			onHoldData=-1, minHoldTime=minHoldTime, maxTimeBetweenHold=timeBetweenHold)
		piece.SetUpLabel("-", None, xLabelAnchor=0.5, yLabelAnchor=0.5)
		piece.SetupAudio("ButtonDown", "ButtonUp")
		self.Manger.AddPiece(piece, False)

		piece = self.MakeGridPiece(1, 1, image="Button_Black")
		piece.SetUpLabel("Level", None, xLabelAnchor=0.5, yLabelAnchor=0)
		self.Manger.AddPiece(piece, False)

		piece = Piece.UiPiece([133, 510], [113, 80])
		piece.SetUpLabel(self.Level, None, xLabelAnchor=0.5, yLabelAnchor=0.5, getMessage=self.GetLevel)
		self.Manger.AddPiece(piece, False)

		piece = self.MakeGridPiece(2, 1, image="Button", hoverImage="Button_Hover")
		piece.SetUpButtonClick("Button_Pressed", onClick=self.ChangeLevelSelect, onClickData=1)
		piece.SetUpButtonHold("Button_Pressed", onHold=self.ChangeLevelSelect, 
			onHoldData=1, minHoldTime=minHoldTime, maxTimeBetweenHold=timeBetweenHold)
		piece.SetUpLabel("+", None, xLabelAnchor=0.5, yLabelAnchor=0.5)
		piece.SetupAudio("ButtonDown", "ButtonUp")
		self.Manger.AddPiece(piece, False)


		#row 3
		piece = self.MakeGridPiece(0, 2, image="Settings_Button", hoverImage="Settings_Hover")
		piece.SetUpButtonClick("Settings_Pressed", onClick=self.SetUpMainScreen)
		piece.SetupAudio("ButtonDown", "ButtonUp")
		self.Manger.AddPiece(piece, False)

		if self.IsDev:
			debugButton = "Button_"
			if self.DebugMode:
				debugButton += "Green"
			else:
				debugButton += "Red"

			piece = self.MakeGridPiece(1, 2, image=debugButton)
			piece.SetUpButtonClick(onClick=self.DebugModeToggle)
			piece.SetUpLabel("Debug", None, yLabelAnchor=0.5, xLabelAnchor=0.5)
			piece.SetupAudio("ButtonDown", "ButtonUp")
			self.Manger.AddPiece(piece, False)

			piece = self.MakeGridPiece(2, 2, image="Button_Green")
			piece.SetUpButtonClick(onClick=self.SaveLevelData)
			piece.SetUpLabel("Save Level", None, yLabelAnchor=0.5, xLabelAnchor=0.5)
			piece.SetupAudio("ButtonDown", "ButtonUp")
			self.Manger.AddPiece(piece, False)
		return