Files
@ r606:8ecd7d248197
Branch filter:
Location: cpp/openttd-patchpack/source/dock_gui.c - annotation
r606:8ecd7d248197
8.3 KiB
text/x-c
(svn r1030) Some toolbar icons are arranged differently:
- Landscaping buttons have to be accessed from the landscaping toolbar
- Landscaping toolbar can be opened from all other toolbars
- The order of buttons in the docks toolbar now matches the other toolbars
- Landscaping toolbar has new keyboard shortcuts
- Landscaping buttons have to be accessed from the landscaping toolbar
- Landscaping toolbar can be opened from all other toolbars
- The order of buttons in the docks toolbar now matches the other toolbars
- Landscaping toolbar has new keyboard shortcuts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | r0:d63b455452f6 r0:d63b455452f6 r507:b1b0a0a3c313 r0:d63b455452f6 r568:3ee180395698 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r337:998f55d0b04c r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r543:efdb197f91ad r0:d63b455452f6 r0:d63b455452f6 r541:062eeec7f0a4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r543:efdb197f91ad r0:d63b455452f6 r541:062eeec7f0a4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r606:8ecd7d248197 r0:d63b455452f6 r606:8ecd7d248197 r0:d63b455452f6 r0:d63b455452f6 r606:8ecd7d248197 r0:d63b455452f6 r606:8ecd7d248197 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r606:8ecd7d248197 r0:d63b455452f6 r606:8ecd7d248197 r0:d63b455452f6 r0:d63b455452f6 r606:8ecd7d248197 r0:d63b455452f6 r606:8ecd7d248197 r606:8ecd7d248197 r0:d63b455452f6 r0:d63b455452f6 r606:8ecd7d248197 r0:d63b455452f6 r606:8ecd7d248197 r0:d63b455452f6 r0:d63b455452f6 r606:8ecd7d248197 r0:d63b455452f6 r606:8ecd7d248197 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r606:8ecd7d248197 r606:8ecd7d248197 r606:8ecd7d248197 r606:8ecd7d248197 r606:8ecd7d248197 r606:8ecd7d248197 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r606:8ecd7d248197 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r606:8ecd7d248197 r606:8ecd7d248197 r606:8ecd7d248197 r606:8ecd7d248197 r606:8ecd7d248197 r606:8ecd7d248197 r606:8ecd7d248197 r606:8ecd7d248197 r606:8ecd7d248197 r606:8ecd7d248197 r606:8ecd7d248197 r606:8ecd7d248197 r176:7d9100f64c27 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r606:8ecd7d248197 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r568:3ee180395698 r568:3ee180395698 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r568:3ee180395698 r568:3ee180395698 r568:3ee180395698 r568:3ee180395698 r568:3ee180395698 r568:3ee180395698 r568:3ee180395698 r568:3ee180395698 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r193:6aa65dc5a4b4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r176:7d9100f64c27 r176:7d9100f64c27 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r541:062eeec7f0a4 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r176:7d9100f64c27 r0:d63b455452f6 r0:d63b455452f6 r176:7d9100f64c27 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 r0:d63b455452f6 | #include "stdafx.h"
#include "ttd.h"
#include "table/strings.h"
#include "window.h"
#include "station.h"
#include "gui.h"
#include "viewport.h"
#include "gfx.h"
#include "sound.h"
#include "command.h"
static void ShowBuildDockStationPicker();
static void ShowBuildDocksDepotPicker();
static byte _ship_depot_direction;
void CcBuildDocks(bool success, uint tile, uint32 p1, uint32 p2)
{
if (success) {
SndPlayTileFx(SND_02_SPLAT, tile);
ResetObjectToPlace();
}
}
void CcBuildCanal(bool success, uint tile, uint32 p1, uint32 p2)
{
if (success) SndPlayTileFx(SND_02_SPLAT, tile);
}
static void PlaceDocks_Dock(uint tile)
{
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_DOCK | CMD_AUTO | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE));
}
static void PlaceDocks_Depot(uint tile)
{
DoCommandP(tile, _ship_depot_direction, 0, CcBuildDocks, CMD_BUILD_SHIP_DEPOT | CMD_AUTO | CMD_MSG(STR_3802_CAN_T_BUILD_SHIP_DEPOT));
}
static void PlaceDocks_Buoy(uint tile)
{
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_BUOY | CMD_AUTO | CMD_MSG(STR_9835_CAN_T_POSITION_BUOY_HERE));
}
static void PlaceDocks_DemolishArea(uint tile)
{
VpStartPlaceSizing(tile, VPM_X_AND_Y);
}
static void PlaceDocks_BuildCanal(uint tile)
{
VpStartPlaceSizing(tile, VPM_X_OR_Y);
}
static void PlaceDocks_BuildLock(uint tile)
{
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_LOCK | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_LOCKS));
}
static void BuildDocksClick_Canal(Window *w)
{
HandlePlacePushButton(w, 2, SPR_OPENTTD_BASE + 11, 1, PlaceDocks_BuildCanal);
}
static void BuildDocksClick_Lock(Window *w)
{
HandlePlacePushButton(w, 3, SPR_OPENTTD_BASE + 64, 1, PlaceDocks_BuildLock);
}
static void BuildDocksClick_Demolish(Window *w)
{
HandlePlacePushButton(w, 5, ANIMCURSOR_DEMOLISH, 1, PlaceDocks_DemolishArea);
}
static void BuildDocksClick_Depot(Window *w)
{
if (HandlePlacePushButton(w, 6, 0x2D1, 1, PlaceDocks_Depot)) ShowBuildDocksDepotPicker();
}
static void BuildDocksClick_Dock(Window *w)
{
if (HandlePlacePushButton(w, 7, 0xE54, 3, PlaceDocks_Dock)) ShowBuildDockStationPicker();
}
static void BuildDocksClick_Buoy(Window *w)
{
HandlePlacePushButton(w, 8, 0x2BE, 1, PlaceDocks_Buoy);
}
static void BuildDocksClick_Landscaping(Window *w)
{
ShowTerraformToolbar();
}
typedef void OnButtonClick(Window *w);
static OnButtonClick * const _build_docks_button_proc[] = {
BuildDocksClick_Canal,
BuildDocksClick_Lock,
0,
BuildDocksClick_Demolish,
BuildDocksClick_Depot,
BuildDocksClick_Dock,
BuildDocksClick_Buoy,
BuildDocksClick_Landscaping,
};
static void BuildDocksToolbWndProc(Window *w, WindowEvent *e)
{
switch(e->event) {
case WE_PAINT:
DrawWindowWidgets(w);
break;
case WE_CLICK: {
if (e->click.widget - 2 >= 0 && e->click.widget!=4) _build_docks_button_proc[e->click.widget - 2](w);
} break;
case WE_PLACE_OBJ:
_place_proc(e->place.tile);
break;
case WE_PLACE_DRAG: {
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata);
return;
}
case WE_PLACE_MOUSEUP:
if (e->click.pt.x != -1) {
if (e->place.userdata == VPM_X_AND_Y)
DoCommandP(e->place.tile, e->place.starttile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
else if(e->place.userdata == VPM_X_OR_Y)
DoCommandP(e->place.tile, e->place.starttile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
}
break;
case WE_ABORT_PLACE_OBJ:
w->click_state = 0;
SetWindowDirty(w);
w = FindWindowById(WC_BUILD_STATION, 0);
if (w != NULL) WP(w,def_d).close=true;
w = FindWindowById(WC_BUILD_DEPOT, 0);
if (w != NULL) WP(w,def_d).close=true;
break;
case WE_PLACE_PRESIZE: {
uint tile_from, tile_to;
tile_from = tile_to = e->place.tile;
switch(GetTileSlope(tile_from, NULL)) {
case 3: tile_to += TILE_XY(-1,0); break;
case 6: tile_to += TILE_XY(0,-1); break;
case 9: tile_to += TILE_XY(0,1); break;
case 12:tile_to += TILE_XY(1,0); break;
}
VpSetPresizeRange(tile_from, tile_to);
} break;
}
}
static const Widget _build_docks_toolb_widgets[] = {
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, 7, 11, 157, 0, 13, STR_9801_DOCK_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_PANEL, 7, 0, 21, 14, 35, SPR_OPENTTD_BASE+65, STR_BUILD_CANALS_TIP},
{ WWT_PANEL, 7, 22, 43, 14, 35, SPR_CANALS_BASE+69, STR_BUILD_LOCKS_TIP},
{ WWT_PANEL, 7, 44, 47, 14, 35, 0x0, STR_NULL},
{ WWT_PANEL, 7, 48, 69, 14, 35, 703, STR_018D_DEMOLISH_BUILDINGS_ETC},
{ WWT_PANEL, 7, 70, 91, 14, 35, 748, STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING},
{ WWT_PANEL, 7, 92, 113, 14, 35, 746, STR_981D_BUILD_SHIP_DOCK},
{ WWT_PANEL, 7, 114, 135, 14, 35, 693, STR_9834_POSITION_BUOY_WHICH_CAN},
{ WWT_PANEL, 7, 136, 157, 14, 35, SPR_IMG_LANDSCAPING_S, STR_LANDSCAPING_TOOLBAR_TIP},
{ WIDGETS_END},
};
static const WindowDesc _build_docks_toolbar_desc = {
640-158, 22, 158, 36,
WC_BUILD_TOOLBAR,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_build_docks_toolb_widgets,
BuildDocksToolbWndProc
};
void ShowBuildDocksToolbar()
{
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
AllocateWindowDesc(&_build_docks_toolbar_desc);
}
static void BuildDockStationWndProc(Window *w, WindowEvent *e)
{
int rad;
switch(e->event) {
case WE_PAINT: {
if (WP(w,def_d).close)
return;
DrawWindowWidgets(w);
//Add some code for the coverage area eariler or later!!
if (_patches.modified_catchment) {
rad = CA_DOCK;
} else {
rad = 4;
}
DrawStationCoverageAreaText(2, 15, (uint)-1, rad);
} break;
case WE_CLICK: {
if (e->click.widget == 0) {
ResetObjectToPlace();
}
} break;
case WE_MOUSELOOP: {
if (WP(w,def_d).close) {
DeleteWindow(w);
return;
}
CheckRedrawStationCoverage(w);
break;
}
}
}
static const Widget _build_dock_station_widgets[] = {
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, 7, 11, 147, 0, 13, STR_3068_DOCK, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_PANEL, 7, 0, 147, 14, 45, 0x0, STR_NULL},
{ WIDGETS_END},
};
static const WindowDesc _build_dock_station_desc = {
-1, -1, 148, 46,
WC_BUILD_STATION,WC_BUILD_TOOLBAR,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_build_dock_station_widgets,
BuildDockStationWndProc
};
static void ShowBuildDockStationPicker()
{
AllocateWindowDesc(&_build_dock_station_desc);
}
static void UpdateDocksDirection()
{
if (_ship_depot_direction != 0) {
SetTileSelectSize(1, 2);
} else {
SetTileSelectSize(2, 1);
}
}
static void BuildDocksDepotWndProc(Window *w, WindowEvent *e)
{
switch(e->event) {
case WE_PAINT:
w->click_state = (1<<3) << _ship_depot_direction;
DrawWindowWidgets(w);
DrawShipDepotSprite(67, 35, 0);
DrawShipDepotSprite(35, 51, 1);
DrawShipDepotSprite(135, 35, 2);
DrawShipDepotSprite(167, 51, 3);
return;
case WE_CLICK: {
switch(e->click.widget) {
case 0:
ResetObjectToPlace();
break;
case 3:
case 4:
_ship_depot_direction = e->click.widget - 3;
SndPlayFx(SND_15_BEEP);
UpdateDocksDirection();
SetWindowDirty(w);
break;
}
} break;
case WE_MOUSELOOP:
if (WP(w,def_d).close)
DeleteWindow(w);
break;
}
}
static const Widget _build_docks_depot_widgets[] = {
{ WWT_CLOSEBOX, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, 7, 11, 203, 0, 13, STR_3800_SHIP_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_PANEL, 7, 0, 203, 14, 85, 0x0, STR_NULL},
{ WWT_PANEL, 14, 3, 100, 17, 82, 0x0, STR_3803_SELECT_SHIP_DEPOT_ORIENTATION},
{ WWT_PANEL, 14, 103, 200, 17, 82, 0x0, STR_3803_SELECT_SHIP_DEPOT_ORIENTATION},
{ WIDGETS_END},
};
static const WindowDesc _build_docks_depot_desc = {
-1, -1, 204, 86,
WC_BUILD_DEPOT,WC_BUILD_TOOLBAR,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_build_docks_depot_widgets,
BuildDocksDepotWndProc
};
static void ShowBuildDocksDepotPicker()
{
AllocateWindowDesc(&_build_docks_depot_desc);
UpdateDocksDirection();
}
void InitializeDockGui()
{
_ship_depot_direction = 0;
}
|