mirror of https://github.com/OpenRCT2/OpenRCT2.git
refactor graph drawing and add finances cash graph tab
This commit is contained in:
parent
42b3121b98
commit
1169329b09
|
@ -27,6 +27,7 @@
|
|||
<ClInclude Include="..\src\finance.h" />
|
||||
<ClInclude Include="..\src\game.h" />
|
||||
<ClInclude Include="..\src\gfx.h" />
|
||||
<ClInclude Include="..\src\graph.h" />
|
||||
<ClInclude Include="..\src\intro.h" />
|
||||
<ClInclude Include="..\src\map.h" />
|
||||
<ClInclude Include="..\src\marketing.h" />
|
||||
|
@ -70,6 +71,7 @@
|
|||
<ClCompile Include="..\src\finance.c" />
|
||||
<ClCompile Include="..\src\game.c" />
|
||||
<ClCompile Include="..\src\gfx.c" />
|
||||
<ClCompile Include="..\src\graph.c" />
|
||||
<ClCompile Include="..\src\intro.c" />
|
||||
<ClCompile Include="..\src\map.c" />
|
||||
<ClCompile Include="..\src\marketing.c" />
|
||||
|
|
|
@ -150,6 +150,9 @@
|
|||
<ClInclude Include="..\src\cursors.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\graph.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\game.c">
|
||||
|
@ -350,6 +353,9 @@
|
|||
<ClCompile Include="..\src\currency.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\graph.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\openrct2.exe">
|
||||
|
|
|
@ -0,0 +1,176 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (c) 2014 Ted John, Peter Hill, Duncan Frost
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
* This file is part of OpenRCT2.
|
||||
*
|
||||
* OpenRCT2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "addresses.h"
|
||||
#include "date.h"
|
||||
#include "graph.h"
|
||||
#include "string_ids.h"
|
||||
|
||||
static void graph_draw_months_uint8(rct_drawpixelinfo *dpi, uint8 *history, int count, int baseX, int baseY)
|
||||
{
|
||||
int i, x, y, yearOver32, currentMonth, currentDay;
|
||||
|
||||
currentMonth = date_get_month(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16));
|
||||
currentDay = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16);
|
||||
yearOver32 = (currentMonth * 4) + (currentDay >> 14) - 31;
|
||||
x = baseX;
|
||||
y = baseY;
|
||||
for (i = count - 1; i >= 0; i--) {
|
||||
if (history[i] != 0 && history[i] != 255 && yearOver32 % 4 == 0) {
|
||||
// Draw month text
|
||||
RCT2_GLOBAL(0x013CE952, uint32) = ((yearOver32 / 4) + 8) % 8 + STR_MONTH_SHORT_MAR;
|
||||
gfx_draw_string_centred(dpi, 2222, x, y - 10, 0, (void*)0x013CE952);
|
||||
|
||||
// Draw month mark
|
||||
gfx_fill_rect(dpi, x, y, x, y + 3, 10);
|
||||
}
|
||||
|
||||
yearOver32 = (yearOver32 + 1) % 32;
|
||||
x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
static void graph_draw_line_a_uint8(rct_drawpixelinfo *dpi, uint8 *history, int count, int baseX, int baseY)
|
||||
{
|
||||
int i, x, y, lastX, lastY;
|
||||
lastX = -1;
|
||||
x = baseX;
|
||||
for (i = count - 1; i >= 0; i--) {
|
||||
if (history[i] != 0 && history[i] != 255) {
|
||||
y = baseY + (history[i] * 100) / 256;
|
||||
|
||||
if (lastX != -1) {
|
||||
gfx_draw_line(dpi, lastX + 1, lastY + 1, x + 1, y + 1, 10);
|
||||
gfx_draw_line(dpi, lastX, lastY + 1, x, y + 1, 10);
|
||||
}
|
||||
if (i == 0)
|
||||
gfx_fill_rect(dpi, x, y, x + 2, y + 2, 10);
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
}
|
||||
x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
static void graph_draw_line_b_uint8(rct_drawpixelinfo *dpi, uint8 *history, int count, int baseX, int baseY)
|
||||
{
|
||||
int i, x, y, lastX, lastY;
|
||||
|
||||
lastX = -1;
|
||||
x = baseX;
|
||||
for (i = count - 1; i >= 0; i--) {
|
||||
if (history[i] != 0 && history[i] != 255) {
|
||||
y = baseY + (history[i] * 100) / 256;
|
||||
|
||||
if (lastX != -1)
|
||||
gfx_draw_line(dpi, lastX, lastY, x, y, 21);
|
||||
if (i == 0)
|
||||
gfx_fill_rect(dpi, x - 1, y - 1, x + 1, y + 1, 21);
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
}
|
||||
x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
void graph_draw_uint8(rct_drawpixelinfo *dpi, uint8 *history, int count, int baseX, int baseY)
|
||||
{
|
||||
graph_draw_months_uint8(dpi, history, count, baseX, baseY);
|
||||
graph_draw_line_a_uint8(dpi, history, count, baseX, baseY);
|
||||
graph_draw_line_b_uint8(dpi, history, count, baseX, baseY);
|
||||
}
|
||||
|
||||
static void graph_draw_months_money32(rct_drawpixelinfo *dpi, money32 *history, int count, int baseX, int baseY)
|
||||
{
|
||||
int i, x, y, yearOver32, currentMonth, currentDay;
|
||||
|
||||
currentMonth = date_get_month(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16));
|
||||
currentDay = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16);
|
||||
yearOver32 = (currentMonth * 4) + (currentDay >> 14) - 31;
|
||||
x = baseX;
|
||||
y = baseY;
|
||||
for (i = count - 1; i >= 0; i--) {
|
||||
if (history[i] != 0x80000000 && yearOver32 % 4 == 0) {
|
||||
// Draw month text
|
||||
sint32 monthFormat = ((yearOver32 / 4) + 8) % 8 + STR_MONTH_SHORT_MAR;
|
||||
gfx_draw_string_centred(dpi, 2222, x, y - 10, 0, &monthFormat);
|
||||
|
||||
// Draw month mark
|
||||
gfx_fill_rect(dpi, x, y, x, y + 3, 10);
|
||||
}
|
||||
|
||||
yearOver32 = (yearOver32 + 1) % 32;
|
||||
x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
static void graph_draw_line_a_money32(rct_drawpixelinfo *dpi, money32 *history, int count, int baseX, int baseY, int modifier)
|
||||
{
|
||||
int i, x, y, lastX, lastY;
|
||||
lastX = -1;
|
||||
x = baseX;
|
||||
for (i = count - 1; i >= 0; i--) {
|
||||
if (history[i] != 0x80000000) {
|
||||
y = baseY + 170 - 6 - ((((history[i] >> modifier) + 128) * 170) / 256);
|
||||
|
||||
if (lastX != -1) {
|
||||
gfx_draw_line(dpi, lastX + 1, lastY + 1, x + 1, y + 1, 10);
|
||||
gfx_draw_line(dpi, lastX, lastY + 1, x, y + 1, 10);
|
||||
}
|
||||
if (i == 0)
|
||||
gfx_fill_rect(dpi, x, y, x + 2, y + 2, 10);
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
}
|
||||
x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
static void graph_draw_line_b_money32(rct_drawpixelinfo *dpi, money32 *history, int count, int baseX, int baseY, int modifier)
|
||||
{
|
||||
int i, x, y, lastX, lastY;
|
||||
|
||||
lastX = -1;
|
||||
x = baseX;
|
||||
for (i = count - 1; i >= 0; i--) {
|
||||
if (history[i] != 0x80000000) {
|
||||
y = baseY + 170 - 6 - ((((history[i] >> modifier) + 128) * 170) / 256);
|
||||
|
||||
if (lastX != -1)
|
||||
gfx_draw_line(dpi, lastX, lastY, x, y, 21);
|
||||
if (i == 0)
|
||||
gfx_fill_rect(dpi, x - 1, y - 1, x + 1, y + 1, 21);
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
}
|
||||
x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
void graph_draw_money32(rct_drawpixelinfo *dpi, money32 *history, int count, int baseX, int baseY, int modifier)
|
||||
{
|
||||
graph_draw_months_money32(dpi, history, count, baseX, baseY, modifier);
|
||||
graph_draw_line_a_money32(dpi, history, count, baseX, baseY, modifier);
|
||||
graph_draw_line_b_money32(dpi, history, count, baseX, baseY, modifier);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (c) 2014 Ted John, Peter Hill, Duncan Frost
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
* This file is part of OpenRCT2.
|
||||
*
|
||||
* OpenRCT2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _GRAPH_H_
|
||||
#define _GRAPH_H_
|
||||
|
||||
#include "gfx.h"
|
||||
#include "rct2.h"
|
||||
|
||||
void graph_draw_uint8(rct_drawpixelinfo *dpi, uint8 *history, int count, int baseX, int baseY);
|
||||
void graph_draw_money32(rct_drawpixelinfo *dpi, money32 *history, int count, int baseX, int baseY, int modifier);
|
||||
|
||||
#endif
|
|
@ -1169,7 +1169,7 @@ const char *format_get_token(char code)
|
|||
void format_string_part_from_raw(char **dest, const char *src, char **args);
|
||||
void format_string_part(char **dest, rct_string_id format, char **args);
|
||||
|
||||
void format_integer(char **dest, int value)
|
||||
void format_integer(char **dest, long long value)
|
||||
{
|
||||
int digit;
|
||||
char *dst = *dest;
|
||||
|
@ -1209,7 +1209,7 @@ void format_integer(char **dest, int value)
|
|||
*dest = finish;
|
||||
}
|
||||
|
||||
void format_comma_separated_integer(char **dest, int value)
|
||||
void format_comma_separated_integer(char **dest, long long value)
|
||||
{
|
||||
int digit, groupIndex;
|
||||
char *dst = *dest;
|
||||
|
@ -1257,7 +1257,7 @@ void format_comma_separated_integer(char **dest, int value)
|
|||
*dest = finish;
|
||||
}
|
||||
|
||||
void format_comma_separated_fixed_2dp(char **dest, int value)
|
||||
void format_comma_separated_fixed_2dp(char **dest, long long value)
|
||||
{
|
||||
int digit, groupIndex;
|
||||
char *dst = *dest;
|
||||
|
@ -1314,7 +1314,7 @@ void format_comma_separated_fixed_2dp(char **dest, int value)
|
|||
*dest = finish;
|
||||
}
|
||||
|
||||
void format_currency(char **dest, int value)
|
||||
void format_currency(char **dest, long long value)
|
||||
{
|
||||
const rct_currency_spec *currencySpec = &g_currency_specs[gGeneral_config.currency_format];
|
||||
|
||||
|
@ -1346,7 +1346,7 @@ void format_currency(char **dest, int value)
|
|||
}
|
||||
}
|
||||
|
||||
void format_currency_2dp(char **dest, int value)
|
||||
void format_currency_2dp(char **dest, long long value)
|
||||
{
|
||||
const rct_currency_spec *currencySpec = &g_currency_specs[gGeneral_config.currency_format];
|
||||
|
||||
|
|
|
@ -594,6 +594,12 @@ enum {
|
|||
STR_MARKETING_FINISHED_PARK_ADS = 2450,
|
||||
STR_MARKETING_FINISHED_RIDE_ADS = 2451,
|
||||
|
||||
STR_FINANCES_FINANCIAL_GRAPH_CASH_LESS_LOAN_POSITIVE = 2452,
|
||||
STR_FINANCES_FINANCIAL_GRAPH_CASH_LESS_LOAN_NEGATIVE = 2453,
|
||||
STR_FINANCES_FINANCIAL_GRAPH_CASH_VALUE = 2454,
|
||||
STR_FINANCES_FINANCIAL_GRAPH_CASH_VALUE_POSITIVE = 2455,
|
||||
STR_FINANCES_FINANCIAL_GRAPH_CASH_VALUE_NEGATIVE = 2456,
|
||||
|
||||
STR_FINANCES_SHOW_SUMMARY_TAB_TIP = 2457,
|
||||
STR_FINANCES_SHOW_CASH_TAB_TIP = 2458,
|
||||
STR_FINANCES_SHOW_PARK_VALUE_TAB_TIP = 2459,
|
||||
|
|
24
src/window.h
24
src/window.h
|
@ -385,4 +385,28 @@ void window_staff_init_vars();
|
|||
|
||||
void window_event_helper(rct_window* w, short widgetIndex, WINDOW_EVENTS event);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define window_get_register(w) \
|
||||
__asm mov w, esi
|
||||
|
||||
#define window_mouse_up_get_registers(w, widgetIndex) \
|
||||
__asm mov widgetIndex, dx \
|
||||
__asm mov w, esi
|
||||
|
||||
#define window_paint_get_registers(w, dpi) \
|
||||
__asm mov w, esi \
|
||||
__asm mov dpi, edi
|
||||
#else
|
||||
#define window_get_register(w) \
|
||||
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
||||
|
||||
#define window_mouse_up_get_registers(w, widgetIndex) \
|
||||
__asm__ ( "mov %[widgetIndex], dx " : [widgetIndex] "+m" (widgetIndex) ); \
|
||||
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
||||
|
||||
#define window_paint_get_registers(w, dpi) \
|
||||
__asm__ ( "mov %[w], esi " : [w] "+m" (w) ); \
|
||||
__asm__ ( "mov %[dpi], edi " : [dpi] "+m" (dpi) );
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#include "addresses.h"
|
||||
#include "date.h"
|
||||
#include "game.h"
|
||||
#include "graph.h"
|
||||
#include "scenario.h"
|
||||
#include "string_ids.h"
|
||||
#include "sprites.h"
|
||||
|
@ -199,6 +201,11 @@ static void window_finances_summary_update(rct_window *w);
|
|||
static void window_finances_summary_invalidate();
|
||||
static void window_finances_summary_paint();
|
||||
|
||||
static void window_finances_financial_graph_mouseup();
|
||||
static void window_finances_financial_graph_update(rct_window *w);
|
||||
static void window_finances_financial_graph_invalidate();
|
||||
static void window_finances_financial_graph_paint();
|
||||
|
||||
// 0x00988EB8
|
||||
static void* window_finances_summary_events[] = {
|
||||
window_finances_emptysub,
|
||||
|
@ -231,9 +238,41 @@ static void* window_finances_summary_events[] = {
|
|||
window_finances_emptysub
|
||||
};
|
||||
|
||||
// 0x00988F28
|
||||
static void* window_finances_financial_graph_events[] = {
|
||||
window_finances_emptysub,
|
||||
window_finances_financial_graph_mouseup,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_financial_graph_update,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_emptysub,
|
||||
window_finances_financial_graph_invalidate,
|
||||
window_finances_financial_graph_paint,
|
||||
window_finances_emptysub
|
||||
};
|
||||
|
||||
static void* window_finances_page_events[] = {
|
||||
window_finances_summary_events,
|
||||
(void*)0x00988F28,
|
||||
window_finances_financial_graph_events,
|
||||
(void*)0x00988F98,
|
||||
(void*)0x00989008,
|
||||
(void*)0x00989078,
|
||||
|
@ -369,17 +408,7 @@ static void window_finances_summary_mouseup()
|
|||
short widgetIndex;
|
||||
rct_window *w;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__asm mov widgetIndex, dx
|
||||
#else
|
||||
__asm__ ( "mov %[widgetIndex], dx " : [widgetIndex] "+m" (widgetIndex) );
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__asm mov w, esi
|
||||
#else
|
||||
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
||||
#endif
|
||||
window_mouse_up_get_registers(w, widgetIndex);
|
||||
|
||||
if (widgetIndex == WIDX_CLOSE)
|
||||
window_close(w);
|
||||
|
@ -431,14 +460,10 @@ static void window_finances_summary_invalidate()
|
|||
{
|
||||
rct_window *w;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__asm mov w, esi
|
||||
#else
|
||||
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
||||
#endif
|
||||
window_get_register(w);
|
||||
|
||||
if (w->widgets != window_finances_page_widgets[0]) {
|
||||
w->widgets = window_finances_page_widgets[0];
|
||||
if (w->widgets != window_finances_page_widgets[WINDOW_FINANCES_PAGE_SUMMARY]) {
|
||||
w->widgets = window_finances_page_widgets[WINDOW_FINANCES_PAGE_SUMMARY];
|
||||
window_init_scroll_widgets(w);
|
||||
}
|
||||
|
||||
|
@ -456,17 +481,7 @@ static void window_finances_summary_paint()
|
|||
rct_drawpixelinfo *dpi;
|
||||
int i, j, x, y;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__asm mov w, esi
|
||||
#else
|
||||
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__asm mov dpi, edi
|
||||
#else
|
||||
__asm__ ( "mov %[dpi], edi " : [dpi] "+m" (dpi) );
|
||||
#endif
|
||||
window_paint_get_registers(w, dpi);
|
||||
|
||||
window_draw_widgets(w, dpi);
|
||||
window_finances_draw_tab_images(dpi, w);
|
||||
|
@ -579,6 +594,144 @@ static void window_finances_summary_paint()
|
|||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Financial graph page
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0069CF70
|
||||
*/
|
||||
static void window_finances_financial_graph_mouseup()
|
||||
{
|
||||
short widgetIndex;
|
||||
rct_window *w;
|
||||
|
||||
window_mouse_up_get_registers(w, widgetIndex);
|
||||
|
||||
if (widgetIndex == WIDX_CLOSE)
|
||||
window_close(w);
|
||||
else if (widgetIndex >= WIDX_TAB_1 && widgetIndex <= WIDX_TAB_6)
|
||||
window_finances_set_page(w, widgetIndex - WIDX_TAB_1);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0069CF8B
|
||||
*/
|
||||
static void window_finances_financial_graph_update(rct_window *w)
|
||||
{
|
||||
// Tab animation
|
||||
if (++w->frame_no >= window_finances_tab_animation_loops[w->page])
|
||||
w->frame_no = 0;
|
||||
widget_invalidate(w->classification, w->number, WIDX_TAB_2);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0069CBDB
|
||||
*/
|
||||
static void window_finances_financial_graph_invalidate()
|
||||
{
|
||||
rct_window *w;
|
||||
|
||||
window_get_register(w);
|
||||
|
||||
if (w->widgets != window_finances_page_widgets[WINDOW_FINANCES_PAGE_FINANCIAL_GRAPH]) {
|
||||
w->widgets = window_finances_page_widgets[WINDOW_FINANCES_PAGE_FINANCIAL_GRAPH];
|
||||
window_init_scroll_widgets(w);
|
||||
}
|
||||
|
||||
window_finances_set_pressed_tab(w);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0069CC10
|
||||
*/
|
||||
static void window_finances_financial_graph_paint()
|
||||
{
|
||||
rct_window *w;
|
||||
rct_drawpixelinfo *dpi;
|
||||
int i, x, y, graphLeft, graphTop, graphRight, graphBottom;
|
||||
|
||||
window_paint_get_registers(w, dpi);
|
||||
|
||||
window_draw_widgets(w, dpi);
|
||||
window_finances_draw_tab_images(dpi, w);
|
||||
|
||||
rct_widget *pageWidget = &window_finances_cash_widgets[WIDX_PAGE_BACKGROUND];
|
||||
graphLeft = w->x + pageWidget->left + 4;
|
||||
graphTop = w->y + pageWidget->top + 15;
|
||||
graphRight = w->x + pageWidget->right - 4;
|
||||
graphBottom = w->y + pageWidget->bottom - 4;
|
||||
|
||||
// Cash (less loan)
|
||||
money32 cashLessLoan =
|
||||
DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, money32)) -
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32);
|
||||
|
||||
gfx_draw_string_left(
|
||||
dpi,
|
||||
cashLessLoan >= 0 ?
|
||||
STR_FINANCES_FINANCIAL_GRAPH_CASH_LESS_LOAN_POSITIVE : STR_FINANCES_FINANCIAL_GRAPH_CASH_LESS_LOAN_NEGATIVE,
|
||||
&cashLessLoan,
|
||||
0,
|
||||
graphLeft,
|
||||
graphTop - 11
|
||||
);
|
||||
|
||||
// Graph
|
||||
gfx_fill_rect_inset(dpi, graphLeft, graphTop, graphRight, graphBottom, w->colours[1], 0x30);
|
||||
|
||||
// Calculate the Y axis scale (log2 of highest [+/-]balance)
|
||||
int yAxisScale = 0;
|
||||
money32 *balanceHistory = RCT2_ADDRESS(RCT2_ADDRESS_BALANCE_HISTORY, money32);
|
||||
for (i = 0; i < 64; i++) {
|
||||
money32 balance = balanceHistory[i];
|
||||
if (balance == 0x80000000)
|
||||
continue;
|
||||
|
||||
// Modifier balance then keep halfing until less than 127 pixels
|
||||
balance = abs(balance) >> yAxisScale;
|
||||
while (balance > 127) {
|
||||
balance /= 2;
|
||||
yAxisScale++;
|
||||
}
|
||||
}
|
||||
|
||||
// Y axis labels
|
||||
x = graphLeft + 18;
|
||||
y = graphTop + 14;
|
||||
money32 axisBase;
|
||||
for (axisBase = MONEY(12,00); axisBase >= MONEY(-12,00); axisBase -= MONEY(6,00)) {
|
||||
money32 axisValue = axisBase << yAxisScale;
|
||||
gfx_draw_string_right(dpi, STR_FINANCES_FINANCIAL_GRAPH_CASH_VALUE, &axisValue, 0, x + 70, y);
|
||||
y += 39;
|
||||
}
|
||||
|
||||
// X axis labels and values
|
||||
x = graphLeft + 98;
|
||||
y = graphTop + 17;
|
||||
graph_draw_money32(dpi, balanceHistory, 64, x, y, yAxisScale);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Value graph page
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Profit graph page
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Marketing page
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Research page
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Common
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "config.h"
|
||||
#include "date.h"
|
||||
#include "game.h"
|
||||
#include "graph.h"
|
||||
#include "park.h"
|
||||
#include "peep.h"
|
||||
#include "ride.h"
|
||||
|
@ -579,9 +580,6 @@ static void window_park_anchor_border_widgets(rct_window *w);
|
|||
static void window_park_align_tabs(rct_window *w);
|
||||
static void window_park_set_pressed_tab(rct_window *w);
|
||||
static void window_park_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w);
|
||||
static void window_park_graph_draw_months(rct_drawpixelinfo *dpi, uint8 *history, int baseX, int baseY);
|
||||
static void window_park_graph_draw_line_a(rct_drawpixelinfo *dpi, uint8 *history, int baseX, int baseY);
|
||||
static void window_park_graph_draw_line_b(rct_drawpixelinfo *dpi, uint8 *history, int baseX, int baseY);
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -1369,9 +1367,7 @@ static void window_park_rating_paint()
|
|||
y += widget->top + 26;
|
||||
|
||||
history = RCT2_ADDRESS(RCT2_ADDRESS_PARK_RATING_HISTORY, uint8);
|
||||
window_park_graph_draw_months(dpi, history, x, y);
|
||||
window_park_graph_draw_line_a(dpi, history, x, y);
|
||||
window_park_graph_draw_line_b(dpi, history, x, y);
|
||||
graph_draw_uint8(dpi, history, 32, x, y);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
@ -1538,9 +1534,7 @@ static void window_park_guests_paint()
|
|||
y += widget->top + 26;
|
||||
|
||||
history = RCT2_ADDRESS(RCT2_ADDRESS_GUESTS_IN_PARK_HISTORY, uint8);
|
||||
window_park_graph_draw_months(dpi, history, x, y);
|
||||
window_park_graph_draw_line_a(dpi, history, x, y);
|
||||
window_park_graph_draw_line_b(dpi, history, x, y);
|
||||
graph_draw_uint8(dpi, history, 32, x, y);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
@ -2383,73 +2377,4 @@ static void window_park_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w)
|
|||
gfx_draw_sprite(dpi, SPR_TAB_AWARDS, w->x + w->widgets[WIDX_TAB_7].left, w->y + w->widgets[WIDX_TAB_7].top, 0);
|
||||
}
|
||||
|
||||
static void window_park_graph_draw_months(rct_drawpixelinfo *dpi, uint8 *history, int baseX, int baseY)
|
||||
{
|
||||
int i, x, y, yearOver32, currentMonth, currentDay;
|
||||
|
||||
currentMonth = date_get_month(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16));
|
||||
currentDay = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16);
|
||||
yearOver32 = (currentMonth * 4) + (currentDay >> 14) - 31;
|
||||
x = baseX;
|
||||
y = baseY;
|
||||
for (i = 31; i >= 0; i--) {
|
||||
if (history[i] != 0 && history[i] != 255 && yearOver32 % 4 == 0) {
|
||||
// Draw month text
|
||||
RCT2_GLOBAL(0x013CE952, uint32) = ((yearOver32 / 4) + 8) % 8 + STR_MONTH_SHORT_MAR;
|
||||
gfx_draw_string_centred(dpi, 2222, x, y - 10, 0, (void*)0x013CE952);
|
||||
|
||||
// Draw month mark
|
||||
gfx_fill_rect(dpi, x, y, x, y + 3, 10);
|
||||
}
|
||||
|
||||
yearOver32 = (yearOver32 + 1) % 32;
|
||||
x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
static void window_park_graph_draw_line_a(rct_drawpixelinfo *dpi, uint8 *history, int baseX, int baseY)
|
||||
{
|
||||
int i, x, y, lastX, lastY;
|
||||
lastX = -1;
|
||||
x = baseX;
|
||||
for (i = 31; i >= 0; i--) {
|
||||
if (history[i] != 0 && history[i] != 255) {
|
||||
y = baseY + (history[i] * 100) / 256;
|
||||
|
||||
if (lastX != -1) {
|
||||
gfx_draw_line(dpi, lastX + 1, lastY + 1, x + 1, y + 1, 10);
|
||||
gfx_draw_line(dpi, lastX, lastY + 1, x, y + 1, 10);
|
||||
}
|
||||
if (i == 0)
|
||||
gfx_fill_rect(dpi, x, y, x + 2, y + 2, 10);
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
}
|
||||
x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
static void window_park_graph_draw_line_b(rct_drawpixelinfo *dpi, uint8 *history, int baseX, int baseY)
|
||||
{
|
||||
int i, x, y, lastX, lastY;
|
||||
|
||||
lastX = -1;
|
||||
x = baseX;
|
||||
for (i = 31; i >= 0; i--) {
|
||||
if (history[i] != 0 && history[i] != 255) {
|
||||
y = baseY + (history[i] * 100) / 256;
|
||||
|
||||
if (lastX != -1)
|
||||
gfx_draw_line(dpi, lastX, lastY, x, y, 21);
|
||||
if (i == 0)
|
||||
gfx_fill_rect(dpi, x - 1, y - 1, x + 1, y + 1, 21);
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
}
|
||||
x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
|
Loading…
Reference in New Issue