Changeset - r12438:46b50b60769b
[Not reviewed]
master
0 1 0
alberth - 15 years ago 2009-07-19 17:28:20
alberth@openttd.org
(svn r16882) -Codechange: Introduce a line_height variable in the station picker window.
1 file changed with 7 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/rail_gui.cpp
Show inline comments
 
@@ -935,12 +935,14 @@ enum BuildRailStationWidgets {
 
	BRSW_NEWST_LIST,
 
	BRSW_NEWST_SCROLL
 
};
 

	
 
struct BuildRailStationWindow : public PickerWindowBase {
 
private:
 
	uint line_height; ///< Height of a single line in the newstation selection matrix (#BRSW_NEWST_LIST widget).
 

	
 
	/**
 
	 * Verify whether the currently selected station size is allowed after selecting a new station class/type.
 
	 * If not, change the station size variables ( _settings_client.gui.station_numtracks and _settings_client.gui.station_platlength ).
 
	 * @param statspec Specification of the new station class/type
 
	 */
 
	void CheckSelectedSize(const StationSpec *statspec)
 
@@ -980,12 +982,14 @@ private:
 
		return list;
 
	}
 

	
 
public:
 
	BuildRailStationWindow(const WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(desc, parent)
 
	{
 
		this->line_height = FONT_HEIGHT_NORMAL + 4;
 

	
 
		this->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X);
 
		if (_settings_client.gui.station_dragdrop) {
 
			this->LowerWidget(BRSW_PLATFORM_DRAG_N_DROP);
 
		} else {
 
			this->LowerWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
 
			this->LowerWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
 
@@ -1092,21 +1096,21 @@ public:
 

	
 
			for (uint16 i = this->vscroll.pos; i < _railstation.station_count && i < (uint)(this->vscroll.pos + this->vscroll.cap); i++) {
 
				const StationSpec *statspec = GetCustomStationSpec(_railstation.station_class, i);
 

	
 
				if (statspec != NULL && statspec->name != 0) {
 
					if (HasBit(statspec->callbackmask, CBM_STATION_AVAIL) && GB(GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE), 0, 8) == 0) {
 
						GfxFillRect(left + 1, y - 2, right - 1, y + 10, 0, FILLRECT_CHECKER);
 
						GfxFillRect(left + 1, y - 2, right - 1, y + FONT_HEIGHT_NORMAL, 0, FILLRECT_CHECKER);
 
					}
 

	
 
					DrawString(left + 2, right - 2, y, statspec->name, i == _railstation.station_type ? TC_WHITE : TC_BLACK);
 
				} else {
 
					DrawString(left + 2, right - 2, y, STR_STAT_CLASS_DFLT, i == _railstation.station_type ? TC_WHITE : TC_BLACK);
 
				}
 

	
 
				y += 14;
 
				y += this->line_height;
 
			}
 
		}
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
@@ -1237,13 +1241,13 @@ public:
 
			case BRSW_NEWST_DROPDOWN:
 
				ShowDropDownList(this, BuildStationClassDropDown(), _railstation.station_class, BRSW_NEWST_DROPDOWN);
 
				break;
 

	
 
			case BRSW_NEWST_LIST: {
 
				const StationSpec *statspec;
 
				int y = (pt.y - this->widget[BRSW_NEWST_LIST].top) / 14;
 
				int y = (pt.y - this->widget[BRSW_NEWST_LIST].top) / this->line_height;
 

	
 
				if (y >= this->vscroll.cap) return;
 
				y += this->vscroll.pos;
 
				if (y >= _railstation.station_count) return;
 

	
 
				/* Check station availability callback */
0 comments (0 inline, 0 general)