Shuvit game master repo. http://shuvit.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Settings.py 9.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. #from bge import logic
  2. import GameLogic
  3. #from os.path import dirname, realpath, join
  4. #BASE_DIR = os.path.join( os.path.dirname( __file__ ), '..' )
  5. mainDir = GameLogic.expandPath("//")
  6. fileName = mainDir + "Settings.dat"
  7. resx = 1280
  8. resy = 720
  9. def readSettings():
  10. import GameLogic
  11. import bge
  12. cont = GameLogic.getCurrentController()
  13. own = cont.owner
  14. scenes = bge.logic.getSceneList()
  15. main_scene = [scene for scene in scenes if scene.name=="main"][0]
  16. own = main_scene.objects['Empty']
  17. with open(fileName) as reading:
  18. #data = [line.split()[0] for line in reading]
  19. data = reading.readlines()
  20. #print lines[25]
  21. #print lines[29]
  22. reading.close()
  23. #own["val"] = int(data[1])
  24. #own["bright"] = int(data[1])
  25. own["playerName"] = data[4]
  26. #own["audio"] = int(data[3])
  27. own["level"] = data[5]
  28. #data6 = data[6]
  29. #data6.split(None, 1)[0]
  30. #data5 = data5.strip('\n')
  31. #print(data6)
  32. own["resx"] = int(data[7])
  33. own["resy"] = int(data[8])
  34. own["framerate"] = int(data[10])
  35. own["profile"] = int(data[12])
  36. dict = bge.logic.globalDict #Get the global dictionary
  37. dict['resx'] = own["resx"]
  38. dict['resy'] = own["resy"]
  39. level = data[5]
  40. level = level.split(None, 1)[0]
  41. level = str(level)
  42. own["level"] = level
  43. dict["level"] = level
  44. print("reading. settings")
  45. print("Level: ", level)
  46. recorder_on = int(data[14])
  47. print("Game play recorder on: ", recorder_on)
  48. #dict = bge.logic.globalDict
  49. dict['recorder_on'] = recorder_on
  50. own['recorder_on'] = recorder_on
  51. dict['recorder_on'] = recorder_on
  52. character = data[1]
  53. dict["character"] = str(character.split(None, 1)[0])
  54. dict["shirt_color_r"] = float(data[16])
  55. dict["shirt_color_g"] = float(data[17])
  56. dict["shirt_color_b"] = float(data[18])
  57. dict["shoe_color_r"] = float(data[20])
  58. dict["shoe_color_g"] = float(data[21])
  59. dict["shoe_color_b"] = float(data[22])
  60. dict["deck_color_r"] = float(data[24])
  61. dict["deck_color_g"] = float(data[25])
  62. dict["deck_color_b"] = float(data[26])
  63. dict["shirt_logo"] = int(data[28])
  64. dict["bc"] = int(data[30])
  65. dict["BC_BRIGHTNESS"] = float(data[31])
  66. dict["BC_CONTRAST"] = float(data[32])
  67. dict['hdr'] = int(data[34])
  68. dict['avgL'] = float(data[35])
  69. dict['HDRamount'] = float(data[36])
  70. dict['ao'] = int(data[38])
  71. dict['onlyAO'] = int(data[39])
  72. dict['aowidth'] = float(data[40])
  73. dict['aoradius'] = float(data[41])
  74. dict['dof_on'] = float(data[43])
  75. dict['sun_strength'] = float(data[45])
  76. dict['sun_rot_x'] = float(data[46])
  77. dict['sun_rot_y'] = float(data[47])
  78. dict['shadow_on'] = int(data[48])
  79. dict['ambient_strength'] = float(data[49])
  80. dict['fullscreen_on'] = int(data[51])
  81. dict['bloom_on'] = int(data[53])
  82. dict['cam_height'] = float(data[55])
  83. dict['focal_length'] = int(data[56])
  84. dict['cam_min'] = float(data[57])
  85. dict['cam_max'] = float(data[58])
  86. dict['music_player'] = int(data[60])
  87. dict['fxaa'] = int(data[62])
  88. dict['FXAA_SPAN_MAX'] = float(data[63])
  89. #print('bc = ', dict['bc'])
  90. #dict['music_player_on'] = int(data[16])
  91. def writeSettings():
  92. import GameLogic
  93. import bge
  94. cont = GameLogic.getCurrentController()
  95. own = cont.owner
  96. scenes = bge.logic.getSceneList()
  97. dict = bge.logic.globalDict
  98. main_scene = [scene for scene in scenes if scene.name=="main"][0]
  99. own = main_scene.objects['Empty']
  100. print("writing called")
  101. with open(fileName, 'w') as writing:
  102. writing.write(str("//settings.dat")+"\n")
  103. writing.write(str(dict["character"])+"\n")
  104. writing.write(str(own["bright"])+"\n")
  105. writing.write(str("-\n"))
  106. writing.write(str("//level (e.g. spine, city, city2)")+"\n")
  107. writing.write(str(own["level"])+"\n")
  108. writing.write(str("//resolution")+"\n")
  109. writing.write(str(dict["resx"])+"\n")
  110. writing.write(str(dict["resy"])+"\n")
  111. writing.write(str("//show framerate")+"\n")
  112. writing.write(str(own["framerate"])+"\n")
  113. writing.write(str("//show profile")+"\n")
  114. writing.write(str(own["profile"])+"\n")
  115. writing.write(str("//Game play recorder off/on (0,1)")+"\n")
  116. writing.write(str(own["recorder_on"])+"\n")
  117. writing.write(str("//Shirt color [r,g,b]")+"\n")
  118. writing.write(str(dict["shirt_color_r"])+"\n") #16
  119. writing.write(str(dict["shirt_color_g"])+"\n")
  120. writing.write(str(dict["shirt_color_b"])+"\n") #
  121. writing.write(str("//Shoe color [r,g,b]")+"\n")
  122. writing.write(str(dict["shoe_color_r"])+"\n") #16
  123. writing.write(str(dict["shoe_color_g"])+"\n")
  124. writing.write(str(dict["shoe_color_b"])+"\n") #
  125. writing.write(str("//Deck color [r,g,b]")+"\n")
  126. writing.write(str(dict["deck_color_r"])+"\n") #24
  127. writing.write(str(dict["deck_color_g"])+"\n")
  128. writing.write(str(dict["deck_color_b"])+"\n") #
  129. writing.write(str("//Shirt Logo")+"\n")
  130. writing.write(str(dict["shirt_logo"])+"\n") #24
  131. writing.write(str("//Brightness/Contrast: On, brightness, contrast")+"\n")
  132. writing.write(str(dict["bc"])+"\n")
  133. writing.write(str(dict["BC_BRIGHTNESS"])+"\n")
  134. writing.write(str(dict["BC_CONTRAST"])+"\n")
  135. writing.write(str("//HDR: On, avgL, amount")+"\n")
  136. writing.write(str(dict["hdr"])+"\n")
  137. writing.write(str(dict["avgL"])+"\n")
  138. writing.write(str(dict["HDRamount"])+"\n")
  139. writing.write(str("//AO: On, only, width, radius")+"\n")
  140. writing.write(str(dict["ao"])+"\n")
  141. writing.write(str(dict["onlyAO"])+"\n")
  142. writing.write(str(dict["aowidth"])+"\n")
  143. writing.write(str(dict["aoradius"])+"\n")
  144. writing.write(str("//dof on")+"\n")
  145. writing.write(str(dict["dof_on"])+"\n")
  146. writing.write(str("//sun settings: strength, rotx, roty, shadow on, ambient strength")+"\n")
  147. writing.write(str(dict["sun_strength"])+"\n")
  148. writing.write(str(dict["sun_rot_x"])+"\n")
  149. writing.write(str(dict["sun_rot_y"])+"\n")
  150. writing.write(str(dict["shadow_on"])+"\n")
  151. writing.write(str(dict["ambient_strength"])+"\n")
  152. writing.write(str("//fullscreen on (0,1)")+"\n")
  153. writing.write(str(dict["fullscreen_on"])+"\n")
  154. writing.write(str("//bloom on (0,1)")+"\n")
  155. writing.write(str(dict["bloom_on"])+"\n")
  156. writing.write(str("//cam")+"\n")
  157. writing.write(str(dict["cam_height"])+"\n")
  158. writing.write(str(dict["focal_length"])+"\n")
  159. writing.write(str(dict["cam_min"])+"\n")
  160. writing.write(str(dict["cam_max"])+"\n")
  161. writing.write(str("//music player on / off")+"\n")
  162. writing.write(str(dict["music_player"])+"\n")
  163. writing.write(str("//fxaa")+"\n")
  164. writing.write(str(dict["fxaa"])+"\n")
  165. writing.write(str(dict["FXAA_SPAN_MAX"])+"\n")
  166. #writing.write(str(own["framerate"])+"\n")
  167. print("writing settings")
  168. writing.close()
  169. def setres():
  170. import GameLogic
  171. import bge
  172. scenes = bge.logic.getSceneList()
  173. main_scene = [scene for scene in scenes if scene.name=="main"][0]
  174. own = main_scene.objects['Empty']
  175. cont = GameLogic.getCurrentController()
  176. own2 = cont.owner
  177. dict = bge.logic.globalDict
  178. resx = dict["resx"]
  179. resy = dict["resy"]
  180. fullscreen = bge.render.getFullScreen()
  181. print("fullscreen = ", fullscreen)
  182. if fullscreen != True:
  183. if dict['fullscreen_on'] == 1:
  184. bge.render.setFullScreen(True)
  185. if fullscreen == True:
  186. if dict['fullscreen_on'] == 0:
  187. bge.render.setFullScreen(False)
  188. bge.render.setWindowSize(resx, resy)
  189. print("resolution = ", resx, resy)
  190. def loadlevel():
  191. import GameLogic
  192. import bge
  193. scenes = bge.logic.getSceneList()
  194. main_scene = [scene for scene in scenes if scene.name=="main"][0]
  195. own = main_scene.objects['Empty']
  196. cont = GameLogic.getCurrentController()
  197. own2 = cont.owner
  198. #readSettings()
  199. dict = bge.logic.globalDict #Get the global dictionary
  200. # resx = dict["resx"]
  201. # resy = dict["resy"]
  202. # #dict['resx'] = resx
  203. # #dict['resy'] = resy
  204. #
  205. # fullscreen = bge.render.getFullScreen()
  206. # print("fullscreen = ", fullscreen)
  207. # if fullscreen != True:
  208. # if dict['fullscreen_on'] == 1:
  209. # bge.render.setFullScreen(True)
  210. # if fullscreen == True:
  211. # if dict['fullscreen_on'] == 0:
  212. # bge.render.setFullScreen(False)
  213. #
  214. # bge.render.setWindowSize(resx, resy)
  215. # print("resolution = ", resx, resy)
  216. #objList = scene.objects
  217. if own["framerate"] == 1:
  218. bge.render.showFramerate(1)
  219. if own["profile"] ==1:
  220. bge.render.showProfile(1)
  221. #cont = GameLogic.getCurrentController()
  222. #own = cont.owner
  223. #cont = own2.controllers['loadLevel']
  224. act = own2.actuators["level"]
  225. #cont.activate(own.actuators["loading"])
  226. #level = own["level"]
  227. dict = bge.logic.globalDict
  228. level = dict['level']
  229. #dict['level'] = level
  230. act.scene = level
  231. cont.activate(own2.actuators["level"])
  232. #cont.activate(own2.actuators["stance"])
  233. dict['npause'] = False
  234. def timer():
  235. import GameLogic
  236. import bge
  237. dict = bge.logic.globalDict
  238. if dict['reload_timer'] == 1:
  239. #restart
  240. # get current scene
  241. scene = bge.logic.getCurrentScene()
  242. # restart the current scene
  243. #scene.restart()
  244. if dict['reload_timer'] > 0:
  245. dict['reload_timer'] -= 1
  246. #print(dict['reload_timer'])
  247. #own['reload_timer'] = dict['reload_timer']