The filtering still doesn't work yet.
Also cleaned up guide tab fill function, and some other code.
Made the guide XonoticEntryList not have to refer to XonoticMapList.
#include "dialog_multiplayer_media_guide.qh"
#include "inputbox.qh"
-#include "maplist.qh"
#include "textlabel.qh"
+#include <menu/xonotic/guide/entries.qh>
void XonoticGuideTab_fill(entity me)
{
- entity topics = me.topicList;
- topics.onChange = XonoticGuideTab_topicChangeNotify;
- topics.onChangeEntity = me;
- entity entries = me.entryList;
- entries.onChange = XonoticGuideTab_entryChangeNotify;
- entries.onChangeEntity = me;
- entity filter = entries.stringFilterBox = makeXonoticInputBox(false, string_null);
- filter.keyDown = MapList_StringFilterBox_keyDown;
- filter.onChange = MapList_StringFilterBox_Change;
- filter.onChangeEntity = entries;
- entries.controlledTextbox = filter;
- entity description = me.descriptionPane;
+ entity e;
- int
- col = 0, width = 1.5;
+ int col = 0, width = 1.5;
me.gotoRC(me, 0, col);
me.TD(me, 1, width, makeXonoticHeaderLabel(_("Topic")));
me.TR(me);
- me.TD(me, me.rows - 1, width, topics);
+ me.TD(me, me.rows - 1, width, e = me.topicList);
+ e.onChange = XonoticGuideTab_topicChangeNotify;
+ e.onChangeEntity = me;
col += width, width = 2;
me.gotoRC(me, 0, col); me.setFirstColumn(me, me.currentColumn);
me.TD(me, 1, width, makeXonoticHeaderLabel(_("Entry")));
me.TR(me);
- me.TD(me, me.rows - 1 - 1, width, entries);
+ me.TD(me, me.rows - 1 - 1, width, e = me.entryList);
+ e.onChange = XonoticGuideTab_entryChangeNotify;
+ e.onChangeEntity = me;
me.gotoRC(me, me.rows - 1, col);
+ me.entryList.stringFilterBox = makeXonoticInputBox_T(false, string_null,
+ _("Click here or Ctrl-F to provide a keyword to narrow down the map list. Ctrl-Delete to clear; Enter when done."));
me.TD(me, 1, 0.3, makeXonoticTextLabel(0, _("Filter:")));
- me.TD(me, 1, width - 0.3, filter);
+ me.TD(me, 1, width - 0.3, e = me.entryList.stringFilterBox);
+ e.onChange = EntryList_StringFilterBox_Change;
+ e.keyDown = EntryList_StringFilterBox_keyDown;
+ e.onChangeEntity = me.entryList;
col += width, width = 2.5;
me.gotoRC(me, 0, col); me.setFirstColumn(me, me.currentColumn);
me.TD(me, 1, width, makeXonoticHeaderLabel(_("Description")));
me.TR(me);
- me.TD(me, me.rows - 1, width, description);
+ me.TD(me, me.rows - 1, width, me.descriptionPane);
- me.topicChangeNotify(topics, me);
+ me.topicChangeNotify(me.topicList, me);
}
void XonoticGuideTab_topicChangeNotify(entity, entity me)
XonoticEntryList_cb_icon = _icon;
}
+entity EntryList_Set_StringFilterBox(entity me, entity e)
+{
+ me.stringFilterBox = e;
+ return e;
+}
+
void XonoticEntryList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
{
if (!me.source) return;
this.setSelected(this, idx);
}
}
- else if (shift & S_CTRL && scan == 'f')
+ else if ((shift & S_CTRL) && scan == 'f') // ctrl-f (as in "F"ind)
+ {
this.parent.setFocus(this.parent, this.stringFilterBox);
- else if (shift & S_CTRL && scan == 'u')
+ }
+ else if ((shift & S_CTRL) && scan == 'u') // ctrl-u (remove stringFilter line)
{
this.stringFilterBox.setText(this.stringFilterBox, "");
- if (this.stringFilter)
- strunzone(this.stringFilter);
- this.stringFilter = string_null;
- this.refilter(this);
+ EntryList_StringFilterBox_Change(this.stringFilterBox, this);
}
return SUPER(XonoticEntryList).keyDown(this, scan, ascii, shift);
}
+float EntryList_StringFilterBox_keyDown(entity me, float scan, float ascii, float shift)
+{
+ // in this section, note that onChangeEntity has the ref to entryList
+ // 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 entryList
+ 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 entryList (to scroll up and down)
+ return me.onChangeEntity.keyDown(me.onChangeEntity, scan, ascii, shift);
+ }
+ return SUPER(XonoticInputBox).keyDown(me, scan, ascii, shift);
+}
+
void XonoticEntryList_refilter(entity me)
{
if (!me.source)
draw_PreloadPicture(XonoticEntryList_cb_icon);
}
+void EntryList_StringFilterBox_Change(entity box, entity me)
+{
+ strfree(me.stringFilter);
+ if(box.text != "")
+ me.stringFilter = strzone(box.text);
+
+ me.refilter(me);
+}
+
void XonoticEntryList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
{
me.itemAbsSize = '0 0 0';
ATTRIB(XonoticEntryList, realUpperMargin1, float, 0);
ATTRIB(XonoticEntryList, realUpperMargin2, float, 0);
ATTRIB(XonoticEntryList, rowsPerItem, float, 4);
+
ATTRIB(XonoticEntryList, stringFilterBox, entity, NULL);
ATTRIB(XonoticEntryList, stringFilter, string, string_null);
ATTRIB(XonoticEntryList, typeToSearchString, string, string_null);
}
ENDCLASS(XonoticEntryList)
+void EntryList_StringFilterBox_Change(entity box, entity me);
+float EntryList_StringFilterBox_keyDown(entity me, float key, float ascii, float shift);
return me;
}
-entity MapList_Set_String_Filter_Box(entity me, entity e)
+entity MapList_Set_StringFilterBox(entity me, entity e)
{
me.stringFilterBox = e;
return e;
{
me.parent.setFocus(me.parent, me.stringFilterBox);
}
- else if((shift & S_CTRL) && scan == 'u') // ctrl-u (remove stringFilter line
+ else if((shift & S_CTRL) && scan == 'u') // ctrl-u (remove stringFilter line)
{
me.stringFilterBox.setText(me.stringFilterBox, "");
MapList_StringFilterBox_Change(me.stringFilterBox, me);