summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordominik <dominik@openttd.org>2005-01-05 10:47:59 +0000
committerdominik <dominik@openttd.org>2005-01-05 10:47:59 +0000
commit87e5984ae218e23a93e070d061faa62a57f782e1 (patch)
tree59223fb5f008c09fcda127e280f8da8e54dbee51
parent9294d33611c144e927dbb44501d1c23feaf32b31 (diff)
downloadopenttd-87e5984ae218e23a93e070d061faa62a57f782e1.tar.xz
(svn r1383) Fix: You can now also delete automatically found servers by pressing "del"
Fix: The scrollbar is correctly updated when deleting servers
-rw-r--r--network_gui.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/network_gui.c b/network_gui.c
index 72a603f1a..fb266a190 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -76,6 +76,21 @@ static void NetworkTruncateString(char *name, const int max_width)
extern const char _openttd_revision[];
+static FiosItem *selected_map = NULL; // to highlight slected map
+
+// called when a new server is found on the network
+void UpdateNetworkGameWindow(bool unselect)
+{
+ Window *w;
+ w = FindWindowById(WC_NETWORK_WINDOW, 0);
+ if (w != NULL) {
+ if (unselect)
+ _selected_item = NULL;
+ w->vscroll.count = _network_game_count;
+ SetWindowDirty(w);
+ }
+}
+
static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
{
switch(e->event) {
@@ -334,10 +349,14 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
case WE_KEYPRESS:
if (_selected_field != 3) {
if ( e->keypress.keycode == WKC_DELETE ) { // press 'delete' to remove servers
- if (_selected_item != NULL && _selected_item->manually) {
+ if (_selected_item != NULL) {
NetworkGameListRemoveItem(_selected_item);
NetworkRebuildHostList();
SetWindowDirty(w);
+ _network_game_count--;
+ // reposition scrollbar
+ if (_network_game_count >= w->vscroll.cap && w->vscroll.pos > _network_game_count-w->vscroll.cap) w->vscroll.pos--;
+ UpdateNetworkGameWindow(false);
_selected_item = NULL;
}
}
@@ -411,21 +430,6 @@ static const WindowDesc _network_game_window_desc = {
NetworkGameWindowWndProc,
};
-static FiosItem *selected_map = NULL; // to highlight slected map
-
-// called when a new server is found on the network
-void UpdateNetworkGameWindow(bool unselect)
-{
- Window *w;
- w = FindWindowById(WC_NETWORK_WINDOW, 0);
- if (w != NULL) {
- if (unselect)
- _selected_item = NULL;
- w->vscroll.count = _network_game_count;
- SetWindowDirty(w);
- }
-}
-
void ShowNetworkGameWindow()
{
uint i;