123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- #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']
|