File diff r18880:d1db1f3ee26b → r18881:ca79a2e629a6
src/engine_gui.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/*
 
 * This file is part of OpenTTD.
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file engine_gui.cpp GUI to show engine related information. */
 

	
 
#include "stdafx.h"
 
#include "window_gui.h"
 
#include "gfx_func.h"
 
#include "engine_base.h"
 
#include "command_func.h"
 
#include "strings_func.h"
 
#include "engine_gui.h"
 
#include "articulated_vehicles.h"
 
#include "vehicle_func.h"
 
#include "company_func.h"
 
#include "rail.h"
 
#include "settings_type.h"
 

	
 
#include "widgets/engine_widget.h"
 

	
 
#include "table/strings.h"
 

	
 
/**
 
 * Return the category of an engine.
 
 * @param engine Engine to examine.
 
 * @return String describing the category ("road veh", "train". "airplane", or "ship") of the engine.
 
 */
 
StringID GetEngineCategoryName(EngineID engine)
 
{
 
	const Engine *e = Engine::Get(engine);
 
	switch (e->type) {
 
		default: NOT_REACHED();
 
		case VEH_ROAD:              return STR_ENGINE_PREVIEW_ROAD_VEHICLE;
 
		case VEH_AIRCRAFT:          return STR_ENGINE_PREVIEW_AIRCRAFT;
 
		case VEH_SHIP:              return STR_ENGINE_PREVIEW_SHIP;
 
		case VEH_TRAIN:
 
			return GetRailTypeInfo(e->u.rail.railtype)->strings.new_loco;
 
	}
 
}
 

	
 
static const NWidgetPart _nested_engine_preview_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
 
		NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_ENGINE_PREVIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE),
 
		NWidget(WWT_EMPTY, INVALID_COLOUR, WID_EP_QUESTION), SetMinimalSize(300, 0), SetPadding(8, 8, 8, 8), SetFill(1, 0),
 
		NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(85, 10, 85),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_EP_NO), SetDataTip(STR_QUIT_NO, STR_NULL), SetFill(1, 0),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_EP_YES), SetDataTip(STR_QUIT_YES, STR_NULL), SetFill(1, 0),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 8),
 
	EndContainer(),
 
};
 

	
 
struct EnginePreviewWindow : Window {