|
@@ -4,6 +4,7 @@
|
|
|
#include "gui.h"
|
|
|
#include "gfx.h"
|
|
|
#include "player.h"
|
|
|
#include "economy.h"
|
|
|
|
|
|
static uint _legend_showbits;
|
|
|
static uint _legend_cargobits;
|
|
@@ -513,6 +514,226 @@ void ShowDeliveredCargoGraph()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*****************************/
|
|
|
/* PERFORMANCE RATING DETAIL */
|
|
|
/*****************************/
|
|
|
|
|
|
static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e)
|
|
|
{
|
|
|
switch(e->event) {
|
|
|
case WE_PAINT: {
|
|
|
int val, needed, score, i;
|
|
|
byte owner, x;
|
|
|
uint16 y=14;
|
|
|
int total_score = 0;
|
|
|
int color_done, color_notdone;
|
|
|
|
|
|
// Draw standard stuff
|
|
|
DrawWindowWidgets(w);
|
|
|
|
|
|
// The player of which we check the detail performance rating
|
|
|
owner = FindFirstBit(w->click_state) - 13;
|
|
|
|
|
|
// Paint the player icons
|
|
|
for (i=0;i<MAX_PLAYERS;i++) {
|
|
|
if (!DEREF_PLAYER(i)->is_active) {
|
|
|
// Check if we have the player as an active player
|
|
|
if (!(w->disabled_state & (1 << (i+13)))) {
|
|
|
// Bah, player gone :(
|
|
|
w->disabled_state += 1 << (i+13);
|
|
|
// Is this player selected? If so, select first player (always save? :s)
|
|
|
if (w->click_state == 1 << (i+13))
|
|
|
w->click_state = 1 << 13;
|
|
|
// We need a repaint
|
|
|
SetWindowDirty(w);
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// Check if we have the player marked as inactive
|
|
|
if ((w->disabled_state & (1 << (i+13)))) {
|
|
|
// New player! Yippie :p
|
|
|
w->disabled_state -= 1 << (i+13);
|
|
|
// We need a repaint
|
|
|
SetWindowDirty(w);
|
|
|
}
|
|
|
|
|
|
if (i == owner) x = 1; else x = 0;
|
|
|
DrawPlayerIcon(i, i*33+11+x, 16+x);
|
|
|
}
|
|
|
|
|
|
// The colors used to show how the progress is going
|
|
|
color_done = _color_list[6].window_color_1b;
|
|
|
color_notdone = _color_list[4].window_color_1b;
|
|
|
|
|
|
// Draw all the score parts
|
|
|
for (i=0;i<NUM_SCORE;i++) {
|
|
|
y += 20;
|
|
|
val = _score_part[owner][i];
|
|
|
needed = score_info[i].needed;
|
|
|
score = score_info[i].score;
|
|
|
// SCORE_TOTAL has his own rulez ;)
|
|
|
if (i == SCORE_TOTAL) {
|
|
|
needed = total_score;
|
|
|
score = SCORE_MAX;
|
|
|
} else
|
|
|
total_score += score;
|
|
|
|
|
|
DrawString(7, y, STR_PERFORMANCE_DETAIL_VEHICLES + i, 0);
|
|
|
|
|
|
// Draw the score
|
|
|
SET_DPARAM32(0, score);
|
|
|
DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, 0);
|
|
|
|
|
|
// Calculate the %-bar
|
|
|
if (val > needed) x = 50;
|
|
|
else if (val == 0) x = 0;
|
|
|
else x = ((val * 50) / needed);
|
|
|
|
|
|
// SCORE_LOAN is inversed
|
|
|
if (val < 0 && i == SCORE_LOAN)
|
|
|
x = 0;
|
|
|
|
|
|
// Draw the bar
|
|
|
if (x != 0)
|
|
|
GfxFillRect(112, y-2, x + 112, y+10, color_done);
|
|
|
if (x != 50)
|
|
|
GfxFillRect(x + 112, y-2, 50 + 112, y+10, color_notdone);
|
|
|
|
|
|
// Calculate the %
|
|
|
if (val > needed) x = 100;
|
|
|
else x = ((val * 100) / needed);
|
|
|
|
|
|
// SCORE_LOAN is inversed
|
|
|
if (val < 0 && i == SCORE_LOAN)
|
|
|
x = 0;
|
|
|
|
|
|
// Draw it
|
|
|
SET_DPARAM32(0, x);
|
|
|
DrawStringCentered(137, y, STR_PERFORMANCE_DETAIL_PERCENT, 0);
|
|
|
|
|
|
// SCORE_LOAN is inversed
|
|
|
if (i == SCORE_LOAN)
|
|
|
val = needed - val;
|
|
|
|
|
|
// Draw the amount we have against what is needed
|
|
|
// For some of them it is in currency format
|
|
|
SET_DPARAM32(0, val);
|
|
|
SET_DPARAM32(1, needed);
|
|
|
switch (i) {
|
|
|
case SCORE_MIN_PROFIT:
|
|
|
case SCORE_MIN_INCOME:
|
|
|
case SCORE_MAX_INCOME:
|
|
|
case SCORE_MONEY:
|
|
|
case SCORE_LOAN:
|
|
|
DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY, 0);
|
|
|
break;
|
|
|
default:
|
|
|
DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_INT, 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
case WE_CLICK:
|
|
|
// Check which button is clicked
|
|
|
if (IS_INT_INSIDE(e->click.widget, 13, 21)) {
|
|
|
// Is it no on disable?
|
|
|
if ((w->disabled_state & (1 << e->click.widget)) == 0) {
|
|
|
w->click_state = 1 << e->click.widget;
|
|
|
SetWindowDirty(w);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case WE_CREATE:
|
|
|
{
|
|
|
int i;
|
|
|
Player *p2;
|
|
|
w->hidden_state = 0;
|
|
|
w->disabled_state = 0;
|
|
|
|
|
|
// Hide the player who are not active
|
|
|
for (i=0;i<MAX_PLAYERS;i++) {
|
|
|
if (!DEREF_PLAYER(i)->is_active) {
|
|
|
w->disabled_state += 1 << (i+13);
|
|
|
}
|
|
|
}
|
|
|
// Update all player stats with the current data
|
|
|
// (this is because _score_info is not saved to a savegame)
|
|
|
FOR_ALL_PLAYERS(p2)
|
|
|
if (p2->is_active)
|
|
|
UpdateCompanyRatingAndValue(p2, false);
|
|
|
|
|
|
w->custom[0] = 74;
|
|
|
w->custom[1] = 5;
|
|
|
|
|
|
w->click_state = 1 << 13;
|
|
|
|
|
|
SetWindowDirty(w);
|
|
|
}
|
|
|
break;
|
|
|
case WE_TICK:
|
|
|
{
|
|
|
// Update the player score every 5 days
|
|
|
if (--w->custom[0] == 0) {
|
|
|
w->custom[0] = 74;
|
|
|
if (--w->custom[1] == 0) {
|
|
|
Player *p2;
|
|
|
w->custom[1] = 5;
|
|
|
FOR_ALL_PLAYERS(p2)
|
|
|
// Skip if player is not active
|
|
|
if (p2->is_active)
|
|
|
UpdateCompanyRatingAndValue(p2, false);
|
|
|
SetWindowDirty(w);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static const Widget _performance_rating_detail_widgets[] = {
|
|
|
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
{ WWT_CAPTION, 14, 11, 266, 0, 13, STR_PERFORMANCE_DETAIL, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
{ WWT_IMGBTN, 14, 0, 266, 14, 27, 0x0},
|
|
|
|
|
|
{ WWT_IMGBTN, 14, 0, 266, 28, 47, 0x0,STR_PERFORMANCE_DETAIL_VEHICLES_TIP},
|
|
|
{ WWT_IMGBTN, 14, 0, 266, 48, 67, 0x0,STR_PERFORMANCE_DETAIL_STATIONS_TIP},
|
|
|
{ WWT_IMGBTN, 14, 0, 266, 68, 87, 0x0,STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP},
|
|
|
{ WWT_IMGBTN, 14, 0, 266, 88, 107, 0x0,STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP},
|
|
|
{ WWT_IMGBTN, 14, 0, 266, 108, 127, 0x0,STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP},
|
|
|
{ WWT_IMGBTN, 14, 0, 266, 128, 147, 0x0,STR_PERFORMANCE_DETAIL_DELIVERED_TIP},
|
|
|
{ WWT_IMGBTN, 14, 0, 266, 148, 167, 0x0,STR_PERFORMANCE_DETAIL_CARGO_TIP},
|
|
|
{ WWT_IMGBTN, 14, 0, 266, 168, 187, 0x0,STR_PERFORMANCE_DETAIL_MONEY_TIP},
|
|
|
{ WWT_IMGBTN, 14, 0, 266, 188, 207, 0x0,STR_PERFORMANCE_DETAIL_LOAN_TIP},
|
|
|
{ WWT_IMGBTN, 14, 0, 266, 208, 227, 0x0,STR_PERFORMANCE_DETAIL_TOTAL_TIP},
|
|
|
|
|
|
{ WWT_IMGBTN, 14, 2, 34, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
|
|
|
{ WWT_IMGBTN, 14, 35, 67, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
|
|
|
{ WWT_IMGBTN, 14, 68, 100, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
|
|
|
{ WWT_IMGBTN, 14, 101, 133, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
|
|
|
{ WWT_IMGBTN, 14, 134, 166, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
|
|
|
{ WWT_IMGBTN, 14, 167, 199, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
|
|
|
{ WWT_IMGBTN, 14, 200, 232, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
|
|
|
{ WWT_IMGBTN, 14, 233, 265, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
|
|
|
{ WWT_LAST},
|
|
|
};
|
|
|
|
|
|
static const WindowDesc _performance_rating_detail_desc = {
|
|
|
-1, -1, 267, 228,
|
|
|
WC_PERFORMANCE_DETAIL,0,
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
|
_performance_rating_detail_widgets,
|
|
|
PerformanceRatingDetailWndProc
|
|
|
};
|
|
|
|
|
|
void ShowPerformanceRatingDetail()
|
|
|
{
|
|
|
AllocateWindowDescFront(&_performance_rating_detail_desc, 0);
|
|
|
}
|
|
|
|
|
|
/***********************/
|
|
|
/* PERFORMANCE HISTORY */
|
|
|
/***********************/
|
|
@@ -558,14 +779,17 @@ static void PerformanceHistoryWndProc(Wi
|
|
|
case WE_CLICK:
|
|
|
if (e->click.widget == 2)
|
|
|
ShowGraphLegend();
|
|
|
if (e->click.widget == 3)
|
|
|
ShowPerformanceRatingDetail();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static const Widget _performance_history_widgets[] = {
|
|
|
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
{ WWT_CAPTION, 14, 11, 525, 0, 13, STR_7051_COMPANY_PERFORMANCE_RATINGS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
{ WWT_CAPTION, 14, 11, 475, 0, 13, STR_7051_COMPANY_PERFORMANCE_RATINGS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
{ WWT_PUSHTXTBTN, 14, 526, 575, 0, 13, STR_704C_KEY, STR_704D_SHOW_KEY_TO_GRAPHS},
|
|
|
{ WWT_PUSHTXTBTN, 14, 476, 525, 0, 13, STR_PERFORMANCE_DETAIL_KEY, STR_704D_SHOW_KEY_TO_GRAPHS},
|
|
|
{ WWT_IMGBTN, 14, 0, 575, 14, 237, 0x0},
|
|
|
{ WWT_LAST},
|
|
|
};
|