add more input logic

This commit is contained in:
IntelOrca 2014-04-25 03:02:06 +01:00
parent 66e4898217
commit be81e69f56
4 changed files with 132 additions and 12 deletions

View file

@ -336,7 +336,40 @@ static void game_handle_input_mouse(int x, int y, int state)
RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, w, widget, 0);
break;
case INPUT_STATE_DRAGGING:
RCT2_CALLPROC_X(0x006E8C5C, x, y, state, widgetIndex, w, widget, 0);
// RCT2_CALLPROC_X(0x006E8C5C, x, y, state, widgetIndex, w, widget, 0);
w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber));
if (w == NULL) {
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET;
break;
}
if (state == 0) {
y = clamp(29, y, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 34);
window_move_position(
w,
x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16),
y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16)
);
RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x;
RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y;
} else if (state == 2) {
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_NORMAL;
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint8) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, sint16);
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass);
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber);
y = clamp(29, y, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 34);
window_move_position(
w,
x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16),
y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16)
);
RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x;
RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y;
RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_18], 0, 0, x, y, w, 0, 0);
}
break;
case INPUT_STATE_VIEWPORT_DRAG:
{
@ -422,7 +455,33 @@ static void game_handle_input_mouse(int x, int y, int state)
RCT2_CALLPROC_X(0x006E8676, x, y, state, widgetIndex, w, widget, 0);
break;
case INPUT_STATE_RESIZING:
RCT2_CALLPROC_X(0x006E8B46, x, y, state, widgetIndex, w, widget, 0);
// RCT2_CALLPROC_X(0x006E8B46, x, y, state, widgetIndex, w, widget, 0);
w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber));
if (w == NULL) {
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET;
break;
}
if (state != 0 && state != 2)
break;
if (state == 2) {
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_NORMAL;
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint8) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, sint16);
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass);
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber);
}
if (y < RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 2) {
window_resize(
w,
x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16),
y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16)
);
}
RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x;
RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y;
break;
case 9:
RCT2_CALLPROC_X(0x006E8ACB, x, y, state, widgetIndex, w, widget, 0);
@ -599,7 +658,7 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex)
if (!(RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)))
break;
w = window_find_by_id(windowClass, windowNumber);
w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber));
if (w == NULL)
break;

View file

@ -453,6 +453,17 @@ void window_init_scroll_widgets(rct_window *w)
}
}
/**
*
* rct2: 0x006EAE4E
*
* @param w The window (esi).
*/
void window_update_scroll_widgets(rct_window *w)
{
RCT2_CALLPROC_X(0x006EAE4E, 0, 0, 0, 0, w, 0, 0);
}
int window_get_scroll_data_index(rct_window *w, int widget_index)
{
int i, result;
@ -793,7 +804,54 @@ void window_draw_viewport(rct_drawpixelinfo *dpi, rct_window *w)
viewport_render(dpi, w->viewport, dpi->x, dpi->y, dpi->x + dpi->width, dpi->y + dpi->height);
}
void window_resize(rct_window *w, int minWidth, int minHeight, int maxWidth, int maxHeight)
void window_move_position(rct_window *w, int dx, int dy)
{
if (dx == 0 && dy == 0)
return;
// Invalidate old region
window_invalidate(w);
// Translate window and viewport
w->x += dx;
w->y += dy;
if (w->viewport != NULL) {
w->viewport->x += dx;
w->viewport->y += dy;
}
// Invalidate new region
window_invalidate(w);
}
void window_resize(rct_window *w, int dw, int dh)
{
int i;
if (dw == 0 && dh == 0)
return;
// Invalidate old region
window_invalidate(w);
// Clamp new size to minimum and maximum
w->width = clamp(w->min_width, w->width + dw, w->max_width);
w->height = clamp(w->min_height, w->height + dh, w->max_height);
RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], w->width, w->height, 0, 0, w, 0, 0);
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, w, 0, 0);
// Update scroll widgets
for (i = 0; i < 3; i++) {
w->scrolls[i].h_right = -1;
w->scrolls[i].v_bottom = -1;
}
window_update_scroll_widgets(w);
// Invalidate new region
window_invalidate(w);
}
void window_set_resize(rct_window *w, int minWidth, int minHeight, int maxWidth, int maxHeight)
{
w->min_width = minWidth;
w->min_height = minHeight;

View file

@ -291,6 +291,7 @@ void window_invalidate(rct_window *window);
void window_invalidate_by_id(uint16 cls, rct_windownumber number);
void widget_invalidate(rct_windowclass cls, rct_windownumber number, int widgetIndex);
void window_init_scroll_widgets(rct_window *w);
void window_update_scroll_widgets(rct_window *w);
int window_get_scroll_data_index(rct_window *w, int widget_index);
rct_window *window_bring_to_front_by_id(rct_windowclass cls, rct_windownumber number);
@ -309,7 +310,9 @@ void window_draw(rct_window *w, int left, int top, int right, int bottom);
void window_draw_widgets(rct_window *w, rct_drawpixelinfo *dpi);
void window_draw_viewport(rct_drawpixelinfo *dpi, rct_window *w);
void window_resize(rct_window *w, int minWidth, int minHeight, int maxWidth, int maxHeight);
void window_move_position(rct_window *w, int dx, int dy);
void window_resize(rct_window *w, int dw, int dh);
void window_set_resize(rct_window *w, int minWidth, int minHeight, int maxWidth, int maxHeight);
// Open window functions
void window_main_open();

View file

@ -700,7 +700,7 @@ static void window_park_entrance_resize()
__asm mov w, esi
w->flags |= WF_RESIZABLE;
window_resize(w, 230, 174 + 9, 230 * 3, (274 + 9) * 3);
window_set_resize(w, 230, 174 + 9, 230 * 3, (274 + 9) * 3);
window_park_init_viewport(w);
}
@ -1110,7 +1110,7 @@ static void window_park_rating_resize()
__asm mov w, esi
window_resize(w, 230, 182, 230, 182);
window_set_resize(w, 230, 182, 230, 182);
}
/**
@ -1224,7 +1224,7 @@ static void window_park_guests_resize()
__asm mov w, esi
window_resize(w, 230, 182, 230, 182);
window_set_resize(w, 230, 182, 230, 182);
}
/**
@ -1339,7 +1339,7 @@ static void window_park_price_resize()
__asm mov w, esi
window_resize(w, 230, 124, 230, 124);
window_set_resize(w, 230, 124, 230, 124);
}
/**
@ -1489,7 +1489,7 @@ static void window_park_stats_resize()
__asm mov w, esi
window_resize(w, 230, 109, 230, 109);
window_set_resize(w, 230, 109, 230, 109);
}
/**
@ -1675,7 +1675,7 @@ static void window_park_objective_resize()
__asm mov w, esi
window_resize(w, 230, 224, 230, 224);
window_set_resize(w, 230, 224, 230, 224);
}
/**
@ -1800,7 +1800,7 @@ static void window_park_awards_resize()
__asm mov w, esi
window_resize(w, 230, 182, 230, 182);
window_set_resize(w, 230, 182, 230, 182);
}
/**