Loading

Paste #pwj2jsxgy

  1. /** Window for displaying the textfile of a AI. */
  2. struct ScriptTextfileWindow : public TextfileWindow {
  3.     CompanyID slot; ///< View the textfile of this CompanyID slot.
  4.  
  5.     ScriptTextfileWindow(TextfileType file_type, CompanyID slot) : TextfileWindow(file_type), slot(slot)
  6.     {
  7.         const char *textfile = GetConfig(slot)->GetTextfile(file_type, slot);
  8.         this->LoadTextfile(textfile, (slot == OWNER_DEITY) ? GAME_DIR : AI_DIR);
  9.     }
  10.  
  11.     /* virtual */ void SetStringParameters(int widget) const
  12.     {
  13.         if (widget == WID_TF_CAPTION) {
  14.             SetDParam(0, (slot == OWNER_DEITY) ? STR_CONTENT_TYPE_GAME_SCRIPT : STR_CONTENT_TYPE_AI);
  15.             const char *script_name = GetConfig(slot)->GetName();
  16.             if (script_name == NULL) {
  17.                 char name[1024];
  18.                 GetString(name, (slot == OWNER_DEITY) ? STR_AI_CONFIG_NONE : STR_AI_CONFIG_RANDOM_AI, lastof(name));
  19.                 script_name = stredup(name);
  20.             }
  21.             SetDParamStr(1, script_name);
  22.         }
  23.     }
  24. };

Comments