diff options
author | Jacek Antonelli | 2010-07-31 01:11:11 -0500 |
---|---|---|
committer | Jacek Antonelli | 2010-08-01 00:33:38 -0500 |
commit | b6478ed527c35a817a72f351fae2169ed7ba2827 (patch) | |
tree | d8b4e8ecfa682cba6607d9a6945d0308513dfa1d /linden/indra | |
parent | Added notification option to ignore all LightShare until you change regions. (diff) | |
download | meta-impy-b6478ed527c35a817a72f351fae2169ed7ba2827.zip meta-impy-b6478ed527c35a817a72f351fae2169ed7ba2827.tar.gz meta-impy-b6478ed527c35a817a72f351fae2169ed7ba2827.tar.bz2 meta-impy-b6478ed527c35a817a72f351fae2169ed7ba2827.tar.xz |
Tidied up and documented lightshare.cpp and lightshare.h.
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/lightshare.cpp | 26 | ||||
-rw-r--r-- | linden/indra/newview/lightshare.h | 57 |
2 files changed, 57 insertions, 26 deletions
diff --git a/linden/indra/newview/lightshare.cpp b/linden/indra/newview/lightshare.cpp index b2bbb96..1d87ab1 100644 --- a/linden/indra/newview/lightshare.cpp +++ b/linden/indra/newview/lightshare.cpp | |||
@@ -2,7 +2,7 @@ | |||
2 | * @file lightshare.cpp | 2 | * @file lightshare.cpp |
3 | * @brief Handler for Meta7 Lightshare (region-side Windlight settings). | 3 | * @brief Handler for Meta7 Lightshare (region-side Windlight settings). |
4 | * | 4 | * |
5 | * Copyright (c) 2010, Tom Meta / Meta7 | 5 | * Copyright (c) 2010, Tom Grimshaw (Tom Meta) |
6 | * Copyright (c) 2010, Jacek Antonelli | 6 | * Copyright (c) 2010, Jacek Antonelli |
7 | * | 7 | * |
8 | * The source code in this file ("Source Code") is provided to you | 8 | * The source code in this file ("Source Code") is provided to you |
@@ -30,8 +30,6 @@ | |||
30 | #include "lightshare.h" | 30 | #include "lightshare.h" |
31 | 31 | ||
32 | #include "linden_common.h" | 32 | #include "linden_common.h" |
33 | |||
34 | #include "lluuid.h" | ||
35 | #include "llviewercontrol.h" | 33 | #include "llviewercontrol.h" |
36 | #include "llwaterparammanager.h" | 34 | #include "llwaterparammanager.h" |
37 | #include "llwaterparamset.h" | 35 | #include "llwaterparamset.h" |
@@ -41,7 +39,6 @@ | |||
41 | #include "meta7windlight.h" | 39 | #include "meta7windlight.h" |
42 | 40 | ||
43 | 41 | ||
44 | // The names of the presets where the region settings are stored. | ||
45 | const std::string WindlightMessage::sWaterPresetName = "(Region settings)"; | 42 | const std::string WindlightMessage::sWaterPresetName = "(Region settings)"; |
46 | const std::string WindlightMessage::sSkyPresetName = "(Region settings)"; | 43 | const std::string WindlightMessage::sSkyPresetName = "(Region settings)"; |
47 | 44 | ||
@@ -82,7 +79,7 @@ WindlightMessage::WindlightMessage( LLMessageSystem* msg ) : | |||
82 | 79 | ||
83 | mWater = new LLWaterParamSet(); | 80 | mWater = new LLWaterParamSet(); |
84 | mSky = new LLWLParamSet(); | 81 | mSky = new LLWLParamSet(); |
85 | mWaterNormal = LLUUID(); | 82 | mWaterNormal = new LLUUID(); |
86 | 83 | ||
87 | process_packet(&buf[0]); | 84 | process_packet(&buf[0]); |
88 | process_water(); | 85 | process_water(); |
@@ -97,6 +94,7 @@ WindlightMessage::~WindlightMessage() | |||
97 | { | 94 | { |
98 | delete mWater; | 95 | delete mWater; |
99 | delete mSky; | 96 | delete mSky; |
97 | delete mWaterNormal; | ||
100 | } | 98 | } |
101 | 99 | ||
102 | 100 | ||
@@ -127,8 +125,8 @@ void WindlightMessage::processWindlight(LLMessageSystem* msg, void**) | |||
127 | if( !ignoreTimerHasExpired() ) | 125 | if( !ignoreTimerHasExpired() ) |
128 | { | 126 | { |
129 | // The user recently ignored a windlight message, so ignore | 127 | // The user recently ignored a windlight message, so ignore |
130 | // this one too, and reset the timer. | 128 | // this one too, and restart the timer. |
131 | resetIgnoreTimer(); | 129 | restartIgnoreTimer(); |
132 | delete wl; | 130 | delete wl; |
133 | return; | 131 | return; |
134 | } | 132 | } |
@@ -145,10 +143,8 @@ void WindlightMessage::processWindlight(LLMessageSystem* msg, void**) | |||
145 | // No most recent, so store this and create notification | 143 | // No most recent, so store this and create notification |
146 | // asking the user whether to apply or not. | 144 | // asking the user whether to apply or not. |
147 | sMostRecent = wl; | 145 | sMostRecent = wl; |
148 | LLNotifications::instance() | 146 | LLNotifications::instance().add("ConfirmLightShare", LLSD(), LLSD(), |
149 | .add("ConfirmLightShare", | 147 | boost::bind(&applyCallback, _1, _2)); |
150 | LLSD(), LLSD(), | ||
151 | boost::bind(&applyCallback, _1, _2)); | ||
152 | return; | 148 | return; |
153 | } | 149 | } |
154 | else | 150 | else |
@@ -177,7 +173,7 @@ bool WindlightMessage::applyCallback(const LLSD& notification, | |||
177 | } | 173 | } |
178 | case 1:{ | 174 | case 1:{ |
179 | // "Not Now", ignore until the region stops spamming | 175 | // "Not Now", ignore until the region stops spamming |
180 | resetIgnoreTimer(); | 176 | restartIgnoreTimer(); |
181 | break; | 177 | break; |
182 | } | 178 | } |
183 | case 2:{ | 179 | case 2:{ |
@@ -202,7 +198,7 @@ void WindlightMessage::resetRegion() | |||
202 | 198 | ||
203 | 199 | ||
204 | // static | 200 | // static |
205 | void WindlightMessage::resetIgnoreTimer() | 201 | void WindlightMessage::restartIgnoreTimer() |
206 | { | 202 | { |
207 | F32 time = gSavedSettings.getF32("LightShareIgnoreTimer"); | 203 | F32 time = gSavedSettings.getF32("LightShareIgnoreTimer"); |
208 | sIgnoreTimer->start(); | 204 | sIgnoreTimer->start(); |
@@ -226,7 +222,7 @@ bool WindlightMessage::apply() | |||
226 | water_mgr->addParamSet( sWaterPresetName, *mWater ); | 222 | water_mgr->addParamSet( sWaterPresetName, *mWater ); |
227 | water_mgr->savePreset( sWaterPresetName ); | 223 | water_mgr->savePreset( sWaterPresetName ); |
228 | water_mgr->loadPreset( sWaterPresetName, true ); | 224 | water_mgr->loadPreset( sWaterPresetName, true ); |
229 | water_mgr->setNormalMapID( mWaterNormal ); | 225 | water_mgr->setNormalMapID( *mWaterNormal ); |
230 | 226 | ||
231 | mSky->mName = sSkyPresetName; | 227 | mSky->mName = sSkyPresetName; |
232 | sky_mgr->mAnimator.mIsRunning = false; | 228 | sky_mgr->mAnimator.mIsRunning = false; |
@@ -306,7 +302,7 @@ void WindlightMessage::process_water() | |||
306 | (U8)(mPacket->normalMapTexture[14]), | 302 | (U8)(mPacket->normalMapTexture[14]), |
307 | (U8)(mPacket->normalMapTexture[15])); | 303 | (U8)(mPacket->normalMapTexture[15])); |
308 | 304 | ||
309 | mWaterNormal.set(uuid); | 305 | mWaterNormal->set(uuid); |
310 | } | 306 | } |
311 | 307 | ||
312 | 308 | ||
diff --git a/linden/indra/newview/lightshare.h b/linden/indra/newview/lightshare.h index 0b2965e..f179458 100644 --- a/linden/indra/newview/lightshare.h +++ b/linden/indra/newview/lightshare.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /** | 1 | /** |
2 | * @file lightshare.h | 2 | * @file lightshare.h |
3 | * @brief Public interface for lightshare.cpp | 3 | * @brief WindlightMessage class definition. |
4 | * | 4 | * |
5 | * Copyright (c) 2010, Jacek Antonelli | 5 | * Copyright (c) 2010, Jacek Antonelli |
6 | * | 6 | * |
@@ -29,38 +29,67 @@ | |||
29 | #ifndef LIGHTSHARE_H | 29 | #ifndef LIGHTSHARE_H |
30 | #define LIGHTSHARE_H | 30 | #define LIGHTSHARE_H |
31 | 31 | ||
32 | #include "message.h" | 32 | #include <string> |
33 | #include "meta7windlight.h" | 33 | |
34 | #include "lltimer.h" | 34 | struct Meta7WindlightPacket; |
35 | #include "llwaterparamset.h" | 35 | class LLMessageSystem; |
36 | #include "llwlparamset.h" | 36 | class LLSD; |
37 | class LLTimer; | ||
38 | class LLUUID; | ||
39 | class LLWaterParamSet; | ||
40 | class LLWLParamSet; | ||
37 | 41 | ||
38 | 42 | ||
39 | // Encapsulates a "Windlight" (LightShare) message sent from the | 43 | // Encapsulates a "Windlight" (LightShare) message sent from the |
40 | // server, allowing the settings to be applied at a later time. | 44 | // region, allowing the settings to be applied at a later time. |
41 | // | 45 | // |
42 | class WindlightMessage | 46 | class WindlightMessage |
43 | { | 47 | { |
44 | public: | 48 | public: |
45 | 49 | ||
50 | // Constructs a new WindlightMessage instance from a GenericMessage | ||
51 | // with the "Windlight" method, such as those sent by a | ||
52 | // Lightshare-enabled OpenSim region. | ||
53 | WindlightMessage( LLMessageSystem* msg ); | ||
54 | |||
55 | ~WindlightMessage(); | ||
56 | |||
57 | // The name of the water preset where the region settings are stored. | ||
46 | static const std::string sWaterPresetName; | 58 | static const std::string sWaterPresetName; |
59 | |||
60 | // The name of the sky preset where the region settings are stored. | ||
47 | static const std::string sSkyPresetName; | 61 | static const std::string sSkyPresetName; |
48 | 62 | ||
49 | WindlightMessage( LLMessageSystem* msg ); | 63 | // Message handler for GenericMessage with the "Windlight" method. |
50 | ~WindlightMessage(); | 64 | // Creates and applies a new WindlightMessage (or prompts user). |
51 | static void processWindlight(LLMessageSystem* msg, void**); | 65 | static void processWindlight(LLMessageSystem* msg, void**); |
66 | |||
67 | // Callback when the user interacts with the notification. | ||
52 | static bool applyCallback(const LLSD& notification, | 68 | static bool applyCallback(const LLSD& notification, |
53 | const LLSD& response); | 69 | const LLSD& response); |
70 | |||
71 | // Called after the user has entered a new region, to reset the | ||
72 | // "ignore while in this region" state. | ||
54 | static void resetRegion(); | 73 | static void resetRegion(); |
55 | 74 | ||
75 | // Applies/activates the Windlight settings from the message. | ||
56 | bool apply(); | 76 | bool apply(); |
77 | |||
78 | // Returns true if the message contains valid Windlight settings. | ||
79 | // (But there's no real validation yet, so this is always true.) | ||
57 | bool isValid(); | 80 | bool isValid(); |
58 | 81 | ||
82 | |||
59 | protected: | 83 | protected: |
60 | 84 | ||
61 | static void resetIgnoreTimer(); | 85 | // Restart the timer for temporarily ignoring settings. |
86 | static void restartIgnoreTimer(); | ||
87 | |||
88 | // Returns true if the ignore timer has expired (i.e. new settings | ||
89 | // should not be ignored anymore). | ||
62 | static bool ignoreTimerHasExpired(); | 90 | static bool ignoreTimerHasExpired(); |
63 | 91 | ||
92 | |||
64 | private: | 93 | private: |
65 | 94 | ||
66 | static WindlightMessage* sMostRecent; | 95 | static WindlightMessage* sMostRecent; |
@@ -70,12 +99,18 @@ class WindlightMessage | |||
70 | Meta7WindlightPacket* mPacket; | 99 | Meta7WindlightPacket* mPacket; |
71 | LLWaterParamSet* mWater; | 100 | LLWaterParamSet* mWater; |
72 | LLWLParamSet* mSky; | 101 | LLWLParamSet* mSky; |
73 | LLUUID mWaterNormal; | 102 | LLUUID* mWaterNormal; |
74 | bool mIsValid; | 103 | bool mIsValid; |
75 | 104 | ||
105 | // Converts the message's raw bytes into a Meta7WindlightPacket. | ||
76 | void process_packet( char* buf ); | 106 | void process_packet( char* buf ); |
107 | |||
108 | // Constructs a LLWaterParamSet from the Meta7WindlightPacket. | ||
77 | void process_water(); | 109 | void process_water(); |
110 | |||
111 | // Constructs a LLWLParamSet from the Meta7WindlightPacket. | ||
78 | void process_sky(); | 112 | void process_sky(); |
113 | |||
79 | }; | 114 | }; |
80 | 115 | ||
81 | #endif | 116 | #endif |