Beispiel #1
0
/**
 * Opens the window/tab for the subject of the news item
 *
 *  rct2: 0x0066EBE6
 *
 */
void news_item_open_subject(sint32 type, sint32 subject)
{
    rct_peep* peep;
    rct_window* window;

    switch (type) {
    case NEWS_ITEM_RIDE:
        window_ride_main_open(subject);
        break;
    case NEWS_ITEM_PEEP_ON_RIDE:
    case NEWS_ITEM_PEEP:
        peep = GET_PEEP(subject);
        window_guest_open(peep);
        break;
    case NEWS_ITEM_MONEY:
        window_finances_open();
        break;
    case NEWS_ITEM_RESEARCH:
        if (subject >= 0x10000) {
            // Open ride list window
            window_new_ride_open();

            // Switch to right tab and scroll to ride location
            ride_list_item rideItem;
            rideItem.type = subject >> 8;
            rideItem.entry_index = subject & 0xFF;
            window_new_ride_focus(rideItem);
            break;
        }

        // Check if window is already open
        window = window_bring_to_front_by_class(WC_SCENERY);
        if (window == NULL) {
            window = window_find_by_class(WC_TOP_TOOLBAR);
            if (window != NULL) {
                window_invalidate(window);
                if (!tool_set(window, WC_TOP_TOOLBAR__WIDX_SCENERY, TOOL_ARROW)) {
                    input_set_flag(INPUT_FLAG_6, true);
                    window_scenery_open();
                }
            }
        }

        // Switch to new scenery tab
        window = window_find_by_class(WC_SCENERY);
        if (window != NULL)
            window_event_mouse_down_call(window, WC_SCENERY__WIDX_SCENERY_TAB_1 + subject);
        break;
    case NEWS_ITEM_PEEPS:
        window_guest_list_open_with_filter(GLFT_GUESTS_THINKING_X, subject);;
        break;
    case NEWS_ITEM_AWARD:
        window_park_awards_open();
        break;
    case NEWS_ITEM_GRAPH:
        window_park_rating_open();
        break;
    }
Beispiel #2
0
/** rct2: 0x00768A3B */
static void paint_space_rings_structure(rct_ride * ride, uint8 direction,  uint32 segment, sint32 height)
{
    rct_map_element * savedMapElement = g_currently_drawn_item;

    uint32 vehicleIndex = (segment - direction) & 0x3;

    if (ride->num_stations == 0 || vehicleIndex < ride->num_vehicles) {
        rct_ride_entry * ride_type = get_ride_entry(ride->subtype);
        rct_vehicle * vehicle = NULL;

        sint32 frameNum = direction;

        uint32 baseImageId = ride_type->vehicles[0].base_image_id;

        if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK
            && ride->vehicles[0] != SPRITE_INDEX_NULL) {
            gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_SPRITE;
            vehicle = GET_VEHICLE(ride->vehicles[vehicleIndex]);
            g_currently_drawn_item = vehicle;
            frameNum += (sint8) vehicle->vehicle_sprite_type * 4;
        }

        uint32 imageColourFlags = gTrackColours[SCHEME_MISC];
        if ((ride->colour_scheme_type & 3) != RIDE_COLOUR_SCHEME_DIFFERENT_PER_TRAIN) {
            vehicleIndex = 0;
        }

        if (imageColourFlags == IMAGE_TYPE_REMAP) {
            imageColourFlags = SPRITE_ID_PALETTE_COLOUR_2(ride->vehicle_colours[vehicleIndex].body_colour, ride->vehicle_colours[0].trim_colour);
        }

        uint32 imageId = (baseImageId + frameNum) | imageColourFlags;
        sub_98197C(imageId, 0, 0, 20, 20, 23, height, -10, -10, height, get_current_rotation());

        if (vehicle != NULL && vehicle->num_peeps > 0) {
            rct_peep * rider = GET_PEEP(vehicle->peep[0]);
            imageColourFlags = SPRITE_ID_PALETTE_COLOUR_2(rider->tshirt_colour, rider->trousers_colour);
            imageId = ((baseImageId & 0x7FFFF) + 352 + frameNum) | imageColourFlags;
            sub_98199C(imageId, 0, 0, 20, 20, 23, height, -10, -10, height, get_current_rotation());
        }
    }

    g_currently_drawn_item = savedMapElement;
    gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE;
}
Beispiel #3
0
/**
 * Get the (x,y,z) coordinates of the subject of a news item.
 * If the new item is no longer valid, return SPRITE_LOCATION_NULL in the x-coordinate
 *
 *  rct2: 0x0066BA74
 */
void news_item_get_subject_location(sint32 type, sint32 subject, sint32 *x, sint32 *y, sint32 *z)
{
    sint32 i;
    rct_ride *ride;
    rct_peep *peep;
    rct_vehicle *vehicle;

    switch (type) {
    case NEWS_ITEM_RIDE:
        ride = get_ride(subject);
        if (ride->overall_view.xy == RCT_XY8_UNDEFINED) {
            *x = SPRITE_LOCATION_NULL;
            break;
        }
        *x = ride->overall_view.x * 32 + 16;
        *y = ride->overall_view.y * 32 + 16;
        *z = map_element_height(*x, *y);
        break;
    case NEWS_ITEM_PEEP_ON_RIDE:
        peep = GET_PEEP(subject);
        *x = peep->x;
        *y = peep->y;
        *z = peep->z;
        if (*x != SPRITE_LOCATION_NULL)
            break;

        if (peep->state != 3 && peep->state != 7) {
            *x = SPRITE_LOCATION_NULL;
            break;
        }

        // Find which ride peep is on
        ride = get_ride(peep->current_ride);
        if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK)) {
            *x = SPRITE_LOCATION_NULL;
            break;
        }

        // Find the first car of the train peep is on
        vehicle = &(get_sprite(ride->vehicles[peep->current_train])->vehicle);
        // Find the actual car peep is on
        for (i = 0; i < peep->current_car; i++)
            vehicle = &(get_sprite(vehicle->next_vehicle_on_train)->vehicle);
        *x = vehicle->x;
        *y = vehicle->y;
        *z = vehicle->z;
        break;
    case NEWS_ITEM_PEEP:
        peep = GET_PEEP(subject);
        *x = peep->x;
        *y = peep->y;
        *z = peep->z;
        break;
    case NEWS_ITEM_BLANK:
        *x = subject;
        *y = subject >> 16;
        *z = map_element_height(*x, *y);
         break;
    default:
        *x = SPRITE_LOCATION_NULL;
        break;
    }
}
Beispiel #4
0
/**
 *
 *  rct2: 0x0066E4EE
 */
static void window_news_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint32 scrollIndex)
{
    sint32 lineHeight = font_get_line_height(gCurrentFontSpriteBase);
    sint32 itemHeight = window_news_get_item_height();
    sint32 i, x, y, yy, press;

    y = 0;
    for (i = 11; i < 61; i++)
    {
        NewsItem * const newsItem = news_item_get(i);
        if (news_item_is_empty(i))
            break;
        if (y >= dpi->y + dpi->height)
            break;
        if (y + itemHeight < dpi->y)
        {
            y += itemHeight;
            continue;
        }

        // Background
        gfx_fill_rect_inset(dpi, -1, y, 383, y + itemHeight - 1, w->colours[1], (INSET_RECT_FLAG_BORDER_INSET | INSET_RECT_FLAG_FILL_GREY));

        // Date text
        set_format_arg(0, rct_string_id, DateDayNames[newsItem->Day - 1]);
        set_format_arg(2, rct_string_id, DateGameMonthNames[date_get_month(newsItem->MonthYear)]);
        gfx_draw_string_left(dpi, STR_NEWS_DATE_FORMAT, gCommonFormatArgs, COLOUR_WHITE, 2, y);

        // Item text
        utf8 *text = newsItem->Text;
        gfx_draw_string_left_wrapped(dpi, &text, 2, y + lineHeight, 325, STR_BOTTOM_TOOLBAR_NEWS_TEXT, COLOUR_BRIGHT_GREEN);

        // Subject button
        if ((news_type_properties[newsItem->Type] & NEWS_TYPE_HAS_SUBJECT) && !(newsItem->Flags & NEWS_FLAG_HAS_BUTTON))
        {
            x = 328;
            yy = y + lineHeight + 4;

            press = 0;
            if (w->news.var_480 != -1) {
                const uint8 idx = 11 + w->news.var_480;
                news_item_is_valid_idx(idx);
                if (i == idx && w->news.var_482 == 1)
                    press = INSET_RECT_FLAG_BORDER_INSET;
            }
            gfx_fill_rect_inset(dpi, x, yy, x + 23, yy + 23, w->colours[2], press);

            switch (newsItem->Type) {
            case NEWS_ITEM_RIDE:
                gfx_draw_sprite(dpi, SPR_RIDE, x, yy, 0);
                break;
            case NEWS_ITEM_PEEP:
            case NEWS_ITEM_PEEP_ON_RIDE:
            {
                rct_drawpixelinfo cliped_dpi;
                if (!clip_drawpixelinfo(&cliped_dpi, dpi, x + 1, yy + 1, 22, 22)) {
                    break;
                }

                rct_peep* peep = GET_PEEP(newsItem->Assoc);
                sint32 clip_x = 10, clip_y = 19;

                // If normal peep set sprite to normal (no food)
                // If staff set sprite to staff sprite
                sint32 sprite_type = 0;
                if (peep->type == PEEP_TYPE_STAFF){
                    sprite_type = peep->sprite_type;
                    if (peep->staff_type == STAFF_TYPE_ENTERTAINER){
                        clip_y += 3;
                    }
                }

                uint32 image_id = g_peep_animation_entries[sprite_type].sprite_animation->base_image;
                image_id += 0xA0000001;
                image_id |= (peep->tshirt_colour << 19) | (peep->trousers_colour << 24);

                gfx_draw_sprite(&cliped_dpi, image_id, clip_x, clip_y, 0);
                break;
            }
            case NEWS_ITEM_MONEY:
                gfx_draw_sprite(dpi, SPR_FINANCE, x, yy, 0);
                break;
            case NEWS_ITEM_RESEARCH:
                gfx_draw_sprite(dpi, newsItem->Assoc < 0x10000 ? SPR_NEW_SCENERY : SPR_NEW_RIDE, x, yy, 0);
                break;
            case NEWS_ITEM_PEEPS:
                gfx_draw_sprite(dpi, SPR_GUESTS, x, yy, 0);
                break;
            case NEWS_ITEM_AWARD:
                gfx_draw_sprite(dpi, SPR_AWARD, x, yy, 0);
                break;
            case NEWS_ITEM_GRAPH:
                gfx_draw_sprite(dpi, SPR_GRAPH, x, yy, 0);
                break;
            }
        }

        // Location button
        if ((news_type_properties[newsItem->Type] & NEWS_TYPE_HAS_LOCATION) && !(newsItem->Flags & NEWS_FLAG_HAS_BUTTON))
        {
            x = 352;
            yy = y + lineHeight + 4;

            press = 0;
            if (w->news.var_480 != -1) {
                const uint8 idx = 11 + w->news.var_480;
                news_item_is_valid_idx(idx);
                if (i == idx && w->news.var_482 == 2)
                    press = 0x20;
            }
            gfx_fill_rect_inset(dpi, x, yy, x + 23, yy + 23, w->colours[2], press);
            gfx_draw_sprite(dpi, SPR_LOCATE, x, yy, 0);
        }

        y += itemHeight;
    }
}
Beispiel #5
0
/**
 *
 *  rct2: 0x0066E4EE
 */
static void window_news_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrollIndex)
{
	int i, x, y, yy, press;

	y = 0;
	for (i = 11; i < 61; i++) {
		rct_news_item * const newsItem = news_item_get(i);
		if (news_item_is_empty(i))
			break;
		if (y >= dpi->y + dpi->height)
			break;
		if (y + 42 < dpi->y) {
			y += 42;
			continue;
		}

		// Background
		gfx_fill_rect_inset(dpi, -1, y, 383, y + 41, w->colours[1], 0x24);

		// Date text
		RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = STR_DATE_DAY_1 + newsItem->day - 1;
		RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, uint16) = STR_MONTH_MARCH + (newsItem->month_year % 8);
		gfx_draw_string_left(dpi, 2235, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 2, 4, y);

		// Item text
		utf8 buffer[400];
		utf8 *ch = buffer;
		ch = utf8_write_codepoint(ch, FORMAT_SMALLFONT);
		memcpy(ch, newsItem->text, 256);
		ch = buffer;
		gfx_draw_string_left_wrapped(dpi, &ch, 2, y + 10, 325, 1170, 14);

		// Subject button
		if ((RCT2_ADDRESS(0x0097BE7C, uint8)[newsItem->type] & 2) && !(newsItem->flags & 1)) {
			x = 328;
			yy = y + 14;

			press = 0;
			if (w->news.var_480 != -1) {
				const uint8 idx = 11 + w->news.var_480;
				news_item_is_valid_idx(idx);
				if (i == idx && w->news.var_482 == 1)
					press = 0x20;
			}
			gfx_fill_rect_inset(dpi, x, yy, x + 23, yy + 23, w->colours[2], press);

			switch (newsItem->type) {
			case NEWS_ITEM_RIDE:
				gfx_draw_sprite(dpi, SPR_RIDE, x, yy, 0);
				break;
			case NEWS_ITEM_PEEP:
			case NEWS_ITEM_PEEP_ON_RIDE:
			{
				rct_drawpixelinfo cliped_dpi;
				if (!clip_drawpixelinfo(&cliped_dpi, dpi, x + 1, yy + 1, 22, 22)) {
					break;
				}

				rct_peep* peep = GET_PEEP(newsItem->assoc);
				int clip_x = 10, clip_y = 19;

				// If normal peep set sprite to normal (no food)
				// If staff set sprite to staff sprite
				int sprite_type = 0;
				if (peep->type == PEEP_TYPE_STAFF){
					sprite_type = peep->sprite_type;
					if (peep->staff_type == STAFF_TYPE_ENTERTAINER){
						clip_y += 3;
					}
				}

				uint32 image_id = g_sprite_entries[sprite_type].sprite_image->base_image;
				image_id += 0xA0000001;
				image_id |= (peep->tshirt_colour << 19) | (peep->trousers_colour << 24);

				gfx_draw_sprite(&cliped_dpi, image_id, clip_x, clip_y, 0);
				break;
			}
			case NEWS_ITEM_MONEY:
				gfx_draw_sprite(dpi, SPR_FINANCE, x, yy, 0);
				break;
			case NEWS_ITEM_RESEARCH:
				gfx_draw_sprite(dpi, newsItem->assoc < 0x10000 ? SPR_NEW_RIDE : SPR_SCENERY, x, yy, 0);
				break;
			case NEWS_ITEM_PEEPS:
				gfx_draw_sprite(dpi, SPR_GUESTS, x, yy, 0);
				break;
			case NEWS_ITEM_AWARD:
				gfx_draw_sprite(dpi, SPR_AWARD, x, yy, 0);
				break;
			case NEWS_ITEM_GRAPH:
				gfx_draw_sprite(dpi, SPR_GRAPH, x, yy, 0);
				break;
			}
		}

		// Location button
		if ((RCT2_ADDRESS(0x0097BE7C, uint8)[newsItem->type] & 1) && !(newsItem->flags & 1)) {
			x = 352;
			yy = y + 14;

			press = 0;
			if (w->news.var_480 != -1) {
				const uint8 idx = 11 + w->news.var_480;
				news_item_is_valid_idx(idx);
				if (i == idx && w->news.var_482 == 2)
					press = 0x20;
			}
			gfx_fill_rect_inset(dpi, x, yy, x + 23, yy + 23, w->colours[2], press);
			gfx_draw_sprite(dpi, SPR_LOCATE, x, yy, 0);
		}

		y += 42;
	}
}