Merged with master
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.scene.ui.Dialog;
|
||||
@@ -35,6 +36,12 @@ public class ColorPickDialog extends Dialog{
|
||||
table.row();
|
||||
}
|
||||
}
|
||||
|
||||
keyDown(key->{
|
||||
if(key == Keys.ESCAPE || key == Keys.BACK)
|
||||
hide();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void show(Consumer<Color> cons){
|
||||
|
||||
@@ -160,7 +160,7 @@ public class FileChooser extends FloatingDialog {
|
||||
Arrays.sort(handles, (a, b) ->{
|
||||
if(a.isDirectory() && !b.isDirectory()) return -1;
|
||||
if( !a.isDirectory() && b.isDirectory()) return 1;
|
||||
return a.name().compareTo(b.name());
|
||||
return a.name().toUpperCase().compareTo(b.name().toUpperCase());
|
||||
});
|
||||
return handles;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package io.anuke.mindustry.ui.dialogs;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.graphics.Colors;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
|
||||
import io.anuke.ucore.core.Inputs;
|
||||
import io.anuke.ucore.scene.ui.Dialog;
|
||||
|
||||
public class FloatingDialog extends Dialog{
|
||||
@@ -26,11 +24,5 @@ public class FloatingDialog extends Dialog{
|
||||
if(key == Keys.ESCAPE || key == Keys.BACK)
|
||||
hide();
|
||||
});
|
||||
|
||||
update(() -> {
|
||||
if(Inputs.keyTap("menu")){
|
||||
hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,10 +40,12 @@ public class HostDialog extends FloatingDialog{
|
||||
});
|
||||
}).size(50f, 54f).get();
|
||||
button.update(() -> button.getStyle().imageUpColor = player.getColor());
|
||||
}).width(w).height(70f).pad(4);
|
||||
}).width(w).height(70f).pad(4).colspan(3);
|
||||
|
||||
content().row();
|
||||
|
||||
content().add().width(65f);
|
||||
|
||||
content().addButton("$text.host", () -> {
|
||||
ui.loadfrag.show("$text.hosting");
|
||||
Timers.runTask(5f, () -> {
|
||||
@@ -57,5 +59,7 @@ public class HostDialog extends FloatingDialog{
|
||||
hide();
|
||||
});
|
||||
}).width(w).height(70f);
|
||||
|
||||
content().addButton("?", () -> ui.showInfo("$text.host.info")).size(65f, 70f).padLeft(6f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,14 @@ public class JoinDialog extends FloatingDialog {
|
||||
|
||||
loadServers();
|
||||
|
||||
buttons().add().width(60f);
|
||||
buttons().add().growX();
|
||||
|
||||
addCloseButton();
|
||||
|
||||
buttons().add().growX();
|
||||
buttons().addButton("?", () -> ui.showInfo("$text.join.info")).size(60f, 64f);
|
||||
|
||||
add = new FloatingDialog("$text.joingame.title");
|
||||
add.content().add("$text.joingame.ip").padRight(5f).left();
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public class BackgroundFragment implements Fragment {
|
||||
Draw.color();
|
||||
|
||||
TextureRegion back = Draw.region("background");
|
||||
float backscl = Math.max(Gdx.graphics.getWidth() / (float)back.getRegionWidth() * 1.5f, Unit.dp.scl(5f));
|
||||
float backscl = (int)Math.max(Gdx.graphics.getWidth() / (float)back.getRegionWidth() * 1.5f, Unit.dp.scl(5f));
|
||||
|
||||
Draw.alpha(0.5f);
|
||||
Core.batch.draw(back, w/2 - back.getRegionWidth()*backscl/2, h/2 - back.getRegionHeight()*backscl/2,
|
||||
@@ -31,7 +31,7 @@ public class BackgroundFragment implements Fragment {
|
||||
float logoh = logo.getRegionHeight()*logoscl;
|
||||
|
||||
Draw.color();
|
||||
Core.batch.draw(logo, w/2 - logow/2, h - logoh + 15 - Unit.dp.scl(portrait ? 30f : 0), logow, logoh);
|
||||
Core.batch.draw(logo, (int)(w/2 - logow/2), (int)(h - logoh + 15 - Unit.dp.scl(portrait ? 30f : 0)), logow, logoh);
|
||||
}).visible(() -> state.is(State.menu)).grow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ import io.anuke.ucore.scene.ui.Label.LabelStyle;
|
||||
import io.anuke.ucore.scene.ui.TextField;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.util.Log;
|
||||
import java.util.Arrays;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
import static io.anuke.ucore.core.Core.scene;
|
||||
@@ -30,7 +29,7 @@ public class ChatFragment extends Table implements Fragment{
|
||||
private final static int messagesShown = 10;
|
||||
private final static int maxLength = 150;
|
||||
private Array<ChatMessage> messages = new Array<>();
|
||||
private float fadetime, lastfade;
|
||||
private float fadetime;
|
||||
private boolean chatOpen = false;
|
||||
private TextField chatfield;
|
||||
private Label fieldlabel = new Label(">");
|
||||
@@ -42,6 +41,7 @@ public class ChatFragment extends Table implements Fragment{
|
||||
private float textspacing = Unit.dp.scl(10);
|
||||
private Array<String> history = new Array<String>();
|
||||
private int historyPos = 0;
|
||||
private int scrollPos = 0;
|
||||
|
||||
public ChatFragment(){
|
||||
super();
|
||||
@@ -62,15 +62,16 @@ public class ChatFragment extends Table implements Fragment{
|
||||
}
|
||||
|
||||
if (chatOpen) {
|
||||
if (Inputs.keyTap("chat_scroll_up") && historyPos < history.size - 1) {
|
||||
if (Inputs.keyTap("chat_history_prev") && historyPos < history.size - 1) {
|
||||
if (historyPos == 0) history.set(0, chatfield.getText());
|
||||
historyPos++;
|
||||
updateChat();
|
||||
}
|
||||
if (Inputs.keyTap("chat_scroll_down") && historyPos > 0) {
|
||||
if (Inputs.keyTap("chat_history_next") && historyPos > 0) {
|
||||
historyPos--;
|
||||
updateChat();
|
||||
}
|
||||
scrollPos = (int)Mathf.clamp(scrollPos + Inputs.getAxis("chat_scroll"), 0, Math.max(0, messages.size - messagesShown));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -134,16 +135,16 @@ public class ChatFragment extends Table implements Fragment{
|
||||
batch.setColor(shadowColor);
|
||||
|
||||
float theight = offsety + spacing + getMarginBottom();
|
||||
for(int i = 0; i < messagesShown && i < messages.size && i < fadetime; i ++){
|
||||
for(int i = scrollPos; i < messages.size && i < messagesShown + scrollPos && (i < fadetime || chatOpen); i++){
|
||||
|
||||
layout.setText(font, messages.get(i).formattedMessage, Color.WHITE, textWidth, Align.bottomLeft, true);
|
||||
theight += layout.height+textspacing;
|
||||
if(i == 0) theight -= textspacing+1;
|
||||
if(i - scrollPos == 0) theight -= textspacing+1;
|
||||
|
||||
font.getCache().clear();
|
||||
font.getCache().addText(messages.get(i).formattedMessage, fontoffsetx + offsetx, offsety + theight, textWidth, Align.bottomLeft, true);
|
||||
|
||||
if(fadetime-i < 1f && fadetime-i >= 0f){
|
||||
if(!chatOpen && fadetime-i < 1f && fadetime-i >= 0f){
|
||||
font.getCache().setAlphas(fadetime-i);
|
||||
batch.setColor(0, 0, 0, shadowColor.a*(fadetime-i));
|
||||
}
|
||||
@@ -163,10 +164,10 @@ public class ChatFragment extends Table implements Fragment{
|
||||
private void sendMessage(){
|
||||
String message = chatfield.getText();
|
||||
clearChatInput();
|
||||
history.insert(1, message);
|
||||
|
||||
if(message.replaceAll(" ", "").isEmpty()) return;
|
||||
|
||||
history.insert(1, message);
|
||||
NetEvents.handleSendMessage(message);
|
||||
}
|
||||
|
||||
@@ -176,12 +177,10 @@ public class ChatFragment extends Table implements Fragment{
|
||||
scene.setKeyboardFocus(chatfield);
|
||||
chatfield.fireClick();
|
||||
chatOpen = !chatOpen;
|
||||
lastfade = fadetime;
|
||||
fadetime = messagesShown + 1;
|
||||
}else{
|
||||
scene.setKeyboardFocus(null);
|
||||
chatOpen = !chatOpen;
|
||||
fadetime = lastfade;
|
||||
scrollPos = 0;
|
||||
sendMessage();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user