|
@@ -749,21 +749,31 @@ enum PatchesSelectionWidgets {
|
|
|
PATCHSEL_STATIONS, ///< Button 'Stations'
|
|
|
PATCHSEL_ECONOMY, ///< Button 'Economy'
|
|
|
PATCHSEL_COMPETITORS ///< Button 'Competitors'
|
|
|
};
|
|
|
|
|
|
struct PatchesSelectionWindow : Window {
|
|
|
static const int SETTINGTREE_LEFT_OFFSET; ///< Position of left edge of patch values
|
|
|
static const int SETTINGTREE_TOP_OFFSET; ///< Position of top edge of patch values
|
|
|
|
|
|
static GameSettings *patches_ptr; ///< Pointer to the game settings being displayed and modified
|
|
|
static int patches_max; ///< Maximal number of patches on a single page
|
|
|
|
|
|
int page;
|
|
|
int entry;
|
|
|
int click;
|
|
|
|
|
|
PatchesSelectionWindow(const WindowDesc *desc) : Window(desc)
|
|
|
{
|
|
|
/* Check that the widget doesn't get moved without adapting the constant as well.
|
|
|
* - SETTINGTREE_LEFT_OFFSET should be 5 pixels to the right of the left edge of the panel
|
|
|
* - SETTINGTREE_TOP_OFFSET should be 5 pixels below the top edge of the panel
|
|
|
*/
|
|
|
assert(this->widget[PATCHSEL_OPTIONSPANEL].left + 5 == SETTINGTREE_LEFT_OFFSET);
|
|
|
assert(this->widget[PATCHSEL_OPTIONSPANEL].top + 5 == SETTINGTREE_TOP_OFFSET);
|
|
|
|
|
|
static bool first_time = true;
|
|
|
|
|
|
patches_ptr = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game;
|
|
|
|
|
|
/* Build up the dynamic settings-array only once per OpenTTD session */
|
|
|
if (first_time) {
|
|
@@ -796,21 +806,20 @@ struct PatchesSelectionWindow : Window {
|
|
|
|
|
|
this->FindWindowPlacementAndResize(desc);
|
|
|
}
|
|
|
|
|
|
virtual void OnPaint()
|
|
|
{
|
|
|
int x, y;
|
|
|
const PatchPage *page = &_patches_page[this->page];
|
|
|
uint i;
|
|
|
|
|
|
/* Set up selected category */
|
|
|
this->DrawWidgets();
|
|
|
|
|
|
x = 5;
|
|
|
y = 47;
|
|
|
int x = SETTINGTREE_LEFT_OFFSET;
|
|
|
int y = SETTINGTREE_TOP_OFFSET;
|
|
|
for (i = 0; i != page->num; i++) {
|
|
|
const SettingDesc *sd = page->entries[i].setting;
|
|
|
const SettingDescBase *sdb = &sd->desc;
|
|
|
const void *var = GetVariableAddress(patches_ptr, &sd->save);
|
|
|
bool editable = true;
|
|
|
bool disabled = false;
|
|
@@ -862,16 +871,16 @@ struct PatchesSelectionWindow : Window {
|
|
|
const SettingDesc *sd;
|
|
|
void *var;
|
|
|
int32 value;
|
|
|
int x, y;
|
|
|
byte btn;
|
|
|
|
|
|
y = pt.y - 46 - 1; // Shift y coordinate
|
|
|
y = pt.y - SETTINGTREE_TOP_OFFSET; // Shift y coordinate
|
|
|
if (y < 0) return; // Clicked above first entry
|
|
|
|
|
|
x = pt.x - 5; // Shift x coordinate
|
|
|
x = pt.x - SETTINGTREE_LEFT_OFFSET; // Shift x coordinate
|
|
|
if (x < 0) return; // Clicked left of the entry
|
|
|
|
|
|
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
|
|
|
|
|
@@ -974,12 +983,14 @@ struct PatchesSelectionWindow : Window {
|
|
|
this->SetDirty();
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
GameSettings *PatchesSelectionWindow::patches_ptr = NULL;
|
|
|
const int PatchesSelectionWindow::SETTINGTREE_LEFT_OFFSET = 5;
|
|
|
const int PatchesSelectionWindow::SETTINGTREE_TOP_OFFSET = 47;
|
|
|
int PatchesSelectionWindow::patches_max = 0;
|
|
|
|
|
|
static const Widget _patches_selection_widgets[] = {
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_MAUVE, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
|
{ WWT_CAPTION, RESIZE_NONE, COLOUR_MAUVE, 11, 369, 0, 13, STR_CONFIG_PATCHES_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
|
{ WWT_PANEL, RESIZE_NONE, COLOUR_MAUVE, 0, 369, 14, 41, 0x0, STR_NULL},
|