Skip to content

Commit

Permalink
allow opening with selection with setting. closes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
FluffierThanThou committed Aug 9, 2020
1 parent ef4e781 commit 62304d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Source/PaletteWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ public void HandleShortcuts()
{
// this is injected to run right before the vanilla LowPriorityShortcuts.
// if nothing selected and right clicked on colony view.
if ( Find.Selector.NumSelected == 0 && !WorldRendererUtility.WorldRenderedNow
&& ( CommandPalette.Settings.KeyBinding?.JustPressed ?? false ) )
if ( ( CommandPalette.Settings.OpenWithSelection || Find.Selector.NumSelected == 0 )
&& !WorldRendererUtility.WorldRenderedNow
&& ( CommandPalette.Settings.KeyBinding?.JustPressed ?? false ) )
{
Event.current.Use();
Event.current.Use();
position = UI.MousePositionOnUIInverted -
new Vector2( GIZMO_SIZE / 2f, SEARCH_HEIGHT );
active = true;
Expand Down
3 changes: 3 additions & 0 deletions Source/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class Settings : ModSettings
public float PaletteScale = 1f;
public int MaxRecentDesignators = 10;
public bool OpenArchitect = true;
public bool OpenWithSelection = false;
public int NumRows = 2;
public int NumCols = 4;
private KeyBind _keyBinding;
Expand Down Expand Up @@ -43,6 +44,7 @@ public void DoWindowContents( Rect canvas )
Widgets.TextFieldNumeric( rect.RightPart( 1 / 3f ), ref NumRows, ref _numRows, 1, 10 );

KeyBinding.Draw( options.GetRect( 30 ) );
options.CheckboxLabeled("Allow opening when something is selected", ref OpenWithSelection, "By default, the command palette will not open when something is selected. This makes sure that it doesn't conflict with right click menus. Enabling this options overrides that behaviour. \n\nWARNING:\nOnly enable this when you have set a different hotkey!");

rect = options.GetRect(30);
Widgets.Label(rect.LeftPart(2 / 3f), "Maximum number of recently used designators shown");
Expand All @@ -60,6 +62,7 @@ public override void ExposeData()
Scribe_Values.Look( ref NumCols, "numCols", 4 );
Scribe_Values.Look( ref NumRows, "numRows", 2 );
Scribe_Values.Look(ref MaxRecentDesignators, "maxRecentDesignators", 10);
Scribe_Values.Look(ref OpenWithSelection, "openWithSelection" );
Scribe_Deep.Look( ref _keyBinding, "keybinding" );
}
}
Expand Down

0 comments on commit 62304d3

Please sign in to comment.