From: terencehill Date: Sat, 12 Feb 2011 11:10:37 +0000 (+0100) Subject: Make Bookmark button update its text (Bookmark/Remove) on address change X-Git-Tag: xonotic-v0.5.0~311^2~9^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2baa4e5296ba5265fd9063b1cad01171a0f2ee48;p=xonotic%2Fxonotic-data.pk3dir.git 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 --- 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; }