Issue/2768 (#2872)

* Rename remote scripting property to reflect better what it does

* Change the remote scripting name in all modules

* Update all scripts and action calls to use the new property for sync

* Simplify code that decides whether to send actions to nodes and peers

* Move Lua console hint text to be right top aligned

* Update Lua script topic

* Added new JSON key whether or not the script should be synced to other
  nodes and peers

* Per default all scripts sync to everyone
  In the next full release, we should have two separate keys that
  decides whether to sync and send to nodes and peers separately

* Add some comments that explain why there is no sync for some scripts

* Make sync argument in trigger action function BooleanType
This commit is contained in:
Malin E
2023-09-07 13:21:29 +02:00
committed by GitHub
parent b49a8704dc
commit 4447de87f5
43 changed files with 449 additions and 165 deletions
+10 -2
View File
@@ -55,7 +55,11 @@ void GuiActionComponent::render() {
for (const std::pair<const K, V>& p : binds) {
boundActions.insert(p.second);
if (ImGui::Button(ghoul::to_string(p.first).c_str())) {
global::actionManager->triggerAction(p.second, ghoul::Dictionary());
global::actionManager->triggerAction(
p.second,
ghoul::Dictionary(),
interaction::ActionManager::ShouldBeSynchronized::Yes
);
}
ImGui::SameLine();
@@ -78,7 +82,11 @@ void GuiActionComponent::render() {
}
if (ImGui::Button(action.identifier.c_str())) {
global::actionManager->triggerAction(action.command, ghoul::Dictionary());
global::actionManager->triggerAction(
action.command,
ghoul::Dictionary(),
interaction::ActionManager::ShouldBeSynchronized::Yes
);
}
ImGui::SameLine();
+2 -1
View File
@@ -147,7 +147,8 @@ void GuiGIBSComponent::render() {
);
global::scriptEngine->queueScript(
script,
scripting::ScriptEngine::RemoteScripting::Yes
scripting::ScriptEngine::ShouldBeSynchronized::Yes,
scripting::ScriptEngine::ShouldSendToRemote::Yes
);
}
@@ -344,7 +344,8 @@ void GuiGlobeBrowsingComponent::render() {
l.name,
l.url
),
scripting::ScriptEngine::RemoteScripting::Yes
scripting::ScriptEngine::ShouldBeSynchronized::Yes,
scripting::ScriptEngine::ShouldSendToRemote::Yes
);
};
+91 -26
View File
@@ -109,12 +109,14 @@ void GuiSpaceTimeComponent::render() {
"openspace.setPropertyValue('" +
std::string(AnchorProperty) + "', '" +
n->identifier() + "');",
scripting::ScriptEngine::RemoteScripting::Yes
scripting::ScriptEngine::ShouldBeSynchronized::Yes,
scripting::ScriptEngine::ShouldSendToRemote::Yes
);
global::scriptEngine->queueScript(
"openspace.setPropertyValue('" +
std::string(RetargetAnchorProperty) + "', nil);",
scripting::ScriptEngine::RemoteScripting::Yes
scripting::ScriptEngine::ShouldBeSynchronized::Yes,
scripting::ScriptEngine::ShouldSendToRemote::Yes
);
}
}
@@ -144,12 +146,14 @@ void GuiSpaceTimeComponent::render() {
global::scriptEngine->queueScript(
"openspace.setPropertyValue('" + std::string(AnchorProperty) + "', '" +
nodes[currentPosition]->identifier() + "');",
scripting::ScriptEngine::RemoteScripting::Yes
scripting::ScriptEngine::ShouldBeSynchronized::Yes,
scripting::ScriptEngine::ShouldSendToRemote::Yes
);
global::scriptEngine->queueScript(
"openspace.setPropertyValue('" +
std::string(RetargetAnchorProperty) + "', nil);",
scripting::ScriptEngine::RemoteScripting::Yes
scripting::ScriptEngine::ShouldBeSynchronized::Yes,
scripting::ScriptEngine::ShouldSendToRemote::Yes
);
}
@@ -159,7 +163,8 @@ void GuiSpaceTimeComponent::render() {
global::scriptEngine->queueScript(
"openspace.setPropertyValue('" +
std::string(RetargetAnchorProperty) + "', nil);",
scripting::ScriptEngine::RemoteScripting::Yes
scripting::ScriptEngine::ShouldBeSynchronized::Yes,
scripting::ScriptEngine::ShouldSendToRemote::Yes
);
}
@@ -195,9 +200,13 @@ void GuiSpaceTimeComponent::render() {
for (size_t i = 0; i < interestingTimes.size(); ++i) {
const Scene::InterestingTime& t = interestingTimes[i];
if (ImGui::Button(t.name.c_str())) {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.setTime(\"" + t.time + "\")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
@@ -223,9 +232,12 @@ void GuiSpaceTimeComponent::render() {
ImGuiInputTextFlags_EnterReturnsTrue
);
if (dateChanged) {
// No sync or send because time settings are always synced and sent to the
// connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.setTime(\"" + std::string(Buffer) + "\")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
@@ -255,17 +267,23 @@ void GuiSpaceTimeComponent::render() {
j2000 + seconds;
if (shift) {
// If any shift key is pressed we want to always jump to the time
// If any shift key is pressed we want to always jump to the time.
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.setTime(" + std::to_string(newTime) + ")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
else {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.interpolateTime(" + std::to_string(newTime) + ", " +
std::to_string(duration) + ")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
};
@@ -302,9 +320,12 @@ void GuiSpaceTimeComponent::render() {
// setTime doesn't like the T in it and wants a space instead
nowTime[11] = ' ';
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.setTime(\"" + nowTime + "\")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
@@ -382,9 +403,13 @@ void GuiSpaceTimeComponent::render() {
// If the value changed, we want to change the delta time to the new value
double newDt = convertTime(_deltaTime, _deltaTimeUnit, TimeUnit::Second);
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.interpolateDeltaTime(" + std::to_string(newDt) + ")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
if (unitChanged) {
@@ -430,16 +455,22 @@ void GuiSpaceTimeComponent::render() {
TimeUnit::Second
);
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.setDeltaTime(" + std::to_string(newDeltaTime) + ")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
if (!ImGui::IsItemActive() && !ImGui::IsItemClicked()) {
if (_slidingDelta != 0.f) {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.setDeltaTime(" + std::to_string(_oldDeltaTime) + ")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
@@ -464,9 +495,12 @@ void GuiSpaceTimeComponent::render() {
TimeUnit::Second
);
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.setDeltaTime(" + std::to_string(newDeltaTime) + ")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
else {
@@ -484,7 +518,8 @@ void GuiSpaceTimeComponent::render() {
if (pauseChanged) {
global::scriptEngine->queueScript(
"openspace.time.interpolateTogglePause()",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::Yes,
scripting::ScriptEngine::ShouldSendToRemote::Yes
);
}
ImGui::SameLine();
@@ -493,53 +528,71 @@ void GuiSpaceTimeComponent::render() {
{ ImGui::GetWindowWidth() / 2 - 7.5f, 0.f }
);
if (invert) {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.interpolateDeltaTime(-1 * openspace.time.deltaTime());",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
const bool minusDs = ImGui::Button("-1d/s");
if (minusDs) {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.interpolateDeltaTime(" + std::to_string(-24 * 60 * 60) + ")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
ImGui::SameLine();
const bool minusHs = ImGui::Button("-1h/s");
if (minusHs) {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.interpolateDeltaTime(" + std::to_string(-60 * 60) + ")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
ImGui::SameLine();
const bool minusMs = ImGui::Button("-1min/s");
if (minusMs) {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.interpolateDeltaTime(" + std::to_string(-60) + ")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
ImGui::SameLine();
const bool minusSs = ImGui::Button("-1s/s");
if (minusSs) {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.interpolateDeltaTime(" + std::to_string(-1) + ")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
ImGui::SameLine();
const bool zero = ImGui::Button("0");
if (zero) {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.interpolateDeltaTime(" + std::to_string(0) + ")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
ImGui::SameLine();
@@ -547,36 +600,48 @@ void GuiSpaceTimeComponent::render() {
const bool plusSs = ImGui::Button("+1s/s");
if (plusSs) {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.interpolateDeltaTime(" + std::to_string(1) + ")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
ImGui::SameLine();
const bool plusMs = ImGui::Button("1min/s");
if (plusMs) {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.interpolateDeltaTime(" + std::to_string(60) + ")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
ImGui::SameLine();
const bool plusHs = ImGui::Button("1h/s");
if (plusHs) {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.interpolateDeltaTime(" + std::to_string(60 * 60) + ")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
ImGui::SameLine();
const bool plusDs = ImGui::Button("1d/s");
if (plusDs) {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(
"openspace.time.interpolateDeltaTime(" + std::to_string(24 * 60 * 60) + ")",
scripting::ScriptEngine::RemoteScripting::No
scripting::ScriptEngine::ShouldBeSynchronized::No,
scripting::ScriptEngine::ShouldSendToRemote::No
);
}
+2 -1
View File
@@ -74,7 +74,8 @@ void renderTooltip(Property* prop, double delay) {
void executeSetPropertyScript(const std::string& id, const std::string& value) {
global::scriptEngine->queueScript(
fmt::format("openspace.setPropertyValueSingle('{}', {});", id, value),
scripting::ScriptEngine::RemoteScripting::Yes
scripting::ScriptEngine::ShouldBeSynchronized::Yes,
scripting::ScriptEngine::ShouldSendToRemote::Yes
);
}