123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- #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'] = own["resx"]
- dict['resy'] = own["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
- dict['recorder_on'] = recorder_on
- dict["shirt_color_r"] = float(data[16])
- dict["shirt_color_g"] = float(data[17])
- dict["shirt_color_b"] = float(data[18])
- dict["shoe_color_r"] = float(data[20])
- dict["shoe_color_g"] = float(data[21])
- dict["shoe_color_b"] = float(data[22])
- dict["deck_color_r"] = float(data[24])
- dict["deck_color_g"] = float(data[25])
- dict["deck_color_b"] = float(data[26])
- dict["shirt_logo"] = int(data[28])
- dict["bc"] = int(data[30])
- dict["BC_BRIGHTNESS"] = float(data[31])
- dict["BC_CONTRAST"] = float(data[32])
- dict['hdr'] = int(data[34])
- dict['avgL'] = float(data[35])
- dict['HDRamount'] = float(data[36])
- dict['ao'] = int(data[38])
- dict['onlyAO'] = int(data[39])
- dict['aowidth'] = float(data[40])
- dict['aoradius'] = float(data[41])
- dict['dof_on'] = float(data[43])
- dict['sun_strength'] = float(data[45])
- dict['sun_rot_x'] = float(data[46])
- dict['sun_rot_y'] = float(data[47])
- dict['shadow_on'] = int(data[48])
- dict['ambient_strength'] = float(data[49])
- dict['fullscreen_on'] = int(data[51])
- dict['bloom_on'] = int(data[53])
- dict['cam_height'] = float(data[55])
- dict['focal_length'] = int(data[56])
- dict['cam_min'] = float(data[57])
- dict['cam_max'] = float(data[58])
-
-
- #print('bc = ', dict['bc'])
- #dict['music_player_on'] = int(data[16])
- def writeSettings():
- import GameLogic
- import bge
- cont = GameLogic.getCurrentController()
- own = cont.owner
- scenes = bge.logic.getSceneList()
- dict = bge.logic.globalDict
- 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(dict["resx"])+"\n")
- writing.write(str(dict["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("//Shirt color [r,g,b]")+"\n")
- writing.write(str(dict["shirt_color_r"])+"\n") #16
- writing.write(str(dict["shirt_color_g"])+"\n")
- writing.write(str(dict["shirt_color_b"])+"\n") #
- writing.write(str("//Shoe color [r,g,b]")+"\n")
- writing.write(str(dict["shoe_color_r"])+"\n") #16
- writing.write(str(dict["shoe_color_g"])+"\n")
- writing.write(str(dict["shoe_color_b"])+"\n") #
- writing.write(str("//Deck color [r,g,b]")+"\n")
- writing.write(str(dict["deck_color_r"])+"\n") #24
- writing.write(str(dict["deck_color_g"])+"\n")
- writing.write(str(dict["deck_color_b"])+"\n") #
- writing.write(str("//Shirt Logo")+"\n")
- writing.write(str(dict["shirt_logo"])+"\n") #24
- writing.write(str("//Brightness/Contrast: On, brightness, contrast")+"\n")
- writing.write(str(dict["bc"])+"\n")
- writing.write(str(dict["BC_BRIGHTNESS"])+"\n")
- writing.write(str(dict["BC_CONTRAST"])+"\n")
- writing.write(str("//HDR: On, avgL, amount")+"\n")
- writing.write(str(dict["hdr"])+"\n")
- writing.write(str(dict["avgL"])+"\n")
- writing.write(str(dict["HDRamount"])+"\n")
- writing.write(str("//AO: On, only, width, radius")+"\n")
- writing.write(str(dict["ao"])+"\n")
- writing.write(str(dict["onlyAO"])+"\n")
- writing.write(str(dict["aowidth"])+"\n")
- writing.write(str(dict["aoradius"])+"\n")
- writing.write(str("//dof on")+"\n")
- writing.write(str(dict["dof_on"])+"\n")
- writing.write(str("//sun settings: strength, rotx, roty, shadow on, ambient strength")+"\n")
- writing.write(str(dict["sun_strength"])+"\n")
- writing.write(str(dict["sun_rot_x"])+"\n")
- writing.write(str(dict["sun_rot_y"])+"\n")
- writing.write(str(dict["shadow_on"])+"\n")
- writing.write(str(dict["ambient_strength"])+"\n")
- writing.write(str("//fullscreen on (0,1)")+"\n")
- writing.write(str(dict["fullscreen_on"])+"\n")
- writing.write(str("//bloom on (0,1)")+"\n")
- writing.write(str(dict["bloom_on"])+"\n")
- writing.write(str("//cam")+"\n")
- writing.write(str(dict["cam_height"])+"\n")
- writing.write(str(dict["focal_length"])+"\n")
- writing.write(str(dict["cam_min"])+"\n")
- writing.write(str(dict["cam_max"])+"\n")
-
-
- #writing.write(str(own["framerate"])+"\n")
- print("writing settings")
- writing.close()
-
-
- def setres():
- 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
- dict = bge.logic.globalDict
- resx = dict["resx"]
- resy = dict["resy"]
- fullscreen = bge.render.getFullScreen()
- print("fullscreen = ", fullscreen)
- if fullscreen != True:
- if dict['fullscreen_on'] == 1:
- bge.render.setFullScreen(True)
- if fullscreen == True:
- if dict['fullscreen_on'] == 0:
- bge.render.setFullScreen(False)
-
- bge.render.setWindowSize(resx, resy)
- print("resolution = ", resx, resy)
-
- 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()
-
- dict = bge.logic.globalDict #Get the global dictionary
-
- # resx = dict["resx"]
- # resy = dict["resy"]
- # #dict['resx'] = resx
- # #dict['resy'] = resy
- #
- # fullscreen = bge.render.getFullScreen()
- # print("fullscreen = ", fullscreen)
- # if fullscreen != True:
- # if dict['fullscreen_on'] == 1:
- # bge.render.setFullScreen(True)
- # if fullscreen == True:
- # if dict['fullscreen_on'] == 0:
- # bge.render.setFullScreen(False)
- #
- # bge.render.setWindowSize(resx, resy)
- # 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']
|