forked from rosebudai/OpenRCT2-Web
1 parent
a0341a7aeb
commit
3c8adb1fc1
12 files changed
+85
-29
No files matched your search
@@ -472,6 +472,16 @@ public:
|
||||
case INTENT_ACTION_TRACK_DESIGN_RESTORE_PROVISIONAL:
|
||||
TrackPlaceRestoreProvisional();
|
||||
break;
|
||||
|
||||
case INTENT_ACTION_SET_MAP_TOOLTIP:
|
||||
{
|
||||
auto ft = static_cast<Formatter*>(intent.GetPointerExtra(INTENT_EXTRA_FORMATTER));
|
||||
if (ft != nullptr)
|
||||
{
|
||||
SetMapTooltip(*ft);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1082,8 +1082,9 @@ void process_mouse_over(const ScreenCoordsXY& screenCoords)
|
||||
int32_t cursorId;
|
||||
|
||||
cursorId = CURSOR_ARROW;
|
||||
auto ft = Formatter::MapTooltip();
|
||||
auto ft = Formatter();
|
||||
ft.Add<rct_string_id>(STR_NONE);
|
||||
SetMapTooltip(ft);
|
||||
window = window_find_from_point(screenCoords);
|
||||
|
||||
if (window != nullptr)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../windows/Window.h"
|
||||
#include "Viewport.h"
|
||||
#include "Window.h"
|
||||
|
||||
@@ -118,9 +119,10 @@ InteractionInfo viewport_interaction_get_item_left(const ScreenCoordsXY& screenC
|
||||
auto& park = OpenRCT2::GetContext()->GetGameState()->GetPark();
|
||||
auto parkName = park.Name.c_str();
|
||||
|
||||
auto ft = Formatter::MapTooltip();
|
||||
auto ft = Formatter();
|
||||
ft.Add<rct_string_id>(STR_STRING);
|
||||
ft.Add<const char*>(parkName);
|
||||
SetMapTooltip(ft);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -267,9 +269,10 @@ InteractionInfo viewport_interaction_get_item_right(const ScreenCoordsXY& screen
|
||||
ride = get_ride(vehicle->ride);
|
||||
if (ride != nullptr && ride->status == RIDE_STATUS_CLOSED)
|
||||
{
|
||||
auto ft = Formatter::MapTooltip();
|
||||
auto ft = Formatter();
|
||||
ft.Add<rct_string_id>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_MODIFY);
|
||||
ride->FormatNameTo(ft);
|
||||
SetMapTooltip(ft);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
@@ -296,7 +299,7 @@ InteractionInfo viewport_interaction_get_item_right(const ScreenCoordsXY& screen
|
||||
if (ride->status != RIDE_STATUS_CLOSED)
|
||||
return info;
|
||||
|
||||
auto ft = Formatter::MapTooltip();
|
||||
auto ft = Formatter();
|
||||
ft.Add<rct_string_id>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_MODIFY);
|
||||
|
||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_ENTRANCE)
|
||||
@@ -365,6 +368,7 @@ InteractionInfo viewport_interaction_get_item_right(const ScreenCoordsXY& screen
|
||||
stationIndex--;
|
||||
stationIndex++;
|
||||
ft.Add<uint16_t>(stationIndex);
|
||||
SetMapTooltip(ft);
|
||||
return info;
|
||||
}
|
||||
case VIEWPORT_INTERACTION_ITEM_WALL:
|
||||
@@ -374,11 +378,12 @@ InteractionInfo viewport_interaction_get_item_right(const ScreenCoordsXY& screen
|
||||
auto banner = tileElement->AsWall()->GetBanner();
|
||||
if (banner != nullptr)
|
||||
{
|
||||
auto ft = Formatter::MapTooltip();
|
||||
auto ft = Formatter();
|
||||
ft.Add<rct_string_id>(STR_MAP_TOOLTIP_BANNER_STRINGID_STRINGID);
|
||||
banner->FormatTextTo(ft);
|
||||
ft.Add<rct_string_id>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_MODIFY);
|
||||
ft.Add<rct_string_id>(sceneryEntry->name);
|
||||
SetMapTooltip(ft);
|
||||
return info;
|
||||
}
|
||||
}
|
||||
@@ -391,11 +396,12 @@ InteractionInfo viewport_interaction_get_item_right(const ScreenCoordsXY& screen
|
||||
auto banner = tileElement->AsLargeScenery()->GetBanner();
|
||||
if (banner != nullptr)
|
||||
{
|
||||
auto ft = Formatter::MapTooltip();
|
||||
auto ft = Formatter();
|
||||
ft.Add<rct_string_id>(STR_MAP_TOOLTIP_BANNER_STRINGID_STRINGID);
|
||||
banner->FormatTextTo(ft);
|
||||
ft.Add<rct_string_id>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_MODIFY);
|
||||
ft.Add<rct_string_id>(sceneryEntry->name);
|
||||
SetMapTooltip(ft);
|
||||
return info;
|
||||
}
|
||||
}
|
||||
@@ -406,11 +412,12 @@ InteractionInfo viewport_interaction_get_item_right(const ScreenCoordsXY& screen
|
||||
auto banner = tileElement->AsBanner()->GetBanner();
|
||||
sceneryEntry = get_banner_entry(banner->type);
|
||||
|
||||
auto ft = Formatter::MapTooltip();
|
||||
auto ft = Formatter();
|
||||
ft.Add<rct_string_id>(STR_MAP_TOOLTIP_BANNER_STRINGID_STRINGID);
|
||||
banner->FormatTextTo(ft, /*addColour*/ true);
|
||||
ft.Add<rct_string_id>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_MODIFY);
|
||||
ft.Add<rct_string_id>(sceneryEntry->name);
|
||||
SetMapTooltip(ft);
|
||||
return info;
|
||||
}
|
||||
default:
|
||||
@@ -426,13 +433,14 @@ InteractionInfo viewport_interaction_get_item_right(const ScreenCoordsXY& screen
|
||||
}
|
||||
}
|
||||
|
||||
auto ft = Formatter::MapTooltip();
|
||||
auto ft = Formatter();
|
||||
switch (info.SpriteType)
|
||||
{
|
||||
case VIEWPORT_INTERACTION_ITEM_SCENERY:
|
||||
sceneryEntry = tileElement->AsSmallScenery()->GetEntry();
|
||||
ft.Add<rct_string_id>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE);
|
||||
ft.Add<rct_string_id>(sceneryEntry->name);
|
||||
SetMapTooltip(ft);
|
||||
return info;
|
||||
|
||||
case VIEWPORT_INTERACTION_ITEM_FOOTPATH:
|
||||
@@ -441,6 +449,7 @@ InteractionInfo viewport_interaction_get_item_right(const ScreenCoordsXY& screen
|
||||
ft.Add<rct_string_id>(STR_QUEUE_LINE_MAP_TIP);
|
||||
else
|
||||
ft.Add<rct_string_id>(STR_FOOTPATH_MAP_TIP);
|
||||
SetMapTooltip(ft);
|
||||
return info;
|
||||
|
||||
case VIEWPORT_INTERACTION_ITEM_FOOTPATH_ITEM:
|
||||
@@ -451,6 +460,7 @@ InteractionInfo viewport_interaction_get_item_right(const ScreenCoordsXY& screen
|
||||
ft.Add<rct_string_id>(STR_BROKEN);
|
||||
}
|
||||
ft.Add<rct_string_id>(sceneryEntry->name);
|
||||
SetMapTooltip(ft);
|
||||
return info;
|
||||
|
||||
case VIEWPORT_INTERACTION_ITEM_PARK:
|
||||
@@ -462,18 +472,21 @@ InteractionInfo viewport_interaction_get_item_right(const ScreenCoordsXY& screen
|
||||
|
||||
ft.Add<rct_string_id>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE);
|
||||
ft.Add<rct_string_id>(STR_OBJECT_SELECTION_PARK_ENTRANCE);
|
||||
SetMapTooltip(ft);
|
||||
return info;
|
||||
|
||||
case VIEWPORT_INTERACTION_ITEM_WALL:
|
||||
sceneryEntry = tileElement->AsWall()->GetEntry();
|
||||
ft.Add<rct_string_id>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE);
|
||||
ft.Add<rct_string_id>(sceneryEntry->name);
|
||||
SetMapTooltip(ft);
|
||||
return info;
|
||||
|
||||
case VIEWPORT_INTERACTION_ITEM_LARGE_SCENERY:
|
||||
sceneryEntry = tileElement->AsLargeScenery()->GetEntry();
|
||||
ft.Add<rct_string_id>(STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE);
|
||||
ft.Add<rct_string_id>(sceneryEntry->name);
|
||||
SetMapTooltip(ft);
|
||||
return info;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -669,16 +669,16 @@ static void window_game_bottom_toolbar_draw_middle_panel(rct_drawpixelinfo* dpi,
|
||||
|
||||
// Check if there is a map tooltip to draw
|
||||
rct_string_id stringId;
|
||||
std::memcpy(&stringId, gMapTooltipFormatArgs, sizeof(rct_string_id));
|
||||
auto ft = GetMapTooltip();
|
||||
std::memcpy(&stringId, ft.Data(), sizeof(rct_string_id));
|
||||
if (stringId == STR_NONE)
|
||||
{
|
||||
gfx_draw_string_centred_wrapped(
|
||||
dpi, gMapTooltipFormatArgs, middleWidgetCoords, width, STR_TITLE_SEQUENCE_OPENRCT2, w->colours[0]);
|
||||
gfx_draw_string_centred_wrapped(dpi, ft.Data(), middleWidgetCoords, width, STR_TITLE_SEQUENCE_OPENRCT2, w->colours[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show tooltip in bottom toolbar
|
||||
gfx_draw_string_centred_wrapped(dpi, gMapTooltipFormatArgs, middleWidgetCoords, width, STR_STRINGID, w->colours[0]);
|
||||
gfx_draw_string_centred_wrapped(dpi, ft.Data(), middleWidgetCoords, width, STR_STRINGID, w->colours[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,18 @@ static int32_t _cursorHoldDuration;
|
||||
|
||||
static void window_map_tooltip_open();
|
||||
|
||||
static Formatter _mapTooltipArgs;
|
||||
|
||||
void SetMapTooltip(Formatter& ft)
|
||||
{
|
||||
_mapTooltipArgs = ft;
|
||||
}
|
||||
|
||||
const Formatter& GetMapTooltip()
|
||||
{
|
||||
return _mapTooltipArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006EE77A
|
||||
@@ -65,7 +77,7 @@ void window_map_tooltip_update_visibility()
|
||||
|
||||
// Show or hide tooltip
|
||||
rct_string_id stringId;
|
||||
std::memcpy(&stringId, gMapTooltipFormatArgs, sizeof(rct_string_id));
|
||||
std::memcpy(&stringId, _mapTooltipArgs.Data(), sizeof(rct_string_id));
|
||||
|
||||
if (_cursorHoldDuration < 25 || stringId == STR_NONE
|
||||
|| input_test_place_object_modifier(
|
||||
@@ -126,12 +138,13 @@ static void window_map_tooltip_update(rct_window* w)
|
||||
static void window_map_tooltip_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
{
|
||||
rct_string_id stringId;
|
||||
std::memcpy(&stringId, gMapTooltipFormatArgs, sizeof(rct_string_id));
|
||||
std::memcpy(&stringId, _mapTooltipArgs.Data(), sizeof(rct_string_id));
|
||||
if (stringId == STR_NONE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ScreenCoordsXY stringCoords(w->windowPos.x + (w->width / 2), w->windowPos.y + (w->height / 2));
|
||||
gfx_draw_string_centred_wrapped(dpi, gMapTooltipFormatArgs, stringCoords, w->width, STR_MAP_TOOLTIP_STRINGID, COLOUR_BLACK);
|
||||
gfx_draw_string_centred_wrapped(
|
||||
dpi, _mapTooltipArgs.Data(), stringCoords, w->width, STR_MAP_TOOLTIP_STRINGID, COLOUR_BLACK);
|
||||
}
|
||||
@@ -141,6 +141,8 @@ void window_ride_measurements_design_cancel();
|
||||
extern RideSelection _window_track_list_item;
|
||||
rct_window* window_track_list_open(RideSelection item);
|
||||
|
||||
void SetMapTooltip(Formatter& ft);
|
||||
const Formatter& GetMapTooltip();
|
||||
void window_map_tooltip_update_visibility();
|
||||
|
||||
rct_window* window_maze_construction_open();
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
|
||||
thread_local char gCommonStringFormatBuffer[512];
|
||||
thread_local uint8_t gCommonFormatArgs[80];
|
||||
thread_local uint8_t gMapTooltipFormatArgs[40];
|
||||
|
||||
#ifdef DEBUG
|
||||
// Set to true before a string format call to see details of the formatting.
|
||||
|
||||
@@ -68,7 +68,6 @@ extern const char* real_names[1024];
|
||||
|
||||
extern thread_local char gCommonStringFormatBuffer[512];
|
||||
extern thread_local uint8_t gCommonFormatArgs[80];
|
||||
extern thread_local uint8_t gMapTooltipFormatArgs[40];
|
||||
extern bool gDebugStringFormatting;
|
||||
|
||||
extern const rct_string_id SpeedNames[5];
|
||||
@@ -127,11 +126,6 @@ public:
|
||||
return Formatter{ gCommonFormatArgs };
|
||||
}
|
||||
|
||||
static Formatter MapTooltip()
|
||||
{
|
||||
return Formatter{ gMapTooltipFormatArgs };
|
||||
}
|
||||
|
||||
auto Buf()
|
||||
{
|
||||
return CurrentBuf;
|
||||
|
||||
@@ -2161,7 +2161,7 @@ int32_t get_peep_face_sprite_large(Peep* peep)
|
||||
|
||||
void peep_set_map_tooltip(Peep* peep)
|
||||
{
|
||||
auto ft = Formatter::MapTooltip();
|
||||
auto ft = Formatter();
|
||||
if (peep->AssignedPeepType == PeepType::Guest)
|
||||
{
|
||||
ft.Add<rct_string_id>((peep->PeepFlags & PEEP_FLAGS_TRACKING) ? STR_TRACKED_GUEST_MAP_TIP : STR_GUEST_MAP_TIP);
|
||||
@@ -2175,6 +2175,10 @@ void peep_set_map_tooltip(Peep* peep)
|
||||
peep->FormatNameTo(ft);
|
||||
peep->FormatActionTo(ft);
|
||||
}
|
||||
|
||||
auto intent = Intent(INTENT_ACTION_SET_MAP_TOOLTIP);
|
||||
intent.putExtra(INTENT_EXTRA_FORMATTER, &ft);
|
||||
context_broadcast_intent(&intent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3306,10 +3306,13 @@ static void ride_track_set_map_tooltip(TileElement* tileElement)
|
||||
auto ride = get_ride(rideIndex);
|
||||
if (ride != nullptr)
|
||||
{
|
||||
auto ft = Formatter::MapTooltip();
|
||||
auto ft = Formatter();
|
||||
ft.Add<rct_string_id>(STR_RIDE_MAP_TIP);
|
||||
ride->FormatNameTo(ft);
|
||||
ride->FormatStatusTo(ft);
|
||||
auto intent = Intent(INTENT_ACTION_SET_MAP_TOOLTIP);
|
||||
intent.putExtra(INTENT_EXTRA_FORMATTER, &ft);
|
||||
context_broadcast_intent(&intent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3319,10 +3322,13 @@ static void ride_queue_banner_set_map_tooltip(TileElement* tileElement)
|
||||
auto ride = get_ride(rideIndex);
|
||||
if (ride != nullptr)
|
||||
{
|
||||
auto ft = Formatter::MapTooltip();
|
||||
auto ft = Formatter();
|
||||
ft.Add<rct_string_id>(STR_RIDE_MAP_TIP);
|
||||
ride->FormatNameTo(ft);
|
||||
ride->FormatStatusTo(ft);
|
||||
auto intent = Intent(INTENT_ACTION_SET_MAP_TOOLTIP);
|
||||
intent.putExtra(INTENT_EXTRA_FORMATTER, &ft);
|
||||
context_broadcast_intent(&intent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3337,13 +3343,16 @@ static void ride_station_set_map_tooltip(TileElement* tileElement)
|
||||
if (ride->stations[i].Start.isNull())
|
||||
stationIndex--;
|
||||
|
||||
auto ft = Formatter::MapTooltip();
|
||||
auto ft = Formatter();
|
||||
ft.Add<rct_string_id>(STR_RIDE_MAP_TIP);
|
||||
ft.Add<rct_string_id>(ride->num_stations <= 1 ? STR_RIDE_STATION : STR_RIDE_STATION_X);
|
||||
ride->FormatNameTo(ft);
|
||||
ft.Add<rct_string_id>(RideComponentNames[RideTypeDescriptors[ride->type].NameConvention.station].capitalised);
|
||||
ft.Add<uint16_t>(stationIndex + 1);
|
||||
ride->FormatStatusTo(ft);
|
||||
auto intent = Intent(INTENT_ACTION_SET_MAP_TOOLTIP);
|
||||
intent.putExtra(INTENT_EXTRA_FORMATTER, &ft);
|
||||
context_broadcast_intent(&intent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3366,7 +3375,7 @@ static void ride_entrance_set_map_tooltip(TileElement* tileElement)
|
||||
if (!ride_get_entrance_location(ride, stationIndex).isNull())
|
||||
queueLength = ride->stations[stationIndex].QueueLength;
|
||||
|
||||
auto ft = Formatter::MapTooltip();
|
||||
auto ft = Formatter();
|
||||
ft.Add<rct_string_id>(STR_RIDE_MAP_TIP);
|
||||
ft.Add<rct_string_id>(ride->num_stations <= 1 ? STR_RIDE_ENTRANCE : STR_RIDE_STATION_X_ENTRANCE);
|
||||
ride->FormatNameTo(ft);
|
||||
@@ -3388,6 +3397,9 @@ static void ride_entrance_set_map_tooltip(TileElement* tileElement)
|
||||
ft.Add<rct_string_id>(STR_QUEUE_PEOPLE);
|
||||
}
|
||||
ft.Add<uint16_t>(queueLength);
|
||||
auto intent = Intent(INTENT_ACTION_SET_MAP_TOOLTIP);
|
||||
intent.putExtra(INTENT_EXTRA_FORMATTER, &ft);
|
||||
context_broadcast_intent(&intent);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3397,7 +3409,7 @@ static void ride_entrance_set_map_tooltip(TileElement* tileElement)
|
||||
if (ride->stations[i].Start.isNull())
|
||||
stationIndex--;
|
||||
|
||||
auto ft = Formatter::MapTooltip();
|
||||
auto ft = Formatter();
|
||||
ft.Add<rct_string_id>(ride->num_stations <= 1 ? STR_RIDE_EXIT : STR_RIDE_STATION_X_EXIT);
|
||||
ride->FormatNameTo(ft);
|
||||
|
||||
@@ -3405,6 +3417,9 @@ static void ride_entrance_set_map_tooltip(TileElement* tileElement)
|
||||
ft.Increment(sizeof(uint16_t));
|
||||
|
||||
ft.Add<uint16_t>(stationIndex + 1);
|
||||
auto intent = Intent(INTENT_ACTION_SET_MAP_TOOLTIP);
|
||||
intent.putExtra(INTENT_EXTRA_FORMATTER, &ft);
|
||||
context_broadcast_intent(&intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6224,13 +6224,16 @@ void Vehicle::SetMapToolbar() const
|
||||
if (curRide->vehicles[vehicleIndex] == vehicle->sprite_index)
|
||||
break;
|
||||
|
||||
auto ft = Formatter::MapTooltip();
|
||||
auto ft = Formatter();
|
||||
ft.Add<rct_string_id>(STR_RIDE_MAP_TIP);
|
||||
ft.Add<rct_string_id>(STR_MAP_TOOLTIP_STRINGID_STRINGID);
|
||||
curRide->FormatNameTo(ft);
|
||||
ft.Add<rct_string_id>(RideComponentNames[RideTypeDescriptors[curRide->type].NameConvention.vehicle].capitalised);
|
||||
ft.Add<uint16_t>(vehicleIndex + 1);
|
||||
curRide->FormatStatusTo(ft);
|
||||
auto intent = Intent(INTENT_ACTION_SET_MAP_TOOLTIP);
|
||||
intent.putExtra(INTENT_EXTRA_FORMATTER, &ft);
|
||||
context_broadcast_intent(&intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ enum
|
||||
INTENT_EXTRA_LIST_COUNT,
|
||||
INTENT_EXTRA_PAGE,
|
||||
INTENT_EXTRA_BANNER_INDEX,
|
||||
INTENT_EXTRA_FORMATTER,
|
||||
};
|
||||
|
||||
enum
|
||||
@@ -105,4 +106,5 @@ enum
|
||||
INTENT_ACTION_UPDATE_RESEARCH,
|
||||
INTENT_ACTION_TRACK_DESIGN_REMOVE_PROVISIONAL,
|
||||
INTENT_ACTION_TRACK_DESIGN_RESTORE_PROVISIONAL,
|
||||
INTENT_ACTION_SET_MAP_TOOLTIP,
|
||||
};
|
||||
Reference in new issue
Block a user