From d63d9c98e7fd2630e64dc266a278be02375e381f Mon Sep 17 00:00:00 2001
From: Torsten Dreyer <Torsten@t3r.de>
Date: Sun, 22 Jan 2012 18:29:11 +0100
Subject: [PATCH] Local/Global Weather Menu cleanup

- use just a single "Weather" menu item
- add buttons to switch between global and local weather dialogs
- Rename Global Weather to Basic Weather
- Rename Local Weather to Advanced Weather
---
 gui/dialogs/local_weather_tiles.xml | 24 +++++++++++++++-
 gui/dialogs/weather.xml             | 44 +++++++++++++++++++++++------
 gui/menubar.xml                     | 39 +++++--------------------
 3 files changed, 65 insertions(+), 42 deletions(-)

diff --git a/gui/dialogs/local_weather_tiles.xml b/gui/dialogs/local_weather_tiles.xml
index cbf4acfe1..c21db9feb 100644
--- a/gui/dialogs/local_weather_tiles.xml
+++ b/gui/dialogs/local_weather_tiles.xml
@@ -539,7 +539,7 @@
    </binding>
   </button>
 
-<button>
+  <button>
    <x>200</x>
    <y>0</y>
    <legend>Show winds</legend>
@@ -553,6 +553,28 @@
    </binding>
   </button>
 
+  <button>
+   <x>290</x>
+   <y>0</y>
+    <legend>Basic Weather --></legend>
+    <default>false</default>
+    <binding>
+      <command>nasal</command>
+      <script>if (getprop("/nasal/local_weather/loaded",0)) local_weather.clear_all()</script>
+    </binding>
+    <binding>
+      <command>property-assign</command>
+      <property>/nasal/local_weather/enabled</property>
+      <value type="bool">false</value>
+    </binding>
+    <binding>
+      <command>dialog-show</command>
+      <dialog-name>weather</dialog-name>
+    </binding>
+    <binding>
+      <command>dialog-close</command>
+    </binding>
+  </button>
  </group>
 
 
diff --git a/gui/dialogs/weather.xml b/gui/dialogs/weather.xml
index 5b56ade46..908ab6f4c 100644
--- a/gui/dialogs/weather.xml
+++ b/gui/dialogs/weather.xml
@@ -19,7 +19,7 @@
     </empty>
 
     <text>
-      <label>Global Troposphere Weather Conditions</label>
+      <label>Basic Troposphere Weather Conditions</label>
     </text>
 
     <empty>
@@ -1862,14 +1862,40 @@
 
   <hrule/>
 
-  <button>
-    <legend>Close</legend>
-    <default>true</default>
-    <key>Esc</key>
-    <binding>
-      <command>dialog-close</command>
-    </binding>
-  </button>
+  <group>
+    <empty>
+      <stretch>true</stretch>
+    </empty>
+    <layout>hbox</layout>
+    <button>
+      <legend>Close</legend>
+      <default>true</default>
+      <key>Esc</key>
+      <binding>
+        <command>dialog-close</command>
+      </binding>
+    </button>
+
+    <button>
+      <legend>Advanced Weather --></legend>
+      <default>false</default>
+      <binding>
+        <command>property-assign</command>
+        <property>/nasal/local_weather/enabled</property>
+        <value type="bool">true</value>
+      </binding>
+      <binding>
+        <command>dialog-show</command>
+        <dialog-name>local_weather_tiles</dialog-name>
+      </binding>
+      <binding>
+        <command>dialog-close</command>
+      </binding>
+    </button>
+    <empty>
+      <stretch>true</stretch>
+    </empty>
+  </group>
 
   <nasal>
     <open><![CDATA[
diff --git a/gui/menubar.xml b/gui/menubar.xml
index 398e61df9..c221d71dd 100644
--- a/gui/menubar.xml
+++ b/gui/menubar.xml
@@ -298,50 +298,25 @@
 		<label>Environment</label>
 		<name>environment</name>
 
-		<!--<item>
-			<label>Weather Scenario</label>
-			<binding>
-				<command>dialog-show</command>
-				<dialog-name>weather_scenario</dialog-name>
-			</binding>
-		</item>
-
 		<item>
-			<label>Weather Conditions</label>
-			<binding>
-				<command>dialog-show</command>
-				<dialog-name>weather</dialog-name>
-			</binding>
-		</item>-->
-
-		<item>
-			<label>Global Weather</label>
+			<label>Weather</label>
 			<name>global-weather</name>
 			<binding>
+				<condition>
+					<not><property>/nasal/local_weather/enabled</property></not>
+				</condition>
 				<command>dialog-show</command>
 				<dialog-name>weather</dialog-name>
 			</binding>
-		</item>
-
-		<item>
-			<label>Local Weather</label>
-			<name>local_weather_tiles</name>
-			<enabled>false</enabled>
 			<binding>
+				<condition>
+					<property>/nasal/local_weather/enabled</property>
+				</condition>
 				<command>dialog-show</command>
 				<dialog-name>local_weather_tiles</dialog-name>
 			</binding>
 		</item>
 
-		<item>
-			<label>Local Weather Settings</label>
-			<name>local_weather_config</name>
-			<binding>
-				<command>dialog-show</command>
-				<dialog-name>local_weather_config</dialog-name>
-			</binding>
-		</item>
-
 		<item>
 			<label>Time Settings</label>
 			<name>time-settings</name>