From 2baa4e5296ba5265fd9063b1cad01171a0f2ee48 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 12 Feb 2011 12:10:37 +0100 Subject: [PATCH] Make Bookmark button update its text (Bookmark/Remove) on address change Otherwise when an address is in favorites list (the button shows "Remove"), modifying the input box text the button still shows "Remove" but clicking it the address gets bookmarked --- qcsrc/menu/xonotic/dialog_multiplayer_join.c | 2 ++ qcsrc/menu/xonotic/serverlist.c | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_join.c b/qcsrc/menu/xonotic/dialog_multiplayer_join.c index fe9f860c3..ee451744f 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_join.c +++ b/qcsrc/menu/xonotic/dialog_multiplayer_join.c @@ -57,6 +57,8 @@ void XonoticServerListTab_fill(entity me) me.TD(me, 1, 2.9, e = makeXonoticInputBox(0, string_null)); e.onEnter = ServerList_Connect_Click; e.onEnterEntity = slist; + e.onChange = ServerList_Update_favoriteButton; + e.onChangeEntity = slist; slist.ipAddressBox = e; me.TD(me, 1, 1.5, e = makeXonoticButton("", '0 0 0')); e.onClick = ServerList_Favorite_Click; diff --git a/qcsrc/menu/xonotic/serverlist.c b/qcsrc/menu/xonotic/serverlist.c index a3d747dab..0e4760e3f 100644 --- a/qcsrc/menu/xonotic/serverlist.c +++ b/qcsrc/menu/xonotic/serverlist.c @@ -63,6 +63,7 @@ void ServerList_ShowFull_Click(entity box, entity me); void ServerList_Filter_Change(entity box, entity me); void ServerList_Favorite_Click(entity btn, entity me); void ServerList_Info_Click(entity btn, entity me); +void ServerList_Update_favoriteButton(entity btn, entity me); #endif #ifdef IMPLEMENTATION @@ -178,6 +179,14 @@ void ToggleFavorite(string srv) resorthostcache(); } +void ServerList_Update_favoriteButton(entity btn, entity me) +{ + if(IsFavorite(me.ipAddressBox.text)) + me.favoriteButton.setText(me.favoriteButton, _("Remove")); + else + me.favoriteButton.setText(me.favoriteButton, _("Bookmark")); +} + entity makeXonoticServerList() { entity me; @@ -356,12 +365,7 @@ void XonoticServerList_draw(entity me) if(me.ipAddressBoxFocused != me.ipAddressBox.focused) { if(me.ipAddressBox.focused || me.ipAddressBoxFocused < 0) - { - if(IsFavorite(me.ipAddressBox.text)) - me.favoriteButton.setText(me.favoriteButton, _("Remove")); - else - me.favoriteButton.setText(me.favoriteButton, _("Bookmark")); - } + ServerList_Update_favoriteButton(NULL, me); me.ipAddressBoxFocused = me.ipAddressBox.focused; } -- 2.39.2