static void widget_hscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, sint32 l, sint32 t, sint32 r, sint32 b, sint32 colour) { colour &= 0x7F; // Trough gfx_fill_rect(dpi, l + 10, t, r - 10, b, ColourMapA[colour].lighter); gfx_fill_rect(dpi, l + 10, t, r - 10, b, 0x1000000 | ColourMapA[colour].mid_dark); gfx_fill_rect(dpi, l + 10, t + 2, r - 10, t + 2, ColourMapA[colour].mid_dark); gfx_fill_rect(dpi, l + 10, t + 3, r - 10, t + 3, ColourMapA[colour].lighter); gfx_fill_rect(dpi, l + 10, t + 7, r - 10, t + 7, ColourMapA[colour].mid_dark); gfx_fill_rect(dpi, l + 10, t + 8, r - 10, t + 8, ColourMapA[colour].lighter); // Left button gfx_fill_rect_inset(dpi, l, t, l + 9, b, colour, ((scroll->flags & HSCROLLBAR_LEFT_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0)); gfx_draw_string(dpi, (char*)BlackLeftArrowString, COLOUR_BLACK, l + 1, t); // Thumb gfx_fill_rect_inset(dpi, max(l + 10, l + scroll->h_thumb_left - 1), t, min(r - 10, l + scroll->h_thumb_right - 1), b, colour, ((scroll->flags & HSCROLLBAR_THUMB_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0)); // Right button gfx_fill_rect_inset(dpi, r - 9, t, r, b, colour, ((scroll->flags & HSCROLLBAR_RIGHT_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0)); gfx_draw_string(dpi, (char*)BlackRightArrowString, COLOUR_BLACK, r - 6, t); }
// This method is the same as gfx_draw_string_left_wrapped. // But this adjusts the initial Y coordinate depending of the number of lines. int32_t chat_history_draw_string(rct_drawpixelinfo* dpi, void* args, int32_t x, int32_t y, int32_t width) { int32_t fontSpriteBase, lineHeight, lineY, numLines; gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM; gfx_draw_string(dpi, (char*)"", TEXT_COLOUR_255, dpi->x, dpi->y); char* buffer = gCommonStringFormatBuffer; format_string(buffer, 256, STR_STRING, args); gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM; gfx_wrap_string(buffer, width, &numLines, &fontSpriteBase); lineHeight = font_get_line_height(fontSpriteBase); gCurrentFontFlags = 0; int32_t expectedY = y - (numLines * lineHeight); if (expectedY < 50) { return (numLines * lineHeight); // Skip drawing, return total height. } lineY = y; for (int32_t line = 0; line <= numLines; ++line) { gfx_draw_string(dpi, buffer, TEXT_COLOUR_254, x, lineY - (numLines * lineHeight)); buffer = get_string_end(buffer) + 1; lineY += lineHeight; } return lineY - y; }
static void widget_vscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, sint32 l, sint32 t, sint32 r, sint32 b, sint32 colour) { colour &= 0x7F; // Trough gfx_fill_rect(dpi, l, t + 10, r, b - 10, ColourMapA[colour].lighter); gfx_fill_rect(dpi, l, t + 10, r, b - 10, 0x1000000 | ColourMapA[colour].mid_dark); gfx_fill_rect(dpi, l + 2, t + 10, l + 2, b - 10, ColourMapA[colour].mid_dark); gfx_fill_rect(dpi, l + 3, t + 10, l + 3, b - 10, ColourMapA[colour].lighter); gfx_fill_rect(dpi, l + 7, t + 10, l + 7, b - 10, ColourMapA[colour].mid_dark); gfx_fill_rect(dpi, l + 8, t + 10, l + 8, b - 10, ColourMapA[colour].lighter); // Up button gfx_fill_rect_inset(dpi, l, t, r, t + 9, colour, ((scroll->flags & VSCROLLBAR_UP_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0)); gfx_draw_string(dpi, (char*)BlackUpArrowString, COLOUR_BLACK, l + 1, t - 1); // Thumb gfx_fill_rect_inset(dpi, l, max(t + 10, t + scroll->v_thumb_top - 1), r, min(b - 10, t + scroll->v_thumb_bottom - 1), colour, ((scroll->flags & VSCROLLBAR_THUMB_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0)); // Down button gfx_fill_rect_inset(dpi, l, b - 9, r, b, colour, ((scroll->flags & VSCROLLBAR_DOWN_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0)); gfx_draw_string(dpi, (char*)BlackDownArrowString, COLOUR_BLACK, l + 1, b - 9); }
void notmain() { led_init(); gpio_init(); gfx_init(); unsigned int index = 0; char line[60]; line[0] = 0; gpio_set_input(GPIO_PIN23); gpio_set_input(GPIO_PIN24); gpio_set_pullup(GPIO_PIN23); gpio_set_pullup(GPIO_PIN24); // while (1) {} while (1) { wait_for_clock(); line[index] = '+'; line[++index] = 0; gfx_clear(); gfx_draw_string(0xFFFFFFFF, 20, 20, "Button pushes: "); gfx_draw_string(0xFFFFFFFF, 210, 20, line); gfx_draw(); } while (1) { unsigned char ch = 0; int pinval; wait_for_clock(); pinval = gpio_pin_read(GPIO_PIN24); if (pinval != 0) { //continue; } int i; for (i = 0; i < 8; i++) { wait_for_clock(); ch |= gpio_pin_read(GPIO_PIN24) << i; } wait_for_clock(); wait_for_clock(); ch = 'z'; //lookup_table[ch]; if (index < LINE_SIZE) { line[index] = ch; line[index++] = 0; } gfx_clear(); gfx_draw_string(0xFFFFFFFF, 20, 20, line); gfx_draw(); } }
void gfx_draw_display_measure() { char valueBuffer[20]; char suffix[5]; // draw read current if (readCurrentMilliampsDisplay == DISPLAY_MILLI) { if (readCurrentMilliamps >= 1000) { readCurrentMilliampsDisplay = DISPLAY_2DECIMALS; } } else { if (readCurrentMilliamps < 800) { readCurrentMilliampsDisplay = DISPLAY_MILLI; } } milli_to_string(readCurrentMilliamps, valueBuffer, readCurrentMilliampsDisplay); if (readCurrentMilliampsDisplay == DISPLAY_MILLI) { strcpy(suffix, "mA"); } else { strcpy(suffix, " A"); } gfx_draw_string(valueBuffer, &FONT_LARGE, 110, 0, GFX_ALIGN_RIGHT); gfx_draw_string(suffix, &FONT_XSMALL, 110, 14, GFX_ALIGN_LEFT); // draw set current if (setCurrentMilliamps < 1000) { milli_to_string(setCurrentMilliamps, valueBuffer, DISPLAY_MILLI); strcpy(suffix, "mA"); } else { milli_to_string(setCurrentMilliamps, valueBuffer, DISPLAY_2DECIMALS); strcpy(suffix, "A"); } gfx_draw_string("SET", &FONT_XSMALL, 2, 2, GFX_ALIGN_LEFT); gfx_draw_string(valueBuffer, &FONT_SMALL_NUMBERS, 30, 11, GFX_ALIGN_RIGHT); gfx_draw_string(suffix, &FONT_XSMALL, 30, 14, GFX_ALIGN_LEFT); // draw read volts milli_to_string(readMilliVolts, valueBuffer, DISPLAY_2DECIMALS); gfx_draw_string(valueBuffer, &FONT_LARGE, 110, 28, GFX_ALIGN_RIGHT); gfx_draw_string("V", &FONT_XSMALL, 110, 42, GFX_ALIGN_LEFT); // draw watts uint16_t milliwatts = readMilliVolts * readCurrentMilliamps / 1000; if (milliwatts < 1000) { milli_to_string(milliwatts, valueBuffer, DISPLAY_MILLI); strcpy(suffix, "mW"); } else { milli_to_string(milliwatts, valueBuffer, DISPLAY_1DECIMALS); strcpy(suffix, " W"); } gfx_draw_string(valueBuffer, &FONT_SMALL_NUMBERS, 25, 30, GFX_ALIGN_RIGHT); gfx_draw_string(suffix, &FONT_XSMALL, 25, 42, GFX_ALIGN_RIGHT); gfx_draw_menu(recorder_is_recording() ? "*REC" : "REC", NULL, NULL, "INFO"); }
void gfx_draw_display_record() { char valueBuffer[20]; // Records gfx_draw_string("Records: ", &FONT_XSMALL, 0, 0, GFX_ALIGN_LEFT); itoa(recorder_count(), valueBuffer, 10); gfx_draw_string(valueBuffer, &FONT_XSMALL, 5, 12, GFX_ALIGN_LEFT); // Rate gfx_draw_string("Rate: ", &FONT_XSMALL, 0, 24, GFX_ALIGN_LEFT); format_rate(recorder_is_recording() ? recorder_rate() : SET_RATES[CLAMP(setRateIndex, 0, MAX_SET_RATE_INDEX)], valueBuffer); gfx_draw_string(valueBuffer, &FONT_XSMALL, 5, 36, GFX_ALIGN_LEFT); gfx_draw_menu(recorder_is_recording() ? "STOP" : "START", NULL, NULL, "EXIT"); }
static void window_changelog_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrollIndex) { uint16 *currentFontFlags = RCT2_ADDRESS(RCT2_ADDRESS_CURRENT_FONT_FLAGS, uint16); sint16 *currentFontSpriteBase = RCT2_ADDRESS(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, sint16); *currentFontFlags = 0; *currentFontSpriteBase = 224; gfx_draw_string(dpi, (char*)0x009C383D, 1, dpi->x, dpi->y); int x = 3; int y = 3; for (int i = 0; i < _changelogNumLines; i++) { gfx_draw_string(dpi, _changelogLines[i], 254, x, y); y += 11; } }
void gfx_draw_menu(const char* menuA, const char* menuB, const char* menuC, const char* menuD) { gfx_fill_rect(0, GFX_HEIGHT - GFX_MENU_HEIGHT, GFX_WIDTH, GFX_MENU_HEIGHT, GFX_COLOR_BLACK); if (menuA) { gfx_draw_string(menuA, &FONT_XSMALL, 15, 54, GFX_ALIGN_CENTER); } if (menuB) { gfx_draw_string(menuB, &FONT_XSMALL, 48, 54, GFX_ALIGN_CENTER); } if (menuC) { gfx_draw_string(menuC, &FONT_XSMALL, 77, 54, GFX_ALIGN_CENTER); } if (menuD) { gfx_draw_string(menuD, &FONT_XSMALL, 110, 54, GFX_ALIGN_CENTER); } }
/** * * rct2: 0x006EBAD9 */ static void widget_checkbox_draw(rct_drawpixelinfo *dpi, rct_window *w, rct_widgetindex widgetIndex) { // Get the widget rct_widget *widget = &w->widgets[widgetIndex]; // Resolve the absolute ltb sint32 l = w->x + widget->left; sint32 t = w->y + widget->top; sint32 b = w->y + widget->bottom; sint32 yMid = (b + t) / 2; // Get the colour uint8 colour = w->colours[widget->colour]; if (widget->type != WWT_24) { // checkbox gfx_fill_rect_inset(dpi, l, yMid - 5, l + 9, yMid + 4, colour, INSET_RECT_F_60); // fill it when checkbox is pressed if (widget_is_pressed(w, widgetIndex)) { gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM; gfx_draw_string(dpi, (char*)CheckBoxMarkString, NOT_TRANSLUCENT(colour), l, yMid - 5); } } // draw the text if (widget->text == STR_NONE) return; if (widget_is_disabled(w, widgetIndex)) { colour |= COLOUR_FLAG_INSET; } gfx_draw_string_left_centred(dpi, widget->text, gCommonFormatArgs, colour, l + 14, yMid); }
/** * \brief Draw square around a finger * * This function draws an unfilled square around the specified finger. * * \param draw_finger Pointer to finger struct * \param color Color to draw with */ static void draw_finger_square(const struct finger *draw_finger, const gfx_color_t color) { gfx_coord_t upper_x, upper_y; uint8_t square_size = MIN_SQUARE_SIZE; #ifdef ENABLE_TOUCH_SIZE_DISPLAY /* Increase the size of the touch square based on the touch size */ square_size += draw_finger->size; #endif /* Calculate upper-left X/Y coordinates for the touch bounding box */ upper_x = draw_finger->x - (square_size / 2); upper_y = draw_finger->y - (square_size / 2); #ifdef ENABLE_COORDINATE_DISPLAY char str_buffer[10]; gfx_coord_t str_width, str_height; /* Print the formatted touch coordinates into the temporary buffer */ sprintf(str_buffer, "%03d, %03d", draw_finger->x, draw_finger->y); /* Calculate the bounding box of the coordinate text on the display */ gfx_get_string_bounding_box(str_buffer, &sysfont, &str_width, &str_height); /* Write touch coordinates to the display above the finger touch box */ gfx_draw_string(str_buffer, upper_x + ((square_size - str_width) / 2), upper_y - (str_height + 1), &sysfont, GFX_COLOR_TRANSPARENT, color); #endif /* Draw a box around the touch point */ gfx_generic_draw_rect(upper_x, upper_y, square_size, square_size, color); }
static void window_loadsave_paint(rct_window *w, rct_drawpixelinfo *dpi) { window_draw_widgets(w, dpi); if (_shortenedDirectory[0] == '\0') { shorten_path(_shortenedDirectory, sizeof(_shortenedDirectory), _directory, w->width - 8); } utf8 buffer[256]; // Format text utf8 *ch = buffer; ch = utf8_write_codepoint(ch, FORMAT_MEDIUMFONT); ch = utf8_write_codepoint(ch, FORMAT_BLACK); safe_strcpy(ch, _shortenedDirectory, sizeof(buffer) - (ch - buffer)); // Draw shadow gfx_draw_string(dpi, buffer, 0, w->x + 4, w->y + 20); rct_string_id id = STR_NONE; // Name button text if (gConfigGeneral.load_save_sort == SORT_NAME_ASCENDING) id = STR_UP; else if (gConfigGeneral.load_save_sort == SORT_NAME_DESCENDING) id = STR_DOWN; gfx_draw_string_centred_clipped(dpi, STR_NAME, &id, 1, w->x + 4 + (w->width - 8) / 4, w->y + 50, (w->width - 8) / 2); // Date button text if (gConfigGeneral.load_save_sort == SORT_DATE_ASCENDING) id = STR_UP; else if (gConfigGeneral.load_save_sort == SORT_DATE_DESCENDING) id = STR_DOWN; else id = STR_NONE; gfx_draw_string_centred_clipped(dpi, STR_DATE, &id, 1, w->x + 4 + (w->width - 8) * 3 / 4, w->y + 50, (w->width - 8) / 2); }
/** * * rct2: 0x006EBAD9 */ static void widget_checkbox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) { rct_widget* widget; int l, t, b; uint8 colour; // Get the widget widget = &w->widgets[widgetIndex]; // Resolve the absolute ltb l = w->x + widget->left; t = w->y + widget->top; b = w->y + widget->bottom; // Get the colour colour = w->colours[widget->colour]; // checkbox gfx_fill_rect_inset(dpi, l, t, l + 9, b - 1, colour, 0x60); // fill it when checkbox is pressed if (widget_is_pressed(w, widgetIndex)) { RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; gfx_draw_string(dpi, (char*)0x009DED72, colour & 0x7F, l, t); } // draw the text if (widget->image == -1) return; if (widget_is_disabled(w, widgetIndex)) { colour |= 0x40; } gfx_draw_string_left(dpi, widget->image, (char*)0x013CE952, colour, l + 14, t); }
static void window_player_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scrollIndex) { int y; gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width - 1, dpi->y + dpi->height - 1, ColourMapA[w->colours[1]].mid_light); y = 0; for (int i = 0; i < network_get_num_players(); i++) { if (y > dpi->y + dpi->height) { break; } if (y + 11 >= dpi->y) { char buffer[300]; char* lineCh = buffer; int colour = 0; if (i == w->selected_list_item) { gfx_fill_rect(dpi, 0, y, 800, y + 9, 0x02000031); safe_strncpy(&buffer[0], network_get_player_name(i), sizeof(buffer)); colour = w->colours[2]; } else { if (network_get_player_flags(i) & NETWORK_PLAYER_FLAG_ISSERVER) { lineCh = utf8_write_codepoint(lineCh, FORMAT_BABYBLUE); } else { lineCh = utf8_write_codepoint(lineCh, FORMAT_BLACK); } safe_strncpy(lineCh, network_get_player_name(i), sizeof(buffer) - (lineCh - buffer)); } gfx_clip_string(buffer, 230); gfx_draw_string(dpi, buffer, colour, 0, y - 1); lineCh = buffer; int ping = network_get_player_ping(i); if (ping <= 100) { lineCh = utf8_write_codepoint(lineCh, FORMAT_GREEN); } else if (ping <= 250) { lineCh = utf8_write_codepoint(lineCh, FORMAT_YELLOW); } else { lineCh = utf8_write_codepoint(lineCh, FORMAT_RED); } sprintf(lineCh, "%d ms", ping); gfx_draw_string(dpi, buffer, colour, 240, y - 1); } y += 10; } }
/** * Draws i formatted text string. * rct2: 0x006C1B2F * dpi (edi) * format (bx) * args (esi) * colour (al) * x (cx) * y (dx) */ void gfx_draw_string_left(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y) { char* buffer; buffer = (char*)0x0141ED68; format_string(buffer, format, args); gfx_draw_string(dpi, buffer, colour, x, y); }
/** * * rct2: 0x006BD785 */ void window_themes_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint32 scrollIndex) { sint32 y; if (_selected_tab == WINDOW_THEMES_TAB_SETTINGS || _selected_tab == WINDOW_THEMES_TAB_FEATURES) return; if ((w->colours[1] & 0x80) == 0) //gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width - 1, dpi->y + dpi->height - 1, ColourMapA[w->colours[1]].mid_light); gfx_clear(dpi, ColourMapA[w->colours[1]].mid_light); y = 0; for (sint32 i = 0; i < get_colour_scheme_tab_count(); i++) { if (y > dpi->y + dpi->height) { break; } if (y + _row_height >= dpi->y) { if (i + 1 < get_colour_scheme_tab_count()) { sint32 colour = w->colours[1]; if (colour & COLOUR_FLAG_TRANSLUCENT) { translucent_window_palette windowPalette = TranslucentWindowPalettes[BASE_COLOUR(colour)]; gfx_filter_rect(dpi, 0, y + _row_height - 2, window_themes_widgets[WIDX_THEMES_LIST].right, y + _row_height - 2, windowPalette.highlight); gfx_filter_rect(dpi, 0, y + _row_height - 1, window_themes_widgets[WIDX_THEMES_LIST].right, y + _row_height - 1, windowPalette.shadow); } else { colour = ColourMapA[w->colours[1]].mid_dark; gfx_fill_rect(dpi, 0, y + _row_height - 2, window_themes_widgets[WIDX_THEMES_LIST].right, y + _row_height - 2, colour); colour = ColourMapA[w->colours[1]].lightest; gfx_fill_rect(dpi, 0, y + _row_height - 1, window_themes_widgets[WIDX_THEMES_LIST].right, y + _row_height - 1, colour); } } rct_windowclass wc = get_window_class_tab_index(i); sint32 numColours = theme_desc_get_num_colours(wc); for (uint8 j = 0; j < numColours; j++) { gfx_draw_string_left(dpi, theme_desc_get_name(wc), NULL, w->colours[1], 2, y + 4); uint8 colour = theme_get_colour(wc, j); uint32 image = SPRITE_ID_PALETTE_COLOUR_1(colour & ~COLOUR_FLAG_TRANSLUCENT) | IMAGE_TYPE_TRANSPARENT | SPR_PALETTE_BTN; if (i == _colour_index_1 && j == _colour_index_2) { image = SPRITE_ID_PALETTE_COLOUR_1(colour & ~COLOUR_FLAG_TRANSLUCENT) | IMAGE_TYPE_TRANSPARENT | SPR_PALETTE_BTN_PRESSED; } gfx_draw_sprite(dpi, image, _button_offset_x + 12 * j, y + _button_offset_y, 0); gfx_fill_rect_inset(dpi, _button_offset_x + 12 * j, y + _check_offset_y, _button_offset_x + 12 * j + 9, y + _check_offset_y + 10, w->colours[1], INSET_RECT_F_E0); if (colour & COLOUR_FLAG_TRANSLUCENT) { gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK; gfx_draw_string(dpi, (char*)CheckBoxMarkString, w->colours[1] & 0x7F, _button_offset_x + 12 * j, y + _check_offset_y); } } } y += _row_height; } }
void chat_draw() { if (network_get_mode() == NETWORK_MODE_NONE || network_get_status() != NETWORK_STATUS_CONNECTED || network_get_authstatus() != NETWORK_AUTH_OK) { gChatOpen = false; return; } rct_drawpixelinfo *dpi = (rct_drawpixelinfo*)RCT2_ADDRESS_SCREEN_DPI; _chatLeft = 10; _chatTop = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 40 - ((CHAT_HISTORY_SIZE + 1) * 10); _chatRight = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - 10; _chatBottom = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 45; char lineBuffer[CHAT_INPUT_SIZE + 10]; char* lineCh = lineBuffer; int x = _chatLeft; int y = _chatBottom - (15 * 2); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_FLAGS, uint16) = 0; for (int i = 0; i < CHAT_HISTORY_SIZE; i++, y -= 15) { if (!gChatOpen && SDL_TICKS_PASSED(SDL_GetTicks(), chat_history_get_time(i) + 10000)) { break; } safe_strcpy(lineBuffer, chat_history_get(i), CHAT_INPUT_SIZE + 10); gfx_set_dirty_blocks(x, y, x + gfx_get_string_width(lineBuffer), y + 12); gfx_draw_string(dpi, lineBuffer, 255, x, y); } if (gChatOpen) { lineCh = utf8_write_codepoint(lineCh, FORMAT_OUTLINE); lineCh = utf8_write_codepoint(lineCh, FORMAT_CELADON); safe_strcpy(lineCh, _chatCurrentLine, CHAT_INPUT_SIZE); y = _chatBottom - 15; gfx_set_dirty_blocks(x, y, x + gfx_get_string_width(lineBuffer) + 7, y + 12); gfx_draw_string(dpi, lineBuffer, 255, x, y); if (_chatCaretTicks < 15) { memcpy(lineBuffer, _chatCurrentLine, gTextInput.selection_offset); lineBuffer[gTextInput.selection_offset] = 0; int caretX = x + gfx_get_string_width(lineBuffer); int caretY = y + 15; gfx_fill_rect(dpi, caretX, caretY, caretX + 6, caretY + 1, 0x38); } } }
static void window_changelog_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint32 scrollIndex) { gCurrentFontFlags = 0; gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM; sint32 x = 3; sint32 y = 3; for (sint32 i = 0; i < _changelogNumLines; i++) { gfx_draw_string(dpi, _changelogLines[i], w->colours[0], x, y); y += 11; } }
static void draw_ime_composition(rct_drawpixelinfo * dpi, int cursorX, int cursorY) { int compositionWidth = gfx_get_string_width(gTextInputComposition); int x = cursorX - (compositionWidth / 2); int y = cursorY + 13; int width = compositionWidth; int height = 10; gfx_fill_rect(dpi, x - 1, y - 1, x + width + 1, y + height + 1, 12); gfx_fill_rect(dpi, x, y, x + width, y + height, 0); gfx_draw_string(dpi, gTextInputComposition, COLOUR_DARK_GREEN, x, y); }
void window_player_overview_paint(rct_window *w, rct_drawpixelinfo *dpi) { window_draw_widgets(w, dpi); window_player_draw_tab_images(dpi, w); int player = network_get_player_index((uint8)w->number); if (player == -1) { return; } // Draw current group int groupindex = network_get_group_index(network_get_player_group(player)); if (groupindex != -1) { rct_widget* widget = &window_player_overview_widgets[WIDX_GROUP]; RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = network_get_group_name_string_id(groupindex); gfx_draw_string_centred_clipped( dpi, 1193, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, w->x + (widget->left + widget->right - 11) / 2, w->y + widget->top, widget->right - widget->left - 8 ); } // Draw ping int x = w->x + 90; int y = w->y + 24; RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = STR_PING; gfx_draw_string_left(dpi, STR_WINDOW_COLOUR_2_STRING, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, x, y); char ping[64]; sprintf(ping, "%d ms", network_get_player_ping(player)); gfx_draw_string(dpi, ping, w->colours[2], x + 30, y); // Draw last action x = w->x + (w->width / 2); y = w->y + w->height - 13; int width = w->width - 8; int lastaction = network_get_player_last_action(player, 0); RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = STR_ACTION_NA; if (lastaction != -999) { RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = network_get_action_name_string_id(lastaction); } gfx_draw_string_centred_clipped(dpi, STR_LAST_ACTION_RAN, (void*)RCT2_ADDRESS_COMMON_FORMAT_ARGS, 0, x, y, width); if (w->viewport != NULL && w->var_492 != -1) { window_draw_viewport(dpi, w); } }
static void window_network_status_paint(rct_window *w, rct_drawpixelinfo *dpi) { window_draw_widgets(w, dpi); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; char buffer[sizeof(window_network_status_text) + 10]; char* lineCh = buffer; lineCh = utf8_write_codepoint(lineCh, FORMAT_BLACK); strcpy(lineCh, window_network_status_text); gfx_clip_string(buffer, 230); int x = w->x + (w->width / 2); int y = w->y + (w->height / 2); x -= gfx_get_string_width(buffer) / 2; gfx_draw_string(dpi, buffer, 0, x, y); }
/** * Draws i formatted text string right aligned. * rct2: 0x006C1BFC * dpi (edi) * format (bx) * args (esi) * colour (al) * x (cx) * y (dx) */ void gfx_draw_string_right(rct_drawpixelinfo* dpi, int format, void* args, int colour, int x, int y) { char* buffer; short text_width; buffer = (char*)0x0141ED68; format_string(buffer, format, args); // Measure text width text_width = gfx_get_string_width(buffer); // Draw the text right aligned x -= text_width; gfx_draw_string(dpi, buffer, colour, x, y); }
/** * \brief Frame draw event handler * * This function will draw the contents of the sub-frame. * * \sa wtk_basic_frame_draw_handler_t */ static void sub_frame_draw_handler(struct win_window *win, struct win_clip_region const *clip) { char buffer[4]; snprintf(buffer, sizeof(buffer), "%3d", counter); /** * \todo Add code here to draw text on screen using the * gfx_draw_string() function. */ gfx_draw_string(buffer, clip->origin.x + 30, clip->origin.y + 12, &sysfont, GFX_COLOR(255, 255, 255), GFX_COLOR_TRANSPARENT); }
static void widget_vscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, int l, int t, int r, int b, int colour) { // Trough gfx_fill_rect(dpi, l, t + 10, r, b - 10, *((char*)(0x0141FC4B + (colour * 8)))); gfx_fill_rect(dpi, l, t + 10, r, b - 10, 0x1000000 | *((char*)(0x0141FC47 + (colour * 8)))); gfx_fill_rect(dpi, l + 2, t + 10, l + 2, b - 10, *((char*)(0x0141FC47 + (colour * 8)))); gfx_fill_rect(dpi, l + 3, t + 10, l + 3, b - 10, *((char*)(0x0141FC4B + (colour * 8)))); gfx_fill_rect(dpi, l + 7, t + 10, l + 7, b - 10, *((char*)(0x0141FC47 + (colour * 8)))); gfx_fill_rect(dpi, l + 8, t + 10, l + 8, b - 10, *((char*)(0x0141FC4B + (colour * 8)))); // Up button gfx_fill_rect_inset(dpi, l, t, r, t + 9, colour, (scroll->flags & VSCROLLBAR_UP_PRESSED ? 0x20 : 0)); gfx_draw_string(dpi, (char*)0x009DED66, 0, l + 1, t - 1); // Thumb gfx_fill_rect_inset(dpi, l, max(t + 10, t + scroll->v_thumb_top - 1), r, min(b - 10, t + scroll->v_thumb_bottom - 1), colour, (scroll->flags & VSCROLLBAR_THUMB_PRESSED ? 0x20 : 0)); // Down button gfx_fill_rect_inset(dpi, l, b - 9, r, b, colour, (scroll->flags & VSCROLLBAR_DOWN_PRESSED ? 0x20 : 0)); gfx_draw_string(dpi, (char*)0x009DED69, 0, l + 1, b - 8); }
static void widget_hscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, int l, int t, int r, int b, int colour) { // Trough gfx_fill_rect(dpi, l + 10, t, r - 10, b, *((char*)(0x0141FC4B + (colour * 8)))); gfx_fill_rect(dpi, l + 10, t, r - 10, b, 0x1000000 | *((char*)(0x0141FC47 + (colour * 8)))); gfx_fill_rect(dpi, l + 10, t + 2, r - 10, t + 2, *((char*)(0x0141FC47 + (colour * 8)))); gfx_fill_rect(dpi, l + 10, t + 3, r - 10, t + 3, *((char*)(0x0141FC4B + (colour * 8)))); gfx_fill_rect(dpi, l + 10, t + 7, r - 10, t + 7, *((char*)(0x0141FC47 + (colour * 8)))); gfx_fill_rect(dpi, l + 10, t + 8, r - 10, t + 8, *((char*)(0x0141FC4B + (colour * 8)))); // Left button gfx_fill_rect_inset(dpi, l, t, l + 9, b, colour, (scroll->flags & HSCROLLBAR_LEFT_PRESSED ? 0x20 : 0)); gfx_draw_string(dpi, (char*)0x009DED6C, 0, l + 1, t); // Thumb gfx_fill_rect_inset(dpi, max(l + 10, l + scroll->h_thumb_left - 1), t, min(r - 10, r + scroll->h_thumb_right - 1), t, colour, (scroll->flags & HSCROLLBAR_THUMB_PRESSED ? 0x20 : 0)); // Right button gfx_fill_rect_inset(dpi, r - 9, t, r, b, colour, (scroll->flags & HSCROLLBAR_RIGHT_PRESSED ? 0x20 : 0)); gfx_draw_string(dpi, (char*)0x009DED6F, 0, r - 6, t); }
static void custom_currency_window_paint(rct_window *w, rct_drawpixelinfo *dpi) { sint32 x, y; set_format_arg(0, sint32, 100); window_draw_widgets(w, dpi); x = w->x + 10; y = w->y + 30; gfx_draw_string_left(dpi, STR_RATE, nullptr, w->colours[1], x, y); sint32 baseExchange = CurrencyDescriptors[CURRENCY_POUNDS].rate; set_format_arg(0, sint32, baseExchange); gfx_draw_string_left(dpi, STR_CUSTOM_CURRENCY_EQUIVALENCY, gCommonFormatArgs, w->colours[1], x + 200, y); y += 20; gfx_draw_string_left(dpi, STR_CURRENCY_SYMBOL_TEXT, nullptr, w->colours[1], x, y); gfx_draw_string( dpi, CurrencyDescriptors[CURRENCY_CUSTOM].symbol_unicode, w->colours[1], w->x + window_custom_currency_widgets[WIDX_SYMBOL_TEXT].left + 1, w->y + window_custom_currency_widgets[WIDX_SYMBOL_TEXT].top); if(CurrencyDescriptors[CURRENCY_CUSTOM].affix_unicode == CURRENCY_PREFIX) { gfx_draw_string_left( dpi, STR_PREFIX, w, w->colours[1], w->x + window_custom_currency_widgets[WIDX_AFFIX_DROPDOWN].left + 1, w->y + window_custom_currency_widgets[WIDX_AFFIX_DROPDOWN].top ); } else { gfx_draw_string_left( dpi, STR_SUFFIX, w, w->colours[1], w->x + window_custom_currency_widgets[WIDX_AFFIX_DROPDOWN].left + 1, w->y + window_custom_currency_widgets[WIDX_AFFIX_DROPDOWN].top ); } }
/** * * rct2: 0x0066B872 */ static void window_title_logo_paint() { int packs, x, y, i; char *buffer, *names; rct_window *w; rct_drawpixelinfo *dpi; window_paint_get_registers(w, dpi); gfx_draw_sprite(dpi, SPR_MENU_LOGO, w->x, w->y, 0); x = 0; y = 105; packs = RCT2_GLOBAL(RCT2_ADDRESS_EXPANSION_FLAGS, uint16); names = RCT2_ADDRESS(RCT2_ADDRESS_EXPANSION_NAMES, char); buffer = (char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER; while (packs != 0) { if (packs & 1) { // Prefix for expansion name buffer[0] = '\n'; buffer[1] = '\v'; buffer[2] = FORMAT_YELLOW; // Colour of the text buffer[3] = '+'; buffer[4] = ' '; i = 0; // Copies the expansion name to the buffer, offset by 5 do { buffer[5 + i] = names[i]; i++; } while (names[i - 1] != 0); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint32) = 0; gfx_draw_string(dpi, buffer, 0, x, y); y += 10; } packs = packs >> 1; names += 128; } }
static void window_tile_inspector_paint() { int x, y; rct_window *w; rct_drawpixelinfo *dpi; char buffer[256]; window_paint_get_registers(w, dpi); window_draw_widgets(w, dpi); x = w->x + 20; y = w->y + 25; if (window_tile_inspector_tile_x == -1) { // No tile selected gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_CHOOSE_MSG, NULL, 12, x, y); } else { sprintf( buffer, "X: %d, Y: %d", window_tile_inspector_tile_x, window_tile_inspector_tile_y ); gfx_draw_string(dpi, buffer, 12, x, y); } y += 25; draw_string_left_underline(dpi, STR_TILE_INSPECTOR_ELEMENT_TYPE, NULL, 12, x, y); draw_string_left_underline(dpi, STR_TILE_INSPECTOR_BASE_HEIGHT, NULL, 12, x + 200, y); draw_string_left_underline(dpi, STR_TILE_INSPECTOR_CLEARANGE_HEIGHT, NULL, 12, x + 280, y); draw_string_left_underline(dpi, STR_TILE_INSPECTOR_FLAGS, NULL, 12, x + 390, y); }
void gfx_draw_display_info() { char valueBuffer[20]; char* p; uint8_t i; uip_ipaddr_t addr; // MAC Addr gfx_draw_string("MAC Addr: ", &FONT_XSMALL, 0, 0 - gfxScroll, GFX_ALIGN_LEFT); p = valueBuffer; for (i = 0; i < EUI48_LENGTH; i++) { if (i > 0) { *p++ = ':'; } *p++ = TO_HEX(EUI48[i] >> 4); *p++ = TO_HEX(EUI48[i] >> 0); } *p = '\0'; gfx_draw_string(valueBuffer, &FONT_XSMALL, 5, 12 - gfxScroll, GFX_ALIGN_LEFT); // IP Address gfx_draw_string("IP Addr: ", &FONT_XSMALL, 0, 24 - gfxScroll, GFX_ALIGN_LEFT); uip_gethostaddr(&addr); valueBuffer[0] = '\0'; for (i = 0; i < 4; i++) { if (i > 0) { strcat(valueBuffer, "."); } p = valueBuffer + strlen(valueBuffer); uitoa(addr.u8[i], p, 10); } gfx_draw_string(valueBuffer, &FONT_XSMALL, 5, 36 - gfxScroll, GFX_ALIGN_LEFT); // git hash gfx_draw_string("GIT Hash: ", &FONT_XSMALL, 0, 48 - gfxScroll, GFX_ALIGN_LEFT); strncpy(valueBuffer, GIT_HASH, 7); valueBuffer[7] = '\0'; gfx_draw_string(valueBuffer, &FONT_XSMALL, 5, 60 - gfxScroll, GFX_ALIGN_LEFT); gfx_draw_menu(NULL, NULL, NULL, "EXIT"); }
static void draw_box_string(int x, int y, frame_t *frame, const char *str) { gfx_draw_string(8*x+20, y+16, 31, 1, frame, str); }
/** * This function is the window event handler for check box widgets. * It handles all events sent to the windows composing the widget. * * \param win Window receiving the event. * \param type The event type. * \param data Custom data, depending on event type. * * \return True if the event was recognized and accepted. */ static bool wtk_check_box_handler(struct win_window *win, enum win_event_type type, void const *data) { struct win_command_event command; /* Custom data for windows of a widget points back to the widget itself. */ struct wtk_check_box *check_box = (struct wtk_check_box *)win_get_custom_data(win); switch (type) { case WIN_EVENT_DRAW: { /* There should not be other windows in this widget. */ Assert(win == check_box->container); /* For DRAW events, the data parameter points to the * clipping region. */ struct win_clip_region const *clip = (struct win_clip_region const *)data; /* Draw check box square. */ gfx_draw_rect(clip->origin.x + WTK_CHECKBOX_BOX_X, clip->origin.y + WTK_CHECKBOX_BOX_Y, WTK_CHECKBOX_BOX_SIZE, WTK_CHECKBOX_BOX_SIZE, WTK_CHECKBOX_BOX_COLOR); /* Draw check box square background. */ if (WTK_CHECKBOX_BACKGROUND_COLOR != GFX_COLOR_TRANSPARENT) { gfx_draw_filled_rect(clip->origin.x + WTK_CHECKBOX_BOX_X + 1, clip->origin.y + WTK_CHECKBOX_BOX_Y + 1, WTK_CHECKBOX_BOX_SIZE - 2, WTK_CHECKBOX_BOX_SIZE - 2, WTK_CHECKBOX_BACKGROUND_COLOR); } /* Draw check box select marker if selected. */ if (check_box->selected) { gfx_draw_filled_rect(clip->origin.x + WTK_CHECKBOX_BOX_X + 2, clip->origin.y + WTK_CHECKBOX_BOX_Y + 2, WTK_CHECKBOX_BOX_SIZE - 4, WTK_CHECKBOX_BOX_SIZE - 4, WTK_CHECKBOX_SELECT_COLOR); } /* Draw caption. */ gfx_draw_string(check_box->caption, clip->origin.x + WTK_CHECKBOX_CAPTION_X, clip->origin.y + WTK_CHECKBOX_CAPTION_Y, &sysfont, GFX_COLOR_TRANSPARENT, WTK_CHECKBOX_CAPTION_COLOR); /* Always accept DRAW events, as the return value is * ignored anyway for that event type. */ return true; } case WIN_EVENT_POINTER: { /* There should not be other windows in this widget. */ Assert(win == check_box->container); /* For POINTER events, the data parameter points to the * pointer event information. */ struct win_pointer_event const *event = (struct win_pointer_event const *)data; switch (event->type) { case WIN_POINTER_PRESS: /* When check box pressed, grab pointer and * wait for release inside widget borders. * Other widgets won't get pointer events * before it is released, and the pointer * ungrabbed by us. */ if (check_box->state == WTK_CHECKBOX_NORMAL) { win_grab_pointer(check_box->container); check_box->state = WTK_CHECKBOX_PRESSED; win_redraw(check_box->container); } break; case WIN_POINTER_RELEASE: /* When check box released, take action only if * released inside widget extents. */ if (check_box->state == WTK_CHECKBOX_PRESSED) { bool is_inside; /* Ungrab pointer. */ win_grab_pointer(NULL); check_box->state = WTK_CHECKBOX_NORMAL; win_redraw(check_box->container); /* Check release position. */ is_inside = win_is_inside_window (check_box->container, &(event->pos)); /* Toggle check box if inside. */ if (is_inside) { wtk_check_box_toggle(check_box); /* Send non-zero command. */ if (check_box->command) { command.sender = check_box->container; command.recipient = check_box->container; command.data = check_box->command; win_queue_command_event (&command); } } } break; default: break; } /* Accept all POINTER events since all acitivity inside * the widget extents is relevant to us. */ return true; } case WIN_EVENT_DESTROY: /* There should not be other windows in this widget. */ Assert(win == check_box->container); /* Memory allocated for windows will be automatically destroyed * by the window system. We must destroy other allocations. */ membag_free(check_box->caption); membag_free(check_box); /* Always accept DESTROY events, as the return value is ignored * anyway for that event type. */ return true; default: /* Reject unknown event types. */ return false; } }