Advertisement
Guest User

Untitled

a guest
Nov 15th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 25.20 KB | None | 0 0
  1. -- This file is executed once on we start up. The state perseveres
  2. -- through callbacks
  3. --
  4. -- wehack.runprocess: Wait for exit code, report errors (grimext)
  5. -- wehack.runprocess2: Wait for exit code, don't report errors (jasshelper)
  6. -- wehack.execprocess: Don't wait for exit code (War3)
  7. --
  8. grimregpath = "Software\\Grimoire\\"
  9. --warcraftdir = grim.getregpair(grimregpath,"War3InstallPath")
  10. --if warcraftdir == 0 then
  11. --    wehack.messagebox("Error, could not find warcraft install path in wehack.lua")
  12. --end
  13.  
  14. isstartup = true
  15. grimdir = grim.getcwd()
  16. dofile("wehacklib.lua")
  17. dofile("findpath.lua")
  18. if path==0 or path=="" then
  19. path = "."
  20. end
  21. mapvalid = true
  22. cmdargs = "" -- used to execute external tools on save
  23.  
  24. confregpath = "HKEY_CURRENT_USER\\Software\\Grimoire\\"
  25.  
  26. haveext = grim.exists("grimext\\grimex.dll")
  27. if haveext then
  28. utils = wehack.addmenu("Extensions")
  29. end
  30. haveumswe = haveext and grim.exists("umswe\\umswecore.lua")
  31. if haveumswe then
  32. ums = wehack.addmenu("UMSWE")
  33. end
  34.  
  35. whmenu = wehack.addmenu("Grimoire")
  36. wh_window = TogMenuEntry:New(whmenu,"Start War3 with -window",nil,true)
  37. wh_opengl = TogMenuEntry:New(whmenu,"Start War3 with -opengl",nil,false)
  38.  
  39. wehack.addmenuseparator(whmenu)
  40. wh_tesh = TogMenuEntry:New(whmenu,"Enable TESH",nil,true)
  41. if grim.isdotnetinstalled() then
  42. wh_colorizer = TogMenuEntry:New(whmenu,"Enable Colorizer",nil,true)
  43. end
  44. wh_nolimits = TogMenuEntry:New(whmenu,"Enable no limits",
  45. function(self) grim.nolimits(self.checked) end,false)
  46. wh_oehack = TogMenuEntry:New(whmenu,"Enable object editor hack",
  47. function(self) grim.objecteditorhack(self.checked) end,true)
  48. wh_syndisable = TogMenuEntry:New(whmenu,"Disable WE syntax checker",
  49. function(self) grim.syndisable(self.checked) end,true)
  50. wh_descpopup = TogMenuEntry:New(whmenu,"Disable default description nag",
  51. function(self) grim.descpopup(self.checked) end,true)
  52. wh_autodisable = TogMenuEntry:New(whmenu,"Don't let WE disable triggers",
  53. function(self) grim.autodisable(self.checked) end,true)
  54. wh_alwaysenable = TogMenuEntry:New(whmenu,"Always allow trigger enable",
  55. function(self) grim.alwaysenable(self.checked) end,true)
  56. wh_disablesound = TogMenuEntry:New(whmenu,"Mute editor sounds",nil,true)
  57. wh_firstsavenag = TogMenuEntry:New(whmenu,"Disable first save warning",nil,true)
  58.  
  59. -- when warmachine is turned on, war3err must not be on
  60. --function setwar3err()
  61. --    if wh_machine.checked then
  62. --  grim.setregstring(confregpath,"Enable war3err","off")
  63. -- wehack.checkmenuentry(wh_enablewar3err.menu,wh_enablewar3err.id,0)
  64. -- end
  65. --end
  66.  
  67. -- when warmachine is turned on, war3err must not be on
  68. --function setwarmachine()
  69. --    if wh_enablewar3err.checked then
  70. --  grim.setregstring(confregpath,"Enable warmachine","off")
  71. -- wehack.checkmenuentry(wh_machine.menu,wh_machine.id,0)
  72. -- end
  73. --end
  74.  
  75. --if not grim.isnewcompiler(path.."\\war3.exe") then
  76. --wh_enablewar3err.cb = setwarmachine
  77. --wh_machine.cb = setwar3err
  78. --end
  79.  
  80. wehack.addmenuseparator(whmenu)
  81.  
  82. usetestmapconf = (grim.getregpair(confregpath,"Use custom test map settings") == "on")
  83. function testmapconfig()
  84. usetestmapconf = wehack.testmapconfig(path,usetestmapconf)
  85. if usetestmapconf then
  86. grim.setregstring(confregpath,"Use custom test map settings","on")
  87. else
  88. grim.setregstring(confregpath,"Use custom test map settings","off")
  89. end
  90. end
  91. wh_configtest = MenuEntry:New(whmenu,"Customize test map settings",testmapconfig);
  92.  
  93. function aboutpopup()
  94. wehack.showaboutdialog("Grimoire 1.5")
  95. end
  96. wh_about = MenuEntry:New(whmenu,"About Grimoire ...",aboutpopup)
  97.  
  98. havejh = grim.exists("jasshelper\\jasshelper.exe")
  99. if havejh then
  100. jhmenu = wehack.addmenu("vJass")
  101. jh_enable = TogMenuEntry:New(jhmenu,"Enable JassHelper",nil,true)
  102. jh_debug = TogMenuEntry:New(jhmenu,"Debug Mode",nil,false)
  103. jh_disable = TogMenuEntry:New(jhmenu,"Disable vJass syntax",nil,false)
  104. jh_disableopt = TogMenuEntry:New(jhmenu,"Disable script optimization",nil,false)
  105. wehack.addmenuseparator(jhmenu)
  106.  
  107. function jhshowerr()
  108. --  if jh_fast ~= nil and jh_fast.checked then
  109. --   wehack.showpreviouserrors();
  110. --  else
  111. wehack.execprocess("jasshelper\\jasshelper.exe --showerrors")
  112. --  end
  113. end
  114.  
  115. function jhabout()
  116. --  if jh_fast ~= nil and jh_fast.checked then
  117. --   wehack.jasshelperabout();
  118. --  else
  119. wehack.execprocess("jasshelper\\jasshelper.exe --about")
  120. --  end
  121. end
  122.  
  123. jhshowerrm = MenuEntry:New(jhmenu,"Show previous errors",jhshowerr)
  124. jhaboutm = MenuEntry:New(jhmenu,"About JassHelper ...",jhabout)
  125. end
  126. -- cJass#1
  127. have_ah = grim.exists("adichelper\\adichelper.exe")
  128. if have_ah then
  129. ah_menu = wehack.addmenu("cJass")
  130. ah_enable = TogMenuEntry:New(ah_menu,"Enable AdicParser",nil,true)
  131. ah_enableopt = TogMenuEntry:New(ah_menu,"Enable AdicOptimizer",nil,true)
  132.  
  133. wehack.addmenuseparator(ah_menu)
  134.  
  135. if (grim.getregpair(confregpath,"First launch passed") ~= "yes") then
  136. ah_firstlaunch = true
  137. end
  138.  
  139. if ah_firstlaunch then
  140. if (wehack.runprocess2("AdicHelper\\AHupdate.exe /ask") == 6) then
  141. ah_enableupdate = true
  142. end
  143.  
  144. grim.setregstring(confregpath,"First launch passed","yes")
  145. if ah_enableupdate then
  146. grim.setregstring(confregpath,"Enable AutoUpdate","on")
  147. else
  148. grim.setregstring(confregpath,"Enable AutoUpdate","off")
  149. end
  150. end
  151.  
  152. ah_enableupdate = TogMenuEntry:New(ah_menu,"Enable AutoUpdate",nil,false)
  153.  
  154. if ah_enableupdate.checked then
  155. wehack.execprocess("adichelper\\AHupdate.exe /silent")
  156. end
  157.  
  158. function ah_execupdate()
  159. wehack.execprocess("adichelper\\AHupdate.exe")
  160. end
  161. ah_update = MenuEntry:New(ah_menu,"Check for updates now",ah_execupdate)
  162.  
  163. wehack.addmenuseparator(ah_menu)
  164.  
  165. function ah_about()
  166. wehack.execprocess("adichelper\\adichelper.exe")
  167. end
  168. ah_aboutm = MenuEntry:New(ah_menu,"About AdicHelper ...",ah_about)
  169.  
  170. end
  171. -- /cJass#1
  172.  
  173. -- Reinventing the Craft
  174. havertc = grim.exists("rtc\\rtcexehack.exe") and grim.exists("rtc\\rcncore.dll")
  175. if havertc then
  176. rtcmenu = wehack.addmenu("RtC")
  177. rtc_enabled = TogMenuEntry:New(rtcmenu, "Enable Reinventing the Craft", nil, true)
  178.  
  179. wehack.addmenuseparator(rtcmenu)
  180. function rtcabout()
  181. wehack.execprocess("rtc\\rtcexehack.exe --about")
  182. end
  183. rtc_about = MenuEntry:New(rtcmenu, "About Reinventing the Craft ...", rtcabout)
  184. else
  185. grim.log("Reinventing the Craft")
  186. if(not grim.exists("rtc\\rtcexehack.exe")) then
  187. grim.log("rtc\\rtcexehack.exe missing!")
  188. end
  189. if(not grim.exists("rtc\\rcncore.dll")) then
  190. grim.log("rtc\\rcncore.dll missing!")
  191. end
  192. end
  193.  
  194. function initshellext()
  195. local first, last = string.find(grim.getregpair("HKEY_CLASSES_ROOT\\WorldEdit.Scenario\\shell\\open\\command\\", ""),"NewGen",1)
  196. if first then
  197. wehack.checkmenuentry(shellext.menu,shellext.id,1)
  198. else
  199. local second, third = string.find(grim.getregpair("HKEY_CLASSES_ROOT\\WorldEdit.Scenario\\shell\\open\\command\\", ""),".bat",1)
  200. if second then
  201. wehack.checkmenuentry(shellext.menu,shellext.id,1)
  202. else
  203. wehack.checkmenuentry(shellext.menu,shellext.id,0)
  204. end
  205. end
  206. end
  207.  
  208. function fixopencommand(disable,warpath,grimpath,filetype)
  209. --local curval = grim.getregpair("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\open\\command\\","")
  210. --if curval ~= 0 then
  211. -- if disable then
  212. -- grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\open\\command\\","",string.gsub(curval, "%%L", "%%1"))
  213. -- else
  214. -- grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\open\\command\\","",string.gsub(curval, "%%1", "%%L"))
  215. -- end
  216. --end
  217.  
  218. local wepath = "\""..grimpath.."\\NewGen WE.exe\""
  219. if not grim.exists(grimpath.."\\NewGen WE.exe") then
  220. wepath = "\""..grimpath.."\\we.bat\""
  221. end
  222. if disable then
  223. grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\open\\command\\","","\""..warpath.."\\World Editor.exe\" -loadfile \"%L\"")
  224. else
  225. grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\open\\command\\","",wepath.." -loadfile \"%L\"")
  226. end
  227. end
  228.  
  229. function registerextension(disable,warpath,grimpath,filetype,istft)
  230. if disable then
  231. grim.deleteregkey("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\fullscreen\\command\\");
  232. grim.deleteregkey("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\fullscreen\\");
  233. grim.deleteregkey("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\windowed\\command\\");
  234. grim.deleteregkey("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\windowed\\");
  235. grim.deleteregkey("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\opengl\\command\\");
  236. grim.deleteregkey("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\opengl\\");
  237. else
  238. --if istft then
  239. -- gamepath = "\""..warpath.."\\Frozen Throne.exe\""
  240. --else
  241. -- gamepath = "\""..warpath.."\\Warcraft III.exe\""
  242. --end
  243. --grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\fullscreen\\","","Play Fullscreen")
  244. --grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\fullscreen\\command\\","",gamepath.." -loadfile \"%L\"")
  245. --grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\windowed\\","","Play Windowed")
  246. --grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\windowed\\command\\","",gamepath.." -window -loadfile \"%L\"")
  247.  
  248. local gamepath = "\""..grimpath.."\\NewGen Warcraft.exe\""
  249. if not grim.exists(grimpath.."\\NewGen Warcraft.exe") then
  250. gamepath = "\""..grimpath.."\\startwar3.bat\""
  251. end
  252. grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\fullscreen\\","","Play Fullscreen")
  253. grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\fullscreen\\command\\","",gamepath.." -loadfile \"%L\"")
  254. grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\windowed\\","","Play Windowed")
  255. grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\windowed\\command\\","",gamepath.." -window -loadfile \"%L\"")
  256. grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\opengl\\","","Play With OpenGL")
  257. grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\opengl\\command\\","",gamepath.." -window -opengl -loadfile \"%L\"")
  258. end
  259. end
  260.  
  261. function toggleshellext()
  262. local istft = (grim.getregpair("HKEY_CURRENT_USER\\Software\\Blizzard Entertainment\\Warcraft III\\", "InstallPathX") ~= 0)
  263. local first, last = string.find(grim.getregpair("HKEY_CLASSES_ROOT\\WorldEdit.Scenario\\shell\\open\\command\\", ""),"NewGen",1)
  264. local found = false
  265. if first then
  266. found = true
  267. else
  268. local second, third = string.find(grim.getregpair("HKEY_CLASSES_ROOT\\WorldEdit.Scenario\\shell\\open\\command\\", ""),".bat",1)
  269. if second then
  270. found = true
  271. end
  272. end
  273.  
  274. if path ~= 0 and grimdir ~= 0 then
  275. fixopencommand(found,path,grimdir,"Scenario")
  276. registerextension(found,path,grimdir,"Scenario",istft)
  277. fixopencommand(found,path,grimdir,"ScenarioEx")
  278. registerextension(found,path,grimdir,"ScenarioEx",istft)
  279. fixopencommand(found,path,grimdir,"Campaign")
  280. registerextension(found,path,grimdir,"Campaign",istft)
  281. fixopencommand(found,path,grimdir,"AIData")
  282. if found then
  283. wehack.checkmenuentry(shellext.menu,shellext.id,0)
  284. else
  285. wehack.checkmenuentry(shellext.menu,shellext.id,1)
  286. end
  287. end
  288. end
  289.  
  290. function initlocalfiles()
  291. if grim.getregpair("HKEY_CURRENT_USER\\Software\\Blizzard Entertainment\\Warcraft III\\", "Allow Local Files") == 0 then
  292. wehack.checkmenuentry(localfiles.menu,localfiles.id,0)
  293. else
  294. wehack.checkmenuentry(localfiles.menu,localfiles.id,1)
  295. end
  296. end
  297.  
  298. function togglelocalfiles()
  299. if grim.getregpair("HKEY_CURRENT_USER\\Software\\Blizzard Entertainment\\Warcraft III\\", "Allow Local Files") == 0 then
  300. grim.setregdword("HKEY_CURRENT_USER\\Software\\Blizzard Entertainment\\Warcraft III\\", "Allow Local Files", 1)
  301. wehack.checkmenuentry(localfiles.menu,localfiles.id,1)
  302. else
  303. grim.setregdword("HKEY_CURRENT_USER\\Software\\Blizzard Entertainment\\Warcraft III\\", "Allow Local Files", 0)
  304. wehack.checkmenuentry(localfiles.menu,localfiles.id,0)
  305. end
  306. end
  307.  
  308. function runobjectmerger(mode)
  309. curmap = wehack.findmappath()
  310. if curmap ~= "" then
  311. source = wehack.openfiledialog("Unit files (*.w3u)|*.w3u|Item files (*.w3t)|*w3t|Doodad files (*.w3d)|*.w3d|Destructable files (*.w3b)|*.w3b|Ability files (*.w3a)|*.w3a|Buff files (*.w3h)|*.w3h|Upgrade files (*.w3q)|*.w3q|", "w3a", "Select files to import ...", true)
  312. grim.log("got in lua: " .. source)
  313. if source ~= "" then
  314. list = strsplit("|", source);
  315. -- cmdargs = "ObjectMerger \""..curmap.."\" "..wehack.getlookupfolders().." "..mode..fileargsjoin(list)
  316. cmdargs = "grimext\\ObjectMerger.exe \""..curmap.."\" "..wehack.getlookupfolders().." "..mode..fileargsjoin(list)
  317. grim.log("assembled cmdline: " .. cmdargs)
  318. -- wehack.messagebox(cmdargs,"Grimoire",false)
  319. wehack.savemap()
  320. grim.log("called saved map")
  321. end
  322. else
  323. showfirstsavewarning()
  324. end
  325. end
  326.  
  327. function runconstantmerger()
  328. curmap = wehack.findmappath()
  329. if curmap ~= "" then
  330. source = wehack.openfiledialog("Text files (*.txt)|*.txt|", "txt", "Select files to import ...", true)
  331. if source ~= "" then
  332. list = strsplit("|", source);
  333. -- cmdargs = "ConstantMerger \""..curmap.."\" "..wehack.getlookupfolders()..fileargsjoin(list)
  334. cmdargs = "grimext\\ConstantMerger.exe \""..curmap.."\" "..wehack.getlookupfolders()..fileargsjoin(list)
  335. -- wehack.messagebox(cmdargs,"Grimoire",false)
  336. wehack.savemap()
  337. end
  338. else
  339. showfirstsavewarning()
  340. end
  341. end
  342.  
  343. function runtriggermerger()
  344. curmap = wehack.findmappath()
  345. if curmap ~= "" then
  346. source = wehack.openfiledialog("GUI Trigger files (*.wtg)|*.wtg|Custom Text Trigger files (*.wct)|*wct|", "wtg", "Select trigger data to import ...", true)
  347. if source ~= "" then
  348. list = strsplit("|", source);
  349. -- cmdargs = "TriggerMerger \""..curmap.."\" "..wehack.getlookupfolders()..fileargsjoin(list)
  350. cmdargs = "grimext\\TriggerMerger.exe \""..curmap.."\" "..wehack.getlookupfolders()..fileargsjoin(list)
  351. -- wehack.messagebox(cmdargs,"Grimoire",false)
  352. wehack.savemap()
  353. end
  354. else
  355. showfirstsavewarning()
  356. end
  357. end
  358.  
  359. function runfileimporterfiles()
  360. curmap = wehack.findmappath()
  361. if curmap ~= "" then
  362. source = wehack.openfiledialog("All files (*.*)|*.*|", "*", "Select files to import ...", true)
  363. if source ~= "" then
  364. list = strsplit("|", source);
  365. inmpqpath = wehack.inputbox("Specify the target path ...","FileImporter","Units\\")
  366. -- cmdargs = "FileImporter \""..curmap.."\" "..wehack.getlookupfolders()..argsjoin(inmpqpath,list)
  367. cmdargs = "grimext\\FileImporter.exe \""..curmap.."\" "..wehack.getlookupfolders()..argsjoin(inmpqpath,list)
  368. -- wehack.messagebox(cmdargs,"Grimoire",false)
  369. wehack.savemap()
  370. end
  371. else
  372. showfirstsavewarning()
  373. end
  374. end
  375.  
  376. function runfileimporterdir()
  377. curmap = wehack.findmappath()
  378. if curmap ~= "" then
  379. source = wehack.browseforfolder("Select the source directory ...")
  380. if source ~= "" then
  381. -- cmdargs = "FileImporter \""..curmap.."\" "..wehack.getlookupfolders().." \""..source.."\""
  382. cmdargs = "grimext\\FileImporter.exe \""..curmap.."\" "..wehack.getlookupfolders().." \""..source.."\""
  383. -- wehack.messagebox(cmdargs,"Grimoire",false)
  384. wehack.savemap()
  385. end
  386. else
  387. showfirstsavewarning()
  388. end
  389. end
  390.  
  391. function runfileexporter()
  392. curmap = wehack.findmappath()
  393. if curmap ~= "" then
  394. target = wehack.browseforfolder("Select the target directory ...")
  395. if target ~= "" then
  396. --   wehack.rungrimextool("FileExporter", curmap, removequotes(wehack.getlookupfolders()), target)
  397. wehack.runprocess("grimext\\FileExporter.exe \""..curmap.."\" "..wehack.getlookupfolders().." \""..target.."\"")
  398. end
  399. else
  400. showfirstsavewarning()
  401. end
  402. end
  403.  
  404. function runtilesetter()
  405. curmap = wehack.findmappath()
  406. if curmap ~= "" then
  407. map = wehack.openarchive(curmap,15)
  408. oldtiles = wehack.getcurrenttiles()
  409. wehack.closearchive(map)
  410. if oldtiles ~= "" then
  411. newtiles = wehack.tilesetconfig(string.sub(oldtiles,1,1), string.sub(oldtiles,2))
  412. if newtiles ~= "" then
  413. tileset = string.sub(newtiles,1,1)
  414. tiles = string.sub(newtiles,2)
  415. if tileset ~= "" and tiles ~= "" then
  416. --        cmdargs = "TileSetter \""..curmap.."\" "..wehack.getlookupfolders().." "..tileset.." "..tiles
  417. cmdargs = "grimext\\TileSetter.exe \""..curmap.."\" "..wehack.getlookupfolders().." "..tileset.." "..tiles
  418. wehack.savemap()
  419. end
  420. end
  421.  
  422. -- tileset = wehack.inputbox("Specify the tileset ...","TileSetter",string.sub(oldtiles,1,1))
  423. -- if tileset ~= "" then
  424. -- tiles = wehack.inputbox("Specify the tile list ...","TileSetter",string.sub(oldtiles,2))
  425. -- if tiles ~= "" then
  426. -- cmdargs = "grimext\\TileSetter.exe \""..curmap.."\" "..wehack.getlookupfolders().." "..tileset.." "..tiles
  427. -- wehack.savemap()
  428. -- end
  429. -- end
  430. end
  431. else
  432. showfirstsavewarning()
  433. end
  434. end
  435.  
  436. function showfirstsavewarning()
  437. if wh_firstsavenag.checked then
  438. return
  439. else
  440. wehack.messagebox("Could not find path to map, please try saving again","Grimoire",false)
  441. end
  442. end
  443.  
  444. function testmap(cmdline)
  445. --if havejh and jh_enable.checked and not mapvalid then
  446. --    return
  447. --end
  448. --wehack.messagebox(cmdline)
  449. --mappath = strsplit(" ",cmdline)[2]
  450. --compilemap_path(mappath)
  451.  
  452. if wh_opengl.checked then
  453. cmdline = cmdline .. " -opengl"
  454. end
  455. if wh_window.checked then
  456. cmdline = cmdline .. " -window"
  457. end
  458. if rtc_enabled and rtc_enabled.checked then
  459. --  local args = string.gsub(cmdline,"\"([^\"]*)\" ","")
  460. --  wehack.messagebox(args,"Grimoire",false)
  461. --  cmdline = "startwar3.bat " .. args
  462.  
  463. local testmaparglist = argsplit(cmdline)
  464. local len = table.getn(testmaparglist)
  465. if len > 2 then
  466. cmdline = "startwar3.bat"
  467. --if not grim.exists(cmdline) then
  468. -- cmdline = "NewGen Warcraft.exe" -- NewGen version doesn't use batch files
  469. --end
  470. for i = 2, len do
  471. if (i < len) and (usetestmapconf) then
  472. local arglen = string.len(testmaparglist[i+1])
  473. if testmaparglist[i] == "-loadfile" and arglen > 3 then
  474. local ext = string.lower(string.sub(testmaparglist[i+1],arglen-4+1))
  475. if ext == ".w3m" or ext == ".w3x" then
  476. local substitute = wehack.setupwgcfile(testmaparglist[i+1]);
  477. if (substitute ~= testmaparglist[i+1]) then
  478. testmaparglist[i+1] = "\"" .. substitute .. "\""
  479. end
  480. end
  481. end
  482. end
  483. cmdline = cmdline .. " " .. testmaparglist[i]
  484. end
  485. end
  486. end
  487. wehack.execprocess(cmdline)
  488. end
  489.  
  490. function compilemap_path(mappath)
  491. if mappath == "" then
  492. showfirstsavewarning()
  493. return
  494. end
  495. map = wehack.openarchive(mappath,15)
  496. wehack.extractfile("jasshelper\\common.j","scripts\\common.j")
  497. wehack.extractfile("jasshelper\\Blizzard.j","scripts\\Blizzard.j")
  498. wehack.extractfile("war3map.j","war3map.j")
  499. wehack.closearchive(map)
  500. if cmdargs ~= "" then
  501. local cmdtable = argsplit(cmdargs)
  502. --  local len = table.getn(cmdtable)
  503. --  for i = 1, len do
  504. --   cmdtable[i] = removequotes(cmdtable[i])
  505. --  end
  506. --  wehack.rungrimextool(cmdtable)
  507. grim.log("running tool on save: "..cmdargs)
  508. wehack.runprocess(cmdargs)
  509. cmdargs = ""
  510. end
  511.  
  512. -- fly-data
  513. fly_preprocess(mappath)
  514. -- /fly-data
  515.  
  516. -- cJass#2
  517. if have_ah and ah_enable.checked then
  518. cmdline = "AdicHelper\\AdicHelper.exe"
  519. if jh_debug.checked then
  520. cmdline = cmdline .. " /dbg"
  521. end
  522. cmdline = cmdline .. " /mappars=\"" .. mappath.."\""
  523. adicresult = wehack.runprocess2(cmdline)
  524. if adicresult == 1 then
  525. mapvalid = false
  526. return
  527. end
  528. end
  529. -- /cJass#2
  530. if havejh and jh_enable.checked then
  531. cmdline = "jasshelper\\jasshelper.exe"
  532. if jh_debug.checked then
  533. cmdline = cmdline .. " --debug"
  534. end
  535. if jh_disable.checked then
  536. cmdline = cmdline .. " --nopreprocessor"
  537. end
  538. if jh_disableopt.checked then
  539. cmdline = cmdline .. " --nooptimize"
  540. end
  541. cmdline = cmdline .. " jasshelper\\common.j jasshelper\\blizzard.j \"" .. mappath .."\""
  542. toolresult = 0
  543. --  if jh_fast ~= nil and jh_fast.checked then
  544. --   toolresult = wehack.runjasshelper(jh_debug.checked, jh_disable.checked, "jasshelper\\common.j", "jasshelper\\blizzard.j", mappath, "")
  545. --  else
  546. toolresult = wehack.runprocess2(cmdline)
  547. --  end
  548. if toolresult == 0 then
  549. -- cJass#3
  550. if have_ah and ah_enableopt.checked then
  551. wehack.runprocess2("AdicHelper\\AdicHelper.exe /mapoptz=\"" .. mappath.."\"")
  552. end
  553. -- /cJass#3
  554. mapvalid = true
  555. else
  556. mapvalid = false
  557. end
  558. end
  559. end
  560.  
  561. dofile("ScExp\\ScExp.lua")
  562.  
  563. dofile("fly\\fly.lua")
  564.  
  565. function compilemap()
  566. mappath = wehack.findmappath()
  567. if mappath == "" then
  568. scexpBuildCampaign()
  569. else
  570. compilemap_path(mappath)
  571. end
  572. end
  573.  
  574. if haveext then
  575. localfiles = MenuEntry:New(utils,"Enable Local Files",togglelocalfiles)
  576. shellext = MenuEntry:New(utils,"Register Shell Extensions",toggleshellext)
  577. initlocalfiles()
  578. initshellext()
  579. wehack.addmenuseparator(utils)
  580. end
  581. if haveext and grim.exists("grimext\\tilesetter.exe") then
  582. tilesetter = MenuEntry:New(utils,"Edit Tileset",runtilesetter)
  583. end
  584. if haveext and grim.exists("grimext\\fileexporter.exe") then
  585. fileexporter = MenuEntry:New(utils,"Export Files",runfileexporter)
  586. end
  587. if haveext and grim.exists("grimext\\fileimporter.exe") then
  588. fileimporterdir = MenuEntry:New(utils,"Import Directory",runfileimporterdir)
  589. fileimporterfiles = MenuEntry:New(utils,"Import Files",runfileimporterfiles)
  590. end
  591. if haveext and grim.exists("grimext\\objectmerger.exe") then
  592. objectmerger = MenuEntry:New(utils,"Merge Object Editor Data",function(self) runobjectmerger("m") end)
  593. objectreplacer = MenuEntry:New(utils,"Replace Object Editor Data",function(self) runobjectmerger("r") end)
  594. objectimporter = MenuEntry:New(utils,"Import Object Editor Data",function(self) runobjectmerger("i") end)
  595. end
  596. if haveext and grim.exists("grimext\\constantmerger.exe") then
  597. constantmerger = MenuEntry:New(utils,"Merge Constants Data",runconstantmerger)
  598. end
  599. if haveext and grim.exists("grimext\\triggermerger.exe") then
  600. triggermerger = MenuEntry:New(utils,"Merge Trigger Data",runtriggermerger)
  601. end
  602.  
  603. function extabout()
  604. grim.openlink("http://www.wc3campaigns.net")
  605. end
  606. if haveext then
  607. wehack.addmenuseparator(utils)
  608. aboutextensions = MenuEntry:New(utils,"About Grimex ...",extabout)
  609. end
  610.  
  611. if haveumswe then
  612. ums_enabled = TogMenuEntry:New(ums,"Enable UMSWE",nil,false)
  613. ums_cat = TogMenuEntry:New(ums,"Custom Editor Categories",nil,false)
  614. ums_til = TogMenuEntry:New(ums,"Non Tileset Specific Objects",nil,false)
  615. ums_pat = TogMenuEntry:New(ums,"Custom Tile Pathability",nil,false)
  616.  
  617. function unloadumswe()
  618. local umswehandle = wehack.getarchivehandle("umswe\\umswe.mpq")
  619. if umswehandle ~= 0 then
  620. wehack.closearchive(umswehandle)
  621. wehack.setarchivehandle("umswe\\umswe.mpq", 0)
  622. end
  623. end
  624.  
  625. function getumsweargs()
  626. local umsargs = "";
  627. if (ums_enabled.checked) then
  628. umsargs = umsargs .. " umscore=1"
  629. else
  630. umsargs = umsargs .. " umscore=0"
  631. end
  632. if (ums_cat.checked) then
  633. umsargs = umsargs .. " umscategories=1"
  634. else
  635. umsargs = umsargs .. " umscategories=0"
  636. end
  637. if (ums_til.checked) then
  638. umsargs = umsargs .. " umstiles=1"
  639. else
  640. umsargs = umsargs .. " umstiles=0"
  641. end
  642. if (ums_pat.checked) then
  643. umsargs = umsargs .. " umspathing=1"
  644. else
  645. umsargs = umsargs .. " umspathing=0"
  646. end
  647. return umsargs
  648. end
  649.  
  650. function toggleumswe()
  651. if not isstartup then
  652. unloadumswe()
  653. wehack.setwaitcursor(true)
  654. wehack.runprocess("grimext\\PatchGenerator.exe umswe\\umswecore.lua "..wehack.getlookupfolders().." umswe"..getumsweargs())
  655. wehack.setwaitcursor(false)
  656. end
  657. end
  658.  
  659. function toggleumswecat()
  660. if ums_enabled.checked and not isstartup then
  661. unloadumswe()
  662. wehack.setwaitcursor(true)
  663. wehack.runprocess("grimext\\PatchGenerator.exe umswe\\umswecategories.lua "..wehack.getlookupfolders().." umswe"..getumsweargs())
  664. wehack.setwaitcursor(false)
  665. end
  666. end
  667.  
  668. function toggleumswetil()
  669. if ums_enabled.checked and not isstartup then
  670. unloadumswe()
  671. wehack.setwaitcursor(true)
  672. wehack.runprocess("grimext\\PatchGenerator.exe umswe\\umswetilesets.lua "..wehack.getlookupfolders().." umswe"..getumsweargs())
  673. wehack.setwaitcursor(false)
  674. end
  675. end
  676.  
  677. function toggleumswepat(newstate)
  678. if ums_enabled.checked and not isstartup then
  679. unloadumswe()
  680. wehack.setwaitcursor(true)
  681. wehack.runprocess("grimext\\PatchGenerator.exe umswe\\umswepathing.lua "..wehack.getlookupfolders().." umswe"..getumsweargs())
  682. wehack.setwaitcursor(false)
  683. end
  684. end
  685.  
  686. ums_enabled.cb = toggleumswe
  687. ums_cat.cb = toggleumswecat
  688. ums_til.cb = toggleumswetil
  689. ums_pat.cb = toggleumswepat
  690.  
  691. function categoryconfig()
  692. if wehack.showcategorydialog("umswe\\umswecategories.conf.lua") and ums_enabled.checked then
  693. if ums_cat.checked then
  694. unloadumswe()
  695. wehack.setwaitcursor(true)
  696. wehack.runprocess("grimext\\PatchGenerator.exe umswe\\umswecategories.lua "..wehack.getlookupfolders().." umswe"..getumsweargs())
  697. wehack.setwaitcursor(false)
  698. end
  699. end
  700. end
  701.  
  702. function pathabilityconfig()
  703. unloadumswe()
  704. if wehack.showpathdialog("umswe\\umswepathing.conf.lua","umswe\\umswe.mpq") and ums_enabled.checked then
  705. if ums_pat.checked then
  706. wehack.setwaitcursor(true)
  707. wehack.runprocess("grimext\\PatchGenerator.exe umswe\\umswepathing.lua "..wehack.getlookupfolders().." umswe"..getumsweargs())
  708. wehack.setwaitcursor(false)
  709. end
  710. end
  711. end
  712.  
  713. function umsweabout()
  714. wehack.showumsweabout("UMSWE 5.0")
  715. end
  716.  
  717. wehack.addmenuseparator(ums)
  718. ums_catconf = MenuEntry:New(ums,"Customize Editor Categories",categoryconfig)
  719. ums_pathconf = MenuEntry:New(ums,"Customize Tile Pathability",pathabilityconfig)
  720. ums_about = MenuEntry:New(ums,"About UMSWE ...",umsweabout)
  721.  
  722. end
  723.  
  724. isstartup = false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement