Fixed brush size layout, added map resize button

This commit is contained in:
Anuken 2018-05-21 13:59:35 -04:00
parent 37afb46957
commit 4a250b4e27
4 changed files with 26 additions and 22 deletions

View File

@ -20,16 +20,17 @@ import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.core.Inputs;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Pixmaps;
import io.anuke.ucore.input.Input;
import io.anuke.ucore.scene.Element;
import io.anuke.ucore.scene.actions.Actions;
import io.anuke.ucore.scene.builders.build;
import io.anuke.ucore.scene.builders.label;
import io.anuke.ucore.scene.builders.table;
import io.anuke.ucore.scene.ui.*;
import io.anuke.ucore.scene.ui.layout.Stack;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.utils.UIUtils;
import io.anuke.ucore.util.Bundles;
import io.anuke.ucore.input.Input;
import io.anuke.ucore.util.Log;
import io.anuke.ucore.util.Strings;
@ -142,6 +143,13 @@ public class MapEditorDialog extends Dialog{
menu.content().row();
menu.content().addImageTextButton("$text.editor.resize", "icon-resize", isize, () -> {
resizeDialog.show();
menu.hide();
});
menu.content().row();
menu.content().addImageTextButton("$text.editor.savemap", "icon-save-map", isize, () -> {
saveFile.show();
menu.hide();
@ -298,6 +306,7 @@ public class MapEditorDialog extends Dialog{
margin(0);
Table tools = new Table();
tools.top();
atop();
ButtonGroup<ImageButton> group = new ButtonGroup<>();
int i = 1;
@ -352,17 +361,18 @@ public class MapEditorDialog extends Dialog{
if(i++ % 2 == 1) tools.row();
}
add(tools).growY().top().padBottom(-6);
add(tools).top().padBottom(-6);
row();
new table(){{
Slider slider = new Slider(0, MapEditor.brushSizes.length-1, 1, true);
new table("button"){{
Slider slider = new Slider(0, MapEditor.brushSizes.length-1, 1, false);
slider.moved(f -> editor.setBrushSize(MapEditor.brushSizes[(int)(float)f]));
new label("brush");
//new label(() -> Bundles.format("text.editor.brushsize", MapEditor.brushSizes[(int)slider.getValue()])).left();
row();
add(slider).growX().padTop(4f);
}}.growX().padBottom(10).end();
add(slider).width(100f).padTop(4f);
}}.padBottom(10).padTop(5).top().end();
}}.left().growY().end();

View File

@ -1,6 +1,5 @@
package io.anuke.mindustry.editor;
import com.badlogic.gdx.utils.Align;
import io.anuke.mindustry.io.MapTileData;
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
import io.anuke.ucore.function.BiConsumer;
@ -9,7 +8,7 @@ import io.anuke.ucore.scene.ui.TextButton;
import io.anuke.ucore.scene.ui.layout.Table;
public class MapResizeDialog extends FloatingDialog{
int[] validMapSizes = {128, 256, 512};
int[] validMapSizes = {200, 300, 400, 500};
int width, height;
public MapResizeDialog(MapEditor editor, BiConsumer<Integer, Integer> cons){
@ -47,10 +46,6 @@ public class MapResizeDialog extends FloatingDialog{
table.row();
}
content().label(() ->
width + height > 512 ? "$text.editor.resizebig" : ""
).get().setAlignment(Align.center, Align.center);
content().row();
content().add(table);

View File

@ -1,7 +1,6 @@
package io.anuke.mindustry.editor;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.input.GestureDetector;
import com.badlogic.gdx.input.GestureDetector.GestureListener;
@ -208,7 +207,7 @@ public class MapView extends Element implements GestureListener{
float sclwidth = size * zoom;
float sclheight = size * zoom * ratio;
float px = ((float)x / editor.getMap().width()) * sclwidth + offsetx*zoom - sclwidth/2 + getWidth()/2;
float py = (float)((float)(y) / editor.getMap().height()) * sclheight
float py = ((float)(y) / editor.getMap().height()) * sclheight
+ offsety*zoom - sclheight/2 + getHeight()/2;
return vec.set(px, py);
}
@ -226,9 +225,7 @@ public class MapView extends Element implements GestureListener{
batch.flush();
boolean pop = ScissorStack.pushScissors(rect.set(x, y, width, height));
//batch.draw(editor.texture(), centerx - sclwidth/2, centery - sclheight/2, sclwidth, sclheight);
//TODO actually render the map here?
Draw.color(Color.LIGHT_GRAY);
Lines.stroke(-2f);
Lines.rect(centerx - sclwidth/2 - 1, centery - sclheight/2 - 1, sclwidth + 2, sclheight + 2);
@ -250,6 +247,9 @@ public class MapView extends Element implements GestureListener{
}
}
//todo is it really math.max?
float scaling = zoom * Math.min(width, height) / Math.max(editor.getMap().width(), editor.getMap().height());
if(tool == EditorTool.line && drawing){
Vector2 v1 = unproject(startx, starty).add(x, y);
float sx = v1.x, sy = v1.y;
@ -257,8 +257,8 @@ public class MapView extends Element implements GestureListener{
Draw.color(Palette.accent);
Lines.stroke(Unit.dp.scl(1f * zoom));
Lines.poly(brushPolygons[index], sx, sy, 3f*zoom);
Lines.poly(brushPolygons[index], v2.x, v2.y, 3f*zoom);
Lines.poly(brushPolygons[index], sx, sy, scaling);
Lines.poly(brushPolygons[index], v2.x, v2.y, scaling);
}
if(tool.edit && (!mobile || drawing)){
@ -266,7 +266,7 @@ public class MapView extends Element implements GestureListener{
Vector2 v = unproject(p.x, p.y).add(x, y);
Draw.color(Palette.accent);
Lines.stroke(Unit.dp.scl(1f * zoom));
Lines.poly(brushPolygons[index], v.x, v.y, 3f*zoom);
Lines.poly(brushPolygons[index], v.x, v.y, scaling);
}
batch.flush();

View File

@ -42,13 +42,12 @@ public class DamageArea{
Bullet.create(TurretBullets.fireball, null, Team.none, x, y, Mathf.random(360f)));
}
float e = explosiveness;
int waves = Mathf.clamp((int)(explosiveness / 4), 0, 30);
for(int i = 0; i < waves; i ++){
int f = i;
Timers.run(i*2f, () -> {
DamageArea.damage(x, y, Mathf.clamp(radius + e, 0, 50f) * ((f + 1f)/waves), e/2f);
DamageArea.damage(x, y, Mathf.clamp(radius + explosiveness, 0, 50f) * ((f + 1f)/waves), explosiveness/2f);
Effects.effect(ExplosionFx.blockExplosionSmoke, x + Mathf.range(radius), y + Mathf.range(radius));
});
}