public void onReleaseCapture() { if (!canDeliverEvents()) return; LayerManager manager = getLayerManagerAt(mPrimaryLayerManagerIndex); if (manager == null) return; manager.releaseCapture(); }
public void recheckInputState() throws TJSException { // slow timer tick (about 1 sec interval, inaccurate) LayerManager manager = getLayerManagerAt(mPrimaryLayerManagerIndex); if (manager == null) return; manager.recheckInputState(); }
public GameMenu(GameMain midlet_ /*,ConnectionServer conn_,RoleDataValue roleData_*/) { // true->使用GameAction(boolean suppressKeyEvents) , false->不使用GameAction(boolean // suppressKeyEvents) super(false); // 使用全螢幕 setFullScreenMode(true); midlet = midlet_; // music = music_; // roleData = roleData_; display = midlet.getDisplay(); layMa = new LayerManager(); spInterface = new Sprite(createImage("/image/gameInterface/inface.png"), bgWidth, bgHeight); spName = new Sprite(createImage("/image/gameInterface/Title.png"), 84, 15); menustate = 0; menuNum = 3; // setFullScreenMode(true); g = getGraphics(); /*if(!(getWidth()<176) || !(getHeight()<208)){ disWidth = (getWidth()-176)/2;//抓取螢幕的中心點 disHeight = (getHeight()-208)/2;//抓取螢幕的中心點 }*/ // 設定Sprite位置 spName.setPosition(80, 20); spInterface.setPosition(0, 0); // 加入到LayerManager layMa.append(spName); spName.setVisible(false); layMa.append(spInterface); spInterface.setFrame(0); System.out.println("start"); start(); }
public void onMouseOutOfWindow() throws TJSException { if (!canDeliverEvents()) return; LayerManager manager = getLayerManagerAt(mPrimaryLayerManagerIndex); if (manager == null) return; manager.notifyMouseOutOfWindow(); }
private void dumpLayerStructure() { // すべての layer manager の DumpLayerStructure を呼ぶ final int count = mManagers.size(); for (int i = 0; i < count; i++) { LayerManager m = mManagers.get(i); m.dumpLayerStructure(); } }
private void update() throws VariantException, TJSException { // すべての layer manager の UpdateToDrawDevice を呼ぶ final int count = mManagers.size(); for (int i = 0; i < count; i++) { LayerManager m = mManagers.get(i); m.updateToDrawDevice(); } }
void getSrcSize(Size s) { s.width = 0; s.height = 0; LayerManager manager = getLayerManagerAt(mPrimaryLayerManagerIndex); if (manager == null) return; if (!manager.getPrimaryLayerSize(s)) { s.width = 0; s.height = 0; } }
private void requestInvalidation(final Rect rect) { Point lt = new Point(rect.left, rect.top); Point rb = new Point(rect.right, rect.bottom); if (!transformToPrimaryLayerManager(lt)) return; if (!transformToPrimaryLayerManager(rb)) return; rb.x++; // 誤差の吸収(本当はもうちょっと厳密にやらないとならないがそれが問題になることはない) rb.y++; LayerManager manager = getLayerManagerAt(mPrimaryLayerManagerIndex); if (manager == null) return; manager.requestInvalidation(new Rect(lt.x, lt.y, rb.x, rb.y)); }
public void onKeyPress(char key) { if (!canDeliverEvents()) return; Dispatch2 owner = mOwner.get(); if (owner != null) { Variant[] arg = new Variant[1]; arg[0] = new Variant(String.valueOf(key)); TVP.EventManager.postEvent(owner, owner, "onKeyPress", 0, EventManager.EPT_IMMEDIATE, arg); } LayerManager manager = getLayerManagerAt(mPrimaryLayerManagerIndex); if (manager == null) return; manager.notifyKeyPress(key); }
private boolean transformFromPrimaryLayerManager(Point pt) { LayerManager manager = getLayerManagerAt(mPrimaryLayerManagerIndex); if (manager == null) return false; // プライマリレイヤマネージャのプライマリレイヤのサイズを得る Size pl = new Size(); if (!manager.getPrimaryLayerSize(pl)) return false; // x , y は DestRect の 0, 0 を原点とした座標として渡されてきている pt.x = pl.width != 0 ? (pt.x * mDestRect.width() / pl.width) : 0; pt.y = pl.height != 0 ? (pt.y * mDestRect.height() / pl.height) : 0; return true; }
public void onKeyUp(int key, int shift) { if (!canDeliverEvents()) return; Dispatch2 owner = mOwner.get(); if (owner != null) { Variant[] arg = new Variant[2]; arg[0] = new Variant(key); arg[1] = new Variant(shift); TVP.EventManager.postEvent(owner, owner, "onKeyUp", 0, EventManager.EPT_IMMEDIATE, arg); } LayerManager manager = getLayerManagerAt(mPrimaryLayerManagerIndex); if (manager == null) return; manager.notifyKeyUp(key, shift); }
public MapTileLayer setBaseMap(TileSource tileSource) { MapTileLayer baseLayer = new MapTileLayer(this); baseLayer.setTileSource(tileSource); mLayerManager.add(1, baseLayer); mRotationEnabled = true; // mLayerManager.add(new GenericOverlay(this, new GridRenderLayer(this))); mLayerManager.add(new BuildingOverlay(this, baseLayer.getTileLayer())); LabelLayer ll = new LabelLayer(this, baseLayer.getTileLayer()); mLayerManager.add(ll); return baseLayer; }
@Override public boolean onTouchEvent(MotionEvent motionEvent) { if (!isClickable()) return false; return mLayerManager.handleMotionEvent(motionEvent); }
public void onDoubleClick(int x, int y) throws TJSException { if (!canDeliverEvents()) return; Dispatch2 owner = mOwner.get(); if (owner != null) { Variant[] arg = new Variant[2]; arg[0] = new Variant(x); arg[1] = new Variant(y); TVP.EventManager.postEvent(owner, owner, "onDoubleClick", 0, EventManager.EPT_IMMEDIATE, arg); } Point pos = new Point(x, y); if (!transformToPrimaryLayerManager(pos)) return; LayerManager manager = getLayerManagerAt(mPrimaryLayerManagerIndex); if (manager == null) return; manager.notifyDoubleClick(pos.x, pos.y); }
// 顯示畫面 public void drawDisplay() { g = getGraphics(); g.setColor(0, 0, 0); g.drawRect(disWidth - 1, disHeight - 1, 176 + 1, 208 + 1); layMa.paint(g, disWidth, disHeight); g.drawString(getWidth() + "|" + getHeight(), 0, 0, 0); flushGraphics(); }
public void onMouseWheel(int shift, int delta, int x, int y) { if (!canDeliverEvents()) return; Dispatch2 owner = mOwner.get(); if (owner != null) { Variant[] arg = new Variant[4]; arg[0] = new Variant(shift); arg[1] = new Variant(delta); arg[2] = new Variant(x); arg[3] = new Variant(y); TVP.EventManager.postEvent(owner, owner, "onMouseWheel", 0, EventManager.EPT_IMMEDIATE, arg); } Point pos = new Point(x, y); if (!transformToPrimaryLayerManager(pos)) return; LayerManager manager = getLayerManagerAt(mPrimaryLayerManagerIndex); if (manager == null) return; manager.notifyMouseWheel(shift, delta, pos.x, pos.y); }
/** * Update all Layers on Main thread. * * @param forceRedraw also render frame FIXME (does nothing atm) */ void redrawMapInternal(boolean forceRedraw) { boolean changed = forceRedraw; if (mPausing || !mInitialized) return; if (forceRedraw && !mClearMap) mGLView.requestRender(); // get the current MapPosition changed |= mMapViewPosition.getMapPosition(mMapPosition); mLayerManager.onUpdate(mMapPosition, changed, mClearMap); // delay redraw until all layers had the chance to clear // their state. if (mClearMap) { mGLView.requestRender(); mClearMap = false; } }
public void fightDo(Soldier[] enemy, LayerManager lm) { lm.remove(sptSword); sptSword = null; int msg = checkMsg[fightRange[fightCurIndex][0]][fightRange[fightCurIndex][1]]; if (msg < 0) return; if (isHero) { if (msg < 100) return; else msg -= 100; } else { if (msg >= 100) return; } int delHp = (grade + 1) * fightPower + 5 - (enemy[msg].getGrade() + 1) * enemy[msg].getDefencePwoer(); if (delHp <= 0) delHp = 1; enemy[msg].setIsBeFightd(delHp); thisCol = oldCol; thisRow = oldRow; }
/** * @param context the enclosing MapActivity instance. * @param attributeSet a set of attributes. * @throws IllegalArgumentException if the context object is not an instance of {@link * MapActivity} . */ public MapView(Context context, AttributeSet attributeSet) { super(context, attributeSet); if (!(context instanceof MapActivity)) { throw new IllegalArgumentException("context is not an instance of MapActivity"); } this.setWillNotDraw(true); DisplayMetrics metrics = getResources().getDisplayMetrics(); dpi = Math.max(metrics.xdpi, metrics.ydpi); // TODO make this dpi dependent Tile.SIZE = 400; MapActivity mapActivity = (MapActivity) context; mMapViewPosition = new MapViewPosition(this); mMapPosition = new MapPosition(); mLayerManager = new LayerManager(context); mGLView = new GLView(context, this); mDebugSettings = new DebugSettings(); // FIXME MapTileLoader.setDebugSettings(mDebugSettings); mapActivity.registerMapView(this); LayoutParams params = new LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT); addView(mGLView, params); mLayerManager.add(0, new MapEventLayer(this)); clearMap(); redrawMap(false); }
public void destroy() { mLayerManager.destroy(); }
public void setBackgroundMap(BitmapTileLayer tileLayer) { mLayerManager.add(0, tileLayer); }
public MapTileLayer setBaseMap(BitmapTileLayer tileLayer) { mLayerManager.add(0, new MapEventLayer(this)); mLayerManager.add(1, tileLayer); return null; }
public void setFocusedLayer(LayerNI layer) throws TJSException { LayerManager manager = getLayerManagerAt(mPrimaryLayerManagerIndex); if (manager == null) return; manager.setFocusedLayer(layer); }
public LayerNI getFocusedLayer() { LayerManager manager = getLayerManagerAt(mPrimaryLayerManagerIndex); if (manager == null) return null; return manager.getFocusedLayer(); }