Various fixes / Placement visual improvements

This commit is contained in:
Anuken
2018-10-17 00:36:43 -04:00
parent 0e5db49b93
commit a29f95194d
8 changed files with 87 additions and 40 deletions

View File

@ -31,7 +31,7 @@ allprojects {
getVersionString = {
String buildVersion = getBuildVersion()
return "$versionNumber-$versionType-$buildVersion"
return "$versionNumber-$versionModifier-$buildVersion"
}
getBuildVersion = {

View File

@ -418,27 +418,48 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
public void drawBuildRequests(){
synchronized(getPlaceQueue()){
for(BuildRequest request : getPlaceQueue()){
if(getCurrentRequest() == request) continue;
if(request.remove){
Block block = world.tile(request.x, request.y).target().block();
//draw removal request
Lines.stroke(2f);
Draw.color(Palette.removeBack);
float rad = Mathf.absin(Timers.time(), 7f, 1f) + block.size * tilesize / 2f;
Lines.square(
request.x * tilesize + block.offset(),
request.y * tilesize + block.offset() - 1,
rad);
Draw.color(Palette.remove);
Lines.stroke((1f - request.progress));
Lines.poly(request.x * tilesize + block.offset(),
request.y * tilesize + block.offset(),
4, block.size * tilesize / 2f, 45 + 15);
Lines.square(
request.x * tilesize + block.offset(),
request.y * tilesize + block.offset(),
rad);
}else{
//draw place request
Lines.stroke(2f);
Draw.color(Palette.accentBack);
float rad = Mathf.absin(Timers.time(), 7f, 1f) - 2f + request.recipe.result.size * tilesize / 2f;
Lines.square(
request.x * tilesize + request.recipe.result.offset(),
request.y * tilesize + request.recipe.result.offset() - 1,
rad);
Draw.color(Palette.accent);
Lines.stroke((1f - request.progress));
Lines.poly(request.x * tilesize + request.recipe.result.offset(),
request.y * tilesize + request.recipe.result.offset(),
4, request.recipe.result.size * tilesize / 2f, 45 + 15);
Lines.square(
request.x * tilesize + request.recipe.result.offset(),
request.y * tilesize + request.recipe.result.offset(),
rad);
}
}

View File

@ -60,8 +60,10 @@ public class Palette{
bar = Color.SLATE,
interact = Color.ORANGE,
accent = Color.valueOf("f4ba6e"),
accentBack = new Color(accent.r * 0.8f, accent.g * 0.8f, accent.b * 0.8f, 1f),
place = Color.valueOf("6335f8"),
remove = Color.valueOf("e55454"),
removeBack = Color.valueOf("a73e3e"),
placeRotate = accent,
breakInvalid = Color.valueOf("d44b3d"),
range = Color.valueOf("f4ba6e"),

View File

@ -94,15 +94,16 @@ public class DesktopInput extends InputHandler{
NormalizeDrawResult result = PlaceUtils.normalizeDrawArea(Blocks.air, selectX, selectY, cursorX, cursorY, false, maxLength, 1f);
NormalizeResult dresult = PlaceUtils.normalizeArea(selectX, selectY, cursorX, cursorY, rotation, false, maxLength);
Draw.color(Palette.remove);
for(int x = dresult.x; x <= dresult.x2; x++){
for(int y = dresult.y; y <= dresult.y2; y++){
Tile tile = world.tile(x, y);
if(tile == null || !validBreak(tile.x, tile.y)) continue;
tile = tile.target();
Lines.poly(tile.drawx(), tile.drawy(), 4, tile.block().size * tilesize / 2f, 45 + 15);
Draw.color(Palette.removeBack);
Lines.square(tile.drawx(), tile.drawy()-1, tile.block().size * tilesize / 2f);
Draw.color(Palette.remove);
Lines.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize / 2f);
}
}

View File

@ -8,7 +8,6 @@ import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.Annotations.Remote;
import io.anuke.mindustry.content.blocks.Blocks;
import io.anuke.mindustry.content.fx.EnvironmentFx;
import io.anuke.mindustry.core.World;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.entities.effect.ItemTransfer;
@ -227,6 +226,12 @@ public abstract class InputHandler extends InputAdapter{
frag.consume.hide();
}
if(!consumed && player.isBuilding()){
player.clearBuilding();
recipe = null;
return true;
}
return consumed;
}

View File

@ -178,9 +178,11 @@ public class MobileInput extends InputHandler implements GestureListener{
request.recipe.result.rotate ? request.rotation * 90 : 0);
}
}else{
Draw.color(Palette.remove);
//draw removing request
Lines.poly(tile.drawx(), tile.drawy(), 4, tile.block().size * tilesize / 2f * request.scale, 45 + 15);
Draw.color(Palette.removeBack);
Lines.square(tile.drawx(), tile.drawy()-1, tile.block().size * tilesize / 2f);
Draw.color(Palette.remove);
Lines.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize / 2f);
}
}
@ -374,18 +376,16 @@ public class MobileInput extends InputHandler implements GestureListener{
NormalizeDrawResult result = PlaceUtils.normalizeDrawArea(Blocks.air, lineStartX, lineStartY, tileX, tileY, false, maxLength, 1f);
NormalizeResult dresult = PlaceUtils.normalizeArea(lineStartX, lineStartY, tileX, tileY, rotation, false, maxLength);
Draw.color(Palette.remove);
Draw.alpha(0.6f);
Draw.alpha(1f);
for(int x = dresult.x; x <= dresult.x2; x++){
for(int y = dresult.y; y <= dresult.y2; y++){
Tile other = world.tile(x, y);
if(other == null || !validBreak(other.x, other.y)) continue;
other = other.target();
Lines.poly(other.drawx(), other.drawy(), 4, other.block().size * tilesize / 2f, 45 + 15);
Draw.color(Palette.removeBack);
Lines.square(other.drawx(), other.drawy()-1, other.block().size * tilesize / 2f);
Draw.color(Palette.remove);
Lines.square(other.drawx(), other.drawy(), other.block().size * tilesize / 2f);
}
}

View File

@ -35,7 +35,7 @@ public class BlockLocMission extends Mission{
public void drawOverlay(){
Lines.stroke(2f);
Draw.color(Palette.accent.r * 0.8f,Palette.accent.g * 0.8f,Palette.accent.b * 0.8f);
Draw.color(Palette.accentBack);
Lines.square(x * tilesize + block.offset(), y * tilesize + block.offset() - 1f, block.size * tilesize/2f + 1f+ Mathf.absin(Timers.time(), 6f, 2f));
Draw.color(Palette.accent);

View File

@ -32,7 +32,6 @@ public class LanguageDialog extends FloatingDialog{
for(Locale loc : locales){
TextButton button = new TextButton(Platform.instance.getLocaleName(loc), "toggle");
button.setChecked(getLocale().equals(loc));
button.clicked(() -> {
if(getLocale().equals(loc)) return;
Settings.putString("locale", loc.toString());
@ -40,9 +39,7 @@ public class LanguageDialog extends FloatingDialog{
Log.info("Setting locale: {0}", loc.toString());
ui.showInfo("$text.language.restart");
});
langs.add(button).group(group).update(t -> {
t.setChecked(loc.equals(getLocale()));
}).size(400f, 60f).row();
langs.add(button).group(group).update(t -> t.setChecked(loc.equals(getLocale()))).size(400f, 60f).row();
}
content().add(pane);
@ -50,19 +47,40 @@ public class LanguageDialog extends FloatingDialog{
public Locale getLocale(){
String loc = Settings.getString("locale");
if(loc.equals("default")){
return Locale.getDefault();
}else{
if(lastLocale == null || !lastLocale.toString().equals(loc)){
if(loc.contains("_")){
String[] split = loc.split("_");
lastLocale = new Locale(split[0], split[1]);
}else{
lastLocale = new Locale(loc);
}
}
return lastLocale;
if(loc.equals("default")){
findClosestLocale();
}
if(lastLocale == null || !lastLocale.toString().equals(loc)){
if(loc.contains("_")){
String[] split = loc.split("_");
lastLocale = new Locale(split[0], split[1]);
}else{
lastLocale = new Locale(loc);
}
}
return lastLocale;
}
void findClosestLocale(){
//check exact locale
for(Locale l : locales){
if(l.equals(Locale.getDefault())){
Settings.putString("locale", l.toString());
return;
}
}
//find by language
for(Locale l : locales){
if(l.getLanguage().equals(Locale.getDefault().getLanguage())){
Settings.putString("locale", l.toString());
return;
}
}
Settings.putString("locale", new Locale("en").toString());
}
}