summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2007-04-19 18:51:40 +0000
committerbelugas <belugas@openttd.org>2007-04-19 18:51:40 +0000
commit8082f4c11a2784a7b60ba575da4e10c95ae375cb (patch)
tree1448e4c9564efa9366eabc287433a62745602f85
parenta50f8bac27ccacc650faba1fce865267f6e789d4 (diff)
downloadopenttd-8082f4c11a2784a7b60ba575da4e10c95ae375cb.tar.xz
(svn r9679) -Codechange: use enums to identify transparency widgets and add a bit of documentation (patch by Wolf01)
-rw-r--r--src/transparency_gui.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp
index ab4f40554..a797e1487 100644
--- a/src/transparency_gui.cpp
+++ b/src/transparency_gui.cpp
@@ -12,6 +12,23 @@
#include "sound.h"
#include "variables.h"
+enum TransparencyToolbarWidgets{
+ /* Widgets not toggled when pressing the X key */
+ TTW_WIDGET_SIGNS = 3, ///< Make signs background transparent
+
+ /* Widgets toggled when pressing the X key */
+ TTW_WIDGET_TREES, ///< Make trees transparent
+ TTW_WIDGET_HOUSES, ///< Make houses transparent
+ TTW_WIDGET_INDUSTRIES, ///< Make Industries transparent
+ TTW_WIDGET_BUILDINGS, ///< Make player buildings and structures transparent
+ TTW_WIDGET_BRIDGES, ///< Make bridges transparent
+ TTW_WIDGET_STRUCTURES, ///< Make unmovable structures transparent
+};
+
+/** Toggle the bits of the transparencies variable
+ * when clicking on a widget, and play a sound
+ * @param widget been clicked.
+ */
static void Transparent_Click(byte widget)
{
TOGGLEBIT(_transparent_opt, widget);
@@ -22,15 +39,17 @@ static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
case WE_PAINT:
- for (uint i = 0; i < 7; i++) {
- SetWindowWidgetLoweredState(w, i + 3, HASBIT(_transparent_opt, i));
+ /* must be sure that the widgets show the transparency variable changes
+ * also when we use shortcuts */
+ for (uint i = TTW_WIDGET_SIGNS; i < TTW_WIDGET_STRUCTURES; i++) {
+ SetWindowWidgetLoweredState(w, i, HASBIT(_transparent_opt, i - TTW_WIDGET_SIGNS));
}
DrawWindowWidgets(w);
break;
case WE_CLICK:
- if (e->we.click.widget >= 3) {
- Transparent_Click(e->we.click.widget - 3);
+ if (e->we.click.widget >= TTW_WIDGET_SIGNS) {
+ Transparent_Click(e->we.click.widget - TTW_WIDGET_SIGNS);
MarkWholeScreenDirty();
}
break;
@@ -42,7 +61,8 @@ static const Widget _transparency_widgets[] = {
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 162, 0, 13, STR_TRANSPARENCY_TOOLB, STR_018C_WINDOW_TITLE_DRAG_THIS},
{WWT_STICKYBOX, RESIZE_NONE, 7, 163, 174, 0, 13, STR_NULL, STR_STICKY_BUTTON},
-/* transparency widgets: transparent signs, trees, houses, industries, player's buildings */
+/* transparency widgets:
+ * transparent signs, trees, houses, industries, player's buildings, bridges and unmovable structures */
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_PLACE_SIGN, STR_TRANSPARENT_SIGNS_DESC},
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_PLANTTREES, STR_TRANSPARENT_TREES_DESC},
{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_TOWN, STR_TRANSPARENT_HOUSES_DESC},