mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #178 from JeroenSack/master
Implement widget_scroll_get_part
This commit is contained in:
commit
486d25cb90
28
src/game.c
28
src/game.c
|
@ -562,17 +562,11 @@ static void input_mouseover(int x, int y, rct_window *w, int widgetIndex)
|
|||
|
||||
input_mouseover_widget_check(windowClass, windowNumber, widgetIndex);
|
||||
|
||||
if (w != NULL && widgetIndex != -1 && widget->type == WWT_SCROLL) {
|
||||
int eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
eax = x;
|
||||
ebx = y;
|
||||
esi = (int)w;
|
||||
edi = (int)widget;
|
||||
RCT2_CALLFUNC_X(0x006E9F92, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); // widget_scoll_get_part
|
||||
eax &= 0xFFFF;
|
||||
ebx &= 0xFFFF;
|
||||
ecx &= 0xFFFF;
|
||||
edx &= 0xFFFF;
|
||||
if (w != NULL && widgetIndex != -1 && widget->type == WWT_SCROLL)
|
||||
{
|
||||
int eax, ebx, ecx, edx;
|
||||
widget_scroll_get_part(w, widget, x, y, &eax, &ebx, &ecx, &edx);
|
||||
|
||||
if (ecx < 0)
|
||||
goto showTooltip;
|
||||
if (ecx == 0) {
|
||||
|
@ -764,16 +758,8 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex)
|
|||
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_X, uint16) = x;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_Y, uint16) = y;
|
||||
|
||||
int eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
eax = x;
|
||||
ebx = y;
|
||||
esi = (int)w;
|
||||
edi = (int)widget;
|
||||
RCT2_CALLFUNC_X(0x006E9F92, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); // widget_scoll_get_part
|
||||
eax &= 0xFFFF;
|
||||
ebx &= 0xFFFF;
|
||||
ecx &= 0xFFFF;
|
||||
edx &= 0xFFFF;
|
||||
int eax, ebx, ecx, edx;
|
||||
widget_scroll_get_part(w, widget, x, y, &eax, &ebx, &ecx, &edx);
|
||||
|
||||
RCT2_GLOBAL(0x009DE548, uint16) = ecx;
|
||||
RCT2_GLOBAL(0x009DE54C, uint32) = edx;
|
||||
|
|
103
src/widget.c
103
src/widget.c
|
@ -996,3 +996,106 @@ int widget_is_active_tool(rct_window *w, int widgetIndex)
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void widget_scroll_get_part(rct_window *w, rct_widget* widget, int x, int y, int *output_x, int *output_y, int *output_scroll_area, int *output_dx)
|
||||
{
|
||||
rct_widget* iterator = w->widgets;
|
||||
int scroll_id = 0;
|
||||
while (++iterator != widget)
|
||||
{
|
||||
if (iterator->type == WWT_SCROLL)
|
||||
{
|
||||
scroll_id++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((w->scrolls[scroll_id].flags & 0x01) && y >= (w->y + widget->bottom - 11))
|
||||
{
|
||||
//horizon scrollbar
|
||||
int rightOffset = 0;
|
||||
int iteratorLeft = widget->left + w->x;
|
||||
int iteratorRight = widget->right + w->x;
|
||||
if (w->scrolls[scroll_id].flags & 0x01)
|
||||
{
|
||||
rightOffset = 11;
|
||||
}
|
||||
if (x <= (iteratorLeft += 10))
|
||||
{
|
||||
*output_scroll_area = SCROLL_PART_HSCROLLBAR_LEFT;
|
||||
}
|
||||
else if (x >= (iteratorRight -= rightOffset))
|
||||
{
|
||||
*output_scroll_area = SCROLL_PART_NONE;
|
||||
}
|
||||
else if (x >= (iteratorRight -= 10))
|
||||
{
|
||||
*output_scroll_area = SCROLL_PART_HSCROLLBAR_RIGHT;
|
||||
}
|
||||
else if (x < (widget->left + w->x + w->scrolls[scroll_id].h_thumb_left))
|
||||
{
|
||||
*output_scroll_area = SCROLL_PART_HSCROLLBAR_LEFT_TROUGH;
|
||||
}
|
||||
else if (x >(widget->left + w->x + w->scrolls[scroll_id].h_thumb_right))
|
||||
{
|
||||
*output_scroll_area = SCROLL_PART_HSCROLLBAR_RIGHT_TROUGH;
|
||||
}
|
||||
else
|
||||
{
|
||||
*output_scroll_area = SCROLL_PART_HSCROLLBAR_THUMB;
|
||||
}
|
||||
}
|
||||
else if ((w->scrolls[scroll_id].flags & 10) || (x >= w->x + widget->right - 11))
|
||||
{
|
||||
//vertical scrollbar
|
||||
int bottomOffset = 0;
|
||||
int iteratorTop = widget->top + w->y;
|
||||
int iteratorBottom = widget->bottom + w->y;
|
||||
if (w->scrolls[scroll_id].flags & 0x01)
|
||||
{
|
||||
bottomOffset = 11;
|
||||
}
|
||||
if (y <= (iteratorTop += 10))
|
||||
{
|
||||
*output_scroll_area = SCROLL_PART_VSCROLLBAR_TOP;
|
||||
}
|
||||
else if (y >= (iteratorBottom -= bottomOffset))
|
||||
{
|
||||
*output_scroll_area = SCROLL_PART_NONE;
|
||||
}
|
||||
else if (y >= (iteratorBottom -= 10))
|
||||
{
|
||||
*output_scroll_area = SCROLL_PART_VSCROLLBAR_BOTTOM;
|
||||
}
|
||||
else if (y < (widget->top + w->y + w->scrolls[scroll_id].v_thumb_top))
|
||||
{
|
||||
*output_scroll_area = SCROLL_PART_VSCROLLBAR_TOP_TROUGH;
|
||||
}
|
||||
else if (y > (widget->top + w->y + w->scrolls[scroll_id].v_thumb_bottom))
|
||||
{
|
||||
*output_scroll_area = SCROLL_PART_VSCROLLBAR_BOTTOM_TROUGH;
|
||||
}
|
||||
else
|
||||
{
|
||||
*output_scroll_area = SCROLL_PART_VSCROLLBAR_THUMB;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//view
|
||||
*output_scroll_area = SCROLL_PART_VIEW;
|
||||
*output_x = x - widget->left;
|
||||
*output_y = y - widget->top;
|
||||
*output_x -= w->x;
|
||||
*output_y -= w->y;
|
||||
if (--*output_x < 0 || --*output_y < 0)
|
||||
{
|
||||
*output_scroll_area = SCROLL_PART_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
*output_x += w->scrolls[scroll_id].h_left;
|
||||
*output_y += w->scrolls[scroll_id].v_top;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,5 +62,5 @@ int widget_is_disabled(rct_window *w, int widgetIndex);
|
|||
int widget_is_pressed(rct_window *w, int widgetIndex);
|
||||
int widget_is_highlighted(rct_window *w, int widgetIndex);
|
||||
int widget_is_active_tool(rct_window *w, int widgetIndex);
|
||||
|
||||
void widget_scroll_get_part(rct_window *w, rct_widget* widget, int x, int y, int *output_x, int *output_y, int *output_cx, int *output_dx);
|
||||
#endif
|
||||
|
|
|
@ -81,7 +81,7 @@ typedef struct {
|
|||
* size: 0x12
|
||||
*/
|
||||
typedef struct {
|
||||
uint16 flags; // 0x00
|
||||
uint16 flags; // 0x00 (0x10 == vertical scrollbar, 0x01 == horizontal scrollbar)
|
||||
sint16 h_left; // 0x02
|
||||
sint16 h_right; // 0x04
|
||||
sint16 h_thumb_left; // 0x06
|
||||
|
|
Loading…
Reference in New Issue