Minor tweaks

This commit is contained in:
Anuken
2019-12-07 14:26:14 -05:00
parent dd5e3b2aba
commit 07598e3f2f
2 changed files with 6 additions and 15 deletions

View File

@@ -45,9 +45,7 @@ public class Scripts implements Disposable{
}
private String getError(Throwable t){
if(t instanceof EcmaError && t.getCause() != null){
t = t.getCause();
}
t = Strings.getFinalCause(t);
return t.getClass().getSimpleName() + (t.getMessage() == null ? "" : ": " + t.getMessage());
}
@@ -74,7 +72,7 @@ public class Scripts implements Disposable{
try{
context.evaluateString(scope, script, file, 1, null);
}catch(Throwable t){
log(file, getError(t));
log(file, "[scarlet]" + getError(t));
}
}

View File

@@ -21,7 +21,6 @@ import static io.anuke.mindustry.Vars.*;
public class ScriptConsoleFragment extends Table{
private final static int messagesShown = 14;
private Array<String> messages = new Array<>();
private float fadetime;
private boolean open = false, shown;
private TextField chatfield;
private Label fieldlabel = new Label(">");
@@ -133,7 +132,7 @@ public class ScriptConsoleFragment extends Table{
Draw.alpha(shadowColor.a * opacity);
float theight = offsety + spacing + getMarginBottom();
for(int i = scrollPos; i < messages.size && i < messagesShown + scrollPos && (i < fadetime || open); i++){
for(int i = scrollPos; i < messages.size && i < messagesShown + scrollPos; i++){
layout.setText(font, messages.get(i), Color.white, textWidth, Align.bottomLeft, true);
theight += layout.height + textspacing;
@@ -142,9 +141,9 @@ public class ScriptConsoleFragment extends Table{
font.getCache().clear();
font.getCache().addText(messages.get(i), fontoffsetx + offsetx, offsety + theight, textWidth, Align.bottomLeft, true);
if(!open && fadetime - i < 1f && fadetime - i >= 0f){
font.getCache().setAlphas((fadetime - i) * opacity);
Draw.color(0, 0, 0, shadowColor.a * (fadetime - i) * opacity);
if(!open){
font.getCache().setAlphas(opacity);
Draw.color(0, 0, 0, shadowColor.a * opacity);
}else{
font.getCache().setAlphas(opacity);
}
@@ -157,9 +156,6 @@ public class ScriptConsoleFragment extends Table{
}
Draw.color();
if(fadetime > 0 && !open)
fadetime -= Time.delta() / 180f;
}
private void sendMessage(){
@@ -224,8 +220,5 @@ public class ScriptConsoleFragment extends Table{
public void addMessage(String message){
messages.insert(0, message);
fadetime += 1f;
fadetime = Math.min(fadetime, messagesShown) + 1f;
}
}