diff options
Diffstat (limited to 'Script.c')
| -rw-r--r-- | Script.c | 34 |
1 files changed, 29 insertions, 5 deletions
@@ -340,6 +340,28 @@ func SelectEntry(indexOrChain, int column) } } +func SelectTopEntry(int column) +{ + for(var i = 0; i < GetLength(columnEntries[column]); ++i) + { + if(columnEntries[column][i][DT_Menu_Entry_Placeholder]) + { + return SelectEntry(i, column); + } + } +} + +func SelectBottomEntry(int column) +{ + for(var i = GetLength(columnEntries[column]) - 1; i >= 0; --i) + { + if(columnEntries[column][i][DT_Menu_Entry_Placeholder]) + { + return SelectEntry(i, column); + } + } +} + func ActivateEntry(int action, indexOrChain, int column) { SelectEntry(indexOrChain); @@ -733,6 +755,8 @@ func AddEntries() entry[DT_Menu_Entry_Extra] |= C4MN_Add_ForceNoDesc; } + entry[DT_Menu_Entry_Placeholder] = !noCommand; + columnEntries[j][rowIndex] = entry; var showDesc = !(entry[DT_Menu_Entry_Extra] & C4MN_Add_ForceNoDesc); @@ -938,12 +962,12 @@ func OnMenuSelection(int selection, object menuObject) if(oldColumnSelection == 0) { // wrap around if the last selection was the top already - SelectEntry(GetLength(columnEntries[column]) - 1, column); + SelectBottomEntry(column); } else { // otherwise maybe wrapped around from the bottom or just hovered it with the mouse - SelectEntry(0, column); + SelectTopEntry(column); } return; } @@ -957,18 +981,18 @@ func OnMenuSelection(int selection, object menuObject) if(oldColumnSelection == GetLength(columnEntries[column]) - 1) { // wrap around if the last selection was the bottom already - SelectEntry(0, column); + SelectTopEntry(column); } else { // otherwise maybe wrapped around from the top or just hovered it with the mouse - SelectEntry(GetLength(columnEntries[column]) - 1, column); + SelectBottomEntry(column); } return; } else if(multiColumnMode) { - SelectEntry(GetLength(columnEntries[column]) - 1, column); + SelectBottomEntry(column); return; } skipHandling = true; |
