Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Commit

Permalink
Merge pull request #21 from JulianSchoenbaechler/version_1.0
Browse files Browse the repository at this point in the history
Version 1.0.2
  • Loading branch information
JulianSchoenbaechler committed Dec 2, 2017
2 parents a37e7de + 3f59267 commit c8ec16d
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 18 deletions.
54 changes: 48 additions & 6 deletions Assets/Volplane/Code/Core/VInput.cs
Expand Up @@ -121,12 +121,12 @@ public enum Axis
/// <summary>
/// Occurs when a device motion gets registered.
/// </summary>
public event Action<int, string, Vector3> OnAccelerometer;
public event Action<int, Vector3> OnAccelerometer;

/// <summary>
/// Occurs when a device motion gets registered.
/// </summary>
public event Action<int, string, Vector3> OnGyroscope;
public event Action<int, Vector3> OnGyroscope;

#endregion

Expand Down Expand Up @@ -255,6 +255,46 @@ public static bool GetTap(int playerId, string elementName)
return false;
}

/// <summary>
/// Indicates whether an input element has been triggered. This method is intended to be used
/// for touch areas and swipe fields.
/// </summary>
/// <remarks>Consider using <see cref="VInput.GetTap(int playerId, string elementName)"/>
/// for a reduced performance impact.</remarks>
/// <returns><c>true</c>, if input was received, <c>false</c> otherwise.</returns>
/// <param name="playerId">Player identifier.</param>
/// <param name="elementName">Name of the element to check.</param>
public static bool GetInput(VPlayer player, string elementName)
{
if(player == null)
return false;

return VInput.GetInput(player.PlayerId, elementName);
}

/// <summary>
/// Indicates whether an input element has been triggered. This method is intended to be used
/// for touch areas and swipe fields.
/// </summary>
/// <returns><c>true</c>, if input was received, <c>false</c> otherwise.</returns>
/// <param name="playerId">Player identifier.</param>
/// <param name="elementName">Name of the element to check.</param>
public static bool GetInput(int playerId, string elementName)
{
if(VInput.Inputs == null)
return false;

if(VInput.Inputs.Count > playerId)
{
if(VInput.Inputs[playerId].TryGetValue(elementName, out VInput.TempInput))
{
return VInput.TempInput.StateDown;
}
}

return false;
}

/// <summary>
/// Returns <c>true</c> while the user touches a button. Think auto fire.
/// </summary>
Expand Down Expand Up @@ -731,8 +771,10 @@ public void Dispose()
public void ControllerUpdate()
{
for(int i = 0; i < VInput.Inputs.Count; i++)
foreach(ElementInput input in VInput.Inputs[i].Values)
input.Update();
{
foreach(string key in VInput.Inputs[i].Keys)
VInput.Inputs[i][key].Update();
}

while(updateQueue.Count > 0)
updateQueue.Dequeue().Invoke();
Expand Down Expand Up @@ -892,14 +934,14 @@ public void ProcessInput(int playerId, JSONNode data)
if(VInput.MotionEvents && (OnAccelerometer != null))
{
updateQueue.Enqueue(delegate {
OnAccelerometer(playerId, data["name"].Value, ((DeviceMotionInput)tempInput).Accelerometer);
OnAccelerometer(playerId, ((DeviceMotionInput)tempInput).Accelerometer);
});
}

if(VInput.MotionEvents && (OnGyroscope != null))
{
updateQueue.Enqueue(delegate {
OnGyroscope(playerId, data["name"].Value, ((DeviceMotionInput)tempInput).Gyroscope);
OnGyroscope(playerId, ((DeviceMotionInput)tempInput).Gyroscope);
});
}

Expand Down
22 changes: 22 additions & 0 deletions Assets/Volplane/Code/VolplaneBehaviour.cs
Expand Up @@ -188,6 +188,28 @@ public void SetActive(VPlayer player, bool value)
VolplaneController.Main.SetActive(player, value);
}

/// <summary>
/// Save user data. This method tries to persistently store the data on the AirConsole servers.
/// When complete, <see cref="Volplane.VolplaneBehaviour.OnUserDataSaved"/> fires for this player.
/// </summary>
/// <param name="playerId">Player identifier.</param>
/// <param name="data">JSON data.</param>
public void SaveUserData(int playerId, SimpleJSON.JSONObject data)
{
VolplaneController.Main.SaveUserData(playerId, data);
}

/// <summary>
/// Save user data. This method tries to persistently store the data on the AirConsole servers.
/// When complete, <see cref="Volplane.VolplaneBehaviour.OnUserDataSaved"/> fires for this player.
/// </summary>
/// <param name="player">Player object.</param>
/// <param name="data">JSON data.</param>
public void SaveUserData(VPlayer player, SimpleJSON.JSONObject data)
{
VolplaneController.Main.SaveUserData(player, data);
}

/// <summary>
/// Sets the standard controller view of the players.
/// </summary>
Expand Down
10 changes: 9 additions & 1 deletion Assets/Volplane/WebServer/editor-style.css
Expand Up @@ -477,6 +477,14 @@ label.align-right div span:last-of-type::after { left: -5px; }
background-color: #222125;
z-index: 1001;
}
.ce-popup-box .ce-popup-wrapper {
display: block;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: auto;
}
.ce-popup-box h1 {
position: relative;
display: inline-block;
Expand All @@ -485,7 +493,7 @@ label.align-right div span:last-of-type::after { left: -5px; }
font-weight: 300;
font-size: 24px;
padding: 10px 0 0;
margin: 10% 0 10px 0;
margin: 80px 0 10px 0;
border-bottom: 1px solid #7A2F34;
}
.ce-popup-box p {
Expand Down
12 changes: 10 additions & 2 deletions Assets/Volplane/WebServer/javascript/controller-editor.jsweb
Expand Up @@ -169,7 +169,10 @@ ControllerEditor.prototype.saveController = function(callback) {
.always(function() {

$(ControllerEditor.LOADING).fadeOut(200);
$('body').css('overflow', 'auto');

// Check for open popups
if($('div.ce-popup-box:visible').length == 0)
$('body').css('overflow', 'auto');

if(error !== false) {

Expand Down Expand Up @@ -546,7 +549,12 @@ ControllerEditor.prototype.loadControllerEditor = function(viewName) {
$(ControllerEditor.CONTROLBAR).append(instance.getNewButton('', 'Preview View', 'img/preview-view.png', { w: 32, h: 32 })
.click(function() {
instance.saveController(function() {
instance.editorPopupInstance.iframe('Preview', '../controller.html?view=' + viewName + '&data=volplane/data/controller/' + instance.controllerObject.name);
instance.editorPopupInstance.iframe(
'Preview',
'../controller.html?view=' + viewName + '&data=volplane/data/controller/' + instance.controllerObject.name,
instance.controllerObject.layout == 'landscape' ? 640 : 360,
instance.controllerObject.layout == 'landscape' ? 360 : 640
);
});
}));

Expand Down
18 changes: 12 additions & 6 deletions Assets/Volplane/WebServer/javascript/editor-popup.jsweb
Expand Up @@ -189,7 +189,7 @@ EditorPopup.prototype.prompt = function(title, text, isName, callback) {
* @param {String} title - The title displayed as header of the popup.
* @param {String} src - The page source for the iframe.
*/
EditorPopup.prototype.iframe = function(title, src) {
EditorPopup.prototype.iframe = function(title, src, width = 640, height = 360) {

var instance = this;

Expand All @@ -214,7 +214,9 @@ EditorPopup.prototype.iframe = function(title, src) {
value: 'OK'
});

$popup.append('<iframe src="' + src + '"></iframe>');
$popup.append('<br /><iframe src="' + src + '" style="' +
'width: ' + width + 'px; ' +
'height: ' + height + 'px;"></iframe><br />');
$inputs.append($default);
$popup.append($inputs);

Expand All @@ -237,12 +239,16 @@ EditorPopup.prototype.iframe = function(title, src) {
*/
EditorPopup.prototype.getPopup = function(name = '') {

$popup = $('<div/>', {
$initial = $('<div/>', {
'class': 'ce-popup-box',
'style': 'display: none;'
});
$popup = $('<div/>', {
'class': 'ce-popup-wrapper'
});
$popup.append('<h1>' + name + '</h1>');
$popup.appendTo($('body'));
$popup.appendTo($initial);
$initial.appendTo($('body'));

return $popup;

Expand All @@ -256,7 +262,7 @@ EditorPopup.prototype.getPopup = function(name = '') {
EditorPopup.prototype.openPopup = function($popup) {

$('body').css('overflow', 'hidden');
$popup.fadeIn(50);
$popup.parent().fadeIn(50);

};

Expand All @@ -269,7 +275,7 @@ EditorPopup.prototype.openPopup = function($popup) {
EditorPopup.prototype.closePopup = function($popup) {

$('body').css('overflow', 'auto');
$popup.fadeOut(200, function() { $popup.remove(); });
$popup.parent().fadeOut(200, function() { $popup.parent().remove(); });

};

Expand Down
6 changes: 3 additions & 3 deletions Assets/WebGLTemplates/Volplane/javascript/controller.js
Expand Up @@ -468,7 +468,7 @@ VolplaneController.prototype.newSwipe = function(elementObject, viewName, $viewS
name: elementObject.name,
type: 'swipe',
data: {
state: true,
state: false,
timeStamp: instance.airconsole.getServerTime()
}
};
Expand Down Expand Up @@ -522,7 +522,7 @@ VolplaneController.prototype.newSwipe = function(elementObject, viewName, $viewS
name: elementObject.name,
type: 'swipe',
data: {
state: true,
state: false,
timeStamp: instance.airconsole.getServerTime()
}
};
Expand Down Expand Up @@ -596,7 +596,7 @@ VolplaneController.prototype.newTouch = function(elementObject, viewName, $viewS
timeStamp: instance.airconsole.getServerTime()
}
};
instance.rateLimiter.message(AirConsole.SCREEN, data);
instance.airconsole.message(AirConsole.SCREEN, data);
},
'touchmove': function(position) {
if(!instance.active) return; // Disable input?
Expand Down

0 comments on commit c8ec16d

Please sign in to comment.