Changeset - r11683:0ad5db20c471
[Not reviewed]
master
0 1 0
alberth - 15 years ago 2009-04-17 19:55:39
alberth@openttd.org
(svn r16073) -Codechange: Replacing some magic constants by computations relative to the SLW_PANEL widget.
1 file changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/subsidy_gui.cpp
Show inline comments
 
@@ -28,25 +28,25 @@ enum SubsidyListWidgets {
 
};
 

	
 
struct SubsidyListWindow : Window {
 
	SubsidyListWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		if (widget != SLW_PANEL) return;
 

	
 
		int y = pt.y - 25;
 
		int y = pt.y - this->widget[SLW_PANEL].top - FONT_HEIGHT_NORMAL - 1; // Skip 'subsidies on offer' line
 

	
 
		if (y < 0) return;
 

	
 
		uint num = 0;
 
		for (const Subsidy *s = _subsidies; s != endof(_subsidies); s++) {
 
			if (s->cargo_type != CT_INVALID && s->age < 12) {
 
				y -= FONT_HEIGHT_NORMAL;
 
				if (y < 0) {
 
					this->HandleClick(s);
 
					return;
 
				}
 
				num++;
 
@@ -108,27 +108,27 @@ struct SubsidyListWindow : Window {
 
		}
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		YearMonthDay ymd;
 
		const Subsidy *s;
 

	
 
		this->DrawWidgets();
 

	
 
		ConvertDateToYMD(_date, &ymd);
 

	
 
		int right = this->width - 12;  // scroll bar = 11 + pixel each side
 
		int y = 15;
 
		int x = 1;
 
		int right = this->widget[SLW_PANEL].right;
 
		int y = this->widget[SLW_PANEL].top + 1;
 
		int x = this->widget[SLW_PANEL].left + 1;
 

	
 
		/* Section for drawing the offered subisidies */
 
		DrawString(x, right, y, STR_2026_SUBSIDIES_ON_OFFER_FOR, TC_FROMSTRING);
 
		y += FONT_HEIGHT_NORMAL;
 
		uint num = 0;
 

	
 
		for (s = _subsidies; s != endof(_subsidies); s++) {
 
			if (s->cargo_type != CT_INVALID && s->age < 12) {
 
				/* Displays the two offered towns */
 
				SetupSubsidyDecodeParam(s, 1);
 
				SetDParam(7, _date - ymd.day + 384 - s->age * 32);
 
				DrawString(x + 2, right - 2, y, STR_2027_FROM_TO, TC_FROMSTRING);
0 comments (0 inline, 0 general)