File diff r16430:b3f65f9bc976 → r16431:ec558deca9d7
src/ai/ai_gui.cpp
Show inline comments
 
@@ -281,25 +281,25 @@ struct AISettingsWindow : public Window 
 
		this->DrawWidgets();
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (widget != AIS_WIDGET_BACKGROUND) return;
 

	
 
		AIConfig *config = this->ai_config;
 
		AIConfigItemList::const_iterator it = config->GetConfigList()->begin();
 
		int i = 0;
 
		for (; !this->vscroll->IsVisible(i); i++) it++;
 

	
 
		bool rtl = _dynlang.text_dir == TD_RTL;
 
		bool rtl = _current_text_dir == TD_RTL;
 
		uint buttons_left = rtl ? r.right - 23 : r.left + 4;
 
		uint text_left    = r.left + (rtl ? WD_FRAMERECT_LEFT : 28);
 
		uint text_right   = r.right - (rtl ? 28 : WD_FRAMERECT_RIGHT);
 

	
 

	
 
		int y = r.top;
 
		for (; this->vscroll->IsVisible(i) && it != config->GetConfigList()->end(); i++, it++) {
 
			int current_value = config->GetSetting((*it).name);
 
			bool editable = (_game_mode == GM_MENU) || ((it->flags & AICONFIG_INGAME) != 0);
 

	
 
			StringID str;
 
			TextColour colour;
 
@@ -351,25 +351,25 @@ struct AISettingsWindow : public Window 
 
				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;
 

	
 
				AIConfigItemList::const_iterator it = this->ai_config->GetConfigList()->begin();
 
				for (int i = 0; i < num; i++) it++;
 
				AIConfigItem config_item = *it;
 
				if (_game_mode != GM_MENU && (config_item.flags & AICONFIG_INGAME) == 0) return;
 

	
 
				bool bool_item = (config_item.flags & AICONFIG_BOOLEAN) != 0;
 

	
 
				int x = pt.x - wid->pos_x;
 
				if (_dynlang.text_dir == TD_RTL) x = wid->current_x - x;
 
				if (_current_text_dir == TD_RTL) x = wid->current_x - x;
 
				x -= 4;
 
				/* One of the arrows is clicked (or green/red rect in case of bool value) */
 
				if (IsInsideMM(x, 0, 21)) {
 
					int new_val = this->ai_config->GetSetting(config_item.name);
 
					if (bool_item) {
 
						new_val = !new_val;
 
					} else if (x >= 10) {
 
						/* Increase button clicked */
 
						new_val += config_item.step_size;
 
						if (new_val > config_item.max_value) new_val = config_item.max_value;
 
						this->clicked_increase = true;
 
					} else {