Index: ps/trunk/binaries/data/config/default.cfg =================================================================== --- ps/trunk/binaries/data/config/default.cfg +++ ps/trunk/binaries/data/config/default.cfg @@ -381,6 +381,7 @@ rankabovestatusbar = true ; Show rank icons above status bars experiencestatusbar = true ; Show an experience status bar above each selected unit respoptooltipsort = 0 ; Sorting players in the resources and population tooltip by value (0 - no sort, -1 - ascending, 1 - descending) +snaptoedges = "disabled" ; Possible values: disabled, enabled. snaptoedgesdistancethreshold = 15 ; On which distance we don't snap to edges [gui.session.minimap] Index: ps/trunk/binaries/data/mods/public/gui/options/options.json =================================================================== --- ps/trunk/binaries/data/mods/public/gui/options/options.json +++ ps/trunk/binaries/data/mods/public/gui/options/options.json @@ -544,6 +544,24 @@ "label": "Diplomacy colors: enemy", "tooltip": "Color of enemies when diplomacy colors are enabled.", "config": "gui.session.diplomacycolors.enemy" + }, + { + "type": "dropdown", + "label": "Snap to edges", + "tooltip": "This option allows to align new structures with nearby structures.", + "config": "gui.session.snaptoedges", + "list": [ + { + "value": "disabled", + "label": "Hotkey to enable snapping", + "tooltip": "New structures are aligned with nearby structures while pressing the hotkey." + }, + { + "value": "enabled", + "label": "Hotkey to disable snapping", + "tooltip": "New structures are aligned with nearby structures unless the hotkey is pressed." + } + ] } ] } Index: ps/trunk/binaries/data/mods/public/gui/session/input.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/input.js +++ ps/trunk/binaries/data/mods/public/gui/session/input.js @@ -281,6 +281,13 @@ return entState && entState.player == g_ViewedPlayer; } +function isSnapToEdgesEnabled() +{ + let config = Engine.ConfigDB_GetValue("user", "gui.session.snaptoedges"); + let hotkeyPressed = Engine.HotkeyIsPressed("session.snaptoedges"); + return hotkeyPressed == (config == "disabled"); +} + function tryPlaceBuilding(queued) { if (placementSupport.mode !== "building") @@ -722,13 +729,12 @@ placementSupport.SetDefaultAngle(); } - let snapToEdges = Engine.HotkeyIsPressed("session.snaptoedges"); let snapData = Engine.GuiInterfaceCall("GetFoundationSnapData", { "template": placementSupport.template, "x": placementSupport.position.x, "z": placementSupport.position.z, "angle": placementSupport.angle, - "snapToEdges": snapToEdges && Engine.GetEdgesOfStaticObstructionsOnScreenNearTo( + "snapToEdges": isSnapToEdgesEnabled() && Engine.GetEdgesOfStaticObstructionsOnScreenNearTo( placementSupport.position.x, placementSupport.position.z) }); if (snapData) @@ -1049,12 +1055,11 @@ return true; } - let snapToEdges = Engine.HotkeyIsPressed("session.snaptoedges"); let snapData = Engine.GuiInterfaceCall("GetFoundationSnapData", { "template": placementSupport.template, "x": placementSupport.position.x, "z": placementSupport.position.z, - "snapToEdges": snapToEdges && Engine.GetEdgesOfStaticObstructionsOnScreenNearTo( + "snapToEdges": isSnapToEdgesEnabled() && Engine.GetEdgesOfStaticObstructionsOnScreenNearTo( placementSupport.position.x, placementSupport.position.z) }); if (snapData) @@ -1081,8 +1086,7 @@ { placementSupport.position = Engine.GetTerrainAtScreenPoint(ev.x, ev.y); - let snapToEdges = Engine.HotkeyIsPressed("session.snaptoedges"); - if (snapToEdges) + if (isSnapToEdgesEnabled()) { let snapData = Engine.GuiInterfaceCall("GetFoundationSnapData", { "template": placementSupport.template,