Fade-in effect / Fixed mobile scaling
This commit is contained in:
@@ -21,6 +21,7 @@ public class Mindustry extends ApplicationCore{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Time.mark();
|
Time.mark();
|
||||||
|
UI.loadSystemCursors();
|
||||||
|
|
||||||
Vars.init();
|
Vars.init();
|
||||||
Log.setUseColors(false);
|
Log.setUseColors(false);
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ import io.anuke.mindustry.ui.fragments.*;
|
|||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class UI implements ApplicationListener{
|
public class UI implements ApplicationListener{
|
||||||
|
private static final int cursorScaling = 1, outlineThickness = 3;
|
||||||
|
private static final Color outlineColor = Color.valueOf("444444");
|
||||||
|
|
||||||
private FreeTypeFontGenerator generator;
|
private FreeTypeFontGenerator generator;
|
||||||
|
|
||||||
public MenuFragment menufrag;
|
public MenuFragment menufrag;
|
||||||
@@ -93,8 +96,7 @@ public class UI implements ApplicationListener{
|
|||||||
Colors.put("accent", Pal.accent);
|
Colors.put("accent", Pal.accent);
|
||||||
Colors.put("highlight", Pal.accent.cpy().lerp(Color.WHITE, 0.3f));
|
Colors.put("highlight", Pal.accent.cpy().lerp(Color.WHITE, 0.3f));
|
||||||
Colors.put("stat", Pal.stat);
|
Colors.put("stat", Pal.stat);
|
||||||
|
loadExtraCursors();
|
||||||
loadCursors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadExtraStyle(Skin skin){
|
void loadExtraStyle(Skin skin){
|
||||||
@@ -116,12 +118,7 @@ public class UI implements ApplicationListener{
|
|||||||
skin.add("flat-down", copy, Drawable.class);
|
skin.add("flat-down", copy, Drawable.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadCursors(){
|
public static void loadSystemCursors(){
|
||||||
int cursorScaling = 1, outlineThickness = 3;
|
|
||||||
Color outlineColor = Color.valueOf("444444");
|
|
||||||
|
|
||||||
drillCursor = Core.graphics.newCursor("drill", cursorScaling, outlineColor, outlineThickness);
|
|
||||||
unloadCursor = Core.graphics.newCursor("unload", cursorScaling, outlineColor, outlineThickness);
|
|
||||||
SystemCursor.arrow.set(Core.graphics.newCursor("cursor", cursorScaling, outlineColor, outlineThickness));
|
SystemCursor.arrow.set(Core.graphics.newCursor("cursor", cursorScaling, outlineColor, outlineThickness));
|
||||||
SystemCursor.hand.set(Core.graphics.newCursor("hand", cursorScaling, outlineColor, outlineThickness));
|
SystemCursor.hand.set(Core.graphics.newCursor("hand", cursorScaling, outlineColor, outlineThickness));
|
||||||
SystemCursor.ibeam.set(Core.graphics.newCursor("ibeam", cursorScaling, outlineColor, outlineThickness));
|
SystemCursor.ibeam.set(Core.graphics.newCursor("ibeam", cursorScaling, outlineColor, outlineThickness));
|
||||||
@@ -129,6 +126,11 @@ public class UI implements ApplicationListener{
|
|||||||
Core.graphics.restoreCursor();
|
Core.graphics.restoreCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void loadExtraCursors(){
|
||||||
|
drillCursor = Core.graphics.newCursor("drill", cursorScaling, outlineColor, outlineThickness);
|
||||||
|
unloadCursor = Core.graphics.newCursor("unload", cursorScaling, outlineColor, outlineThickness);
|
||||||
|
}
|
||||||
|
|
||||||
void generateFonts(Skin skin){
|
void generateFonts(Skin skin){
|
||||||
generator = new FreeTypeFontGenerator(Core.files.internal("fonts/font.ttf"));
|
generator = new FreeTypeFontGenerator(Core.files.internal("fonts/font.ttf"));
|
||||||
FreeTypeFontParameter param = new FreeTypeFontParameter();
|
FreeTypeFontParameter param = new FreeTypeFontParameter();
|
||||||
@@ -202,6 +204,7 @@ public class UI implements ApplicationListener{
|
|||||||
chatfrag.container().build(hudGroup);
|
chatfrag.container().build(hudGroup);
|
||||||
listfrag.build(hudGroup);
|
listfrag.build(hudGroup);
|
||||||
loadfrag.build(group);
|
loadfrag.build(group);
|
||||||
|
new FadeInFragment().build(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public class DistortFilter extends GenerateFilter{
|
|||||||
{
|
{
|
||||||
buffered = true;
|
buffered = true;
|
||||||
options(
|
options(
|
||||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 400f),
|
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 200f),
|
||||||
new SliderOption("mag", () -> mag, f -> mag = f, 0.5f, 100f)
|
new SliderOption("mag", () -> mag, f -> mag = f, 0.5f, 100f)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
40
core/src/io/anuke/mindustry/ui/fragments/FadeInFragment.java
Normal file
40
core/src/io/anuke/mindustry/ui/fragments/FadeInFragment.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package io.anuke.mindustry.ui.fragments;
|
||||||
|
|
||||||
|
import io.anuke.arc.*;
|
||||||
|
import io.anuke.arc.graphics.g2d.*;
|
||||||
|
import io.anuke.arc.math.*;
|
||||||
|
import io.anuke.arc.scene.*;
|
||||||
|
import io.anuke.arc.scene.event.*;
|
||||||
|
import io.anuke.arc.util.*;
|
||||||
|
|
||||||
|
/** Fades in a black overlay.*/
|
||||||
|
public class FadeInFragment extends Fragment{
|
||||||
|
private static final float duration = 40f;
|
||||||
|
float time = 0f;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void build(Group parent){
|
||||||
|
parent.addChild(new Element(){
|
||||||
|
{
|
||||||
|
setFillParent(true);
|
||||||
|
touchable(Touchable.disabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(){
|
||||||
|
Draw.color(0f, 0f, 0f, Mathf.clamp(1f - time));
|
||||||
|
Fill.crect(0, 0, Core.graphics.getWidth(), Core.graphics.getHeight());
|
||||||
|
Draw.color();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void act(float delta){
|
||||||
|
super.act(delta);
|
||||||
|
time += Time.delta() / duration;
|
||||||
|
if(time > 1){
|
||||||
|
remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user