Update to 1.10.0-beta1

This commit is contained in:
dP
2019-10-31 22:24:28 +03:00
parent b84a475e14
commit 599ccf0c2b
1470 changed files with 354219 additions and 16795 deletions

View File

@@ -22,6 +22,9 @@
#include "guitimer_func.h"
#include "company_base.h"
#include "ai/ai_info.hpp"
#include "ai/ai_instance.hpp"
#include "game/game.hpp"
#include "game/game_instance.hpp"
#include "widgets/framerate_widget.h"
#include "safeguards.h"
@@ -365,6 +368,9 @@ static const NWidgetPart _framerate_window_widgets[] = {
NWidget(WWT_EMPTY, COLOUR_GREY, WID_FRW_TIMES_NAMES), SetScrollbar(WID_FRW_SCROLLBAR),
NWidget(WWT_EMPTY, COLOUR_GREY, WID_FRW_TIMES_CURRENT), SetScrollbar(WID_FRW_SCROLLBAR),
NWidget(WWT_EMPTY, COLOUR_GREY, WID_FRW_TIMES_AVERAGE), SetScrollbar(WID_FRW_SCROLLBAR),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_FRW_SEL_MEMORY),
NWidget(WWT_EMPTY, COLOUR_GREY, WID_FRW_ALLOCSIZE), SetScrollbar(WID_FRW_SCROLLBAR),
EndContainer(),
EndContainer(),
NWidget(WWT_TEXT, COLOUR_GREY, WID_FRW_INFO_DATA_POINTS), SetDataTip(STR_FRAMERATE_DATA_POINTS, 0x0),
EndContainer(),
@@ -378,6 +384,7 @@ static const NWidgetPart _framerate_window_widgets[] = {
struct FramerateWindow : Window {
bool small;
bool showing_memory;
GUITimer next_update;
int num_active;
int num_displayed;
@@ -424,6 +431,7 @@ struct FramerateWindow : Window {
{
this->InitNested(number);
this->small = this->IsShaded();
this->showing_memory = true;
this->UpdateData();
this->num_displayed = this->num_active;
this->next_update.SetInterval(100);
@@ -432,7 +440,7 @@ struct FramerateWindow : Window {
ResizeWindow(this, 0, (max(MIN_ELEMENTS, this->num_displayed) - MIN_ELEMENTS) * FONT_HEIGHT_NORMAL);
}
virtual void OnRealtimeTick(uint delta_ms)
void OnRealtimeTick(uint delta_ms) override
{
bool elapsed = this->next_update.Elapsed(delta_ms);
@@ -453,6 +461,7 @@ struct FramerateWindow : Window {
void UpdateData()
{
double gl_rate = _pf_data[PFE_GAMELOOP].GetRate();
bool have_script = false;
this->rate_gameloop.SetRate(gl_rate, _pf_data[PFE_GAMELOOP].expected_rate);
this->speed_gameloop.SetRate(gl_rate / _pf_data[PFE_GAMELOOP].expected_rate, 1.0);
if (this->small) return; // in small mode, this is everything needed
@@ -463,7 +472,16 @@ struct FramerateWindow : Window {
for (PerformanceElement e = PFE_FIRST; e < PFE_MAX; e++) {
this->times_shortterm[e].SetTime(_pf_data[e].GetAverageDurationMilliseconds(8), MILLISECONDS_PER_TICK);
this->times_longterm[e].SetTime(_pf_data[e].GetAverageDurationMilliseconds(NUM_FRAMERATE_POINTS), MILLISECONDS_PER_TICK);
if (_pf_data[e].num_valid > 0) new_active++;
if (_pf_data[e].num_valid > 0) {
new_active++;
if (e == PFE_GAMESCRIPT || e >= PFE_AI0) have_script = true;
}
}
if (this->showing_memory != have_script) {
NWidgetStacked *plane = this->GetWidget<NWidgetStacked>(WID_FRW_SEL_MEMORY);
plane->SetDisplayedPlane(have_script ? 0 : SZSP_VERTICAL);
this->showing_memory = have_script;
}
if (new_active != this->num_active) {
@@ -475,7 +493,7 @@ struct FramerateWindow : Window {
}
}
virtual void SetStringParameters(int widget) const
void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_FRW_CAPTION:
@@ -503,7 +521,7 @@ struct FramerateWindow : Window {
}
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
switch (widget) {
case WID_FRW_RATE_GAMELOOP:
@@ -545,7 +563,8 @@ struct FramerateWindow : Window {
}
case WID_FRW_TIMES_CURRENT:
case WID_FRW_TIMES_AVERAGE: {
case WID_FRW_TIMES_AVERAGE:
case WID_FRW_ALLOCSIZE: {
*size = GetStringBoundingBox(STR_FRAMERATE_CURRENT + (widget - WID_FRW_TIMES_CURRENT));
SetDParam(0, 999999);
SetDParam(1, 2);
@@ -582,7 +601,38 @@ struct FramerateWindow : Window {
}
}
virtual void DrawWidget(const Rect &r, int widget) const
void DrawElementAllocationsColumn(const Rect &r) const
{
const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR);
uint16 skip = sb->GetPosition();
int drawable = this->num_displayed;
int y = r.top;
DrawString(r.left, r.right, y, STR_FRAMERATE_MEMORYUSE, TC_FROMSTRING, SA_CENTER, true);
y += FONT_HEIGHT_NORMAL + VSPACING;
for (PerformanceElement e : DISPLAY_ORDER_PFE) {
if (_pf_data[e].num_valid == 0) continue;
if (skip > 0) {
skip--;
} else if (e == PFE_GAMESCRIPT || e >= PFE_AI0) {
if (e == PFE_GAMESCRIPT) {
SetDParam(0, Game::GetInstance()->GetAllocatedMemory());
} else {
SetDParam(0, Company::Get(e - PFE_AI0)->ai_instance->GetAllocatedMemory());
}
DrawString(r.left, r.right, y, STR_FRAMERATE_BYTES_GOOD, TC_FROMSTRING, SA_RIGHT);
y += FONT_HEIGHT_NORMAL;
drawable--;
if (drawable == 0) break;
} else {
/* skip non-script */
y += FONT_HEIGHT_NORMAL;
drawable--;
if (drawable == 0) break;
}
}
}
void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_FRW_TIMES_NAMES: {
@@ -618,10 +668,13 @@ struct FramerateWindow : Window {
/* Render averages of all recorded values */
DrawElementTimesColumn(r, STR_FRAMERATE_AVERAGE, this->times_longterm);
break;
case WID_FRW_ALLOCSIZE:
DrawElementAllocationsColumn(r);
break;
}
}
virtual void OnClick(Point pt, int widget, int click_count)
void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_FRW_TIMES_NAMES:
@@ -646,7 +699,7 @@ struct FramerateWindow : Window {
}
}
virtual void OnResize()
void OnResize() override
{
auto *wid = this->GetWidget<NWidgetResizeBase>(WID_FRW_TIMES_NAMES);
this->num_displayed = (wid->current_y - wid->min_y - VSPACING) / FONT_HEIGHT_NORMAL - 1; // subtract 1 for headings
@@ -694,7 +747,7 @@ struct FrametimeGraphWindow : Window {
this->InitNested(number);
}
virtual void SetStringParameters(int widget) const
void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_FGW_CAPTION:
@@ -709,7 +762,7 @@ struct FrametimeGraphWindow : Window {
}
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
if (widget == WID_FGW_GRAPH) {
SetDParam(0, 100);
@@ -807,7 +860,7 @@ struct FrametimeGraphWindow : Window {
this->SelectVerticalScale(peak_value);
}
virtual void OnRealtimeTick(uint delta_ms)
void OnRealtimeTick(uint delta_ms) override
{
this->SetDirty();
@@ -826,7 +879,7 @@ struct FrametimeGraphWindow : Window {
return (value - src_min) * dst_diff / src_diff + dst_min;
}
virtual void DrawWidget(const Rect &r, int widget) const
void DrawWidget(const Rect &r, int widget) const override
{
if (widget == WID_FGW_GRAPH) {
const TimingMeasurement *durations = _pf_data[this->element].durations;
@@ -865,7 +918,7 @@ struct FrametimeGraphWindow : Window {
}
}
}
/* Draw divison lines and labels for the horizontal axis */
/* Draw division lines and labels for the horizontal axis */
for (uint division = horz_divisions; division > 0; division--) {
int x = Scinterlate(x_zero, x_max, 0, (int)horz_divisions, (int)horz_divisions - (int)division);
GfxDrawLine(x, y_max, x, y_zero, c_grid);