From 78b64ed1925c99ecc4fe26ffb4969b7001e7e095 Mon Sep 17 00:00:00 2001 From: darkvater Date: Mon, 6 Sep 2004 21:20:01 +0000 Subject: (svn r169) -Fix: move around sort-widgets a bit so it looks more natural -Fix: savegames are sorted with newest date first by default -Codechange: refine sorter functions -Fix: fixed linux warnings (tokai) --- ship_gui.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'ship_gui.c') diff --git a/ship_gui.c b/ship_gui.c index 12f927b2b..a43db3295 100644 --- a/ship_gui.c +++ b/ship_gui.c @@ -911,11 +911,9 @@ static void MakeSortedShiptList(byte owner) n = _num_ship_sort[owner] - _num_ship_sort[owner-1]; } - _internal_sort_type = _ship_sort_type[owner]; _internal_sort_order = _ship_sort_order[owner]; _internal_name_sorter_id = STR_SV_SHIP_NAME; - // only name sorting needs a different procedure, all others are handled by the general sorter - qsort(firstelement, n, sizeof(_ship_sort[0]), (_internal_sort_type == SORT_BY_NAME) ? VehicleNameSorter : GeneralVehicleSorter); + qsort(firstelement, n, sizeof(_ship_sort[0]), _vehicle_sorter[_ship_sort_type[owner]]); DEBUG(misc, 1) ("Resorting Ships list player %d...", owner+1); } @@ -928,7 +926,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e) const byte window_number = (byte)w->window_number; if (_ship_sort_type[window_number] == SORT_BY_UNSORTED) // disable 'Sort By' tooltip on Unsorted sorting criteria - w->disabled_state |= (1 << 3); + w->disabled_state |= (1 << 2); if (_ship_sort_dirty[window_number] || _vehicle_sort_dirty[VEHSHIP]) { _ship_sort_dirty[window_number] = false; @@ -950,11 +948,12 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e) SET_DPARAM16(0, p->name_1); SET_DPARAM32(1, p->name_2); SET_DPARAM16(2, w->vscroll.count); - SET_DPARAM16(3, _vehicle_sort_listing[_ship_sort_type[window_number]]); DrawWindowWidgets(w); } + /* draw sorting criteria string */ + DrawString(85, 15, _vehicle_sort_listing[_ship_sort_type[window_number]], 0x10); /* draw arrow pointing up/down for ascending/descending soring */ - DoDrawString(_ship_sort_order[window_number] & 1 ? "\xAA" : "\xA0", 85, 15, 0x10); + DoDrawString(_ship_sort_order[window_number] & 1 ? "\xAA" : "\xA0", 69, 15, 0x10); /* draw the ship vehicles */ { @@ -1000,13 +999,13 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e) case WE_CLICK: { switch(e->click.widget) { - case 3: /* Flip sorting method ascending/descending */ + case 2: /* Flip sorting method ascending/descending */ _ship_sort_order[(byte)w->window_number] ^= 1; _ship_sort_dirty[(byte)w->window_number] = true; SetWindowDirty(w); break; - case 4: case 5:/* Select sorting criteria dropdown menu */ - ShowDropDownMenu(w, _vehicle_sort_listing, _ship_sort_type[(byte)w->window_number], 5, 0); // do it for widget 5 + case 3: case 4:/* Select sorting criteria dropdown menu */ + ShowDropDownMenu(w, _vehicle_sort_listing, _ship_sort_type[(byte)w->window_number], 4, 0); // do it for widget 4 return; case 6: { /* Matrix to show vehicles */ int id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_BIG; @@ -1056,7 +1055,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e) _ship_sort_type[(byte)w->window_number] = e->dropdown.index; if (_ship_sort_type[(byte)w->window_number] != SORT_BY_UNSORTED) // enable 'Sort By' if a sorter criteria is chosen - w->disabled_state &= ~(1 << 3); + w->disabled_state &= ~(1 << 2); SetWindowDirty(w); break; @@ -1077,13 +1076,14 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e) break; } } + static const Widget _player_ships_widgets[] = { { WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, { WWT_CAPTION, 14, 11, 259, 0, 13, STR_9805_SHIPS, STR_018C_WINDOW_TITLE_DRAG_THIS}, -{ WWT_PANEL, 14, 0, 15, 14, 25, 0x0, 0}, -{ WWT_PUSHTXTBTN, 14, 16, 96, 14, 25, SRT_SORT_BY, STR_SORT_TIP}, -{ WWT_TEXTBTN, 14, 97, 248, 14, 25, STR_02E7, 0}, -{ WWT_CLOSEBOX, 14, 249, 259, 14, 25, STR_0225, STR_SORT_TIP}, +{ WWT_PUSHTXTBTN, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP}, +{ WWT_PANEL, 14, 81, 237, 14, 25, 0x0, 0}, +{ WWT_CLOSEBOX, 14, 238, 248, 14, 25, STR_0225, STR_SORT_TIP}, +{ WWT_PANEL, 14, 249, 259, 14, 25, 0x0, 0}, { WWT_MATRIX, 14, 0, 248, 26, 169, 0x401, STR_9823_SHIPS_CLICK_ON_SHIP_FOR}, { WWT_SCROLLBAR, 14, 249, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, { WWT_PUSHTXTBTN, 14, 0, 129, 170, 181, STR_9804_NEW_SHIPS, STR_9824_BUILD_NEW_SHIPS_REQUIRES}, @@ -1094,7 +1094,7 @@ static const Widget _player_ships_widgets[] = { static const WindowDesc _player_ships_desc = { -1, -1, 260, 182, WC_SHIPS_LIST,0, - WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM, + WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, _player_ships_widgets, PlayerShipsWndProc }; @@ -1102,10 +1102,10 @@ static const WindowDesc _player_ships_desc = { static const Widget _other_player_ships_widgets[] = { { WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, { WWT_CAPTION, 14, 11, 259, 0, 13, STR_9805_SHIPS, STR_018C_WINDOW_TITLE_DRAG_THIS}, -{ WWT_PANEL, 14, 0, 15, 14, 25, 0x0, 0}, -{ WWT_PUSHTXTBTN, 14, 16, 96, 14, 25, SRT_SORT_BY, STR_SORT_TIP}, -{ WWT_TEXTBTN, 14, 97, 248, 14, 25, STR_02E7, 0}, -{ WWT_CLOSEBOX, 14, 249, 259, 14, 25, STR_0225, STR_SORT_TIP}, +{ WWT_PUSHTXTBTN, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP}, +{ WWT_PANEL, 14, 81, 237, 14, 25, 0x0, 0}, +{ WWT_CLOSEBOX, 14, 238, 248, 14, 25, STR_0225, STR_SORT_TIP}, +{ WWT_PANEL, 14, 249, 259, 14, 25, 0x0, 0}, { WWT_MATRIX, 14, 0, 248, 26, 169, 0x401, STR_9823_SHIPS_CLICK_ON_SHIP_FOR}, { WWT_SCROLLBAR, 14, 249, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, { WWT_LAST}, @@ -1114,7 +1114,7 @@ static const Widget _other_player_ships_widgets[] = { static const WindowDesc _other_player_ships_desc = { -1, -1, 260, 170, WC_SHIPS_LIST,0, - WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM, + WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, _other_player_ships_widgets, PlayerShipsWndProc }; -- cgit v1.2.3-54-g00ecf