Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -113,6 +113,8 @@ public class Vars implements Loadable{
|
||||
public static final float tilePayload = tilesize * tilesize;
|
||||
/** icon sizes for UI */
|
||||
public static final float iconXLarge = 8*6f, iconLarge = 8*5f, iconMed = 8*4f, iconSmall = 8*3f;
|
||||
/** macbook screen notch height */
|
||||
public static float macNotchHeight = 32f;
|
||||
/** for map generator dialog */
|
||||
public static boolean updateEditorOnChange = false;
|
||||
/** all choosable player colors in join/host dialog */
|
||||
|
||||
@@ -349,7 +349,7 @@ public class NetServer implements ApplicationListener{
|
||||
|
||||
class VoteSession{
|
||||
Player target;
|
||||
ObjectSet<String> voted = new ObjectSet<>();
|
||||
ObjectIntMap<String> voted = new ObjectIntMap<>();
|
||||
VoteSession[] map;
|
||||
Timer.Task task;
|
||||
int votes;
|
||||
@@ -367,8 +367,12 @@ public class NetServer implements ApplicationListener{
|
||||
}
|
||||
|
||||
void vote(Player player, int d){
|
||||
int lastVote = voted.get(player.uuid(), 0) | voted.get(admins.getInfo(player.uuid()).lastIP, 0);
|
||||
votes -= lastVote;
|
||||
|
||||
votes += d;
|
||||
voted.addAll(player.uuid(), admins.getInfo(player.uuid()).lastIP);
|
||||
voted.put(player.uuid(), d);
|
||||
voted.put(admins.getInfo(player.uuid()).lastIP, d);
|
||||
|
||||
Call.sendMessage(Strings.format("[lightgray]@[lightgray] has voted on kicking[orange] @[lightgray].[accent] (@/@)\n[lightgray]Type[orange] /vote <y/n>[] to agree.",
|
||||
player.name, target.name, votes, votesRequired()));
|
||||
@@ -393,7 +397,7 @@ public class NetServer implements ApplicationListener{
|
||||
//current kick sessions
|
||||
VoteSession[] currentlyKicking = {null};
|
||||
|
||||
clientCommands.<Player>register("votekick", "[player...]", "Vote to kick a player.", (args, player) -> {
|
||||
clientCommands.<Player>register("votekick", "[player] [reason...]", "Vote to kick a player with a valid reason.", (args, player) -> {
|
||||
if(!Config.enableVotekick.bool()){
|
||||
player.sendMessage("[scarlet]Vote-kick is disabled on this server.");
|
||||
return;
|
||||
@@ -422,6 +426,8 @@ public class NetServer implements ApplicationListener{
|
||||
builder.append("[lightgray] ").append(p.name).append("[accent] (#").append(p.id()).append(")\n");
|
||||
});
|
||||
player.sendMessage(builder.toString());
|
||||
}else if(args.length == 1){
|
||||
player.sendMessage("[orange]You need a valid reason to kick the player. Add a reason after the player name.");
|
||||
}else{
|
||||
Player found;
|
||||
if(args[0].length() > 1 && args[0].startsWith("#") && Strings.canParseInt(args[0].substring(1))){
|
||||
@@ -450,6 +456,7 @@ public class NetServer implements ApplicationListener{
|
||||
|
||||
VoteSession session = new VoteSession(currentlyKicking, found);
|
||||
session.vote(player, 1);
|
||||
Call.sendMessage(Strings.format("[lightgray]Reason:[orange] @[lightgray].", args[1]));
|
||||
vtime.reset();
|
||||
currentlyKicking[0] = session;
|
||||
}
|
||||
@@ -459,18 +466,31 @@ public class NetServer implements ApplicationListener{
|
||||
}
|
||||
});
|
||||
|
||||
clientCommands.<Player>register("vote", "<y/n>", "Vote to kick the current player.", (arg, player) -> {
|
||||
clientCommands.<Player>register("vote", "<y/n/c>", "Vote to kick the current player. Admin can cancel the voting with 'c'.", (arg, player) -> {
|
||||
if(currentlyKicking[0] == null){
|
||||
player.sendMessage("[scarlet]Nobody is being voted on.");
|
||||
}else{
|
||||
if(player.admin && arg[0].equalsIgnoreCase("c")){
|
||||
Call.sendMessage(Strings.format("[lightgray]Vote canceled by admin[orange] @[lightgray].", player.name));
|
||||
currentlyKicking[0].task.cancel();
|
||||
currentlyKicking[0] = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if(player.isLocal()){
|
||||
player.sendMessage("[scarlet]Local players can't vote. Kick the player yourself instead.");
|
||||
return;
|
||||
}
|
||||
|
||||
int sign = switch(arg[0].toLowerCase()){
|
||||
case "y", "yes" -> 1;
|
||||
case "n", "no" -> -1;
|
||||
default -> 0;
|
||||
};
|
||||
|
||||
//hosts can vote all they want
|
||||
if((currentlyKicking[0].voted.contains(player.uuid()) || currentlyKicking[0].voted.contains(admins.getInfo(player.uuid()).lastIP))){
|
||||
player.sendMessage("[scarlet]You've already voted. Sit down.");
|
||||
if((currentlyKicking[0].voted.get(player.uuid(), 2) == sign || currentlyKicking[0].voted.get(admins.getInfo(player.uuid()).lastIP, 2) == sign)){
|
||||
player.sendMessage(Strings.format("[scarlet]You've already voted @. Sit down.", arg[0].toLowerCase()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -484,12 +504,6 @@ public class NetServer implements ApplicationListener{
|
||||
return;
|
||||
}
|
||||
|
||||
int sign = switch(arg[0].toLowerCase()){
|
||||
case "y", "yes" -> 1;
|
||||
case "n", "no" -> -1;
|
||||
default -> 0;
|
||||
};
|
||||
|
||||
if(sign == 0){
|
||||
player.sendMessage("[scarlet]Vote either 'y' (yes) or 'n' (no).");
|
||||
return;
|
||||
|
||||
@@ -490,6 +490,10 @@ public class SettingsMenuDialog extends BaseDialog{
|
||||
graphics.checkPref("skipcoreanimation", false);
|
||||
graphics.checkPref("hidedisplays", false);
|
||||
|
||||
if(OS.isMac){
|
||||
graphics.checkPref("macnotch", false);
|
||||
}
|
||||
|
||||
if(!mobile){
|
||||
Core.settings.put("swapdiagonal", false);
|
||||
}
|
||||
|
||||
@@ -293,6 +293,11 @@ public class HudFragment{
|
||||
//core info
|
||||
parent.fill(t -> {
|
||||
t.top();
|
||||
|
||||
if(Core.settings.getBool("macnotch") ){
|
||||
t.margin(macNotchHeight);
|
||||
}
|
||||
|
||||
t.visible(() -> shown);
|
||||
|
||||
t.name = "coreinfo";
|
||||
|
||||
@@ -100,6 +100,9 @@ public class MenuFragment{
|
||||
|
||||
float fx = (int)(width / 2f);
|
||||
float fy = (int)(height - 6 - logoh) + logoh / 2 - (Core.graphics.isPortrait() ? Scl.scl(30f) : 0f);
|
||||
if(Core.settings.getBool("macnotch") ){
|
||||
fy -= Scl.scl(macNotchHeight);
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
Draw.rect(logo, fx, fy, logow, logoh);
|
||||
@@ -277,7 +280,7 @@ public class MenuFragment{
|
||||
addButton(text, Styles.none, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Adds a custom button to the menu.
|
||||
* If {@link MenuButton#submenu} is null or the player is on mobile, {@link MenuButton#runnable} is invoked on click.
|
||||
* Otherwise, {@link MenuButton#submenu} is shown.
|
||||
|
||||
@@ -199,8 +199,8 @@ public class PlayerListFragment{
|
||||
button.add().growY();
|
||||
|
||||
button.button(Icon.hammer, ustyle,
|
||||
() -> ui.showConfirm("@confirm", Core.bundle.format("confirmvotekick", user.name()),
|
||||
() -> Call.sendChatMessage("/votekick #" + user.id)))
|
||||
() -> ui.showTextInput("@votekick.reason", Core.bundle.format("votekick.reason.message", user.name()), "",
|
||||
reason -> Call.sendChatMessage("/votekick #" + user.id + " " + reason)))
|
||||
.size(h);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,10 +33,15 @@ public class LiquidBlock extends Block{
|
||||
}
|
||||
|
||||
public static void drawTiledFrames(int size, float x, float y, float padding, Liquid liquid, float alpha){
|
||||
drawTiledFrames(size, x, y, padding, padding, padding, padding, liquid, alpha);
|
||||
}
|
||||
|
||||
public static void drawTiledFrames(int size, float x, float y, float padLeft, float padRight, float padTop, float padBottom, Liquid liquid, float alpha){
|
||||
TextureRegion region = renderer.fluidFrames[liquid.gas ? 1 : 0][liquid.getAnimationFrame()];
|
||||
TextureRegion toDraw = Tmp.tr1;
|
||||
|
||||
float bounds = size/2f * tilesize - padding;
|
||||
float leftBounds = size/2f * tilesize - padRight;
|
||||
float bottomBounds = size/2f * tilesize - padTop;
|
||||
Color color = Tmp.c1.set(liquid.color).a(1f);
|
||||
|
||||
for(int sx = 0; sx < size; sx++){
|
||||
@@ -46,8 +51,8 @@ public class LiquidBlock extends Block{
|
||||
toDraw.set(region);
|
||||
|
||||
//truncate region if at border
|
||||
float rightBorder = relx*tilesize + padding, topBorder = rely*tilesize + padding;
|
||||
float squishX = rightBorder + tilesize/2f - bounds, squishY = topBorder + tilesize/2f - bounds;
|
||||
float rightBorder = relx*tilesize + padLeft, topBorder = rely*tilesize + padBottom;
|
||||
float squishX = rightBorder + tilesize/2f - leftBounds, squishY = topBorder + tilesize/2f - bottomBounds;
|
||||
float ox = 0f, oy = 0f;
|
||||
|
||||
if(squishX >= 8 || squishY >= 8) continue;
|
||||
|
||||
@@ -2,11 +2,13 @@ package mindustry.world.draw;
|
||||
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.liquid.*;
|
||||
|
||||
public class DrawLiquidTile extends DrawBlock{
|
||||
public Liquid drawLiquid;
|
||||
public float padding;
|
||||
public float padLeft = -1, padRight = -1, padTop = -1, padBottom = -1;
|
||||
public float alpha = 1f;
|
||||
|
||||
public DrawLiquidTile(Liquid drawLiquid, float padding){
|
||||
@@ -24,6 +26,14 @@ public class DrawLiquidTile extends DrawBlock{
|
||||
@Override
|
||||
public void draw(Building build){
|
||||
Liquid drawn = drawLiquid != null ? drawLiquid : build.liquids.current();
|
||||
LiquidBlock.drawTiledFrames(build.block.size, build.x, build.y, padding, drawn, build.liquids.get(drawn) / build.block.liquidCapacity * alpha);
|
||||
LiquidBlock.drawTiledFrames(build.block.size, build.x, build.y, padLeft, padRight, padTop, padBottom, drawn, build.liquids.get(drawn) / build.block.liquidCapacity * alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
if(padLeft < 0) padLeft = padding;
|
||||
if(padRight < 0) padRight = padding;
|
||||
if(padTop < 0) padTop = padding;
|
||||
if(padBottom < 0) padBottom = padding;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user