Advertisement
Guest User

Untitled

a guest
Aug 10th, 2011
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 23.31 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.  
  31. whmenu = wehack.addmenu("Grimoire")
  32. wh_window = TogMenuEntry:New(whmenu,"Start War3 with -window",nil,true)
  33. wh_opengl = TogMenuEntry:New(whmenu,"Start War3 with -opengl",nil,false)
  34. if not grim.isnewcompiler(path.."\\war3.exe") then
  35.   wh_grimoire = TogMenuEntry:New(whmenu,"Start War3 with Grimoire",nil,true)
  36.   wh_enablewar3err = TogMenuEntry:New(whmenu,"Enable war3err",nil,true)
  37.   --wh_machine = TogMenuEntry:New(whmenu,"Enable warmachine",nil,false)
  38. end
  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. weukey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\WE Unlimited_is1"
  82. weuval = "InstallLocation"
  83. weupath = grim.getregpair(weukey,weuval)
  84. haveweu = grim.exists(weupath .. "WE Unlimited.exe")
  85. if haveweu then
  86.     wh_useweu = TogMenuEntry:New(whmenu,"Integrate WEU",nil,false)
  87. end
  88.  
  89. usetestmapconf = (grim.getregpair(confregpath,"Use custom test map settings") == "on")
  90. function testmapconfig()
  91.     usetestmapconf = wehack.testmapconfig(path,usetestmapconf)
  92.     if usetestmapconf then
  93.         grim.setregstring(confregpath,"Use custom test map settings","on")
  94.     else
  95.         grim.setregstring(confregpath,"Use custom test map settings","off")
  96.     end
  97. end
  98. wh_configtest = MenuEntry:New(whmenu,"Customize test map settings",testmapconfig);
  99.  
  100. function attachdebugger()
  101.     wehack.execprocess("w3jdebug\\pyw3jdebug.exe")
  102. end
  103. havedebugger = grim.exists("w3jdebug\\pyw3jdebug.exe")
  104. if havedebugger then
  105.     wh_debug = MenuEntry:New(whmenu,"Attach debugger",attachdebugger)
  106. end
  107.  
  108. function aboutpopup()
  109.     wehack.showaboutdialog("Grimoire 1.5")
  110. end
  111. wh_about = MenuEntry:New(whmenu,"About Grimoire ...",aboutpopup)
  112.  
  113. havejh = grim.exists("jasshelper\\jasshelper.exe")
  114. if havejh then
  115.     jhmenu = wehack.addmenu("JassHelper")
  116.     jh_enable = TogMenuEntry:New(jhmenu,"Enable JassHelper",nil,true)
  117.     jh_debug = TogMenuEntry:New(jhmenu,"Debug Mode",nil,false)
  118.     jh_disable = TogMenuEntry:New(jhmenu,"Disable vJass syntax",nil,false)
  119.   jh_disableopt = TogMenuEntry:New(jhmenu,"Disable script optimization",nil,false)
  120. --  if grim.exists("jasshelper\\jasshelper.dll") then
  121. --      jh_fast = TogMenuEntry:New(jhmenu,"Fast external evaluation",nil,true)
  122. --  else
  123. --    jh_fast = nil
  124. --  end
  125.     wehack.addmenuseparator(jhmenu)
  126.    
  127.     function jhshowerr()
  128. --      if jh_fast ~= nil and jh_fast.checked then
  129. --          wehack.showpreviouserrors();
  130. --      else
  131.         wehack.execprocess("jasshelper\\jasshelper.exe --showerrors")
  132. --    end
  133.     end
  134.    
  135.     function jhabout()
  136. --      if jh_fast ~= nil and jh_fast.checked then
  137. --          wehack.jasshelperabout();
  138. --      else
  139.         wehack.execprocess("jasshelper\\jasshelper.exe --about")
  140. --    end
  141.     end
  142.    
  143.   jhshowerrm = MenuEntry:New(jhmenu,"Show previous errors",jhshowerr)
  144.   jhaboutm = MenuEntry:New(jhmenu,"About JassHelper ...",jhabout)
  145. end
  146. -- cJass#1
  147. have_ah = grim.exists("adichelper\\adichelper.exe")
  148. if have_ah then
  149.     ah_menu = wehack.addmenu("cJass")
  150.     ah_enable = TogMenuEntry:New(ah_menu,"Enable AdicParser",nil,true)
  151.     ah_enableopt = TogMenuEntry:New(ah_menu,"Enable AdicOptimizer",nil,true)
  152.  
  153.     -- Flags
  154.  
  155.     wehack.addmenuseparator(ah_menu)
  156.  
  157.     ah_opt_remove = TogMenuEntry:New(ah_menu,"Remove unused code",nil,true)
  158.     ah_alf_flag = TogMenuEntry:New(ah_menu,"Locals auto flush",nil,true)
  159.     ah_igno_cjbj = TogMenuEntry:New(ah_menu,"Compile for default cj and bj",nil,true)
  160.  
  161.     -- Game version switch
  162.     wehack.addmenuseparator(ah_menu)
  163.  
  164.     ah_version = MenuEntryGroup:New(ah_menu,"Game version switch")
  165.  
  166.     ah_ver23m = SwitchMenuEntry:New(ah_version,"Compile for game version 1.23")
  167.     ah_ver24m = SwitchMenuEntry:New(ah_version,"Compile for game version 1.24+",true)
  168.  
  169.     -- Updater items
  170.  
  171.     wehack.addmenuseparator(ah_menu)
  172.  
  173.     if (grim.getregpair(confregpath,"First launch passed") ~= "yes") then
  174.         ah_firstlaunch = true
  175.     end
  176.  
  177.     if ah_firstlaunch then
  178.         if (wehack.runprocess2("AdicHelper\\AHupdate.exe /ask") == 6) then
  179.             ah_enableupdate = true
  180.         end
  181.  
  182.         grim.setregstring(confregpath,"First launch passed","yes")
  183.         if ah_enableupdate then
  184.             grim.setregstring(confregpath,"Enable AutoUpdate","on")
  185.         else
  186.             grim.setregstring(confregpath,"Enable AutoUpdate","off")
  187.         end
  188.     end
  189.  
  190.     ah_enableupdate = TogMenuEntry:New(ah_menu,"Enable AutoUpdate",nil,false)
  191.  
  192.     if ah_enableupdate.checked then
  193.         wehack.execprocess("adichelper\\AHupdate.exe /silent")
  194.     end
  195.  
  196.     ah_update = MenuEntry:New(ah_menu,"Check for updates now", function() wehack.execprocess("adichelper\\AHupdate.exe") end)
  197.     ah_updateopt = MenuEntry:New(ah_menu,"AutoUpdate settings", function() wehack.runprocess2("adichelper\\AHupdate.exe /options") end)
  198.  
  199.     -- About box
  200.  
  201.     wehack.addmenuseparator(ah_menu)
  202.     ah_aboutm = MenuEntry:New(ah_menu,"About AdicHelper ...",function() wehack.execprocess("adichelper\\adichelper.exe") end)
  203.  
  204. end
  205. -- /cJass#1
  206.  
  207. -- Reinventing the Craft
  208. -- Removed
  209.  
  210. function initshellext()
  211.     local first, last = string.find(grim.getregpair("HKEY_CLASSES_ROOT\\WorldEdit.Scenario\\shell\\open\\command\\", ""),"NewGen",1)
  212.     if first then
  213.         wehack.checkmenuentry(shellext.menu,shellext.id,1)
  214.     else
  215.             local second, third = string.find(grim.getregpair("HKEY_CLASSES_ROOT\\WorldEdit.Scenario\\shell\\open\\command\\", ""),".bat",1)
  216.             if second then
  217.                 wehack.checkmenuentry(shellext.menu,shellext.id,1)
  218.             else
  219.             wehack.checkmenuentry(shellext.menu,shellext.id,0)
  220.         end
  221.     end
  222. end
  223.  
  224. function fixopencommand(disable,warpath,grimpath,filetype)
  225.     --local curval = grim.getregpair("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\open\\command\\","")
  226.     --if curval ~= 0 then
  227.     --    if disable then
  228.     --        grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\open\\command\\","",string.gsub(curval, "%%L", "%%1"))
  229.     --    else
  230.     --        grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\open\\command\\","",string.gsub(curval, "%%1", "%%L"))
  231.     --    end
  232.     --end
  233.    
  234.     local wepath = "\""..grimpath.."\\NewGen WE.exe\""
  235.     if not grim.exists(grimpath.."\\NewGen WE.exe") then
  236.       wepath = "\""..grimpath.."\\we.bat\""
  237.     end
  238.     if disable then
  239.         grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\open\\command\\","","\""..warpath.."\\World Editor.exe\" -loadfile \"%L\"")
  240.     else
  241.         grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\open\\command\\","",wepath.." -loadfile \"%L\"")
  242.     end
  243. end
  244.  
  245. function registerextension(disable,warpath,grimpath,filetype,istft)
  246.     if disable then
  247.         grim.deleteregkey("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\fullscreen\\command\\");
  248.         grim.deleteregkey("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\fullscreen\\");
  249.         grim.deleteregkey("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\windowed\\command\\");
  250.         grim.deleteregkey("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\windowed\\");
  251.         grim.deleteregkey("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\opengl\\command\\");
  252.         grim.deleteregkey("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\opengl\\");
  253.     else
  254.         --if istft then
  255.         --    gamepath = "\""..warpath.."\\Frozen Throne.exe\""
  256.         --else
  257.         --    gamepath = "\""..warpath.."\\Warcraft III.exe\""
  258.         --end
  259.         --grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\fullscreen\\","","Play Fullscreen")
  260.         --grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\fullscreen\\command\\","",gamepath.." -loadfile \"%L\"")
  261.         --grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\windowed\\","","Play Windowed")
  262.         --grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\windowed\\command\\","",gamepath.." -window -loadfile \"%L\"")
  263.  
  264.         local gamepath = "\""..grimpath.."\\NewGen Warcraft.exe\""
  265.         if not grim.exists(grimpath.."\\NewGen Warcraft.exe") then
  266.             gamepath = "\""..grimpath.."\\startwar3.bat\""
  267.           end
  268.         grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\fullscreen\\","","Play Fullscreen")
  269.         grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\fullscreen\\command\\","",gamepath.." -loadfile \"%L\"")
  270.         grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\windowed\\","","Play Windowed")
  271.         grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\windowed\\command\\","",gamepath.." -window -loadfile \"%L\"")
  272.         grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\opengl\\","","Play With OpenGL")
  273.         grim.setregstring("HKEY_CLASSES_ROOT\\WorldEdit."..filetype.."\\shell\\opengl\\command\\","",gamepath.." -window -opengl -loadfile \"%L\"")
  274.     end
  275. end
  276.  
  277. function toggleshellext()
  278.     local istft = (grim.getregpair("HKEY_CURRENT_USER\\Software\\Blizzard Entertainment\\Warcraft III\\", "InstallPathX") ~= 0)
  279.     local first, last = string.find(grim.getregpair("HKEY_CLASSES_ROOT\\WorldEdit.Scenario\\shell\\open\\command\\", ""),"NewGen",1)
  280.     local found = false
  281.     if first then
  282.         found = true
  283.     else
  284.             local second, third = string.find(grim.getregpair("HKEY_CLASSES_ROOT\\WorldEdit.Scenario\\shell\\open\\command\\", ""),".bat",1)
  285.             if second then
  286.                 found = true
  287.             end
  288.     end
  289.  
  290.     if path ~= 0 and grimdir ~= 0 then
  291.         fixopencommand(found,path,grimdir,"Scenario")
  292.         registerextension(found,path,grimdir,"Scenario",istft)
  293.         fixopencommand(found,path,grimdir,"ScenarioEx")
  294.         registerextension(found,path,grimdir,"ScenarioEx",istft)
  295.         fixopencommand(found,path,grimdir,"Campaign")
  296.         registerextension(found,path,grimdir,"Campaign",istft)
  297.         fixopencommand(found,path,grimdir,"AIData")
  298.         if found then
  299.             wehack.checkmenuentry(shellext.menu,shellext.id,0)
  300.         else
  301.             wehack.checkmenuentry(shellext.menu,shellext.id,1)
  302.         end
  303.     end
  304. end
  305.  
  306. function initlocalfiles()
  307.     if grim.getregpair("HKEY_CURRENT_USER\\Software\\Blizzard Entertainment\\Warcraft III\\", "Allow Local Files") == 0 then
  308.         wehack.checkmenuentry(localfiles.menu,localfiles.id,0)
  309.     else
  310.         wehack.checkmenuentry(localfiles.menu,localfiles.id,1)
  311.     end
  312. end
  313.  
  314. function togglelocalfiles()
  315.     if grim.getregpair("HKEY_CURRENT_USER\\Software\\Blizzard Entertainment\\Warcraft III\\", "Allow Local Files") == 0 then
  316.         grim.setregdword("HKEY_CURRENT_USER\\Software\\Blizzard Entertainment\\Warcraft III\\", "Allow Local Files", 1)
  317.         wehack.checkmenuentry(localfiles.menu,localfiles.id,1)
  318.     else
  319.         grim.setregdword("HKEY_CURRENT_USER\\Software\\Blizzard Entertainment\\Warcraft III\\", "Allow Local Files", 0)
  320.         wehack.checkmenuentry(localfiles.menu,localfiles.id,0)
  321.     end
  322. end
  323.  
  324. function runobjectmerger(mode)
  325.     curmap = wehack.findmappath()
  326.     if curmap ~= "" then
  327.         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)
  328. grim.log("got in lua: " .. source)
  329.         if source ~= "" then
  330.             list = strsplit("|", source);
  331. --            cmdargs = "ObjectMerger \""..curmap.."\" "..wehack.getlookupfolders().." "..mode..fileargsjoin(list)        
  332.             cmdargs = "grimext\\ObjectMerger.exe \""..curmap.."\" "..wehack.getlookupfolders().." "..mode..fileargsjoin(list)
  333. grim.log("assembled cmdline: " .. cmdargs)
  334. --            wehack.messagebox(cmdargs,"Grimoire",false)
  335.             wehack.savemap()
  336. grim.log("called saved map")
  337.         end
  338.     else
  339.         showfirstsavewarning()
  340.     end
  341. end
  342.  
  343. function runconstantmerger()
  344.     curmap = wehack.findmappath()
  345.     if curmap ~= "" then
  346.         source = wehack.openfiledialog("Text files (*.txt)|*.txt|", "txt", "Select files to import ...", true)
  347.         if source ~= "" then
  348.             list = strsplit("|", source);
  349. --            cmdargs = "ConstantMerger \""..curmap.."\" "..wehack.getlookupfolders()..fileargsjoin(list)
  350.             cmdargs = "grimext\\ConstantMerger.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 runtriggermerger()
  360.     curmap = wehack.findmappath()
  361.     if curmap ~= "" then
  362.         source = wehack.openfiledialog("GUI Trigger files (*.wtg)|*.wtg|Custom Text Trigger files (*.wct)|*wct|", "wtg", "Select trigger data to import ...", true)
  363.         if source ~= "" then
  364.             list = strsplit("|", source);
  365. --            cmdargs = "TriggerMerger \""..curmap.."\" "..wehack.getlookupfolders()..fileargsjoin(list)
  366.             cmdargs = "grimext\\TriggerMerger.exe \""..curmap.."\" "..wehack.getlookupfolders()..fileargsjoin(list)
  367. --            wehack.messagebox(cmdargs,"Grimoire",false)
  368.             wehack.savemap()
  369.         end
  370.     else
  371.         showfirstsavewarning()
  372.     end
  373. end
  374.  
  375. function runfileimporterfiles()
  376.     curmap = wehack.findmappath()
  377.     if curmap ~= "" then
  378.         source = wehack.openfiledialog("All files (*.*)|*.*|", "*", "Select files to import ...", true)
  379.         if source ~= "" then
  380.             list = strsplit("|", source);
  381.             inmpqpath = wehack.inputbox("Specify the target path ...","FileImporter","Units\\")
  382. --            cmdargs = "FileImporter \""..curmap.."\" "..wehack.getlookupfolders()..argsjoin(inmpqpath,list)
  383.             cmdargs = "grimext\\FileImporter.exe \""..curmap.."\" "..wehack.getlookupfolders()..argsjoin(inmpqpath,list)
  384. --            wehack.messagebox(cmdargs,"Grimoire",false)
  385.             wehack.savemap()
  386.         end
  387.     else
  388.         showfirstsavewarning()
  389.     end
  390. end
  391.  
  392. function runfileimporterdir()
  393.     curmap = wehack.findmappath()
  394.     if curmap ~= "" then
  395.         source = wehack.browseforfolder("Select the source directory ...")
  396.         if source ~= "" then
  397. --            cmdargs = "FileImporter \""..curmap.."\" "..wehack.getlookupfolders().." \""..source.."\""
  398.             cmdargs = "grimext\\FileImporter.exe \""..curmap.."\" "..wehack.getlookupfolders().." \""..source.."\""
  399. --            wehack.messagebox(cmdargs,"Grimoire",false)
  400.             wehack.savemap()
  401.         end
  402.     else
  403.         showfirstsavewarning()
  404.     end
  405. end
  406.  
  407. function runfileexporter()
  408.     curmap = wehack.findmappath()
  409.     if curmap ~= "" then
  410.         target = wehack.browseforfolder("Select the target directory ...")
  411.         if target ~= "" then
  412. --              wehack.rungrimextool("FileExporter", curmap, removequotes(wehack.getlookupfolders()), target)
  413.             wehack.runprocess("grimext\\FileExporter.exe \""..curmap.."\" "..wehack.getlookupfolders().." \""..target.."\"")
  414.         end
  415.     else
  416.         showfirstsavewarning()
  417.     end
  418. end
  419.  
  420. function runtilesetter()
  421.     curmap = wehack.findmappath()
  422.     if curmap ~= "" then
  423.         map = wehack.openarchive(curmap,15)
  424.         oldtiles = wehack.getcurrenttiles()
  425.         wehack.closearchive(map)
  426.         if oldtiles ~= "" then
  427.                 newtiles = wehack.tilesetconfig(string.sub(oldtiles,1,1), string.sub(oldtiles,2))
  428.                 if newtiles ~= "" then
  429.                     tileset = string.sub(newtiles,1,1)
  430.                     tiles = string.sub(newtiles,2)
  431.                             if tileset ~= "" and tiles ~= "" then
  432. --                              cmdargs = "TileSetter \""..curmap.."\" "..wehack.getlookupfolders().." "..tileset.." "..tiles
  433.                                 cmdargs = "grimext\\TileSetter.exe \""..curmap.."\" "..wehack.getlookupfolders().." "..tileset.." "..tiles
  434.                                 wehack.savemap()
  435.                     end
  436.                 end
  437.                
  438. --            tileset = wehack.inputbox("Specify the tileset ...","TileSetter",string.sub(oldtiles,1,1))
  439. --            if tileset ~= "" then
  440. --                tiles = wehack.inputbox("Specify the tile list ...","TileSetter",string.sub(oldtiles,2))
  441. --                if tiles ~= "" then
  442. --                    cmdargs = "grimext\\TileSetter.exe \""..curmap.."\" "..wehack.getlookupfolders().." "..tileset.." "..tiles
  443. --                    wehack.savemap()
  444. --                end
  445. --            end
  446.         end
  447.     else
  448.         showfirstsavewarning()
  449.     end
  450. end
  451.  
  452. function showfirstsavewarning()
  453.     if wh_firstsavenag.checked then
  454.         return
  455.     else
  456.         wehack.messagebox("Could not find path to map, please try saving again","Grimoire",false)
  457.     end
  458. end
  459.  
  460. function testmap(cmdline)
  461.     --if havejh and jh_enable.checked and not mapvalid then
  462.     --  return
  463.     --end
  464.     --wehack.messagebox(cmdline)
  465.     --mappath = strsplit(" ",cmdline)[2]
  466.     --compilemap_path(mappath)
  467.    
  468.     if wh_opengl.checked then
  469.         cmdline = cmdline .. " -opengl"
  470.     end
  471.     if wh_window.checked then
  472.         cmdline = cmdline .. " -window"
  473.     end
  474.     wehack.execprocess(cmdline)
  475. end
  476.  
  477. function compilemap_path(mappath)
  478.     if mappath == "" then
  479.         showfirstsavewarning()
  480.         return
  481.     end
  482.     map = wehack.openarchive(mappath,15)
  483.     wehack.extractfile("jasshelper\\common.j","scripts\\common.j")
  484.     wehack.extractfile("jasshelper\\Blizzard.j","scripts\\Blizzard.j")
  485.     wehack.extractfile("war3map.j","war3map.j")
  486.     wehack.closearchive(map)
  487.     if cmdargs ~= "" then
  488.         local cmdtable = argsplit(cmdargs)
  489. --      local len = table.getn(cmdtable)
  490. --      for i = 1, len do
  491. --          cmdtable[i] = removequotes(cmdtable[i])
  492. --      end
  493. --      wehack.rungrimextool(cmdtable)
  494. grim.log("running tool on save: "..cmdargs)
  495.         wehack.runprocess(cmdargs)
  496.         cmdargs = ""
  497.     end
  498. -- cJass#2
  499.     if have_ah and ah_enable.checked then
  500.         cmdline = "AdicHelper\\AdicHelper.exe /tmcrpre=\""..grimdir.."\\jasshelper\\clijasshelper.exe\" "
  501.         if ah_version.checked == 1 then
  502.             cmdline = cmdline .. " /v23"
  503.         else
  504.             cmdline = cmdline .. " /v24"
  505.         end
  506.         if jh_debug.checked then
  507.             cmdline = cmdline .. " /dbg"
  508.         end
  509.         if ah_alf_flag.checked then
  510.             cmdline = cmdline .. " /alf"
  511.         end
  512.         if ah_igno_cjbj.checked then
  513.             cmdline = cmdline .. " /ibj=\"0\" /icj=\"0\""
  514.         end
  515.         cmdline = cmdline .. " /mappars=\"" .. mappath.."\""
  516.         adicresult = wehack.runprocess2(cmdline)
  517.         if adicresult == 1 then
  518.             mapvalid = false
  519.             return
  520.         end
  521.     end
  522. -- /cJass#2
  523.     if havejh and jh_enable.checked then
  524.         cmdline = "jasshelper\\jasshelper.exe"
  525.         if jh_debug.checked then
  526.             cmdline = cmdline .. " --debug"
  527.         end
  528.         if jh_disable.checked then
  529.             cmdline = cmdline .. " --nopreprocessor"
  530.         end
  531.         if jh_disableopt.checked then
  532.             cmdline = cmdline .. " --nooptimize"
  533.         end
  534.         cmdline = cmdline .. " jasshelper\\common.j jasshelper\\blizzard.j \"" .. mappath .."\""
  535.         toolresult = 0
  536. --      if jh_fast ~= nil and jh_fast.checked then
  537. --          toolresult = wehack.runjasshelper(jh_debug.checked, jh_disable.checked, "jasshelper\\common.j", "jasshelper\\blizzard.j", mappath, "")
  538. --      else
  539.             toolresult = wehack.runprocess2(cmdline)
  540. --      end
  541.         if toolresult == 0 then
  542. -- cJass#3
  543.             if have_ah and ah_enableopt.checked then
  544.                 cmdline = "AdicHelper\\AdicHelper.exe"
  545.                 if not ah_opt_remove.checked then
  546.                     cmdline = cmdline .. " /nop"
  547.                 end
  548.                 cmdline = cmdline .. " /mapoptz=\"" .. mappath.."\""
  549.                 wehack.runprocess2(cmdline)
  550.             end
  551. -- /cJass#3
  552.             mapvalid = true
  553.         else
  554.             mapvalid = false
  555.         end
  556.     end
  557. end
  558.  
  559. function compilemap()
  560.     mappath = wehack.findmappath()
  561.     compilemap_path(mappath)
  562. end
  563.  
  564. if haveext then
  565.     localfiles = MenuEntry:New(utils,"Enable Local Files",togglelocalfiles)
  566.     shellext = MenuEntry:New(utils,"Register Shell Extensions",toggleshellext)
  567.     initlocalfiles()
  568.     initshellext()
  569.     wehack.addmenuseparator(utils)
  570. end
  571. if haveext and grim.exists("grimext\\tilesetter.exe") then
  572.     tilesetter = MenuEntry:New(utils,"Edit Tileset",runtilesetter)
  573. end
  574. if haveext and grim.exists("grimext\\fileexporter.exe") then
  575.     fileexporter = MenuEntry:New(utils,"Export Files",runfileexporter)
  576. end
  577. if haveext and grim.exists("grimext\\fileimporter.exe") then
  578.     fileimporterdir = MenuEntry:New(utils,"Import Directory",runfileimporterdir)
  579.     fileimporterfiles = MenuEntry:New(utils,"Import Files",runfileimporterfiles)
  580. end
  581. if haveext and grim.exists("grimext\\objectmerger.exe") then
  582.     objectmerger = MenuEntry:New(utils,"Merge Object Editor Data",function(self) runobjectmerger("m") end)
  583.     objectreplacer = MenuEntry:New(utils,"Replace Object Editor Data",function(self) runobjectmerger("r") end)
  584.     objectimporter = MenuEntry:New(utils,"Import Object Editor Data",function(self) runobjectmerger("i") end)
  585. end
  586. if haveext and grim.exists("grimext\\constantmerger.exe") then
  587.     constantmerger = MenuEntry:New(utils,"Merge Constants Data",runconstantmerger)
  588. end
  589. if haveext and grim.exists("grimext\\triggermerger.exe") then
  590.     triggermerger = MenuEntry:New(utils,"Merge Trigger Data",runtriggermerger)
  591. end
  592.  
  593. function extabout()
  594.     grim.openlink("http://www.wc3campaigns.net")
  595. end
  596. if haveext then
  597.     wehack.addmenuseparator(utils)
  598.   aboutextensions = MenuEntry:New(utils,"About Grimex ...",extabout)
  599. end
  600.  
  601. isstartup = false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement