Shuvit game release repo.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Settings.py 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. #from bge import logic
  2. import bge
  3. import GameLogic
  4. import configobj
  5. from configobj import ConfigObj
  6. #from os.path import dirname, realpath, join
  7. #BASE_DIR = os.path.join( os.path.dirname( __file__ ), '..' )
  8. mainDir = GameLogic.expandPath("//")
  9. fileName = mainDir + "config.ini"
  10. config = ConfigObj(fileName, interpolation=True)
  11. #config.filename = filename
  12. dict = bge.logic.globalDict
  13. #resx = 1280
  14. #resy = 720
  15. print('###############start game##########')
  16. dict['music_player'] = 1
  17. def to_dict(section, key):
  18. dict = bge.logic.globalDict
  19. #print(key, config[key])
  20. str = config[key]
  21. if str.isdigit():
  22. dict[key] = int(str)
  23. else:
  24. try:
  25. dict[key] = float(str)
  26. except:
  27. dict[key] = str
  28. def readSettings():
  29. config.walk(to_dict)
  30. # import GameLogic
  31. # import bge
  32. # cont = GameLogic.getCurrentController()
  33. # own = cont.owner
  34. # scenes = bge.logic.getSceneList()
  35. # main_scene = [scene for scene in scenes if scene.name=="main"][0]
  36. # own = main_scene.objects['Empty']
  37. #
  38. # with open(fileName) as reading:
  39. # #data = [line.split()[0] for line in reading]
  40. # data = reading.readlines()
  41. # #print lines[25]
  42. # #print lines[29]
  43. # reading.close()
  44. # #own["val"] = int(data[1])
  45. # #own["bright"] = int(data[1])
  46. # own["playerName"] = data[4]
  47. # #own["audio"] = int(data[3])
  48. # own["level"] = data[5]
  49. # #data6 = data[6]
  50. # #data6.split(None, 1)[0]
  51. # #data5 = data5.strip('\n')
  52. # #print(data6)
  53. # own["resx"] = int(data[7])
  54. # own["resy"] = int(data[8])
  55. # own["framerate"] = int(data[10])
  56. # own["profile"] = int(data[12])
  57. # dict = bge.logic.globalDict #Get the global dictionary
  58. #
  59. # dict['resx'] = own["resx"]
  60. # dict['resy'] = own["resy"]
  61. # level = data[5]
  62. # level = level.split(None, 1)[0]
  63. # level = str(level)
  64. # own["level"] = level
  65. # dict["level"] = level
  66. # print("reading. settings")
  67. #
  68. #
  69. #
  70. #
  71. #
  72. #
  73. #
  74. #
  75. #
  76. # print("Level: ", level)
  77. # recorder_on = int(data[14])
  78. # print("Game play recorder on: ", recorder_on)
  79. # #dict = bge.logic.globalDict
  80. # dict['recorder_on'] = recorder_on
  81. # own['recorder_on'] = recorder_on
  82. # dict['recorder_on'] = recorder_on
  83. # character = data[1]
  84. # dict["character"] = str(character.split(None, 1)[0])
  85. # dict["shirt_color_r"] = float(data[16])
  86. # dict["shirt_color_g"] = float(data[17])
  87. # dict["shirt_color_b"] = float(data[18])
  88. # dict["shoe_color_r"] = float(data[20])
  89. # dict["shoe_color_g"] = float(data[21])
  90. # dict["shoe_color_b"] = float(data[22])
  91. # dict["deck_color_r"] = float(data[24])
  92. # dict["deck_color_g"] = float(data[25])
  93. # dict["deck_color_b"] = float(data[26])
  94. # dict["shirt_logo"] = int(data[28])
  95. # dict["bc"] = int(data[30])
  96. # dict["BC_BRIGHTNESS"] = float(data[31])
  97. # dict["BC_CONTRAST"] = float(data[32])
  98. # dict['hdr'] = int(data[34])
  99. # dict['avgL'] = float(data[35])
  100. # dict['HDRamount'] = float(data[36])
  101. # dict['ao'] = int(data[38])
  102. # dict['onlyAO'] = int(data[39])
  103. # dict['aowidth'] = float(data[40])
  104. # dict['aoradius'] = float(data[41])
  105. # dict['dof_on'] = float(data[43])
  106. # dict['sun_strength'] = float(data[45])
  107. # dict['sun_rot_x'] = float(data[46])
  108. # dict['sun_rot_y'] = float(data[47])
  109. # dict['shadow_on'] = int(data[48])
  110. # dict['ambient_strength'] = float(data[49])
  111. # dict['fullscreen_on'] = int(data[51])
  112. # dict['bloom_on'] = int(data[53])
  113. # dict['cam_height'] = float(data[55])
  114. # dict['focal_length'] = int(data[56])
  115. # dict['cam_min'] = float(data[57])
  116. # dict['cam_max'] = float(data[58])
  117. # dict['music_player'] = int(data[60])
  118. # dict['fxaa'] = int(data[62])
  119. # dict['FXAA_SPAN_MAX'] = float(data[63])
  120. # dict['cch_targetHeight'] = float(data[65])
  121. # dict["trucks_r"] = float(data[67])
  122. # dict["trucks_g"] = float(data[68])
  123. # dict["trucks_b"] = float(data[69])
  124. # dict["wheel1_r"] = float(data[71])
  125. # dict["wheel1_g"] = float(data[72])
  126. # dict["wheel1_b"] = float(data[73])
  127. # dict["wheel2_r"] = float(data[75])
  128. # dict["wheel2_g"] = float(data[76])
  129. # dict["wheel2_b"] = float(data[77])
  130. # dict["wheel3_r"] = float(data[79])
  131. # dict["wheel3_g"] = float(data[80])
  132. # dict["wheel3_b"] = float(data[81])
  133. # dict["wheel4_r"] = float(data[83])
  134. # dict["wheel4_g"] = float(data[84])
  135. # dict["wheel4_b"] = float(data[85])
  136. # dict["deck_index"] = int(data[87])
  137. #
  138. #print('bc = ', dict['bc'])
  139. #dict['music_player_on'] = int(data[16])
  140. def from_dict(section, key):
  141. config[key] = dict[key]
  142. def writeSettings():
  143. config.walk(from_dict)
  144. config.write()
  145. # import GameLogic
  146. # import bge
  147. # cont = GameLogic.getCurrentController()
  148. # own = cont.owner
  149. # scenes = bge.logic.getSceneList()
  150. # dict = bge.logic.globalDict
  151. # main_scene = [scene for scene in scenes if scene.name=="main"][0]
  152. # own = main_scene.objects['Empty']
  153. # print("writing called")
  154. # with open(fileName, 'w') as writing:
  155. # writing.write(str("//settings.dat")+"\n")
  156. # writing.write(str(dict["character"])+"\n")
  157. # writing.write(str(own["bright"])+"\n")
  158. # writing.write(str("-\n"))
  159. # writing.write(str("//level (e.g. spine, city, city2)")+"\n")
  160. # writing.write(str(own["level"])+"\n")
  161. # writing.write(str("//resolution")+"\n")
  162. # writing.write(str(dict["resx"])+"\n")
  163. # writing.write(str(dict["resy"])+"\n")
  164. # writing.write(str("//show framerate")+"\n")
  165. # writing.write(str(own["framerate"])+"\n")
  166. # writing.write(str("//show profile")+"\n")
  167. # writing.write(str(own["profile"])+"\n")
  168. # writing.write(str("//Game play recorder off/on (0,1)")+"\n")
  169. # writing.write(str(own["recorder_on"])+"\n")
  170. # writing.write(str("//Shirt color [r,g,b]")+"\n")
  171. # writing.write(str(dict["shirt_color_r"])+"\n") #16
  172. # writing.write(str(dict["shirt_color_g"])+"\n")
  173. # writing.write(str(dict["shirt_color_b"])+"\n") #
  174. # writing.write(str("//Shoe color [r,g,b]")+"\n")
  175. # writing.write(str(dict["shoe_color_r"])+"\n") #16
  176. # writing.write(str(dict["shoe_color_g"])+"\n")
  177. # writing.write(str(dict["shoe_color_b"])+"\n") #
  178. # writing.write(str("//Deck color [r,g,b]")+"\n")
  179. # writing.write(str(dict["deck_color_r"])+"\n") #24
  180. # writing.write(str(dict["deck_color_g"])+"\n")
  181. # writing.write(str(dict["deck_color_b"])+"\n") #
  182. # writing.write(str("//Shirt Logo")+"\n")
  183. # writing.write(str(dict["shirt_logo"])+"\n") #24
  184. # writing.write(str("//Brightness/Contrast: On, brightness, contrast")+"\n")
  185. # writing.write(str(dict["bc"])+"\n")
  186. # writing.write(str(dict["BC_BRIGHTNESS"])+"\n")
  187. # writing.write(str(dict["BC_CONTRAST"])+"\n")
  188. # writing.write(str("//HDR: On, avgL, amount")+"\n")
  189. # writing.write(str(dict["hdr"])+"\n")
  190. # writing.write(str(dict["avgL"])+"\n")
  191. # writing.write(str(dict["HDRamount"])+"\n")
  192. # writing.write(str("//AO: On, only, width, radius")+"\n")
  193. # writing.write(str(dict["ao"])+"\n")
  194. # writing.write(str(dict["onlyAO"])+"\n")
  195. # writing.write(str(dict["aowidth"])+"\n")
  196. # writing.write(str(dict["aoradius"])+"\n")
  197. # writing.write(str("//dof on")+"\n")
  198. # writing.write(str(dict["dof_on"])+"\n")
  199. # writing.write(str("//sun settings: strength, rotx, roty, shadow on, ambient strength")+"\n")
  200. # writing.write(str(dict["sun_strength"])+"\n")
  201. # writing.write(str(dict["sun_rot_x"])+"\n")
  202. # writing.write(str(dict["sun_rot_y"])+"\n")
  203. # writing.write(str(dict["shadow_on"])+"\n")
  204. # writing.write(str(dict["ambient_strength"])+"\n")
  205. # writing.write(str("//fullscreen on (0,1)")+"\n")
  206. # writing.write(str(dict["fullscreen_on"])+"\n")
  207. # writing.write(str("//bloom on (0,1)")+"\n")
  208. # writing.write(str(dict["bloom_on"])+"\n")
  209. # writing.write(str("//cam")+"\n")
  210. # writing.write(str(dict["cam_height"])+"\n")
  211. # writing.write(str(dict["focal_length"])+"\n")
  212. # writing.write(str(dict["cam_min"])+"\n")
  213. # writing.write(str(dict["cam_max"])+"\n")
  214. # writing.write(str("//music player on / off")+"\n")
  215. # writing.write(str(dict["music_player"])+"\n")
  216. # writing.write(str("//fxaa")+"\n")
  217. # writing.write(str(dict["fxaa"])+"\n")
  218. # writing.write(str(dict["FXAA_SPAN_MAX"])+"\n")
  219. # writing.write(str("//camera target height")+"\n")
  220. # writing.write(str(dict["cch_targetHeight"] )+"\n")
  221. # writing.write(str("//trucks color [r,g,b]")+"\n")
  222. # writing.write(str(dict["trucks_r"])+"\n")
  223. # writing.write(str(dict["trucks_g"])+"\n")
  224. # writing.write(str(dict["trucks_b"])+"\n")
  225. # writing.write(str("//wheel1 color [r,g,b]")+"\n")
  226. # writing.write(str(dict["wheel1_r"])+"\n")
  227. # writing.write(str(dict["wheel1_g"])+"\n")
  228. # writing.write(str(dict["wheel1_b"])+"\n")
  229. # writing.write(str("//wheel2 color [r,g,b]")+"\n")
  230. # writing.write(str(dict["wheel2_r"])+"\n")
  231. # writing.write(str(dict["wheel2_g"])+"\n")
  232. # writing.write(str(dict["wheel2_b"])+"\n")
  233. # writing.write(str("//wheel3 color [r,g,b]")+"\n")
  234. # writing.write(str(dict["wheel3_r"])+"\n")
  235. # writing.write(str(dict["wheel3_g"])+"\n")
  236. # writing.write(str(dict["wheel3_b"])+"\n")
  237. # writing.write(str("//wheel4 color [r,g,b]")+"\n")
  238. # writing.write(str(dict["wheel4_r"])+"\n")
  239. # writing.write(str(dict["wheel4_g"])+"\n")
  240. # writing.write(str(dict["wheel4_b"])+"\n")
  241. # writing.write(str("//deck index")+"\n")
  242. # writing.write(str(dict["deck_index"])+"\n")
  243. #
  244. # #dict['ccH_targetHeight']
  245. #
  246. # #writing.write(str(own["framerate"])+"\n")
  247. # print("writing settings")
  248. # writing.close()
  249. def setres():
  250. import GameLogic
  251. import bge
  252. scenes = bge.logic.getSceneList()
  253. main_scene = [scene for scene in scenes if scene.name=="main"][0]
  254. own = main_scene.objects['Empty']
  255. cont = GameLogic.getCurrentController()
  256. own2 = cont.owner
  257. dict = bge.logic.globalDict
  258. resx = int(dict["resx"])
  259. resy = int(dict["resy"])
  260. fullscreen = bge.render.getFullScreen()
  261. print("fullscreen = ", fullscreen)
  262. if fullscreen != True:
  263. if dict['fullscreen_on'] == 1:
  264. bge.render.setFullScreen(True)
  265. if fullscreen == True:
  266. if dict['fullscreen_on'] == 0:
  267. bge.render.setFullScreen(False)
  268. bge.render.setWindowSize(resx, resy)
  269. print("resolution = ", resx, resy)
  270. def loadlevel():
  271. import GameLogic
  272. import bge
  273. scenes = bge.logic.getSceneList()
  274. main_scene = [scene for scene in scenes if scene.name=="main"][0]
  275. own = main_scene.objects['Empty']
  276. cont = GameLogic.getCurrentController()
  277. own2 = cont.owner
  278. #readSettings()
  279. dict = bge.logic.globalDict #Get the global dictionary
  280. # resx = dict["resx"]
  281. # resy = dict["resy"]
  282. # #dict['resx'] = resx
  283. # #dict['resy'] = resy
  284. #
  285. # fullscreen = bge.render.getFullScreen()
  286. # print("fullscreen = ", fullscreen)
  287. # if fullscreen != True:
  288. # if dict['fullscreen_on'] == 1:
  289. # bge.render.setFullScreen(True)
  290. # if fullscreen == True:
  291. # if dict['fullscreen_on'] == 0:
  292. # bge.render.setFullScreen(False)
  293. #
  294. # bge.render.setWindowSize(resx, resy)
  295. # print("resolution = ", resx, resy)
  296. #objList = scene.objects
  297. if own["framerate"] == 1:
  298. bge.render.showFramerate(1)
  299. if own["profile"] ==1:
  300. bge.render.showProfile(1)
  301. #cont = GameLogic.getCurrentController()
  302. #own = cont.owner
  303. #cont = own2.controllers['loadLevel']
  304. act = own2.actuators["level"]
  305. #cont.activate(own.actuators["loading"])
  306. #level = own["level"]
  307. dict = bge.logic.globalDict
  308. level = dict['level']
  309. #dict['level'] = level
  310. act.scene = level
  311. cont.activate(own2.actuators["level"])
  312. #cont.activate(own2.actuators["stance"])
  313. dict['npause'] = False
  314. def timer():
  315. import GameLogic
  316. import bge
  317. dict = bge.logic.globalDict
  318. if dict['reload_timer'] == 1:
  319. #restart
  320. # get current scene
  321. scene = bge.logic.getCurrentScene()
  322. # restart the current scene
  323. #scene.restart()
  324. if dict['reload_timer'] > 0:
  325. dict['reload_timer'] -= 1
  326. #print(dict['reload_timer'])
  327. #own['reload_timer'] = dict['reload_timer']