Update to 1.11.0-beta1

This commit is contained in:
dP
2021-01-23 17:31:11 +03:00
parent d3c06c25c8
commit 5e4506f493
1045 changed files with 23534 additions and 60345 deletions

View File

@@ -71,7 +71,7 @@ static WindowDesc _errmsg_face_desc(
* @param data The data to copy.
*/
ErrorMessageData::ErrorMessageData(const ErrorMessageData &data) :
duration(data.duration), textref_stack_grffile(data.textref_stack_grffile), textref_stack_size(data.textref_stack_size),
display_timer(data.display_timer), textref_stack_grffile(data.textref_stack_grffile), textref_stack_size(data.textref_stack_size),
summary_msg(data.summary_msg), detailed_msg(data.detailed_msg), position(data.position), face(data.face)
{
memcpy(this->textref_stack, data.textref_stack, sizeof(this->textref_stack));
@@ -103,7 +103,6 @@ ErrorMessageData::~ErrorMessageData()
* @param textref_stack Values to put on the #TextRefStack.
*/
ErrorMessageData::ErrorMessageData(StringID summary_msg, StringID detailed_msg, uint duration, int x, int y, const GRFFile *textref_stack_grffile, uint textref_stack_size, const uint32 *textref_stack) :
duration(duration),
textref_stack_grffile(textref_stack_grffile),
textref_stack_size(textref_stack_size),
summary_msg(summary_msg),
@@ -119,6 +118,8 @@ ErrorMessageData::ErrorMessageData(StringID summary_msg, StringID detailed_msg,
if (textref_stack_size > 0) MemCpyT(this->textref_stack, textref_stack, textref_stack_size);
assert(summary_msg != INVALID_STRING_ID);
this->display_timer.SetInterval(duration * 3000);
}
/**
@@ -189,7 +190,7 @@ public:
CopyInDParam(0, this->decode_params, lengthof(this->decode_params));
if (this->textref_stack_size > 0) StartTextRefStackUsage(this->textref_stack_grffile, this->textref_stack_size, this->textref_stack);
int text_width = max(0, (int)size->width - WD_FRAMETEXT_LEFT - WD_FRAMETEXT_RIGHT);
int text_width = std::max(0, (int)size->width - WD_FRAMETEXT_LEFT - WD_FRAMETEXT_RIGHT);
this->height_summary = GetStringHeight(this->summary_msg, text_width);
this->height_detailed = (this->detailed_msg == INVALID_STRING_ID) ? 0 : GetStringHeight(this->detailed_msg, text_width);
@@ -198,13 +199,13 @@ public:
uint panel_height = WD_FRAMERECT_TOP + this->height_summary + WD_FRAMERECT_BOTTOM;
if (this->detailed_msg != INVALID_STRING_ID) panel_height += this->height_detailed + WD_PAR_VSEP_WIDE;
size->height = max(size->height, panel_height);
size->height = std::max(size->height, panel_height);
break;
}
case WID_EM_FACE: {
Dimension face_size = GetSpriteSize(SPR_GRADIENT);
size->width = max(size->width, face_size.width);
size->height = max(size->height, face_size.height);
size->width = std::max(size->width, face_size.width);
size->height = std::max(size->height, face_size.height);
break;
}
}
@@ -225,7 +226,7 @@ public:
int scr_bot = GetMainViewBottom() - 20;
Point pt = RemapCoords(this->position.x, this->position.y, GetSlopePixelZOutsideMap(this->position.x, this->position.y));
const ViewPort *vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
const Viewport *vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
if (this->face == INVALID_COMPANY) {
/* move x pos to opposite corner */
pt.x = UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left;
@@ -297,16 +298,14 @@ public:
void OnMouseLoop() override
{
/* Disallow closing the window too easily, if timeout is disabled */
if (_right_button_down && this->duration != 0) delete this;
if (_right_button_down && !this->display_timer.HasElapsed()) delete this;
}
void OnHundredthTick() override
void OnRealtimeTick(uint delta_ms) override
{
/* Timeout enabled? */
if (this->duration != 0) {
this->duration--;
if (this->duration == 0) delete this;
}
if (this->display_timer.CountElapsed(delta_ms) == 0) return;
delete this;
}
~ErrmsgWindow()
@@ -315,20 +314,13 @@ public:
if (_window_system_initialized) ShowFirstError();
}
EventState OnKeyPress(WChar key, uint16 keycode) override
{
if (keycode != WKC_SPACE) return ES_NOT_HANDLED;
delete this;
return ES_HANDLED;
}
/**
* Check whether the currently shown error message was critical or not.
* @return True iff the message was critical.
*/
bool IsCritical()
{
return this->duration == 0;
return this->display_timer.HasElapsed();
}
};
@@ -424,6 +416,18 @@ void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel
}
}
/**
* Close active error message window
* @return true if a window was closed.
*/
bool HideActiveErrorMessage() {
ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0);
if (w == nullptr) return false;
delete w;
return true;
}
/**
* Schedule a list of errors.
* Note: This does not try to display the error now. This is useful if the window system is not yet running.