Changeset - r10532:23a12232250b
[Not reviewed]
master
0 20 0
rubidium - 15 years ago 2009-01-02 22:42:05
rubidium@openttd.org
(svn r14789) -Feature: allow scrolling with the left mouse button pressed (if enabled). Primarily useful for systems with touch screen (aapo)
20 files changed with 59 insertions and 31 deletions:
0 comments (0 inline, 0 general)
src/clear_cmd.cpp
Show inline comments
 
@@ -307,15 +307,16 @@ void GenerateClearTile()
 
			}
 
get_out:;
 
		}
 
	} while (--i);
 
}
 

	
 
static void ClickTile_Clear(TileIndex tile)
 
static bool ClickTile_Clear(TileIndex tile)
 
{
 
	/* not used */
 
	return false;
 
}
 

	
 
static TrackStatus GetTileTrackStatus_Clear(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 
{
 
	return 0;
 
}
src/dummy_land.cpp
Show inline comments
 
@@ -51,15 +51,16 @@ static void AnimateTile_Dummy(TileIndex 
 

	
 
static void TileLoop_Dummy(TileIndex tile)
 
{
 
	/* not used */
 
}
 

	
 
static void ClickTile_Dummy(TileIndex tile)
 
static bool ClickTile_Dummy(TileIndex tile)
 
{
 
	/* not used */
 
	return false;
 
}
 

	
 
static void ChangeTileOwner_Dummy(TileIndex tile, Owner old_owner, Owner new_owner)
 
{
 
	/* not used */
 
}
src/industry_cmd.cpp
Show inline comments
 
@@ -834,15 +834,16 @@ static void TileLoop_Industry(TileIndex 
 
	case GFX_SUGAR_MINE_SIEVE:
 
		if (Chance16(1, 3)) AddAnimatedTile(tile);
 
		break;
 
	}
 
}
 

	
 
static void ClickTile_Industry(TileIndex tile)
 
static bool ClickTile_Industry(TileIndex tile)
 
{
 
	ShowIndustryViewWindow(GetIndustryIndex(tile));
 
	return true;
 
}
 

	
 
static TrackStatus GetTileTrackStatus_Industry(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 
{
 
	return 0;
 
}
src/landscape.cpp
Show inline comments
 
@@ -516,15 +516,15 @@ void GetAcceptedCargo(TileIndex tile, Ac
 

	
 
void AnimateTile(TileIndex tile)
 
{
 
	_tile_type_procs[GetTileType(tile)]->animate_tile_proc(tile);
 
}
 

	
 
void ClickTile(TileIndex tile)
 
bool ClickTile(TileIndex tile)
 
{
 
	_tile_type_procs[GetTileType(tile)]->click_tile_proc(tile);
 
	return _tile_type_procs[GetTileType(tile)]->click_tile_proc(tile);
 
}
 

	
 
void GetTileDesc(TileIndex tile, TileDesc *td)
 
{
 
	_tile_type_procs[GetTileType(tile)]->get_tile_desc_proc(tile, td);
 
}
src/lang/english.txt
Show inline comments
 
@@ -1123,12 +1123,14 @@ STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIE
 

	
 
STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU                          :{LTBLUE}Right-click emulation: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_COMMAND                  :Command-click
 
STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_CONTROL                  :Control-click
 
STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_OFF                      :Off
 

	
 
STR_CONFIG_PATCHES_LEFT_MOUSE_BTN_SCROLLING                     :{LTBLUE}Left-click scrolling: {ORANGE}{STRING1}
 

	
 
STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME                            :{LTBLUE}Automatically pause when starting a new game: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS                       :{LTBLUE}Use the advanced vehicle list: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OFF                   :Off
 
STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OWN                   :Own company
 
STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_ALL                   :All companies
 
STR_CONFIG_PATCHES_LOADING_INDICATORS                           :{LTBLUE}Use loading indicators: {ORANGE}{STRING1}
src/rail_cmd.cpp
Show inline comments
 
@@ -2329,18 +2329,18 @@ static TrackStatus GetTileTrackStatus_Tr
 
			break;
 
	}
 

	
 
	return CombineTrackStatus(TrackBitsToTrackdirBits(trackbits), red_signals);
 
}
 

	
 
static void ClickTile_Track(TileIndex tile)
 
static bool ClickTile_Track(TileIndex tile)
 
{
 
	switch (GetRailTileType(tile)) {
 
		case RAIL_TILE_DEPOT:    ShowDepotWindow(tile, VEH_TRAIN);            break;
 
		case RAIL_TILE_WAYPOINT: ShowWaypointWindow(GetWaypointByTile(tile)); break;
 
		default: break;
 
		case RAIL_TILE_DEPOT:    ShowDepotWindow(tile, VEH_TRAIN);            return true;
 
		case RAIL_TILE_WAYPOINT: ShowWaypointWindow(GetWaypointByTile(tile)); return true;
 
		default: return false;
 
	}
 
}
 

	
 
static void GetTileDesc_Track(TileIndex tile, TileDesc *td)
 
{
 
	td->owner[0] = GetTileOwner(tile);
src/road_cmd.cpp
Show inline comments
 
@@ -1427,15 +1427,18 @@ static void TileLoop_Road(TileIndex tile
 
		}
 

	
 
		MarkTileDirtyByTile(tile);
 
	}
 
}
 

	
 
static void ClickTile_Road(TileIndex tile)
 
static bool ClickTile_Road(TileIndex tile)
 
{
 
	if (IsRoadDepot(tile)) ShowDepotWindow(tile, VEH_ROAD);
 
	if (!IsRoadDepot(tile)) return false;
 

	
 
	ShowDepotWindow(tile, VEH_ROAD);
 
	return true;
 
}
 

	
 
/* Converts RoadBits to TrackBits */
 
static const byte _road_trackbits[16] = {
 
	0x0, 0x0, 0x0, 0x10, 0x0, 0x2, 0x8, 0x1A, 0x0, 0x4, 0x1, 0x15, 0x20, 0x26, 0x29, 0x3F,
 
};
src/settings.cpp
Show inline comments
 
@@ -1421,12 +1421,13 @@ const SettingDesc _patch_settings[] = {
 
	 SDTC_BOOL(gui.vehicle_speed,                        S,  0,  true,                        STR_CONFIG_PATCHES_VEHICLESPEED,                NULL),
 
	 SDTC_BOOL(gui.status_long_date,                     S,  0,  true,                        STR_CONFIG_PATCHES_LONGDATE,                    NULL),
 
	 SDTC_BOOL(gui.show_finances,                        S,  0,  true,                        STR_CONFIG_PATCHES_SHOWFINANCES,                NULL),
 
	 SDTC_BOOL(gui.autoscroll,                           S,  0, false,                        STR_CONFIG_PATCHES_AUTOSCROLL,                  NULL),
 
	 SDTC_BOOL(gui.reverse_scroll,                       S,  0, false,                        STR_CONFIG_PATCHES_REVERSE_SCROLLING,           NULL),
 
	 SDTC_BOOL(gui.smooth_scroll,                        S,  0, false,                        STR_CONFIG_PATCHES_SMOOTH_SCROLLING,            NULL),
 
	 SDTC_BOOL(gui.left_mouse_btn_scrolling,             S,  0, false,                        STR_CONFIG_PATCHES_LEFT_MOUSE_BTN_SCROLLING,    NULL),
 
	 SDTC_BOOL(gui.measure_tooltip,                      S,  0, false,                        STR_CONFIG_PATCHES_MEASURE_TOOLTIP,             NULL),
 
	  SDTC_VAR(gui.errmsg_duration,           SLE_UINT8, S,  0,     5,        0,       20, 0, STR_CONFIG_PATCHES_ERRMSG_DURATION,             NULL),
 
	  SDTC_VAR(gui.toolbar_pos,               SLE_UINT8, S, MS,     0,        0,        2, 0, STR_CONFIG_PATCHES_TOOLBAR_POS,                 v_PositionMainToolbar),
 
	  SDTC_VAR(gui.window_snap_radius,        SLE_UINT8, S, D0,    10,        1,       32, 0, STR_CONFIG_PATCHES_SNAP_RADIUS,                 NULL),
 
	 SDTC_BOOL(gui.population_in_label,                  S,  0,  true,                        STR_CONFIG_PATCHES_POPULATION_IN_LABEL,         PopulationInLabelActive),
 
	 SDTC_BOOL(gui.link_terraform_toolbar,               S,  0, false,                        STR_CONFIG_PATCHES_LINK_TERRAFORM_TOOLBAR,      NULL),
src/settings_gui.cpp
Show inline comments
 
@@ -611,12 +611,13 @@ static const char *_patches_ui[] = {
 
	"gui.advanced_vehicle_list",
 
	"gui.loading_indicators",
 
	"gui.timetable_in_ticks",
 
	"gui.default_rail_type",
 
	"gui.always_build_infrastructure",
 
	"gui.show_track_reservation",
 
	"gui.left_mouse_btn_scrolling",
 
};
 

	
 
static const char *_patches_construction[] = {
 
	"construction.build_on_slopes",
 
	"construction.autoslope",
 
	"construction.extra_dynamite",
src/settings_type.h
Show inline comments
 
@@ -63,12 +63,13 @@ struct GUISettings {
 
	bool   autosave_on_exit;                 ///< save an autosave when you quit the game, but do not ask "Do you really want to quit?"
 
	byte   max_num_autosaves;                ///< controls how many autosavegames are made before the game starts to overwrite (names them 0 to max_num_autosaves - 1)
 
	bool   population_in_label;              ///< show the population of a town in his label?
 
	uint8  right_mouse_btn_emulation;        ///< should we emulate right mouse clicking?
 
	uint8  scrollwheel_scrolling;            ///< scrolling using the scroll wheel?
 
	uint8  scrollwheel_multiplier;           ///< how much 'wheel' per incoming event from the OS?
 
	bool   left_mouse_btn_scrolling;         ///< left mouse button scroll
 
	bool   pause_on_newgame;                 ///< whether to start new games paused or not
 
	bool   enable_signal_gui;                ///< show the signal GUI when the signal button is pressed
 
	Year   colored_news_year;                ///< when does newspaper become colored?
 
	bool   timetable_in_ticks;               ///< whether to show the timetable in ticks rather than days
 
	bool   bridge_pillars;                   ///< show bridge pillars for high bridges
 
	bool   auto_euro;                        ///< automatically switch to euro in 2002
src/station_cmd.cpp
Show inline comments
 
@@ -2566,19 +2566,20 @@ static void AnimateTile_Station(TileInde
 
			break;
 
		}
 
	}
 
}
 

	
 

	
 
static void ClickTile_Station(TileIndex tile)
 
static bool ClickTile_Station(TileIndex tile)
 
{
 
	if (IsHangar(tile)) {
 
		ShowDepotWindow(tile, VEH_AIRCRAFT);
 
	} else {
 
		ShowStationViewWindow(GetStationIndex(tile));
 
	}
 
	return true;
 
}
 

	
 
static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	StationID station_id = GetStationIndex(tile);
 

	
src/tile_cmd.h
Show inline comments
 
@@ -100,13 +100,13 @@ typedef TrackStatus GetTileTrackStatusPr
 
/**
 
 * Tile callback function signature for obtaining the produced cargo of a tile.
 
 * @param tile Tile being queried
 
 * @param b    Destination array of produced cargo
 
 */
 
typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
 
typedef void ClickTileProc(TileIndex tile);
 
typedef bool ClickTileProc(TileIndex tile);
 
typedef void AnimateTileProc(TileIndex tile);
 
typedef void TileLoopProc(TileIndex tile);
 
typedef void ChangeTileOwnerProc(TileIndex tile, Owner old_owner, Owner new_owner);
 

	
 
/** @see VehicleEnterTileStatus to see what the return values mean */
 
typedef VehicleEnterTileStatus VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y);
 
@@ -153,10 +153,10 @@ extern const TileTypeProcs * const _tile
 

	
 
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side = INVALID_DIAGDIR);
 
VehicleEnterTileStatus VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y);
 
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac);
 
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner);
 
void AnimateTile(TileIndex tile);
 
void ClickTile(TileIndex tile);
 
bool ClickTile(TileIndex tile);
 
void GetTileDesc(TileIndex tile, TileDesc *td);
 

	
 
#endif /* TILE_CMD_H */
src/town_cmd.cpp
Show inline comments
 
@@ -519,15 +519,16 @@ static void TileLoop_Town(TileIndex tile
 
}
 

	
 
/**
 
 * Dummy tile callback function for handling tile clicks in towns
 
 * @param tile unused
 
 */
 
static void ClickTile_Town(TileIndex tile)
 
static bool ClickTile_Town(TileIndex tile)
 
{
 
	/* not used */
 
	return false;
 
}
 

	
 
static CommandCost ClearTile_Town(TileIndex tile, byte flags)
 
{
 
	if ((flags & DC_AUTO) && !(flags & DC_AI_BUILDING)) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
 
	if (!CanDeleteHouse(tile)) return CMD_ERROR;
src/tree_cmd.cpp
Show inline comments
 
@@ -741,15 +741,16 @@ void OnTick_Trees()
 
	tile = TILE_MASK(r);
 
	if (CanPlantTreesOnTile(tile, false) && (tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {
 
		PlantTreesOnTile(tile, tree, 0, 0);
 
	}
 
}
 

	
 
static void ClickTile_Trees(TileIndex tile)
 
static bool ClickTile_Trees(TileIndex tile)
 
{
 
	/* not used */
 
	return false;
 
}
 

	
 
static TrackStatus GetTileTrackStatus_Trees(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 
{
 
	return 0;
 
}
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -1279,15 +1279,16 @@ static void TileLoop_TunnelBridge(TileIn
 

	
 
		default:
 
			break;
 
	}
 
}
 

	
 
static void ClickTile_TunnelBridge(TileIndex tile)
 
static bool ClickTile_TunnelBridge(TileIndex tile)
 
{
 
	/* not used */
 
	return false;
 
}
 

	
 

	
 
static TrackStatus GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 
{
 
	TransportType transport_type = GetTunnelBridgeTransportType(tile);
src/unmovable_cmd.cpp
Show inline comments
 
@@ -352,15 +352,18 @@ static void TileLoop_Unmovable(TileIndex
 

	
 
static TrackStatus GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 
{
 
	return 0;
 
}
 

	
 
static void ClickTile_Unmovable(TileIndex tile)
 
static bool ClickTile_Unmovable(TileIndex tile)
 
{
 
	if (IsCompanyHQ(tile)) ShowCompany(GetTileOwner(tile));
 
	if (!IsCompanyHQ(tile)) return false;
 

	
 
	ShowCompany(GetTileOwner(tile));
 
	return true;
 
}
 

	
 

	
 
/* checks, if a radio tower is within a 9x9 tile square around tile */
 
static bool IsRadioTowerNearby(TileIndex tile)
 
{
src/viewport.cpp
Show inline comments
 
@@ -1983,17 +1983,18 @@ static bool CheckClickOnWaypoint(const V
 
	}
 

	
 
	return false;
 
}
 

	
 

	
 
static void CheckClickOnLandscape(const ViewPort *vp, int x, int y)
 
static bool CheckClickOnLandscape(const ViewPort *vp, int x, int y)
 
{
 
	Point pt = TranslateXYToTileCoord(vp, x, y);
 

	
 
	if (pt.x != -1) ClickTile(TileVirtXY(pt.x, pt.y));
 
	if (pt.x != -1) return ClickTile(TileVirtXY(pt.x, pt.y));
 
	return true;
 
}
 

	
 

	
 
static void SafeShowTrainViewWindow(const Vehicle* v)
 
{
 
	if (!IsFrontEngine(v)) v = v->First();
 
@@ -2015,27 +2016,29 @@ static OnVehicleClickProc* const _on_veh
 
	ShowVehicleViewWindow,
 
	ShowVehicleViewWindow,
 
	Nop, // Special vehicles
 
	Nop  // Disaster vehicles
 
};
 

	
 
void HandleViewportClicked(const ViewPort *vp, int x, int y)
 
bool HandleViewportClicked(const ViewPort *vp, int x, int y)
 
{
 
	const Vehicle *v;
 

	
 
	if (CheckClickOnTown(vp, x, y)) return;
 
	if (CheckClickOnStation(vp, x, y)) return;
 
	if (CheckClickOnSign(vp, x, y)) return;
 
	if (CheckClickOnWaypoint(vp, x, y)) return;
 
	if (CheckClickOnTown(vp, x, y)) return true;
 
	if (CheckClickOnStation(vp, x, y)) return true;
 
	if (CheckClickOnSign(vp, x, y)) return true;
 
	if (CheckClickOnWaypoint(vp, x, y)) return true;
 
	CheckClickOnLandscape(vp, x, y);
 

	
 
	v = CheckClickOnVehicle(vp, x, y);
 
	if (v != NULL) {
 
		DEBUG(misc, 2, "Vehicle %d (index %d) at %p", v->unitnumber, v->index, v);
 
		_on_vehicle_click_proc[v->type](v);
 
		return true;
 
	}
 
	return CheckClickOnLandscape(vp, x, y);
 
}
 

	
 
Vehicle *CheckMouseOverVehicle()
 
{
 
	const Window *w;
 
	const ViewPort *vp;
src/viewport_func.h
Show inline comments
 
@@ -40,13 +40,13 @@ void AddStringToDraw(int x, int y, Strin
 
void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y, bool transparent = false, const SubSprite *sub = NULL);
 

	
 

	
 
void StartSpriteCombine();
 
void EndSpriteCombine();
 

	
 
void HandleViewportClicked(const ViewPort *vp, int x, int y);
 
bool HandleViewportClicked(const ViewPort *vp, int x, int y);
 
void PlaceObject();
 
void SetRedErrorSquare(TileIndex tile);
 
void SetTileSelectSize(int w, int h);
 
void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
 

	
 
Vehicle *CheckMouseOverVehicle();
src/water_cmd.cpp
Show inline comments
 
@@ -1201,19 +1201,21 @@ static TrackStatus GetTileTrackStatus_Wa
 
		/* NW border: remove tracks that connects NW tile edge */
 
		ts &= ~(TRACK_BIT_Y | TRACK_BIT_LEFT | TRACK_BIT_UPPER);
 
	}
 
	return CombineTrackStatus(TrackBitsToTrackdirBits(ts), TRACKDIR_BIT_NONE);
 
}
 

	
 
static void ClickTile_Water(TileIndex tile)
 
static bool ClickTile_Water(TileIndex tile)
 
{
 
	if (GetWaterTileType(tile) == WATER_TILE_DEPOT) {
 
		TileIndex tile2 = GetOtherShipDepotTile(tile);
 

	
 
		ShowDepotWindow(tile < tile2 ? tile : tile2, VEH_SHIP);
 
		return true;
 
	}
 
	return false;
 
}
 

	
 
static void ChangeTileOwner_Water(TileIndex tile, Owner old_owner, Owner new_owner)
 
{
 
	if (!IsTileOwner(tile, old_owner)) return;
 

	
src/window.cpp
Show inline comments
 
@@ -1578,13 +1578,13 @@ static bool HandleViewportScroll()
 
	bool scrollwheel_scrolling = _settings_client.gui.scrollwheel_scrolling == 1 && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0);
 

	
 
	if (!_scrolling_viewport) return true;
 

	
 
	Window *w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
 

	
 
	if (!(_right_button_down || scrollwheel_scrolling) || w == NULL) {
 
	if (!(_right_button_down || scrollwheel_scrolling || (_settings_client.gui.left_mouse_btn_scrolling && _left_button_down)) || w == NULL) {
 
		_cursor.fix_at = false;
 
		_scrolling_viewport = false;
 
		return true;
 
	}
 

	
 
	if (w == FindWindowById(WC_MAIN_WINDOW, 0) && w->viewport->follow_vehicle != INVALID_VEHICLE) {
 
@@ -1592,13 +1592,13 @@ static bool HandleViewportScroll()
 
		const Vehicle *veh = GetVehicle(w->viewport->follow_vehicle);
 
		ScrollMainWindowTo(veh->x_pos, veh->y_pos, true); /* This also resets follow_vehicle */
 
		return true;
 
	}
 

	
 
	Point delta;
 
	if (_settings_client.gui.reverse_scroll) {
 
	if (_settings_client.gui.reverse_scroll || (_settings_client.gui.left_mouse_btn_scrolling && _left_button_down)) {
 
		delta.x = -_cursor.delta.x;
 
		delta.y = -_cursor.delta.y;
 
	} else {
 
		delta.x = _cursor.delta.x;
 
		delta.y = _cursor.delta.y;
 
	}
 
@@ -1912,13 +1912,18 @@ void MouseLoop(MouseClick click, int mou
 
						_pause_game != 0 &&
 
						!_cheats.build_in_pause.value) {
 
					return;
 
				}
 

	
 
				if (_thd.place_mode == VHM_NONE) {
 
					HandleViewportClicked(vp, x, y);
 
					if (!HandleViewportClicked(vp, x, y) &&
 
							!(w->flags4 & WF_DISABLE_VP_SCROLL) &&
 
							_settings_client.gui.left_mouse_btn_scrolling) {
 
						_scrolling_viewport = true;
 
						_cursor.fix_at = false;
 
					}
 
				} else {
 
					PlaceObject();
 
				}
 
				break;
 

	
 
			case MC_RIGHT:
0 comments (0 inline, 0 general)