Fixed minimap zoom not resetting after map load
This commit is contained in:
@@ -86,49 +86,50 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
t.row();
|
t.row();
|
||||||
|
|
||||||
t.addImageTextButton("$editor.import", "icon-load-map", isize, () ->
|
t.addImageTextButton("$editor.import", "icon-load-map", isize, () ->
|
||||||
createDialog("$editor.import",
|
createDialog("$editor.import",
|
||||||
"$editor.importmap", "$editor.importmap.description", "icon-load-map", (Runnable)loadDialog::show,
|
"$editor.importmap", "$editor.importmap.description", "icon-load-map", (Runnable)loadDialog::show,
|
||||||
"$editor.importfile", "$editor.importfile.description", "icon-file", (Runnable)() ->
|
"$editor.importfile", "$editor.importfile.description", "icon-file", (Runnable)() ->
|
||||||
Platform.instance.showFileChooser("$editor.loadmap", "Map Files", file -> ui.loadAnd(() -> {
|
Platform.instance.showFileChooser("$editor.loadmap", "Map Files", file -> ui.loadAnd(() -> {
|
||||||
try{
|
|
||||||
//TODO what if it's an image? users should be warned for their stupidity
|
|
||||||
editor.beginEdit(MapIO.readMap(file, true));
|
|
||||||
}catch(Exception e){
|
|
||||||
ui.showError(Core.bundle.format("editor.errorload", Strings.parseException(e, false)));
|
|
||||||
Log.err(e);
|
|
||||||
}
|
|
||||||
}), true, mapExtension),
|
|
||||||
|
|
||||||
"$editor.importimage", "$editor.importimage.description", "icon-file-image", (Runnable)() ->
|
|
||||||
Platform.instance.showFileChooser("$loadimage", "Image Files", file ->
|
|
||||||
ui.loadAnd(() -> {
|
|
||||||
try{
|
|
||||||
Pixmap pixmap = new Pixmap(file);
|
|
||||||
Tile[][] tiles = editor.createTiles(pixmap.getWidth(), pixmap.getHeight());
|
|
||||||
editor.load(() -> MapIO.readLegacyPixmap(pixmap, tiles));
|
|
||||||
editor.beginEdit(tiles);
|
|
||||||
}catch(Exception e){
|
|
||||||
ui.showError(Core.bundle.format("editor.errorload", Strings.parseException(e, false)));
|
|
||||||
Log.err(e);
|
|
||||||
}
|
|
||||||
}), true, "png")));
|
|
||||||
|
|
||||||
t.addImageTextButton("$editor.export", "icon-save-map", isize, () ->
|
|
||||||
Platform.instance.showFileChooser("$editor.savemap", "Map Files", file -> {
|
|
||||||
file = file.parent().child(file.nameWithoutExtension() + "." + mapExtension);
|
|
||||||
FileHandle result = file;
|
|
||||||
ui.loadAnd(() -> {
|
|
||||||
try{
|
try{
|
||||||
if(!editor.getTags().containsKey("name")){
|
//TODO what if it's an image? users should be warned for their stupidity
|
||||||
editor.getTags().put("name", result.nameWithoutExtension());
|
editor.beginEdit(MapIO.readMap(file, true));
|
||||||
}
|
|
||||||
MapIO.writeMap(result, editor.createMap(result), editor.tiles());
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
ui.showError(Core.bundle.format("editor.errorsave", Strings.parseException(e, false)));
|
ui.showError(Core.bundle.format("editor.errorload", Strings.parseException(e, false)));
|
||||||
Log.err(e);
|
Log.err(e);
|
||||||
}
|
}
|
||||||
});
|
}), true, mapExtension),
|
||||||
}, false, mapExtension));
|
|
||||||
|
"$editor.importimage", "$editor.importimage.description", "icon-file-image", (Runnable)() ->
|
||||||
|
Platform.instance.showFileChooser("$loadimage", "Image Files", file ->
|
||||||
|
ui.loadAnd(() -> {
|
||||||
|
try{
|
||||||
|
Pixmap pixmap = new Pixmap(file);
|
||||||
|
Tile[][] tiles = editor.createTiles(pixmap.getWidth(), pixmap.getHeight());
|
||||||
|
editor.load(() -> MapIO.readLegacyPixmap(pixmap, tiles));
|
||||||
|
editor.beginEdit(tiles);
|
||||||
|
}catch(Exception e){
|
||||||
|
ui.showError(Core.bundle.format("editor.errorload", Strings.parseException(e, false)));
|
||||||
|
Log.err(e);
|
||||||
|
}
|
||||||
|
}), true, "png"))
|
||||||
|
);
|
||||||
|
|
||||||
|
t.addImageTextButton("$editor.export", "icon-save-map", isize, () ->
|
||||||
|
Platform.instance.showFileChooser("$editor.savemap", "Map Files", file -> {
|
||||||
|
file = file.parent().child(file.nameWithoutExtension() + "." + mapExtension);
|
||||||
|
FileHandle result = file;
|
||||||
|
ui.loadAnd(() -> {
|
||||||
|
try{
|
||||||
|
if(!editor.getTags().containsKey("name")){
|
||||||
|
editor.getTags().put("name", result.nameWithoutExtension());
|
||||||
|
}
|
||||||
|
MapIO.writeMap(result, editor.createMap(result), editor.tiles());
|
||||||
|
}catch(Exception e){
|
||||||
|
ui.showError(Core.bundle.format("editor.errorsave", Strings.parseException(e, false)));
|
||||||
|
Log.err(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, false, mapExtension));
|
||||||
});
|
});
|
||||||
|
|
||||||
menu.cont.row();
|
menu.cont.row();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class MinimapRenderer implements Disposable{
|
|||||||
private Pixmap pixmap;
|
private Pixmap pixmap;
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
private TextureRegion region;
|
private TextureRegion region;
|
||||||
private Rectangle rect = new Rectangle(), scissor = new Rectangle();
|
private Rectangle rect = new Rectangle();
|
||||||
private float zoom = 4;
|
private float zoom = 4;
|
||||||
|
|
||||||
public MinimapRenderer(){
|
public MinimapRenderer(){
|
||||||
@@ -60,6 +60,7 @@ public class MinimapRenderer implements Disposable{
|
|||||||
pixmap.dispose();
|
pixmap.dispose();
|
||||||
texture.dispose();
|
texture.dispose();
|
||||||
}
|
}
|
||||||
|
setZoom(4f);
|
||||||
pixmap = new Pixmap(world.width(), world.height(), Format.RGBA8888);
|
pixmap = new Pixmap(world.width(), world.height(), Format.RGBA8888);
|
||||||
texture = new Texture(pixmap);
|
texture = new Texture(pixmap);
|
||||||
region = new TextureRegion(texture);
|
region = new TextureRegion(texture);
|
||||||
|
|||||||
Reference in New Issue
Block a user