/** Window for displaying the textfile of a AI. */
struct ScriptTextfileWindow : public TextfileWindow {
CompanyID slot; ///< View the textfile of this CompanyID slot.
ScriptTextfileWindow(TextfileType file_type, CompanyID slot) : TextfileWindow(file_type), slot(slot)
{
const char *textfile = GetConfig(slot)->GetTextfile(file_type, slot);
this->LoadTextfile(textfile, (slot == OWNER_DEITY) ? GAME_DIR : AI_DIR);
}
/* virtual */ void SetStringParameters(int widget) const
{
if (widget == WID_TF_CAPTION) {
SetDParam(0, (slot == OWNER_DEITY) ? STR_CONTENT_TYPE_GAME_SCRIPT : STR_CONTENT_TYPE_AI);
const char *script_name = GetConfig(slot)->GetName();
if (script_name == NULL) {
char name[1024];
GetString(name, (slot == OWNER_DEITY) ? STR_AI_CONFIG_NONE : STR_AI_CONFIG_RANDOM_AI, lastof(name));
script_name = stredup(name);
}
SetDParamStr(1, script_name);
}
}
};