mirror of
https://github.com/copyrighttxt/watrbx-game-engine.git
synced 2026-09-07 22:07:48 +00:00
GEEKING
This commit is contained in:
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Camera module for Angular
|
||||
* @module angular/camera
|
||||
*/
|
||||
angular.module('roblox.camera', [])
|
||||
|
||||
.factory('$robloxCamera', [function ($q) {
|
||||
|
||||
return {
|
||||
/**
|
||||
* Capture a picture
|
||||
* @instance
|
||||
*
|
||||
* @arg {Object} options - Options
|
||||
*/
|
||||
getPicture: function (options) {
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Clean up cached data
|
||||
* @instance
|
||||
*/
|
||||
cleanup: function () {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}]);
|
||||
@@ -0,0 +1,188 @@
|
||||
//
|
||||
// RobloxHybrid
|
||||
//
|
||||
var require, define;
|
||||
|
||||
//---------------------------------------------------
|
||||
(function () {
|
||||
// Loaded modules
|
||||
var modules = {};
|
||||
|
||||
// Stack of moduleIds currently being built.
|
||||
var requireStack = [];
|
||||
|
||||
// Map of module ID -> index into requireStack of modules currently being built.
|
||||
var inProgressModules = {};
|
||||
|
||||
var nativePrefix = (function() {
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
var isNative = ua.indexOf("hybrid") != -1;
|
||||
if(isNative) {
|
||||
// iOS
|
||||
if(ua.indexOf("ipad") != -1 || ua.indexOf("iphone") != -1) {
|
||||
return "iOS";
|
||||
}
|
||||
|
||||
// Android
|
||||
if(ua.indexOf("android") != -1) {
|
||||
return "Android";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
})();
|
||||
|
||||
function build(module) {
|
||||
var factory = module.factory;
|
||||
var localRequire = require;
|
||||
|
||||
module.exports = createBaseModule(module);
|
||||
|
||||
delete module.factory;
|
||||
factory(localRequire, module.exports, module);
|
||||
|
||||
// Check if there's a native implementation available
|
||||
if(nativePrefix) {
|
||||
var nativeModuleID = module.id + "/Native";
|
||||
var nativeModule = modules[nativeModuleID];
|
||||
|
||||
if( !nativeModule && module.options && module.options.autoGenerateNative ) {
|
||||
nativeModule = autoGenerateNative(factory, module.options);
|
||||
}
|
||||
|
||||
// If exists, build the native implementation
|
||||
if( nativeModule ) {
|
||||
nativeModule.factory(localRequire, module.exports, module);
|
||||
delete nativeModule.factory;
|
||||
}
|
||||
|
||||
// Check if there's a platform specific implementation available
|
||||
var platformModuleID = module.id + "/" + nativePrefix;
|
||||
var platformModule = modules[platformModuleID];
|
||||
if( platformModule ) {
|
||||
platformModule.factory(localRequire, module.exports, module);
|
||||
delete platformModule.factory;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the module
|
||||
if(module.exports && module.exports.init && typeof module.exports.init === "function") {
|
||||
module.exports.init();
|
||||
}
|
||||
|
||||
return module.exports;
|
||||
}
|
||||
|
||||
// Common members and methods for each module
|
||||
function createBaseModule(module) {
|
||||
var exports = {};
|
||||
|
||||
// Native modules override this member
|
||||
exports.isNative = false;
|
||||
|
||||
// This function returns true in the callback if the
|
||||
// function is supported natively by the module
|
||||
exports.supports = function(functionName, callback) {
|
||||
if(callback) {
|
||||
callback(false);
|
||||
}
|
||||
};
|
||||
|
||||
return exports;
|
||||
}
|
||||
|
||||
function autoGenerateNative(nativeModuleID, options) {
|
||||
|
||||
// This factory replaces every function
|
||||
var generatedFactory = function(require, exports, module) {
|
||||
|
||||
var bridge = require("Bridge");
|
||||
|
||||
// Iterate over all the exports to find and override the functions
|
||||
for(var prop in exports) {
|
||||
|
||||
(function() {
|
||||
var currentProp = prop;
|
||||
|
||||
var func = exports[currentProp];
|
||||
if(func && typeof func === "function"){
|
||||
|
||||
// Extract parameter names from function
|
||||
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
|
||||
var ARGUMENT_NAMES = /([^\s,]+)/g;
|
||||
var fnStr = func.toString().replace(STRIP_COMMENTS, '');
|
||||
var paramNames = fnStr.slice(fnStr.indexOf('(')+1, fnStr.indexOf(')')).match(ARGUMENT_NAMES);
|
||||
if(paramNames === null) {
|
||||
paramNames = [];
|
||||
}
|
||||
|
||||
// Overrided function
|
||||
exports[currentProp] = function() {
|
||||
|
||||
var callback = null;
|
||||
var parameters = {};
|
||||
|
||||
// Find the callback function in the argument list
|
||||
// (It should be the first and only function)
|
||||
for(var i = 0; i < arguments.length; ++i) {
|
||||
var paramName = paramNames[i] || ("" + i);
|
||||
var paramValue = arguments[i];
|
||||
|
||||
if(typeof paramValue === "function") {
|
||||
callback = paramValue;
|
||||
}
|
||||
|
||||
parameters[paramName] = paramValue;
|
||||
}
|
||||
|
||||
bridge.execute(module.id, currentProp, parameters, callback);
|
||||
};
|
||||
}
|
||||
})();
|
||||
}
|
||||
};
|
||||
|
||||
delete options.autoGenerateNative;
|
||||
|
||||
return define(nativeModuleID, options, generatedFactory);
|
||||
}
|
||||
|
||||
require = function (id) {
|
||||
if (!modules[id]) {
|
||||
throw "module " + id + " not found";
|
||||
} else if (id in inProgressModules) {
|
||||
var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id;
|
||||
throw "Cycle in require graph: " + cycle;
|
||||
}
|
||||
if (modules[id].factory) {
|
||||
try {
|
||||
inProgressModules[id] = requireStack.length;
|
||||
requireStack.push(id);
|
||||
return build(modules[id]);
|
||||
} finally {
|
||||
delete inProgressModules[id];
|
||||
requireStack.pop();
|
||||
}
|
||||
}
|
||||
return modules[id].exports;
|
||||
};
|
||||
|
||||
define = function (id, options, factory) {
|
||||
if (modules[id]) {
|
||||
throw "module " + id + " already defined";
|
||||
}
|
||||
|
||||
modules[id] = {
|
||||
id: id,
|
||||
options: options,
|
||||
factory: factory
|
||||
};
|
||||
|
||||
return modules[id];
|
||||
};
|
||||
|
||||
define.remove = function (id) {
|
||||
delete modules[id];
|
||||
};
|
||||
|
||||
define.moduleMap = modules;
|
||||
})();
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Native iOS execution module
|
||||
* @augments bridge
|
||||
*/
|
||||
define("Bridge/Android", {}, function(require, exports, module) {
|
||||
|
||||
/** @inheritdoc */
|
||||
exports.execute = function(moduleID, functionName, params, callback) {
|
||||
|
||||
var callbackID = exports.registerCallback(callback);
|
||||
|
||||
var query = {
|
||||
moduleID: moduleID,
|
||||
functionName: functionName,
|
||||
params: params,
|
||||
callbackID: callbackID
|
||||
};
|
||||
|
||||
window.__globalRobloxAndroidBridge__.executeRoblox( JSON.stringify(query) );
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* Native iOS execution module
|
||||
* @augments bridge
|
||||
*/
|
||||
define("Bridge/iOS", {}, function(require, exports, module) {
|
||||
|
||||
var execXhr; // Reusing XMLHttpRequest improves performance.
|
||||
|
||||
var requestId = 0; // NSURLProtocol issues each command several times
|
||||
// 'requestId' helps prevent duplicates.
|
||||
|
||||
var webViewId; // Identifier for the current webview
|
||||
// This number is injected in the userAgent.
|
||||
|
||||
|
||||
var utils = require("Utils");
|
||||
|
||||
function doNativeRequest(query) {
|
||||
if(!webViewId) {
|
||||
var ua = navigator.userAgent;
|
||||
webViewId = ua.match(/Hybrid\((.*)\)/i);
|
||||
if(webViewId) {
|
||||
webViewId = webViewId[1];
|
||||
} else {
|
||||
webViewId = utils.createUUID();
|
||||
}
|
||||
}
|
||||
|
||||
// This prevents sending an XHR when there is already one being sent.
|
||||
if (execXhr && execXhr.readyState != 4) {
|
||||
execXhr = null;
|
||||
}
|
||||
// Re-using the XHR improves bridge performance by about 10%.
|
||||
execXhr = execXhr || new XMLHttpRequest();
|
||||
|
||||
// Add a timestamp to the query param to prevent caching.
|
||||
execXhr.open('HEAD', "rbx_native_exec?" + (+new Date()), true);
|
||||
execXhr.setRequestHeader('command', JSON.stringify(query));
|
||||
execXhr.setRequestHeader('webViewId', webViewId);
|
||||
execXhr.setRequestHeader('requestId', ++requestId);
|
||||
execXhr.send(null);
|
||||
|
||||
/*
|
||||
This is needed to support Apple's new WebKit javascript callback messaging.
|
||||
The value "RobloxWKHybrid" in "window.webkit.messageHandlers.RobloxWKHybrid.postMessage" is very intentional. It must match the
|
||||
script message handler name value in /ClientIntegration/Client/iOS/RobloxUI/Source/Screens/RBMobileWebViewController.mm
|
||||
*/
|
||||
if ( window.webkit.messageHandlers )
|
||||
{
|
||||
window.webkit.messageHandlers.RobloxWKHybrid.postMessage({
|
||||
"webViewId":webViewId
|
||||
,"command":JSON.stringify(query)
|
||||
,"requestId":requestId})
|
||||
}
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
exports.execute = function(moduleID, functionName, params, callback) {
|
||||
|
||||
var callbackID = exports.registerCallback(callback);
|
||||
|
||||
var query = {
|
||||
moduleID: moduleID,
|
||||
functionName: functionName,
|
||||
params: params,
|
||||
callbackID: callbackID
|
||||
};
|
||||
|
||||
doNativeRequest(query);
|
||||
};
|
||||
|
||||
exports.getWebViewID = function() {
|
||||
return webViewId;
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* Native/Browser execution module
|
||||
* @module bridge
|
||||
*/
|
||||
define("Bridge", {}, function(require, exports, module) {
|
||||
|
||||
/**
|
||||
* Status values
|
||||
* @enum {number}
|
||||
* @readonly
|
||||
*/
|
||||
exports.CallbackStatus = Object.freeze({
|
||||
SUCCESS: 0,
|
||||
FAILURE: 1
|
||||
});
|
||||
|
||||
/**
|
||||
* Execute a native/browser command
|
||||
*
|
||||
* @param {string} moduleID - The id of the module
|
||||
* @param {string} functionName -
|
||||
* @params {Object} params -
|
||||
* @param {Function} callback - Function to be called when the event is triggered
|
||||
* @returns {string} uuid to reference this slot-callback pair
|
||||
* @instance
|
||||
*/
|
||||
exports.execute = function(moduleID, functionName, params, callback) {
|
||||
Roblox.Hybrid.Console.log("JS bridge failed to load a native implementation");
|
||||
};
|
||||
|
||||
/**
|
||||
* Function called from native to fire a single callback
|
||||
* It will always be executed on the main thread.
|
||||
*
|
||||
* @param {string} callbackID - Unique ID of the stored callback
|
||||
* @param {CallbackStatus} status - Callback status
|
||||
* @param {Object} params - Parameters
|
||||
* @instance
|
||||
*/
|
||||
exports.nativeCallback = function(callbackID, status, params) {
|
||||
Roblox.Hybrid.Console.log("JS bridge failed to load a native implementation");
|
||||
};
|
||||
|
||||
/**
|
||||
* Function called from native to fire an event
|
||||
* It will always be executed on the main thread.
|
||||
*
|
||||
* @param {string} moduleID - Unique ID of the module that owns the event
|
||||
* @param {string} eventName - Name of the event
|
||||
* @param {Object} params - Parameters
|
||||
* @instance
|
||||
*/
|
||||
exports.emitEvent = function(moduleID, eventName, params) {
|
||||
var targetModule = require(moduleID);
|
||||
if(targetModule) {
|
||||
var slot = targetModule[eventName];
|
||||
if(slot) {
|
||||
slot.emit(params);
|
||||
} else {
|
||||
Roblox.Hybrid.Console.log("Unable to emit event: Slot " + eventName + " not found in module " + moduleID);
|
||||
}
|
||||
} else {
|
||||
Roblox.Hybrid.Console.log("Unable to emit event: Module " + moduleID + " not found");
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
define("Bridge/Native", {}, function(require, exports, module) {
|
||||
|
||||
var utils = require("Utils");
|
||||
|
||||
// List of callbacks
|
||||
var callbacks = {};
|
||||
|
||||
// Mark this module as native
|
||||
exports.isNative = true;
|
||||
|
||||
// Associate a callback function with a UUID.
|
||||
// Returns the UUID or null if the callback function is not valid
|
||||
exports.registerCallback = function(callback) {
|
||||
if(callback) {
|
||||
var callbackID = utils.createUUID();
|
||||
callbacks[callbackID] = callback;
|
||||
return callbackID;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
/** @inheritdoc */
|
||||
exports.nativeCallback = function(callbackID, status, params) {
|
||||
var callback = callbacks[callbackID];
|
||||
if(callback !== undefined) {
|
||||
delete callbacks[callbackID];
|
||||
callback.apply(null, [status, params]);
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* Events module
|
||||
* @module events
|
||||
*/
|
||||
define("Events", {}, function(require, exports, module) {
|
||||
|
||||
/**
|
||||
* Event declaration
|
||||
*
|
||||
* @param name {string} name - Event ID
|
||||
* @param params {Object} - Custom event specific information
|
||||
*/
|
||||
function Event(name, params) {
|
||||
this.name = name;
|
||||
this.params = params;
|
||||
};
|
||||
|
||||
/**
|
||||
* Slot declaration
|
||||
*
|
||||
* @class
|
||||
* @param eventName {string} - eventID of the events that
|
||||
* @param sticky {boolean} - If true, the event will fire for observers that subscribe even after the event was fired (example, moduleInitialized)
|
||||
*/
|
||||
exports.Slot = function(eventName, sticky) {
|
||||
this.eventName = eventName;
|
||||
this.sticky = sticky;
|
||||
|
||||
// Has this event already been emitted?
|
||||
var emittedEvent = null;
|
||||
|
||||
// List of all subscribers
|
||||
var listeners = [];
|
||||
|
||||
/**
|
||||
* Subscribe to an event
|
||||
*
|
||||
* @param {string} eventName - The name of the event
|
||||
* @param {Function} listener - Function to be called when the event is triggered.
|
||||
* This callback should return true to stop propagation.
|
||||
* @instance
|
||||
*/
|
||||
this.subscribe = function(listener) {
|
||||
listeners.push(listener);
|
||||
|
||||
// Fire the event if its sticky and was already fired
|
||||
if(emittedEvent) {
|
||||
listener(emittedEvent);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Unsubscribe from an event
|
||||
*
|
||||
* @param {Function} listener - Listener to be removed
|
||||
* @instance
|
||||
*/
|
||||
this.unsubscribe = function(listener) {
|
||||
var listenersCount = listeners.length;
|
||||
for(var i = 0; i < listenersCount; i++) {
|
||||
var thisListener = listeners[i];
|
||||
if( thisListener === listener ) {
|
||||
listeners.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Emit the event with parameters
|
||||
*
|
||||
* @param {Object} - Custom user object to pass to the listeners
|
||||
* @instance
|
||||
*/
|
||||
this.emit = function(params) {
|
||||
var eventInstance = new Event(this.eventName, params);
|
||||
if(this.sticky) {
|
||||
emittedEvent = eventInstance;
|
||||
}
|
||||
|
||||
var listenersCount = listeners.length;
|
||||
for(var i = 0; i < listenersCount; i++) {
|
||||
var listener = listeners[i];
|
||||
if( listener(eventInstance) ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* Utils module
|
||||
* @module utils
|
||||
*/
|
||||
define("Utils", {}, function(require, exports, module) {
|
||||
|
||||
/**
|
||||
* Returns true if this app is executed in a mobile device, either in a native app or in the browser.
|
||||
*
|
||||
* @returns {Boolean} true if this app is executed in a mobile device, either in a native app or in the browser.
|
||||
* @instance
|
||||
*/
|
||||
exports.isMobile = function() {
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
var keywords = "(iphone;android;midp;240x320;blackberry;netfront;nokia;panasonic;portalmmm;sharp;sie-;sonyericsson;symbian;windows ce;benq;mda;mot-;opera mini;philips;pocket pc;sagem;samsung;htc".split(";");
|
||||
var keyword;
|
||||
for (keyword in keywords) {
|
||||
if (-1 != ua.indexOf(keywords[keyword])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if this app is executed natively ONLY
|
||||
*
|
||||
* @returns {Boolean} true if this app is executed in a mobile device, either in a native app or in the browser.
|
||||
* @instance
|
||||
*/
|
||||
exports.isMobileApp = function() {
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
return ua.indexOf("hybrid") != -1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Loads/injects a script
|
||||
*
|
||||
* @param {string} scriptURL - Script URL to load
|
||||
* @param {Function} callback - Callback to be executed when the script is loaded
|
||||
* @instance
|
||||
*/
|
||||
exports.loadScript = function(scriptURL, callback) {
|
||||
|
||||
var scriptLoaded = false;
|
||||
function onScriptLoaded() {
|
||||
if(!scriptLoaded) {
|
||||
scriptLoaded = true;
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
var script = document.createElement('script');
|
||||
script.type= 'text/javascript';
|
||||
script.async = true;
|
||||
script.onreadystatechange= function () {
|
||||
if (this.readyState == 'complete') onScriptLoaded();
|
||||
}
|
||||
script.onload= onScriptLoaded;
|
||||
script.src= scriptURL;
|
||||
|
||||
head.appendChild(script);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Extends a child object from a parent object using classical inheritance
|
||||
* pattern.
|
||||
*
|
||||
* @param {Function} Child - Child class
|
||||
* @param {Function} Parent - Parent class
|
||||
*/
|
||||
exports.extend = (function() {
|
||||
// proxy used to establish prototype chain
|
||||
var F = function() {};
|
||||
// extend Child from Parent
|
||||
return function(Child, Parent) {
|
||||
F.prototype = Parent.prototype;
|
||||
Child.prototype = new F();
|
||||
Child.__super__ = Parent.prototype;
|
||||
Child.prototype.constructor = Child;
|
||||
};
|
||||
}());
|
||||
|
||||
/**
|
||||
* Create a UUID
|
||||
*
|
||||
* @returns A newly random UUID with the format XXXX-XX-XX-XX-XXXXXX
|
||||
*/
|
||||
exports.createUUID = function() {
|
||||
|
||||
function createPart(length) {
|
||||
var uuidpart = "";
|
||||
for (var i=0; i<length; i++) {
|
||||
var uuidchar = parseInt((Math.random() * 256), 10).toString(16);
|
||||
if (uuidchar.length == 1) {
|
||||
uuidchar = "0" + uuidchar;
|
||||
}
|
||||
uuidpart += uuidchar;
|
||||
}
|
||||
return uuidpart;
|
||||
}
|
||||
|
||||
return createPart(4) + '-' +
|
||||
createPart(2) + '-' +
|
||||
createPart(2) + '-' +
|
||||
createPart(2) + '-' +
|
||||
createPart(6);
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// RobloxHybrid
|
||||
//
|
||||
|
||||
//---------------------------------------------------
|
||||
define('RobloxHybrid', {}, function(require, exports, module) {
|
||||
exports.Utils = require("Utils");
|
||||
exports.Events = require("Events");
|
||||
exports.Bridge = require("Bridge");
|
||||
exports.Game = require("Game");
|
||||
exports.Social = require("Social");
|
||||
exports.Chat = require("Chat");
|
||||
exports.Input = require("Input");
|
||||
});
|
||||
|
||||
//---------------------------------------------------
|
||||
// Define a global roblox scope
|
||||
if(!window.Roblox) {
|
||||
window.Roblox = {};
|
||||
}
|
||||
window.Roblox.Hybrid = require('RobloxHybrid');
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Analytics module
|
||||
* @module analytics
|
||||
*/
|
||||
define("Analytics", {autoGenerateNative:true}, function(require, exports, module) {
|
||||
/**
|
||||
* Track an event
|
||||
*
|
||||
* @param {string} eventName - Event name
|
||||
* @param {Object} params - Dictionary with the event parameters. Only the first level will be saved. (i.e. no nested objects).
|
||||
* @instance
|
||||
* @platforms iOS(7.0)
|
||||
*/
|
||||
exports.trackEvent = function(eventName, params) {
|
||||
//
|
||||
};
|
||||
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Camera module
|
||||
* @module camera
|
||||
*/
|
||||
define("Camera", {autoGenerateNative:true}, function(require, exports, module) {
|
||||
/**
|
||||
* Gets a picture from source defined by "options.sourceType", and returns the
|
||||
* image as defined by the "options.destinationType" option.
|
||||
*
|
||||
* @param {Function} successCallback
|
||||
* @param {Function} errorCallback
|
||||
* @param {Object} options
|
||||
* @instance
|
||||
*/
|
||||
exports.getPicture = function(successCallback, errorCallback, options) {
|
||||
//
|
||||
};
|
||||
|
||||
/**
|
||||
* Clean up
|
||||
* @param {Function} successCallback
|
||||
* @param {Function} errorCallback
|
||||
* @instance
|
||||
*/
|
||||
exports.cleanup = function(successCallback, errorCallback) {
|
||||
//
|
||||
};
|
||||
|
||||
});
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Chat module
|
||||
* @module roblox.chat
|
||||
*/
|
||||
define("Chat", {autoGenerateNative:true}, function(require, exports, module) {
|
||||
|
||||
exports.events = require("Events");
|
||||
|
||||
/**
|
||||
* Notification that the Unread Messages badge should be revealed or updated
|
||||
* with the number of unread messages. If numUnreadMessages <= 0, the badge
|
||||
* will be removed.
|
||||
*
|
||||
* @param {int} numUnreadMessages - number of currently unread messages
|
||||
* @param {Function} callback
|
||||
*
|
||||
* @instance
|
||||
* @platforms iOS(7.0)
|
||||
* @platforms Android(15)
|
||||
*/
|
||||
exports.newMessageNotification = function(numUnreadMessages, callback) {
|
||||
// TODO: Implement for WEB
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the height of the top bar, in pixels, from the app.
|
||||
*
|
||||
* @param {Function} callback
|
||||
*
|
||||
* @instance
|
||||
* @platforms iOS(7.0)
|
||||
* @platforms Android(15)
|
||||
*/
|
||||
exports.getTopBarHeight = function(callback) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the height of the keyboard, in pixels, from the app. Will
|
||||
* only work when the keyboard is already open.
|
||||
*
|
||||
* @param {Function} callback
|
||||
*
|
||||
* @instance
|
||||
* @platforms iOS(7.0)
|
||||
* @platforms Android(15)
|
||||
*/
|
||||
exports.getKeyboardHeight = function(callback) {
|
||||
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Console module
|
||||
* @module console
|
||||
*/
|
||||
define("Console", {autoGenerateNative:true}, function(require, exports, module) {
|
||||
|
||||
var DEFAULT_TAG = "RobloxHybrid";
|
||||
|
||||
var bridge = require("Bridge");
|
||||
|
||||
/**
|
||||
* Log event
|
||||
*
|
||||
* @param {string} tag - Tag
|
||||
* @param {string} message - Message
|
||||
* @instance
|
||||
*/
|
||||
exports.log = function(tag, message) {
|
||||
if(arguments.length < 2) {
|
||||
message = tag;
|
||||
tag = DEFAULT_TAG;
|
||||
}
|
||||
window.console.log(tag + ": " + message);
|
||||
};
|
||||
|
||||
/**
|
||||
* Error event
|
||||
*
|
||||
* @param {string} tag - Tag
|
||||
* @param {string} message - Message
|
||||
* @instance
|
||||
*/
|
||||
exports.error = function(tag, message) {
|
||||
if(arguments.length < 2) {
|
||||
message = tag;
|
||||
tag = DEFAULT_TAG;
|
||||
}
|
||||
window.console.error(tag, message);
|
||||
};
|
||||
|
||||
});
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Camera module
|
||||
* @module roblox.dialogs
|
||||
*/
|
||||
define("Dialogs", {autoGenerateNative:true}, function(require, exports, module) {
|
||||
/**
|
||||
* Present a single button dialog
|
||||
*
|
||||
* @param {string} text - Content text
|
||||
* @param {Function} callback - Callback
|
||||
* @param {string} title - Window title
|
||||
* @param {string} buttonName - Button name
|
||||
* @instance
|
||||
* @platforms iOS(7.0)
|
||||
*/
|
||||
exports.alert = function(text, callback, title, buttonName) {
|
||||
window.alert(text);
|
||||
if(callback) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Present a dialog with multiple options
|
||||
*
|
||||
* @param {string} text - Content text
|
||||
* @param {Function} callback - Callback
|
||||
* @param {string} title - Window title
|
||||
* @param {string[]} buttonName - Button labels
|
||||
* @example
|
||||
* function onConfirm(results) {
|
||||
* // results.input1
|
||||
* // results.buttonIndex
|
||||
* }
|
||||
*
|
||||
* Roblox.Hybrid.dialogs.confirm(
|
||||
* 'Please enter your name',
|
||||
* onConfirm,
|
||||
* 'Window title',
|
||||
* ['Ok', 'Cancel']
|
||||
* );
|
||||
* @instance
|
||||
* @platforms iOS(7.0)
|
||||
*/
|
||||
exports.confirm = function(text, callback, title, buttonName) {
|
||||
var result = window.confirm(text);
|
||||
if(callback) {
|
||||
callback(result);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Present a dialog with a textbox
|
||||
*
|
||||
* @param {string} text - Content text
|
||||
* @param {Function} callback - Callback
|
||||
* @param {string} title - Window title
|
||||
* @param {string} buttonName - Button name
|
||||
* @param {string} defaultText - Default text
|
||||
* @example
|
||||
* function onPrompt(results) {
|
||||
* // results.input1
|
||||
* // results.buttonIndex
|
||||
* }
|
||||
*
|
||||
* Roblox.Hybrid.dialogs.prompt(
|
||||
* 'Please enter your name',
|
||||
* onPrompt,
|
||||
* 'Window title',
|
||||
* ['Ok', 'Cancel'],
|
||||
* 'Your name here'
|
||||
* );
|
||||
* @instance
|
||||
* @platforms iOS(7.0)
|
||||
*/
|
||||
exports.prompt = function(text, callback, title, buttonName, defaultText) {
|
||||
var result = window.prompt(text, defaultText);
|
||||
if(callback) {
|
||||
callback(result);
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Camera module
|
||||
* @module roblox.game
|
||||
*/
|
||||
define("Game", {autoGenerateNative:true}, function(require, exports, module) {
|
||||
|
||||
exports.events = require("Events");
|
||||
|
||||
/**
|
||||
* Start a game session
|
||||
*
|
||||
* @param {string} placeID - ID of the place to start
|
||||
* @param {Function} callback
|
||||
* @instance
|
||||
* @platforms iOS(7.0)
|
||||
*/
|
||||
exports.startWithPlaceID = function(placeID, callback) {
|
||||
// TODO: Implement for WEB
|
||||
};
|
||||
|
||||
/**
|
||||
* Launches a game from a party request - only used for members joining, NOT leader joining
|
||||
*
|
||||
* @param {string} placeId - Asset ID of game to launch
|
||||
* @param {Function} callback
|
||||
*
|
||||
* @instance
|
||||
* @platforms iOS(7.0)
|
||||
* @platforms Android(15)
|
||||
*/
|
||||
exports.launchPartyForPlaceId = function(placeId, callback) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Launches a game as a party leader - do NOT use for party member joins
|
||||
*
|
||||
* @param {string} placeId - Asset ID of game to launch
|
||||
* @param {Function} callback
|
||||
*
|
||||
* @instance
|
||||
* @platforms iOS(7.0)
|
||||
* @platforms Android(15)
|
||||
*/
|
||||
exports.launchPartyLeaderForPlaceId = function (placeId, callback) {
|
||||
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Input module
|
||||
* @module roblox.input
|
||||
*/
|
||||
define("Input", {autoGenerateNative:true}, function(require, exports, module) {
|
||||
|
||||
var events = require("Events");
|
||||
|
||||
/**
|
||||
* Notifies when the keyboard appears
|
||||
*
|
||||
* @event Input#onKeyboardShow
|
||||
* @type {object}
|
||||
* @property {object} params - Indicates the keyboard overlapped area size with the webview
|
||||
*/
|
||||
exports.onKeyboardShow = new events.Slot("onKeyboardShow");
|
||||
|
||||
/**
|
||||
* Notifies when the keyboard hides
|
||||
*
|
||||
* @event Input#onKeyboardHide
|
||||
* @type {object}
|
||||
*/
|
||||
exports.onKeyboardHide = new events.Slot("onKeyboardHide");
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Camera module
|
||||
* @module roblox.network
|
||||
*/
|
||||
define("Network", {autoGenerateNative:true}, function(require, exports, module) {
|
||||
|
||||
/**
|
||||
* Network status
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
* @instance
|
||||
*/
|
||||
exports.status = Object.freeze({
|
||||
UNKNOWN: "unknown",
|
||||
ETHERNET: "ethernet",
|
||||
WIFI: "wifi",
|
||||
CELL_2G: "2g",
|
||||
CELL_3G: "3g",
|
||||
CELL_4G: "4g",
|
||||
CELL:"cellular",
|
||||
NONE: "none"
|
||||
});
|
||||
|
||||
/**
|
||||
* Start a game session
|
||||
*
|
||||
* @param {string} placeID - ID of the place to start
|
||||
* @param {Function} successCallback
|
||||
* @param {Function} errorCallback
|
||||
* @returns {status}
|
||||
* @instance
|
||||
* @todo NOT IMPLEMENTED
|
||||
*/
|
||||
exports.getStatus = function() {
|
||||
//
|
||||
};
|
||||
|
||||
});
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* Camera module
|
||||
* @module roblox.social
|
||||
*/
|
||||
define("Social", {autoGenerateNative:true}, function(require, exports, module) {
|
||||
|
||||
// var utils = require("Utils");
|
||||
// var events = require("Events");
|
||||
|
||||
// // Roblox's Gigya API key
|
||||
// var GIGYA_API_KEY = "3_OsvmtBbTg6S_EUbwTPtbbmoihFY5ON6v6hbVrTbuqpBs7SyF_LQaJwtwKJ60sY1p";
|
||||
|
||||
/**
|
||||
* Enum with the available providers
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
* @instance
|
||||
*/
|
||||
exports.providers = Object.freeze({
|
||||
FACEBOOK: "facebook",
|
||||
TWITTER: "twitter",
|
||||
GOOGLEPLUS: "googleplus"
|
||||
});
|
||||
|
||||
/**
|
||||
* Event triggered when the module is initialized
|
||||
* @event
|
||||
*/
|
||||
// exports.onModuleInitialized = new events.Slot("social_initialized", true);
|
||||
|
||||
/**
|
||||
* Initialize module.
|
||||
* This function is automatically called by the module loader.
|
||||
*/
|
||||
// exports.init = function() {
|
||||
|
||||
// if(window.gigya) {
|
||||
// // Gigya's global object is declared
|
||||
// // This module dependencies are already initialized
|
||||
// exports.onModuleInitialized.emit();
|
||||
// } else {
|
||||
// // Initialize Gigya
|
||||
// var scriptURL = "http://cdn.gigya.com/js/gigya.js?apiKey=" + GIGYA_API_KEY;
|
||||
// utils.loadScript(scriptURL, function() {
|
||||
// exports.onModuleInitialized.emit();
|
||||
// });
|
||||
// }
|
||||
// };
|
||||
|
||||
/**
|
||||
* Present a share dialog
|
||||
* @param {string} text - Text to share
|
||||
* @param {string} link - Link to embed
|
||||
* @param {string} [imageURL=null] - link
|
||||
* @param {string} snapToElementID - ID of the DOM element
|
||||
* @param {Function} [callback] - Callback
|
||||
* @instance
|
||||
* @platforms Web
|
||||
* @platforms iOS(7.0)
|
||||
* @platforms Android(19)
|
||||
*/
|
||||
exports.presentShareDialog = function(text, link, imageURL, callback) {
|
||||
// The web team doesn't want to include gigya here
|
||||
|
||||
// exports.onModuleInitialized.subscribe(function() {
|
||||
// var ua = new gigya.socialize.UserAction();
|
||||
// ua.setLinkBack(link);
|
||||
// ua.setTitle(text);
|
||||
// var params = {
|
||||
// userAction: ua,
|
||||
// showEmailButton: false,
|
||||
// operationMode: "simpleShare",
|
||||
// snapToElementID: snapToElementID,
|
||||
// grayedOutScreenOpacity: 50
|
||||
// };
|
||||
// gigya.socialize.showShareUI(params);
|
||||
// });
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Login to a single social network
|
||||
*
|
||||
* @param {Object} options - Login options
|
||||
* @param {provider} options.privider - The provider that is used for authenticating the user. The following values are currently supported for use with this parameter: facebook, twitter, yahoo, messenger, googleplus, linkedin, aol, foursquare, instagram, renren, qq, sina, kaixin, vkontakte, blogger, wordpress, typepad, paypal, amazon, livejournal, verisign, openid, netlog, signon, orangefrance, mixi, yahoojapan, odnoklassniki, spiceworks, livedoor, skyrock, vznet, xing. Also SAML providers are supported - the format of the provider name is "saml-<name>".
|
||||
* @param {boolean} [options.forceAuthentication] - The default value of this parameter is 'false'. If set to 'true', the user will be forced to provide her social network credentials during the login, even if she is already connected to the social network. This parameter is currently supported by Facebook, Twitter, Renren, and LinkedIn. Please note that the behavior of the various social networks may be slightly different: Facebook expects the current user to enter their password, and will not accept a different user name. Other networks prompt the user to re-authorize the application or allow a different user to log in.
|
||||
* @param {Function} callback
|
||||
* @see {@link http://developers.gigya.com/020_Client_API/010_Socialize/socialize.login} for full login options
|
||||
* @instance
|
||||
* @todo NOT IMPLEMENTED
|
||||
*/
|
||||
exports.login = function(options, successCallback, errorCallback) {
|
||||
//
|
||||
};
|
||||
|
||||
/**
|
||||
* Logout from a social network
|
||||
* @param {Function} callback
|
||||
* @instance
|
||||
* @todo NOT IMPLEMENTED
|
||||
*/
|
||||
exports.logout = function(callback) {
|
||||
//
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user