Java 类com.badlogic.gdx.utils.ObjectMap.Keys 实例源码

项目:RavTech    文件:ShaderManager.java   
/** Resizes internal RavCamera for framebuffer use, call this in you ApplicationListener's resize.
 * 
 * @param width - new screen width
 * @param height - new screen height
 * @param resizeFramebuffers - whether all of the framebuffers should be recreated to match new screen size */
public void resize (int width, int height, boolean resizeFramebuffers) {
    // ?????
    if (resizeFramebuffers) {
        Keys<String> keys = frameBuffers.keys();
        while (keys.hasNext) {
            String key = keys.next();
            FrameBuffer fb = frameBuffers.get(key);
            int oldWidth = fb.getWidth();
            int oldHeight = fb.getHeight();
            Format format = fb.getColorBufferTexture().getTextureData().getFormat();
            fb.dispose();
            frameBuffers.put(key, null);
            float factorX = 1f * width / screenCamera.viewportWidth;
            float factorY = 1f * height / screenCamera.viewportHeight;
            createFB(key, format, (int)(factorX * oldWidth), (int)(factorY * oldHeight));
            // System.out.println("Recreated FB '" + key + "' from " +
            // oldWidth + "x" + oldHeight + " to " +
            // frameBuffers.get(key).getWidth() + "x" +
            // frameBuffers.get(key).getHeight());
        }
    }
    screenCamera = new OrthographicCamera(width, height);
    createScreenQuad();
}
项目:RavTech    文件:ShaderManager.java   
/** Reloads all shaders from disk. Useful for writing shaders: edit and save shader source, reload in game. Should be used for
 * development purposes only! */
public void reload () {
    float t = System.currentTimeMillis();
    Keys<String> keys = shaderPaths.keys();
    while (keys.hasNext) {
        String key = keys.next();
        int ind = shaderPaths.get(key).indexOf(";");
        String vertPath = shaderPaths.get(key).substring(0, ind);
        String fragPath = shaderPaths.get(key).substring(ind + 1, shaderPaths.get(key).length());
        if (am != null)
            add(key, RavTech.files.getAssetHandle(vertPath), RavTech.files.getAssetHandle(fragPath));
        else
            add(key, vertPath, fragPath);
    }
    Gdx.app.log("ShaderManager", "Shaders reloaded in " + (System.currentTimeMillis() - t) + "ms");
}
项目:libgdxcn    文件:PixmapPacker.java   
/** Generates a new {@link TextureAtlas} from the {@link Pixmap} instances inserted so far.
 * @param minFilter
 * @param magFilter
 * @return the TextureAtlas */
public synchronized TextureAtlas generateTextureAtlas (TextureFilter minFilter, TextureFilter magFilter, boolean useMipMaps) {
    TextureAtlas atlas = new TextureAtlas();
    for (Page page : pages) {
        if (page.rects.size != 0) {
            Texture texture = new Texture(new PixmapTextureData(page.image, page.image.getFormat(), useMipMaps, false, true)) {
                @Override
                public void dispose () {
                    super.dispose();
                    getTextureData().consumePixmap().dispose();
                }
            };
            texture.setFilter(minFilter, magFilter);

            Keys<String> names = page.rects.keys();
            for (String name : names) {
                Rectangle rect = page.rects.get(name);
                TextureRegion region = new TextureRegion(texture, (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
                atlas.addRegion(name, region);
            }
        }
    }
    return atlas;
}
项目:vis-editor    文件:SceneMetadataModule.java   
@Override
public void init () {
    json = new Json();

    FileAccessModule fileAccess = projectContainer.get(FileAccessModule.class);

    FileHandle moduleFolder = fileAccess.getModuleFolder(".metadata");
    metadataFile = moduleFolder.child("sceneMetadata");

    if (metadataFile.exists())
        metadata = json.fromJson(SceneMetadataList.class, metadataFile);
    else {
        metadata = new SceneMetadataList();
        metadata.map = new ObjectMap<>();
    }

    //clear no longer existing scenes
    Keys<String> it = metadata.map.keys().iterator();
    while (it.hasNext()) {
        String path = it.next();

        if (fileAccess.getAssetsFolder().child(path).exists() == false)
            it.remove();
    }
}
项目:cachebox3.0    文件:OptionsPane.java   
/**
 *
 */
protected void showDeleteDialog() {

    // FIXME: Check if it used by other style prior to delete it

    Dialog dlgStyle = new Dialog("Delete Style", game.skin) {

        @Override
        protected void result(Object object) {
            if ((Boolean) object == false) {
                return;
            }

            // Now we really add it!
            game.skinProject.remove((String) listStyles.getSelected(), currentStyle.getClass());
            refresh(true);
            game.screenMain.saveToSkin();
            game.screenMain.panePreview.refresh();

        }

    };

    dlgStyle.pad(20);
    dlgStyle.getContentTable().add("You are sure you want to delete this style?");
    dlgStyle.button("OK", true);
    dlgStyle.button("Cancel", false);
    dlgStyle.key(com.badlogic.gdx.Input.Keys.ENTER, true);
    dlgStyle.key(com.badlogic.gdx.Input.Keys.ESCAPE, false);
    dlgStyle.show(getStage());

}
项目:fabulae    文件:OrthogonalGameMapRenderer.java   
public void renderTransitions (int row1, int row2, int col1, int col2, float tileWidth, float tileHeight) {
    spriteBatch.setColor(1, 1, 1, 0.3f);
    Keys<Vector2> coordinates = map.getTransitionTileCoordinates();
    for (Vector2 coordinate : coordinates) {
        if (map.shouldRenderTile((int) coordinate.x, (int) coordinate.y)
                && coordinate.x >= col1 && coordinate.x <= col2
                && coordinate.y >= row1 && coordinate.y <= row2) {
            spriteBatch.draw(map.getTransitionTexture(),coordinate.x*tileWidth,coordinate.y*tileHeight, map.getTileSizeX()
                    * map.getScaleX(), map.getTileSizeY() * map.getScaleY());
        }

    }
    spriteBatch.setColor(1, 1, 1, 1);
}
项目:gaiasky    文件:CustomInterface.java   
private void initSizes(Skin skin) {
    sizes = new ArrayList<Integer>();
    ObjectMap<String, LabelStyle> ls = skin.getAll(LabelStyle.class);
    Keys<String> keys = ls.keys();
    for (String key : keys) {
        if (key.startsWith("msg-")) {
            // Hit
            key = key.substring(4);
            sizes.add(Integer.parseInt(key));
        }
    }

    Collections.sort(sizes);

}
项目:gdx-skineditor    文件:OptionsPane.java   
/**
 * 
 */
protected void showDeleteDialog() {

    // Check if it used by other style prior to delete it
    // FIXME: TODO

    Dialog dlgStyle = new Dialog("Delete Style", game.skin) {

        @Override
        protected void result(Object object) {
            if ((Boolean) object == false) {
                return;
            }

            // Now we really add it!
            game.skinProject.remove((String) listStyles.getSelected(), currentStyle.getClass());
            refresh();
            game.screenMain.saveToSkin();
            game.screenMain.panePreview.refresh();

        }

    };

    dlgStyle.pad(20);
    dlgStyle.getContentTable().add("You are sure you want to delete this style?");
    dlgStyle.button("OK", true);
    dlgStyle.button("Cancel", false);
    dlgStyle.key(com.badlogic.gdx.Input.Keys.ENTER, true);
    dlgStyle.key(com.badlogic.gdx.Input.Keys.ESCAPE, false);
    dlgStyle.show(getStage());

}
项目:cachebox3.0    文件:OptionsPane.java   
/**
 *
 */
protected void createNewStyle() {

    final TextField textStyleName = new TextField("", game.skin);
    Dialog dlgStyle = new Dialog("New Style", game.skin) {

        @Override
        protected void result(Object object) {
            if ((Boolean) object == false) {
                return;
            }

            String styleName = textStyleName.getText();
            if (styleName.length() == 0) {

                game.showMsgDlg("Warning", "No style name entered!", game.screenMain.stage);
                return;
            }

            // Check if the style name is already in use
            if (listItems.contains(styleName, false)) {
                game.showMsgDlg("Warning", "Style name already in use!", game.screenMain.stage);
                return;
            }


            try {
                if (currentStyle instanceof MapArrowStyle) {
                    // switch current style to MapWayPointItemStyle
                    // we have only one MapArrowStyle
                    currentStyle = MapWayPointItemStyle.class.newInstance();
                }
                game.skinProject.add(styleName, currentStyle.getClass().newInstance());
            } catch (Exception e) {
                e.printStackTrace();
            }
            //game.skinProject.add(text, game.skin.get("default", currentStyle.getClass()), currentStyle.getClass());
            game.screenMain.saveToSkin();
            refresh(true);

            game.screenMain.panePreview.refresh();

        }

    };

    dlgStyle.pad(20);
    dlgStyle.getContentTable().add("Style name:");
    dlgStyle.getContentTable().add(textStyleName).pad(20);
    dlgStyle.button("OK", true);
    dlgStyle.button("Cancel", false);
    dlgStyle.key(com.badlogic.gdx.Input.Keys.ENTER, true);
    dlgStyle.key(com.badlogic.gdx.Input.Keys.ESCAPE, false);
    dlgStyle.show(getStage());
    getStage().setKeyboardFocus(textStyleName);

}
项目:cachebox3.0    文件:OptionsPane.java   
/**
 *
 */
public void refreshSelection() {

    String key = listStyles.getSelected();

    ImageButton button = (ImageButton) game.screenMain.barWidgets.group.getChecked();
    String widget = button.getUserObject().toString();
    String widgetStyle = game.resolveWidgetPackageName(widget);
    Gdx.app.log("OptionsPane", "Fetching style:" + widgetStyle);

    listItems.clear();

    try {
        Class<?> style = Class.forName(widgetStyle);

        styles = (ObjectMap<String, Object>) game.skinProject.getAll(style);
        if (styles == null) {
            Gdx.app.error("OptionsPane", "No styles defined for this widget type");

            tableFields.clear();
        } else {
            Keys<String> keys = styles.keys();

            for (String k : keys) {
                listItems.add(k);

            }

        }
        listItems.sort();
        listStyles.setItems(listItems);

    } catch (Exception e) {
        e.printStackTrace();
    }


    currentStyle = styles.get(key);
    updateTableFields(key);

}
项目:gdx-skineditor    文件:OptionsPane.java   
/**
 * 
 */
protected void createNewStyle() {

    final TextField textStyleName = new TextField("", game.skin);
    Dialog dlgStyle = new Dialog("New Style", game.skin) {

        @Override
        protected void result(Object object) {
            if ((Boolean) object == false) {
                return;
            }

            String styleName = textStyleName.getText();
            if (styleName.length() == 0) {

                game.showNotice("Warning", "No style name entered!", game.screenMain.stage);
                return;
            }

            // Check if the style name is already in use
            if (listItems.contains(styleName, false)) {
                game.showNotice("Warning", "Style name already in use!", game.screenMain.stage);
                return;
            }


            try {
                game.skinProject.add(styleName,  currentStyle.getClass().newInstance());
            } catch(Exception e) {
                e.printStackTrace();
            }
            //game.skinProject.add(text, game.skin.get("default", currentStyle.getClass()), currentStyle.getClass());
            game.screenMain.saveToSkin();
            refresh();

            game.screenMain.panePreview.refresh();

        }

    };

    dlgStyle.pad(20);
    dlgStyle.getContentTable().add("Style Name:");
    dlgStyle.getContentTable().add(textStyleName).pad(20);
    dlgStyle.button("OK", true);
    dlgStyle.button("Cancel", false);
    dlgStyle.key(com.badlogic.gdx.Input.Keys.ENTER, true);
    dlgStyle.key(com.badlogic.gdx.Input.Keys.ESCAPE, false);
    dlgStyle.show(getStage());
    getStage().setKeyboardFocus(textStyleName);

}
项目:gdx-skineditor    文件:OptionsPane.java   
/**
 * 
 */
public void refreshSelection() {

    String key = listStyles.getSelected();

    ImageButton button = (ImageButton) game.screenMain.barWidgets.group.getChecked();
    String widget = button.getUserObject().toString();
    String widgetStyle = "com.badlogic.gdx.scenes.scene2d.ui." + widget + "$" + widget + "Style";
    Gdx.app.log("OptionsPane", "Fetching style:" + widgetStyle);

    listItems.clear();

    try {
        Class<?> style = Class.forName(widgetStyle);

        styles = game.skinProject.getAll(style);
        if (styles == null) {
            Gdx.app.error("OptionsPane", "No styles defined for this widget type");

            tableFields.clear();
        } else {
            Keys<String> keys = styles.keys();

            for (String k : keys) {
                listItems.add(k);

            }

        }
        listItems.sort();
        listStyles.setItems(listItems);

    } catch (Exception e) {
        e.printStackTrace();
    }


    currentStyle = styles.get(key);
    updateTableFields(key);

}
项目:gdx-skineditor    文件:OptionsPane.java   
/**
 * 
 */
public void refresh() {

    Gdx.app.log("OptionsPane", "Refresh");

    ImageButton button = (ImageButton) game.screenMain.barWidgets.group.getChecked();
    String widget = button.getUserObject().toString();
    String widgetStyle = "com.badlogic.gdx.scenes.scene2d.ui." + widget + "$" + widget + "Style";
    Gdx.app.log("OptionsPane", "Fetching style:" + widgetStyle);

    listItems.clear();
    int selection = -1;

    try {
        Class<?> style = Class.forName(widgetStyle);

        styles = game.skinProject.getAll(style);
        if (styles == null) {
            Gdx.app.error("OptionsPane", "No styles defined for this widget type");

            tableFields.clear();
        } else {
            Keys<String> keys = styles.keys();
            boolean first = true;

            for (String key : keys) {
                listItems.add(key);

                if (first == true) {

                    currentStyle = styles.get(key);
                    updateTableFields(key);
                    selection = listItems.size-1;
                    first = false;
                }

            }

        }
        listItems.sort();
        listStyles.setItems(listItems);

        if (selection != -1) {
            listStyles.setSelectedIndex(selection);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}
项目:fabulae    文件:GameMap.java   
/**
 * Returns an array containing the coordinates of all transition tiles
 * on the map.
 * 
 * @return
 */
public Keys<Vector2> getTransitionTileCoordinates() {
    return transitionTiles.keys();
}