glx@9574: /* $Id$ */ glx@9574: glx@9574: #include "stdafx.h" glx@9574: #include "openttd.h" glx@9574: #include "table/sprites.h" glx@9574: #include "table/strings.h" glx@9574: #include "functions.h" glx@9574: #include "window.h" glx@9574: #include "gui.h" glx@9574: #include "viewport.h" glx@9574: #include "gfx.h" glx@9574: #include "sound.h" glx@9574: #include "variables.h" glx@9574: rubidium@9601: enum TransparencyToolbarWidgets{ rubidium@9601: /* Widgets not toggled when pressing the X key */ rubidium@9601: TTW_WIDGET_SIGNS = 3, ///< Make signs background transparent rubidium@9601: rubidium@9601: /* Widgets toggled when pressing the X key */ rubidium@9601: TTW_WIDGET_TREES, ///< Make trees transparent rubidium@9601: TTW_WIDGET_HOUSES, ///< Make houses transparent rubidium@9601: TTW_WIDGET_INDUSTRIES, ///< Make Industries transparent rubidium@9601: TTW_WIDGET_BUILDINGS, ///< Make player buildings and structures transparent rubidium@9601: TTW_WIDGET_BRIDGES, ///< Make bridges transparent rubidium@9601: TTW_WIDGET_STRUCTURES, ///< Make unmovable structures transparent glx@9629: TTW_WIDGET_LOADING, ///< Make loading indicators transperent rubidium@9620: TTW_WIDGET_END, ///< End of toggle buttons rubidium@9601: }; rubidium@9601: rubidium@9601: /** Toggle the bits of the transparencies variable rubidium@9601: * when clicking on a widget, and play a sound rubidium@9601: * @param widget been clicked. rubidium@9601: */ glx@9574: static void Transparent_Click(byte widget) glx@9574: { glx@9574: TOGGLEBIT(_transparent_opt, widget); glx@9574: SndPlayFx(SND_15_BEEP); glx@9574: } glx@9574: glx@9574: static void TransparencyToolbWndProc(Window *w, WindowEvent *e) glx@9574: { glx@9574: switch (e->event) { glx@9574: case WE_PAINT: rubidium@9601: /* must be sure that the widgets show the transparency variable changes rubidium@9601: * also when we use shortcuts */ rubidium@9620: for (uint i = TTW_WIDGET_SIGNS; i < TTW_WIDGET_END; i++) { rubidium@9601: SetWindowWidgetLoweredState(w, i, HASBIT(_transparent_opt, i - TTW_WIDGET_SIGNS)); glx@9574: } glx@9574: DrawWindowWidgets(w); glx@9574: break; glx@9574: glx@9574: case WE_CLICK: rubidium@9601: if (e->we.click.widget >= TTW_WIDGET_SIGNS) { rubidium@9601: Transparent_Click(e->we.click.widget - TTW_WIDGET_SIGNS); glx@9574: MarkWholeScreenDirty(); glx@9574: } glx@9574: break; glx@9574: } glx@9574: } glx@9574: glx@9574: static const Widget _transparency_widgets[] = { glx@9574: { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, glx@9629: { WWT_CAPTION, RESIZE_NONE, 7, 11, 184, 0, 13, STR_TRANSPARENCY_TOOLB, STR_018C_WINDOW_TITLE_DRAG_THIS}, glx@9629: {WWT_STICKYBOX, RESIZE_NONE, 7, 185, 196, 0, 13, STR_NULL, STR_STICKY_BUTTON}, glx@9574: rubidium@9601: /* transparency widgets: glx@9629: * transparent signs, trees, houses, industries, player's buildings, bridges, unmovable structures and loading indicators */ rubidium@9620: { WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_SIGN, STR_TRANSPARENT_SIGNS_DESC}, glx@9574: { WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_PLANTTREES, STR_TRANSPARENT_TREES_DESC}, glx@9574: { WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_TOWN, STR_TRANSPARENT_HOUSES_DESC}, glx@9574: { WWT_IMGBTN, RESIZE_NONE, 7, 66, 87, 14, 35, SPR_IMG_INDUSTRY, STR_TRANSPARENT_INDUSTRIES_DESC}, glx@9574: { WWT_IMGBTN, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_COMPANY_LIST, STR_TRANSPARENT_BUILDINGS_DESC}, glx@9574: { WWT_IMGBTN, RESIZE_NONE, 7, 110, 152, 14, 35, SPR_IMG_BRIDGE, STR_TRANSPARENT_BRIDGES_DESC}, glx@9574: { WWT_IMGBTN, RESIZE_NONE, 7, 153, 174, 14, 35, SPR_IMG_TRANSMITTER, STR_TRANSPARENT_STRUCTURES_DESC}, glx@9629: { WWT_IMGBTN, RESIZE_NONE, 7, 175, 196, 14, 35, SPR_IMG_TRAINLIST, STR_TRANSPARENT_LOADING_DESC}, glx@9574: glx@9574: { WIDGETS_END}, glx@9574: }; glx@9574: glx@9574: static const WindowDesc _transparency_desc = { rubidium@9694: WDP_ALIGN_TBR, 58+36, 197, 36, 197, 36, glx@9574: WC_TRANSPARENCY_TOOLBAR, WC_NONE, glx@9574: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, glx@9574: _transparency_widgets, glx@9574: TransparencyToolbWndProc glx@9574: }; glx@9574: glx@9574: void ShowTransparencyToolbar(void) glx@9574: { glx@9574: AllocateWindowDescFront(&_transparency_desc, 0); glx@9574: }