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){ private String getError(Throwable t){
if(t instanceof EcmaError && t.getCause() != null){ t = Strings.getFinalCause(t);
t = t.getCause();
}
return t.getClass().getSimpleName() + (t.getMessage() == null ? "" : ": " + t.getMessage()); return t.getClass().getSimpleName() + (t.getMessage() == null ? "" : ": " + t.getMessage());
} }
@@ -74,7 +72,7 @@ public class Scripts implements Disposable{
try{ try{
context.evaluateString(scope, script, file, 1, null); context.evaluateString(scope, script, file, 1, null);
}catch(Throwable t){ }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{ public class ScriptConsoleFragment extends Table{
private final static int messagesShown = 14; private final static int messagesShown = 14;
private Array<String> messages = new Array<>(); private Array<String> messages = new Array<>();
private float fadetime;
private boolean open = false, shown; private boolean open = false, shown;
private TextField chatfield; private TextField chatfield;
private Label fieldlabel = new Label(">"); private Label fieldlabel = new Label(">");
@@ -133,7 +132,7 @@ public class ScriptConsoleFragment extends Table{
Draw.alpha(shadowColor.a * opacity); Draw.alpha(shadowColor.a * opacity);
float theight = offsety + spacing + getMarginBottom(); 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); layout.setText(font, messages.get(i), Color.white, textWidth, Align.bottomLeft, true);
theight += layout.height + textspacing; theight += layout.height + textspacing;
@@ -142,9 +141,9 @@ public class ScriptConsoleFragment extends Table{
font.getCache().clear(); font.getCache().clear();
font.getCache().addText(messages.get(i), fontoffsetx + offsetx, offsety + theight, textWidth, Align.bottomLeft, true); font.getCache().addText(messages.get(i), fontoffsetx + offsetx, offsety + theight, textWidth, Align.bottomLeft, true);
if(!open && fadetime - i < 1f && fadetime - i >= 0f){ if(!open){
font.getCache().setAlphas((fadetime - i) * opacity); font.getCache().setAlphas(opacity);
Draw.color(0, 0, 0, shadowColor.a * (fadetime - i) * opacity); Draw.color(0, 0, 0, shadowColor.a * opacity);
}else{ }else{
font.getCache().setAlphas(opacity); font.getCache().setAlphas(opacity);
} }
@@ -157,9 +156,6 @@ public class ScriptConsoleFragment extends Table{
} }
Draw.color(); Draw.color();
if(fadetime > 0 && !open)
fadetime -= Time.delta() / 180f;
} }
private void sendMessage(){ private void sendMessage(){
@@ -224,8 +220,5 @@ public class ScriptConsoleFragment extends Table{
public void addMessage(String message){ public void addMessage(String message){
messages.insert(0, message); messages.insert(0, message);
fadetime += 1f;
fadetime = Math.min(fadetime, messagesShown) + 1f;
} }
} }