@@ -417,6 +417,24 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear class filter if the selected class is not included in the filter.
|
||||||
|
* @param object_class Object class select.
|
||||||
|
*/
|
||||||
|
void ClearFilterIsClassNotIncluded(ObjectClassID object_class)
|
||||||
|
{
|
||||||
|
/* Filter is not enabled */
|
||||||
|
if (!this->object_classes.IsFilterEnabled()) return;
|
||||||
|
|
||||||
|
for (auto oc : this->object_classes) {
|
||||||
|
if (oc == object_class) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->ClearEditBox(WID_BO_FILTER);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select the specified object class.
|
* Select the specified object class.
|
||||||
* @param object_class Object class select.
|
* @param object_class Object class select.
|
||||||
@@ -456,6 +474,22 @@ public:
|
|||||||
this->UpdateButtons(_selected_object_class, _selected_object_index, _selected_object_view);
|
this->UpdateButtons(_selected_object_class, _selected_object_index, _selected_object_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scrolls #WID_BO_SCROLLBAR so that the selected class is visible.
|
||||||
|
*/
|
||||||
|
void EnsureSelectedClassIsVisible()
|
||||||
|
{
|
||||||
|
uint pos = 0;
|
||||||
|
for (auto object_class : this->object_classes) {
|
||||||
|
if (object_class == _selected_object_class) {
|
||||||
|
this->vscroll->SetCount(this->object_classes.size());
|
||||||
|
this->vscroll->ScrollTowards(pos);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateSelectSize()
|
void UpdateSelectSize()
|
||||||
{
|
{
|
||||||
if (_selected_object_index == -1) {
|
if (_selected_object_index == -1) {
|
||||||
@@ -760,8 +794,10 @@ void ShowBuildObjectPickerAndSelect(const ObjectSpec *spec)
|
|||||||
|
|
||||||
BuildObjectWindow *w = AllocateWindowDescFront<BuildObjectWindow>(&_build_object_desc, 0, true);
|
BuildObjectWindow *w = AllocateWindowDescFront<BuildObjectWindow>(&_build_object_desc, 0, true);
|
||||||
if (w != nullptr) {
|
if (w != nullptr) {
|
||||||
|
w->ClearFilterIsClassNotIncluded(spec->cls_id);
|
||||||
w->SelectOtherClass(spec->cls_id);
|
w->SelectOtherClass(spec->cls_id);
|
||||||
w->SelectOtherObject(spec_id);
|
w->SelectOtherObject(spec_id);
|
||||||
|
w->EnsureSelectedClassIsVisible();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2755,6 +2755,22 @@ EventState Window::HandleEditBoxKey(int wid, WChar key, uint16 keycode)
|
|||||||
return ES_HANDLED;
|
return ES_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear editbox widget.
|
||||||
|
* @param wid Editbox widget.
|
||||||
|
* @return if the Editbox was successfully cleared
|
||||||
|
*/
|
||||||
|
bool Window::ClearEditBox(int wid)
|
||||||
|
{
|
||||||
|
QueryString *query = this->GetQueryString(wid);
|
||||||
|
if (query == nullptr) return false;
|
||||||
|
|
||||||
|
query->text.DeleteAll();
|
||||||
|
this->SetWidgetDirty(wid);
|
||||||
|
this->OnEditboxChanged(wid);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Focus a window by its class and window number (if it is open).
|
* Focus a window by its class and window number (if it is open).
|
||||||
* @param cls Window class.
|
* @param cls Window class.
|
||||||
|
@@ -506,6 +506,7 @@ public:
|
|||||||
bool SetFocusedWidget(int widget_index);
|
bool SetFocusedWidget(int widget_index);
|
||||||
|
|
||||||
EventState HandleEditBoxKey(int wid, WChar key, uint16 keycode);
|
EventState HandleEditBoxKey(int wid, WChar key, uint16 keycode);
|
||||||
|
bool ClearEditBox(int wid);
|
||||||
virtual void InsertTextString(int wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end);
|
virtual void InsertTextString(int wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end);
|
||||||
|
|
||||||
void HandleButtonClick(byte widget);
|
void HandleButtonClick(byte widget);
|
||||||
|
Reference in New Issue
Block a user