/** * * rct2: 0x0066DF32 */ void news_item_init_queue() { sint32 i; news_item_get(0)->Type = NEWS_ITEM_NULL; news_item_get(11)->Type = NEWS_ITEM_NULL; // Throttles for warning types (PEEP_*_WARNING) for (i = 0; i < 16; i++) { gPeepWarningThrottle[i] = 0; } window_game_bottom_toolbar_invalidate_news_item(); }
static void news_item_shift_history_up() { const sint32 history_idx = 11; NewsItem *history_start = news_item_get(history_idx); const size_t count = sizeof(NewsItem) * (MAX_NEWS_ITEMS - 1 - history_idx); memmove(history_start, history_start + 1, count); }
static void news_item_tick_current() { sint32 ticks; ticks = ++news_item_get(0)->Ticks; // Only play news item sound when in normal playing mode if (ticks == 1 && (gScreenFlags == SCREEN_FLAGS_PLAYING)) { // Play sound audio_play_sound(SOUND_NEWS_ITEM, 0, context_get_width() / 2); } }
static bool news_item_is_current_old() { sint32 remove_time = 320; if (!news_item_is_empty(5) && !news_item_is_empty(4) && !news_item_is_empty(3) && !news_item_is_empty(2)) remove_time = 256; if (news_item_get(0)->Ticks >= remove_time) return true; return false; }
/** * * rct2: 0x0066EA5C */ static void window_news_scrollmousedown(rct_window *w, int scrollIndex, int x, int y) { int i, buttonIndex; buttonIndex = 0; for (i = 11; i < 61; i++) { if (news_item_is_empty(i)) break; if (y < 42) { rct_news_item * const newsItem = news_item_get(i); if (newsItem->flags & 1) { buttonIndex = 0; break; } else if (y < 14) { buttonIndex = 0; break; } else if (y >= 38) { buttonIndex = 0; break; } else if (x < 328) { buttonIndex = 0; break; } else if (x < 351) { if (RCT2_ADDRESS(0x0097BE7C, uint8)[newsItem->type] & 2) { buttonIndex = 1; break; } } else if (x < 376) { if (RCT2_ADDRESS(0x0097BE7C, uint8)[newsItem->type] & 1) { buttonIndex = 2; break; } } } y -= 42; } 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_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); } }
/** * * 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: 0x0066EAB8 */ static void window_news_update(rct_window *w) { sint32 i, j, x, y, z; if (w->news.var_480 == -1 || --w->news.var_484 != 0) { return; } window_invalidate(w); audio_play_sound(SOUND_CLICK_2, 0, w->x + (w->width / 2)); j = w->news.var_480; w->news.var_480 = -1; for (i = 11; i < 61; i++) { if (news_item_is_empty(i)) return; if (j == 0) { NewsItem * const newsItem = news_item_get(i); if (newsItem->Flags & NEWS_FLAG_HAS_BUTTON) return; if (w->news.var_482 == 1) { news_item_open_subject(newsItem->Type, newsItem->Assoc); return; } else if (w->news.var_482 > 1) { news_item_get_subject_location(newsItem->Type, newsItem->Assoc, &x, &y, &z); if (x != LOCATION_NULL && (w = window_get_main()) != nullptr) { window_scroll_to_location(w, x, y, z); } return; } } j--; } }
/** * * rct2: 0x0066EAB8 */ static void window_news_update(rct_window *w) { int i, j, x, y, z; if (w->news.var_480 == -1) return; if (--w->news.var_484 != 0) return; window_invalidate(w); audio_play_sound_panned(SOUND_CLICK_2, w->x + (w->width / 2), 0, 0, 0); j = w->news.var_480; w->news.var_480 = -1; for (i = 11; i < 61; i++) { if (news_item_is_empty(i)) return; if (j == 0) { rct_news_item * const newsItem = news_item_get(i); if (newsItem->flags & 1) return; if (w->news.var_482 == 1) { news_item_open_subject(newsItem->type, newsItem->assoc); return; } else if (w->news.var_482 > 1) { news_item_get_subject_location(newsItem->type, newsItem->assoc, &x, &y, &z); if (x != SPRITE_LOCATION_NULL) if ((w = window_get_main()) != NULL) window_scroll_to_location(w, x, y, z); return; } } j--; } }
bool news_item_is_empty(sint32 index) { return news_item_get(index)->Type == NEWS_ITEM_NULL; }
/** * * 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; } }
/** * * 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; } }