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
 
@@ -310,9 +310,10 @@ 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)
src/dummy_land.cpp
Show inline comments
 
@@ -54,9 +54,10 @@ static void TileLoop_Dummy(TileIndex til
 
	/* 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)
src/industry_cmd.cpp
Show inline comments
 
@@ -837,9 +837,10 @@ static void TileLoop_Industry(TileIndex 
 
	}
 
}
 

	
 
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)
src/landscape.cpp
Show inline comments
 
@@ -519,9 +519,9 @@ 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)
src/lang/english.txt
Show inline comments
 
@@ -1126,6 +1126,8 @@ STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_C
 
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
src/rail_cmd.cpp
Show inline comments
 
@@ -2332,12 +2332,12 @@ static TrackStatus GetTileTrackStatus_Tr
 
	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;
 
	}
 
}
 

	
src/road_cmd.cpp
Show inline comments
 
@@ -1430,9 +1430,12 @@ static void TileLoop_Road(TileIndex 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 */
src/settings.cpp
Show inline comments
 
@@ -1424,6 +1424,7 @@ const SettingDesc _patch_settings[] = {
 
	 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),
src/settings_gui.cpp
Show inline comments
 
@@ -614,6 +614,7 @@ static const char *_patches_ui[] = {
 
	"gui.default_rail_type",
 
	"gui.always_build_infrastructure",
 
	"gui.show_track_reservation",
 
	"gui.left_mouse_btn_scrolling",
 
};
 

	
 
static const char *_patches_construction[] = {
src/settings_type.h
Show inline comments
 
@@ -66,6 +66,7 @@ struct GUISettings {
 
	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?
src/station_cmd.cpp
Show inline comments
 
@@ -2569,13 +2569,14 @@ static void AnimateTile_Station(TileInde
 
}
 

	
 

	
 
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)
src/tile_cmd.h
Show inline comments
 
@@ -103,7 +103,7 @@ typedef TrackStatus GetTileTrackStatusPr
 
 * @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);
 
@@ -156,7 +156,7 @@ VehicleEnterTileStatus VehicleEnterTile(
 
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
 
@@ -522,9 +522,10 @@ 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)
src/tree_cmd.cpp
Show inline comments
 
@@ -744,9 +744,10 @@ void OnTick_Trees()
 
	}
 
}
 

	
 
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)
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -1282,9 +1282,10 @@ static void TileLoop_TunnelBridge(TileIn
 
	}
 
}
 

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

	
 

	
src/unmovable_cmd.cpp
Show inline comments
 
@@ -355,9 +355,12 @@ static TrackStatus GetTileTrackStatus_Un
 
	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;
 
}
 

	
 

	
src/viewport.cpp
Show inline comments
 
@@ -1986,11 +1986,12 @@ static bool CheckClickOnWaypoint(const V
 
}
 

	
 

	
 
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;
 
}
 

	
 

	
 
@@ -2018,21 +2019,23 @@ static OnVehicleClickProc* const _on_veh
 
	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()
src/viewport_func.h
Show inline comments
 
@@ -43,7 +43,7 @@ void AddChildSpriteScreen(SpriteID image
 
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);
src/water_cmd.cpp
Show inline comments
 
@@ -1204,13 +1204,15 @@ static TrackStatus GetTileTrackStatus_Wa
 
	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)
src/window.cpp
Show inline comments
 
@@ -1581,7 +1581,7 @@ static bool HandleViewportScroll()
 

	
 
	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;
 
@@ -1595,7 +1595,7 @@ static bool HandleViewportScroll()
 
	}
 

	
 
	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 {
 
@@ -1915,7 +1915,12 @@ void MouseLoop(MouseClick click, int mou
 
				}
 

	
 
				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();
 
				}
0 comments (0 inline, 0 general)