make scenery window usable, partially fixes #408

This commit is contained in:
IntelOrca 2015-02-15 13:54:11 +00:00 committed by Thomas
parent abe3008fc8
commit cfff5c6d88
2 changed files with 168 additions and 123 deletions

View File

@ -827,7 +827,40 @@ void window_init_scroll_widgets(rct_window *w)
*/
void window_update_scroll_widgets(rct_window *w)
{
RCT2_CALLPROC_X(0x006EAE4E, 0, 0, 0, 0, (int)w, 0, 0);
// RCT2_CALLPROC_X(0x006EAE4E, 0, 0, 0, 0, (int)w, 0, 0);
int widgetIndex, scrollIndex, width, height, scrollPositionChanged;
rct_scroll *scroll;
rct_widget *widget;
widgetIndex = 0;
scrollIndex = 0;
for (widget = w->widgets; widget->type != WWT_LAST; widget++, widgetIndex++) {
if (widget->type != WWT_SCROLL)
continue;
scroll = &w->scrolls[scrollIndex];
window_get_scroll_size(w, scrollIndex, &width, &height);
width++;
height++;
scrollPositionChanged = 0;
if ((widget->image & 1) && width != scroll->h_right) {
scrollPositionChanged = 1;
scroll->h_right = width;
}
if ((widget->image & 2) && height != scroll->v_bottom) {
scrollPositionChanged = 1;
scroll->v_bottom = height;
}
if (scrollPositionChanged) {
widget_scroll_update_thumbs(w, widgetIndex);
window_invalidate(w);
}
scrollIndex++;
}
}
int window_get_scroll_size(rct_window *w, int scrollIndex, int *width, int *height)

View File

@ -55,7 +55,7 @@ enum {
WINDOW_SCENERY_TAB_18,
WINDOW_SCENERY_TAB_19,
WINDOW_SCENERY_TAB_20
} WINDOW_SCENERY_LIST_TAB;
};
static void window_scenery_emptysub() { }
static void window_scenery_close();
@ -176,10 +176,10 @@ static rct_widget window_scenery_widgets[] = {
static sint16 window_scenery_tab_entries[0x14][SCENERY_ENTRIES_BY_TAB + 1];
/*
* Was part of 0x006DFA00
* The same code repeated five times for every scenery entry type
*/
/**
* Was part of 0x006DFA00
* The same code repeated five times for every scenery entry type
*/
void init_scenery_entry(rct_scenery_entry *sceneryEntry, int index, uint8 sceneryTabId) {
if (RCT2_ADDRESS(0x01357BD0, sint32)[index >> 5] & (1 << (index & 0x1F))) {
if (sceneryTabId != 0xFF) {
@ -217,9 +217,10 @@ void init_scenery_entry(rct_scenery_entry *sceneryEntry, int index, uint8 scener
}
}
/*
* rct2: 0x006DFA00
**/
/**
*
* rct2: 0x006DFA00
*/
void init_scenery() {
bool enabledScenerySets[0x13] = { false };
@ -366,9 +367,10 @@ void init_scenery() {
window_invalidate_by_class(WC_SCENERY);
}
/*
* rct2: 0x006E0FEF
**/
/**
*
* rct2: 0x006E0FEF
*/
void window_scenery_open()
{
rct_window* window;
@ -437,9 +439,10 @@ void window_scenery_open()
window->colours[2] = 0x0C;
}
/*
* rct2: 0x0066DB3D
*/
/**
*
* rct2: 0x0066DB3D
*/
bool window_scenery_is_scenery_tool_active() {
int toolWindowClassification = RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass);
int toolWidgetIndex = RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, rct_windownumber);
@ -452,9 +455,10 @@ bool window_scenery_is_scenery_tool_active() {
}
/*
* rct2: 0x006E1A73
**/
/**
*
* rct2: 0x006E1A73
*/
void window_scenery_close() {
rct_window *w;
@ -468,7 +472,8 @@ void window_scenery_close() {
tool_cancel();
}
int window_scenery_scrollgetsize_num() {
int window_scenery_scrollgetsize_num()
{
int items = 0;
while (window_scenery_tab_entries[window_scenery_active_tab_index][items] != -1)
items++;
@ -482,9 +487,9 @@ int window_scenery_scrollgetsize_num() {
}
/**
*
* rct2: 0x006BD94C
*/
*
* rct2: 0x006BD94C
*/
static void window_scenery_mouseup()
{
short widgetIndex;
@ -514,12 +519,12 @@ static void window_scenery_mouseup()
}
/*
*
* rct2: 0x006E1EB4
*/
void window_scenery_update_scroll(rct_window *w) {
int scrollsize = window_scenery_scrollgetsize_num();
w->scrolls[0].v_bottom = scrollsize;
*
* rct2: 0x006E1EB4
*/
void window_scenery_update_scroll(rct_window *w)
{
w->scrolls[0].v_bottom = window_scenery_scrollgetsize_num() + 1;
int tabIndex = window_scenery_active_tab_index;
@ -543,9 +548,9 @@ void window_scenery_update_scroll(rct_window *w) {
}
/**
*
* rct2: 0x006E1E48
*/
*
* rct2: 0x006E1E48
*/
static void window_scenery_resize()
{
rct_window *w;
@ -576,9 +581,9 @@ static void window_scenery_resize()
}
/**
*
* rct2: 0x006E1A25
*/
*
* rct2: 0x006E1A25
*/
static void window_scenery_mousedown(int widgetIndex, rct_window* w, rct_widget* widget) {
switch (widgetIndex) {
case WIDX_SCENERY_PRIMARY_COLOUR_BUTTON:
@ -601,9 +606,9 @@ static void window_scenery_mousedown(int widgetIndex, rct_window* w, rct_widget*
}
/**
*
* rct2: 0x006E1A54
*/
*
* rct2: 0x006E1A54
*/
static void window_scenery_dropdown() {
rct_window* w;
short widgetIndex, dropdownIndex;
@ -626,9 +631,9 @@ static void window_scenery_dropdown() {
}
/**
*
* rct2: 0x006E1B9F
*/
*
* rct2: 0x006E1B9F
*/
static void window_scenery_event_07() {
rct_window *w;
@ -640,21 +645,19 @@ static void window_scenery_event_07() {
}
/**
*
* rct2: 0x006E1CD3
*/
*
* rct2: 0x006E1CD3
*/
static void window_scenery_update(rct_window *w)
{
rct_window* other = window_find_from_point(RCT2_GLOBAL(0x0142406C, int), RCT2_GLOBAL(0x01424070, int));
rct_window *other = window_find_from_point(RCT2_GLOBAL(0x0142406C, int), RCT2_GLOBAL(0x01424070, int));
if (other == w) {
int window_x = RCT2_GLOBAL(0x0142406C, int) - w->x + 0x1A;
int window_x = RCT2_GLOBAL(0x0142406C, int) - w->x + 26;
int window_y = RCT2_GLOBAL(0x01424070, int) - w->y;
if (window_y < 0x2C || window_x <= w->width) {
int widgetIndex = window_find_widget_from_point(w,
RCT2_GLOBAL(0x0142406C, int), RCT2_GLOBAL(0x01424070, int));
if (widgetIndex >= 3) {
if (window_y < 44 || window_x <= w->width) {
int widgetIndex = window_find_widget_from_point(w, RCT2_GLOBAL(0x0142406C, int), RCT2_GLOBAL(0x01424070, int));
if (widgetIndex >= WIDX_SCENERY_TAB_CONTENT_PANEL) {
w->scenery.hover_counter++;
if (w->scenery.hover_counter < 8) {
if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, sint8) != INPUT_STATE_SCROLL_LEFT) {
@ -664,13 +667,9 @@ static void window_scenery_update(rct_window *w)
w->max_height = WINDOW_SCENERY_HEIGHT;
}
} else {
int windowHeight = w->scrolls[0].v_bottom + 0x3E;
if (windowHeight > 0x1C6)
windowHeight = 0x1C6;
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) < 0x258){
if (windowHeight > 0x176)
windowHeight = 0x176;
}
int windowHeight = min(454, w->scrolls[0].v_bottom - 1 + 62);
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) < 600)
windowHeight = min(374, windowHeight);
w->min_width = WINDOW_SCENERY_WIDTH;
w->max_width = WINDOW_SCENERY_WIDTH;
@ -721,20 +720,21 @@ static void window_scenery_update(rct_window *w)
}
/**
*
* rct2: 0x006E1A91
*/
void window_scenery_scrollgetsize() {
int scrollHeight = window_scenery_scrollgetsize_num();
*
* rct2: 0x006E1A91
*/
void window_scenery_scrollgetsize()
{
int width, height;
#ifdef _MSC_VER
__asm mov edx, scrollHeight
#else
__asm__("mov edx, %[scrollHeight] " : [scrollHeight] "+m" (scrollHeight));
#endif
width = 0;
height = window_scenery_scrollgetsize_num();
window_scrollsize_set_registers(width, height);
}
short get_scenery_id_by_cursor_pos(short x, short y) {
short get_scenery_id_by_cursor_pos(short x, short y)
{
int tabSceneryIndex = x / SCENERY_BUTTON_WIDTH + (y / SCENERY_BUTTON_HEIGHT) * 9;
uint8 tabIndex = window_scenery_active_tab_index;
@ -752,10 +752,11 @@ short get_scenery_id_by_cursor_pos(short x, short y) {
}
/**
*
* rct2: 0x006E1C4A
*/
void window_scenery_scrollmousedown() {
*
* rct2: 0x006E1C4A
*/
void window_scenery_scrollmousedown()
{
short x, y, scrollIndex;
rct_window *w;
@ -776,10 +777,11 @@ void window_scenery_scrollmousedown() {
}
/**
*
* rct2: 0x006E1BB8
*/
void window_scenery_scrollmouseover() {
*
* rct2: 0x006E1BB8
*/
void window_scenery_scrollmouseover()
{
short x, y, scrollIndex;
rct_window *w;
@ -792,53 +794,69 @@ void window_scenery_scrollmouseover() {
}
/**
*
* rct2: 0x006E1C05
*/
void window_scenery_tooltip() {
uint16 tooltipIndex;
*
* rct2: 0x006E1C05
*/
void window_scenery_tooltip()
{
rct_window *w;
short widget;
#ifdef _MSC_VER
__asm mov tooltipIndex, ax
#else
__asm__("mov %[tooltipIndex], ax " : [tooltipIndex] "+m" (tooltipIndex));
#endif
window_scroll_get_registers(w, widget);
if (tooltipIndex == 0x18)
{
switch (widget) {
case WIDX_SCENERY_LIST:
RCT2_GLOBAL(0x013CE952, uint16) = 3159;
}
else if (tooltipIndex >= 4 && tooltipIndex < 0x17)
{
RCT2_GLOBAL(0x013CE952, uint16) = g_scenerySetEntries[tooltipIndex - 4]->name;
break;
case WIDX_SCENERY_TAB_1:
case WIDX_SCENERY_TAB_2:
case WIDX_SCENERY_TAB_3:
case WIDX_SCENERY_TAB_4:
case WIDX_SCENERY_TAB_5:
case WIDX_SCENERY_TAB_6:
case WIDX_SCENERY_TAB_7:
case WIDX_SCENERY_TAB_8:
case WIDX_SCENERY_TAB_9:
case WIDX_SCENERY_TAB_10:
case WIDX_SCENERY_TAB_11:
case WIDX_SCENERY_TAB_12:
case WIDX_SCENERY_TAB_13:
case WIDX_SCENERY_TAB_14:
case WIDX_SCENERY_TAB_15:
case WIDX_SCENERY_TAB_16:
case WIDX_SCENERY_TAB_17:
case WIDX_SCENERY_TAB_18:
case WIDX_SCENERY_TAB_19:
case WIDX_SCENERY_TAB_20:
RCT2_GLOBAL(0x013CE952, uint16) = g_scenerySetEntries[widget - WIDX_SCENERY_TAB_1]->name;
break;
}
}
/**
*
* rct2: 0x006E118B
*/
void window_scenery_invalidate() {
*
* rct2: 0x006E118B
*/
void window_scenery_invalidate()
{
rct_window* w;
window_get_register(w);
uint16 tabIndex = window_scenery_active_tab_index;
uint32 titleStringId = 0x715;
if (tabIndex <= 0x13) {
uint32 titleStringId = 1813;
if (tabIndex <= 19)
titleStringId = g_scenerySetEntries[tabIndex]->name;
}
window_scenery_widgets[WIDX_SCENERY_TITLE].image = titleStringId;
w->pressed_widgets = (((uint32)w->pressed_widgets & 0xFF00000F) | (1 << (tabIndex + 4))) & 0xBBFFFFFF;
if (window_scenery_is_repaint_scenery_tool_on == 1) {
if (window_scenery_is_repaint_scenery_tool_on == 1)
w->pressed_widgets |= (1 << WIDX_SCENERY_REPAINT_SCENERY_BUTTON);
}
if (window_scenery_is_build_cluster_tool_on == 1) {
if (window_scenery_is_build_cluster_tool_on == 1)
w->pressed_widgets |= (1 << WIDX_SCENERY_BUILD_CLUSTER_BUTTON);
}
window_scenery_widgets[WIDX_SCENERY_ROTATE_OBJECTS_BUTTON].type = WWT_EMPTY;
window_scenery_widgets[WIDX_SCENERY_BUILD_CLUSTER_BUTTON].type = WWT_EMPTY;
@ -875,8 +893,7 @@ void window_scenery_invalidate() {
window_scenery_widgets[WIDX_SCENERY_SECONDARY_COLOUR_BUTTON].type = WWT_COLORBTN;
window_scenery_widgets[WIDX_SCENERY_TERTIARY_COLOUR_BUTTON].type = WWT_COLORBTN;
window_scenery_widgets[WIDX_SCENERY_ROTATE_OBJECTS_BUTTON].type = WWT_EMPTY;
}
else if (tabSelectedSceneryId != -1) {
} else if (tabSelectedSceneryId != -1) {
rct_scenery_entry* sceneryEntry = NULL;
if (tabSelectedSceneryId >= 0x400) {
@ -884,16 +901,14 @@ void window_scenery_invalidate() {
if (sceneryEntry->banner.flags & 1)
window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WWT_COLORBTN;
}
else if (tabSelectedSceneryId >= 0x300) {
} else if (tabSelectedSceneryId >= 0x300) {
sceneryEntry = g_largeSceneryEntries[tabSelectedSceneryId - 0x300];
if (sceneryEntry->large_scenery.flags & 1)
window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WWT_COLORBTN;
if (sceneryEntry->large_scenery.flags & 2)
window_scenery_widgets[WIDX_SCENERY_SECONDARY_COLOUR_BUTTON].type = WWT_COLORBTN;
}
else if (tabSelectedSceneryId >= 0x200) {
} else if (tabSelectedSceneryId >= 0x200) {
sceneryEntry = g_wallSceneryEntries[tabSelectedSceneryId - 0x200];
if (sceneryEntry->wall.flags & (WALL_SCENERY_FLAG1 | WALL_SCENERY_FLAG2)) {
window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WWT_COLORBTN;
@ -907,8 +922,7 @@ void window_scenery_invalidate() {
window_scenery_widgets[WIDX_SCENERY_TERTIARY_COLOUR_BUTTON].type = WWT_COLORBTN;
}
}
}
else if (tabSelectedSceneryId < 0x100) {
} else if (tabSelectedSceneryId < 0x100) {
sceneryEntry = g_smallSceneryEntries[tabSelectedSceneryId];
if (sceneryEntry->small_scenery.flags & (SMALL_SCENERY_HAS_PRIMARY_COLOUR | SMALL_SCENERY_FLAG10)) {
@ -927,8 +941,8 @@ void window_scenery_invalidate() {
window_scenery_widgets[WIDX_SCENERY_TITLE].right = w->width - 2;
window_scenery_widgets[WIDX_SCENERY_CLOSE].left = w->width - 13;
window_scenery_widgets[WIDX_SCENERY_CLOSE].right = window_scenery_widgets[WIDX_SCENERY_CLOSE].left + 10;
window_scenery_widgets[WIDX_SCENERY_LIST].right = w->width - 0x1A;
window_scenery_widgets[WIDX_SCENERY_LIST].bottom = w->height - 0x0E;
window_scenery_widgets[WIDX_SCENERY_LIST].right = w->width - 26;
window_scenery_widgets[WIDX_SCENERY_LIST].bottom = w->height - 14;
window_scenery_widgets[WIDX_SCENERY_ROTATE_OBJECTS_BUTTON].left = w->width - 25;
window_scenery_widgets[WIDX_SCENERY_REPAINT_SCENERY_BUTTON].left = w->width - 25;
@ -946,10 +960,11 @@ void window_scenery_invalidate() {
}
/**
*
* rct2: 0x006E1462
*/
void window_scenery_paint() {
*
* rct2: 0x006E1462
*/
void window_scenery_paint()
{
rct_window *w;
rct_drawpixelinfo *dpi;
@ -1061,16 +1076,14 @@ void window_scenery_scrollpaint()
gfx_draw_sprite(dpi, imageId, left + 0x21, top + 0x28, w->colours[1]);
gfx_draw_sprite(dpi, imageId + 1, left + 0x21, top + 0x28, w->colours[1]);
}
else if (currentSceneryGlobalId >= 0x300) {
} else if (currentSceneryGlobalId >= 0x300) {
sceneryEntry = g_largeSceneryEntries[currentSceneryGlobalId - 0x300];
uint32 imageId = sceneryEntry->image + window_scenery_rotation;
imageId |= (window_scenery_primary_colour << 19) | 0x20000000;
imageId |= (window_scenery_secondary_colour << 24) | 0x80000000;
gfx_draw_sprite(dpi, imageId, left + 0x21, top, w->colours[1]);
}
else if (currentSceneryGlobalId >= 0x200) {
} else if (currentSceneryGlobalId >= 0x200) {
sceneryEntry = g_wallSceneryEntries[currentSceneryGlobalId - 0x200];
rct_drawpixelinfo* clipdpi = clip_drawpixelinfo(dpi, left + 1, 64, top + 1, 78);
if (clipdpi != NULL) {
@ -1114,8 +1127,7 @@ void window_scenery_scrollpaint()
rct2_free(clipdpi);
}
}
else if (currentSceneryGlobalId >= 0x100) {
} else if (currentSceneryGlobalId >= 0x100) {
sceneryEntry = g_pathBitSceneryEntries[currentSceneryGlobalId - 0x100];
uint32 imageId = sceneryEntry->image;