Improve code / xml formatting, #54

This commit is contained in:
Emux
2016-07-12 19:25:33 +03:00
parent e793e8851b
commit 43ca550832
133 changed files with 2803 additions and 2791 deletions

View File

@@ -332,19 +332,19 @@ public abstract class GwtApplication implements EntryPoint, Application {
**/
private static native AgentInfo computeAgentInfo() /*-{
var userAgent = navigator.userAgent.toLowerCase();
return {
// browser type flags
isFirefox : userAgent.indexOf("firefox") != -1,
isChrome : userAgent.indexOf("chrome") != -1,
isSafari : userAgent.indexOf("safari") != -1,
isOpera : userAgent.indexOf("opera") != -1,
isIE : userAgent.indexOf("msie") != -1,
// OS type flags
isMacOS : userAgent.indexOf("mac") != -1,
isLinux : userAgent.indexOf("linux") != -1,
isWindows : userAgent.indexOf("win") != -1
};
}-*/;
return {
// browser type flags
isFirefox : userAgent.indexOf("firefox") != -1,
isChrome : userAgent.indexOf("chrome") != -1,
isSafari : userAgent.indexOf("safari") != -1,
isOpera : userAgent.indexOf("opera") != -1,
isIE : userAgent.indexOf("msie") != -1,
// OS type flags
isMacOS : userAgent.indexOf("mac") != -1,
isLinux : userAgent.indexOf("linux") != -1,
isWindows : userAgent.indexOf("win") != -1
};
}-*/;
/**
* Returned by {@link #agentInfo}. Kindly borrowed from PlayN.
@@ -352,35 +352,35 @@ public abstract class GwtApplication implements EntryPoint, Application {
public static class AgentInfo extends JavaScriptObject {
public final native boolean isFirefox() /*-{
return this.isFirefox;
}-*/;
}-*/;
public final native boolean isChrome() /*-{
return this.isChrome;
}-*/;
return this.isChrome;
}-*/;
public final native boolean isSafari() /*-{
return this.isSafari;
}-*/;
return this.isSafari;
}-*/;
public final native boolean isOpera() /*-{
return this.isOpera;
}-*/;
return this.isOpera;
}-*/;
public final native boolean isIE() /*-{
return this.isIE;
}-*/;
return this.isIE;
}-*/;
public final native boolean isMacOS() /*-{
return this.isMacOS;
}-*/;
return this.isMacOS;
}-*/;
public final native boolean isLinux() /*-{
return this.isLinux;
}-*/;
return this.isLinux;
}-*/;
public final native boolean isWindows() /*-{
return this.isWindows;
}-*/;
return this.isWindows;
}-*/;
protected AgentInfo() {
}

View File

@@ -96,15 +96,15 @@ public class GwtGraphics implements Graphics {
public static native double getDevicePixelRatioJSNI() /*-{
return $wnd.devicePixelRatio || 1.0;
}-*/;
}-*/;
public static native int getWindowWidthJSNI() /*-{
return $wnd.innerWidth;
}-*/;
}-*/;
public static native int getWindowHeightJSNI() /*-{
return $wnd.innerHeight;
}-*/;
return $wnd.innerHeight;
}-*/;
public WebGLRenderingContext getContext() {
return context;
@@ -173,22 +173,22 @@ public class GwtGraphics implements Graphics {
}
private native int getScreenWidthJSNI() /*-{
return $wnd.screen.width;
}-*/;
return $wnd.screen.width;
}-*/;
private native int getScreenHeightJSNI() /*-{
return $wnd.screen.height;
}-*/;
return $wnd.screen.height;
}-*/;
private native boolean isFullscreenJSNI() /*-{
if ("webkitIsFullScreen" in $doc) {
return $doc.webkitIsFullScreen;
}
if ("mozFullScreen" in $doc) {
return $doc.mozFullScreen;
}
return false
}-*/;
if ("webkitIsFullScreen" in $doc) {
return $doc.webkitIsFullScreen;
}
if ("mozFullScreen" in $doc) {
return $doc.mozFullScreen;
}
return false
}-*/;
private void fullscreenChanged() {
if (!isFullscreen()) {
@@ -198,39 +198,39 @@ public class GwtGraphics implements Graphics {
}
private native boolean setFullscreenJSNI(GwtGraphics graphics, CanvasElement element) /*-{
if (element.webkitRequestFullScreen) {
element.width = $wnd.screen.width;
element.height = $wnd.screen.height;
element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
$doc
.addEventListener(
"webkitfullscreenchange",
function() {
graphics.@com.badlogic.gdx.backends.gwt.GwtGraphics::fullscreenChanged()();
}, false);
return true;
}
if (element.mozRequestFullScreen) {
element.width = $wnd.screen.width;
element.height = $wnd.screen.height;
element.mozRequestFullScreen();
$doc
.addEventListener(
"mozfullscreenchange",
function() {
graphics.@com.badlogic.gdx.backends.gwt.GwtGraphics::fullscreenChanged()();
}, false);
return true;
}
return false;
}-*/;
if (element.webkitRequestFullScreen) {
element.width = $wnd.screen.width;
element.height = $wnd.screen.height;
element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
$doc
.addEventListener(
"webkitfullscreenchange",
function() {
graphics.@com.badlogic.gdx.backends.gwt.GwtGraphics::fullscreenChanged()();
}, false);
return true;
}
if (element.mozRequestFullScreen) {
element.width = $wnd.screen.width;
element.height = $wnd.screen.height;
element.mozRequestFullScreen();
$doc
.addEventListener(
"mozfullscreenchange",
function() {
graphics.@com.badlogic.gdx.backends.gwt.GwtGraphics::fullscreenChanged()();
}, false);
return true;
}
return false;
}-*/;
private native void exitFullscreen() /*-{
if ($doc.webkitExitFullscreen)
$doc.webkitExitFullscreen();
if ($doc.mozExitFullscreen)
$doc.mozExitFullscreen();
}-*/;
if ($doc.webkitExitFullscreen)
$doc.webkitExitFullscreen();
if ($doc.mozExitFullscreen)
$doc.mozExitFullscreen();
}-*/;
@Override
public DisplayMode getDesktopDisplayMode() {

View File

@@ -271,22 +271,22 @@ public class GwtInput implements Input {
*/
private native boolean isCursorCatchedJSNI() /*-{
if (!navigator.pointer) {
navigator.pointer = navigator.webkitPointer || navigator.mozPointer;
}
if (navigator.pointer) {
if (typeof (navigator.pointer.isLocked) === "boolean") {
// Chrome initially launched with this interface
return navigator.pointer.isLocked;
} else if (typeof (navigator.pointer.isLocked) === "function") {
// Some older builds might provide isLocked as a function
return navigator.pointer.isLocked();
} else if (typeof (navigator.pointer.islocked) === "function") {
// For compatibility with early Firefox build
return navigator.pointer.islocked();
}
}
return false;
}-*/;
navigator.pointer = navigator.webkitPointer || navigator.mozPointer;
}
if (navigator.pointer) {
if (typeof (navigator.pointer.isLocked) === "boolean") {
// Chrome initially launched with this interface
return navigator.pointer.isLocked;
} else if (typeof (navigator.pointer.isLocked) === "function") {
// Some older builds might provide isLocked as a function
return navigator.pointer.isLocked();
} else if (typeof (navigator.pointer.islocked) === "function") {
// For compatibility with early Firefox build
return navigator.pointer.islocked();
}
}
return false;
}-*/;
/**
* from https://github.com/toji/game-shim/blob/master/game-shim.js
@@ -295,40 +295,40 @@ public class GwtInput implements Input {
*/
private native void setCursorCatchedJSNI(CanvasElement element) /*-{
// Navigator pointer is not the right interface according to spec.
// Here for backwards compatibility only
if (!navigator.pointer) {
navigator.pointer = navigator.webkitPointer || navigator.mozPointer;
}
// element.requestPointerLock
if (!element.requestPointerLock) {
element.requestPointerLock = (function() {
return element.webkitRequestPointerLock
|| element.mozRequestPointerLock || function() {
if (navigator.pointer) {
navigator.pointer.lock(element);
}
};
})();
}
element.requestPointerLock();
}-*/;
// Here for backwards compatibility only
if (!navigator.pointer) {
navigator.pointer = navigator.webkitPointer || navigator.mozPointer;
}
// element.requestPointerLock
if (!element.requestPointerLock) {
element.requestPointerLock = (function() {
return element.webkitRequestPointerLock
|| element.mozRequestPointerLock || function() {
if (navigator.pointer) {
navigator.pointer.lock(element);
}
};
})();
}
element.requestPointerLock();
}-*/;
/**
* from https://github.com/toji/game-shim/blob/master/game-shim.js
*/
private native void exitCursorCatchedJSNI() /*-{
if (!$doc.exitPointerLock) {
$doc.exitPointerLock = (function() {
return $doc.webkitExitPointerLock || $doc.mozExitPointerLock
|| function() {
if (navigator.pointer) {
var elem = this;
navigator.pointer.unlock();
}
};
})();
}
}-*/;
if (!$doc.exitPointerLock) {
$doc.exitPointerLock = (function() {
return $doc.webkitExitPointerLock || $doc.mozExitPointerLock
|| function() {
if (navigator.pointer) {
var elem = this;
navigator.pointer.unlock();
}
};
})();
}
}-*/;
/**
* from https://github.com/toji/game-shim/blob/master/game-shim.js
@@ -337,8 +337,8 @@ public class GwtInput implements Input {
* @return movement in x direction
*/
private native float getMovementXJSNI(NativeEvent event) /*-{
return event.movementX || event.webkitMovementX || 0;
}-*/;
return event.movementX || event.webkitMovementX || 0;
}-*/;
/**
* from https://github.com/toji/game-shim/blob/master/game-shim.js
@@ -347,12 +347,12 @@ public class GwtInput implements Input {
* @return movement in y direction
*/
private native float getMovementYJSNI(NativeEvent event) /*-{
return event.movementY || event.webkitMovementY || 0;
}-*/;
return event.movementY || event.webkitMovementY || 0;
}-*/;
private static native boolean isTouchScreen() /*-{
return (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0));
}-*/;
return (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0));
}-*/;
/**
* works only for Chrome > Version 18 with enabled Mouse Lock enable in
@@ -384,55 +384,55 @@ public class GwtInput implements Input {
// kindly borrowed from our dear playn friends...
static native void addEventListener(JavaScriptObject target, String name, GwtInput handler,
boolean capture) /*-{
target
.addEventListener(
name,
function(e) {
handler.@com.badlogic.gdx.backends.gwt.GwtInput::handleEvent(Lcom/google/gwt/dom/client/NativeEvent;)(e);
}, capture);
}-*/;
target
.addEventListener(
name,
function(e) {
handler.@com.badlogic.gdx.backends.gwt.GwtInput::handleEvent(Lcom/google/gwt/dom/client/NativeEvent;)(e);
}, capture);
}-*/;
private static native float getMouseWheelVelocity(NativeEvent evt) /*-{
var delta = 0.0;
var agentInfo = @com.badlogic.gdx.backends.gwt.GwtApplication::agentInfo()();
var delta = 0.0;
var agentInfo = @com.badlogic.gdx.backends.gwt.GwtApplication::agentInfo()();
if (agentInfo.isFirefox) {
if (agentInfo.isMacOS) {
delta = 1.0 * evt.detail;
} else {
delta = 1.0 * evt.detail / 3;
}
} else if (agentInfo.isOpera) {
if (agentInfo.isLinux) {
delta = -1.0 * evt.wheelDelta / 80;
} else {
// on mac
delta = -1.0 * evt.wheelDelta / 40;
}
} else if (agentInfo.isChrome || agentInfo.isSafari) {
delta = -1.0 * evt.wheelDelta / 120;
// handle touchpad for chrome
if (Math.abs(delta) < 1) {
if (agentInfo.isWindows) {
delta = -1.0 * evt.wheelDelta;
} else if (agentInfo.isMacOS) {
delta = -1.0 * evt.wheelDelta / 3;
}
}
}
return delta;
}-*/;
if (agentInfo.isFirefox) {
if (agentInfo.isMacOS) {
delta = 1.0 * evt.detail;
} else {
delta = 1.0 * evt.detail / 3;
}
} else if (agentInfo.isOpera) {
if (agentInfo.isLinux) {
delta = -1.0 * evt.wheelDelta / 80;
} else {
// on mac
delta = -1.0 * evt.wheelDelta / 40;
}
} else if (agentInfo.isChrome || agentInfo.isSafari) {
delta = -1.0 * evt.wheelDelta / 120;
// handle touchpad for chrome
if (Math.abs(delta) < 1) {
if (agentInfo.isWindows) {
delta = -1.0 * evt.wheelDelta;
} else if (agentInfo.isMacOS) {
delta = -1.0 * evt.wheelDelta / 3;
}
}
}
return delta;
}-*/;
/**
* Kindly borrowed from PlayN.
**/
protected static native String getMouseWheelEvent() /*-{
if (navigator.userAgent.toLowerCase().indexOf('firefox') != -1) {
return "DOMMouseScroll";
} else {
return "mousewheel";
}
}-*/;
if (navigator.userAgent.toLowerCase().indexOf('firefox') != -1) {
return "DOMMouseScroll";
} else {
return "mousewheel";
}
}-*/;
/**
* Kindly borrowed from PlayN.
@@ -452,15 +452,15 @@ public class GwtInput implements Input {
private void hookEvents() {
addEventListener(canvas, "mousedown", this, true);
// addEventListener(Document.get(), "mousedown", this, true);
// addEventListener(Document.get(), "mousedown", this, true);
addEventListener(canvas, "mouseup", this, true);
// addEventListener(Document.get(), "mouseup", this, true);
// addEventListener(Document.get(), "mouseup", this, true);
addEventListener(canvas, "mousemove", this, true);
// addEventListener(Document.get(), "mousemove", this, true);
// addEventListener(Document.get(), "mousemove", this, true);
addEventListener(canvas, getMouseWheelEvent(), this, true);
// addEventListener(Document.get(), "keydown", this, false);
// addEventListener(Document.get(), "keyup", this, false);
// addEventListener(Document.get(), "keypress", this, false);
// addEventListener(Document.get(), "keydown", this, false);
// addEventListener(Document.get(), "keyup", this, false);
// addEventListener(Document.get(), "keypress", this, false);
addEventListener(canvas, "keydown", this, false);
addEventListener(canvas, "keyup", this, false);
addEventListener(canvas, "keypress", this, false);

View File

@@ -379,25 +379,25 @@ public class GLMatrix {
System.arraycopy(tmp, 0, mata, 0, 16);
}
// @Override
// public void finalize() {
// if (pointer != 0)
// delete(pointer);
// }
// @Override
// public void finalize() {
// if (pointer != 0)
// delete(pointer);
// }
/* Copyright (C) 2007 The Android Open Source Project
/* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. */
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. */
/**
* Define a projection matrix in terms of six clip planes

View File

@@ -118,8 +118,8 @@ public class LwHttp implements HttpEngine {
@Override
public boolean requestCompleted(boolean success) {
// mHttpRequest.clearOnReadyStateChange();
// mHttpRequest = null;
// mHttpRequest.clearOnReadyStateChange();
// mHttpRequest = null;
return true;
}

View File

@@ -87,11 +87,11 @@ public class BitmapTileSource extends UrlTileSource {
final Image img = new Image();
img.setVisible(false);
/* As if researching CORS issues doesnt result in
/* As if researching CORS issues doesnt result in
* enough headache...
*
* Here are some more special Chrome/Webkit quirks:
* MUST SET CORS BEFORE URL! */
*
* Here are some more special Chrome/Webkit quirks:
* MUST SET CORS BEFORE URL! */
img.getElement().setAttribute("crossorigin", "anonymous");
img.setUrl(uri);

View File

@@ -124,17 +124,17 @@ public class Tessellator {
return 0;
}
// if (vo.length() != plen) {
// // TODO handle different output points
// log.debug(" + io.length());
// if (vo.length() != plen) {
// // TODO handle different output points
// log.debug(" + io.length());
//
// //for (int i = 0; i < vo.length(); i += 2)
// // log.debug(vo.get(i) + " " + vo.get(i + 1));
// //for (int i = ppos; i < ppos + plen; i += 2)
// // log.debug( points[i]+ " " + points[i + 1]);
// //for (int i = 0; i < vo.length(); i += 2)
// // log.debug(vo.get(i) + " " + vo.get(i + 1));
// //for (int i = ppos; i < ppos + plen; i += 2)
// // log.debug( points[i]+ " " + points[i + 1]);
//
// return 0;
// }
// return 0;
// }
int numIndices = io.length();
@@ -164,17 +164,17 @@ public class Tessellator {
static native Int32Array tessellate(JsArrayNumber points, int pOffset, int pLength,
JsArrayInteger bounds, int bOffset, int bLength)/*-{
return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
bOffset, bOffset + bLength, false);
}-*/;
return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
bOffset, bOffset + bLength, false);
}-*/;
static native TessResult tessellate2(JsArrayNumber points, int pOffset, int pLength,
JsArrayInteger bounds, int bOffset, int bLength)
/*-{
return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
bOffset, bOffset + bLength, true);
}-*/;
return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
bOffset, bOffset + bLength, true);
}-*/;
static final class TessResult extends JavaScriptObject {
protected TessResult() {
@@ -182,10 +182,10 @@ public class Tessellator {
native Float32Array getPoints(JavaScriptObject result)/*-{
return result.vertices;
}-*/;
}-*/;
native Int32Array getIndices(JavaScriptObject result)/*-{
return result.triangles;
}-*/;
return result.triangles;
}-*/;
}
}