aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMcCabe Maxsted2011-06-23 20:47:21 -0700
committerMcCabe Maxsted2011-06-23 20:47:21 -0700
commitc96afda71bd39e69e1b26849ac5e956d0fd97072 (patch)
tree96ae96e4f54e3951759b856bacdd09e740118f5f
parentUpdated Imp's easter egg chat commands with the new website urls (diff)
downloadmeta-impy-c96afda71bd39e69e1b26849ac5e956d0fd97072.zip
meta-impy-c96afda71bd39e69e1b26849ac5e956d0fd97072.tar.gz
meta-impy-c96afda71bd39e69e1b26849ac5e956d0fd97072.tar.bz2
meta-impy-c96afda71bd39e69e1b26849ac5e956d0fd97072.tar.xz
Created new window for inworld dice rolling in advanced > UI. Todo: add button for 'rocks fall, everybody dies'
-rw-r--r--linden/indra/newview/CMakeLists.txt2
-rw-r--r--linden/indra/newview/app_settings/settings.xml38
-rw-r--r--linden/indra/newview/floaterdice.cpp108
-rw-r--r--linden/indra/newview/floaterdice.h50
-rw-r--r--linden/indra/newview/llviewermenu.cpp29
-rw-r--r--linden/indra/newview/skins/default/xui/en-us/floater_dice.xml15
-rw-r--r--linden/indra/newview/skins/default/xui/en-us/menu_viewer.xml7
7 files changed, 248 insertions, 1 deletions
diff --git a/linden/indra/newview/CMakeLists.txt b/linden/indra/newview/CMakeLists.txt
index b0cb366..46da492 100644
--- a/linden/indra/newview/CMakeLists.txt
+++ b/linden/indra/newview/CMakeLists.txt
@@ -78,6 +78,7 @@ set(viewer_SOURCE_FILES
78 floaterao.cpp 78 floaterao.cpp
79 floaterbusy.cpp 79 floaterbusy.cpp
80 floatercommandline.cpp 80 floatercommandline.cpp
81 floaterdice.cpp
81 floatergriddefault.cpp 82 floatergriddefault.cpp
82 floatergridmanager.cpp 83 floatergridmanager.cpp
83 floaterlocalassetbrowse.cpp 84 floaterlocalassetbrowse.cpp
@@ -535,6 +536,7 @@ set(viewer_HEADER_FILES
535 floaterao.h 536 floaterao.h
536 floaterbusy.h 537 floaterbusy.h
537 floatercommandline.h 538 floatercommandline.h
539 floaterdice.h
538 floatergriddefault.h 540 floatergriddefault.h
539 floatergridmanager.h 541 floatergridmanager.h
540 floaterlocalassetbrowse.h 542 floaterlocalassetbrowse.h
diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml
index a6b782d..eb59254 100644
--- a/linden/indra/newview/app_settings/settings.xml
+++ b/linden/indra/newview/app_settings/settings.xml
@@ -399,6 +399,44 @@
399 <key>Value</key> 399 <key>Value</key>
400 <integer>3</integer> 400 <integer>3</integer>
401 </map> 401 </map>
402 <key>DiceLastCount</key>
403 <map>
404 <key>Comment</key>
405 <string>Last entered dice count</string>
406 <key>Persist</key>
407 <integer>1</integer>
408 <key>Type</key>
409 <string>S32</string>
410 <key>Value</key>
411 <integer>1</integer>
412 </map>
413 <key>DiceLastSides</key>
414 <map>
415 <key>Comment</key>
416 <string>Last entered dice sides</string>
417 <key>Persist</key>
418 <integer>1</integer>
419 <key>Type</key>
420 <string>S32</string>
421 <key>Value</key>
422 <integer>6</integer>
423 </map>
424 <key>DiceFloaterRect</key>
425 <map>
426 <key>Comment</key>
427 <string>Rectangle for dice window</string>
428 <key>Persist</key>
429 <integer>1</integer>
430 <key>Type</key>
431 <string>Rect</string>
432 <key>Value</key>
433 <array>
434 <integer>0</integer>
435 <integer>100</integer>
436 <integer>100</integer>
437 <integer>100</integer>
438 </array>
439 </map>
402 <key>DisableInternalFlyUpAnimation</key> 440 <key>DisableInternalFlyUpAnimation</key>
403 <map> 441 <map>
404 <key>Comment</key> 442 <key>Comment</key>
diff --git a/linden/indra/newview/floaterdice.cpp b/linden/indra/newview/floaterdice.cpp
new file mode 100644
index 0000000..f16a6ca
--- /dev/null
+++ b/linden/indra/newview/floaterdice.cpp
@@ -0,0 +1,108 @@
1/**
2* @file floaterdice.cpp
3* @brief Dice window for Imprudence
4*
5* $LicenseInfo:firstyear=2009&license=viewergpl$
6*
7* Copyright (c) 2011, McCabe Maxsted
8*
9* Imprudence Viewer Source Code
10* The source code in this file ("Source Code") is provided to you
11* under the terms of the GNU General Public License, version 2.0
12* ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in
13* this distribution, or online at
14* http://secondlifegrid.net/programs/open_source/licensing/gplv2
15*
16* There are special exceptions to the terms and conditions of the GPL as
17* it is applied to this Source Code. View the full text of the exception
18* in the file doc/FLOSS-exception.txt in this software distribution, or
19* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
20*
21* By copying, modifying or distributing this software, you acknowledge
22* that you have read and understood your obligations described above,
23* and agree to abide by those obligations.
24*
25* ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO
26* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
27* COMPLETENESS OR PERFORMANCE.
28* $/LicenseInfo$
29*/
30
31#include "llviewerprecompiledheaders.h"
32
33#include "floaterdice.h"
34
35#include "llspinctrl.h"
36#include "lluictrlfactory.h"
37
38#include "llchat.h"
39#include "llchatbar.h"
40#include "llkeyboard.h"
41#include "llviewercontrol.h"
42
43
44FloaterDice::FloaterDice(const LLSD& seed) : LLFloater("Roll Dice")
45{
46 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_dice.xml");
47}
48
49FloaterDice::~FloaterDice()
50{
51}
52
53BOOL FloaterDice::postBuild()
54{
55 childSetAction("btn_roll", onClickRoll, this);
56
57 return TRUE;
58}
59
60// static
61void FloaterDice::onClickRoll(void* data)
62{
63 FloaterDice* self = (FloaterDice*)data;
64 if (self)
65 {
66 S32 dice_count = (S32)(self->getChild<LLSpinCtrl>("spin_dice_count")->getValue());
67 S32 dice_sides = (S32)(self->getChild<LLSpinCtrl>("spin_dice_sides")->getValue());
68
69 if (dice_count <= 0 || dice_sides <= 3)
70 {
71 llwarns << "Invalid dice roll! Someone's trying to cheat, perhaps?" << llendl;
72 return;
73 }
74 else
75 {
76 S32 dice_total = 0;
77 std::ostringstream rolls;
78 for (S32 i = 0; i < dice_count; ++i)
79 {
80 S32 roll = ll_rand(dice_sides);
81 dice_total += roll;
82 rolls << roll;
83 if (i < dice_count - 1) rolls << ", ";
84 }
85
86 std::string roll_text = llformat("/me rolled %dd%d for a total of %d", dice_count, dice_sides, dice_total);
87 if (dice_count > 1)
88 {
89 roll_text += " (" + rolls.str() + ")";
90 }
91 gChatBar->sendChatFromViewer(roll_text, CHAT_TYPE_NORMAL, FALSE);
92 }
93 }
94}
95
96// virtual
97BOOL FloaterDice::handleKeyHere(KEY key, MASK mask)
98{
99 BOOL handled = FALSE;
100
101 if ((KEY_RETURN == key) && (mask == MASK_NONE))
102 {
103 onClickRoll(this);
104 handled = TRUE;
105 }
106
107 return handled;
108}
diff --git a/linden/indra/newview/floaterdice.h b/linden/indra/newview/floaterdice.h
new file mode 100644
index 0000000..57a664b
--- /dev/null
+++ b/linden/indra/newview/floaterdice.h
@@ -0,0 +1,50 @@
1/**
2* @file floaterdice.h
3* @brief Dice window for Imprudence
4*
5* $LicenseInfo:firstyear=2009&license=viewergpl$
6*
7* Copyright (c) 2011, McCabe Maxsted
8*
9* Imprudence Viewer Source Code
10* The source code in this file ("Source Code") is provided to you
11* under the terms of the GNU General Public License, version 2.0
12* ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in
13* this distribution, or online at
14* http://secondlifegrid.net/programs/open_source/licensing/gplv2
15*
16* There are special exceptions to the terms and conditions of the GPL as
17* it is applied to this Source Code. View the full text of the exception
18* in the file doc/FLOSS-exception.txt in this software distribution, or
19* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
20*
21* By copying, modifying or distributing this software, you acknowledge
22* that you have read and understood your obligations described above,
23* and agree to abide by those obligations.
24*
25* ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO
26* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
27* COMPLETENESS OR PERFORMANCE.
28* $/LicenseInfo$
29*/
30
31#ifndef floaterdice_h
32#define floaterdice_h
33
34#include "llfloater.h"
35
36class FloaterDice : public LLFloater, public LLFloaterSingleton<FloaterDice>
37{
38public:
39
40 FloaterDice(const LLSD& seed);
41 virtual ~FloaterDice();
42 BOOL postBuild();
43
44private:
45
46 static void onClickRoll(void* data);
47 virtual BOOL handleKeyHere(KEY key, MASK mask);
48};
49
50#endif //floaterdice_h
diff --git a/linden/indra/newview/llviewermenu.cpp b/linden/indra/newview/llviewermenu.cpp
index c336c3a..a83c11b 100644
--- a/linden/indra/newview/llviewermenu.cpp
+++ b/linden/indra/newview/llviewermenu.cpp
@@ -84,6 +84,7 @@
84#include "llfirstuse.h" 84#include "llfirstuse.h"
85#include "llfloater.h" 85#include "llfloater.h"
86#include "floaterao.h" 86#include "floaterao.h"
87#include "floaterdice.h"
87#include "llfloaterabout.h" 88#include "llfloaterabout.h"
88#include "llfloaterbuycurrency.h" 89#include "llfloaterbuycurrency.h"
89#include "llfloateractivespeakers.h" 90#include "llfloateractivespeakers.h"
@@ -9601,6 +9602,32 @@ class LLAdvancedReloadBalance : public view_listener_t
9601 } 9602 }
9602}; 9603};
9603 9604
9605
9606/////////////////
9607// DICE WINDOW //
9608/////////////////
9609
9610
9611class LLAdvancedToggleDice : public view_listener_t
9612{
9613 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
9614 {
9615 FloaterDice::toggleInstance();
9616 return true;
9617 }
9618};
9619
9620class LLAdvancedCheckDice : public view_listener_t
9621{
9622 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
9623 {
9624 bool new_value = FloaterDice::instanceVisible();
9625 std::string control_name = userdata["control"].asString();
9626 gMenuHolder->findControl(control_name)->setValue(new_value);
9627 return true;
9628 }
9629};
9630
9604///////////////////// 9631/////////////////////
9605// DUMP SELECT MGR // 9632// DUMP SELECT MGR //
9606///////////////////// 9633/////////////////////
@@ -11421,6 +11448,8 @@ void initialize_menus()
11421 addMenu(new LLAdvancedWebBrowserTest(), "Advanced.WebBrowserTest"); 11448 addMenu(new LLAdvancedWebBrowserTest(), "Advanced.WebBrowserTest");
11422 addMenu(new LLAdvancedToggleEditableUI(), "Advanced.ToggleEditableUI"); 11449 addMenu(new LLAdvancedToggleEditableUI(), "Advanced.ToggleEditableUI");
11423 addMenu(new LLAdvancedReloadBalance(), "Advanced.ReloadBalance"); 11450 addMenu(new LLAdvancedReloadBalance(), "Advanced.ReloadBalance");
11451 addMenu(new LLAdvancedToggleDice(), "Advanced.ToggleDice");
11452 addMenu(new LLAdvancedCheckDice(), "Advanced.CheckDice");
11424 //addMenu(new LLAdvancedCheckEditableUI(), "Advanced.CheckEditableUI"); 11453 //addMenu(new LLAdvancedCheckEditableUI(), "Advanced.CheckEditableUI");
11425 addMenu(new LLAdvancedDumpSelectMgr(), "Advanced.DumpSelectMgr"); 11454 addMenu(new LLAdvancedDumpSelectMgr(), "Advanced.DumpSelectMgr");
11426 addMenu(new LLAdvancedDumpInventory(), "Advanced.DumpInventory"); 11455 addMenu(new LLAdvancedDumpInventory(), "Advanced.DumpInventory");
diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_dice.xml b/linden/indra/newview/skins/default/xui/en-us/floater_dice.xml
new file mode 100644
index 0000000..4a70c1c
--- /dev/null
+++ b/linden/indra/newview/skins/default/xui/en-us/floater_dice.xml
@@ -0,0 +1,15 @@
1<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
2<floater bottom="-95" can_close="true" can_drag_on_left="false" can_minimize="true"
3 can_resize="false" follows="left|top" mouse_opaque="true" height="95" width="200"
4 name="Roll Dice" title="Roll Dice" rect_control="DiceFloaterRect">
5 <spinner bottom="-37" decimal_digits="0" follows="left|top" height="16"
6 increment="1" initial_val="1" label="Number of dice:" label_width="120" left="10"
7 max_val="512" min_val="1" mouse_opaque="true" name="spin_dice_count"
8 width="170" control_name="DiceLastCount" />
9 <spinner bottom_delta="-25" decimal_digits="0" follows="left|top" height="16"
10 increment="1" initial_val="6" label="Number of sides:" label_width="120" left="10"
11 max_val="512" min_val="4" mouse_opaque="true" name="spin_dice_sides"
12 width="170" control_name="DiceLastSides" />
13 <button bottom_delta="-30" follows="right|top" font="SansSerif" halign="center" height="22"
14 label="Roll" left="-85" mouse_opaque="true" name="btn_roll" width="80" />
15</floater> \ No newline at end of file
diff --git a/linden/indra/newview/skins/default/xui/en-us/menu_viewer.xml b/linden/indra/newview/skins/default/xui/en-us/menu_viewer.xml
index df1cdf2..efde449 100644
--- a/linden/indra/newview/skins/default/xui/en-us/menu_viewer.xml
+++ b/linden/indra/newview/skins/default/xui/en-us/menu_viewer.xml
@@ -1609,10 +1609,15 @@
1609 <on_check control="ShowSearchBar" /> 1609 <on_check control="ShowSearchBar" />
1610 </menu_item_check> 1610 </menu_item_check>
1611 1611
1612 <menu_item_call name="Reload Balance" label="Reload [CURRENCY] balance" shortcut="control|alt|B"> 1612 <menu_item_call name="Reload Balance" label="Reload [CURRENCY] balance" shortcut="control|alt|B">
1613 <on_click function="Advanced.ReloadBalance" userdata="" /> 1613 <on_click function="Advanced.ReloadBalance" userdata="" />
1614 </menu_item_call> 1614 </menu_item_call>
1615 1615
1616 <menu_item_check name="Roll Dice"
1617 label="Roll Dice">
1618 <on_click function="Advanced.ToggleDice" userdata="" />
1619 <on_check function="Advanced.CheckDice" userdata="" />
1620 </menu_item_check>
1616 1621
1617 <menu_item_separator /> 1622 <menu_item_separator />
1618 1623