/* * StatsMainResize: Called when the main window is resized. */ void StatsMainResize(int xsize, int ysize, AREA *view) { stat_x = view->x + view->cx + LEFT_BORDER + USERAREA_WIDTH + RIGHT_BORDER + MAPTREAT_WIDTH; stat_bar_x = stat_x + STAT_ICON_WIDTH + RIGHT_BORDER; stat_width = xsize - stat_bar_x - RIGHT_BORDER - EDGETREAT_WIDTH - MAPTREAT_WIDTH - 4; StatsMainMove(); }
/* * StatsMainChange: Given stat in main group changed to given value. */ void StatsMainChange(Statistic *s) { int old_vigor; SendMessage(s->hControl, GRPH_RANGESET, s->numeric.min, s->numeric.max); SendMessage(s->hControl, GRPH_POSSET, 0, s->numeric.value); if (s->num == STAT_XP) SendMessage(s->hControl, GRPH_LIMITSET, 0, 0); else SendMessage(s->hControl, GRPH_LIMITSET, 0, s->numeric.current_max); if (s->num == STAT_VIGOR) { old_vigor = pinfo.vigor; pinfo.vigor = s->numeric.value; // Set color of graph if vigor is very low if (pinfo.vigor < MIN_VIGOR && old_vigor >= MIN_VIGOR) SendMessage(s->hControl, GRPH_COLORSET, GRAPHCOLOR_BAR, STAT_EMERGENCY_COLOR); if (pinfo.vigor >= MIN_VIGOR && old_vigor < MIN_VIGOR) SendMessage(s->hControl, GRPH_COLORSET, GRAPHCOLOR_BAR, GetColor(COLOR_BAR1)); } else if (s->num == STAT_XP) { // Update tooltip StatsMainMove(); } }
/* * StatsMainReceive: We received main group of stats from server. * stats is a list of pointers to Statistic structures. */ void StatsMainReceive(list_type stats) { int height, y, count; list_type l; TOOLINFO ti; StatsMainDestroy(); // Destroy existent controls main_stats = stats; pinfo.vigor = MIN_VIGOR; // Initialize for changing color of bar graph ti.cbSize = sizeof(TOOLINFO); ti.uFlags = 0; ti.hwnd = cinfo->hMain; ti.hinst = hInst; ti.lpszText = 0; count = 0; // Create graph controls for integer stats height = STAT_ICON_HEIGHT + STATS_MAIN_SPACING; //y = ENCHANT_SIZE + 2 * ENCHANT_BORDER - 1 + EDGETREAT_HEIGHT; y = ENCHANT_BORDER + EDGETREAT_HEIGHT + ((USERAREA_HEIGHT - (STAT_ICON_HEIGHT * 3)) / 2); for (l = stats; l != NULL; l = l->next) { Statistic *s = (Statistic *) (l->data); s->y = y; s->cy = height; y += height; if (s->numeric.tag != STAT_INT) continue; if (s->num == STAT_XP) s->hControl = CreateWindow(GraphCtlGetClassName(), NULL, WS_CHILD | WS_VISIBLE | GCS_LIMITBAR | GCS_NUMBER | GCS_XP, 0, 0, 0, 0, cinfo->hMain, NULL, hInst, NULL); else s->hControl = CreateWindow(GraphCtlGetClassName(), NULL, WS_CHILD | WS_VISIBLE | GCS_LIMITBAR | GCS_NUMBER, 0, 0, 0, 0, cinfo->hMain, NULL, hInst, NULL); StatsMainSetColor(s); StatsMainChange(s); // Add tooltip for icon ti.uId = STAT_TOOLTIP_BASE + count; SendMessage(cinfo->hToolTips, TTM_ADDTOOL, 0, (LPARAM) &ti); count++; } StatsMainRedraw(); StatsMainMove(); }