Skip to content

Commit 1f60251

Browse files
authored
Add CustomDragDistance setting which overrides DragDistance (CnCNet#980)
1 parent efffa9d commit 1f60251

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

ClientCore/Settings/UserINISettings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ protected UserINISettings(IniFile iniFile)
139139

140140
ScrollRate = new IntSetting(iniFile, OPTIONS, "ScrollRate", 3);
141141
DragDistance = new IntSetting(iniFile, OPTIONS, "DragDistance", 4);
142+
CustomDragDistance = new IntSetting(iniFile, OPTIONS, "CustomDragDistance", 0);
142143
DoubleTapInterval = new IntSetting(iniFile, OPTIONS, "DoubleTapInterval", 30);
143144
Win8CompatMode = new StringSetting(iniFile, OPTIONS, "Win8Compat", "No");
144145

@@ -239,6 +240,8 @@ protected UserINISettings(IniFile iniFile)
239240

240241
public IntSetting ScrollRate { get; private set; }
241242
public IntSetting DragDistance { get; private set; }
243+
// When > 0, overrides the auto-scaled DragDistance. Allows players to set a fixed pixel threshold regardless of resolution.
244+
public IntSetting CustomDragDistance { get; private set; }
242245
public IntSetting DoubleTapInterval { get; private set; }
243246
public StringSetting Win8CompatMode { get; private set; }
244247

DXMainClient/DXGUI/Generic/OptionPanels/DisplayOptionsPanel.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace DTAClient.DXGUI.Generic.OptionPanels
2525
{
2626
class DisplayOptionsPanel : XNAOptionsPanel
2727
{
28+
// Mouse must move at least this many pixels from click point before drag selection activates.
2829
private const int DRAG_DISTANCE_DEFAULT = 4;
2930
private const int ORIGINAL_RESOLUTION_WIDTH = 640;
3031

@@ -628,7 +629,10 @@ public override bool Save()
628629
(IniSettings.IngameScreenWidth.Value, IniSettings.IngameScreenHeight.Value) = ingameRes;
629630

630631
// Calculate drag selection distance, scale it with resolution width
631-
int dragDistance = ingameRes.Width / ORIGINAL_RESOLUTION_WIDTH * DRAG_DISTANCE_DEFAULT;
632+
// CustomDragDistance > 0 overrides auto-scaling for players who need a specific value
633+
int dragDistance = IniSettings.CustomDragDistance.Value > 0
634+
? IniSettings.CustomDragDistance.Value
635+
: ingameRes.Width / ORIGINAL_RESOLUTION_WIDTH * DRAG_DISTANCE_DEFAULT;
632636
IniSettings.DragDistance.Value = dragDistance;
633637

634638
var newSelectedRenderer = (DirectDrawWrapper)ddRenderer.SelectedItem.Tag;

0 commit comments

Comments
 (0)