Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/vthibault/roBrowser
Browse files Browse the repository at this point in the history
  • Loading branch information
vthibault committed Oct 20, 2015
2 parents 4aa0137 + 82c6fe7 commit 8b2e9f5
Show file tree
Hide file tree
Showing 48 changed files with 3,113 additions and 307 deletions.
3 changes: 2 additions & 1 deletion api.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
ROConfig.API = event.data.api || false;
ROConfig.socketProxy = event.data.socketProxy || null;
ROConfig.packetKeys = event.data.packetKeys || false;
ROConfig.saveFiles = event.data.saveFiles || false;
ROConfig.skipServerList = event.data.skipServerList || false;
ROConfig.skipIntro = event.data.skipIntro || false;
ROConfig.autoLogin = event.data.autoLogin || [];
Expand All @@ -32,7 +33,7 @@
var script = document.createElement('script');
script.src = 'src/Vendors/require.js?' + ROConfig.version;
script.type = 'text/javascript';
script.setAttribute('data-main', 'src/App/' + event.data.application + '?' + ROConfig.version);
script.setAttribute('data-main', 'src/App/' + event.data.application + '.js?' + ROConfig.version);

document.getElementsByTagName('head')[0].appendChild(script);
event.source.postMessage('ready', '*' );
Expand Down
18 changes: 15 additions & 3 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@
ROBrowser.prototype.packetKeys = false;


/**
* @var {boolean} should we save files in chrome filesystem ?
*
* If set to true, then we try to save the files loaded from server/grfs on a filesystem to load
* them faster the next time.
*
* Only working on Chrome, status: deprecated.
*/
ROBrowser.prototype.saveFiles = false;


/**
* @var {boolean} skip server list if only one server define ?
*
Expand Down Expand Up @@ -287,9 +298,9 @@
frame.height = this.height;
frame.style.border = 'none';

frame.setAttribute('allowfullscreen', true);
frame.setAttribute('webkitallowfullscreen', true);
frame.setAttribute('mozallowfullscreen', true);
frame.setAttribute('allowfullscreen', 'true');
frame.setAttribute('webkitallowfullscreen', 'true');
frame.setAttribute('mozallowfullscreen', 'true');

if (this.target) {
while (this.target.firstChild) {
Expand Down Expand Up @@ -362,6 +373,7 @@
api: this.api,
socketProxy: this.socketProxy,
packetKeys: this.packetKeys,
saveFiles: this.saveFiles,
skipServerList: this.skipServerList,
skipIntro: this.skipIntro,
autoLogin: this.autoLogin,
Expand Down
26 changes: 25 additions & 1 deletion src/Controls/EntityControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ define(function( require )

case Entity.TYPE_PC:
/// TODO: complete it :
/// - check for guild leader action (invite, ally, ...)
/// - check for admin action (kick, mute, ...)

ContextMenu.remove();
Expand All @@ -236,6 +235,31 @@ define(function( require )
Trade.reqExchange(entity.GID, entity.display.name);
});


// Guild features
if (Session.hasGuild) {
if (Session.guildRight & 0x01 && !this.GUID) {
// Send (%s) a Guild invitation
ContextMenu.addElement( DB.getMessage(382).replace('%s', this.display.name), function(){
getModule('Engine/MapEngine/Guild').requestPlayerInvitation(entity.GID);
});
}

if (Session.isGuildMaster && this.GUID && Session.Entity.GUID !== this.GUID) {
ContextMenu.nextGroup();

// Set this guild as an Alliance
ContextMenu.addElement( DB.getMessage(399).replace('%s', this.display.name), function(){
getModule('Engine/MapEngine/Guild').requestAlliance(entity.GID);
});

// Set this guild as an Antagonist
ContextMenu.addElement( DB.getMessage(403).replace('%s', this.display.name), function(){
getModule('Engine/MapEngine/Guild').requestHostility(entity.GID);
});
}
}

//ContextMenu.addElement( DB.getMessage(360), openPrivateMessageWindow);

if (!Friends.isFriend(this.display.name)) {
Expand Down
2 changes: 0 additions & 2 deletions src/Controls/MapControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ define(function( require )
.on('drop', onDrop.bind(this));

jQuery(window)
.on('contextmenu', function(){ return false; })
.on('mousedown.map', onMouseDown.bind(this))
.on('mouseup.map', onMouseUp.bind(this));
};
Expand Down Expand Up @@ -234,7 +233,6 @@ define(function( require )
function onDrop( event )
{
var item, data;
var MapEngine = this;

try {
data = JSON.parse(
Expand Down
18 changes: 17 additions & 1 deletion src/Controls/ProcessCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,28 @@ define(function( require )
case 'hi':
getModule('Engine/MapEngine/Friends').sayHi();
return;

case 'guild':
matches = text.match(/^guild\s+(")?([^"]+)(")?/);
if (matches && matches[2]) {
getModule('Engine/MapEngine/Guild').createGuild(matches[2]);
return;
}
break;

case 'breakguild':
matches = text.match(/^breakguild\s+(")?([^"]+)(")?/);
if (matches && matches[2]) {
getModule('Engine/MapEngine/Guild').breakGuild(matches[2]);
return;
}
break;
}


// /str+
// TODO: do we have to spam the server with "1" unit or do we have to fix the servers code ?
var matches = text.match(/^(\w{3})\+ (\d+)$/);
matches = text.match(/^(\w{3})\+ (\d+)$/);
if (matches) {
var pos = ['str', 'agi', 'vit', 'int', 'dex', 'luk'].indexOf(matches[1]);
if (pos > -1 && matches[2] !== 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ define(function()
*/
Context.isFullScreen = function IsFullScreen()
{
return (
return !!(
document.fullscreenElement ||
document.mozFullScreenElement ||
document.webkitFullscreenElement ||
Expand Down
2 changes: 1 addition & 1 deletion src/Core/FileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ define(function()
*/
function init( files, save, quota )
{
var requestFileSystemSync, requestFileSystem, temporaryStorage;
var requestFileSystemSync, requestFileSystem;
_files = normalizeFilesPath(files);

if (!_available) {
Expand Down
12 changes: 6 additions & 6 deletions src/Core/MemoryManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ define( ['Core/MemoryItem'], function( MemoryItem )
* Remove files from memory if not used until a period of time
* @var {number}
*/
var _remember_time = 2 * 60 * 1000; // 2 min
var _rememberTime = 2 * 60 * 1000; // 2 min


/**
Expand Down Expand Up @@ -54,7 +54,7 @@ define( ['Core/MemoryItem'], function( MemoryItem )
var item;

// Not in memory yet, create slot
if (!exist(filename)) {
if (!_memory[filename]) {
_memory[filename] = new MemoryItem();
}

Expand All @@ -80,7 +80,7 @@ define( ['Core/MemoryItem'], function( MemoryItem )
*/
function exist( filename )
{
return filename in _memory;
return !!_memory[filename];
}


Expand All @@ -94,7 +94,7 @@ define( ['Core/MemoryItem'], function( MemoryItem )
function set( filename, data, error )
{
// Not in memory yet, create slot
if (!exist(filename)) {
if (!_memory[filename]) {
_memory[filename] = new MemoryItem();
}

Expand Down Expand Up @@ -125,7 +125,7 @@ define( ['Core/MemoryItem'], function( MemoryItem )

keys = Object.keys(_memory);
count = keys.length;
tick = now - _remember_time;
tick = now - _rememberTime;

for (i = 0; i < count; ++i) {
item = _memory[ keys[i] ];
Expand All @@ -152,7 +152,7 @@ define( ['Core/MemoryItem'], function( MemoryItem )
function remove( gl, filename )
{
// Not found ?
if (!exist(filename)) {
if (!_memory[filename]) {
return;
}

Expand Down
36 changes: 29 additions & 7 deletions src/Core/Mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@ define(function( require )
};


/**
* Remove autofocus on mobile.
* Let the user decide to focus an input/textarea by himself
*/
var remoteAutoFocus = (function removeAutoFocusClosure()
{
var _done = false;

return function removeAutoFocus() {
if (_done) {
return;
}

jQuery.fn.focus = function() {};
jQuery.fn.select = function() {};
_done = true;
};
})();


/**
* Return distance between touches
*
Expand Down Expand Up @@ -138,8 +158,6 @@ define(function( require )
*/
var onTouchStart = function onTouchStartClosure()
{
var _disabled = false;

function delayedClick() {
// Only process mousedown if not doing a gesture
if (!_processGesture) {
Expand All @@ -161,6 +179,7 @@ define(function( require )

return function onTouchStart(event)
{
remoteAutoFocus();
_touches = event.originalEvent.touches;
event.stopImmediatePropagation();

Expand All @@ -175,7 +194,7 @@ define(function( require )
_scale = touchDistance(_touches);
_angle = touchAngle(_touches);
_processGesture = true;
return;
return false;
}

Mouse.screen.x = _touches[0].pageX;
Expand All @@ -184,6 +203,7 @@ define(function( require )
_intersect = true;

_timer = Events.setTimeout( delayedClick, 200);
return false;
};
}();

Expand Down Expand Up @@ -233,7 +253,7 @@ define(function( require )
}

var scale = touchDistance(touches) - _scale;
var angle = touchAngle(touches) / _angle;
//var angle = touchAngle(touches) / _angle;
var x = Math.abs(touchTranslationX(_touches, touches));
var y = Math.abs(touchTranslationY(_touches, touches));

Expand All @@ -244,9 +264,11 @@ define(function( require )
}

// Process zoom
Camera.zoomFinal += scale * 0.1;
Camera.zoomFinal = Math.min( Camera.zoomFinal, Math.abs(Camera.altitudeTo-Camera.altitudeFrom) * Camera.MAX_ZOOM );
Camera.zoomFinal = Math.max( Camera.zoomFinal, 2.0 );
if (Math.abs(scale) > 10) {
Camera.zoomFinal += scale * 0.1;
Camera.zoomFinal = Math.min( Camera.zoomFinal, Math.abs(Camera.altitudeTo-Camera.altitudeFrom) * Camera.MAX_ZOOM );
Camera.zoomFinal = Math.max( Camera.zoomFinal, 2.0 );
}
}


Expand Down
15 changes: 15 additions & 0 deletions src/DB/DBManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,18 @@ define(function(require)
return null;
}

// Dual weapon (based on range id)
if (id > 500 && (id < 2100 || id > 2200)) {
return DB.getWeaponPath(id, job, sex);
}

var baseClass = WeaponJobTable[job] || WeaponJobTable[0];

// ItemID to View Id
if ((id in ItemTable) && ('ClassNum' in ItemTable[id])) {
id = ItemTable[id].ClassNum;
}

return 'data/sprite/\xb9\xe6\xc6\xd0/' + baseClass + '/' + baseClass + '_' + SexTable[sex] + '_' + ( ShieldTable[id] || ShieldTable[1] );
};

Expand All @@ -333,6 +343,11 @@ define(function(require)

var baseClass = WeaponJobTable[job] || WeaponJobTable[0];

// ItemID to View Id
if ((id in ItemTable) && ('ClassNum' in ItemTable[id])) {
id = ItemTable[id].ClassNum;
}

return 'data/sprite/\xc0\xce\xb0\xa3\xc1\xb7/' + baseClass + '/' + baseClass + '_' + SexTable[sex] + ( WeaponTable[id] || ('_' + id) ) ;
};

Expand Down
Loading

0 comments on commit 8b2e9f5

Please sign in to comment.