/* * StatsMainRedraw: Called when the main window needs to be redrawn. */ void StatsMainRedraw(void) { list_type l; HDC hdc; AREA a, b; object_node *obj; // Fake object node for DrawObject hdc = GetDC(cinfo->hMain); obj = ObjectGetBlank(); a.x = stat_x; a.cx = STAT_ICON_HEIGHT; for (l = main_stats; l != NULL; l = l->next) { Statistic *s = (Statistic *) (l->data); a.y = s->y; a.cy = s->cy; obj->icon_res = s->name_res; OffscreenWindowBackground(NULL, a.x, a.y, a.cx, a.cy); DrawStretchedObjectDefault(hdc, obj, &a, NULL); GdiFlush(); b.x = stat_bar_x; b.cx = stat_width; b.y = a.y + STATS_MAIN_SPACING; b.cy = s->cy - 4 * STATS_MAIN_SPACING; InterfaceDrawBarBorder(NULL, hdc, &b); } ObjectDestroyAndFree(obj); ReleaseDC(cinfo->hMain, hdc); }
/* * DisplayNumericStat: Display the given numeric type stat from the current group on the * main window. */ void DisplayNumericStat(Statistic *s) { RECT r; HDC hdc; HFONT hOldFont; char *name, *str; AREA stats_area; AREA a; // ajw - Avoid drawing if Inventory is selected as the "group". if( StatsGetCurrentGroup() == STATS_INVENTORY ) return; StatsGetArea(&stats_area); r.left = 0; r.right = stats_area.cx / 2; r.top = s->y; r.bottom = r.top + s->cy; /* If stat is out of stats area, abort */ if (r.bottom > stats_area.cy || s->num <= top_stat) return; hdc = GetDC(hStats); // DrawWindowBackground(hdc, &r, stats_area.x + r.left, stats_area.y + r.top); DrawWindowBackgroundColor( pinventory_bkgnd(), hdc, &r, stats_area.x + r.left, stats_area.y + r.top, -1 ); hOldFont = (HFONT) SelectObject(hdc, GetFont(FONT_STATS)); SetBkMode(hdc, TRANSPARENT); name = LookupNameRsc(s->name_res); // Draw with drop shadow SetTextColor(hdc, GetColor(COLOR_STATSBGD)); DrawText(hdc, name, strlen(name), &r, DT_LEFT); OffsetRect(&r, 1, 1); SetTextColor(hdc, GetColor(COLOR_STATSFGD)); DrawText(hdc, name, strlen(name), &r, DT_LEFT); switch (s->numeric.tag) { case STAT_RES: r.left = stats_area.cx / 2; r.right = stats_area.cx; DrawWindowBackgroundColor( pinventory_bkgnd(), hdc, &r, stats_area.x + r.left, stats_area.y + r.top, -1 ); str = LookupNameRsc(s->numeric.value); DrawText(hdc, str, strlen(str), &r, DT_RIGHT); break; case STAT_INT: // Draw background around stat bar a.x = stats_area.cx / 2; a.cx = stats_bar_width; a.y = s->y + (s->cy - STATS_BAR_HEIGHT) / 2; a.cy = STATS_BAR_HEIGHT; InterfaceDrawBarBorder( pinventory_bkgnd(), hdc, &a ); break; } SelectObject(hdc, hOldFont); ReleaseDC(hStats, hdc); InvalidateRect( s->hControl, NULL, FALSE ); }