aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llettherebelight.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llettherebelight.h')
-rw-r--r--linden/indra/newview/llettherebelight.h137
1 files changed, 137 insertions, 0 deletions
diff --git a/linden/indra/newview/llettherebelight.h b/linden/indra/newview/llettherebelight.h
new file mode 100644
index 0000000..d83e827
--- /dev/null
+++ b/linden/indra/newview/llettherebelight.h
@@ -0,0 +1,137 @@
1/**
2 * @file llettherebelight.h
3 * @brief WindlightMessage class definition.
4 *
5 * Copyright (c) 2010, Jacek Antonelli
6 *
7 * The source code in this file ("Source Code") is provided to you
8 * under the terms of the GNU General Public License, version 2.0
9 * ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in
10 * this distribution, or online at
11 * http://secondlifegrid.net/programs/open_source/licensing/gplv2
12 *
13 * There are special exceptions to the terms and conditions of the GPL as
14 * it is applied to this Source Code. View the full text of the exception
15 * in the file doc/FLOSS-exception.txt in this software distribution, or
16 * online at
17 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28
29#ifndef LIGHTSHARE_H
30#define LIGHTSHARE_H
31
32#include <string>
33#include "llwlparamset.h"
34#include "llwaterparamset.h"
35#include "lluuid.h"
36
37struct Meta7WindlightPacket;
38
39
40typedef enum wl_scope
41{
42 WL_SCOPE_USER,
43 WL_SCOPE_REGION,
44 WL_SCOPE_PARCEL,
45 WL_SCOPE_RLV
46} WLScope;
47
48struct WLCombined
49{
50 LLWaterParamSet water;
51 LLWLParamSet sky;
52 BOOL enabled;
53};
54
55// Encapsulates a "Windlight" (LightShare) message sent from the
56// region, allowing the settings to be applied at a later time.
57//
58class LightShare
59{
60public:
61 // The meanings of the LightShareAllowed user setting.
62 enum LIGHTSHARE_ALLOWED
63 {
64 LIGHTSHARE_NEVER = 0,
65 LIGHTSHARE_ASK = 1,
66 LIGHTSHARE_ALWAYS = 2,
67 };
68
69 // The name of the preset where the region settings are stored.
70 static const std::string sRegionPresetName;
71 // The name of the preset where the parcel settings are stored.
72 static const std::string sParcelPresetName;
73 // The name of the preset where the RLV settings are stored.
74 static const std::string sRLVPresetName;
75
76 // Constructs a new LightShare instance from a GenericMessage
77 // with the "Windlight" method, such as those sent by a
78 // Lightshare-enabled OpenSim region.
79 LightShare( LLMessageSystem* msg );
80
81 ~LightShare();
82
83 // The name of the preset where the backup settings are stored.
84 static const std::string sBackupWaterPresetName;
85 static const std::string sBackupSkyPresetName;
86
87 // Message handler for GenericMessage with the "Windlight" method.
88 // Creates and applies a new LightShare (or prompts user).
89 static void processWindlight(LLMessageSystem* msg, void**);
90
91 static void applyMaybe(LLWaterParamSet* thisWater, LLUUID* thisVaterNormal, LLWLParamSet* thisSky);
92
93 // Called after the user has entered a new region, to reset the
94 // "ignore while in this region" state.
95 // Also resets/deactivates the Windlight settings in response to the "WindlightReset" method.
96 static void resetRegion();
97
98 // Returns true if the message contains valid Windlight settings.
99 // (But there's no real validation yet, so this is always true.)
100 bool isValid();
101
102 static void apply(LLWaterParamSet * newWater, LLUUID *newWaterNormal, LLWLParamSet *newSky, WLScope scope);
103
104private:
105 static LLTimer* sIgnoreTimer;
106 static bool sIgnoreRegion;
107
108 Meta7WindlightPacket* mPacket;
109 static LLWaterParamSet* mWater;
110 static LLWLParamSet* mSky;
111 static LLUUID* mWaterNormal;
112 bool mIsValid;
113
114 // Callback when the user interacts with the notification.
115 static bool applyCallback(const LLSD& notification, const LLSD& response);
116
117 // Converts the message's raw bytes into a Meta7WindlightPacket.
118 void process_packet( char* buf );
119
120 // Constructs a LLWaterParamSet from the Meta7WindlightPacket.
121 void process_water();
122
123 // Constructs a LLWLParamSet from the Meta7WindlightPacket.
124 void process_sky();
125
126 // Restart the timer for temporarily ignoring settings.
127 static void restartIgnoreTimer();
128
129 // Returns true if the ignore timer has expired (i.e. new settings
130 // should not be ignored anymore).
131 static bool ignoreTimerHasExpired();
132
133 static void mergeWaterSets(LLWaterParamSet* thisSet, LLWaterParamSet* oldSet);
134 static void mergeWLSets(LLWLParamSet* thisSet, LLWLParamSet* oldSet);
135};
136
137#endif