|
@@ -122,49 +122,49 @@ struct SignListWindow : Window, SignList
|
|
|
uint icon_left = 4 + (rtl ? r.right - this->text_offset : r.left);
|
|
|
uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT : this->text_offset);
|
|
|
uint text_right = r.right - (rtl ? this->text_offset : WD_FRAMERECT_RIGHT);
|
|
|
|
|
|
/* At least one sign available. */
|
|
|
for (uint16 i = this->vscroll.GetPosition(); this->vscroll.IsVisible(i) && i < this->vscroll.GetCount(); i++) {
|
|
|
const Sign *si = this->signs[i];
|
|
|
|
|
|
if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, icon_left, y + sprite_offset_y);
|
|
|
|
|
|
SetDParam(0, si->index);
|
|
|
DrawString(text_left, text_right, y, STR_SIGN_NAME, TC_YELLOW);
|
|
|
y += this->resize.step_height;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void SetStringParameters(int widget) const
|
|
|
{
|
|
|
if (widget == SLW_CAPTION) SetDParam(0, this->vscroll.GetCount());
|
|
|
}
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
|
|
{
|
|
|
if (widget == SLW_LIST) {
|
|
|
uint id_v = (pt.y - this->GetWidget<NWidgetBase>(SLW_LIST)->pos_y - WD_FRAMERECT_TOP) / this->resize.step_height;
|
|
|
|
|
|
if (id_v >= this->vscroll.GetCapacity()) return;
|
|
|
id_v += this->vscroll.GetPosition();
|
|
|
if (id_v >= this->vscroll.GetCount()) return;
|
|
|
|
|
|
const Sign *si = this->signs[id_v];
|
|
|
ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnResize()
|
|
|
{
|
|
|
this->vscroll.SetCapacityFromWidget(this, SLW_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
|
|
|
}
|
|
|
|
|
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case SLW_LIST: {
|
|
|
Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON);
|
|
|
this->text_offset = WD_FRAMETEXT_LEFT + spr_dim.width + 2; // 2 pixels space between icon and the sign text.
|
|
@@ -307,49 +307,49 @@ struct SignWindow : QueryStringBaseWindo
|
|
|
if (this->cur_sign == this->signs[i]->index) {
|
|
|
/* We've found the current sign, so return the sign before/after it */
|
|
|
return this->signs[i + (next ? 1 : -1)];
|
|
|
}
|
|
|
}
|
|
|
/* If we haven't found the current sign by now, return the last/first sign */
|
|
|
return this->signs[next ? 0 : this->signs.Length() - 1];
|
|
|
}
|
|
|
|
|
|
virtual void SetStringParameters(int widget) const
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case QUERY_EDIT_SIGN_WIDGET_CAPTION:
|
|
|
SetDParam(0, this->caption);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual void OnPaint()
|
|
|
{
|
|
|
this->DrawWidgets();
|
|
|
if (!this->IsShaded()) this->DrawEditBox(QUERY_EDIT_SIGN_WIDGET_TEXT);
|
|
|
}
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case QUERY_EDIT_SIGN_WIDGET_PREVIOUS:
|
|
|
case QUERY_EDIT_SIGN_WIDGET_NEXT: {
|
|
|
const Sign *si = this->PrevNextSign(widget == QUERY_EDIT_SIGN_WIDGET_NEXT);
|
|
|
|
|
|
/* Rebuild the sign list */
|
|
|
this->signs.ForceRebuild();
|
|
|
this->signs.NeedResort();
|
|
|
this->BuildSignsList();
|
|
|
this->SortSignsList();
|
|
|
|
|
|
/* Scroll to sign and reopen window */
|
|
|
ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
|
|
|
UpdateSignEditWindow(si);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
case QUERY_EDIT_SIGN_WIDGET_DELETE:
|
|
|
/* Only need to set the buffer to null, the rest is handled as the OK button */
|
|
|
RenameSign(this->cur_sign, "");
|
|
|
/* don't delete this, we are deleted in Sign::~Sign() -> DeleteRenameSignWindow() */
|
|
|
break;
|
|
|
|