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