script.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. var $ = require('jQuery');
  2. const remote = require('electron').remote
  3. const shell = require('electron').shell
  4. const path = require('path')
  5. /* Open web links in the user's default browser. */
  6. $(document).on('click', 'a[href^="http"]', function(event) {
  7. event.preventDefault();
  8. //testdownloads()
  9. shell.openExternal(this.href)
  10. });
  11. testdownloads = async function(){
  12. const ag = require(path.join(__dirname, 'assets', 'js', 'assetguard.js'))
  13. const lp = require(path.join(__dirname, 'assets', 'js', 'launchprocess.js'))
  14. const basePath = path.join(__dirname, '..', 'mcfiles')
  15. let versionData = await ag.loadVersionData('1.11.2', basePath)
  16. await ag.validateAssets(versionData, basePath)
  17. console.log('assets done')
  18. await ag.validateLibraries(versionData, basePath)
  19. console.log('libs done')
  20. await ag.validateMiscellaneous(versionData, basePath)
  21. console.log('files done')
  22. ag.instance.on('dlcomplete', function(){
  23. lp.launchMinecraft(versionData, basePath)
  24. })
  25. ag.processDlQueues()
  26. }
  27. /*Opens DevTools window if you type "wcdev" in sequence.
  28. This will crash the program if you are using multiple
  29. DevTools, for example the chrome debugger in VS Code. */
  30. const match = [87, 67, 68, 69, 86]
  31. let at = 0;
  32. document.addEventListener('keydown', function (e) {
  33. switch(e.keyCode){
  34. case match[0]:
  35. if(at === 0) ++at
  36. break
  37. case match[1]:
  38. if(at === 1) ++at
  39. break
  40. case match[2]:
  41. if(at === 2) ++at
  42. break
  43. case match[3]:
  44. if(at === 3) ++at
  45. case match[4]:
  46. if(at === 4) ++at
  47. break
  48. default:
  49. at = 0
  50. }
  51. if(at === 5) {
  52. var window = remote.getCurrentWindow()
  53. window.toggleDevTools()
  54. at = 0
  55. }
  56. })