src/main_gui.cpp
changeset 7889 e74ce8853ba7
parent 7857 6572278b5822
child 7922 a7e266f966d9
equal deleted inserted replaced
7888:a28f4cfff934 7889:e74ce8853ba7
   117  * @param cursor How should the cursor image change? E.g. cursor with depot image in it
   117  * @param cursor How should the cursor image change? E.g. cursor with depot image in it
   118  * @param mode Tile highlighting mode, e.g. drawing a rectangle or a dot on the ground
   118  * @param mode Tile highlighting mode, e.g. drawing a rectangle or a dot on the ground
   119  * @param placeproc Procedure which will be called when someone clicks on the map
   119  * @param placeproc Procedure which will be called when someone clicks on the map
   120  * @return true if the button is clicked, false if it's unclicked
   120  * @return true if the button is clicked, false if it's unclicked
   121  */
   121  */
   122 bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, int mode, PlaceProc *placeproc)
   122 bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc)
   123 {
   123 {
   124 	if (IsWindowWidgetDisabled(w, widget)) return false;
   124 	if (IsWindowWidgetDisabled(w, widget)) return false;
   125 
   125 
   126 	SndPlayFx(SND_15_BEEP);
   126 	SndPlayFx(SND_15_BEEP);
   127 	SetWindowDirty(w);
   127 	SetWindowDirty(w);
   350 static void SelectSignTool()
   350 static void SelectSignTool()
   351 {
   351 {
   352 	if (_cursor.sprite == SPR_CURSOR_SIGN) {
   352 	if (_cursor.sprite == SPR_CURSOR_SIGN) {
   353 		ResetObjectToPlace();
   353 		ResetObjectToPlace();
   354 	} else {
   354 	} else {
   355 		SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, 1, WC_MAIN_TOOLBAR, 0);
   355 		SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, VHM_RECT, WC_MAIN_TOOLBAR, 0);
   356 		_place_proc = PlaceProc_Sign;
   356 		_place_proc = PlaceProc_Sign;
   357 	}
   357 	}
   358 }
   358 }
   359 
   359 
   360 static void MenuClickForest(int index)
   360 static void MenuClickForest(int index)
  1195  * @todo Merge with terraform_gui.cpp (move there) after I have cooled down at its braindeadness
  1195  * @todo Merge with terraform_gui.cpp (move there) after I have cooled down at its braindeadness
  1196  * and changed OnButtonClick to include the widget as well in the function declaration. Post 0.4.0 - Darkvater
  1196  * and changed OnButtonClick to include the widget as well in the function declaration. Post 0.4.0 - Darkvater
  1197  */
  1197  */
  1198 static void EditorTerraformClick_Dynamite(Window *w)
  1198 static void EditorTerraformClick_Dynamite(Window *w)
  1199 {
  1199 {
  1200 	HandlePlacePushButton(w, 4, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea);
  1200 	HandlePlacePushButton(w, 4, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea);
  1201 }
  1201 }
  1202 
  1202 
  1203 static void EditorTerraformClick_LowerBigLand(Window *w)
  1203 static void EditorTerraformClick_LowerBigLand(Window *w)
  1204 {
  1204 {
  1205 	HandlePlacePushButton(w, 5, ANIMCURSOR_LOWERLAND, 2, PlaceProc_LowerBigLand);
  1205 	HandlePlacePushButton(w, 5, ANIMCURSOR_LOWERLAND, VHM_POINT, PlaceProc_LowerBigLand);
  1206 }
  1206 }
  1207 
  1207 
  1208 static void EditorTerraformClick_RaiseBigLand(Window *w)
  1208 static void EditorTerraformClick_RaiseBigLand(Window *w)
  1209 {
  1209 {
  1210 	HandlePlacePushButton(w, 6, ANIMCURSOR_RAISELAND, 2, PlaceProc_RaiseBigLand);
  1210 	HandlePlacePushButton(w, 6, ANIMCURSOR_RAISELAND, VHM_POINT, PlaceProc_RaiseBigLand);
  1211 }
  1211 }
  1212 
  1212 
  1213 static void EditorTerraformClick_LevelLand(Window *w)
  1213 static void EditorTerraformClick_LevelLand(Window *w)
  1214 {
  1214 {
  1215 	HandlePlacePushButton(w, 7, SPR_CURSOR_LEVEL_LAND, 2, PlaceProc_LevelLand);
  1215 	HandlePlacePushButton(w, 7, SPR_CURSOR_LEVEL_LAND, VHM_POINT, PlaceProc_LevelLand);
  1216 }
  1216 }
  1217 
  1217 
  1218 static void EditorTerraformClick_WaterArea(Window *w)
  1218 static void EditorTerraformClick_WaterArea(Window *w)
  1219 {
  1219 {
  1220 	HandlePlacePushButton(w, 8, SPR_CURSOR_CANAL, 1, PlaceProc_WaterArea);
  1220 	HandlePlacePushButton(w, 8, SPR_CURSOR_CANAL, VHM_RECT, PlaceProc_WaterArea);
  1221 }
  1221 }
  1222 
  1222 
  1223 static void EditorTerraformClick_RockyArea(Window *w)
  1223 static void EditorTerraformClick_RockyArea(Window *w)
  1224 {
  1224 {
  1225 	HandlePlacePushButton(w, 9, SPR_CURSOR_ROCKY_AREA, 1, PlaceProc_RockyArea);
  1225 	HandlePlacePushButton(w, 9, SPR_CURSOR_ROCKY_AREA, VHM_RECT, PlaceProc_RockyArea);
  1226 }
  1226 }
  1227 
  1227 
  1228 static void EditorTerraformClick_DesertLightHouse(Window *w)
  1228 static void EditorTerraformClick_DesertLightHouse(Window *w)
  1229 {
  1229 {
  1230 	HandlePlacePushButton(w, 10, SPR_CURSOR_LIGHTHOUSE, 1, (_opt.landscape == LT_TROPIC) ? PlaceProc_DesertArea : PlaceProc_LightHouse);
  1230 	HandlePlacePushButton(w, 10, SPR_CURSOR_LIGHTHOUSE, VHM_RECT, (_opt.landscape == LT_TROPIC) ? PlaceProc_DesertArea : PlaceProc_LightHouse);
  1231 }
  1231 }
  1232 
  1232 
  1233 static void EditorTerraformClick_Transmitter(Window *w)
  1233 static void EditorTerraformClick_Transmitter(Window *w)
  1234 {
  1234 {
  1235 	HandlePlacePushButton(w, 11, SPR_CURSOR_TRANSMITTER, 1, PlaceProc_Transmitter);
  1235 	HandlePlacePushButton(w, 11, SPR_CURSOR_TRANSMITTER, VHM_RECT, PlaceProc_Transmitter);
  1236 }
  1236 }
  1237 
  1237 
  1238 static const uint16 _editor_terraform_keycodes[] = {
  1238 static const uint16 _editor_terraform_keycodes[] = {
  1239 	'D',
  1239 	'D',
  1240 	'Q',
  1240 	'Q',
  1460 		break;
  1460 		break;
  1461 
  1461 
  1462 	case WE_CLICK:
  1462 	case WE_CLICK:
  1463 		switch (e->we.click.widget) {
  1463 		switch (e->we.click.widget) {
  1464 		case 4: // new town
  1464 		case 4: // new town
  1465 			HandlePlacePushButton(w, 4, SPR_CURSOR_TOWN, 1, PlaceProc_Town);
  1465 			HandlePlacePushButton(w, 4, SPR_CURSOR_TOWN, VHM_RECT, PlaceProc_Town);
  1466 			break;
  1466 			break;
  1467 		case 5: {// random town
  1467 		case 5: {// random town
  1468 			Town *t;
  1468 			Town *t;
  1469 			uint size = min(_scengen_town_size, (int)TSM_CITY);
  1469 			uint size = min(_scengen_town_size, (int)TSM_CITY);
  1470 			TownSizeMode mode = _scengen_town_size > TSM_CITY ? TSM_CITY : TSM_FIXED;
  1470 			TownSizeMode mode = _scengen_town_size > TSM_CITY ? TSM_CITY : TSM_FIXED;