| 117 | } |
| 118 | |
| 119 | void DrawWidget(const Rect &r, WidgetID widget) const override |
| 120 | { |
| 121 | switch (widget) { |
| 122 | case WID_SCRL_LIST: { |
| 123 | /* Draw a list of all available Scripts. */ |
| 124 | Rect tr = r.Shrink(WidgetDimensions::scaled.matrix); |
| 125 | /* First AI in the list is hardcoded to random */ |
| 126 | if (this->vscroll->IsVisible(0)) { |
| 127 | DrawString(tr, this->slot == OWNER_DEITY ? STR_AI_CONFIG_NONE : STR_AI_CONFIG_RANDOM_AI, this->selected == -1 ? TC_WHITE : TC_ORANGE); |
| 128 | tr.top += this->line_height; |
| 129 | } |
| 130 | int i = 0; |
| 131 | for (const auto &item : *this->info_list) { |
| 132 | i++; |
| 133 | if (this->vscroll->IsVisible(i)) { |
| 134 | DrawString(tr, this->show_all ? GetString(STR_AI_CONFIG_NAME_VERSION, item.second->GetName(), item.second->GetVersion()) : item.second->GetName(), (this->selected == i - 1) ? TC_WHITE : TC_ORANGE); |
| 135 | tr.top += this->line_height; |
| 136 | } |
| 137 | } |
| 138 | break; |
| 139 | } |
| 140 | case WID_SCRL_INFO_BG: { |
| 141 | ScriptInfo *selected_info = nullptr; |
| 142 | int i = 0; |
| 143 | for (const auto &item : *this->info_list) { |
| 144 | i++; |
| 145 | if (this->selected == i - 1) selected_info = static_cast<ScriptInfo *>(item.second); |
| 146 | } |
| 147 | /* Some info about the currently selected Script. */ |
| 148 | if (selected_info != nullptr) { |
| 149 | Rect tr = r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect); |
| 150 | DrawString(tr, GetString(STR_AI_LIST_AUTHOR, selected_info->GetAuthor())); |
| 151 | tr.top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; |
| 152 | DrawString(tr, GetString(STR_AI_LIST_VERSION, selected_info->GetVersion())); |
| 153 | tr.top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; |
| 154 | if (!selected_info->GetURL().empty()) { |
| 155 | DrawString(tr, GetString(STR_AI_LIST_URL, selected_info->GetURL())); |
| 156 | tr.top += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; |
| 157 | } |
| 158 | DrawStringMultiLine(tr, selected_info->GetDescription(), TC_WHITE); |
| 159 | } |
| 160 | break; |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * Changes the Script of the current slot. |
nothing calls this directly
no test coverage detected