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 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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'] = resx
  38. dict['resy'] = 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["shirt_color_r"] = float(data[16])
  52. dict["shirt_color_g"] = float(data[17])
  53. dict["shirt_color_b"] = float(data[18])
  54. dict["shoe_color_r"] = float(data[20])
  55. dict["shoe_color_g"] = float(data[21])
  56. dict["shoe_color_b"] = float(data[22])
  57. dict["deck_color_r"] = float(data[24])
  58. dict["deck_color_g"] = float(data[25])
  59. dict["deck_color_b"] = float(data[26])
  60. dict["shirt_logo"] = int(data[28])
  61. dict["bc"] = int(data[30])
  62. dict["BC_BRIGHTNESS"] = float(data[31])
  63. dict["BC_CONTRAST"] = float(data[32])
  64. dict['hdr'] = int(data[34])
  65. dict['avgL'] = float(data[35])
  66. dict['HDRamount'] = float(data[36])
  67. dict['ao'] = int(data[38])
  68. dict['onlyAO'] = int(data[39])
  69. dict['aowidth'] = float(data[40])
  70. dict['aoradius'] = float(data[41])
  71. dict['dof_on'] = float(data[43])
  72. dict['sun_strength'] = float(data[45])
  73. dict['sun_rot_x'] = float(data[46])
  74. dict['sun_rot_y'] = float(data[47])
  75. dict['shadow_on'] = float(data[48])
  76. dict['ambient_strength'] = float(data[49])
  77. #print('bc = ', dict['bc'])
  78. #dict['music_player_on'] = int(data[16])
  79. def writeSettings():
  80. import GameLogic
  81. import bge
  82. cont = GameLogic.getCurrentController()
  83. own = cont.owner
  84. scenes = bge.logic.getSceneList()
  85. dict = bge.logic.globalDict
  86. main_scene = [scene for scene in scenes if scene.name=="main"][0]
  87. own = main_scene.objects['Empty']
  88. print("writing called")
  89. with open(fileName, 'w') as writing:
  90. writing.write(str("//settings.dat")+"\n")
  91. writing.write(str(own["val"])+"\n")
  92. writing.write(str(own["bright"])+"\n")
  93. writing.write(str("-\n"))
  94. writing.write(str("//level (e.g. spine, city, city2)")+"\n")
  95. writing.write(str(own["level"])+"\n")
  96. writing.write(str("//resolution")+"\n")
  97. writing.write(str(own["resx"])+"\n")
  98. writing.write(str(own["resy"])+"\n")
  99. writing.write(str("//show framerate")+"\n")
  100. writing.write(str(own["framerate"])+"\n")
  101. writing.write(str("//show profile")+"\n")
  102. writing.write(str(own["profile"])+"\n")
  103. writing.write(str("//Game play recorder off/on (0,1)")+"\n")
  104. writing.write(str(own["recorder_on"])+"\n")
  105. writing.write(str("//Shirt color [r,g,b]")+"\n")
  106. writing.write(str(dict["shirt_color_r"])+"\n") #16
  107. writing.write(str(dict["shirt_color_g"])+"\n")
  108. writing.write(str(dict["shirt_color_b"])+"\n") #
  109. writing.write(str("//Shoe color [r,g,b]")+"\n")
  110. writing.write(str(dict["shoe_color_r"])+"\n") #16
  111. writing.write(str(dict["shoe_color_g"])+"\n")
  112. writing.write(str(dict["shoe_color_b"])+"\n") #
  113. writing.write(str("//Deck color [r,g,b]")+"\n")
  114. writing.write(str(dict["deck_color_r"])+"\n") #24
  115. writing.write(str(dict["deck_color_g"])+"\n")
  116. writing.write(str(dict["deck_color_b"])+"\n") #
  117. writing.write(str("//Shirt Logo")+"\n")
  118. writing.write(str(dict["shirt_logo"])+"\n") #24
  119. writing.write(str("//Brightness/Contrast: On, brightness, contrast")+"\n")
  120. writing.write(str(dict["bc"])+"\n")
  121. writing.write(str(dict["BC_BRIGHTNESS"])+"\n")
  122. writing.write(str(dict["BC_CONTRAST"])+"\n")
  123. writing.write(str("//HDR: On, avgL, amount")+"\n")
  124. writing.write(str(dict["hdr"])+"\n")
  125. writing.write(str(dict["avgL"])+"\n")
  126. writing.write(str(dict["HDRamount"])+"\n")
  127. writing.write(str("//AO: On, only, width, radius")+"\n")
  128. writing.write(str(dict["ao"])+"\n")
  129. writing.write(str(dict["onlyAO"])+"\n")
  130. writing.write(str(dict["aowidth"])+"\n")
  131. writing.write(str(dict["aoradius"])+"\n")
  132. writing.write(str("//dof on")+"\n")
  133. writing.write(str(dict["dof_on"])+"\n")
  134. writing.write(str("//sun settings: strength, rotx, roty, shadow on, ambient strength")+"\n")
  135. writing.write(str(dict["sun_strength"])+"\n")
  136. writing.write(str(dict["sun_rot_x"])+"\n")
  137. writing.write(str(dict["sun_rot_y"])+"\n")
  138. writing.write(str(dict["shadow_on"])+"\n")
  139. writing.write(str(dict["ambient_strength"])+"\n")
  140. #writing.write(str(own["framerate"])+"\n")
  141. print("writing settings")
  142. writing.close()
  143. def loadlevel():
  144. import GameLogic
  145. import bge
  146. scenes = bge.logic.getSceneList()
  147. main_scene = [scene for scene in scenes if scene.name=="main"][0]
  148. own = main_scene.objects['Empty']
  149. cont = GameLogic.getCurrentController()
  150. own2 = cont.owner
  151. #readSettings()
  152. resx = own["resx"]
  153. resy = own["resy"]
  154. dict = bge.logic.globalDict #Get the global dictionary
  155. dict['resx'] = resx
  156. dict['resy'] = resy
  157. bge.render.setWindowSize(resx, resy)
  158. fullscreen = bge.render.getFullScreen()
  159. print("fullscreen = ", fullscreen)
  160. if fullscreen != True:
  161. bge.render.setFullScreen(True)
  162. print("resolution = ", resx, resy)
  163. #objList = scene.objects
  164. if own["framerate"] == 1:
  165. bge.render.showFramerate(1)
  166. if own["profile"] ==1:
  167. bge.render.showProfile(1)
  168. #cont = GameLogic.getCurrentController()
  169. #own = cont.owner
  170. #cont = own2.controllers['loadLevel']
  171. act = own2.actuators["level"]
  172. #cont.activate(own.actuators["loading"])
  173. #level = own["level"]
  174. dict = bge.logic.globalDict
  175. level = dict['level']
  176. #dict['level'] = level
  177. act.scene = level
  178. cont.activate(own2.actuators["level"])
  179. #cont.activate(own2.actuators["stance"])
  180. dict['npause'] = False
  181. def timer():
  182. import GameLogic
  183. import bge
  184. dict = bge.logic.globalDict
  185. if dict['reload_timer'] == 1:
  186. #restart
  187. # get current scene
  188. scene = bge.logic.getCurrentScene()
  189. # restart the current scene
  190. #scene.restart()
  191. if dict['reload_timer'] > 0:
  192. dict['reload_timer'] -= 1
  193. #print(dict['reload_timer'])
  194. #own['reload_timer'] = dict['reload_timer']