|
|
|
|
@@ -8,37 +8,21 @@
|
|
|
|
|
/** @file game_gui.cpp %Window for configuring the Game Script */
|
|
|
|
|
|
|
|
|
|
#include "../stdafx.h"
|
|
|
|
|
#include "../table/sprites.h"
|
|
|
|
|
#include "../error.h"
|
|
|
|
|
#include "../settings_gui.h"
|
|
|
|
|
#include "../querystring_gui.h"
|
|
|
|
|
#include "../stringfilter_type.h"
|
|
|
|
|
#include "../company_base.h"
|
|
|
|
|
#include "../company_gui.h"
|
|
|
|
|
#include "../strings_func.h"
|
|
|
|
|
#include "../window_func.h"
|
|
|
|
|
#include "../window_type.h"
|
|
|
|
|
#include "../gfx_func.h"
|
|
|
|
|
#include "../command_func.h"
|
|
|
|
|
#include "../network/network.h"
|
|
|
|
|
#include "../settings_func.h"
|
|
|
|
|
#include "../network/network_content.h"
|
|
|
|
|
#include "../textfile_gui.h"
|
|
|
|
|
#include "../widgets/dropdown_type.h"
|
|
|
|
|
#include "../widgets/dropdown_func.h"
|
|
|
|
|
#include "../hotkeys.h"
|
|
|
|
|
#include "../core/geometry_func.hpp"
|
|
|
|
|
#include "../guitimer_func.h"
|
|
|
|
|
#include "../settings_type.h"
|
|
|
|
|
|
|
|
|
|
#include "game.hpp"
|
|
|
|
|
#include "game_gui.hpp"
|
|
|
|
|
#include "../ai/ai_config.hpp"
|
|
|
|
|
#include "../ai/ai_gui.hpp"
|
|
|
|
|
#include "../widgets/game_widget.h"
|
|
|
|
|
#include "game_config.hpp"
|
|
|
|
|
#include "game_info.hpp"
|
|
|
|
|
#include "../script/script_gui.h"
|
|
|
|
|
#include "../table/strings.h"
|
|
|
|
|
#include "../game/game.hpp"
|
|
|
|
|
#include "../game/game_config.hpp"
|
|
|
|
|
#include "../game/game_info.hpp"
|
|
|
|
|
#include "../game/game_instance.hpp"
|
|
|
|
|
|
|
|
|
|
#include "../safeguards.h"
|
|
|
|
|
|
|
|
|
|
@@ -98,7 +82,7 @@ bool UserIsAllowedToChangeGameScript()
|
|
|
|
|
* Window to configure which GSs will start.
|
|
|
|
|
*/
|
|
|
|
|
struct GSConfigWindow : public Window {
|
|
|
|
|
ScriptConfig* gs_config; ///< The configuration we're modifying.
|
|
|
|
|
ScriptConfig *gs_config; ///< The configuration we're modifying.
|
|
|
|
|
int line_height; ///< Height of a single GS-name line.
|
|
|
|
|
int clicked_button; ///< The button we clicked.
|
|
|
|
|
bool clicked_increase; ///< Whether we clicked the increase or decrease button.
|
|
|
|
|
@@ -106,8 +90,8 @@ struct GSConfigWindow : public Window {
|
|
|
|
|
bool closing_dropdown; ///< True, if the dropdown list is currently closing.
|
|
|
|
|
GUITimer timeout; ///< Timeout for unclicking the button.
|
|
|
|
|
int clicked_row; ///< The clicked row of settings.
|
|
|
|
|
Scrollbar* vscroll; ///< Cache of the vertical scrollbar.
|
|
|
|
|
typedef std::vector<const ScriptConfigItem*> VisibleSettingsList; ///< typdef for a vector of script settings
|
|
|
|
|
Scrollbar *vscroll; ///< Cache of the vertical scrollbar.
|
|
|
|
|
typedef std::vector<const ScriptConfigItem *> VisibleSettingsList; ///< typdef for a vector of script settings
|
|
|
|
|
VisibleSettingsList visible_settings; ///< List of visible GS settings
|
|
|
|
|
|
|
|
|
|
GSConfigWindow() : Window(&_gs_config_desc),
|
|
|
|
|
@@ -128,7 +112,7 @@ struct GSConfigWindow : public Window {
|
|
|
|
|
|
|
|
|
|
~GSConfigWindow()
|
|
|
|
|
{
|
|
|
|
|
DeleteWindowByClass(WC_AI_LIST);
|
|
|
|
|
DeleteWindowByClass(WC_SCRIPT_LIST);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -140,7 +124,7 @@ struct GSConfigWindow : public Window {
|
|
|
|
|
{
|
|
|
|
|
visible_settings.clear();
|
|
|
|
|
|
|
|
|
|
for (const auto& item : *this->gs_config->GetConfigList()) {
|
|
|
|
|
for (const auto &item : *this->gs_config->GetConfigList()) {
|
|
|
|
|
bool no_hide = (item.flags & SCRIPTCONFIG_DEVELOPER) == 0;
|
|
|
|
|
if (no_hide || _settings_client.gui.ai_developer_tools) {
|
|
|
|
|
visible_settings.push_back(&item);
|
|
|
|
|
@@ -150,7 +134,7 @@ struct GSConfigWindow : public Window {
|
|
|
|
|
this->vscroll->SetCount((int)this->visible_settings.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UpdateWidgetSize(int widget, Dimension* size, const Dimension& padding, Dimension* fill, Dimension* resize) override
|
|
|
|
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
|
|
|
|
{
|
|
|
|
|
switch (widget) {
|
|
|
|
|
case WID_GSC_SETTINGS:
|
|
|
|
|
@@ -176,7 +160,7 @@ struct GSConfigWindow : public Window {
|
|
|
|
|
return UserIsAllowedToChangeGameScript() || Game::GetInstance() != nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawWidget(const Rect& r, int widget) const override
|
|
|
|
|
void DrawWidget(const Rect &r, int widget) const override
|
|
|
|
|
{
|
|
|
|
|
switch (widget) {
|
|
|
|
|
case WID_GSC_GSLIST: {
|
|
|
|
|
@@ -192,7 +176,7 @@ struct GSConfigWindow : public Window {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case WID_GSC_SETTINGS: {
|
|
|
|
|
ScriptConfig* config = this->gs_config;
|
|
|
|
|
ScriptConfig *config = this->gs_config;
|
|
|
|
|
VisibleSettingsList::const_iterator it = this->visible_settings.begin();
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (; !this->vscroll->IsVisible(i); i++) it++;
|
|
|
|
|
@@ -206,7 +190,7 @@ struct GSConfigWindow : public Window {
|
|
|
|
|
int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
|
|
|
|
|
int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
|
|
|
|
|
for (; this->vscroll->IsVisible(i) && it != visible_settings.end(); i++, it++) {
|
|
|
|
|
const ScriptConfigItem& config_item = **it;
|
|
|
|
|
const ScriptConfigItem &config_item = **it;
|
|
|
|
|
int current_value = config->GetSetting((config_item).name);
|
|
|
|
|
bool editable = this->IsEditableItem(config_item);
|
|
|
|
|
|
|
|
|
|
@@ -214,14 +198,8 @@ struct GSConfigWindow : public Window {
|
|
|
|
|
TextColour colour;
|
|
|
|
|
uint idx = 0;
|
|
|
|
|
if (StrEmpty(config_item.description)) {
|
|
|
|
|
if (!strcmp(config_item.name, "start_date")) {
|
|
|
|
|
/* Build-in translation */
|
|
|
|
|
str = STR_AI_SETTINGS_START_DELAY;
|
|
|
|
|
colour = TC_LIGHT_BLUE;
|
|
|
|
|
} else {
|
|
|
|
|
str = STR_JUST_STRING;
|
|
|
|
|
colour = TC_ORANGE;
|
|
|
|
|
}
|
|
|
|
|
str = STR_JUST_STRING;
|
|
|
|
|
colour = TC_ORANGE;
|
|
|
|
|
} else {
|
|
|
|
|
str = STR_AI_SETTINGS_SETTING;
|
|
|
|
|
colour = TC_LIGHT_BLUE;
|
|
|
|
|
@@ -275,12 +253,12 @@ struct GSConfigWindow : public Window {
|
|
|
|
|
switch (widget) {
|
|
|
|
|
case WID_GSC_GSLIST: {
|
|
|
|
|
this->InvalidateData();
|
|
|
|
|
if (click_count > 1 && UserIsAllowedToChangeGameScript()) ShowAIListWindow((CompanyID)OWNER_DEITY);
|
|
|
|
|
if (click_count > 1 && UserIsAllowedToChangeGameScript()) ShowScriptListWindow((CompanyID)OWNER_DEITY);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case WID_GSC_CHANGE: // choose other Game Script
|
|
|
|
|
ShowAIListWindow((CompanyID)OWNER_DEITY);
|
|
|
|
|
ShowScriptListWindow((CompanyID)OWNER_DEITY);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WID_GSC_CONTENT_DOWNLOAD:
|
|
|
|
|
@@ -384,7 +362,7 @@ struct GSConfigWindow : public Window {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnQueryTextFinished(char* str) override
|
|
|
|
|
void OnQueryTextFinished(char *str) override
|
|
|
|
|
{
|
|
|
|
|
if (StrEmpty(str)) return;
|
|
|
|
|
int32 value = atoi(str);
|
|
|
|
|
|