(svn r12705) -Codechange: enumification of some more widgets

This commit is contained in:
belugas 2008-04-14 17:50:15 +00:00
parent 8418bc5050
commit a8008db23d

View File

@ -275,18 +275,28 @@ static void ShowTownAuthorityWindow(uint town)
} }
} }
enum TownViewWidget {
TVW_CAPTION = 1,
TVW_CENTERVIEW = 6,
TVW_SHOWAUTORITY,
TVW_CHANGENAME,
TVW_EXPAND,
TVW_DELETE,
};
static void TownViewWndProc(Window *w, WindowEvent *e) static void TownViewWndProc(Window *w, WindowEvent *e)
{ {
Town *t = GetTown(w->window_number); Town *t = GetTown(w->window_number);
switch (e->event) { switch (e->event) {
case WE_CREATE: case WE_CREATE:
if (t->larger_town) w->widget[1].data = STR_CITY; if (t->larger_town) w->widget[TVW_CAPTION].data = STR_CITY;
break; break;
case WE_PAINT: case WE_PAINT:
/* disable renaming town in network games if you are not the server */ /* disable renaming town in network games if you are not the server */
w->SetWidgetDisabledState(8, _networking && !_network_server); w->SetWidgetDisabledState(TVW_CHANGENAME, _networking && !_network_server);
SetDParam(0, t->index); SetDParam(0, t->index);
DrawWindowWidgets(w); DrawWindowWidgets(w);
@ -308,24 +318,24 @@ static void TownViewWndProc(Window *w, WindowEvent *e)
case WE_CLICK: case WE_CLICK:
switch (e->we.click.widget) { switch (e->we.click.widget) {
case 6: /* scroll to location */ case TVW_CENTERVIEW: /* scroll to location */
ScrollMainWindowToTile(t->xy); ScrollMainWindowToTile(t->xy);
break; break;
case 7: /* town authority */ case TVW_SHOWAUTORITY: /* town authority */
ShowTownAuthorityWindow(w->window_number); ShowTownAuthorityWindow(w->window_number);
break; break;
case 8: /* rename */ case TVW_CHANGENAME: /* rename */
SetDParam(0, w->window_number); SetDParam(0, w->window_number);
ShowQueryString(STR_TOWN, STR_2007_RENAME_TOWN, 31, 130, w, CS_ALPHANUMERAL); ShowQueryString(STR_TOWN, STR_2007_RENAME_TOWN, 31, 130, w, CS_ALPHANUMERAL);
break; break;
case 9: /* expand town */ case TVW_EXPAND: /* expand town - only available on Scenario editor */
ExpandTown(t); ExpandTown(t);
break; break;
case 10: /* delete town */ case TVW_DELETE: /* delete town - only available on Scenario editor */
delete t; delete t;
break; break;
} break; } break;
@ -592,6 +602,16 @@ static void PlaceProc_Town(TileIndex tile)
DoCommandP(tile, size, mode, CcBuildTown, CMD_BUILD_TOWN | CMD_MSG(STR_0236_CAN_T_BUILD_TOWN_HERE)); DoCommandP(tile, size, mode, CcBuildTown, CMD_BUILD_TOWN | CMD_MSG(STR_0236_CAN_T_BUILD_TOWN_HERE));
} }
enum TownScenarioEditorWidget {
TSEW_NEWTOWN = 4,
TSEW_RANDOMTOWN,
TSEW_MANYRANDOMTOWNS,
TSEW_SMALLTOWN,
TSEW_MEDIUMTOWN,
TSEW_LARGETOWN,
TSEW_CITY,
};
static const Widget _scen_edit_town_gen_widgets[] = { static const Widget _scen_edit_town_gen_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_0233_TOWN_GENERATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, { WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_0233_TOWN_GENERATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
@ -616,21 +636,21 @@ static void ScenEditTownGenWndProc(Window *w, WindowEvent *e)
break; break;
case WE_CREATE: case WE_CREATE:
w->LowerWidget(_scengen_town_size + 7); w->LowerWidget(_scengen_town_size + TSEW_SMALLTOWN);
break; break;
case WE_CLICK: case WE_CLICK:
switch (e->we.click.widget) { switch (e->we.click.widget) {
case 4: // new town case TSEW_NEWTOWN:
HandlePlacePushButton(w, 4, SPR_CURSOR_TOWN, VHM_RECT, PlaceProc_Town); HandlePlacePushButton(w, TSEW_NEWTOWN, SPR_CURSOR_TOWN, VHM_RECT, PlaceProc_Town);
break; break;
case 5: {// random town case TSEW_RANDOMTOWN: {
Town *t; Town *t;
uint size = min(_scengen_town_size, (int)TSM_CITY); uint size = min(_scengen_town_size, (int)TSM_CITY);
TownSizeMode mode = _scengen_town_size > TSM_CITY ? TSM_CITY : TSM_FIXED; TownSizeMode mode = _scengen_town_size > TSM_CITY ? TSM_CITY : TSM_FIXED;
w->HandleButtonClick(5); w->HandleButtonClick(TSEW_RANDOMTOWN);
_generating_world = true; _generating_world = true;
t = CreateRandomTown(20, mode, size); t = CreateRandomTown(20, mode, size);
_generating_world = false; _generating_world = false;
@ -642,25 +662,25 @@ static void ScenEditTownGenWndProc(Window *w, WindowEvent *e)
} }
} break; } break;
case 6: // many random towns case TSEW_MANYRANDOMTOWNS:
w->HandleButtonClick(6); w->HandleButtonClick(TSEW_MANYRANDOMTOWNS);
_generating_world = true; _generating_world = true;
if (!GenerateTowns()) ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0); if (!GenerateTowns()) ShowErrorMessage(STR_NO_SPACE_FOR_TOWN, STR_CANNOT_GENERATE_TOWN, 0, 0);
_generating_world = false; _generating_world = false;
break; break;
case 7: case 8: case 9: case 10: case TSEW_SMALLTOWN: case TSEW_MEDIUMTOWN: case TSEW_LARGETOWN: case TSEW_CITY:
w->RaiseWidget(_scengen_town_size + 7); w->RaiseWidget(_scengen_town_size + TSEW_SMALLTOWN);
_scengen_town_size = e->we.click.widget - 7; _scengen_town_size = e->we.click.widget - TSEW_SMALLTOWN;
w->LowerWidget(_scengen_town_size + 7); w->LowerWidget(_scengen_town_size + TSEW_SMALLTOWN);
SetWindowDirty(w); SetWindowDirty(w);
break; break;
} break; } break;
case WE_TIMEOUT: case WE_TIMEOUT:
w->RaiseWidget(5); w->RaiseWidget(TSEW_RANDOMTOWN);
w->RaiseWidget(6); w->RaiseWidget(TSEW_MANYRANDOMTOWNS);
SetWindowDirty(w); SetWindowDirty(w);
break; break;
@ -670,7 +690,7 @@ static void ScenEditTownGenWndProc(Window *w, WindowEvent *e)
case WE_ABORT_PLACE_OBJ: case WE_ABORT_PLACE_OBJ:
w->RaiseButtons(); w->RaiseButtons();
w->LowerWidget(_scengen_town_size + 7); w->LowerWidget(_scengen_town_size + TSEW_SMALLTOWN);
SetWindowDirty(w); SetWindowDirty(w);
break; break;
} }