Changeset - r10538:b47d533c4a04
[Not reviewed]
master
0 1 0
rubidium - 15 years ago 2009-01-03 10:53:49
rubidium@openttd.org
(svn r14795) -Codechange: replace a magic number with a constant (Alberth)
1 file changed with 7 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/settings_gui.cpp
Show inline comments
 
@@ -580,12 +580,14 @@ public:
 
void ShowGameDifficulty()
 
{
 
	DeleteWindowById(WC_GAME_OPTIONS, 0);
 
	new GameDifficultyWindow();
 
}
 

	
 
static const int SETTING_HEIGHT = 11;         ///< Height of a single patch setting in the tree view
 

	
 
static const char *_patches_ui[] = {
 
	"gui.vehicle_speed",
 
	"gui.status_long_date",
 
	"gui.date_format_in_default_names",
 
	"gui.show_finances",
 
	"gui.autoscroll",
 
@@ -782,16 +784,16 @@ struct PatchesSelectionWindow : Window {
 
				}
 
			}
 
			first_time = false;
 
		}
 

	
 
		/* Resize the window to fit the largest patch tab */
 
		ResizeWindowForWidget(this, PATCHSEL_OPTIONSPANEL, 0, patches_max * 11);
 
		ResizeWindowForWidget(this, PATCHSEL_OPTIONSPANEL, 0, patches_max * SETTING_HEIGHT);
 

	
 
		/* Recentre the window for the new size */
 
		this->top = this->top - (patches_max * 11) / 2;
 
		this->top = this->top - (patches_max * SETTING_HEIGHT) / 2;
 

	
 
		this->LowerWidget(PATCHSEL_INTERFACE);
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
@@ -845,13 +847,13 @@ struct PatchesSelectionWindow : Window {
 
						SetDParam(0, (sdb->flags & SGF_NOCOMMA) ? STR_CONFIG_PATCHES_INT32 : STR_7024);
 
					}
 
					SetDParam(1, value);
 
				}
 
			}
 
			DrawString(30, y, (sdb->str) + disabled, TC_FROMSTRING);
 
			y += 11;
 
			y += SETTING_HEIGHT;
 
		}
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		switch (widget) {
 
@@ -866,14 +868,14 @@ struct PatchesSelectionWindow : Window {
 
				y = pt.y - 46 - 1;  // Shift y coordinate
 
				if (y < 0) return;  // Clicked above first entry
 

	
 
				x = pt.x - 5;  // Shift x coordinate
 
				if (x < 0) return;  // Clicked left of the entry
 

	
 
				btn = y / 11;  // Compute which setting is selected
 
				if (y % 11 > 9) return;  // Clicked too low at the setting
 
				btn = y / SETTING_HEIGHT;  // Compute which setting is selected
 
				if (y % SETTING_HEIGHT > SETTING_HEIGHT - 2) return;  // Clicked too low at the setting
 
				if (btn >= page->num) return;  // Clicked below the last setting of the page
 

	
 
				sd = page->entries[btn].setting;
 

	
 
				/* return if action is only active in network, or only settable by server */
 
				if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) return;
0 comments (0 inline, 0 general)