From 5271334f9a85723fa21202ca3b922c2f964cbb9d Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 16 Aug 2010 19:29:35 +0200 Subject: [PATCH] Filter the list after 0.5 seconds the filter string has been changed --- .../xonotic/dialog_multiplayer_screenshot.c | 3 +-- qcsrc/menu/xonotic/screenshotlist.c | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_screenshot.c b/qcsrc/menu/xonotic/dialog_multiplayer_screenshot.c index b0eebeda1..432c988e7 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_screenshot.c +++ b/qcsrc/menu/xonotic/dialog_multiplayer_screenshot.c @@ -41,10 +41,9 @@ void XonoticScreenshotBrowserTab_fill(entity me) me.TD(me, 1, 0.5, btn = makeXonoticButton("Clear", '0 0 0')); btn.onClick = InputBox_Clear_Click; me.TD(me, 1, me.columns - 1.5, e = makeXonoticInputBox(0, string_null)); - e.onChange = ScreenshotList_Filter_Change; + e.onChange = ScreenshotList_Filter_Would_Change; e.onChangeEntity = slist; btn.onClickEntity = e; - slist.controlledTextbox = e; slist.screenshotViewerDialog = main.screenshotViewerDialog; main.screenshotViewerDialog.scrList = slist; me.TD(me, 1, 0.5, e = makeXonoticButton("Refresh", '0 0 0')); diff --git a/qcsrc/menu/xonotic/screenshotlist.c b/qcsrc/menu/xonotic/screenshotlist.c index 1fa901d9a..0a8575dc0 100644 --- a/qcsrc/menu/xonotic/screenshotlist.c +++ b/qcsrc/menu/xonotic/screenshotlist.c @@ -4,6 +4,7 @@ CLASS(XonoticScreenshotList) EXTENDS(XonoticListBox) ATTRIB(XonoticScreenshotList, rowsPerItem, float, 1) METHOD(XonoticScreenshotList, resizeNotify, void(entity, vector, vector, vector, vector)) METHOD(XonoticScreenshotList, setSelected, void(entity, float)) + METHOD(XonoticScreenshotList, draw, void(entity)) METHOD(XonoticScreenshotList, drawListBoxItem, void(entity, float, vector, float)) METHOD(XonoticScreenshotList, getScreenshots, void(entity)) METHOD(XonoticScreenshotList, previewScreenshot, void(entity)) @@ -23,6 +24,8 @@ CLASS(XonoticScreenshotList) EXTENDS(XonoticListBox) ATTRIB(XonoticScreenshotList, lastClickedScreenshot, float, -1) ATTRIB(XonoticScreenshotList, lastClickedTime, float, 0) ATTRIB(XonoticScreenshotList, filterString, string, string_null) + ATTRIB(XonoticScreenshotList, filterBox, entity, NULL) + ATTRIB(XonoticScreenshotList, filterTime, float, 0) ATTRIB(XonoticScreenshotList, screenshotBrowserDialog, entity, NULL) ATTRIB(XonoticScreenshotList, screenshotPreview, entity, NULL) @@ -33,6 +36,7 @@ ENDCLASS(XonoticScreenshotList) entity makeXonoticScreenshotList(); void StartScreenshot_Click(entity btn, entity me); void ScreenshotList_Refresh_Click(entity btn, entity me); +void ScreenshotList_Filter_Would_Change(entity box, entity me); void ScreenshotList_Filter_Change(entity box, entity me); #endif @@ -169,6 +173,22 @@ void ScreenshotList_Filter_Change(entity box, entity me) ScreenshotList_Refresh_Click(world, me); } +void ScreenshotList_Filter_Would_Change(entity box, entity me) +{ + me.filterBox = box; + me.filterTime = time + 0.5; +} + +void XonoticScreenshotList_draw(entity me) +{ + if (me.filterTime && time > me.filterTime) + { + ScreenshotList_Filter_Change(me.filterBox, me); + me.filterTime = 0; + } + SUPER(XonoticScreenshotList).draw(me); +} + void XonoticScreenshotList_goScreenshot(entity me, float d) { if(!me.screenshotViewerDialog) -- 2.39.2