(svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.

This commit is contained in:
rubidium 2008-04-13 22:25:18 +00:00
parent b6ce235700
commit 60102c9d73

View File

@ -69,10 +69,7 @@ static void SignListWndProc(Window *w, WindowEvent *e)
{ {
switch (e->event) { switch (e->event) {
case WE_PAINT: { case WE_PAINT: {
int y = 16; // offset from top of widget if (_sign_sort_dirty) GlobalSortSignList();
if (_sign_sort_dirty)
GlobalSortSignList();
SetVScrollCount(w, _num_sign_sort); SetVScrollCount(w, _num_sign_sort);
@ -80,47 +77,36 @@ static void SignListWndProc(Window *w, WindowEvent *e)
DrawWindowWidgets(w); DrawWindowWidgets(w);
/* No signs? */ /* No signs? */
int y = 16; // offset from top of widget
if (w->vscroll.count == 0) { if (w->vscroll.count == 0) {
DrawString(2, y, STR_304A_NONE, TC_FROMSTRING); DrawString(2, y, STR_304A_NONE, TC_FROMSTRING);
return; return;
} }
{
uint16 i;
/* Start drawing the signs */ /* Start drawing the signs */
for (i = w->vscroll.pos; i < w->vscroll.cap + w->vscroll.pos && i < w->vscroll.count; i++) { for (uint16 i = w->vscroll.pos; i < w->vscroll.cap + w->vscroll.pos && i < w->vscroll.count; i++) {
const Sign *si = _sign_sort[i]; const Sign *si = _sign_sort[i];
if (si->owner != OWNER_NONE) if (si->owner != OWNER_NONE) DrawPlayerIcon(si->owner, 4, y + 1);
DrawPlayerIcon(si->owner, 4, y + 1);
SetDParam(0, si->index); SetDParam(0, si->index);
DrawString(22, y, STR_SIGN_NAME, TC_YELLOW); DrawString(22, y, STR_SIGN_NAME, TC_YELLOW);
y += 10; y += 10;
} }
}
} break; } break;
case WE_CLICK: { case WE_CLICK:
switch (e->we.click.widget) { if (e->we.click.widget == 3) {
case 3: {
uint32 id_v = (e->we.click.pt.y - 15) / 10; uint32 id_v = (e->we.click.pt.y - 15) / 10;
const Sign *si;
if (id_v >= w->vscroll.cap)
return;
if (id_v >= w->vscroll.cap) return;
id_v += w->vscroll.pos; id_v += w->vscroll.pos;
if (id_v >= w->vscroll.count) return;
if (id_v >= w->vscroll.count) const Sign *si = _sign_sort[id_v];
return;
si = _sign_sort[id_v];
ScrollMainWindowToTile(TileVirtXY(si->x, si->y)); ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
} break;
} }
} break; break;
case WE_RESIZE: case WE_RESIZE:
w->vscroll.cap += e->we.sizing.diff.y / 10; w->vscroll.cap += e->we.sizing.diff.y / 10;
@ -149,9 +135,7 @@ static const WindowDesc _sign_list_desc = {
void ShowSignList() void ShowSignList()
{ {
Window *w; Window *w = AllocateWindowDescFront(&_sign_list_desc, 0);
w = AllocateWindowDescFront(&_sign_list_desc, 0);
if (w != NULL) { if (w != NULL) {
w->vscroll.cap = 12; w->vscroll.cap = 12;
w->resize.step_height = 10; w->resize.step_height = 10;
@ -159,8 +143,7 @@ void ShowSignList()
} }
} }
/* Edit sign window stuff */ /** Edit sign window stuff */
struct editsign_d : querystr_d { struct editsign_d : querystr_d {
SignID cur_sign; SignID cur_sign;
}; };
@ -314,13 +297,11 @@ static const WindowDesc _query_sign_edit_desc = {
void ShowRenameSignWindow(const Sign *si) void ShowRenameSignWindow(const Sign *si)
{ {
Window *w;
/* Delete all other edit windows and the save window */ /* Delete all other edit windows and the save window */
DeleteWindowById(WC_QUERY_STRING, 0); DeleteWindowById(WC_QUERY_STRING, 0);
DeleteWindowById(WC_SAVELOAD, 0); DeleteWindowById(WC_SAVELOAD, 0);
w = AllocateWindowDesc(&_query_sign_edit_desc); Window *w = AllocateWindowDesc(&_query_sign_edit_desc);
WP(w, editsign_d).caption = STR_280B_EDIT_SIGN_TEXT; WP(w, editsign_d).caption = STR_280B_EDIT_SIGN_TEXT;
WP(w, editsign_d).afilter = CS_ALPHANUMERAL; WP(w, editsign_d).afilter = CS_ALPHANUMERAL;
@ -328,6 +309,3 @@ void ShowRenameSignWindow(const Sign *si)
UpdateSignEditWindow(w, si); UpdateSignEditWindow(w, si);
} }