/** * * rct2: 0x0066EA3C */ static void window_news_scrollgetsize(rct_window *w, sint32 scrollIndex, sint32 *width, sint32 *height) { sint32 itemHeight = window_news_get_item_height(); *height = 0; for (sint32 i = 11; i < 61; i++) { if (news_item_is_empty(i)) break; *height += itemHeight; } }
/** * * rct2: 0x0066EA3C */ static void window_news_scrollgetsize(rct_window* w, int32_t scrollIndex, int32_t* width, int32_t* height) { int32_t itemHeight = window_news_get_item_height(); *height = 0; for (int32_t i = 11; i < 61; i++) { if (news_item_is_empty(i)) break; *height += itemHeight; } }
/** * * rct2: 0x0066EA5C */ static void window_news_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32 x, sint32 y) { sint32 itemHeight = window_news_get_item_height(); sint32 i, buttonIndex; buttonIndex = 0; for (i = 11; i < 61; i++) { if (news_item_is_empty(i)) break; if (y < itemHeight) { NewsItem * const newsItem = news_item_get(i); if (newsItem->Flags & NEWS_FLAG_HAS_BUTTON || y < 14 || y >= 38 || x < 328) { buttonIndex = 0; break; } else if (x < 351 && news_type_properties[newsItem->Type] & NEWS_TYPE_HAS_SUBJECT) { buttonIndex = 1; break; } else if (x < 376 && news_type_properties[newsItem->Type] & NEWS_TYPE_HAS_LOCATION) { buttonIndex = 2; break; } } y -= itemHeight; } if (buttonIndex != 0) { w->news.var_480 = i - 11; w->news.var_482 = buttonIndex; w->news.var_484 = 4; window_invalidate(w); audio_play_sound(SOUND_CLICK_1, 0, w->x + (w->width / 2)); } }
/** * * 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; } }