Show ride and vehicle names in research list

This commit is contained in:
Michael Steenbeek 2018-03-21 12:52:39 +01:00
parent 2545d01db4
commit 919533d7c2
5 changed files with 71 additions and 12 deletions

View File

@ -4535,6 +4535,10 @@ STR_6225 :Not supported with OpenGL renderer
STR_6226 :Enable early scenario completion STR_6226 :Enable early scenario completion
STR_6227 :{SMALLFONT}{BLACK}Triggers scenario completion when all scenario goals are met before the target date. STR_6227 :{SMALLFONT}{BLACK}Triggers scenario completion when all scenario goals are met before the target date.
STR_6228 :Scenario Options STR_6228 :Scenario Options
STR_6229 :{WINDOW_COLOUR_2}{STRINGID}: {STRINGID}
STR_6230 :{STRINGID}: {MOVE_X}{185}{STRINGID}
STR_6231 :{WINDOW_COLOUR_2}{STRINGID}: {MOVE_X}{185}{STRINGID}
############# #############
# Scenarios # # Scenarios #

View File

@ -30,6 +30,7 @@
#include <openrct2/sprites.h> #include <openrct2/sprites.h>
#include <openrct2/util/Util.h> #include <openrct2/util/Util.h>
#include <openrct2/world/Scenery.h> #include <openrct2/world/Scenery.h>
#include <openrct2/ride/RideGroupManager.h>
#pragma region Widgets #pragma region Widgets
@ -87,6 +88,8 @@ static void window_editor_inventions_list_drag_cursor(rct_window *w, rct_widgeti
static void window_editor_inventions_list_drag_moved(rct_window* w, sint32 x, sint32 y); static void window_editor_inventions_list_drag_moved(rct_window* w, sint32 x, sint32 y);
static void window_editor_inventions_list_drag_paint(rct_window *w, rct_drawpixelinfo *dpi); static void window_editor_inventions_list_drag_paint(rct_window *w, rct_drawpixelinfo *dpi);
static rct_string_id window_editor_inventions_list_prepare_name(const rct_research_item * researchItem, bool withGap);
// 0x0098177C // 0x0098177C
static rct_window_event_list window_editor_inventions_list_events = { static rct_window_event_list window_editor_inventions_list_events = {
window_editor_inventions_list_close, window_editor_inventions_list_close,
@ -711,8 +714,9 @@ static void window_editor_inventions_list_paint(rct_window *w, rct_drawpixelinfo
x = w->x + ((widget->left + widget->right) / 2) + 1; x = w->x + ((widget->left + widget->right) / 2) + 1;
y = w->y + widget->bottom + 3; y = w->y + widget->bottom + 3;
width = w->width - w->widgets[WIDX_RESEARCH_ORDER_SCROLL].right - 6; width = w->width - w->widgets[WIDX_RESEARCH_ORDER_SCROLL].right - 6;
stringId = research_item_get_name(researchItem);
gfx_draw_string_centred_clipped(dpi, STR_WINDOW_COLOUR_2_STRINGID, &stringId, COLOUR_BLACK, x, y, width); rct_string_id drawString = window_editor_inventions_list_prepare_name(researchItem, false);
gfx_draw_string_centred_clipped(dpi, drawString, gCommonFormatArgs, COLOUR_BLACK, x, y, width);
y += 15; y += 15;
// Item category // Item category
@ -780,6 +784,7 @@ static void window_editor_inventions_list_scrollpaint(rct_window *w, rct_drawpix
continue; continue;
disableItemMovement = research_item_is_always_researched(researchItem); disableItemMovement = research_item_is_always_researched(researchItem);
stringId = research_item_get_name(researchItem); stringId = research_item_get_name(researchItem);
ptr = buffer; ptr = buffer;
@ -787,7 +792,19 @@ static void window_editor_inventions_list_scrollpaint(rct_window *w, rct_drawpix
ptr = utf8_write_codepoint(ptr, colour); ptr = utf8_write_codepoint(ptr, colour);
} }
format_string(ptr, 256, stringId, nullptr); if (researchItem->type == RESEARCH_ENTRY_TYPE_RIDE && !RideGroupManager::RideTypeIsIndependent(researchItem->baseRideType))
{
const rct_string_id rideGroupName = get_ride_naming(researchItem->baseRideType, get_ride_entry(researchItem->entryIndex)).name;
rct_string_id args[] = {
rideGroupName,
stringId
};
format_string(ptr, 256, STR_INVENTIONS_LIST_RIDE_AND_VEHICLE_NAME, &args);
}
else
{
format_string(ptr, 256, stringId, nullptr);
}
if (disableItemMovement) { if (disableItemMovement) {
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK; gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK;
@ -814,16 +831,29 @@ static void window_editor_inventions_list_scrollpaint(rct_window *w, rct_drawpix
*/ */
static void window_editor_inventions_list_drag_open(rct_research_item *researchItem) static void window_editor_inventions_list_drag_open(rct_research_item *researchItem)
{ {
char buffer[256]; char buffer[256], *ptr;
sint32 stringWidth; sint32 stringWidth;
rct_string_id stringId;
rct_window *w; rct_window *w;
window_close_by_class(WC_EDITOR_INVENTION_LIST_DRAG); window_close_by_class(WC_EDITOR_INVENTION_LIST_DRAG);
_editorInventionsListDraggedItem = researchItem; _editorInventionsListDraggedItem = researchItem;
rct_string_id stringId = research_item_get_name(researchItem);
ptr = buffer;
if (researchItem->type == RESEARCH_ENTRY_TYPE_RIDE && !RideGroupManager::RideTypeIsIndependent(researchItem->baseRideType))
{
const rct_string_id rideGroupName = get_ride_naming(researchItem->baseRideType, get_ride_entry(researchItem->entryIndex)).name;
rct_string_id args[] = {
rideGroupName,
stringId
};
format_string(ptr, 256, STR_INVENTIONS_LIST_RIDE_AND_VEHICLE_NAME, &args);
}
else
{
format_string(ptr, 256, stringId, nullptr);
}
stringId = research_item_get_name(researchItem);
format_string(buffer, 256, stringId, nullptr);
stringWidth = gfx_get_string_width(buffer); stringWidth = gfx_get_string_width(buffer);
window_editor_inventions_list_drag_widgets[0].right = stringWidth; window_editor_inventions_list_drag_widgets[0].right = stringWidth;
@ -882,13 +912,34 @@ static void window_editor_inventions_list_drag_moved(rct_window* w, sint32 x, si
*/ */
static void window_editor_inventions_list_drag_paint(rct_window *w, rct_drawpixelinfo *dpi) static void window_editor_inventions_list_drag_paint(rct_window *w, rct_drawpixelinfo *dpi)
{ {
rct_string_id stringId; rct_string_id drawString;
sint32 x, y; sint32 x, y;
x = w->x; x = w->x;
y = w->y + 2; y = w->y + 2;
stringId = research_item_get_name(_editorInventionsListDraggedItem); drawString = window_editor_inventions_list_prepare_name(_editorInventionsListDraggedItem, true);
gfx_draw_string_left(dpi, STR_WINDOW_COLOUR_2_STRINGID, &stringId, COLOUR_BLACK | COLOUR_FLAG_OUTLINE, x, y); gfx_draw_string_left(dpi, drawString, gCommonFormatArgs, COLOUR_BLACK | COLOUR_FLAG_OUTLINE, x, y);
}
static rct_string_id window_editor_inventions_list_prepare_name(const rct_research_item * researchItem, bool withGap)
{
rct_string_id drawString;
rct_string_id stringId = research_item_get_name(researchItem);
if (researchItem->type == RESEARCH_ENTRY_TYPE_RIDE && !RideGroupManager::RideTypeIsIndependent(researchItem->baseRideType))
{
drawString = withGap ? STR_INVENTIONS_LIST_RIDE_AND_VEHICLE_NAME_DRAG : STR_WINDOW_COLOUR_2_STRINGID_STRINGID;
rct_string_id rideGroupName = get_ride_naming(researchItem->baseRideType, get_ride_entry(researchItem->entryIndex)).name;
set_format_arg(0, rct_string_id, rideGroupName);
set_format_arg(2, rct_string_id, stringId);
}
else
{
drawString = STR_WINDOW_COLOUR_2_STRINGID;
set_format_arg(0, rct_string_id, stringId);
}
return drawString;
} }
#pragma endregion #pragma endregion

View File

@ -3891,6 +3891,10 @@ enum {
STR_EARLY_COMPLETION_TIP = 6227, STR_EARLY_COMPLETION_TIP = 6227,
STR_SCENARIO_OPTIONS = 6228, STR_SCENARIO_OPTIONS = 6228,
STR_WINDOW_COLOUR_2_STRINGID_STRINGID = 6229,
STR_INVENTIONS_LIST_RIDE_AND_VEHICLE_NAME = 6230,
STR_INVENTIONS_LIST_RIDE_AND_VEHICLE_NAME_DRAG = 6231,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
STR_COUNT = 32768 STR_COUNT = 32768
}; };

View File

@ -775,7 +775,7 @@ void set_every_ride_entry_not_invented()
* *
* rct2: 0x0068563D * rct2: 0x0068563D
*/ */
rct_string_id research_item_get_name(rct_research_item * researchItem) rct_string_id research_item_get_name(const rct_research_item * researchItem)
{ {
if (researchItem->type == RESEARCH_ENTRY_TYPE_RIDE) if (researchItem->type == RESEARCH_ENTRY_TYPE_RIDE)

View File

@ -139,7 +139,7 @@ void set_every_ride_type_invented();
void set_every_ride_type_not_invented(); void set_every_ride_type_not_invented();
void set_every_ride_entry_invented(); void set_every_ride_entry_invented();
void set_every_ride_entry_not_invented(); void set_every_ride_entry_not_invented();
rct_string_id research_item_get_name(rct_research_item * researchItem); rct_string_id research_item_get_name(const rct_research_item * researchItem);
rct_string_id research_get_friendly_base_ride_type_name(uint8 trackType, rct_ride_entry * rideEntry); rct_string_id research_get_friendly_base_ride_type_name(uint8 trackType, rct_ride_entry * rideEntry);
void research_remove_flags(); void research_remove_flags();
void research_fix(); void research_fix();