Mercurial > hg > openttd
changeset 5126:034523e0293e draft
(svn r7207) -Codechange: Pass the (unchanged) windowpointer to the console window and do it only once.
author | Darkvater <Darkvater@openttd.org> |
---|---|
date | Sat, 18 Nov 2006 17:07:05 +0000 |
parents | 23f9c36e71e9 |
children | 2c67b184f1c7 |
files | console.c console.h window.c |
diffstat | 3 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/console.c +++ b/console.c @@ -152,7 +152,7 @@ break; case WKC_CTRL | WKC_RETURN: _iconsole_mode = (_iconsole_mode == ICONSOLE_FULL) ? ICONSOLE_OPENED : ICONSOLE_FULL; - IConsoleResize(); + IConsoleResize(w); MarkWholeScreenDirty(); break; case (WKC_CTRL | 'V'): @@ -283,9 +283,9 @@ CloseConsoleLogIfActive(); } -void IConsoleResize(void) +void IConsoleResize(Window *w) { - _iconsole_win = FindWindowById(WC_CONSOLE, 0); + assert(_iconsole_win == w); switch (_iconsole_mode) { case ICONSOLE_OPENED:
--- a/console.h +++ b/console.h @@ -118,7 +118,7 @@ void IConsoleInit(void); void IConsoleFree(void); void IConsoleClearBuffer(void); -void IConsoleResize(void); +void IConsoleResize(Window *w); void IConsoleSwitch(void); void IConsoleClose(void); void IConsoleOpen(void);
--- a/window.c +++ b/window.c @@ -20,7 +20,7 @@ static Window _windows[25]; Window *_z_windows[lengthof(_windows)]; -Window **_last_z_window; // always points to the next free space in the z-array +Window **_last_z_window; ///< always points to the next free space in the z-array void CDECL SetWindowWidgetsDisabledState(Window *w, bool disab_stat, int widgets, ...) { @@ -1886,8 +1886,8 @@ continue; // don't modify top,left } - IConsoleResize(); - + /* XXX - this probably needs something more sane. For example specying + * in a 'backup'-desc that the window should always be centred. */ switch (w->window_class) { case WC_MAIN_TOOLBAR: top = w->top; @@ -1916,6 +1916,10 @@ left = (neww - w->width) >> 1; break; + case WC_CONSOLE: + IConsoleResize(w); + break; + default: left = w->left; if (left + (w->width >> 1) >= neww) left = neww - w->width;