Skip to content

Commit 030f0d7

Browse files
Merge pull request #9114 from howard-stearns/bubble-state
bubble state
2 parents 6f0377e + b37feb2 commit 030f0d7

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

libraries/networking/src/NodeList.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ bool NodeList::sockAddrBelongsToDomainOrNode(const HifiSockAddr& sockAddr) {
751751
}
752752

753753
void NodeList::ignoreNodesInRadius(float radiusToIgnore, bool enabled) {
754+
bool isEnabledChange = _ignoreRadiusEnabled.get() != enabled;
754755
_ignoreRadiusEnabled.set(enabled);
755756
_ignoreRadius.set(radiusToIgnore);
756757

@@ -759,6 +760,9 @@ void NodeList::ignoreNodesInRadius(float radiusToIgnore, bool enabled) {
759760
}, [this](const SharedNodePointer& destinationNode) {
760761
sendIgnoreRadiusStateToNode(destinationNode);
761762
});
763+
if (isEnabledChange) {
764+
emit ignoreRadiusEnabledChanged(enabled);
765+
}
762766
}
763767

764768
void NodeList::sendIgnoreRadiusStateToNode(const SharedNodePointer& destinationNode) {

libraries/networking/src/NodeList.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public slots:
108108
void limitOfSilentDomainCheckInsReached();
109109
void receivedDomainServerList();
110110
void ignoredNode(const QUuid& nodeID);
111+
void ignoreRadiusEnabledChanged(bool isIgnored);
111112

112113
private slots:
113114
void stopKeepalivePingTimer();
@@ -154,7 +155,7 @@ private slots:
154155
tbb::concurrent_unordered_set<QUuid, UUIDHasher> _ignoredNodeIDs;
155156

156157
void sendIgnoreRadiusStateToNode(const SharedNodePointer& destinationNode);
157-
Setting::Handle<bool> _ignoreRadiusEnabled { "IgnoreRadiusEnabled", false };
158+
Setting::Handle<bool> _ignoreRadiusEnabled { "IgnoreRadiusEnabled", true };
158159
Setting::Handle<float> _ignoreRadius { "IgnoreRadius", 1.0f };
159160

160161
#if (PR_BUILD || DEV_BUILD)

libraries/script-engine/src/UsersScriptingInterface.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ UsersScriptingInterface::UsersScriptingInterface() {
1717
// emit a signal when kick permissions have changed
1818
auto nodeList = DependencyManager::get<NodeList>();
1919
connect(nodeList.data(), &LimitedNodeList::canKickChanged, this, &UsersScriptingInterface::canKickChanged);
20+
connect(nodeList.data(), &NodeList::ignoreRadiusEnabledChanged, this, &UsersScriptingInterface::ignoreRadiusEnabledChanged);
2021
}
2122

2223
void UsersScriptingInterface::ignore(const QUuid& nodeID) {

libraries/script-engine/src/UsersScriptingInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public slots:
100100

101101
signals:
102102
void canKickChanged(bool canKick);
103+
void ignoreRadiusEnabledChanged(bool isEnabled);
103104
};
104105

105106

scripts/system/bubble.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,30 @@ function buttonImageURL() {
2525
return TOOLS_PATH + 'bubble.svg';
2626
}
2727

28-
var bubbleActive = Users.getIgnoreRadiusEnabled();
28+
function onBubbleToggled() {
29+
var bubbleActive = Users.getIgnoreRadiusEnabled();
30+
button.writeProperty('buttonState', bubbleActive ? 0 : 1);
31+
button.writeProperty('defaultState', bubbleActive ? 0 : 1);
32+
button.writeProperty('hoverState', bubbleActive ? 2 : 3);
33+
}
2934

3035
// setup the mod button and add it to the toolbar
3136
var button = toolbar.addButton({
3237
objectName: 'bubble',
3338
imageURL: buttonImageURL(),
3439
visible: true,
35-
buttonState: bubbleActive ? 0 : 1,
36-
defaultState: bubbleActive ? 0 : 1,
37-
hoverState: bubbleActive ? 2 : 3,
3840
alpha: 0.9
3941
});
42+
onBubbleToggled();
4043

41-
42-
// handle clicks on the toolbar button
43-
function buttonClicked(){
44-
Users.toggleIgnoreRadius();
45-
bubbleActive = Users.getIgnoreRadiusEnabled();
46-
button.writeProperty('buttonState', bubbleActive ? 0 : 1);
47-
button.writeProperty('defaultState', bubbleActive ? 0 : 1);
48-
button.writeProperty('hoverState', bubbleActive ? 2 : 3);
49-
}
50-
51-
button.clicked.connect(buttonClicked);
44+
button.clicked.connect(Users.toggleIgnoreRadius);
45+
Users.ignoreRadiusEnabledChanged.connect(onBubbleToggled);
5246

5347
// cleanup the toolbar button and overlays when script is stopped
5448
Script.scriptEnding.connect(function() {
5549
toolbar.removeButton('bubble');
50+
button.clicked.disconnect(Users.toggleIgnoreRadius);
51+
Users.ignoreRadiusEnabledChanged.disconnect(onBubbleToggled);
5652
});
5753

5854
}()); // END LOCAL_SCOPE

0 commit comments

Comments
 (0)