mirror of https://github.com/OpenTTD/OpenTTD
(svn r18318) -Codechange: add an enum value for manual window placement
parent
a427ab751d
commit
458c73aecb
|
@ -158,7 +158,7 @@ static const struct NWidgetPart _nested_console_window_widgets[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WindowDesc _console_window_desc(
|
static const WindowDesc _console_window_desc(
|
||||||
0, 0, 0, 0,
|
WDP_MANUAL, WDP_MANUAL, 0, 0,
|
||||||
WC_CONSOLE, WC_NONE,
|
WC_CONSOLE, WC_NONE,
|
||||||
0,
|
0,
|
||||||
_nested_console_window_widgets, lengthof(_nested_console_window_widgets)
|
_nested_console_window_widgets, lengthof(_nested_console_window_widgets)
|
||||||
|
|
|
@ -179,14 +179,14 @@ static const NWidgetPart _nested_highscore_widgets[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WindowDesc _highscore_desc(
|
static const WindowDesc _highscore_desc(
|
||||||
0, 0, 641, 481,
|
WDP_MANUAL, WDP_MANUAL, 641, 481,
|
||||||
WC_HIGHSCORE, WC_NONE,
|
WC_HIGHSCORE, WC_NONE,
|
||||||
0,
|
0,
|
||||||
_nested_highscore_widgets, lengthof(_nested_highscore_widgets)
|
_nested_highscore_widgets, lengthof(_nested_highscore_widgets)
|
||||||
);
|
);
|
||||||
|
|
||||||
static const WindowDesc _endgame_desc(
|
static const WindowDesc _endgame_desc(
|
||||||
0, 0, 641, 481,
|
WDP_MANUAL, WDP_MANUAL, 641, 481,
|
||||||
WC_ENDSCREEN, WC_NONE,
|
WC_ENDSCREEN, WC_NONE,
|
||||||
0,
|
0,
|
||||||
_nested_highscore_widgets, lengthof(_nested_highscore_widgets)
|
_nested_highscore_widgets, lengthof(_nested_highscore_widgets)
|
||||||
|
|
|
@ -200,7 +200,7 @@ static const struct NWidgetPart _nested_main_window_widgets[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WindowDesc _main_window_desc(
|
static const WindowDesc _main_window_desc(
|
||||||
0, 0, 0, 0,
|
WDP_MANUAL, WDP_MANUAL, 0, 0,
|
||||||
WC_MAIN_WINDOW, WC_NONE,
|
WC_MAIN_WINDOW, WC_NONE,
|
||||||
0,
|
0,
|
||||||
_nested_main_window_widgets, lengthof(_nested_main_window_widgets)
|
_nested_main_window_widgets, lengthof(_nested_main_window_widgets)
|
||||||
|
|
|
@ -497,7 +497,7 @@ static const NWidgetPart _nested_errmsg_widgets[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WindowDesc _errmsg_desc(
|
static const WindowDesc _errmsg_desc(
|
||||||
0, 0, 240, 46, // x/y position is not used.
|
WDP_MANUAL, WDP_MANUAL, 240, 46,
|
||||||
WC_ERRMSG, WC_NONE,
|
WC_ERRMSG, WC_NONE,
|
||||||
0,
|
0,
|
||||||
_nested_errmsg_widgets, lengthof(_nested_errmsg_widgets)
|
_nested_errmsg_widgets, lengthof(_nested_errmsg_widgets)
|
||||||
|
@ -517,7 +517,7 @@ static const NWidgetPart _nested_errmsg_face_widgets[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WindowDesc _errmsg_face_desc(
|
static const WindowDesc _errmsg_face_desc(
|
||||||
0, 0, 334, 137, // x/y position is not used.
|
WDP_MANUAL, WDP_MANUAL, 334, 137,
|
||||||
WC_ERRMSG, WC_NONE,
|
WC_ERRMSG, WC_NONE,
|
||||||
0,
|
0,
|
||||||
_nested_errmsg_face_widgets, lengthof(_nested_errmsg_face_widgets)
|
_nested_errmsg_face_widgets, lengthof(_nested_errmsg_face_widgets)
|
||||||
|
@ -764,7 +764,7 @@ static const NWidgetPart _nested_tooltips_widgets[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WindowDesc _tool_tips_desc(
|
static const WindowDesc _tool_tips_desc(
|
||||||
100, 100, 0, 0, // Coordinates and sizes are not used,
|
WDP_MANUAL, WDP_MANUAL, 0, 0, // Coordinates and sizes are not used,
|
||||||
WC_TOOLTIPS, WC_NONE,
|
WC_TOOLTIPS, WC_NONE,
|
||||||
0,
|
0,
|
||||||
_nested_tooltips_widgets, lengthof(_nested_tooltips_widgets)
|
_nested_tooltips_widgets, lengthof(_nested_tooltips_widgets)
|
||||||
|
|
|
@ -543,7 +543,7 @@ static const NWidgetPart _nested_chat_window_widgets[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WindowDesc _chat_window_desc(
|
static const WindowDesc _chat_window_desc(
|
||||||
WDP_CENTER, 0, 640, 14, // x, y, width, height
|
WDP_MANUAL, WDP_MANUAL, 640, 14, // x, y, width, height
|
||||||
WC_SEND_NETWORK_MSG, WC_NONE,
|
WC_SEND_NETWORK_MSG, WC_NONE,
|
||||||
0,
|
0,
|
||||||
_nested_chat_window_widgets, lengthof(_nested_chat_window_widgets)
|
_nested_chat_window_widgets, lengthof(_nested_chat_window_widgets)
|
||||||
|
|
|
@ -105,8 +105,8 @@ static const NWidgetPart _nested_normal_news_widgets[] = {
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
};
|
};
|
||||||
|
|
||||||
static WindowDesc _normal_news_desc(
|
static const WindowDesc _normal_news_desc(
|
||||||
WDP_CENTER, 476, 430, 170,
|
WDP_MANUAL, WDP_MANUAL, 430, 170,
|
||||||
WC_NEWS_WINDOW, WC_NONE,
|
WC_NEWS_WINDOW, WC_NONE,
|
||||||
0,
|
0,
|
||||||
_nested_normal_news_widgets, lengthof(_nested_normal_news_widgets)
|
_nested_normal_news_widgets, lengthof(_nested_normal_news_widgets)
|
||||||
|
@ -132,8 +132,8 @@ static const NWidgetPart _nested_vehicle_news_widgets[] = {
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
};
|
};
|
||||||
|
|
||||||
static WindowDesc _vehicle_news_desc(
|
static const WindowDesc _vehicle_news_desc(
|
||||||
WDP_CENTER, 476, 430, 170,
|
WDP_MANUAL, WDP_MANUAL, 430, 170,
|
||||||
WC_NEWS_WINDOW, WC_NONE,
|
WC_NEWS_WINDOW, WC_NONE,
|
||||||
0,
|
0,
|
||||||
_nested_vehicle_news_widgets, lengthof(_nested_vehicle_news_widgets)
|
_nested_vehicle_news_widgets, lengthof(_nested_vehicle_news_widgets)
|
||||||
|
@ -163,8 +163,8 @@ static const NWidgetPart _nested_company_news_widgets[] = {
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
};
|
};
|
||||||
|
|
||||||
static WindowDesc _company_news_desc(
|
static const WindowDesc _company_news_desc(
|
||||||
WDP_CENTER, 476, 430, 170,
|
WDP_MANUAL, WDP_MANUAL, 430, 170,
|
||||||
WC_NEWS_WINDOW, WC_NONE,
|
WC_NEWS_WINDOW, WC_NONE,
|
||||||
0,
|
0,
|
||||||
_nested_company_news_widgets, lengthof(_nested_company_news_widgets)
|
_nested_company_news_widgets, lengthof(_nested_company_news_widgets)
|
||||||
|
@ -186,15 +186,15 @@ static const NWidgetPart _nested_thin_news_widgets[] = {
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
};
|
};
|
||||||
|
|
||||||
static WindowDesc _thin_news_desc(
|
static const WindowDesc _thin_news_desc(
|
||||||
WDP_CENTER, 476, 430, 130,
|
WDP_MANUAL, WDP_MANUAL, 430, 130,
|
||||||
WC_NEWS_WINDOW, WC_NONE,
|
WC_NEWS_WINDOW, WC_NONE,
|
||||||
0,
|
0,
|
||||||
_nested_thin_news_widgets, lengthof(_nested_thin_news_widgets)
|
_nested_thin_news_widgets, lengthof(_nested_thin_news_widgets)
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Small news items. */
|
/* Small news items. */
|
||||||
static NWidgetPart _nested_small_news_widgets[] = {
|
static const NWidgetPart _nested_small_news_widgets[] = {
|
||||||
/* Caption + close box */
|
/* Caption + close box */
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE, NTW_CLOSEBOX),
|
NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE, NTW_CLOSEBOX),
|
||||||
|
@ -210,8 +210,8 @@ static NWidgetPart _nested_small_news_widgets[] = {
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
};
|
};
|
||||||
|
|
||||||
static WindowDesc _small_news_desc(
|
static const WindowDesc _small_news_desc(
|
||||||
WDP_CENTER, 476, 280, 87,
|
WDP_MANUAL, WDP_MANUAL, 280, 87,
|
||||||
WC_NEWS_WINDOW, WC_NONE,
|
WC_NEWS_WINDOW, WC_NONE,
|
||||||
0,
|
0,
|
||||||
_nested_small_news_widgets, lengthof(_nested_small_news_widgets)
|
_nested_small_news_widgets, lengthof(_nested_small_news_widgets)
|
||||||
|
@ -223,7 +223,7 @@ static WindowDesc _small_news_desc(
|
||||||
struct NewsSubtypeData {
|
struct NewsSubtypeData {
|
||||||
NewsType type; ///< News category @see NewsType
|
NewsType type; ///< News category @see NewsType
|
||||||
NewsFlag flags; ///< Initial NewsFlags bits @see NewsFlag
|
NewsFlag flags; ///< Initial NewsFlags bits @see NewsFlag
|
||||||
WindowDesc *desc; ///< Window description for displaying this news.
|
const WindowDesc *desc; ///< Window description for displaying this news.
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -339,6 +339,12 @@ struct NewsWindow : Window {
|
||||||
GfxFillRect(r.left, r.bottom, r.right, r.bottom, 0xD7);
|
GfxFillRect(r.left, r.bottom, r.right, r.bottom, 0xD7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 };
|
||||||
|
return pt;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void OnPaint()
|
virtual void OnPaint()
|
||||||
{
|
{
|
||||||
this->DrawWidgets();
|
this->DrawWidgets();
|
||||||
|
@ -560,9 +566,7 @@ static void ShowNewspaper(NewsItem *ni)
|
||||||
SoundFx sound = _news_type_data[_news_subtype_data[ni->subtype].type].sound;
|
SoundFx sound = _news_type_data[_news_subtype_data[ni->subtype].type].sound;
|
||||||
if (sound != 0) SndPlayFx(sound);
|
if (sound != 0) SndPlayFx(sound);
|
||||||
|
|
||||||
WindowDesc *desc = _news_subtype_data[ni->subtype].desc;
|
new NewsWindow(_news_subtype_data[ni->subtype].desc, ni);
|
||||||
desc->top = _screen.height;
|
|
||||||
new NewsWindow(desc, ni);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Show news item in the ticker */
|
/** Show news item in the ticker */
|
||||||
|
|
|
@ -235,7 +235,7 @@ static const NWidgetPart _nested_main_status_widgets[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WindowDesc _main_status_desc(
|
static const WindowDesc _main_status_desc(
|
||||||
WDP_CENTER, 0, 640, 12,
|
WDP_MANUAL, WDP_MANUAL, 640, 12,
|
||||||
WC_STATUS_BAR, WC_NONE,
|
WC_STATUS_BAR, WC_NONE,
|
||||||
WDF_UNCLICK_BUTTONS | WDF_NO_FOCUS,
|
WDF_UNCLICK_BUTTONS | WDF_NO_FOCUS,
|
||||||
_nested_main_status_widgets, lengthof(_nested_main_status_widgets)
|
_nested_main_status_widgets, lengthof(_nested_main_status_widgets)
|
||||||
|
|
|
@ -1376,7 +1376,7 @@ static const NWidgetPart _nested_toolbar_normal_widgets[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WindowDesc _toolb_normal_desc(
|
static const WindowDesc _toolb_normal_desc(
|
||||||
0, 0, 640, 22,
|
WDP_MANUAL, WDP_MANUAL, 640, 22,
|
||||||
WC_MAIN_TOOLBAR, WC_NONE,
|
WC_MAIN_TOOLBAR, WC_NONE,
|
||||||
WDF_NO_FOCUS,
|
WDF_NO_FOCUS,
|
||||||
_nested_toolbar_normal_widgets, lengthof(_nested_toolbar_normal_widgets)
|
_nested_toolbar_normal_widgets, lengthof(_nested_toolbar_normal_widgets)
|
||||||
|
@ -1599,7 +1599,7 @@ static const NWidgetPart _nested_toolb_scen_widgets[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WindowDesc _toolb_scen_desc(
|
static const WindowDesc _toolb_scen_desc(
|
||||||
0, 0, 640, 22,
|
WDP_MANUAL, WDP_MANUAL, 640, 22,
|
||||||
WC_MAIN_TOOLBAR, WC_NONE,
|
WC_MAIN_TOOLBAR, WC_NONE,
|
||||||
WDF_UNCLICK_BUTTONS | WDF_NO_FOCUS,
|
WDF_UNCLICK_BUTTONS | WDF_NO_FOCUS,
|
||||||
_nested_toolb_scen_widgets, lengthof(_nested_toolb_scen_widgets)
|
_nested_toolb_scen_widgets, lengthof(_nested_toolb_scen_widgets)
|
||||||
|
|
|
@ -159,6 +159,7 @@ enum WindowDefaultFlag {
|
||||||
* Special values for 'left' and 'top' to cause a specific placement
|
* Special values for 'left' and 'top' to cause a specific placement
|
||||||
*/
|
*/
|
||||||
enum WindowDefaultPosition {
|
enum WindowDefaultPosition {
|
||||||
|
WDP_MANUAL, ///< Manually align the window (so no automatic location finding)
|
||||||
WDP_AUTO = -1, ///< Find a place automatically
|
WDP_AUTO = -1, ///< Find a place automatically
|
||||||
WDP_CENTER = -2, ///< Center the window (left/right or top/bottom)
|
WDP_CENTER = -2, ///< Center the window (left/right or top/bottom)
|
||||||
WDP_ALIGN_TBR = -3, ///< Align the right side of the window with the right side of the main toolbar
|
WDP_ALIGN_TBR = -3, ///< Align the right side of the window with the right side of the main toolbar
|
||||||
|
|
Loading…
Reference in New Issue