src/transparency_gui.cpp
branchcpp_gui
changeset 6308 646711c5feaa
parent 6307 f40e88cff863
equal deleted inserted replaced
6307:f40e88cff863 6308:646711c5feaa
    10 #include "viewport.h"
    10 #include "viewport.h"
    11 #include "gfx.h"
    11 #include "gfx.h"
    12 #include "sound.h"
    12 #include "sound.h"
    13 #include "variables.h"
    13 #include "variables.h"
    14 
    14 
       
    15 enum TransparencyToolbarWidgets{
       
    16 	/* Widgets not toggled when pressing the X key */
       
    17 	TTW_WIDGET_SIGNS = 3,    ///< Make signs background transparent
       
    18 
       
    19 	/* Widgets toggled when pressing the X key */
       
    20 	TTW_WIDGET_TREES,        ///< Make trees transparent
       
    21 	TTW_WIDGET_HOUSES,       ///< Make houses transparent
       
    22 	TTW_WIDGET_INDUSTRIES,   ///< Make Industries transparent
       
    23 	TTW_WIDGET_BUILDINGS,    ///< Make player buildings and structures transparent
       
    24 	TTW_WIDGET_BRIDGES,      ///< Make bridges transparent
       
    25 	TTW_WIDGET_STRUCTURES,   ///< Make unmovable structures transparent
       
    26 };
       
    27 
       
    28 /** Toggle the bits of the transparencies variable
       
    29  * when clicking on a widget, and play a sound
       
    30  * @param widget been clicked.
       
    31  */
    15 static void Transparent_Click(byte widget)
    32 static void Transparent_Click(byte widget)
    16 {
    33 {
    17 	TOGGLEBIT(_transparent_opt, widget);
    34 	TOGGLEBIT(_transparent_opt, widget);
    18 	SndPlayFx(SND_15_BEEP);
    35 	SndPlayFx(SND_15_BEEP);
    19 }
    36 }
    20 
    37 
    21 static void TransparencyToolbWndProc(BaseWindow *w, WindowEvent *e)
    38 static void TransparencyToolbWndProc(BaseWindow *w, WindowEvent *e)
    22 {
    39 {
    23 	switch (e->event) {
    40 	switch (e->event) {
    24 		case WE_PAINT:
    41 		case WE_PAINT:
    25 			for (uint i = 0; i < 7; i++) {
    42 			/* must be sure that the widgets show the transparency variable changes
    26 				w->SetWidgetLoweredState(i + 3, HASBIT(_transparent_opt, i));
    43 			 * also when we use shortcuts */
       
    44 			for (uint i = TTW_WIDGET_SIGNS; i < TTW_WIDGET_STRUCTURES; i++) {
       
    45 				w->SetWidgetLoweredState(i, HASBIT(_transparent_opt, i - TTW_WIDGET_SIGNS));
    27 			}
    46 			}
    28 			w->DrawWidgets();
    47 			w->DrawWidgets();
    29 			break;
    48 			break;
    30 
    49 
    31 		case WE_CLICK:
    50 		case WE_CLICK:
    32 			if (e->we.click.widget >= 3) {
    51 			if (e->we.click.widget >= TTW_WIDGET_SIGNS) {
    33 				Transparent_Click(e->we.click.widget - 3);
    52 				Transparent_Click(e->we.click.widget - TTW_WIDGET_SIGNS);
    34 				MarkWholeScreenDirty();
    53 				MarkWholeScreenDirty();
    35 			}
    54 			}
    36 			break;
    55 			break;
    37 	}
    56 	}
    38 }
    57 }
    40 static const OldWidget _transparency_widgets[] = {
    59 static const OldWidget _transparency_widgets[] = {
    41 { WWT_CLOSEBOX,   RESIZE_NONE,  7,   0,  10,   0,  13, STR_00C5,                 STR_018B_CLOSE_WINDOW},
    60 { WWT_CLOSEBOX,   RESIZE_NONE,  7,   0,  10,   0,  13, STR_00C5,                 STR_018B_CLOSE_WINDOW},
    42 {  WWT_CAPTION,   RESIZE_NONE,  7,  11, 162,   0,  13, STR_TRANSPARENCY_TOOLB,   STR_018C_WINDOW_TITLE_DRAG_THIS},
    61 {  WWT_CAPTION,   RESIZE_NONE,  7,  11, 162,   0,  13, STR_TRANSPARENCY_TOOLB,   STR_018C_WINDOW_TITLE_DRAG_THIS},
    43 {WWT_STICKYBOX,   RESIZE_NONE,  7, 163, 174,   0,  13, STR_NULL,                 STR_STICKY_BUTTON},
    62 {WWT_STICKYBOX,   RESIZE_NONE,  7, 163, 174,   0,  13, STR_NULL,                 STR_STICKY_BUTTON},
    44 
    63 
    45 /* transparency widgets: transparent signs, trees, houses, industries, player's buildings */
    64 /* transparency widgets:
       
    65  * transparent signs, trees, houses, industries, player's buildings, bridges and unmovable structures */
    46 {   WWT_IMGBTN,   RESIZE_NONE,  7,   0,  21,  14,  35, SPR_IMG_PLACE_SIGN,   STR_TRANSPARENT_SIGNS_DESC},
    66 {   WWT_IMGBTN,   RESIZE_NONE,  7,   0,  21,  14,  35, SPR_IMG_PLACE_SIGN,   STR_TRANSPARENT_SIGNS_DESC},
    47 {   WWT_IMGBTN,   RESIZE_NONE,  7,  22,  43,  14,  35, SPR_IMG_PLANTTREES,   STR_TRANSPARENT_TREES_DESC},
    67 {   WWT_IMGBTN,   RESIZE_NONE,  7,  22,  43,  14,  35, SPR_IMG_PLANTTREES,   STR_TRANSPARENT_TREES_DESC},
    48 {   WWT_IMGBTN,   RESIZE_NONE,  7,  44,  65,  14,  35, SPR_IMG_TOWN,         STR_TRANSPARENT_HOUSES_DESC},
    68 {   WWT_IMGBTN,   RESIZE_NONE,  7,  44,  65,  14,  35, SPR_IMG_TOWN,         STR_TRANSPARENT_HOUSES_DESC},
    49 {   WWT_IMGBTN,   RESIZE_NONE,  7,  66,  87,  14,  35, SPR_IMG_INDUSTRY,     STR_TRANSPARENT_INDUSTRIES_DESC},
    69 {   WWT_IMGBTN,   RESIZE_NONE,  7,  66,  87,  14,  35, SPR_IMG_INDUSTRY,     STR_TRANSPARENT_INDUSTRIES_DESC},
    50 {   WWT_IMGBTN,   RESIZE_NONE,  7,  88, 109,  14,  35, SPR_IMG_COMPANY_LIST, STR_TRANSPARENT_BUILDINGS_DESC},
    70 {   WWT_IMGBTN,   RESIZE_NONE,  7,  88, 109,  14,  35, SPR_IMG_COMPANY_LIST, STR_TRANSPARENT_BUILDINGS_DESC},