mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-04 05:15:21 +00:00
(svn r14679) -Fix [FS#2431]: opening the OSK on the chatbox did disable map scrolling (with keyboard) until another window with editbox was opened and closed. Just "refcount" the open edit boxes instead of setting/clearing a bit when opening/closing a window.
This commit is contained in:
parent
bfe9743f20
commit
1599ade7ca
@ -153,7 +153,7 @@ struct IConsoleWindow : Window
|
||||
IConsoleWindow(const WindowDesc *desc) : Window(desc)
|
||||
{
|
||||
_iconsole_mode = ICONSOLE_OPENED;
|
||||
SetBit(_no_scroll, SCROLL_CON); // override cursor arrows; the gamefield will not scroll
|
||||
_no_scroll++; // override cursor arrows; the gamefield will not scroll
|
||||
|
||||
this->height = _screen.height / 3;
|
||||
this->width = _screen.width;
|
||||
@ -162,7 +162,7 @@ struct IConsoleWindow : Window
|
||||
~IConsoleWindow()
|
||||
{
|
||||
_iconsole_mode = ICONSOLE_CLOSED;
|
||||
ClrBit(_no_scroll, SCROLL_CON);
|
||||
_no_scroll--;
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
|
@ -1068,7 +1068,6 @@ struct QueryStringWindow : public QueryStringBaseWindow
|
||||
QueryStringWindow(uint16 size, const WindowDesc *desc, Window *parent) : QueryStringBaseWindow(size, desc)
|
||||
{
|
||||
this->parent = parent;
|
||||
SetBit(_no_scroll, SCROLL_EDIT);
|
||||
|
||||
this->FindWindowPlacementAndResize(desc);
|
||||
}
|
||||
@ -1142,7 +1141,6 @@ struct QueryStringWindow : public QueryStringBaseWindow
|
||||
this->parent = NULL; // so parent doesn't try to delete us again
|
||||
parent->OnQueryTextFinished(NULL);
|
||||
}
|
||||
ClrBit(_no_scroll, SCROLL_EDIT);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1443,7 +1441,6 @@ struct SaveLoadWindow : public QueryStringBaseWindow {
|
||||
};
|
||||
|
||||
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
|
||||
SetBit(_no_scroll, SCROLL_SAVE);
|
||||
|
||||
/* Use an array to define what will be the current file type being handled
|
||||
* by current file mode */
|
||||
@ -1505,7 +1502,6 @@ struct SaveLoadWindow : public QueryStringBaseWindow {
|
||||
if (_pause_game >= 0) DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
|
||||
}
|
||||
FiosFreeSavegameList();
|
||||
ClrBit(_no_scroll, SCROLL_SAVE);
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
|
@ -277,7 +277,6 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
|
||||
InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, 0);
|
||||
|
||||
InvalidateWindowData(WC_NEWS_WINDOW, 0, this->height);
|
||||
SetBit(_no_scroll, SCROLL_CHAT); // do not scroll the game with the arrow-keys
|
||||
|
||||
_chat_tab_completion_active = false;
|
||||
|
||||
@ -287,7 +286,6 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
|
||||
~NetworkChatWindow ()
|
||||
{
|
||||
InvalidateWindowData(WC_NEWS_WINDOW, 0, 0);
|
||||
ClrBit(_no_scroll, SCROLL_CHAT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,7 +66,6 @@ struct OskWindow : public Window {
|
||||
/* make a copy in case we need to reset later */
|
||||
this->orig_str_buf = strdup(this->qs->text.buf);
|
||||
|
||||
SetBit(_no_scroll, SCROLL_EDIT);
|
||||
/* Not needed by default. */
|
||||
this->DisableWidget(OSK_WIDGET_SPECIAL);
|
||||
|
||||
|
@ -199,7 +199,6 @@ struct SignWindow : QueryStringBaseWindow, SignList {
|
||||
|
||||
SignWindow(const WindowDesc *desc, const Sign *si) : QueryStringBaseWindow(MAX_LENGTH_SIGN_NAME_BYTES, desc)
|
||||
{
|
||||
SetBit(_no_scroll, SCROLL_EDIT);
|
||||
this->caption = STR_280B_EDIT_SIGN_TEXT;
|
||||
this->afilter = CS_ALPHANUMERAL;
|
||||
this->LowerWidget(QUERY_EDIT_SIGN_WIDGET_TEXT);
|
||||
@ -208,11 +207,6 @@ struct SignWindow : QueryStringBaseWindow, SignList {
|
||||
this->FindWindowPlacementAndResize(desc);
|
||||
}
|
||||
|
||||
~SignWindow()
|
||||
{
|
||||
ClrBit(_no_scroll, SCROLL_EDIT);
|
||||
}
|
||||
|
||||
void UpdateSignEditWindow(const Sign *si)
|
||||
{
|
||||
char *last_of = &this->edit_str_buf[this->edit_str_size - 1]; // points to terminating '\0'
|
||||
|
@ -461,7 +461,13 @@ Window::~Window()
|
||||
if (this->viewport != NULL) DeleteWindowViewport(this);
|
||||
|
||||
this->SetDirty();
|
||||
free(this->widget);
|
||||
|
||||
if (this->widget != NULL) {
|
||||
for (const Widget *wi = this->widget; wi->type != WWT_LAST; wi++) {
|
||||
if (wi->type == WWT_EDITBOX) _no_scroll--;
|
||||
}
|
||||
free(this->widget);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -690,6 +696,10 @@ static void AssignWidgetToWindow(Window *w, const Widget *widget)
|
||||
w->widget = MallocT<Widget>(index);
|
||||
memcpy(w->widget, widget, sizeof(*w->widget) * index);
|
||||
w->widget_count = index - 1;
|
||||
|
||||
for (const Widget *wi = w->widget; wi->type != WWT_LAST; wi++) {
|
||||
if (wi->type == WWT_EDITBOX) _no_scroll++;
|
||||
}
|
||||
} else {
|
||||
w->widget = NULL;
|
||||
w->widget_count = 0;
|
||||
|
@ -544,18 +544,9 @@ extern Window **_last_z_window;
|
||||
#define FOR_ALL_WINDOWS(wz) for (wz = _z_windows; wz != _last_z_window; wz++)
|
||||
|
||||
/**
|
||||
* In certain windows you navigate with the arrow keys. Do not scroll the
|
||||
* gameview when here. Bitencoded variable that only allows scrolling if all
|
||||
* elements are zero
|
||||
* Disable scrolling of the main viewport when an input-window is active.
|
||||
* This contains the count of windows with a textbox in them.
|
||||
*/
|
||||
enum {
|
||||
SCROLL_CON = 0,
|
||||
SCROLL_EDIT = 1,
|
||||
SCROLL_SAVE = 2,
|
||||
SCROLL_CHAT = 4,
|
||||
};
|
||||
|
||||
/** Disable scrolling of the main viewport when an input-window is active. */
|
||||
extern byte _no_scroll;
|
||||
|
||||
extern Point _cursorpos_drag_start;
|
||||
|
Loading…
Reference in New Issue
Block a user