mirror of https://github.com/OpenTTD/OpenTTD
(svn r15708) -Feature [FS#2728]: Pop up the AI Debug Window if one of the AIs crashed and show a message that the user should report the crash.
parent
0ca92a47a2
commit
2e6e2457f1
|
@ -688,16 +688,21 @@ struct AIDebugWindow : public Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChangeToAI(CompanyID show_ai)
|
||||||
|
{
|
||||||
|
this->RaiseWidget(ai_debug_company + AID_WIDGET_COMPANY_BUTTON_START);
|
||||||
|
ai_debug_company = show_ai;
|
||||||
|
this->LowerWidget(ai_debug_company + AID_WIDGET_COMPANY_BUTTON_START);
|
||||||
|
this->SetDirty();
|
||||||
|
}
|
||||||
|
|
||||||
virtual void OnClick(Point pt, int widget)
|
virtual void OnClick(Point pt, int widget)
|
||||||
{
|
{
|
||||||
/* Check which button is clicked */
|
/* Check which button is clicked */
|
||||||
if (IsInsideMM(widget, AID_WIDGET_COMPANY_BUTTON_START, AID_WIDGET_COMPANY_BUTTON_END + 1)) {
|
if (IsInsideMM(widget, AID_WIDGET_COMPANY_BUTTON_START, AID_WIDGET_COMPANY_BUTTON_END + 1)) {
|
||||||
/* Is it no on disable? */
|
/* Is it no on disable? */
|
||||||
if (!this->IsWidgetDisabled(widget)) {
|
if (!this->IsWidgetDisabled(widget)) {
|
||||||
this->RaiseWidget(ai_debug_company + AID_WIDGET_COMPANY_BUTTON_START);
|
ChangeToAI((CompanyID)(widget - AID_WIDGET_COMPANY_BUTTON_START));
|
||||||
ai_debug_company = (CompanyID)(widget - AID_WIDGET_COMPANY_BUTTON_START);
|
|
||||||
this->LowerWidget(ai_debug_company + AID_WIDGET_COMPANY_BUTTON_START);
|
|
||||||
this->SetDirty();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (widget == AID_WIDGET_RELOAD_TOGGLE && !this->IsWidgetDisabled(widget)) {
|
if (widget == AID_WIDGET_RELOAD_TOGGLE && !this->IsWidgetDisabled(widget)) {
|
||||||
|
@ -770,10 +775,12 @@ static const WindowDesc _ai_debug_desc = {
|
||||||
_ai_debug_widgets
|
_ai_debug_widgets
|
||||||
};
|
};
|
||||||
|
|
||||||
void ShowAIDebugWindow()
|
void ShowAIDebugWindow(CompanyID show_company)
|
||||||
{
|
{
|
||||||
if (!_networking || _network_server) {
|
if (!_networking || _network_server) {
|
||||||
AllocateWindowDescFront<AIDebugWindow>(&_ai_debug_desc, 0);
|
AIDebugWindow *w = (AIDebugWindow *)BringWindowToFrontById(WC_AI_DEBUG, 0);
|
||||||
|
if (w == NULL) w = new AIDebugWindow(&_ai_debug_desc, 0);
|
||||||
|
if (show_company != INVALID_COMPANY) w->ChangeToAI(show_company);
|
||||||
} else {
|
} else {
|
||||||
ShowErrorMessage(INVALID_STRING_ID, STR_AI_DEBUG_SERVER_ONLY, 0, 0);
|
ShowErrorMessage(INVALID_STRING_ID, STR_AI_DEBUG_SERVER_ONLY, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#ifndef AI_GUI_HPP
|
#ifndef AI_GUI_HPP
|
||||||
#define AI_GUI_HPP
|
#define AI_GUI_HPP
|
||||||
|
|
||||||
void ShowAIDebugWindow();
|
void ShowAIDebugWindow(CompanyID show_company = INVALID_COMPANY);
|
||||||
void ShowAIConfigWindow();
|
void ShowAIConfigWindow();
|
||||||
|
|
||||||
#endif /* AI_GUI_HPP */
|
#endif /* AI_GUI_HPP */
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "../settings_type.h"
|
#include "../settings_type.h"
|
||||||
#include "../vehicle_base.h"
|
#include "../vehicle_base.h"
|
||||||
#include "../saveload/saveload.h"
|
#include "../saveload/saveload.h"
|
||||||
|
#include "../gui.h"
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
|
||||||
#include <squirrel.h>
|
#include <squirrel.h>
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
#include "ai_info.hpp"
|
#include "ai_info.hpp"
|
||||||
#include "ai_storage.hpp"
|
#include "ai_storage.hpp"
|
||||||
#include "ai_instance.hpp"
|
#include "ai_instance.hpp"
|
||||||
|
#include "ai_gui.hpp"
|
||||||
|
|
||||||
/* Convert all AI related classes to Squirrel data.
|
/* Convert all AI related classes to Squirrel data.
|
||||||
* Note: this line a marker in squirrel_export.sh. Do not change! */
|
* Note: this line a marker in squirrel_export.sh. Do not change! */
|
||||||
|
@ -251,6 +253,9 @@ void AIInstance::Died()
|
||||||
delete this->engine;
|
delete this->engine;
|
||||||
this->instance = NULL;
|
this->instance = NULL;
|
||||||
this->engine = NULL;
|
this->engine = NULL;
|
||||||
|
|
||||||
|
ShowAIDebugWindow(_current_company);
|
||||||
|
ShowErrorMessage(INVALID_STRING_ID, STR_AI_PLEASE_REPORT_CRASH, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AIInstance::GameLoop()
|
void AIInstance::GameLoop()
|
||||||
|
|
|
@ -3583,6 +3583,7 @@ STR_AI_RANDOM_AI :Random AI
|
||||||
STR_AI_SETTINGS_CAPTION :{WHITE}AI Parameters
|
STR_AI_SETTINGS_CAPTION :{WHITE}AI Parameters
|
||||||
STR_AI_AUTHOR :Author:
|
STR_AI_AUTHOR :Author:
|
||||||
STR_AI_VERSION :Version:
|
STR_AI_VERSION :Version:
|
||||||
|
STR_AI_PLEASE_REPORT_CRASH :{WHITE}One of the running AIs crashed. Please report this to the AI author with a screenshot of the AI Debug Window.
|
||||||
########
|
########
|
||||||
|
|
||||||
############ town controlled noise level
|
############ town controlled noise level
|
||||||
|
|
Loading…
Reference in New Issue