Added synced server label + effect methods
This commit is contained in:
@@ -13,6 +13,7 @@ import mindustry.*;
|
||||
import mindustry.core.GameState.*;
|
||||
import mindustry.ctype.ContentType;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.Effects.*;
|
||||
import mindustry.entities.traits.BuilderTrait.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
@@ -271,6 +272,21 @@ public class NetClient implements ApplicationListener{
|
||||
ui.showInfoPopup(message, duration, align, top, left, bottom, right);
|
||||
}
|
||||
|
||||
@Remote(variants = Variant.both)
|
||||
public static void onLabel(String info, float duration, float worldx, float worldy){
|
||||
ui.showLabel(info, duration, worldx, worldy);
|
||||
}
|
||||
|
||||
@Remote(variants = Variant.both, unreliable = true)
|
||||
public static void onEffect(Effect effect, float x, float y, float rotation, Color color){
|
||||
Effects.effect(effect, color, x, y, rotation);
|
||||
}
|
||||
|
||||
@Remote(variants = Variant.both)
|
||||
public static void onEffectReliable(Effect effect, float x, float y, float rotation, Color color){
|
||||
Effects.effect(effect, color, x, y, rotation);
|
||||
}
|
||||
|
||||
@Remote(variants = Variant.both)
|
||||
public static void onInfoToast(String message, float duration){
|
||||
ui.showInfoToast(message, duration);
|
||||
|
||||
@@ -9,6 +9,7 @@ import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.input.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.*;
|
||||
import arc.scene.actions.*;
|
||||
import arc.scene.event.*;
|
||||
@@ -289,28 +290,49 @@ public class UI implements ApplicationListener, Loadable{
|
||||
Core.scene.add(table);
|
||||
}
|
||||
|
||||
/** Shows a fading label at the top of the screen. */
|
||||
public void showInfoToast(String info, float duration){
|
||||
Table table = new Table();
|
||||
table.setFillParent(true);
|
||||
table.touchable(Touchable.disabled);
|
||||
table.update(() -> {
|
||||
if(state.is(State.menu)){
|
||||
table.remove();
|
||||
}
|
||||
if(state.is(State.menu)) table.remove();
|
||||
});
|
||||
table.actions(Actions.delay(duration * 0.9f), Actions.fadeOut(duration * 0.1f, Interpolation.fade), Actions.remove());
|
||||
table.top().table(Styles.black3, t -> t.margin(4).add(info).style(Styles.outlineLabel)).padTop(10);
|
||||
Core.scene.add(table);
|
||||
}
|
||||
|
||||
/** Shows a label at some position on the screen. Does not fade. */
|
||||
public void showInfoPopup(String info, float duration, int align, int top, int left, int bottom, int right){
|
||||
Table table = new Table();
|
||||
table.setFillParent(true);
|
||||
table.update(() -> { if(state.is(State.menu)) table.remove(); });
|
||||
table.touchable(Touchable.disabled);
|
||||
table.update(() -> {
|
||||
if(state.is(State.menu)) table.remove();
|
||||
});
|
||||
table.actions(Actions.delay(duration), Actions.remove());
|
||||
table.align(align).table(Styles.black3, t -> t.margin(4).add(info).style(Styles.outlineLabel)).pad(top,left,bottom,right);
|
||||
table.align(align).table(Styles.black3, t -> t.margin(4).add(info).style(Styles.outlineLabel)).pad(top, left, bottom, right);
|
||||
Core.scene.add(table);
|
||||
}
|
||||
|
||||
/** Shows a label in the world. This label is behind everything. Does not fade. */
|
||||
public void showLabel(String info, float duration, float worldx, float worldy){
|
||||
Table table = new Table();
|
||||
table.setFillParent(true);
|
||||
table.touchable(Touchable.disabled);
|
||||
table.update(() -> {
|
||||
if(state.is(State.menu)) table.remove();
|
||||
});
|
||||
table.actions(Actions.delay(duration), Actions.remove());
|
||||
table.align(Align.center).table(Styles.black3, t -> t.margin(4).add(info).style(Styles.outlineLabel)).update(t -> {
|
||||
Vec2 v = Core.camera.project(worldx, worldy);
|
||||
t.setPosition(v.x, v.y, Align.center);
|
||||
});
|
||||
//make sure it's at the back
|
||||
Core.scene.root.addChildAt(0, table);
|
||||
}
|
||||
|
||||
public void showInfo(String info){
|
||||
new Dialog(""){{
|
||||
getCell(cont).growX();
|
||||
|
||||
Reference in New Issue
Block a user