Bulk Upgrade: Mouse Selection Tool

Everyone knows how frustrating the Bulk Infrastructure Upgrade can be, forcing you to actually upgrade star by star, manually. Well, not any more!

#USAGE:

  1. Press Q twice to switch from quick_upgrade to bulk_upgrade_selection.

  2. Hover over stars with your mouse. (Avoid clicking at stars!, it will break the tool (read below).)
    Hold SHIFT or ALT to add/remove stars from selection.

  3. Upgrade your stars.

  4. Turn the tool off by pressing Q a third time.
    (This step is necessary.)

  5. If you want to continue upgrading with selected stars, open the bulk-upgrade again, but now from the menu.

Protip: The tool’s radius depends on current zoom level. Zoom out to select more stars at once!

#Bookmarklet
Create a Bookmarklet or input this code right into adressbar. How to create a bookmarklet?

[size=11]Don’t forget to remove the leading +[/size]

+javascript: /*by Qwerty*/ (function(){var map=NeptunesPride.npui.map,universe=NeptunesPride.universe,np=NeptunesPride.np;map.mouseSelectionToolSrc=document.getElementById("img_ripple");map.mouseSelectionRingSrc=document.getElementById("img_fleet_waypoint_next");map.mouseSelectionToolSprite={width:128,height:128,pivotX:64,pivotY:64,rotation:0,scale:0,image:map.mouseSelectionToolSrc,spriteX:0,spriteY:0,visible:true};map.mouseSelectionRingSprite={width:128,height:128,pivotX:64,pivotY:64,rotation:0,scale:0,image:map.mouseSelectionRingSrc,spriteX:0,spriteY:0,visible:true};map.drawMouseSelectionToolState=0;map.drawMouseSelectionToolToggled=0;map.drawMouseSelectionToolToggle=function(){if(map.drawMouseSelectionToolState==0){Crux.crux.trigger("start_quick_upgrade");map.drawMouseSelectionToolState=1}else if(map.drawMouseSelectionToolState==1){Crux.crux.trigger("show_screen","bulk_upgrade");universe.editMode="bulk_upgrade_selection";universe.interfaceSettings.showQuickUpgrade=true;universe.interfaceSettings.showBasicInfo=false;map.drawMouseSelectionToolToggled=1;map.drawMouseSelectionToolState=2}else if(map.drawMouseSelectionToolState==2){for(var e in NeptunesPride.universe.galaxy.stars)NeptunesPride.universe.galaxy.stars[e].selected=false;NeptunesPride.npui.onHideScreen(null,true);np.onEndQuickUpgrade();map.drawMouseSelectionToolToggled=0;map.drawMouseSelectionToolState=0}Crux.crux.trigger("map_refresh")};Mousetrap.bind(["q","Q"],map.drawMouseSelectionToolToggle);map.onMouseMove=function(e){e.pageX-=map.x;e.pageY-=map.y;if(map.dragging){map.deltaX=map.oldX-e.pageX;map.deltaY=map.oldY-e.pageY;map.oldX=e.pageX;map.oldY=e.pageY;map.moveDelta()}if(map.drawMouseSelectionToolToggled){var t=map.ui.offset().left,n=map.ui.offset().top,r={x:(e.pageX-map.sx-t)/map.scale,y:(e.pageY-map.sy-n)/map.scale,altKey:e.altKey,shiftKey:e.shiftKey};map.drawMouseSelectionTool(r);np.onMouseSelectionToolSelection(r,38/map.scale)}};map.on("mousemove",function(e){map.onMouseMove(e)});np.onMouseSelectionToolSelection=function(e,t){var n=universe.seekSelection(e.x,e.y,t);for(i in n)if(n[i].kind=="star"&&n[i].player===universe.player){if(e.shiftKey==true)n[i].selected=true;else if(e.altKey==true)n[i].selected=false}};map.drawMouseSelectionTool=function(e){map.draw();map.mouseSelectionToolSprite.scale=.7*map.pixelRatio;map.mouseSelectionToolSprite.screenX=map.worldToScreenX(e.x);map.mouseSelectionToolSprite.screenY=map.worldToScreenY(e.y);map.drawSprite(map.mouseSelectionToolSprite)};map.drawMouseSelectionRings=function(){for(var e in NeptunesPride.universe.galaxy.stars){var t=NeptunesPride.universe.galaxy.stars[e];if(map.drawMouseSelectionToolToggled&&t.selected){map.mouseSelectionRingSprite.scale=.5*map.pixelRatio*map.scale/250;map.mouseSelectionRingSprite.screenX=map.worldToScreenX(t.x);map.mouseSelectionRingSprite.screenY=map.worldToScreenY(t.y);map.drawSprite(map.mouseSelectionRingSprite)}}};if(!map.old_draw)map.old_draw=map.draw;(function(){var draw=map.draw.toString(),inject=".drawMouseSelectionRings()",before=".drawText",parts=draw.match("([^,; ]*).drawStars..(.)"),cutStops=[draw.indexOf("{")+1,draw.indexOf(".drawText")-parts[1].length];if(draw.indexOf(inject)==-1)eval("NeptunesPride.npui.map.draw = function(){\n    var map = o = NeptunesPride.npui.map;\n    var universe = t = NeptunesPride.universe;\n"+draw.slice(cutStops[0],cutStops[1])+"\n"+parts[1]+inject+parts[2]+"\n"+draw.slice(cutStops[1]))})();Crux.tickCallbacks[0]=map.draw;universe.seekSelection=function(e,t,n){n=n||.04;var r,i;r=[];if(universe.interfaceSettings.showStars){for(i in universe.galaxy.stars){if(universe.galaxy.stars[i].x>e-n&&universe.galaxy.stars[i].x<e+n&&universe.galaxy.stars[i].y>t-n&&universe.galaxy.stars[i].y<t+n){r.push(universe.galaxy.stars[i])}}}if(universe.interfaceSettings.showFleets){for(i in universe.galaxy.fleets){if(universe.galaxy.fleets[i].x>e-n&&universe.galaxy.fleets[i].x<e+n&&universe.galaxy.fleets[i].y>t-n&&universe.galaxy.fleets[i].y<t+n){r.push(universe.galaxy.fleets[i])}}}universe.possibleSelections=r;return r};if(!universe.old_findCheapestUpgrade)universe.old_findCheapestUpgrade=universe.findCheapestUpgrade;universe.findCheapestUpgrade=function(e){var t,n,r;for(t in universe.galaxy.stars){n=universe.galaxy.stars[t];if(n.player!==universe.player)continue;if(map.drawMouseSelectionToolToggled&&!n.selected)continue;if(r===undefined)r=n;if(e==="economy"){if(n.uce<r.uce)r=n}if(e==="industry"){if(n.uci<r.uci)r=n}if(e==="science"){if(n.ucs<r.ucs)r=n}}return r}})()

[size=11]Download full source code here.[/size]

7 Likes

Awesome work!

1 Like

This looks cool!

Niiiiiiiiiiiice!

I’m currently in a game with Qwerty - how comes he doesn’t have the wizard badge yet?!? :wink:

Nice work. … hope this gets rolled into the game …

I would really like to see this as a featur ein the game. Some way to draw a selection area and do buk upgrades or view just the selection in the Galaxy area. When you have a large number of stars neither the bulk tool or going one by one is very efficient.

You can use it already in your browser. It still works! :blush: