Browse Source

Adding WebViewProperties example

Josh Engebretson 9 years ago
parent
commit
2a78abd3f6

+ 5 - 0
WebViewProperties/Resources.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "255bcaa66114bc014d05ab312ff94d28",
+	"FolderImporter": {}
+}

+ 5 - 0
WebViewProperties/Resources/Components.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "39faa2b903cbf2b7b63c6a99b7fc6c7e",
+	"FolderImporter": {}
+}

+ 58 - 0
WebViewProperties/Resources/Components/WebView.js

@@ -0,0 +1,58 @@
+'atomic component';
+
+var WIDTH = Atomic.graphics.width - 100;
+var HEIGHT = Atomic.graphics.height - 100;
+
+// Setup some global JS properties that will be available on every page loaded
+// into the WebView
+WebView.browserHost.setGlobalBoolProperty("WebViewExample", "boolValue", true);
+WebView.browserHost.setGlobalNumberProperty("WebViewExample", "numberValue", 42);
+WebView.browserHost.setGlobalStringProperty("WebViewExample", "stringValue", "Hello World!");
+
+//UI component
+exports.component = function(self) {
+
+  //create a new UIView
+  var view = new Atomic.UIView();
+
+  // Create a UIWindow
+  var window = new Atomic.UIWindow();
+  // It will only have a title bar and won't be resizeable or have a close button
+  window.settings = Atomic.UI_WINDOW_SETTINGS_TITLEBAR;
+  window.text = "WebView Properties";
+  window.setSize(WIDTH, HEIGHT);
+
+  var webView = new WebView.UIWebView("");
+  webView.webClient.loadString(getHTML());
+  webView.gravity = Atomic.UI_GRAVITY_ALL;
+  window.addChild(webView);
+
+  // Add to main UI view and center
+  view.addChild(window);
+  window.center();
+
+}
+
+// Simple example of access global properties
+function getHTML() {
+
+  return "<!DOCTYPE html>\
+  <html>\
+  <body>\
+  \
+  <h1>WebView Properties!</h1>\
+  \
+  <p id=\"boolValue\"></p>\
+  <p id=\"numberValue\"></p>\
+  <p id=\"stringValue\"></p>\
+  \
+  <script>\
+  document.getElementById(\"boolValue\").innerHTML = \"WebViewExample.boolValue = \" + WebViewExample.boolValue; \
+  document.getElementById(\"numberValue\").innerHTML = \"WebViewExample.numberValue = \" + WebViewExample.numberValue; \
+  document.getElementById(\"stringValue\").innerHTML = \"WebViewExample.stringValue = \" + WebViewExample.stringValue; \
+  </script>\
+  \
+  </body>\
+  </html>"
+
+}

+ 7 - 0
WebViewProperties/Resources/Components/WebView.js.asset

@@ -0,0 +1,7 @@
+{
+	"version": 1,
+	"guid": "0ff4501c0d2f2581772c0bb4e2929e3d",
+	"JavascriptImporter": {
+		"IsComponentFile": true
+	}
+}

+ 5 - 0
WebViewProperties/Resources/Scenes.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "afa757ed17fa60e4bbfca8cea6aa7a47",
+	"FolderImporter": {}
+}

+ 67 - 0
WebViewProperties/Resources/Scenes/WebViewScene.scene

@@ -0,0 +1,67 @@
+<?xml version="1.0"?>
+<scene id="1">
+	<attribute name="Name" value="" />
+	<attribute name="Time Scale" value="1" />
+	<attribute name="Smoothing Constant" value="50" />
+	<attribute name="Snap Threshold" value="5" />
+	<attribute name="Elapsed Time" value="0" />
+	<attribute name="Next Replicated Node ID" value="364" />
+	<attribute name="Next Replicated Component ID" value="1976" />
+	<attribute name="Next Local Node ID" value="16778496" />
+	<attribute name="Next Local Component ID" value="16777216" />
+	<attribute name="Variables" />
+	<attribute name="Variable Names" value="" />
+	<component type="PhysicsWorld" id="1" />
+	<component type="Octree" id="2" />
+	<component type="DebugRenderer" id="3" />
+	<node id="2">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Zone" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Zone" id="4">
+			<attribute name="Bounding Box Min" value="-10000 -10000 -10000" />
+			<attribute name="Bounding Box Max" value="10000 10000 10000" />
+			<attribute name="Ambient Color" value="0.4 0.4 0.4 1" />
+		</component>
+	</node>
+	<node id="3">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="GlobalLight" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="0.888074 0.325058 -0.325058 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Light" id="5">
+			<attribute name="Light Type" value="Directional" />
+			<attribute name="Cast Shadows" value="true" />
+			<attribute name="CSM Splits" value="10 20 50 0" />
+			<attribute name="View Size Quantize" value="1" />
+			<attribute name="View Size Minimum" value="5" />
+			<attribute name="Depth Constant Bias" value="0.00025" />
+			<attribute name="Depth Slope Bias" value="0.001" />
+		</component>
+	</node>
+	<node id="361">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Camera" />
+		<attribute name="Position" value="0 0 -5" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Camera" id="1973" />
+	</node>
+	<node id="363">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="WebView" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="0.999945 0.00510105 0.00308397 0.00864025" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="JSComponent" id="1975">
+			<attribute name="ComponentFile" value="JSComponentFile;Components/WebView.js" />
+		</component>
+	</node>
+</scene>

+ 8 - 0
WebViewProperties/Resources/Scenes/WebViewScene.scene.asset

@@ -0,0 +1,8 @@
+{
+	"version": 1,
+	"guid": "d4100769225d5fe226a827714ee38ac3",
+	"SceneImporter": {
+		"sceneCamRotation": "1 0 0 0",
+		"sceneCamPosition": "0 0 0"
+	}
+}

+ 5 - 0
WebViewProperties/Resources/Scripts.asset

@@ -0,0 +1,5 @@
+{
+	"version": 1,
+	"guid": "1738c76d1408e6144cd647401e05be61",
+	"FolderImporter": {}
+}

+ 10 - 0
WebViewProperties/Resources/Scripts/main.js

@@ -0,0 +1,10 @@
+// This script is the main entry point of the game
+
+var scene = Atomic.player.loadScene("Scenes/WebViewScene.scene");
+
+// called per frame, optional
+function update(timeStep) {
+
+}
+
+exports.update = update;

+ 7 - 0
WebViewProperties/Resources/Scripts/main.js.asset

@@ -0,0 +1,7 @@
+{
+	"version": 1,
+	"guid": "8edb0a7488e0496179261b71c07bbb60",
+	"JavascriptImporter": {
+		"IsComponentFile": false
+	}
+}

+ 0 - 0
WebViewProperties/WebViewProperties.atomic