(svn r21179) -Fix [FS#4201] (r69): if the main toolbar's location is configurable, why isn't the statusbar's location configurable?

pull/155/head
rubidium 14 years ago
parent 2a29b99681
commit 9bdf6a36f4

@ -1304,6 +1304,10 @@ STR_CONFIG_SETTING_TOOLBAR_POS :{LTBLUE}Positio
STR_CONFIG_SETTING_TOOLBAR_POS_LEFT :Left
STR_CONFIG_SETTING_TOOLBAR_POS_CENTER :Centre
STR_CONFIG_SETTING_TOOLBAR_POS_RIGHT :Right
STR_CONFIG_SETTING_STATUSBAR_POS :{LTBLUE}Position of statusbar: {ORANGE}{STRING1}
STR_CONFIG_SETTING_STATUSBAR_POS_LEFT :Left
STR_CONFIG_SETTING_STATUSBAR_POS_CENTER :Centre
STR_CONFIG_SETTING_STATUSBAR_POS_RIGHT :Right
STR_CONFIG_SETTING_SNAP_RADIUS :{LTBLUE}Window snap radius: {ORANGE}{STRING1} px
STR_CONFIG_SETTING_SNAP_RADIUS_DISABLED :{LTBLUE}Window snap radius: {ORANGE}disabled
STR_CONFIG_SETTING_SOFT_LIMIT :{LTBLUE}Window soft limit (non-sticky): {ORANGE}{STRING1}

@ -681,14 +681,22 @@ static void IniSaveSettingList(IniFile *ini, const char *grpname, StringList *li
}
}
/* Begin - Callback Functions for the various settings
* virtual PositionMainToolbar function, calls the right one.*/
/* Begin - Callback Functions for the various settings. */
/** Reposition the main toolbar as the setting changed. */
static bool v_PositionMainToolbar(int32 p1)
{
if (_game_mode != GM_MENU) PositionMainToolbar(NULL);
return true;
}
/** Reposition the statusbar as the setting changed. */
static bool v_PositionStatusbar(int32 p1)
{
if (_game_mode != GM_MENU) PositionStatusbar(NULL);
return true;
}
static bool PopulationInLabelActive(int32 p1)
{
UpdateAllTownVirtCoords();

@ -1300,6 +1300,7 @@ static SettingEntry _settings_ui[] = {
SettingEntry("gui.errmsg_duration"),
SettingEntry("gui.hover_delay"),
SettingEntry("gui.toolbar_pos"),
SettingEntry("gui.statusbar_pos"),
SettingEntry("gui.pause_on_newgame"),
SettingEntry("gui.advanced_vehicle_list"),
SettingEntry("gui.timetable_in_ticks"),

@ -65,6 +65,7 @@ struct GUISettings {
uint8 loading_indicators; ///< show loading indicators
uint8 default_rail_type; ///< the default rail type for the rail GUI
uint8 toolbar_pos; ///< position of toolbars, 0=left, 1=center, 2=right
uint8 statusbar_pos; ///< position of statusbar, 0=left, 1=center, 2=right
uint8 window_snap_radius; ///< windows snap at each other if closer than this
uint8 window_soft_limit; ///< soft limit of maximum number of non-stickied non-vital windows (0 = no limit)
bool always_build_infrastructure; ///< always allow building of infrastructure, even when you do not have the vehicles for it

@ -95,11 +95,12 @@ struct StatusBarWindow : Window {
this->reminder_timeout = REMINDER_STOP;
this->InitNested(desc);
PositionStatusbar(this);
}
virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number)
{
Point pt = { (_screen.width - max(sm_width, desc->default_width)) / 2, _screen.height - sm_height };
Point pt = { 0, _screen.height - sm_height };
return pt;
}
@ -238,7 +239,7 @@ static const NWidgetPart _nested_main_status_widgets[] = {
EndContainer(),
};
static const WindowDesc _main_status_desc(
static WindowDesc _main_status_desc(
WDP_MANUAL, 640, 12,
WC_STATUS_BAR, WC_NONE,
WDF_UNCLICK_BUTTONS | WDF_NO_FOCUS,
@ -254,6 +255,8 @@ bool IsNewsTickerShown()
return w != NULL && w->ticker_scroll < StatusBarWindow::TICKER_STOP;
}
int16 *_preferred_statusbar_size = &_main_status_desc.default_width; ///< Pointer to the default size for the status toolbar.
void ShowStatusBar()
{
new StatusBarWindow(&_main_status_desc);

@ -24,4 +24,6 @@ enum StatusBarInvalidate {
bool IsNewsTickerShown();
void ShowStatusBar();
extern int16 *_preferred_statusbar_size;
#endif /* STATUSBAR_GUI_H */

@ -11,6 +11,7 @@
/* Begin - Callback Functions for the various settings */
static bool v_PositionMainToolbar(int32 p1);
static bool v_PositionStatusbar(int32 p1);
static bool PopulationInLabelActive(int32 p1);
static bool RedrawScreen(int32 p1);
static bool RedrawSmallmap(int32 p1);
@ -568,6 +569,7 @@ const SettingDesc _settings[] = {
SDTC_VAR(gui.errmsg_duration, SLE_UINT8, S, 0, 5, 0, 20, 0, STR_CONFIG_SETTING_ERRMSG_DURATION, NULL),
SDTC_VAR(gui.hover_delay, SLE_UINT8, S, D0, 2, 1, 5, 0, STR_CONFIG_SETTING_HOVER_DELAY, NULL),
SDTC_VAR(gui.toolbar_pos, SLE_UINT8, S, MS, 1, 0, 2, 0, STR_CONFIG_SETTING_TOOLBAR_POS, v_PositionMainToolbar),
SDTC_VAR(gui.statusbar_pos, SLE_UINT8, S, MS, 1, 0, 2, 0, STR_CONFIG_SETTING_STATUSBAR_POS, v_PositionStatusbar),
SDTC_VAR(gui.window_snap_radius, SLE_UINT8, S, D0, 10, 1, 32, 0, STR_CONFIG_SETTING_SNAP_RADIUS, NULL),
SDTC_VAR(gui.window_soft_limit, SLE_UINT8, S, D0, 20, 5, 255, 1, STR_CONFIG_SETTING_SOFT_LIMIT, NULL),
SDTC_BOOL(gui.population_in_label, S, 0, true, STR_CONFIG_SETTING_POPULATION_IN_LABEL, PopulationInLabelActive),

@ -33,6 +33,7 @@
#include "newgrf_debug.h"
#include "hotkeys.h"
#include "toolbar_gui.h"
#include "statusbar_gui.h"
#include "table/sprites.h"
@ -2642,27 +2643,49 @@ void ReInitAllWindows()
}
/**
* (Re)position main toolbar window at the screen
* @param w Window structure of the main toolbar window, may also be \c NULL
* @return X coordinate of left edge of the repositioned toolbar window
* (Re)position a window at the screen.
* @param w Window structure of the window, may also be \c NULL.
* @param clss The class of the window to position.
* @param setting The actual setting used for the window's position.
* @return X coordinate of left edge of the repositioned window.
*/
int PositionMainToolbar(Window *w)
static int PositionWindow(Window *w, WindowClass clss, int setting)
{
DEBUG(misc, 5, "Repositioning Main Toolbar...");
if (w == NULL || w->window_class != WC_MAIN_TOOLBAR) {
w = FindWindowById(WC_MAIN_TOOLBAR, 0);
if (w == NULL || w->window_class != clss) {
w = FindWindowById(clss, 0);
}
switch (_settings_client.gui.toolbar_pos) {
switch (setting) {
case 1: w->left = (_screen.width - w->width) / 2; break;
case 2: w->left = _screen.width - w->width; break;
default: w->left = 0;
default: w->left = 0; break;
}
SetDirtyBlocks(0, 0, _screen.width, w->height); // invalidate the whole top part
SetDirtyBlocks(0, w->top, _screen.width, w->top + w->height); // invalidate the whole row
return w->left;
}
/**
* (Re)position main toolbar window at the screen.
* @param w Window structure of the main toolbar window, may also be \c NULL.
* @return X coordinate of left edge of the repositioned toolbar window.
*/
int PositionMainToolbar(Window *w)
{
DEBUG(misc, 5, "Repositioning Main Toolbar...");
return PositionWindow(w, WC_MAIN_TOOLBAR, _settings_client.gui.toolbar_pos);
}
/**
* (Re)position statusbar window at the screen.
* @param w Window structure of the statusbar window, may also be \c NULL.
* @return X coordinate of left edge of the repositioned statusbar.
*/
int PositionStatusbar(Window *w)
{
DEBUG(misc, 5, "Repositioning statusbar...");
return PositionWindow(w, WC_STATUS_BAR, _settings_client.gui.statusbar_pos);
}
/**
* Switches viewports following vehicles, which get autoreplaced
@ -2718,9 +2741,10 @@ void RelocateAllWindows(int neww, int newh)
break;
case WC_STATUS_BAR:
ResizeWindow(w, Clamp(neww, 320, 640) - w->width, 0);
ResizeWindow(w, min(neww, *_preferred_statusbar_size) - w->width, 0);
top = newh - w->height;
left = (neww - w->width) >> 1;
left = PositionStatusbar(w);
break;
case WC_SEND_NETWORK_MSG:

@ -21,6 +21,7 @@ void ChangeWindowOwner(Owner old_owner, Owner new_owner);
void ResizeWindow(Window *w, int x, int y);
int PositionMainToolbar(Window *w);
int PositionStatusbar(Window *w);
int GetMainViewTop();
int GetMainViewBottom();

Loading…
Cancel
Save