Merge branch 'master' into jgrpp

# Conflicts:
#	src/game/game_gui.cpp
#	src/graph_gui.cpp
#	src/linkgraph/linkgraph_gui.h
#	src/newgrf.cpp
#	src/order_gui.cpp
#	src/saveload/engine_sl.cpp
#	src/saveload/saveload.h
#	src/script/api/script_text.cpp
#	src/script/script_gui.cpp
#	src/settings_table.cpp
#	src/strings.cpp
#	src/table/settings/economy_settings.ini
#	src/table/settings/locale_settings.ini
#	src/timetable_gui.cpp
This commit is contained in:
Jonathan G Rennison
2023-04-10 15:11:53 +01:00
104 changed files with 527 additions and 293 deletions

View File

@@ -57,19 +57,21 @@ struct ScriptListWindow : public Window {
CompanyID slot; ///< The company we're selecting a new Script for.
int line_height; ///< Height of a row in the matrix widget.
Scrollbar *vscroll; ///< Cache of the vertical scrollbar.
bool show_all; ///< Whether to show all available versions.
/**
* Constructor for the window.
* @param desc The description of the window.
* @param slot The company we're changing the Script for.
* @param show_all Whether to show all available versions.
*/
ScriptListWindow(WindowDesc *desc, CompanyID slot) : Window(desc),
slot(slot)
ScriptListWindow(WindowDesc *desc, CompanyID slot, bool show_all) : Window(desc),
slot(slot), show_all(show_all)
{
if (slot == OWNER_DEITY) {
this->info_list = Game::GetUniqueInfoList();
this->info_list = this->show_all ? Game::GetInfoList() : Game::GetUniqueInfoList();
} else {
this->info_list = AI::GetUniqueInfoList();
this->info_list = this->show_all ? AI::GetInfoList() : AI::GetUniqueInfoList();
}
this->CreateNestedTree();
@@ -123,11 +125,14 @@ struct ScriptListWindow : public Window {
DrawString(tr, this->slot == OWNER_DEITY ? STR_AI_CONFIG_NONE : STR_AI_CONFIG_RANDOM_AI, this->selected == -1 ? TC_WHITE : TC_ORANGE);
tr.top += this->line_height;
}
StringID str = this->show_all ? STR_AI_CONFIG_NAME_VERSION : STR_JUST_RAW_STRING;
int i = 0;
for (const auto &item : *this->info_list) {
i++;
if (this->vscroll->IsVisible(i)) {
DrawString(tr, item.second->GetName(), (this->selected == i - 1) ? TC_WHITE : TC_ORANGE);
SetDParamStr(0, item.second->GetName());
SetDParam(1, item.second->GetVersion());
DrawString(tr, str, (this->selected == i - 1) ? TC_WHITE : TC_ORANGE);
tr.top += this->line_height;
}
}
@@ -271,13 +276,14 @@ static WindowDesc _script_list_desc(
);
/**
* Open the AI list window to chose an AI for the given company slot.
* @param slot The slot to change the AI of.
* Open the Script list window to chose a script for the given company slot.
* @param slot The slot to change the script of.
* @param show_all Whether to show all available versions.
*/
void ShowScriptListWindow(CompanyID slot)
void ShowScriptListWindow(CompanyID slot, bool show_all)
{
DeleteWindowByClass(WC_SCRIPT_LIST);
new ScriptListWindow(&_script_list_desc, slot);
new ScriptListWindow(&_script_list_desc, slot, show_all);
}