#from bge import logic import GameLogic #from os.path import dirname, realpath, join #BASE_DIR = os.path.join( os.path.dirname( __file__ ), '..' ) mainDir = GameLogic.expandPath("//") fileName = mainDir + "Settings.dat" resx = 1280 resy = 720 def readSettings(): import GameLogic import bge cont = GameLogic.getCurrentController() own = cont.owner scenes = bge.logic.getSceneList() main_scene = [scene for scene in scenes if scene.name=="main"][0] own = main_scene.objects['Empty'] with open(fileName) as reading: #data = [line.split()[0] for line in reading] data = reading.readlines() #print lines[25] #print lines[29] reading.close() own["val"] = int(data[1]) own["bright"] = int(data[1]) own["playerName"] = data[4] #own["audio"] = int(data[3]) own["level"] = data[5] #data6 = data[6] #data6.split(None, 1)[0] #data5 = data5.strip('\n') #print(data6) own["resx"] = int(data[7]) own["resy"] = int(data[8]) own["framerate"] = int(data[10]) own["profile"] = int(data[12]) dict = bge.logic.globalDict #Get the global dictionary dict['resx'] = resx dict['resy'] = resy level = data[5] level = level.split(None, 1)[0] level = str(level) own["level"] = level dict["level"] = level print("reading. settings") print("Level: ", level) recorder_on = int(data[14]) print("Game play recorder on: ", recorder_on) #dict = bge.logic.globalDict dict['recorder_on'] = recorder_on own['recorder_on'] = recorder_on def writeSettings(): import GameLogic import bge cont = GameLogic.getCurrentController() own = cont.owner scenes = bge.logic.getSceneList() main_scene = [scene for scene in scenes if scene.name=="main"][0] own = main_scene.objects['Empty'] print("writing called") with open(fileName, 'w') as writing: writing.write(str("//settings.dat")+"\n") writing.write(str(own["val"])+"\n") writing.write(str(own["bright"])+"\n") writing.write(str("-\n")) writing.write(str("//level (e.g. spine, city, city2)")+"\n") writing.write(str(own["level"])+"\n") writing.write(str("//resolution")+"\n") writing.write(str(own["resx"])+"\n") writing.write(str(own["resy"])+"\n") writing.write(str("//show framerate")+"\n") writing.write(str(own["framerate"])+"\n") writing.write(str("//show profile")+"\n") writing.write(str(own["profile"])+"\n") writing.write(str("//Game play recorder off/on (0,1)")+"\n") writing.write(str(own["recorder_on"])+"\n") #writing.write(str(own["framerate"])+"\n") print("writing settings") writing.close() def loadlevel(): import GameLogic import bge scenes = bge.logic.getSceneList() main_scene = [scene for scene in scenes if scene.name=="main"][0] own = main_scene.objects['Empty'] cont = GameLogic.getCurrentController() own2 = cont.owner #readSettings() resx = own["resx"] resy = own["resy"] #dict = bge.logic.globalDict #Get the global dictionary #dict['resx'] = resx #dict['resy'] = resy #bge.render.setWindowSize(resx, resy) #fullscreen = bge.render.getFullScreen() #print("fullscreen = ", fullscreen) #if fullscreen != True: #bge.render.setFullScreen(True) print("resolution = ", resx, resy) #objList = scene.objects if own["framerate"] == 1: bge.render.showFramerate(1) if own["profile"] ==1: bge.render.showProfile(1) #cont = GameLogic.getCurrentController() #own = cont.owner #cont = own2.controllers['loadLevel'] act = own2.actuators["level"] #cont.activate(own.actuators["loading"]) #level = own["level"] dict = bge.logic.globalDict level = dict['level'] #dict['level'] = level act.scene = level cont.activate(own2.actuators["level"]) #cont.activate(own2.actuators["stance"]) dict['npause'] = False def timer(): import GameLogic import bge dict = bge.logic.globalDict if dict['reload_timer'] == 1: #restart # get current scene scene = bge.logic.getCurrentScene() # restart the current scene #scene.restart() if dict['reload_timer'] > 0: dict['reload_timer'] -= 1 #print(dict['reload_timer']) #own['reload_timer'] = dict['reload_timer']