Skip to content

Commit 1cb5882

Browse files
committed
Changed subtitle action to have scrolling text, added interface script install action (broken), added prompt action, updated entity click trigger to work in VR with the laser as well, added hidden reload trigger in web app
1 parent a8166a7 commit 1cb5882

File tree

8 files changed

+111
-5
lines changed

8 files changed

+111
-5
lines changed

common/Plugins/ActionHFUISubtitle.js

+22-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default class ActionHFUISubtitle extends BasePlugin {
5757

5858
// Get text, break up long lines
5959
var text = this.option("text")
60-
text = wordWrap(text, 120)
60+
text = wordWrap(text, 100)
6161

6262
// Create text label
6363
this.overlay = new Label()
@@ -69,14 +69,34 @@ export default class ActionHFUISubtitle extends BasePlugin {
6969
this.overlay.backgroundColor = { red: 0, green: 4, blue: 8 }
7070
this.overlay.backgroundAlpha = 0.75
7171
this.overlay.font = { size: 17 }
72-
this.overlay.text = text
72+
this.overlay.text = ""
7373
this.overlay.leftMargin = 10
7474
this.overlay.topMargin = 10
7575
this.overlay.show()
7676

7777
// Start timer to remove the element, if needed
7878
this.removeTimer = Script.setTimeout(this.removeOverlay.bind(this), 30 * 1000)
7979

80+
// Create a loop to display each character one at a time
81+
var numChars = 0
82+
var textTimer = 0
83+
var overlay = this.overlay
84+
textTimer = Script.setInterval(e => {
85+
86+
// Add another char
87+
numChars += 1
88+
89+
// Check if done
90+
if (numChars > text.length) {
91+
Script.clearInterval(textTimer)
92+
return
93+
}
94+
95+
// Set text
96+
overlay.text = text.substring(0, numChars)
97+
98+
}, 1000 / 30)
99+
80100
}
81101

82102
/** Removes any overlay */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// Logs text to the console.
3+
4+
import BasePlugin from './BasePlugin'
5+
6+
export default class ActionInstallInterfaceScript extends BasePlugin {
7+
8+
/** Plugin ID */
9+
static get pluginID() { return "com.jjv360.actions.InstallInterfaceScript" }
10+
11+
/** Plugin name */
12+
static get pluginName() { return "Install an Interface script" }
13+
14+
/** Plugin type */
15+
static get pluginType() { return "action" }
16+
17+
/** Plugin icon */
18+
static get pluginIcon() { return "build" }
19+
20+
/** Configurable fields */
21+
static get fields() { return [
22+
{ id: "url", name: "URL" }
23+
]}
24+
25+
/** Called in High Fidelity when this action is triggered. Return a Promise. */
26+
onTrigger() {
27+
28+
// Install script
29+
Script.load(this.option("url"))
30+
31+
}
32+
33+
}

common/Plugins/ActionPrompt.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// Shows an alert to the user.
3+
4+
import BasePlugin from './BasePlugin'
5+
6+
export default class ActionPrompt extends BasePlugin {
7+
8+
/** Plugin ID */
9+
static get pluginID() { return "com.jjv360.actions.Prompt" }
10+
11+
/** Plugin name */
12+
static get pluginName() { return "Show prompt popup" }
13+
14+
/** Plugin type */
15+
static get pluginType() { return "action" }
16+
17+
/** Plugin icon */
18+
static get pluginIcon() { return "flag" }
19+
20+
/** Configurable fields */
21+
static get fields() { return [
22+
{ id: "text", name: "Text" },
23+
{ id: "defaultText", name: "Default Input" },
24+
]}
25+
26+
/** Called in High Fidelity when this action is triggered. Return a Promise. */
27+
onTrigger() {
28+
29+
// Output to console
30+
return Window.prompt(this.option("text"), this.option("defaultText"))
31+
32+
}
33+
34+
}

common/Plugins/PluginManager.js

+2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class PluginManager {
1414
this.add(require("./ActionDelay").default)
1515
this.add(require("./ActionHFUIAlert").default)
1616
this.add(require("./ActionHFUISubtitle").default)
17+
this.add(require("./ActionInstallInterfaceScript").default)
1718
this.add(require("./ActionLog").default)
19+
this.add(require("./ActionPrompt").default)
1820
this.add(require("./TriggerLeaveEntity").default)
1921
this.add(require("./TriggerEnterEntity").default)
2022
this.add(require("./TriggerOnLoad").default)

common/Plugins/TriggerEntityClick.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ export default class TriggerEntityClick extends BasePlugin {
1818
static get pluginIcon() { return "mouse" }
1919

2020
/** HF event: Clicking on the entity */
21-
clickDownOnEntity(id) {
21+
mousePressOnEntity(id) {
2222

2323
// Check if ours
24+
print("Mouse press! " + id + " ours " + this.localEntity.id)
2425
if (id != this.localEntity.id)
2526
return
2627

hf-scripter-client.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
// Link to your app's HTML file
1111
// var APP_URL = "http://localhost:8080"
12-
var APP_URL = "https://jjv360.s3.amazonaws.com/hifi/hf-scripter"
12+
var APP_URL = "https://s3.amazonaws.com/jjv360/hifi/hf-scripter"
1313

1414
// Get a reference to the tablet
1515
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");

hifi-script/start.js

+16
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,22 @@ export default class MyEntity extends LocalEntity {
111111

112112
}
113113

114+
/** Called when the user clicks up on an entity */
115+
clickReleaseOnEntity(id) {
116+
117+
// Pass on event to all plugins
118+
this.passEvent("clickReleaseOnEntity", id)
119+
120+
}
121+
122+
/** Called when the user clicks up on an entity. This includes controllers as well. */
123+
mousePressOnEntity(id, event) {
124+
125+
// Pass on event to all plugins
126+
this.passEvent("mousePressOnEntity", id, event)
127+
128+
}
129+
114130
/** Executes a script. This is called by a Trigger plugin. @returns Promise resolved to final action's output. */
115131
executeScript(script, triggerOutput) {
116132

web-ui/Screens/Main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default class Main extends React.Component {
3939
<div style={{ position: "fixed", top: 0, left: 0, width: "100%", height: 80, display: "flex", alignItems: "center", backgroundColor: "#222", background: "linear-gradient(#2b2b2b, #1e1e1e)" }}>
4040

4141
{/* Icon */}
42-
<img src={require("./Main.icon.svg")} style={{ margin: 32, height: 32, }} />
42+
<img src={require("./Main.icon.svg")} style={{ margin: 32, height: 32, }} onClick={e => location.reload()} />
4343

4444
{/* Text */}
4545
<div>

0 commit comments

Comments
 (0)