Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. import os
  2. import glob
  3. import binascii
  4.  
  5. prb = "gr2 >> object"
  6. prd = "gr2 >> dungeon block"
  7. prt = "spt >> tree"
  8. pre = "mse >> effect"
  9. bshadow = ''
  10. filetype = [prb, prd, prt, pre]
  11. filename = []
  12. filepath = []
  13. crc32 = []
  14. filecount = 0
  15. currentfile = 0
  16. count = 0
  17.  
  18. def clear():
  19. os.system('cls')
  20.  
  21.  
  22. def getcrc32(f):
  23. fo = open(f, 'rb').read()
  24. return binascii.crc32(fo) % (1 << 32)
  25.  
  26.  
  27. def properties(fileext, propertyext, propetytype):
  28. global currentfile, filecount, count
  29.  
  30. for srcfn in glob.glob('*%s' % fileext):
  31. if '_lod_0' in srcfn: # skip LOD files
  32. pass
  33. else:
  34. filename.append(srcfn)
  35. filepath.append((os.getcwd() + '\%s' % srcfn).replace('\\', '/').lower())
  36. filecount += 1
  37.  
  38. for i in range(0, len(filename)):
  39. prop = open(filename[i][:-4] + propertyext, 'w')
  40. prop.write('YPRT\n')
  41. crc32.append(getcrc32(filename[i]))
  42. prop.write(str(crc32[i]) + '\n')
  43. if propertyext == '.prb':
  44. prop.write('buildingfile\t\t"%s"' % filepath[i].lower())
  45. if os.path.exists(filename[i][:-4] + '.mdatr'):
  46. prop.write('\nisattributedata\t\t"0"') # include .mdatr
  47. if propertyext == '.prd':
  48. prop.write('dungeonblockfile\t\t"%s"' % filepath[i].lower())
  49. if propertyext == '.prt':
  50. prop.write('treefile\t\t"%s"' % filepath[i].lower())
  51. if propertyext == '.pre':
  52. prop.write('effectfile\t\t"%s"' % filepath[i].lower())
  53. prop.write('\npropertyname\t\t"%s"\n' % filename[i][:-4])
  54. prop.write('propertytype\t\t"%s"\n' % propetytype)
  55. if propertyext == '.prb' and bshadow == 'T':
  56. prop.write('shadowflag\t\t"1"\n') # include shadow
  57. if propertyext == '.prt':
  58. prop.write('treesize\t\t"1000.000000"\n')
  59. prop.write('treevariance\t\t"0.000000"')
  60.  
  61. print "(%d/%d) %s | crc32: %d" % (currentfile + 1, filecount, filename[i], crc32[i])
  62. currentfile += 1
  63. count += 1
  64.  
  65.  
  66. def option(ext):
  67. global bshadow
  68.  
  69. if ext == prb:
  70. outputshadow = raw_input("Include shadows? (T/N): ")
  71. if outputshadow == 't' or outputshadow == 'T':
  72. bshadow += 'T'
  73. properties('.gr2', '.prb', 'Building')
  74. if ext == prd:
  75. properties('.gr2', '.prd', 'DungeonBlock')
  76. if ext == prt:
  77. properties('.spt', '.prt', 'Tree')
  78. if ext == pre:
  79. properties('.mse', '.pre', 'Effect')
  80.  
  81.  
  82. def menu():
  83. print "1) ", prb
  84. print "2) ", prd
  85. print "3) ", prt
  86. print "4) ", pre
  87. select = raw_input("Choose option: ")
  88. if 5 > int(select) > 0:
  89. clear()
  90. print "You have chosen: ", filetype[int(select) - 1]
  91. option(filetype[int(select) - 1])
  92. else:
  93. clear()
  94. menu()
  95.  
  96.  
  97. menu()
  98. print "Generated", count
  99. raw_input("Press any key to exit")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement