mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-07-31 16:28:34 +01:00
(svn r16093) -Feature [FS#2808]: Add GetURL() as possible function to info.nut. If AIs implement it, that url is shown when the AI crashes and also in the AI selection window.
This commit is contained in:
parent
ef90925226
commit
a91ff2d5e8
@ -101,6 +101,11 @@ struct AIListWindow : public Window {
|
||||
SetDParam(0, selected_info->GetVersion());
|
||||
DrawString(4, this->widget[AIL_WIDGET_INFO_BG].right - 4, y, STR_AI_VERSION, TC_BLACK);
|
||||
y += 13;
|
||||
if (selected_info->GetURL() != NULL) {
|
||||
SetDParamStr(0, selected_info->GetURL());
|
||||
DrawString(4, this->widget[AIL_WIDGET_INFO_BG].right - 4, y, STR_AI_URL, TC_BLACK);
|
||||
y += 13;
|
||||
}
|
||||
SetDParamStr(0, selected_info->GetDescription());
|
||||
DrawStringMultiLine(4, this->width - 8, y, this->widget[AIL_WIDGET_INFO_BG].bottom, STR_JUST_RAW_STRING);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define DEFINE_SCRIPT_FILES
|
||||
|
||||
#include "ai_info.hpp"
|
||||
#include "ai_config.hpp"
|
||||
#include "ai_storage.hpp"
|
||||
#include "ai_instance.hpp"
|
||||
#include "ai_gui.hpp"
|
||||
@ -258,6 +259,12 @@ void AIInstance::Died()
|
||||
if (strcmp(GetCompany(_current_company)->ai_info->GetMainScript(), "%_dummy") != 0) {
|
||||
ShowErrorMessage(INVALID_STRING_ID, STR_AI_PLEASE_REPORT_CRASH, 0, 0);
|
||||
}
|
||||
|
||||
const AIInfo *info = AIConfig::GetConfig(_current_company)->GetInfo();
|
||||
if (info->GetURL() != NULL) {
|
||||
AILog::Info("Please report the error to the following URL:");
|
||||
AILog::Info(info->GetURL());
|
||||
}
|
||||
}
|
||||
|
||||
void AIInstance::GameLoop()
|
||||
|
@ -3593,6 +3593,7 @@ STR_AI_RANDOM_AI :Random AI
|
||||
STR_AI_SETTINGS_CAPTION :{WHITE}AI Parameters
|
||||
STR_AI_AUTHOR :Author: {RAW_STRING}
|
||||
STR_AI_VERSION :Version: {NUM}
|
||||
STR_AI_URL :URL: {RAW_STRING}
|
||||
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.
|
||||
########
|
||||
|
||||
|
@ -19,6 +19,7 @@ ScriptFileInfo::~ScriptFileInfo()
|
||||
free((void *)this->description);
|
||||
free((void *)this->date);
|
||||
free((void *)this->instance_name);
|
||||
free((void *)this->url);
|
||||
free(this->main_script);
|
||||
free(this->SQ_instance);
|
||||
}
|
||||
@ -68,5 +69,10 @@ bool ScriptFileInfo::CheckMethod(const char *name) const
|
||||
if (!info->engine->CallIntegerMethod(*info->SQ_instance, "GetVersion", &info->version)) return SQ_ERROR;
|
||||
if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "CreateInstance", &info->instance_name)) return SQ_ERROR;
|
||||
|
||||
/* The GetURL function is optional. */
|
||||
if (info->engine->MethodExists(*info->SQ_instance, "GetURL")) {
|
||||
if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetURL", &info->url)) return SQ_ERROR;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -17,7 +17,8 @@ public:
|
||||
short_name(NULL),
|
||||
description(NULL),
|
||||
date(NULL),
|
||||
instance_name(NULL)
|
||||
instance_name(NULL),
|
||||
url(NULL)
|
||||
{}
|
||||
~ScriptFileInfo();
|
||||
|
||||
@ -56,6 +57,11 @@ public:
|
||||
*/
|
||||
const char *GetInstanceName() const { return this->instance_name; }
|
||||
|
||||
/**
|
||||
* Get the website for this script.
|
||||
*/
|
||||
const char *GetURL() const { return this->url; }
|
||||
|
||||
/**
|
||||
* Get the filename of the main.nut script.
|
||||
*/
|
||||
@ -83,6 +89,7 @@ private:
|
||||
const char *date;
|
||||
const char *instance_name;
|
||||
int version;
|
||||
const char *url;
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_INFO */
|
||||
|
Loading…
Reference in New Issue
Block a user