diff --git a/core/src/com/etheller/warsmash/WarsmashGdxMapGame.java b/core/src/com/etheller/warsmash/WarsmashGdxMapGame.java index 5687bd8..64375dd 100644 --- a/core/src/com/etheller/warsmash/WarsmashGdxMapGame.java +++ b/core/src/com/etheller/warsmash/WarsmashGdxMapGame.java @@ -161,8 +161,8 @@ public class WarsmashGdxMapGame extends ApplicationAdapter implements CanvasProv // this.mainModel = (MdxModel) this.viewer.load("UI\\Glues\\MainMenu\\MainMenu3D_exp\\MainMenu3D_exp.mdx", // libGDX stuff - final float w = Gdx.graphics.getWidth(); - final float h = Gdx.graphics.getHeight(); + final int width = Gdx.graphics.getWidth(); + final int height = Gdx.graphics.getHeight(); final FreeTypeFontGenerator fontGenerator = new FreeTypeFontGenerator( new DataSourceFileHandle(this.viewer.dataSource, "fonts\\FRIZQT__.TTF")); @@ -177,8 +177,18 @@ public class WarsmashGdxMapGame extends ApplicationAdapter implements CanvasProv // height // Height is multiplied by aspect ratio. this.uiCamera = new OrthographicCamera(); - this.uiViewport = new ExtendViewport(1600, 1200, this.uiCamera); - this.uiViewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); + int aspect3By4Width; + int aspect3By4Height; + if (width < ((height * 4) / 3)) { + aspect3By4Width = width; + aspect3By4Height = (width * 3) / 4; + } + else { + aspect3By4Width = (height * 4) / 3; + aspect3By4Height = height; + } + this.uiViewport = new ExtendViewport(aspect3By4Width, aspect3By4Height, this.uiCamera); + this.uiViewport.update(width, height); this.uiCamera.position.set(this.uiViewport.getMinWorldWidth() / 2, this.uiViewport.getMinWorldHeight() / 2, 0); this.uiCamera.update(); @@ -237,7 +247,7 @@ public class WarsmashGdxMapGame extends ApplicationAdapter implements CanvasProv updateUIScene(); - resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); + resize(width, height); try { this.viewer.loadAfterUI(); diff --git a/core/src/com/etheller/warsmash/parsers/fdf/frames/FilterModeTextureFrame.java b/core/src/com/etheller/warsmash/parsers/fdf/frames/FilterModeTextureFrame.java new file mode 100644 index 0000000..653c9df --- /dev/null +++ b/core/src/com/etheller/warsmash/parsers/fdf/frames/FilterModeTextureFrame.java @@ -0,0 +1,33 @@ +package com.etheller.warsmash.parsers.fdf.frames; + +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.GlyphLayout; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.etheller.warsmash.parsers.fdf.datamodel.Vector4Definition; +import com.etheller.warsmash.parsers.mdlx.Layer.FilterMode; + +public class FilterModeTextureFrame extends TextureFrame { + private int blendSrc; + private int blendDst; + + public FilterModeTextureFrame(final String name, final UIFrame parent, final boolean decorateFileNames, + final Vector4Definition texCoord) { + super(name, parent, decorateFileNames, texCoord); + } + + @Override + protected void internalRender(final SpriteBatch batch, final BitmapFont baseFont, final GlyphLayout glyphLayout) { + final int blendDstFunc = batch.getBlendDstFunc(); + final int blendSrcFunc = batch.getBlendSrcFunc(); + batch.setBlendFunction(this.blendSrc, this.blendDst); + super.internalRender(batch, baseFont, glyphLayout); + batch.setBlendFunction(blendSrcFunc, blendDstFunc); + } + + public void setFilterMode(final FilterMode filterMode) { + final int[] layerFilterMode = com.etheller.warsmash.viewer5.handlers.mdx.FilterMode.layerFilterMode(filterMode); + this.blendSrc = layerFilterMode[0]; + this.blendDst = layerFilterMode[1]; + } + +} diff --git a/core/src/com/etheller/warsmash/parsers/fdf/frames/TextureFrame.java b/core/src/com/etheller/warsmash/parsers/fdf/frames/TextureFrame.java index 3e1ae18..203a167 100644 --- a/core/src/com/etheller/warsmash/parsers/fdf/frames/TextureFrame.java +++ b/core/src/com/etheller/warsmash/parsers/fdf/frames/TextureFrame.java @@ -66,9 +66,6 @@ public class TextureFrame extends AbstractRenderableFrame { @Override public UIFrame touchDown(final float screenX, final float screenY, final int button) { - if (this.renderBounds.contains(screenX, screenY)) { - return this; - } return super.touchDown(screenX, screenY, button); } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderTargetWidget.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderTargetWidget.java new file mode 100644 index 0000000..13ce91a --- /dev/null +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/orders/COrderTargetWidget.java @@ -0,0 +1,5 @@ +package com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders; + +public class COrderTargetWidget { + +} diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUI.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUI.java index 86643d5..0deff81 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUI.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUI.java @@ -14,7 +14,6 @@ import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; -import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; @@ -138,8 +137,6 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma private int selectedSoundCount = 0; private final ActiveCommandUnitTargetFilter activeCommandUnitTargetFilter; - private UIFrame clickUI = null; - public MeleeUI(final DataSource dataSource, final Viewport uiViewport, final FreeTypeFontGenerator fontGenerator, final Scene uiScene, final Scene portraitScene, final CameraPreset[] cameraPresets, final CameraRates cameraRates, final War3MapViewer war3MapViewer, final RootFrameListener rootFrameListener, @@ -421,7 +418,9 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma mouseX = Math.max(minX, Math.min(maxX, mouseX)); mouseY = Math.max(minY, Math.min(maxY, mouseY)); -// Gdx.input.setCursorPosition(mouseX, mouseY); + if (Gdx.input.isCursorCatched()) { + Gdx.input.setCursorPosition(mouseX, mouseY); + } screenCoordsVector.set(mouseX, mouseY); this.uiViewport.unproject(screenCoordsVector); @@ -481,18 +480,6 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma this.meleeUIMinimap.render(batch, this.war3MapViewer.units); this.timeIndicator.setFrameByRatio(this.war3MapViewer.simulation.getGameTimeOfDay() / this.war3MapViewer.simulation.getGameplayConstants().getGameDayHours()); - - if (this.clickUI != null) { - batch.end(); - this.shapeRenderer.setProjectionMatrix(this.uiViewport.getCamera().combined); - this.shapeRenderer.begin(ShapeType.Line); - this.shapeRenderer.rect(this.clickUI.getFramePointX(FramePoint.LEFT), - this.clickUI.getFramePointY(FramePoint.BOTTOM), - this.clickUI.getFramePointX(FramePoint.RIGHT) - this.clickUI.getFramePointX(FramePoint.LEFT), - this.clickUI.getFramePointY(FramePoint.TOP) - this.clickUI.getFramePointY(FramePoint.BOTTOM)); - this.shapeRenderer.end(); - batch.begin(); - } } public void portraitTalk() { @@ -787,8 +774,6 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma this.cameraManager.scrolled(amount); } - private float lastX, lastY; - public boolean touchDown(final int screenX, final int screenY, final float worldScreenY, final int button) { screenCoordsVector.set(screenX, screenY); this.uiViewport.unproject(screenCoordsVector); @@ -797,8 +782,6 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma screenCoordsVector.y); this.cameraManager.target.x = worldPoint.x; this.cameraManager.target.y = worldPoint.y; - this.lastX = screenCoordsVector.x; - this.lastY = screenCoordsVector.y; return true; } final UIFrame clickedUIFrame = this.rootFrame.touchDown(screenCoordsVector.x, screenCoordsVector.y, button); @@ -973,11 +956,6 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma } } } - else { - this.clickUI = clickedUIFrame; - this.lastX = screenCoordsVector.x; - this.lastY = screenCoordsVector.y; - } return false; } @@ -988,19 +966,13 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma public boolean touchDragged(final int screenX, final int screenY, final float worldScreenY, final int pointer) { screenCoordsVector.set(screenX, screenY); this.uiViewport.unproject(screenCoordsVector); - final float dx = screenCoordsVector.x - this.lastX; - final float dy = screenCoordsVector.y - this.lastY; if (this.meleeUIMinimap.containsMouse(screenCoordsVector.x, screenCoordsVector.y)) { - this.meleeUIMinimap.touchDragged(screenX, screenY, worldScreenY, pointer, dx, dy); + final Vector2 worldPoint = this.meleeUIMinimap.getWorldPointFromScreen(screenCoordsVector.x, + screenCoordsVector.y); + this.cameraManager.target.x = worldPoint.x; + this.cameraManager.target.y = worldPoint.y; } - else if (this.clickUI != null) { - this.clickUI.setFramePointX(FramePoint.LEFT, this.clickUI.getFramePointX(FramePoint.LEFT) + dx); - this.clickUI.setFramePointY(FramePoint.BOTTOM, this.clickUI.getFramePointY(FramePoint.BOTTOM) + dy); - } - - this.lastX = screenCoordsVector.x; - this.lastY = screenCoordsVector.y; return false; } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUIMinimap.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUIMinimap.java index ccd0ee9..fcaf00f 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUIMinimap.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUIMinimap.java @@ -59,12 +59,4 @@ public class MeleeUIMinimap { public boolean containsMouse(final float x, final float y) { return this.minimapFilledArea.contains(x, y); } - - public void touchDragged(final int screenX, final int screenY, final float worldScreenY, final int pointer, - final float dx, final float dy) { - this.minimapFilledArea.x += dx; - this.minimapFilledArea.y += dy; - this.minimap.x += dx; - this.minimap.y += dy; - } } diff --git a/desktop/src/com/etheller/warsmash/desktop/DesktopLauncher.java b/desktop/src/com/etheller/warsmash/desktop/DesktopLauncher.java index 0675b3a..9caaca2 100644 --- a/desktop/src/com/etheller/warsmash/desktop/DesktopLauncher.java +++ b/desktop/src/com/etheller/warsmash/desktop/DesktopLauncher.java @@ -24,7 +24,7 @@ import com.etheller.warsmash.viewer5.gl.SoundLengthExtension; import com.etheller.warsmash.viewer5.gl.WireframeExtension; public class DesktopLauncher { - public static void main(String[] arg) { + public static void main(final String[] arg) { Extensions.angleInstancedArrays = new ANGLEInstancedArrays() { @Override public void glVertexAttribDivisorANGLE(final int index, final int divisor) { @@ -83,11 +83,10 @@ public class DesktopLauncher { config.useGL30 = true; config.gles30ContextMajorVersion = 3; config.gles30ContextMinorVersion = 3; - //config.samples = 16; + // config.samples = 16; // config.vSyncEnabled = false; // config.foregroundFPS = 0; // config.backgroundFPS = 0; - arg = new String[]{"-windowed"}; if ((arg.length > 0) && "-windowed".equals(arg[0])) { config.fullscreen = false; }