summaryrefslogtreecommitdiff
path: root/src/roadveh_gui.cpp
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2007-01-22 02:09:51 +0000
committerbjarni <bjarni@openttd.org>2007-01-22 02:09:51 +0000
commit6ccbfffbeabf2c7c814a5b251265201f86581571 (patch)
tree1f61292e8f2a6f5505daf3630655f44b8c653f16 /src/roadveh_gui.cpp
parentcf0e5816d6ea6e625803fa3597a74c8f75e98d5e (diff)
downloadopenttd-6ccbfffbeabf2c7c814a5b251265201f86581571.tar.xz
(svn r8338) -Codechange: merged road vehicle build window into the other ones
Note: now all build vehicle windows are merged into build_vehicle_gui.cpp
Diffstat (limited to 'src/roadveh_gui.cpp')
-rw-r--r--src/roadveh_gui.cpp183
1 files changed, 0 insertions, 183 deletions
diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp
index c112f5891..8d525f395 100644
--- a/src/roadveh_gui.cpp
+++ b/src/roadveh_gui.cpp
@@ -22,53 +22,6 @@
#include "newgrf_engine.h"
#include "date.h"
-/**
- * Draw the purchase info details of road vehicle at a given location.
- * @param x,y location where to draw the info
- * @param engine_number the engine of which to draw the info of
- */
-void DrawRoadVehPurchaseInfo(int x, int y, uint w, EngineID engine_number)
-{
- const RoadVehicleInfo *rvi = RoadVehInfo(engine_number);
- const Engine *e = GetEngine(engine_number);
- bool refittable = (_engine_info[engine_number].refit_mask != 0);
- YearMonthDay ymd;
- ConvertDateToYMD(e->intro_date, &ymd);
-
- /* Purchase cost - Max speed */
- SetDParam(0, rvi->base_cost * (_price.roadveh_base>>3)>>5);
- SetDParam(1, rvi->max_speed / 2);
- DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0);
- y += 10;
-
- /* Running cost */
- SetDParam(0, rvi->running_cost * _price.roadveh_running >> 8);
- DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
- y += 10;
-
- /* Cargo type + capacity */
- SetDParam(0, rvi->cargo_type);
- SetDParam(1, rvi->capacity);
- SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY);
- DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);
- y += 10;
-
- /* Design date - Life length */
- SetDParam(0, ymd.year);
- SetDParam(1, e->lifelength);
- DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0);
- y += 10;
-
- /* Reliability */
- SetDParam(0, e->reliability * 100 >> 16);
- DrawString(x, y, STR_PURCHASE_INFO_RELIABILITY, 0);
- y += 10;
-
- /* Additional text from NewGRF */
- y += ShowAdditionalText(x, y, w, engine_number);
- y += ShowRefitOptionsList(x, y, w, engine_number);
-}
-
void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection)
{
SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
@@ -396,48 +349,6 @@ void ShowRoadVehViewWindow(const Vehicle *v)
}
}
-
-static void DrawNewRoadVehWindow(Window *w)
-{
- EngineID selected_id;
- EngineID e;
- uint count;
- int pos;
- int sel;
- int y;
-
- SetWindowWidgetDisabledState(w, 5, w->window_number == 0);
-
- count = 0;
- for (e = ROAD_ENGINES_INDEX; e < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; e++) {
- if (HASBIT(GetEngine(e)->player_avail, _local_player)) count++;
- }
- SetVScrollCount(w, count);
-
- DrawWindowWidgets(w);
-
- y = 15;
- sel = WP(w,buildvehicle_d).sel_index;
- pos = w->vscroll.pos;
- selected_id = INVALID_ENGINE;
- for (e = ROAD_ENGINES_INDEX; e < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; e++) {
- if (!HASBIT(GetEngine(e)->player_avail, _local_player)) continue;
- if (sel == 0) selected_id = e;
- if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) {
- DrawString(60, y + 2, GetCustomEngineName(e), sel == 0 ? 0xC : 0x10);
- DrawRoadVehEngine(30, y + 6, e, GetEnginePalette(e, _local_player));
- y += 14;
- }
- sel--;
- }
-
- WP(w,buildvehicle_d).sel_engine = selected_id;
- if (selected_id != INVALID_ENGINE) {
- const Widget *wi = &w->widget[4];
- DrawRoadVehPurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, selected_id);
- }
-}
-
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
const Vehicle *v;
@@ -451,97 +362,3 @@ void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2)
}
ShowRoadVehViewWindow(v);
}
-
-static void NewRoadVehWndProc(Window *w, WindowEvent *e)
-{
- switch (e->event) {
- case WE_PAINT:
- DrawNewRoadVehWindow(w);
- break;
-
- case WE_CLICK:
- switch (e->we.click.widget) {
- case 2: { /* listbox */
- uint i = (e->we.click.pt.y - 14) / 14;
- if (i < w->vscroll.cap) {
- WP(w,buildvehicle_d).sel_index = i + w->vscroll.pos;
- SetWindowDirty(w);
- }
- } break;
-
- case 5: { /* build */
- EngineID sel_eng = WP(w,buildvehicle_d).sel_engine;
- if (sel_eng != INVALID_ENGINE)
- DoCommandP(w->window_number, sel_eng, 0, CcBuildRoadVeh, CMD_BUILD_ROAD_VEH | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE));
- } break;
-
- case 6: { /* rename */
- EngineID sel_eng = WP(w,buildvehicle_d).sel_engine;
- if (sel_eng != INVALID_ENGINE) {
- WP(w,buildvehicle_d).rename_engine = sel_eng;
- ShowQueryString(GetCustomEngineName(sel_eng), STR_9036_RENAME_ROAD_VEHICLE_TYPE, 31, 160, w, CS_ALPHANUMERAL);
- }
- } break;
- }
- break;
-
- case WE_ON_EDIT_TEXT:
- if (e->we.edittext.str[0] != '\0') {
- _cmd_text = e->we.edittext.str;
- DoCommandP(0, WP(w, buildvehicle_d).rename_engine, 0, NULL,
- CMD_RENAME_ENGINE | CMD_MSG(STR_9037_CAN_T_RENAME_ROAD_VEHICLE));
- }
- break;
-
- case WE_RESIZE: {
- if (e->we.sizing.diff.y == 0) break;
-
- w->vscroll.cap += e->we.sizing.diff.y / 14;
- w->widget[2].data = (w->vscroll.cap << 8) + 1;
- } break;
-
- }
-}
-
-static const Widget _new_road_veh_widgets[] = {
-{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{ WWT_CAPTION, RESIZE_NONE, 14, 11, 247, 0, 13, STR_9006_NEW_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 235, 14, 125, 0x801, STR_9026_ROAD_VEHICLE_SELECTION},
-{ WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 236, 247, 14, 125, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
-{ WWT_PANEL, RESIZE_TB, 14, 0, 247, 126, 217, 0x0, STR_NULL},
-{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 117, 218, 229, STR_9007_BUILD_VEHICLE, STR_9027_BUILD_THE_HIGHLIGHTED_ROAD},
-{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 118, 235, 218, 229, STR_9034_RENAME, STR_9035_RENAME_ROAD_VEHICLE_TYPE},
-{ WWT_RESIZEBOX, RESIZE_TB, 14, 236, 247, 218, 229, 0x0, STR_RESIZE_BUTTON},
-{ WIDGETS_END},
-};
-
-static const WindowDesc _new_road_veh_desc = {
- WDP_AUTO, WDP_AUTO, 248, 230,
- WC_BUILD_VEHICLE,0,
- WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
- _new_road_veh_widgets,
- NewRoadVehWndProc
-};
-
-void ShowBuildRoadVehWindow(TileIndex tile)
-{
- Window *w;
-
- DeleteWindowById(WC_BUILD_VEHICLE, tile);
-
- w = AllocateWindowDescFront(&_new_road_veh_desc, tile);
- w->vscroll.cap = 8;
- w->widget[2].data = (w->vscroll.cap << 8) + 1;
-
- w->resize.step_height = 14;
- w->resize.height = w->height - 14 * 4; /* Minimum of 4 vehicles in the display */
-
- if (tile != 0) {
- w->caption_color = GetTileOwner(tile);
- } else {
- w->caption_color = _local_player;
- }
-}
-
-
-