Skip to content

Commit

Permalink
bf-scroll-lock - Fixed a bug where scroll lock would get stuck perman…
Browse files Browse the repository at this point in the history
…ently

- Fixed a bug where manual keys would not clear when deleted
- Manual keys can be double clicked on to re-assess them
- Added a shortcut key for export all
- Added find to the edit menu
- Added NewFromLastTemplate(from most recent template) menu option
- Changed new template shortcut to CTRL+SHIFT+N
  • Loading branch information
TomNCatz committed Feb 8, 2022
1 parent f07e1b6 commit 018dfcb
Show file tree
Hide file tree
Showing 8 changed files with 3,405 additions and 3,376 deletions.
7 changes: 6 additions & 1 deletion Code/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public bool HasUnsavedChanges
if(!_hasUnsavedChanges)
{
_mainView.SetNodesClean();
_mainView.ClearScrollLock();
MainView.ScrollLock = false;
}
}
get => _hasUnsavedChanges;
Expand Down Expand Up @@ -742,6 +742,11 @@ public void LoadDefaultTemplate()
SaveFilePath = null;
}

public void NewFromLastTemplate()
{
OnRecentTemplateMenuSelection(0);
}

public void LoadGraph( string path )
{
CheckIfSavedFirst()
Expand Down
72 changes: 37 additions & 35 deletions Code/NodeCode/MainView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,7 @@ public class MainView : ColorRect

public string SearchString => _searchBar.Text;

public static bool ScrollLock
{
set
{
if(value)
{
_scrollLock++;
}
else
{
_scrollLock--;
}
}
get => _scrollLock != 0;
}
private static int _scrollLock = 0;
public static bool ScrollLock { get; set; }
private Vector2 _scrollCurrent;

public Color GridMajorColor
Expand Down Expand Up @@ -199,13 +184,14 @@ public override void _Ready()

PopupMenu menu = _fileMenuButton.GetPopup();
menu.Connect( "id_pressed", this, nameof(OnFileMenuSelection));
menu.AddItem( "New Graph (CTRL+N)", 14 );
menu.AddItem( "Save Graph (CTRL+S)", 11 );
menu.AddItem( "Save Graph As", 2 );
menu.AddItem( "Load Graph", 3 );
menu.AddChild( _recentSubmenu );
menu.AddSubmenuItem( "Recent Graph", "RecentMenu" );
menu.AddSeparator( );
menu.AddItem( "Export All", 4 );
menu.AddItem( "Export All (CTRL+E)", 4 );
_exportSubmenu.Connect( "id_pressed", this, nameof(OnExportMenuSelection));
menu.AddChild(_exportSubmenu);
menu.AddSubmenuItem( "Export", "ExportMenu" );
Expand All @@ -214,10 +200,11 @@ public override void _Ready()

PopupMenu dataMenu = _dataMenuButton.GetPopup();
dataMenu.Connect( "id_pressed", this, nameof(OnFileMenuSelection));
dataMenu.AddItem( "Build Template (CTRL+N)", 0 );
dataMenu.AddItem( "Build Template (CTRL+SHIFT+N)", 0 );
dataMenu.AddItem( "Load Template", 1 );
dataMenu.AddChild( _recentTemplateSubmenu );
dataMenu.AddSubmenuItem( "Recent Template", "RecentTemplateMenu" );
dataMenu.AddSeparator( );
dataMenu.AddItem( "Shift Template Under Data", 7 );
dataMenu.AddChild( _recentShiftSubmenu );
dataMenu.AddSubmenuItem( "Recent Template Under Data", "RecentShiftMenu" );
Expand All @@ -232,9 +219,12 @@ public override void _Ready()
_editMenu.Connect( "id_pressed", this, nameof(OnEditMenuSelection));
_editMenu.AddChild( _createSubmenu );
_editMenu.AddSubmenuItem( "Create", "CreateMenu" );
_editMenu.AddSeparator( );
_editMenu.AddItem( "Copy Nodes (CTRL+C)", 0 );
_editMenu.AddItem( "Paste Nodes (CTRL+V)", 1 );
_editMenu.AddItem( "Delete Nodes (DEL)", 2 );
_editMenu.AddSeparator( );
_editMenu.AddItem( "Find (CTRL+F)", 3 );

PopupMenu settingsMenu = _settingsMenuButton.GetPopup();
settingsMenu.Connect( "id_pressed", this, nameof(OnSettingsMenuSelection));
Expand Down Expand Up @@ -284,22 +274,37 @@ public override void _Input( InputEvent @event )
if (!(@event is InputEventKey eventKey)) return;
if (eventKey.IsPressed()) return;
if (!eventKey.Control && !eventKey.Command) return;

var key = OS.GetScancodeString(eventKey.Scancode);

if( OS.GetScancodeString( eventKey.Scancode ).Equals( "S" ) )
// CTRL + SHIFT + <key>
if (eventKey.Shift)
{
_app.SaveGraph();
}
else if( OS.GetScancodeString( eventKey.Scancode ).Equals( "N" ) )
{
_app.LoadDefaultTemplate();
}
else if( OS.GetScancodeString( eventKey.Scancode ).Equals( "P" ) )
{
SortNodes();
if( key.Equals( "N" ) )
{
_app.LoadDefaultTemplate();
}
return;
}
else if( OS.GetScancodeString( eventKey.Scancode ).Equals( "F" ) )

// CTRL + <key>
switch (key)
{
_app.OpenSearch();
case "S":
_app.SaveGraph();
break;
case "N":
_app.NewFromLastTemplate();
break;
case "P":
SortNodes();
break;
case "F":
_app.OpenSearch();
break;
case "E":
_app.ExportAll();
break;
}
}
catch( Exception e )
Expand Down Expand Up @@ -345,6 +350,7 @@ private void OnFileMenuSelection( int id )
case 11 : _app.SaveGraph(); break;
case 12 : _app.OpenHelpPopup(); break;
case 13 : TrimOldData(); break;
case 14 : _app.NewFromLastTemplate(); break;
}
}
catch( Exception e )
Expand All @@ -362,6 +368,7 @@ private void OnEditMenuSelection( int id )
case 0 : RequestCopyNode(); break;
case 1 : RequestPasteNode(); break;
case 2 : RequestDeleteNode(); break;
case 3 : _app.OpenSearch(); break;
}
}
catch( Exception e )
Expand Down Expand Up @@ -948,11 +955,6 @@ public void SetNodesClean()
node.Dirty = false;
}
}

public void ClearScrollLock()
{
_scrollLock = 0;
}
#endregion

#region Connections
Expand Down
28 changes: 25 additions & 3 deletions Code/NodeCode/NodeSlots/KeyManualSlot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ public override void _Ready()
_field.Connect("text_changed",this,nameof(OnChanged));
}

public override void _GuiInput( InputEvent @event )
{
if (@event is InputEventMouseButton mouseButton && mouseButton.Doubleclick)
{
OnChanged(_field.Text);
}
}

public override void Init(GenericDataDictionary template, GenericDataObject parentModel)
{
template.GetValue( "label", out string label );
Expand Down Expand Up @@ -56,9 +64,7 @@ public override void Init(GenericDataDictionary template, GenericDataObject pare

private void OnChanged( string text )
{
bool problem = string.IsNullOrEmpty(text);
problem |= _app.ContainsKey(_keyPrefix + text);
IndicateTrouble(problem);
var problem = TroubleCheck(text);
_app.RemoveKey(this);

if(problem) return;
Expand All @@ -69,6 +75,22 @@ private void OnChanged( string text )
ValueUpdate();
}

public override void _ExitTree()
{
_app.RemoveKey(this);
base._ExitTree();
}

private bool TroubleCheck(string text)
{
var problem = string.IsNullOrEmpty(text);
problem |= _app.ContainsKey(_keyPrefix + text);

IndicateTrouble(problem);

return problem;
}

private void IndicateTrouble(bool trouble = true)
{
var color = new Color(1,1,1);
Expand Down
2 changes: 1 addition & 1 deletion Code/NodeCode/NodeSlots/KeySlot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class KeySlot : KeyAbstraction
public override int LinkType => _linkType;
private int _linkType;

private string _keyPrefix = String.Empty;
private string _keyPrefix = string.Empty;
private int _keySize = 1;
private GenericDataObject<string> _model;

Expand Down
2 changes: 1 addition & 1 deletion Resources/TEMPLATE.tmplt
Original file line number Diff line number Diff line change
Expand Up @@ -1434,5 +1434,5 @@
]
}
],
"metaMakerVersion": "0.7.2"
"metaMakerVersion": "0.7.3"
}
2 changes: 1 addition & 1 deletion Resources/Version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.2
0.7.3
Loading

0 comments on commit 018dfcb

Please sign in to comment.