* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
* The scrollbar uses rows of the page, while the page data structure is a tree of #SettingsPage and #SettingEntry objects.
* As a result, the drawing routing traverses the tree from top to bottom, counting rows in \a cur_row until it reaches \a first_row.
* Then it enables drawing rows while traversing until \a max_row is reached, at which point drawing is terminated.
*
* The \a parent_last parameter ensures that the vertical lines at the left are
* only drawn when another entry follows, that it prevents output like
* \verbatim
* |-- setting
* |-- (-) - Title
* | |-- setting
* | |-- setting
* \endverbatim
* The left-most vertical line is not wanted. It is prevented by setting the
* appropriate bit in the \a parent_last parameter.
*
* @param settings_ptr Pointer to current values of all settings
* @param left Left-most position in window/panel to start drawing \a first_row
* @param right Right-most x position to draw strings at.
* @param y Upper-most position in window/panel to start drawing \a first_row
* @param first_row First row number to draw
* @param max_row Row-number to stop drawing (the row-number of the row below the last row to draw)
* @param selected Selected entry by the user.
* @param cur_row Current row number (internal variable)
* @param parent_last Last-field booleans of parent page level (page level \e i sets bit \e i to 1 if it is its last field)
* @return Row number of the next row to draw
*/
uint BaseSettingEntry::Draw(GameSettings *settings_ptr, int left, int right, int y, uint first_row, uint max_row, BaseSettingEntry *selected, uint cur_row, uint parent_last) const
{
if (this->IsFiltered()) return cur_row;
if (cur_row >= max_row) return cur_row;
bool rtl = _current_text_dir == TD_RTL;
int offset = rtl ? -4 : 4;
int level_width = rtl ? -LEVEL_WIDTH : LEVEL_WIDTH;
int x = rtl ? right : left;
if (cur_row >= first_row) {
int colour = _colour_gradient[COLOUR_ORANGE][4];
y += (cur_row - first_row) * SETTING_HEIGHT; // Compute correct y start position
/* Draw vertical for parent nesting levels */
for (uint lvl = 0; lvl < this->level; lvl++) {
if (!HasBit(parent_last, lvl)) GfxDrawLine(x + offset, y, x + offset, y + SETTING_HEIGHT - 1, colour);
x += level_width;
}
/* draw own |- prefix */
int halfway_y = y + SETTING_HEIGHT / 2;
int bottom_y = (flags & SEF_LAST_FIELD) ? halfway_y : y + SETTING_HEIGHT - 1;
GfxDrawLine(x + offset, y, x + offset, bottom_y, colour);
/* Small horizontal line from the last vertical line */
* @param settings_ptr Pointer to current values of all settings
* @param left Left-most position in window/panel to start drawing \a first_row
* @param right Right-most x position to draw strings at.
* @param y Upper-most position in window/panel to start drawing \a first_row
* @param first_row First row number to draw
* @param max_row Row-number to stop drawing (the row-number of the row below the last row to draw)
* @param selected Selected entry by the user.
* @param cur_row Current row number (internal variable)
* @param parent_last Last-field booleans of parent page level (page level \e i sets bit \e i to 1 if it is its last field)
* @return Row number of the next row to draw
*/
uint SettingsContainer::Draw(GameSettings *settings_ptr, int left, int right, int y, uint first_row, uint max_row, BaseSettingEntry *selected, uint cur_row, uint parent_last) const
{
for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
* @param settings_ptr Pointer to current values of all settings
* @param left Left-most position in window/panel to start drawing \a first_row
* @param right Right-most x position to draw strings at.
* @param y Upper-most position in window/panel to start drawing \a first_row
* @param first_row First row number to draw
* @param max_row Row-number to stop drawing (the row-number of the row below the last row to draw)
* @param selected Selected entry by the user.
* @param cur_row Current row number (internal variable)
* @param parent_last Last-field booleans of parent page level (page level \e i sets bit \e i to 1 if it is its last field)
* @return Row number of the next row to draw
*/
uint SettingsPage::Draw(GameSettings *settings_ptr, int left, int right, int y, uint first_row, uint max_row, BaseSettingEntry *selected, uint cur_row, uint parent_last) const