mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-04 13:42:55 +01:00
fix up track manage window
This commit is contained in:
@@ -3364,7 +3364,7 @@ STR_3353 :New name contains invalid characters
|
||||
STR_3354 :Another file exists with this name, or file is write-protected
|
||||
STR_3355 :File is write-protected or locked
|
||||
STR_3356 :Delete File
|
||||
STR_3357 :{WINDOW_COLOUR_2}Are you sure you want to permanently delete {STRINGID} ?
|
||||
STR_3357 :{WINDOW_COLOUR_2}Are you sure you want to permanently delete {STRING} ?
|
||||
STR_3358 :Can't delete track design...
|
||||
STR_3359 :{BLACK}No track designs of this type
|
||||
STR_3360 :Warning!
|
||||
|
||||
@@ -19,12 +19,13 @@
|
||||
|
||||
#include "../common.h"
|
||||
#include "../drawing/drawing.h"
|
||||
#include "../management/research.h"
|
||||
#include "../peep/peep.h"
|
||||
#include "../ride/ride.h"
|
||||
#include "../ride/track_design.h"
|
||||
#include "../ride/vehicle.h"
|
||||
#include "../world/park.h"
|
||||
#include "../management/research.h"
|
||||
#include "../scenario.h"
|
||||
#include "../world/park.h"
|
||||
#include "colour.h"
|
||||
|
||||
struct rct_window;
|
||||
@@ -651,7 +652,7 @@ void window_research_funding_page_paint(rct_window *w, rct_drawpixelinfo *dpi, i
|
||||
void window_scenery_open();
|
||||
void window_music_credits_open();
|
||||
void window_publisher_credits_open();
|
||||
void window_track_manage_open();
|
||||
void window_track_manage_open(track_design_file_ref *tdFileRef);
|
||||
void window_viewport_open();
|
||||
void window_themes_open();
|
||||
void window_title_editor_open(int tab);
|
||||
|
||||
@@ -1879,10 +1879,13 @@ enum {
|
||||
STR_TRACK_MANAGE_RENAME = 3348,
|
||||
STR_TRACK_MANAGE_DELETE = 3349,
|
||||
|
||||
STR_TRACK_DESIGN_RENAME_TITLE = 3350,
|
||||
STR_TRACK_DESIGN_RENAME_DESC = 3351,
|
||||
STR_CANT_RENAME_TRACK_DESIGN = 3352,
|
||||
STR_NEW_NAME_CONTAINS_INVALID_CHARACTERS = 3353,
|
||||
STR_ANOTHER_FILE_EXISTS_WITH_NAME_OR_FILE_IS_WRITE_PROTECTED = 3354,
|
||||
STR_FILE_IS_WRITE_PROTECTED_OR_LOCKED = 3355,
|
||||
STR_DELETE_FILE = 3356,
|
||||
|
||||
STR_ARE_YOU_SURE_YOU_WANT_TO_PERMANENTLY_DELETE_TRACK = 3357,
|
||||
STR_CANT_DELETE_TRACK_DESIGN = 3358,
|
||||
|
||||
@@ -182,7 +182,7 @@ static void window_install_track_select(rct_window *w, int index)
|
||||
substitute_path(track_path, (char*)RCT2_ADDRESS_TRACKS_PATH, trackDesignItem);
|
||||
|
||||
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
||||
window_track_manage_open();
|
||||
window_track_manage_open(NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -186,28 +186,16 @@ static void window_track_list_select(rct_window *w, int index)
|
||||
}
|
||||
|
||||
track_design_file_ref *tdRef = &_trackDesigns[index];
|
||||
|
||||
// trackDesignItem = trackDesignList + (index * 128);
|
||||
// RCT2_GLOBAL(0x00F4403C, utf8*) = trackDesignItem;
|
||||
// window_track_list_format_name(
|
||||
// (char*)0x009BC313,
|
||||
// trackDesignItem,
|
||||
// gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER ?
|
||||
// 0 :
|
||||
// FORMAT_WHITE,
|
||||
// 1);
|
||||
|
||||
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
||||
window_track_manage_open();
|
||||
return;
|
||||
}
|
||||
window_track_manage_open(tdRef);
|
||||
} else {
|
||||
if (_loadedTrackDesignIndex != -1 && (_loadedTrackDesign->track_flags & 4)) {
|
||||
window_error_open(STR_THIS_DESIGN_WILL_BE_BUILT_WITH_AN_ALTERNATIVE_VEHICLE_TYPE, STR_NONE);
|
||||
}
|
||||
|
||||
if (_loadedTrackDesignIndex != -1 && (_loadedTrackDesign->track_flags & 4)) {
|
||||
window_error_open(STR_THIS_DESIGN_WILL_BE_BUILT_WITH_AN_ALTERNATIVE_VEHICLE_TYPE, STR_NONE);
|
||||
window_close(w);
|
||||
window_track_place_open(tdRef->path);
|
||||
}
|
||||
|
||||
window_close(w);
|
||||
window_track_place_open(tdRef->path);
|
||||
}
|
||||
|
||||
static int window_track_list_get_list_item_index_from_position(int x, int y)
|
||||
@@ -247,7 +235,7 @@ static void window_track_list_mouseup(rct_window *w, int widgetIndex)
|
||||
break;
|
||||
case WIDX_TOGGLE_SCENERY:
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TRACK_DESIGN_SCENERY_TOGGLE, uint8) ^= 1;
|
||||
// reset_track_list_cache();
|
||||
_loadedTrackDesignIndex = -1;
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_BACK:
|
||||
@@ -547,17 +535,13 @@ static void window_track_list_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
*/
|
||||
static void window_track_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrollIndex)
|
||||
{
|
||||
rct_string_id stringId, stringId2;
|
||||
int i, x, y, colour;
|
||||
|
||||
colour = ColourMapA[w->colours[0]].mid_light;
|
||||
int colour = ColourMapA[w->colours[0]].mid_light;
|
||||
colour = (colour << 24) | (colour << 16) | (colour << 8) | colour;
|
||||
gfx_clear(dpi, colour);
|
||||
|
||||
i = 0;
|
||||
x = 0;
|
||||
y = 0;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
size_t listIndex = 0;
|
||||
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
|
||||
if (_trackDesignsCount == 0) {
|
||||
// No track designs
|
||||
@@ -566,7 +550,8 @@ static void window_track_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi,
|
||||
}
|
||||
} else {
|
||||
// Build custom track item
|
||||
if (i == w->track_list.var_482) {
|
||||
rct_string_id stringId;
|
||||
if (listIndex == w->track_list.var_482) {
|
||||
// Highlight
|
||||
gfx_fill_rect(dpi, x, y, w->width, y + 9, 0x2000000 | 49);
|
||||
stringId = 1193;
|
||||
@@ -574,15 +559,15 @@ static void window_track_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi,
|
||||
stringId = 1191;
|
||||
}
|
||||
|
||||
stringId2 = STR_BUILD_CUSTOM_DESIGN;
|
||||
rct_string_id stringId2 = STR_BUILD_CUSTOM_DESIGN;
|
||||
gfx_draw_string_left(dpi, stringId, &stringId2, 0, x, y - 1);
|
||||
y += 10;
|
||||
i++;
|
||||
listIndex++;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < _trackDesignsCount; i++) {
|
||||
for (size_t i = 0; i < _trackDesignsCount; i++, listIndex++) {
|
||||
if (y + 10 >= dpi->y && y < dpi->y + dpi->height) {
|
||||
uint16 listIndex = (uint16)(i + 1);
|
||||
rct_string_id stringId;
|
||||
if (listIndex == w->track_list.var_482) {
|
||||
// Highlight
|
||||
gfx_fill_rect(dpi, x, y, w->width, y + 9, 0x2000000 | 49);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "../localisation/localisation.h"
|
||||
#include "../ride/track.h"
|
||||
#include "../ride/track_design.h"
|
||||
#include "../util/util.h"
|
||||
#include "error.h"
|
||||
|
||||
#pragma region Widgets
|
||||
@@ -48,10 +49,10 @@ static rct_widget window_track_manage_widgets[] = {
|
||||
|
||||
static rct_widget window_track_delete_prompt_widgets[] = {
|
||||
{ WWT_FRAME, 0, 0, 249, 0, 73, STR_NONE, STR_NONE },
|
||||
{ WWT_CAPTION, 0, 1, 248, 1, 14, 3356, STR_WINDOW_TITLE_TIP },
|
||||
{ WWT_CAPTION, 0, 1, 248, 1, 14, STR_DELETE_FILE, STR_WINDOW_TITLE_TIP },
|
||||
{ WWT_CLOSEBOX, 0, 237, 247, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP },
|
||||
{ WWT_DROPDOWN_BUTTON, 0, 10, 119, 54, 65, 3349, STR_NONE },
|
||||
{ WWT_DROPDOWN_BUTTON, 0, 130, 239, 54, 65, 972, STR_NONE },
|
||||
{ WWT_DROPDOWN_BUTTON, 0, 10, 119, 54, 65, STR_TRACK_MANAGE_DELETE, STR_NONE },
|
||||
{ WWT_DROPDOWN_BUTTON, 0, 130, 239, 54, 65, STR_CANCEL, STR_NONE },
|
||||
{ WIDGETS_END }
|
||||
};
|
||||
|
||||
@@ -135,19 +136,19 @@ static rct_window_event_list window_track_delete_prompt_events = {
|
||||
|
||||
#pragma endregion
|
||||
|
||||
static track_design_file_ref *_trackDesignFileReference;
|
||||
|
||||
static void window_track_delete_prompt_open();
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006D348F
|
||||
*/
|
||||
void window_track_manage_open()
|
||||
void window_track_manage_open(track_design_file_ref *tdFileRef)
|
||||
{
|
||||
rct_window *w, *trackDesignListWindow;
|
||||
|
||||
window_close_by_class(WC_MANAGE_TRACK_DESIGN);
|
||||
|
||||
w = window_create_centred(
|
||||
rct_window *w = window_create_centred(
|
||||
250,
|
||||
44,
|
||||
&window_track_manage_events,
|
||||
@@ -161,9 +162,15 @@ void window_track_manage_open()
|
||||
(1 << WIDX_DELETE);
|
||||
window_init_scroll_widgets(w);
|
||||
|
||||
trackDesignListWindow = window_find_by_class(WC_TRACK_DESIGN_LIST);
|
||||
if (trackDesignListWindow != NULL)
|
||||
rct_window *trackDesignListWindow = window_find_by_class(WC_TRACK_DESIGN_LIST);
|
||||
if (trackDesignListWindow != NULL) {
|
||||
trackDesignListWindow->track_list.var_484 |= 1;
|
||||
}
|
||||
|
||||
utf8 *title = (utf8*)language_get_string(3155);
|
||||
format_string(title, STR_TRACK_LIST_NAME_FORMAT, &tdFileRef->name);
|
||||
|
||||
_trackDesignFileReference = tdFileRef;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,8 +180,9 @@ void window_track_manage_open()
|
||||
static void window_track_manage_close(rct_window *w)
|
||||
{
|
||||
rct_window *trackDesignListWindow = window_find_by_class(WC_TRACK_DESIGN_LIST);
|
||||
if (trackDesignListWindow != NULL)
|
||||
if (trackDesignListWindow != NULL) {
|
||||
trackDesignListWindow->track_list.var_484 &= ~1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,24 +191,19 @@ static void window_track_manage_close(rct_window *w)
|
||||
*/
|
||||
static void window_track_manage_mouseup(rct_window *w, int widgetIndex)
|
||||
{
|
||||
char *trackDesignList = RCT2_ADDRESS(RCT2_ADDRESS_TRACK_LIST, char);
|
||||
rct_window *trackDesignListWindow;
|
||||
char *dst, *src;
|
||||
|
||||
switch (widgetIndex) {
|
||||
case WIDX_CLOSE:
|
||||
window_close(w);
|
||||
break;
|
||||
case WIDX_RENAME:
|
||||
trackDesignListWindow = window_find_by_class(WC_TRACK_DESIGN_LIST);
|
||||
if (trackDesignListWindow != NULL) {
|
||||
src = &trackDesignList[trackDesignListWindow->track_list.var_482 * 128];
|
||||
dst = (char*)0x009BC677;
|
||||
while (*src != 0 && *src != '.')
|
||||
*dst++ = *src++;
|
||||
*dst = 0;
|
||||
window_text_input_open(w, widgetIndex, 3350, 3351, 3165, 0, 127);
|
||||
}
|
||||
window_text_input_raw_open(
|
||||
w,
|
||||
widgetIndex,
|
||||
STR_TRACK_DESIGN_RENAME_TITLE,
|
||||
STR_TRACK_DESIGN_RENAME_DESC,
|
||||
_trackDesignFileReference->name,
|
||||
127
|
||||
);
|
||||
break;
|
||||
case WIDX_DELETE:
|
||||
window_track_delete_prompt_open();
|
||||
@@ -214,8 +217,9 @@ static void window_track_manage_mouseup(rct_window *w, int widgetIndex)
|
||||
*/
|
||||
static void window_track_manage_textinput(rct_window *w, int widgetIndex, char *text)
|
||||
{
|
||||
if (widgetIndex != WIDX_RENAME || text == NULL)
|
||||
if (widgetIndex != WIDX_RENAME || text == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if (track_rename(text)) {
|
||||
// window_close_by_class(WC_TRACK_DELETE_PROMPT);
|
||||
@@ -280,10 +284,11 @@ static void window_track_delete_prompt_mouseup(rct_window *w, int widgetIndex)
|
||||
break;
|
||||
case WIDX_PROMPT_DELETE:
|
||||
window_close(w);
|
||||
if (track_delete())
|
||||
if (track_delete()) {
|
||||
window_close_by_class(WC_MANAGE_TRACK_DESIGN);
|
||||
else
|
||||
} else {
|
||||
window_error_open(STR_CANT_DELETE_TRACK_DESIGN, gGameCommandErrorText);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -299,12 +304,15 @@ static void window_track_delete_prompt_invalidate(rct_window *w)
|
||||
*/
|
||||
static void window_track_delete_prompt_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
{
|
||||
rct_string_id stringId;
|
||||
|
||||
window_draw_widgets(w, dpi);
|
||||
|
||||
stringId = 3155;
|
||||
gfx_draw_string_centred_wrapped(
|
||||
dpi, &stringId, w->x + 125, w->y + 28, 246, STR_ARE_YOU_SURE_YOU_WANT_TO_PERMANENTLY_DELETE_TRACK, 0
|
||||
dpi,
|
||||
&_trackDesignFileReference->name,
|
||||
w->x + 125,
|
||||
w->y + 28,
|
||||
246,
|
||||
STR_ARE_YOU_SURE_YOU_WANT_TO_PERMANENTLY_DELETE_TRACK,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user