]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make Bookmark button update its text (Bookmark/Remove) on address change
authorterencehill <piuntn@gmail.com>
Sat, 12 Feb 2011 11:10:37 +0000 (12:10 +0100)
committerterencehill <piuntn@gmail.com>
Sat, 12 Feb 2011 15:31:08 +0000 (16:31 +0100)
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
qcsrc/menu/xonotic/serverlist.c

index fe9f860c314a3c93592c9e191626fb1cc70554d8..ee451744fb8899942380f76248d7ff8bfa638f51 100644 (file)
@@ -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;
index a3d747dabb9b2a1a3a26db9145b2785e82ae9bc3..0e4760e3ff3522af46781e235cc1a8cbfdcd1190 100644 (file)
@@ -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;
        }