add theme toggle keys

This commit is contained in:
Hannes Janetzek 2013-06-24 15:26:31 +02:00
parent 30839efffd
commit 1f3041e6fe

View File

@ -15,6 +15,7 @@ import org.oscim.view.MapViewPosition;
import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.Input.Buttons; import com.badlogic.gdx.Input.Buttons;
import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.InputProcessor;
@ -33,6 +34,7 @@ public class GdxMap implements ApplicationListener, MapRenderCallback {
// Stage ui; // Stage ui;
// Label fps; // Label fps;
// BitmapFont font; // BitmapFont font;
MapTileLayer mMapLayer;
@Override @Override
public void create() { public void create() {
@ -50,17 +52,16 @@ public class GdxMap implements ApplicationListener, MapRenderCallback {
mWidth = w; mWidth = w;
mHeight = h; mHeight = h;
TileSource tileSource = new OSciMap2TileSource(); TileSource tileSource = new OSciMap2TileSource();
tileSource.setOption("url", tileSource.setOption("url", "http://city.informatik.uni-bremen.de/osci/map-live");
"http://city.informatik.uni-bremen.de/osci/map-live");
//TileSource tileSource = new OSciMap4TileSource(); //TileSource tileSource = new OSciMap4TileSource();
//tileSource.setOption("url", "http://city.informatik.uni-bremen.de/osci/testing"); //tileSource.setOption("url", "http://city.informatik.uni-bremen.de/osci/testing");
MapTileLayer l = mMapView.setBaseMap(tileSource); mMapLayer = mMapView.setBaseMap(tileSource);
l.setRenderTheme(InternalRenderTheme.DEFAULT); mMapLayer.setRenderTheme(InternalRenderTheme.DEFAULT);
//mMapView.getLayerManager().add(new GenericOverlay(mMapView, new //mMapView.getLayerManager().add(new GenericOverlay(mMapView, new
// GridRenderLayer(mMapView))); // GridRenderLayer(mMapView)));
mMapView.getMapViewPosition().setViewport(w, h); mMapView.getMapViewPosition().setViewport(w, h);
@ -95,11 +96,11 @@ public class GdxMap implements ApplicationListener, MapRenderCallback {
// Gdx.gl20.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0); // Gdx.gl20.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0);
// Gdx.gl20.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, 0); // Gdx.gl20.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, 0);
// int f = Gdx.graphics.getFramesPerSecond(); // int f = Gdx.graphics.getFramesPerSecond();
// if (f != fpsCnt) { // if (f != fpsCnt) {
// Log.d("fps", ">" + f); // Log.d("fps", ">" + f);
// fpsCnt = f; // fpsCnt = f;
// } // }
// fps.setText("fps: " + Gdx.graphics.getFramesPerSecond()); // fps.setText("fps: " + Gdx.graphics.getFramesPerSecond());
// ui.draw(); // ui.draw();
@ -241,7 +242,7 @@ public class GdxMap implements ApplicationListener, MapRenderCallback {
@Override @Override
public boolean keyDown(int keycode) { public boolean keyDown(int keycode) {
// switch (keycode) { switch (keycode) {
// //
// case Input.Keys.UP: // case Input.Keys.UP:
// mMapPosition.moveMap(0, -50); // mMapPosition.moveMap(0, -50);
@ -260,17 +261,17 @@ public class GdxMap implements ApplicationListener, MapRenderCallback {
// mMapView.redrawMap(true); // mMapView.redrawMap(true);
// break; // break;
// //
// case Input.Keys.R: case Input.Keys.R:
// mMapView.setRenderTheme(InternalRenderTheme.DEFAULT); mMapLayer.setRenderTheme(InternalRenderTheme.DEFAULT);
// mMapView.redrawMap(true); mMapView.updateMap(false);
// break; break;
//
// case Input.Keys.T: case Input.Keys.T:
// mMapView.setRenderTheme(InternalRenderTheme.TRONRENDER); mMapLayer.setRenderTheme(InternalRenderTheme.TRONRENDER);
// mMapView.redrawMap(true); mMapView.updateMap(false);
// break; break;
//
// } }
return true; return true;
} }
@ -285,9 +286,7 @@ public class GdxMap implements ApplicationListener, MapRenderCallback {
} }
@Override @Override
public boolean touchDown(int screenX, int screenY, int pointer, public boolean touchDown(int screenX, int screenY, int pointer, int button) {
int button) {
if (button == Buttons.MIDDLE) { if (button == Buttons.MIDDLE) {
mActiveScale = true; mActiveScale = true;
// mActiveTilt = true; // mActiveTilt = true;
@ -316,8 +315,7 @@ public class GdxMap implements ApplicationListener, MapRenderCallback {
if (mActiveScale) { if (mActiveScale) {
// changed = mMapPosition.tilt((screenY - mStartY) / 5f); // changed = mMapPosition.tilt((screenY - mStartY) / 5f);
changed = mMapPosition.scaleMap(1 - (screenY - mPosY) / 100f, changed = mMapPosition.scaleMap(1 - (screenY - mPosY) / 100f, 0, 0);
0, 0);
mPosY = screenY; mPosY = screenY;
return true; return true;
} }