|
|
/* $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 bridge_gui.cpp Graphical user interface for bridge construction */
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
#include "gui.h"
|
|
|
#include "command_func.h"
|
|
|
#include "economy_func.h"
|
|
|
#include "bridge.h"
|
|
|
#include "rail.h"
|
|
|
#include "strings_func.h"
|
|
|
#include "window_func.h"
|
|
|
#include "sound_func.h"
|
|
|
#include "gfx_func.h"
|
|
|
#include "tunnelbridge.h"
|
|
|
#include "sortlist_type.h"
|
|
|
#include "widgets/dropdown_func.h"
|
|
|
#include "core/geometry_func.hpp"
|
|
|
|
|
|
#include "table/strings.h"
|
|
|
|
|
|
/** The type of the last built rail bridge */
|
|
|
static BridgeType _last_railbridge_type = 0;
|
|
|
/** The type of the last built road bridge */
|
|
|
static BridgeType _last_roadbridge_type = 0;
|
|
|
|
|
|
/**
|
|
|
* Carriage for the data we need if we want to build a bridge
|
|
|
*/
|
|
|
struct BuildBridgeData {
|
|
|
BridgeType index;
|
|
|
const BridgeSpec *spec;
|
|
|
Money cost;
|
|
|
};
|
|
|
|
|
|
typedef GUIList<BuildBridgeData> GUIBridgeList;
|
|
|
|
|
|
/**
|
|
|
* Callback executed after a build Bridge CMD has been called
|
|
|
*
|
|
|
* @param result Whether the build succeded
|
|
|
* @param tile The tile where the command has been executed
|
|
|
* @param p1 not used
|
|
|
* @param p2 not used
|
|
|
*/
|
|
|
void CcBuildBridge(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
|
|
|
{
|
|
|
if (result.Succeeded()) SndPlayTileFx(SND_27_BLACKSMITH_ANVIL, tile);
|
|
|
}
|
|
|
|
|
|
/* Names of the build bridge selection window */
|
|
|
enum BuildBridgeSelectionWidgets {
|
|
|
BBSW_CAPTION,
|
|
|
BBSW_DROPDOWN_ORDER,
|
|
|
BBSW_DROPDOWN_CRITERIA,
|
|
|
BBSW_BRIDGE_LIST,
|