From: BuddyFriendGuy Date: Thu, 9 Apr 2015 21:38:27 +0000 (-0400) Subject: add hotkeys for better usability X-Git-Tag: xonotic-v0.8.1~23^2~9 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4e126df160b25d75d7f9d66c3957acaf5b71ba20;p=xonotic%2Fxonotic-data.pk3dir.git add hotkeys for better usability --- diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_create.qc b/qcsrc/menu/xonotic/dialog_multiplayer_create.qc index 2da8a4169..23c10e588 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_create.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_create.qc @@ -160,7 +160,8 @@ void XonoticServerCreateTab_fill(entity me) me.TD(me, 1, 0.35, e = makeXonoticTextLabel(1, _("Filter:"))); me.mapListBox.stringFilterBox = makeXonoticMapListStringFilterBox(me, 0, string_null); me.TD(me, 1, me.columns - me.firstColumn - 0.35, e = me.mapListBox.stringFilterBox); - e.onChange = MapList_StringFilter_Change; + e.onChange = MapList_StringFilterBox_Change; + e.keyDown = MapList_StringFilterBox_keyDown; e.onChangeEntity = me.mapListBox; me.mapListBox.controlledTextbox = e; diff --git a/qcsrc/menu/xonotic/maplist.qc b/qcsrc/menu/xonotic/maplist.qc index a01af9264..baeaf82e9 100644 --- a/qcsrc/menu/xonotic/maplist.qc +++ b/qcsrc/menu/xonotic/maplist.qc @@ -47,7 +47,8 @@ CLASS(XonoticMapList) EXTENDS(XonoticListBox) ENDCLASS(XonoticMapList) entity makeXonoticMapList(); entity makeXonoticMapListStringFilterBox(entity me, float doEditColorCodes, string theCvar); -void MapList_StringFilter_Change(entity box, entity me); +void MapList_StringFilterBox_Change(entity box, entity me); +float MapList_StringFilterBox_keyDown(entity me, float key, float ascii, float shift); void MapList_Add_Shown(entity btn, entity me); void MapList_Remove_Shown(entity btn, entity me); void MapList_Clear_All(entity btn, entity me); @@ -62,8 +63,7 @@ void XonoticMapList_destroy(entity me) entity makeXonoticMapListStringFilterBox(entity me, float doEditColorCodes, string theCvar) { - me.mapListBox.stringFilterBox = makeXonoticInputBox(doEditColorCodes, theCvar); - return me.mapListBox.stringFilterBox; + return makeXonoticInputBox(doEditColorCodes, theCvar); } entity makeXonoticMapList() { @@ -257,7 +257,7 @@ void XonoticMapList_refilterCallback(entity me, entity cb) me.refilter(me); } -void MapList_StringFilter_Change(entity box, entity me) +void MapList_StringFilterBox_Change(entity box, entity me) { if(me.stringFilter) strunzone(me.stringFilter); @@ -406,8 +406,34 @@ float XonoticMapList_keyDown(entity me, float scan, float ascii, float shift) { me.parent.setFocus(me.parent, me.stringFilterBox); } + else if(shift & S_CTRL && scan == 'u') // ctrl-u (remove stringFilter line + { + me.stringFilterBox.setText(me.stringFilterBox, ""); + MapList_StringFilterBox_Change(me.stringFilterBox, me); + } else return SUPER(XonoticMapList).keyDown(me, scan, ascii, shift); return 1; } + +float MapList_StringFilterBox_keyDown(entity me, float scan, float ascii, float shift) +{ + // in this section, note that onChangeEntity has the ref to mapListBox + // we make use of that, instead of extending a class to add one more attrib + switch(scan) + { + case K_KP_ENTER: + case K_ENTER: + // move the focus to the mapListBox + me.onChangeEntity.parent.setFocus(me.onChangeEntity.parent, me.onChangeEntity); + return 1; + case K_KP_UPARROW: + case K_UPARROW: + case K_KP_DOWNARROW: + case K_DOWNARROW: + // pass the event to the mapListBox (to scroll up and down) + return me.onChangeEntity.keyDown(me.onChangeEntity, scan, ascii, shift); + } + return SUPER(XonoticInputBox).keyDown(me, scan, ascii, shift); +} #endif