|
@@ -146,20 +146,24 @@ struct AIListWindow : public Window {
|
|
|
for (int i = 0; i < this->selected; i++) it++;
|
|
|
AIConfig::GetConfig(slot)->ChangeAI((*it).second->GetName(), (*it).second->GetVersion());
|
|
|
}
|
|
|
SetWindowDirty(WC_GAME_OPTIONS, 0);
|
|
|
}
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case AIL_WIDGET_LIST: { // Select one of the AIs
|
|
|
int sel = (pt.y - this->GetWidget<NWidgetBase>(AIL_WIDGET_LIST)->pos_y) / this->line_height + this->vscroll.GetPosition() - 1;
|
|
|
if (sel < (int)this->ai_info_list->size()) {
|
|
|
this->selected = sel;
|
|
|
this->SetDirty();
|
|
|
if (click_count > 1) {
|
|
|
this->ChangeAI();
|
|
|
delete this;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
case AIL_WIDGET_ACCEPT: {
|
|
|
this->ChangeAI();
|
|
@@ -170,27 +174,12 @@ struct AIListWindow : public Window {
|
|
|
case AIL_WIDGET_CANCEL:
|
|
|
delete this;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnDoubleClick(Point pt, int widget)
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case AIL_WIDGET_LIST: {
|
|
|
int sel = (pt.y - this->GetWidget<NWidgetBase>(AIL_WIDGET_LIST)->pos_y) / this->line_height + this->vscroll.GetPosition() - 1;
|
|
|
if (sel < (int)this->ai_info_list->size()) {
|
|
|
this->selected = sel;
|
|
|
this->ChangeAI();
|
|
|
delete this;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnResize()
|
|
|
{
|
|
|
NWidgetCore *nwi = this->GetWidget<NWidgetCore>(AIL_WIDGET_LIST);
|
|
|
this->vscroll.SetCapacity(nwi->current_y / this->line_height);
|
|
|
nwi->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
|
|
|
}
|
|
@@ -329,13 +318,13 @@ struct AISettingsWindow : public Window
|
|
|
}
|
|
|
} else if (_settings_game.difficulty.diff_level != 3) {
|
|
|
IConsoleSetSetting("difficulty.diff_level", 3);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case AIS_WIDGET_BACKGROUND: {
|
|
|
const NWidgetBase *wid = this->GetWidget<NWidgetBase>(AIS_WIDGET_BACKGROUND);
|
|
|
int num = (pt.y - wid->pos_y) / this->line_height + this->vscroll.GetPosition();
|
|
|
if (num >= (int)this->ai_config->GetConfigList()->size()) break;
|
|
@@ -585,13 +574,13 @@ struct AIConfigWindow : public Window {
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case AIC_WIDGET_DECREASE:
|
|
|
case AIC_WIDGET_INCREASE: {
|
|
|
int new_value;
|
|
|
if (widget == AIC_WIDGET_DECREASE) {
|
|
@@ -604,12 +593,13 @@ struct AIConfigWindow : public Window {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
case AIC_WIDGET_LIST: { // Select a slot
|
|
|
this->selected_slot = (CompanyID)((pt.y - this->GetWidget<NWidgetBase>(widget)->pos_y) / this->line_height + this->vscroll.GetPosition());
|
|
|
this->InvalidateData();
|
|
|
if (click_count > 1 && this->selected_slot != INVALID_COMPANY) ShowAIListWindow((CompanyID)this->selected_slot);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
case AIC_WIDGET_MOVE_UP:
|
|
|
if (this->selected_slot > 1) {
|
|
|
Swap(_settings_newgame.ai_config[this->selected_slot], _settings_newgame.ai_config[this->selected_slot - 1]);
|
|
@@ -649,22 +639,12 @@ struct AIConfigWindow : public Window {
|
|
|
#endif
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnDoubleClick(Point pt, int widget)
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case AIC_WIDGET_LIST:
|
|
|
this->OnClick(pt, widget);
|
|
|
if (this->selected_slot != INVALID_COMPANY) ShowAIListWindow((CompanyID)this->selected_slot);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnInvalidateData(int data)
|
|
|
{
|
|
|
if (this->selected_slot == 0 || this->selected_slot > _settings_newgame.difficulty.max_no_competitors) {
|
|
|
this->selected_slot = INVALID_COMPANY;
|
|
|
}
|
|
|
|
|
@@ -908,13 +888,13 @@ struct AIDebugWindow : public Window {
|
|
|
this->last_vscroll_pos = this->vscroll.GetPosition();
|
|
|
this->SetDirty();
|
|
|
/* Close AI settings window to prevent confusion */
|
|
|
DeleteWindowByClass(WC_AI_SETTINGS);
|
|
|
}
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
|
|
{
|
|
|
/* Check which button is clicked */
|
|
|
if (IsInsideMM(widget, AID_WIDGET_COMPANY_BUTTON_START, AID_WIDGET_COMPANY_BUTTON_END + 1)) {
|
|
|
/* Is it no on disable? */
|
|
|
if (!this->IsWidgetDisabled(widget)) {
|
|
|
ChangeToAI((CompanyID)(widget - AID_WIDGET_COMPANY_BUTTON_START));
|