def delDB(i): netSave = startLoad(netPath) if len(recName) < 8: ui.addText("Zuerst Name der Sicherung angeben") return if not runs(): ui.addText("entferne " + recName) os.remove(netPath + locs[i-1] + "\\" + recName)
def startLoad(path): saves = False try: saves = sorted(os.listdir(path)) except WindowsError: ui.addText(path + " nicht erreichbar") assert False return saves
def saveTo(fromPath, fName, toPath): currYear = str(datetime.datetime.now().year) currMonth = "0" + str(datetime.datetime.now().month) currDay = "0" + str(datetime.datetime.now().day) currDate = currYear + currMonth[-2:] + currDay[-2:] ui.addText("kopiere " + fName + " nach " + toPath) newName = toPath[41:] + " " + currDate + fName[-4:] shutil.copy(fromPath + "\\" + fName, toPath + "\\" + newName) ui.addText("Sicherungsname: " + newName)
def myRemove(path, remName, keepName): global counter ui.addText("entferne " + remName + " behalte " + keepName) if doIt: if os.path.isdir(path): shutil.rmtree(path) if os.path.isfile(path): os.remove(path) else: counter += 0.25
def endGame(win): ui.addText(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 2, textSize=48, text=("VOUS AVEZ GAGNE :)" if win else "VOUS AVEZ PERDU :("), textColor=("green" if win else "red"), ID="endText", layer=2) ui.render(getFps()) attente_clic_ou_touche()
def runs(): cmd = 'WMIC PROCESS get Caption' proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) for l in proc.stdout: if "wincws.exe" in l.lower(): ui.addText("WinCWS zuerst schliessen") return True if "bld.exe" in l.lower(): ui.addText("Label Designer zuerst schliessen") return True return False
def copyTo(fromPath, aSave, toPath): global counter currMonth = datetime.datetime.now().month if (not os.path.exists(toPath + "\\" + aSave) and os.path.isdir(fromPath + "\\" + aSave)): if ((aSave[4] <> "0" and aSave[4] <> "1") or int(aSave[4:6]) <= currMonth): ui.addText("kopiere " + aSave + " nach " + toPath[-33:]) if doIt: shutil.copytree(fromPath + aSave, toPath + "\\" + aSave) else: counter += 1
def initScores(scores): ui.addText(render.WIDTH_WINDOW/24, render.HEIGHT_WINDOW/20, text="Levels", textColor="white", textSize=32, textAnchor="nw") ui.addButton(render.WIDTH_WINDOW/4, 2*render.HEIGHT_WINDOW / 14, width=100, height=30, fill="white", stroke=5, polygonal=POLYGONS["up-arrow"], action=evenement.setGameEvent, arguments=["up"]) ui.addButton(render.WIDTH_WINDOW/4, 13*render.HEIGHT_WINDOW / 14, width=100, height=30, fill="white", stroke=5, polygonal=POLYGONS["down-arrow"], action=evenement.setGameEvent, arguments=["down"]) levels = [key for key in scores["s"]] for i in range(3): ui.addText(render.WIDTH_WINDOW/20, render.HEIGHT_WINDOW / 3.3 + (render.HEIGHT_WINDOW/7) * 1.30*i, ID="ltext"+str(i+1), text= levels[i] + " - "+ str(scores["s"][levels[i]][0]) + "\n\t"+scores["s"][levels[i]][1], textColor="white", textSize=18, textAnchor="sw") ui.addPolygon(render.WIDTH_WINDOW/4, render.HEIGHT_WINDOW / 2.9 + (render.HEIGHT_WINDOW/7) * 1.30*i, width=render.WIDTH_WINDOW/2.4, height=render.HEIGHT_WINDOW/80, points=POLYGONS["separator-horizontal"], fill="white", ID='levelSeparator'+str(i)) ui.addText(render.WIDTH_WINDOW/20, render.HEIGHT_WINDOW / 3.3 + (render.HEIGHT_WINDOW/7) * 1.30*3, ID="ltext"+str(3+1), text= levels[3%len(levels)] + " - "+ str(scores["s"][levels[3%len(levels)]][0]) + "\n\t"+scores["s"][levels[3%len(levels)]][1], textColor="white", textSize=18, textAnchor="sw") ui.addPolygon(render.WIDTH_WINDOW/2, render.HEIGHT_WINDOW/2, width=render.WIDTH_WINDOW/100, height=0, points=POLYGONS["separator-vertical"], fill="white", ID='separator') animation.animate("separator", [0.4], [{"height":render.HEIGHT_WINDOW/1.1}]) ui.addText(render.WIDTH_WINDOW/2 + render.WIDTH_WINDOW/24, render.HEIGHT_WINDOW/20, text="Unlimited Random", textColor="white", textSize=32, textAnchor="nw") for i in range(10): ui.addText(render.WIDTH_WINDOW/2 + render.WIDTH_WINDOW/24, render.HEIGHT_WINDOW/5.5+ (render.HEIGHT_WINDOW/16) * 1.3*i, ID="urtext"+str(i+1), text=str(i+1)+") "+scores["r"][i][0]+" - "+scores["r"][i][1], textColor="white", textSize=18, textAnchor="nw")
def initSaveLevel(level): """ Initialise les éléments d'interface du menu de sélection d'une partie sauvegardée. """ ui.addButton(render.WIDTH_WINDOW * 0.1, render.HEIGHT_WINDOW / 2, width=70, height=100, fill="white", stroke=5, polygonal=POLYGONS["left-arrow"], action=setLevelDirection, arguments=["left", "leftButton"], ID="leftButton") ui.addButton(render.WIDTH_WINDOW * 0.9, render.HEIGHT_WINDOW / 2, width=70, height=100, fill="white", stroke=5, polygonal=POLYGONS["right-arrow"], action=setLevelDirection, arguments=["right", "rightButton"], ID="rightButton") ui.addButton(render.WIDTH_WINDOW/2, 7*render.HEIGHT_WINDOW/8, width=render.WIDTH_WINDOW/4, height=render.HEIGHT_WINDOW/7, text=language.get("playSelectedButton"), outlineColor="white", textColor="white", action=evenement.setGameEvent, arguments=["play"], ID="playButton") animation.new("leftButton", [0.1, 0.1], [{"x":render.WIDTH_WINDOW * 0.05}, {"x":render.WIDTH_WINDOW * 0.1}]) animation.new("rightButton", [0.1, 0.1], [{"x":render.WIDTH_WINDOW * 0.95}, {"x":render.WIDTH_WINDOW * 0.9}]) ui.addText(render.WIDTH_WINDOW/2, render.HEIGHT_WINDOW/9, "levelName", render.WIDTH_WINDOW/2, render.HEIGHT_WINDOW/8, text=" ", textColor="white", textSize=28) ui.addText(3*render.WIDTH_WINDOW/4, render.HEIGHT_WINDOW/9, "levelSelected", render.WIDTH_WINDOW/2, render.HEIGHT_WINDOW/8, text=" ", textColor="white", textSize=28) ui.addCanvas(render.WIDTH_WINDOW/2, render.HEIGHT_WINDOW/2, "levelSelection", width=0, height=0, squaresMap=level, cellSize=24)
def initEditorUI(): """ Initialise les éléments d'interface de l'éditeur de niveau. """ RightXPos = render.WIDTH_WINDOW * 2 / 2.2 # Buttons ui.addButton(RightXPos, render.HEIGHT_WINDOW / 16, action=evenement.setGameEvent, arguments=["reset"], outlineColor="white", text=language.get("resetButton"), textColor="white", layer=1) ui.addButton(RightXPos, render.HEIGHT_WINDOW, action=saveLevel, anchor="sc",outlineColor="white", text="Sauvegarder", textSize=15, textColor="white", layer=1, ID="saveButton") # Texts ui.addText(render.WIDTH_WINDOW*0.15, render.WIDTH_WINDOW*0.035, ID="timeLeftText", anchor="nw", textColor="green", text=language.get("editorTimeText"), textFont="Monospace") # textFields ui.addTextField(render.WIDTH_WINDOW*0.35, render.WIDTH_WINDOW*0.035, ID="timeLeftTextField", outlineColor="white", textColor="white") # Game canvas ui.addCanvas(0, render.HEIGHT_WINDOW/8, ID="editorCanvas", width=0, height=0, fill="green", anchor="nw") ui.addCanvas(RightXPos, render.HEIGHT_WINDOW/8, ID="blockCanvas", width=0, height=0, fill="red", anchor="n", cellSize=64, selected=[(0,0)])
def initGameUI(): """ Initialise les éléments d'interface d'une partie. """ RightXPos = render.WIDTH_WINDOW * 2 / 2.2 # Buttons ui.addButton(RightXPos, render.HEIGHT_WINDOW / 16, action=evenement.setGameEvent, arguments=["reset"], outlineColor="white", text=language.get("resetButton"), textColor="white", layer=1) ui.addButton(RightXPos, render.HEIGHT_WINDOW / 16 * 4, action=evenement.setGameEvent, arguments=["debug"], outlineColor="white", text=language.get("debugButton"), textColor="white", ID="debug", layer=1) ui.addButton(RightXPos, render.HEIGHT_WINDOW / 16 * 7, action=evenement.setGameEvent, arguments=["save"], outlineColor="white", text=language.get("saveButton"), textColor="white", textSize=18, layer=1) ui.addButton(RightXPos, render.HEIGHT_WINDOW - 1, action=logic.quitter, anchor="sc", outlineColor="white", text=language.get("quitButton"), textColor="white", layer=1) # Texts ui.addText(render.WIDTH_WINDOW*0.05, render.WIDTH_WINDOW*0.02, ID="timeLeftText", anchor="nw", textColor="green", textFont="Monospace") ui.addText(render.WIDTH_WINDOW*0.25, render.WIDTH_WINDOW*0.02, ID="diamondsText", anchor="nw", textColor="red", textFont="Monospace") ui.addText(render.WIDTH_WINDOW*0.45, render.WIDTH_WINDOW*0.02, ID="scoreText", anchor='nw', textColor="purple", textFont="Monospace") # Game canvas ui.addCanvas(0, render.HEIGHT_WINDOW/8, ID="gameCanvas", width=0, height=0, anchor="nw", cellSize=32)
def recoverTo(fromPath, recName, fName, toPath): if len(recName) < 8: ui.addText("Zuerst Name der Sicherung angeben") return ui.addText("kopiere " + recName + " nach " + toPath) shutil.copy(fromPath + "\\" + recName, toPath + "\\" + fName)
def layout(i): bldFiles = [f for f in os.listdir(locBldPath) if f[-4:] == ".bld"] for f in bldFiles: name = f.replace("ü", "ue") ui.addText("kopiere " + name + " nach " + netBldPath) shutil.copy(locBldPath + "\\" + f, netBldPath + "\\" + f)
def tryRepair(): ui.addText("Versuche " + cardPath[:2] + " zu reparieren") ui.addText( "Bei Frage \"Ordner oder Verlorene Kette in Datei umwandeln\" mit \"J\" antworten" ) os.system('chkdsk /f ' + cardPath[:2])