diff options
author | darkvater <darkvater@openttd.org> | 2004-12-15 23:33:04 +0000 |
---|---|---|
committer | darkvater <darkvater@openttd.org> | 2004-12-15 23:33:04 +0000 |
commit | 83981e40b594af221abf78eab41aa41182003b52 (patch) | |
tree | 74df7f1875fe162b316df2d10c6bb505e11cea71 | |
parent | ec94450aef385beb279e5b158389767611112f40 (diff) | |
download | openttd-83981e40b594af221abf78eab41aa41182003b52.tar.xz |
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
-To use the feature add WDF_STICKY_BUTTON to the widget description and update all widget-ID's since sticky button will be widget 2.
-rw-r--r-- | lang/english.txt | 1 | ||||
-rw-r--r-- | main_gui.c | 2 | ||||
-rw-r--r-- | smallmap_gui.c | 13 | ||||
-rw-r--r-- | table/sprites.h | 4 | ||||
-rw-r--r-- | ttd.vcproj | 6 | ||||
-rw-r--r-- | widget.c | 6 | ||||
-rw-r--r-- | window.c | 14 | ||||
-rw-r--r-- | window.h | 15 |
8 files changed, 44 insertions, 17 deletions
diff --git a/lang/english.txt b/lang/english.txt index bc4b44cdd..0400cd341 100644 --- a/lang/english.txt +++ b/lang/english.txt @@ -418,6 +418,7 @@ STR_0189 :{BLACK}{SMALLDOWNARROW} STR_018A_CAN_T_CHANGE_SERVICING :{WHITE}Can't change servicing interval... STR_018B_CLOSE_WINDOW :{BLACK}Close window STR_018C_WINDOW_TITLE_DRAG_THIS :{BLACK}Window title - drag this to move window +STR_STICKY_BUTTON :{BLACK}Mark this window as undeletable for the 'Close All Windows' key STR_018D_DEMOLISH_BUILDINGS_ETC :{BLACK}Demolish buildings etc. on a square of land STR_018E_LOWER_A_CORNER_OF_LAND :{BLACK}Lower a corner of land STR_018F_RAISE_A_CORNER_OF_LAND :{BLACK}Raise a corner of land diff --git a/main_gui.c b/main_gui.c index 3bc7349a5..97e516c05 100644 --- a/main_gui.c +++ b/main_gui.c @@ -888,7 +888,7 @@ bool DoZoomInOutWindow(int how, Window *w) break; case WC_EXTRA_VIEW_PORT: wt = FindWindowById(WC_EXTRA_VIEW_PORT, w->window_number); - button = 4; + button = 5; break; } diff --git a/smallmap_gui.c b/smallmap_gui.c index 515a80a29..063a3da90 100644 --- a/smallmap_gui.c +++ b/smallmap_gui.c @@ -1003,7 +1003,8 @@ void ShowSmallMap() /* Extra ViewPort Window Stuff */ static Widget _extra_view_port_widgets[] = { { WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, -{ WWT_CAPTION, 14, 11, 299, 0, 13, STR_EXTRA_VIEW_PORT_TITLE, STR_018C_WINDOW_TITLE_DRAG_THIS}, +{ WWT_CAPTION, 14, 11, 287, 0, 13, STR_EXTRA_VIEW_PORT_TITLE, STR_018C_WINDOW_TITLE_DRAG_THIS}, +{ WWT_STICKYBOX, 14, 288, 299, 0, 13, 0x0, STR_STICKY_BUTTON}, { WWT_PANEL, 14, 0, 299, 14, 233, 0x0, STR_NULL}, { WWT_6, 14, 2, 297, 16, 231, 0x0, STR_NULL}, { WWT_PANEL, 14, 0, 21, 234, 255, 0x2DF, STR_017F_ZOOM_THE_VIEW_IN}, @@ -1027,15 +1028,15 @@ static void ExtraViewPortWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: { switch(e->click.widget) { - case 4: { /* zoom in */ + case 5: { /* zoom in */ DoZoomInOutWindow(ZOOM_IN,w); } break; - case 5: { /* zoom out */ + case 6: { /* zoom out */ DoZoomInOutWindow(ZOOM_OUT,w); } break; - case 6: { /* location button (move main view to same spot as this view) */ + case 7: { /* location button (move main view to same spot as this view) */ Window * w2 = FindWindowById(WC_MAIN_WINDOW, 0); int x = WP(w,vp_d).scrollpos_x; // Where is the main looking at int y = WP(w,vp_d).scrollpos_y; @@ -1044,7 +1045,7 @@ static void ExtraViewPortWndProc(Window *w, WindowEvent *e) WP(w2,vp_d).scrollpos_x = x - (w2->viewport->virtual_width - (294 <<vp->zoom) )/2; WP(w2,vp_d).scrollpos_y = y - (w2->viewport->virtual_height - (214 << vp->zoom) )/2; } break; - case 7: { /* inverse location button (move this view to same spot as main view) */ + case 8: { /* inverse location button (move this view to same spot as main view) */ Window * w2 = FindWindowById(WC_MAIN_WINDOW, 0); int x = WP(w2,vp_d).scrollpos_x; int y = WP(w2,vp_d).scrollpos_y; @@ -1060,7 +1061,7 @@ static void ExtraViewPortWndProc(Window *w, WindowEvent *e) static const WindowDesc _extra_view_port_desc = { -1,-1, 300, 256, WC_EXTRA_VIEW_PORT,0, - WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, + WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, _extra_view_port_widgets, ExtraViewPortWndProc }; diff --git a/table/sprites.h b/table/sprites.h index 9978445ab..61b4307ad 100644 --- a/table/sprites.h +++ b/table/sprites.h @@ -48,8 +48,8 @@ enum Sprites { SPR_BLOT = SPR_OPENTTD_BASE + 32, // colored circle (mainly used as vehicle profit marker and for sever compatibility) - SPR_PIN_UP = SPR_OPENTTD_BASE + 62, // pin icon - SPR_PIN_DOWN = SPR_OPENTTD_BASE + 63, + SPR_PIN_UP = SPR_OPENTTD_BASE + 62, // pin icon + SPR_PIN_DOWN = SPR_OPENTTD_BASE + 63, /* Network GUI sprites */ diff --git a/ttd.vcproj b/ttd.vcproj index e1feecd02..68564ea43 100644 --- a/ttd.vcproj +++ b/ttd.vcproj @@ -456,6 +456,9 @@ </FileConfiguration>
</File>
<File
+ RelativePath=".\map.c">
+ </File>
+ <File
RelativePath=".\md5.c">
</File>
<File
@@ -1168,6 +1171,9 @@ RelativePath="macros.h">
</File>
<File
+ RelativePath=".\map.h">
+ </File>
+ <File
RelativePath="md5.h">
</File>
<File
@@ -348,6 +348,12 @@ void DrawWindowWidgets(Window *w) goto restore_dparam; } + case WWT_STICKYBOX: { + DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (cur_click & 1) ? 0x20 : 0); + DrawSprite((cur_click & 1) ? SPR_PIN_UP :SPR_PIN_DOWN, r.left + 2, r.top + 3); + break; + } + case WWT_CAPTION: { DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, 0x10); DrawFrameRect(r.left+1, r.top+1, r.right-1, r.bottom-1, wi->color, (w->caption_color == 0xFF) ? 0x60 : 0x70); @@ -61,6 +61,14 @@ void DispatchLeftClickEvent(Window *w, int x, int y) { } } } + + if (w->desc_flags & WDF_STICKY_BUTTON) { + if (e.click.widget == 2) { + w->click_state ^= (1 << e.click.widget); + w->flags4 ^= WF_STICKY; + InvalidateWidget(w, e.click.widget); + } + } } else { w->wndproc(w, &e); } @@ -296,7 +304,8 @@ restart:; assert(w < _last_window); if (w->window_class != WC_MAIN_WINDOW && w->window_class != WC_MAIN_TOOLBAR && - w->window_class != WC_STATUS_BAR && w->window_class != WC_NEWS_WINDOW) { + w->window_class != WC_STATUS_BAR && w->window_class != WC_NEWS_WINDOW && + !(w->flags4 & WF_STICKY) ) { DeleteWindow(w); goto restart; @@ -1324,7 +1333,8 @@ void DeleteNonVitalWindows() w->window_class != WC_MAIN_TOOLBAR && w->window_class != WC_STATUS_BAR && w->window_class != WC_TOOLBAR_MENU && - w->window_class != WC_TOOLTIPS) { + w->window_class != WC_TOOLTIPS && + (w->flags4 & WF_STICKY) == 0) { // do not delete windows which are 'pinned' DeleteWindow(w); w = _windows; } else { @@ -157,11 +157,12 @@ typedef struct WindowDesc { } WindowDesc; enum { - WDF_STD_TOOLTIPS = 1, /* use standard routine when displaying tooltips */ - WDF_DEF_WIDGET = 2, /* default widget control for some widgets in the on click event */ - WDF_STD_BTN = 4, /* default handling for close and drag widgets (widget no 0 and 1) */ + WDF_STD_TOOLTIPS = 1, /* use standard routine when displaying tooltips */ + WDF_DEF_WIDGET = 2, /* default widget control for some widgets in the on click event */ + WDF_STD_BTN = 4, /* default handling for close and drag widgets (widget no 0 and 1) */ WDF_RESTORE_DPARAM = 8, /* when drawing widgets, restore the dparam so all widgets recieve the same set of them */ WDF_UNCLICK_BUTTONS=16, /* Unclick buttons when the window event times out */ + WDF_STICKY_BUTTON =32, /* Set window to sticky mode; they are not closed unless closed with 'X' (widget 2) */ }; /* can be used as x or y coordinates to cause a specific placement */ @@ -356,7 +357,8 @@ enum WindowWidgetTypes { WWT_CAPTION = 10, WWT_HSCROLLBAR = 11, - WWT_LAST = 12, /* Last Item. use WIDGETS_END to fill up padding!! */ + WWT_STICKYBOX = 12, + WWT_LAST = 13, /* Last Item. use WIDGETS_END to fill up padding!! */ WWT_MASK = 31, @@ -376,7 +378,8 @@ enum WindowFlags { WF_SCROLL_MIDDLE = 1 << 6, WF_HSCROLL = 1 << 7, WF_SIZING = 1 << 8, - + WF_STICKY = 1 << 9, + WF_DISABLE_VP_SCROLL = 1 << 10, WF_WHITE_BORDER_ONE = 1 << 11, @@ -458,7 +461,7 @@ Window *GetCallbackWnd(); void DeleteNonVitalWindows(); /* window.c */ -VARDEF Window _windows[20]; +VARDEF Window _windows[25]; VARDEF Window *_last_window; VARDEF Point _cursorpos_drag_start; |