add path dropdowns and disabled widgets

This commit is contained in:
IntelOrca 2014-04-29 22:25:37 +01:00
parent 9cf658356f
commit c20d209b69
2 changed files with 106 additions and 10 deletions

View File

@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include <memory.h>
#include <stdlib.h>
#include "addresses.h"
#include "sprites.h"
@ -800,6 +801,10 @@ static void widget_vscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, i
gfx_draw_string(dpi, (char*)0x009DED69, 0, l + 1, b - 8);
}
/**
*
* rct2: 0x006EB951
*/
static void widget_draw_image(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex)
{
int l, t, r, b, colour, image;
@ -826,7 +831,26 @@ static void widget_draw_image(rct_drawpixelinfo *dpi, rct_window *w, int widgetI
if (widget_is_pressed(w, widgetIndex) || widget_is_active_tool(w, widgetIndex))
image++;
if (!widget_is_disabled(w, widgetIndex)) {
if (widget_is_disabled(w, widgetIndex)) {
// Draw greyed out (light border bottom right shadow)
colour = w->colours[widget->colour];
colour = RCT2_ADDRESS(0x00141FC4A, uint8)[(colour & 0x7F) * 8] & 0xFF;
RCT2_GLOBAL(0x009ABDA4, uint32) = 0x009DED74;
memset(0x009DED74, colour, 256);
RCT2_GLOBAL(0x009DED74, uint8) = 0;
RCT2_GLOBAL(0x00EDF81C, uint32) = 0x20000000;
image &= 0x7FFFF;
RCT2_CALLPROC_X(0x0067A46E, 0, image, l + 1, t + 1, 0, dpi, 0);
// Draw greyed out (dark)
colour = w->colours[widget->colour];
colour = RCT2_ADDRESS(0x00141FC48, uint8)[(colour & 0x7F) * 8] & 0xFF;
RCT2_GLOBAL(0x009ABDA4, uint32) = 0x009DED74;
memset(0x009DED74, colour, 256);
RCT2_GLOBAL(0x009DED74, uint8) = 0;
RCT2_GLOBAL(0x00EDF81C, uint32) = 0x20000000;
RCT2_CALLPROC_X(0x0067A46E, 0, image, l, t, 0, dpi, 0);
} else {
if (image & 0x80000000) {
// ?
}
@ -837,8 +861,6 @@ static void widget_draw_image(rct_drawpixelinfo *dpi, rct_window *w, int widgetI
image |= colour << 19;
gfx_draw_sprite(dpi, image, l, t);
} else {
// ?
}
}

View File

@ -25,13 +25,14 @@
#include "viewport.h"
#include "widget.h"
#include "window.h"
#include "window_dropdown.h"
typedef struct {
uint16 pad_00;
uint32 image; // 0x02
uint32 pad_06;
uint8 pad_0A;
uint8 pad_0B;
uint8 flags; // 0x0B
} rct_path_type;
static enum WINDOW_FOOTPATH_WIDGET_IDX {
@ -139,6 +140,8 @@ static uint32 window_footpath_events[] = {
sint32 _window_footpath_cost;
static void window_footpath_show_footpath_types_dialog(rct_window *w, rct_widget *widget, int showQueues);
/**
*
* rct2: 0x006A7C43
@ -258,10 +261,10 @@ static void window_footpath_mousedown()
switch (widgetIndex) {
case WIDX_FOOTPATH_TYPE:
RCT2_CALLPROC_X(0x006A7F88, 0, 0, 0, widgetIndex, w, widget, 0);
window_footpath_show_footpath_types_dialog(w, widget, 0);
break;
case WIDX_QUEUELINE_TYPE:
RCT2_CALLPROC_X(0x006A7F88, 0, 0, 0, widgetIndex, w, widget, 0);
window_footpath_show_footpath_types_dialog(w, widget, 1);
break;
case WIDX_DIRECTION_NW:
RCT2_CALLPROC_X(0x006A8111, 0, 0, 0, 0, w, 0, 0);
@ -293,17 +296,47 @@ static void window_footpath_mousedown()
*/
static void window_footpath_dropdown()
{
int i, pathId;
short dropdownIndex;
short widgetIndex;
rct_window *w;
rct_path_type *pathType;
__asm mov dropdownIndex, ax
__asm mov widgetIndex, dx
__asm mov w, esi
if (widgetIndex == WIDX_FOOTPATH_TYPE) {
RCT2_CALLPROC_X(0x006A7F25, 0, 0, 0, 0, w, 0, 0);
} else if (widgetIndex == WIDX_QUEUELINE_TYPE) {
RCT2_CALLPROC_X(0x006A7F2E, 0, 0, 0, 0, w, 0, 0);
if (widgetIndex == WIDX_FOOTPATH_TYPE)
RCT2_GLOBAL(0x00F3EFA2, uint8) = 0;
else if (widgetIndex == WIDX_QUEUELINE_TYPE)
RCT2_GLOBAL(0x00F3EFA2, uint8) = 1;
else
return;
pathId = dropdownIndex;
if (pathId == -1) {
pathId = RCT2_GLOBAL(0x00F3EFA0, sint16);
} else {
int flags = 4;
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)
flags = 0;
i = -1;
do {
i++;
pathType = RCT2_ADDRESS(0x009ADA14, rct_path_type*)[i];
if (pathType == (rct_path_type*)-1)
continue;
if (pathType->flags & flags)
continue;
} while (--pathId >= 0);
pathId = i;
}
RCT2_GLOBAL(0x00F3EFA0, sint16) = pathId;
RCT2_CALLPROC_EBPSAFE(0x006A7831);
_window_footpath_cost = 0x80000000;
window_invalidate(w);
}
/**
@ -495,4 +528,45 @@ static void window_footpath_paint()
if (_window_footpath_cost != 0x80000000)
if (!(RCT2_GLOBAL(RCT2_ADDRESS_GAME_FLAGS, uint32) & GAME_FLAGS_NO_MONEY))
gfx_draw_string_centred(dpi, STR_COST_LABEL, x, y, 0, &_window_footpath_cost);
}
/**
*
* rct2: 0x006A7F88
*/
static void window_footpath_show_footpath_types_dialog(rct_window *w, rct_widget *widget, int showQueues)
{
int i, flags, numPathTypes, image;
rct_path_type *pathType;
numPathTypes = 0;
flags = 4;
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)
flags = 0;
for (i = 0; i < 16; i++) {
pathType = RCT2_ADDRESS(0x009ADA14, rct_path_type*)[i];
if (pathType == (rct_path_type*)-1)
continue;
if (pathType->flags & flags)
continue;
image = pathType->image + 71;
if (showQueues)
image++;
gDropdownItemsFormat[numPathTypes] = -1;
gDropdownItemsArgs[numPathTypes] = image;
numPathTypes++;
}
window_dropdown_show_image(
w->x + widget->left, w->y + widget->top, widget->bottom - widget->top + 1,
w->colours[1],
0,
numPathTypes,
47,
36,
gAppropriateImageDropdownItemsPerRow[numPathTypes]
);
}