mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r14789) -Feature: allow scrolling with the left mouse button pressed (if enabled). Primarily useful for systems with touch screen (aapo)
This commit is contained in:
parent
2086fbcf17
commit
1357b0a4c2
@ -310,9 +310,10 @@ get_out:;
|
|||||||
} while (--i);
|
} while (--i);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ClickTile_Clear(TileIndex tile)
|
static bool ClickTile_Clear(TileIndex tile)
|
||||||
{
|
{
|
||||||
/* not used */
|
/* not used */
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TrackStatus GetTileTrackStatus_Clear(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
|
static TrackStatus GetTileTrackStatus_Clear(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
|
||||||
|
@ -54,9 +54,10 @@ static void TileLoop_Dummy(TileIndex tile)
|
|||||||
/* not used */
|
/* not used */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ClickTile_Dummy(TileIndex tile)
|
static bool ClickTile_Dummy(TileIndex tile)
|
||||||
{
|
{
|
||||||
/* not used */
|
/* not used */
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ChangeTileOwner_Dummy(TileIndex tile, Owner old_owner, Owner new_owner)
|
static void ChangeTileOwner_Dummy(TileIndex tile, Owner old_owner, Owner new_owner)
|
||||||
|
@ -837,9 +837,10 @@ static void TileLoop_Industry(TileIndex tile)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ClickTile_Industry(TileIndex tile)
|
static bool ClickTile_Industry(TileIndex tile)
|
||||||
{
|
{
|
||||||
ShowIndustryViewWindow(GetIndustryIndex(tile));
|
ShowIndustryViewWindow(GetIndustryIndex(tile));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TrackStatus GetTileTrackStatus_Industry(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
|
static TrackStatus GetTileTrackStatus_Industry(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
|
||||||
|
@ -519,9 +519,9 @@ void AnimateTile(TileIndex tile)
|
|||||||
_tile_type_procs[GetTileType(tile)]->animate_tile_proc(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)
|
void GetTileDesc(TileIndex tile, TileDesc *td)
|
||||||
|
@ -1126,6 +1126,8 @@ 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_CONTROL :Control-click
|
||||||
STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_OFF :Off
|
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_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 :{LTBLUE}Use the advanced vehicle list: {ORANGE}{STRING1}
|
||||||
STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OFF :Off
|
STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OFF :Off
|
||||||
|
@ -2332,12 +2332,12 @@ static TrackStatus GetTileTrackStatus_Track(TileIndex tile, TransportType mode,
|
|||||||
return CombineTrackStatus(TrackBitsToTrackdirBits(trackbits), red_signals);
|
return CombineTrackStatus(TrackBitsToTrackdirBits(trackbits), red_signals);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ClickTile_Track(TileIndex tile)
|
static bool ClickTile_Track(TileIndex tile)
|
||||||
{
|
{
|
||||||
switch (GetRailTileType(tile)) {
|
switch (GetRailTileType(tile)) {
|
||||||
case RAIL_TILE_DEPOT: ShowDepotWindow(tile, VEH_TRAIN); break;
|
case RAIL_TILE_DEPOT: ShowDepotWindow(tile, VEH_TRAIN); return true;
|
||||||
case RAIL_TILE_WAYPOINT: ShowWaypointWindow(GetWaypointByTile(tile)); break;
|
case RAIL_TILE_WAYPOINT: ShowWaypointWindow(GetWaypointByTile(tile)); return true;
|
||||||
default: break;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 */
|
/* Converts RoadBits to TrackBits */
|
||||||
|
@ -1424,6 +1424,7 @@ const SettingDesc _patch_settings[] = {
|
|||||||
SDTC_BOOL(gui.autoscroll, S, 0, false, STR_CONFIG_PATCHES_AUTOSCROLL, 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.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.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_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.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.toolbar_pos, SLE_UINT8, S, MS, 0, 0, 2, 0, STR_CONFIG_PATCHES_TOOLBAR_POS, v_PositionMainToolbar),
|
||||||
|
@ -614,6 +614,7 @@ static const char *_patches_ui[] = {
|
|||||||
"gui.default_rail_type",
|
"gui.default_rail_type",
|
||||||
"gui.always_build_infrastructure",
|
"gui.always_build_infrastructure",
|
||||||
"gui.show_track_reservation",
|
"gui.show_track_reservation",
|
||||||
|
"gui.left_mouse_btn_scrolling",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *_patches_construction[] = {
|
static const char *_patches_construction[] = {
|
||||||
|
@ -66,6 +66,7 @@ struct GUISettings {
|
|||||||
uint8 right_mouse_btn_emulation; ///< should we emulate right mouse clicking?
|
uint8 right_mouse_btn_emulation; ///< should we emulate right mouse clicking?
|
||||||
uint8 scrollwheel_scrolling; ///< scrolling using the scroll wheel?
|
uint8 scrollwheel_scrolling; ///< scrolling using the scroll wheel?
|
||||||
uint8 scrollwheel_multiplier; ///< how much 'wheel' per incoming event from the OS?
|
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 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
|
bool enable_signal_gui; ///< show the signal GUI when the signal button is pressed
|
||||||
Year colored_news_year; ///< when does newspaper become colored?
|
Year colored_news_year; ///< when does newspaper become colored?
|
||||||
|
@ -2569,13 +2569,14 @@ static void AnimateTile_Station(TileIndex tile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ClickTile_Station(TileIndex tile)
|
static bool ClickTile_Station(TileIndex tile)
|
||||||
{
|
{
|
||||||
if (IsHangar(tile)) {
|
if (IsHangar(tile)) {
|
||||||
ShowDepotWindow(tile, VEH_AIRCRAFT);
|
ShowDepotWindow(tile, VEH_AIRCRAFT);
|
||||||
} else {
|
} else {
|
||||||
ShowStationViewWindow(GetStationIndex(tile));
|
ShowStationViewWindow(GetStationIndex(tile));
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
|
static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
|
||||||
|
@ -103,7 +103,7 @@ typedef TrackStatus GetTileTrackStatusProc(TileIndex tile, TransportType mode, u
|
|||||||
* @param b Destination array of produced cargo
|
* @param b Destination array of produced cargo
|
||||||
*/
|
*/
|
||||||
typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
|
typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
|
||||||
typedef void ClickTileProc(TileIndex tile);
|
typedef bool ClickTileProc(TileIndex tile);
|
||||||
typedef void AnimateTileProc(TileIndex tile);
|
typedef void AnimateTileProc(TileIndex tile);
|
||||||
typedef void TileLoopProc(TileIndex tile);
|
typedef void TileLoopProc(TileIndex tile);
|
||||||
typedef void ChangeTileOwnerProc(TileIndex tile, Owner old_owner, Owner new_owner);
|
typedef void ChangeTileOwnerProc(TileIndex tile, Owner old_owner, Owner new_owner);
|
||||||
@ -156,7 +156,7 @@ VehicleEnterTileStatus VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y
|
|||||||
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac);
|
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac);
|
||||||
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner);
|
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner);
|
||||||
void AnimateTile(TileIndex tile);
|
void AnimateTile(TileIndex tile);
|
||||||
void ClickTile(TileIndex tile);
|
bool ClickTile(TileIndex tile);
|
||||||
void GetTileDesc(TileIndex tile, TileDesc *td);
|
void GetTileDesc(TileIndex tile, TileDesc *td);
|
||||||
|
|
||||||
#endif /* TILE_CMD_H */
|
#endif /* TILE_CMD_H */
|
||||||
|
@ -522,9 +522,10 @@ static void TileLoop_Town(TileIndex tile)
|
|||||||
* Dummy tile callback function for handling tile clicks in towns
|
* Dummy tile callback function for handling tile clicks in towns
|
||||||
* @param tile unused
|
* @param tile unused
|
||||||
*/
|
*/
|
||||||
static void ClickTile_Town(TileIndex tile)
|
static bool ClickTile_Town(TileIndex tile)
|
||||||
{
|
{
|
||||||
/* not used */
|
/* not used */
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CommandCost ClearTile_Town(TileIndex tile, byte flags)
|
static CommandCost ClearTile_Town(TileIndex tile, byte flags)
|
||||||
|
@ -744,9 +744,10 @@ void OnTick_Trees()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ClickTile_Trees(TileIndex tile)
|
static bool ClickTile_Trees(TileIndex tile)
|
||||||
{
|
{
|
||||||
/* not used */
|
/* not used */
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TrackStatus GetTileTrackStatus_Trees(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
|
static TrackStatus GetTileTrackStatus_Trees(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
|
||||||
|
@ -1282,9 +1282,10 @@ static void TileLoop_TunnelBridge(TileIndex tile)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ClickTile_TunnelBridge(TileIndex tile)
|
static bool ClickTile_TunnelBridge(TileIndex tile)
|
||||||
{
|
{
|
||||||
/* not used */
|
/* not used */
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -355,9 +355,12 @@ static TrackStatus GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mo
|
|||||||
return 0;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1986,11 +1986,12 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
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_vehicle_click_proc[] = {
|
|||||||
Nop // Disaster 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;
|
const Vehicle *v;
|
||||||
|
|
||||||
if (CheckClickOnTown(vp, x, y)) return;
|
if (CheckClickOnTown(vp, x, y)) return true;
|
||||||
if (CheckClickOnStation(vp, x, y)) return;
|
if (CheckClickOnStation(vp, x, y)) return true;
|
||||||
if (CheckClickOnSign(vp, x, y)) return;
|
if (CheckClickOnSign(vp, x, y)) return true;
|
||||||
if (CheckClickOnWaypoint(vp, x, y)) return;
|
if (CheckClickOnWaypoint(vp, x, y)) return true;
|
||||||
CheckClickOnLandscape(vp, x, y);
|
CheckClickOnLandscape(vp, x, y);
|
||||||
|
|
||||||
v = CheckClickOnVehicle(vp, x, y);
|
v = CheckClickOnVehicle(vp, x, y);
|
||||||
if (v != NULL) {
|
if (v != NULL) {
|
||||||
DEBUG(misc, 2, "Vehicle %d (index %d) at %p", v->unitnumber, v->index, v);
|
DEBUG(misc, 2, "Vehicle %d (index %d) at %p", v->unitnumber, v->index, v);
|
||||||
_on_vehicle_click_proc[v->type](v);
|
_on_vehicle_click_proc[v->type](v);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return CheckClickOnLandscape(vp, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vehicle *CheckMouseOverVehicle()
|
Vehicle *CheckMouseOverVehicle()
|
||||||
|
@ -43,7 +43,7 @@ void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y, bool trans
|
|||||||
void StartSpriteCombine();
|
void StartSpriteCombine();
|
||||||
void EndSpriteCombine();
|
void EndSpriteCombine();
|
||||||
|
|
||||||
void HandleViewportClicked(const ViewPort *vp, int x, int y);
|
bool HandleViewportClicked(const ViewPort *vp, int x, int y);
|
||||||
void PlaceObject();
|
void PlaceObject();
|
||||||
void SetRedErrorSquare(TileIndex tile);
|
void SetRedErrorSquare(TileIndex tile);
|
||||||
void SetTileSelectSize(int w, int h);
|
void SetTileSelectSize(int w, int h);
|
||||||
|
@ -1204,13 +1204,15 @@ static TrackStatus GetTileTrackStatus_Water(TileIndex tile, TransportType mode,
|
|||||||
return CombineTrackStatus(TrackBitsToTrackdirBits(ts), TRACKDIR_BIT_NONE);
|
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) {
|
if (GetWaterTileType(tile) == WATER_TILE_DEPOT) {
|
||||||
TileIndex tile2 = GetOtherShipDepotTile(tile);
|
TileIndex tile2 = GetOtherShipDepotTile(tile);
|
||||||
|
|
||||||
ShowDepotWindow(tile < tile2 ? tile : tile2, VEH_SHIP);
|
ShowDepotWindow(tile < tile2 ? tile : tile2, VEH_SHIP);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ChangeTileOwner_Water(TileIndex tile, Owner old_owner, Owner new_owner)
|
static void ChangeTileOwner_Water(TileIndex tile, Owner old_owner, Owner new_owner)
|
||||||
|
@ -1581,7 +1581,7 @@ static bool HandleViewportScroll()
|
|||||||
|
|
||||||
Window *w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
|
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;
|
_cursor.fix_at = false;
|
||||||
_scrolling_viewport = false;
|
_scrolling_viewport = false;
|
||||||
return true;
|
return true;
|
||||||
@ -1595,7 +1595,7 @@ static bool HandleViewportScroll()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Point delta;
|
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.x = -_cursor.delta.x;
|
||||||
delta.y = -_cursor.delta.y;
|
delta.y = -_cursor.delta.y;
|
||||||
} else {
|
} else {
|
||||||
@ -1915,7 +1915,12 @@ void MouseLoop(MouseClick click, int mousewheel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_thd.place_mode == VHM_NONE) {
|
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 {
|
} else {
|
||||||
PlaceObject();
|
PlaceObject();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user