mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
(svn r17573) -Codechange: NWID_SELECTION containers have a selected widget-plane, and optionally an index in the nested_array.
This commit is contained in:
parent
d54028fde8
commit
4ff755ac90
@ -1443,7 +1443,7 @@ static const NWidgetPart _nested_company_widgets[] = {
|
|||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(0, 94),
|
NWidget(NWID_SPACER), SetMinimalSize(0, 94),
|
||||||
/* Multi player buttons. */
|
/* Multi player buttons. */
|
||||||
NWidget(NWID_SELECTION),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, -1),
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(NWID_SPACER), SetFill(true, false),
|
NWidget(NWID_SPACER), SetFill(true, false),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, CW_WIDGET_COMPANY_PASSWORD), SetMinimalSize(90, 12), SetPadding(0, 4, 0, 0),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, CW_WIDGET_COMPANY_PASSWORD), SetMinimalSize(90, 12), SetPadding(0, 4, 0, 0),
|
||||||
@ -1458,7 +1458,7 @@ static const NWidgetPart _nested_company_widgets[] = {
|
|||||||
NWidget(NWID_SPACER), SetMinimalSize(0, 8),
|
NWidget(NWID_SPACER), SetMinimalSize(0, 8),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
/* Button bars at the bottom. */
|
/* Button bars at the bottom. */
|
||||||
NWidget(NWID_SELECTION),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, -1),
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, CW_WIDGET_NEW_FACE), SetMinimalSize(90, 12),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, CW_WIDGET_NEW_FACE), SetMinimalSize(90, 12),
|
||||||
SetDataTip(STR_COMPANY_VIEW_NEW_FACE_BUTTON, STR_COMPANY_VIEW_NEW_FACE_TOOLTIP),
|
SetDataTip(STR_COMPANY_VIEW_NEW_FACE_BUTTON, STR_COMPANY_VIEW_NEW_FACE_TOOLTIP),
|
||||||
|
@ -811,7 +811,7 @@ static const NWidgetPart _nested_network_content_list_widgets[] = {
|
|||||||
/* Bottom. */
|
/* Bottom. */
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(NWID_SPACER), SetMinimalSize(10, 0),
|
NWidget(NWID_SPACER), SetMinimalSize(10, 0),
|
||||||
NWidget(NWID_SELECTION),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, -1),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NCLWW_SELECT_ALL), SetMinimalSize(101, 12),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NCLWW_SELECT_ALL), SetMinimalSize(101, 12),
|
||||||
SetDataTip(STR_CONTENT_SELECT_ALL_CAPTION, STR_CONTENT_SELECT_ALL_CAPTION_TOOLTIP),
|
SetDataTip(STR_CONTENT_SELECT_ALL_CAPTION, STR_CONTENT_SELECT_ALL_CAPTION_TOOLTIP),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NCLWW_SELECT_UPDATE), SetMinimalSize(101, 12),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NCLWW_SELECT_UPDATE), SetMinimalSize(101, 12),
|
||||||
|
@ -1296,7 +1296,7 @@ static const NWidgetPart _nested_orders_train_widgets[] = {
|
|||||||
|
|
||||||
/* First button row. */
|
/* First button row. */
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(NWID_SELECTION),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, -1),
|
||||||
/* Unload + (full load, unload) or (refit, service) buttons. */
|
/* Unload + (full load, unload) or (refit, service) buttons. */
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(NWID_LAYERED),
|
NWidget(NWID_LAYERED),
|
||||||
@ -1306,7 +1306,7 @@ static const NWidgetPart _nested_orders_train_widgets[] = {
|
|||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, ORDER_WIDGET_NON_STOP_DROPDOWN), SetMinimalSize(124, 12), SetDataTip(STR_NULL, STR_ORDER_TOOLTIP_NON_STOP),
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, ORDER_WIDGET_NON_STOP_DROPDOWN), SetMinimalSize(124, 12), SetDataTip(STR_NULL, STR_ORDER_TOOLTIP_NON_STOP),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_SELECTION),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, -1),
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(NWID_LAYERED),
|
NWidget(NWID_LAYERED),
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
@ -1433,7 +1433,7 @@ static const NWidgetPart _nested_orders_widgets[] = {
|
|||||||
|
|
||||||
/* First button row. */
|
/* First button row. */
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(NWID_SELECTION),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, -1),
|
||||||
/* Refit + service buttons. */
|
/* Refit + service buttons. */
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, ORDER_WIDGET_REFIT), SetMinimalSize(186, 12), SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, ORDER_WIDGET_REFIT), SetMinimalSize(186, 12), SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP),
|
||||||
|
@ -1558,11 +1558,11 @@ static const NWidgetPart _nested_vehicle_view_widgets[] = {
|
|||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_VERTICAL),
|
NWidget(NWID_VERTICAL),
|
||||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, VVW_WIDGET_CENTER_MAIN_VIEH), SetMinimalSize(18, 18), SetDataTip(SPR_CENTRE_VIEW_VEHICLE, 0x0 /* filled later */),
|
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, VVW_WIDGET_CENTER_MAIN_VIEH), SetMinimalSize(18, 18), SetDataTip(SPR_CENTRE_VIEW_VEHICLE, 0x0 /* filled later */),
|
||||||
NWidget(NWID_SELECTION),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, -1),
|
||||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, VVW_WIDGET_GOTO_DEPOT), SetMinimalSize(18, 18), SetDataTip(0x0 /* filled later */, 0x0 /* filled later */),
|
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, VVW_WIDGET_GOTO_DEPOT), SetMinimalSize(18, 18), SetDataTip(0x0 /* filled later */, 0x0 /* filled later */),
|
||||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, VVW_WIDGET_CLONE_VEH), SetMinimalSize(18, 18), SetDataTip(0x0 /* filled later */, 0x0 /* filled later */),
|
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, VVW_WIDGET_CLONE_VEH), SetMinimalSize(18, 18), SetDataTip(0x0 /* filled later */, 0x0 /* filled later */),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_SELECTION),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, -1),
|
||||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, VVW_WIDGET_REFIT_VEH), SetMinimalSize(18, 18),
|
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, VVW_WIDGET_REFIT_VEH), SetMinimalSize(18, 18),
|
||||||
SetDataTip(SPR_REFIT_VEHICLE, 0x0 /* filled later */),
|
SetDataTip(SPR_REFIT_VEHICLE, 0x0 /* filled later */),
|
||||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, VVW_WIDGET_TURN_AROUND), SetMinimalSize(18, 18),
|
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, VVW_WIDGET_TURN_AROUND), SetMinimalSize(18, 18),
|
||||||
|
@ -1253,6 +1253,12 @@ static inline uint ComputeOffset(uint space, uint max_space)
|
|||||||
*/
|
*/
|
||||||
NWidgetStacked::NWidgetStacked(WidgetType tp) : NWidgetContainer(tp)
|
NWidgetStacked::NWidgetStacked(WidgetType tp) : NWidgetContainer(tp)
|
||||||
{
|
{
|
||||||
|
this->index = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NWidgetStacked::SetIndex(int index)
|
||||||
|
{
|
||||||
|
this->index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NWidgetStacked::SetupSmallestSize(Window *w, bool init_array)
|
void NWidgetStacked::SetupSmallestSize(Window *w, bool init_array)
|
||||||
@ -1301,8 +1307,24 @@ void NWidgetStacked::StoreWidgets(Widget *widgets, int length, bool left_moving,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NWidgetStacked::FillNestedArray(NWidgetBase **array, uint length)
|
||||||
|
{
|
||||||
|
if (this->index >= 0 && (uint)(this->index) < length) array[this->index] = this;
|
||||||
|
NWidgetContainer::FillNestedArray(array, length);
|
||||||
|
}
|
||||||
|
|
||||||
void NWidgetStacked::Draw(const Window *w)
|
void NWidgetStacked::Draw(const Window *w)
|
||||||
{
|
{
|
||||||
|
if (this->type == NWID_SELECTION) {
|
||||||
|
int plane = 0;
|
||||||
|
for (NWidgetBase *child_wid = this->head; child_wid != NULL; plane++, child_wid = child_wid->next) {
|
||||||
|
if (plane == this->shown_plane) {
|
||||||
|
child_wid->Draw(w);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assert(this->type == NWID_LAYERED); // Currently, NWID_SELECTION is not supported.
|
assert(this->type == NWID_LAYERED); // Currently, NWID_SELECTION is not supported.
|
||||||
/* Render from back to front. */
|
/* Render from back to front. */
|
||||||
for (NWidgetBase *child_wid = this->tail; child_wid != NULL; child_wid = child_wid->prev) {
|
for (NWidgetBase *child_wid = this->tail; child_wid != NULL; child_wid = child_wid->prev) {
|
||||||
@ -1313,13 +1335,23 @@ void NWidgetStacked::Draw(const Window *w)
|
|||||||
NWidgetCore *NWidgetStacked::GetWidgetFromPos(int x, int y)
|
NWidgetCore *NWidgetStacked::GetWidgetFromPos(int x, int y)
|
||||||
{
|
{
|
||||||
if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return NULL;
|
if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return NULL;
|
||||||
for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
|
int plane = 0;
|
||||||
NWidgetCore *nwid = child_wid->GetWidgetFromPos(x, y);
|
for (NWidgetBase *child_wid = this->head; child_wid != NULL; plane++, child_wid = child_wid->next) {
|
||||||
if (nwid != NULL) return nwid;
|
if (plane == this->shown_plane) {
|
||||||
|
return child_wid->GetWidgetFromPos(x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Select which plane to show (for #NWID_SELECTION only).
|
||||||
|
* @param plane Plane number to display.
|
||||||
|
*/
|
||||||
|
void NWidgetStacked::SetDisplayedPlane(int plane)
|
||||||
|
{
|
||||||
|
this->shown_plane = plane;
|
||||||
|
}
|
||||||
|
|
||||||
NWidgetPIPContainer::NWidgetPIPContainer(WidgetType tp, NWidContainerFlags flags) : NWidgetContainer(tp)
|
NWidgetPIPContainer::NWidgetPIPContainer(WidgetType tp, NWidContainerFlags flags) : NWidgetContainer(tp)
|
||||||
{
|
{
|
||||||
this->flags = flags;
|
this->flags = flags;
|
||||||
@ -2435,14 +2467,12 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case NWID_SELECTION:
|
|
||||||
case NWID_LAYERED:
|
case NWID_LAYERED:
|
||||||
if (*dest != NULL) return num_used;
|
if (*dest != NULL) return num_used;
|
||||||
*dest = new NWidgetStacked(parts->type);
|
*dest = new NWidgetStacked(parts->type);
|
||||||
*fill_dest = true;
|
*fill_dest = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case WPT_RESIZE: {
|
case WPT_RESIZE: {
|
||||||
NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(*dest);
|
NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(*dest);
|
||||||
if (nwrb != NULL) {
|
if (nwrb != NULL) {
|
||||||
@ -2498,6 +2528,16 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
|
|||||||
*biggest_index = max(*biggest_index, (int)parts->u.widget.index);
|
*biggest_index = max(*biggest_index, (int)parts->u.widget.index);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case NWID_SELECTION: {
|
||||||
|
if (*dest != NULL) return num_used;
|
||||||
|
NWidgetStacked *nws = new NWidgetStacked(parts->type);
|
||||||
|
*dest = nws;
|
||||||
|
*fill_dest = true;
|
||||||
|
nws->SetIndex(parts->u.widget.index);
|
||||||
|
*biggest_index = max(*biggest_index, (int)parts->u.widget.index);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (*dest != NULL) return num_used;
|
if (*dest != NULL) return num_used;
|
||||||
assert((parts->type & WWT_MASK) < WWT_LAST);
|
assert((parts->type & WWT_MASK) < WWT_LAST);
|
||||||
|
@ -377,12 +377,20 @@ class NWidgetStacked : public NWidgetContainer {
|
|||||||
public:
|
public:
|
||||||
NWidgetStacked(WidgetType tp);
|
NWidgetStacked(WidgetType tp);
|
||||||
|
|
||||||
|
void SetIndex(int index);
|
||||||
|
|
||||||
void SetupSmallestSize(Window *w, bool init_array);
|
void SetupSmallestSize(Window *w, bool init_array);
|
||||||
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl);
|
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl);
|
||||||
void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl);
|
void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl);
|
||||||
|
/* virtual */ void FillNestedArray(NWidgetBase **array, uint length);
|
||||||
|
|
||||||
/* virtual */ void Draw(const Window *w);
|
/* virtual */ void Draw(const Window *w);
|
||||||
/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
|
/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
|
||||||
|
|
||||||
|
void SetDisplayedPlane(int plane);
|
||||||
|
|
||||||
|
int shown_plane; ///< Plane being displayed (for #NWID_SELECTION only).
|
||||||
|
int index; ///< If non-negative, index in the #Window::nested_array.
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Nested widget container flags, */
|
/** Nested widget container flags, */
|
||||||
|
Loading…
Reference in New Issue
Block a user