Fixed black styles on game reload (Android)

This commit is contained in:
Anuken
2019-09-12 09:06:25 -04:00
parent 41b21c81a0
commit bbaaa91575
3 changed files with 278 additions and 270 deletions
@@ -55,6 +55,7 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
TypeSpec.Builder type = TypeSpec.classBuilder("Tex").addModifiers(Modifier.PUBLIC);
TypeSpec.Builder ictype = TypeSpec.classBuilder("Icon").addModifiers(Modifier.PUBLIC);
MethodSpec.Builder load = MethodSpec.methodBuilder("load").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
MethodSpec.Builder loadStyles = MethodSpec.methodBuilder("loadStyles").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
MethodSpec.Builder icload = MethodSpec.methodBuilder("load").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
String resources = path + "/assets-raw/sprites/ui";
Files.walk(Paths.get(resources)).forEach(p -> {
@@ -98,7 +99,7 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
t.getEnclosedElements().stream().filter(e -> e.getKind() == ElementKind.FIELD).forEach(field -> {
String fname = field.getSimpleName().toString();
if(fname.startsWith("default")){
load.addStatement("io.anuke.arc.Core.scene.addStyle(" + field.asType().toString() + ".class, io.anuke.mindustry.ui.Styles." + fname + ")");
loadStyles.addStatement("io.anuke.arc.Core.scene.addStyle(" + field.asType().toString() + ".class, io.anuke.mindustry.ui.Styles." + fname + ")");
}
});
}
@@ -107,6 +108,7 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
JavaFile.builder(packageName, ictype.build()).build().writeTo(Utils.filer);
type.addMethod(load.build());
type.addMethod(loadStyles.build());
JavaFile.builder(packageName, type.build()).build().writeTo(Utils.filer);
}
+2
View File
@@ -91,6 +91,8 @@ public class UI implements ApplicationListener, Loadable{
Tex.load();
Icon.load();
Styles.load();
Tex.loadStyles();
Dialog.setShowAction(() -> sequence(alpha(0f), fadeIn(0.1f)));
Dialog.setHideAction(() -> sequence(fadeOut(0.1f)));
+50 -46
View File
@@ -23,30 +23,41 @@ import static io.anuke.mindustry.gen.Tex.*;
@StyleDefaults
public class Styles{
public static Drawable
black = whiteui.tint(0f, 0f, 0f, 1f),
black9 = whiteui.tint(0f, 0f, 0f, 0.9f),
black8 = whiteui.tint(0f, 0f, 0f, 0.8f),
black6 = whiteui.tint(0f, 0f, 0f, 0.6f),
black3 = whiteui.tint(0f, 0f, 0f, 0.3f),
none = whiteui.tint(0f, 0f, 0f, 0f),
flatDown = createFlatDown(),
public static Drawable black, black9, black8, black6, black3, none, flatDown, flatOver;
public static ButtonStyle defaultb, waveb;
public static TextButtonStyle defaultt, squaret, nodet, cleart, discordt, infot, clearPartialt, clearTogglet, clearToggleMenut, togglet;
public static ImageButtonStyle defaulti, nodei, righti, emptyi, emptytogglei, selecti, cleari, clearFulli, clearPartiali, clearPartial2i, clearTogglei, clearTransi, clearToggleTransi, clearTogglePartiali;
public static ScrollPaneStyle defaultPane, horizontalPane;
public static KeybindDialogStyle defaultKeybindDialog;
public static SliderStyle defaultSlider, vSlider;
public static LabelStyle defaultLabel, outlineLabel;
public static TextFieldStyle defaultField, areaField;
public static CheckBoxStyle defaultCheck;
public static DialogStyle defaultDialog, fullDialog;
public static void load(){
black = whiteui.tint(0f, 0f, 0f, 1f);
black9 = whiteui.tint(0f, 0f, 0f, 0.9f);
black8 = whiteui.tint(0f, 0f, 0f, 0.8f);
black6 = whiteui.tint(0f, 0f, 0f, 0.6f);
black3 = whiteui.tint(0f, 0f, 0f, 0.3f);
none = whiteui.tint(0f, 0f, 0f, 0f);
flatDown = createFlatDown();
flatOver = whiteui.tint(Color.valueOf("454545"));
public static ButtonStyle
defaultb = new ButtonStyle(){{
down = buttonDown;
up = button;
over = buttonOver;
disabled = buttonDisabled;
}},
}};
waveb = new ButtonStyle(){{
up = buttonEdge4;
over = buttonEdgeOver4;
disabled = buttonEdge4;
}};
public static TextButtonStyle
defaultt = new TextButtonStyle(){{
over = buttonOver;
disabled = buttonDisabled;
@@ -55,7 +66,7 @@ public class Styles{
disabledFontColor = Color.gray;
down = buttonDown;
up = button;
}},
}};
squaret = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
@@ -64,7 +75,7 @@ public class Styles{
disabled = buttonDisabled;
down = buttonSquareDown;
up = buttonSquare;
}},
}};
nodet = new TextButtonStyle(){{
disabled = button;
font = Fonts.def;
@@ -72,7 +83,7 @@ public class Styles{
disabledFontColor = Color.gray;
up = buttonOver;
over = buttonDown;
}},
}};
cleart = new TextButtonStyle(){{
over = flatOver;
font = Fonts.def;
@@ -80,17 +91,17 @@ public class Styles{
disabledFontColor = Color.gray;
down = flatOver;
up = black;
}},
}};
discordt = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
up = discordBanner;
}},
}};
infot = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
up = infoBanner;
}},
}};
clearPartialt = new TextButtonStyle(){{
down = whiteui;
up = pane;
@@ -98,7 +109,7 @@ public class Styles{
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
}},
}};
clearTogglet = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
@@ -108,7 +119,7 @@ public class Styles{
over = flatOver;
disabled = black;
disabledFontColor = Color.gray;
}},
}};
clearToggleMenut = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
@@ -118,7 +129,7 @@ public class Styles{
over = flatOver;
disabled = black;
disabledFontColor = Color.gray;
}},
}};
togglet = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
@@ -130,7 +141,6 @@ public class Styles{
disabledFontColor = Color.gray;
}};
public static ImageButtonStyle
defaulti = new ImageButtonStyle(){{
down = buttonDown;
up = button;
@@ -138,66 +148,66 @@ public class Styles{
imageDisabledColor = Color.gray;
imageUpColor = Color.white;
disabled = buttonDisabled;
}},
}};
nodei = new ImageButtonStyle(){{
up = buttonOver;
over = buttonDown;
}},
}};
righti = new ImageButtonStyle(){{
over = buttonRightOver;
down = buttonRightDown;
up = buttonRight;
}},
}};
emptyi = new ImageButtonStyle(){{
imageDownColor = Pal.accent;
imageUpColor = Color.white;
}},
}};
emptytogglei = new ImageButtonStyle(){{
imageCheckedColor = Color.white;
imageDownColor = Color.white;
imageUpColor = Color.gray;
}},
}};
selecti = new ImageButtonStyle(){{
checked = buttonSelect;
up = none;
}},
}};
cleari = new ImageButtonStyle(){{
down = flatOver;
up = black;
over = flatOver;
}},
}};
clearFulli = new ImageButtonStyle(){{
down = whiteui;
up = pane;
over = flatDown;
}},
}};
clearPartiali = new ImageButtonStyle(){{
down = flatDown;
up = none;
over = flatOver;
}},
}};
clearPartial2i = new ImageButtonStyle(){{
down = whiteui;
up = pane;
over = flatDown;
}},
}};
clearTogglei = new ImageButtonStyle(){{
down = flatDown;
checked = flatDown;
up = black;
over = flatOver;
}},
}};
clearTransi = new ImageButtonStyle(){{
down = flatDown;
up = black6;
over = flatOver;
}},
}};
clearToggleTransi = new ImageButtonStyle(){{
down = flatDown;
checked = flatDown;
up = black6;
over = flatOver;
}},
}};
clearTogglePartiali = new ImageButtonStyle(){{
down = flatDown;
checked = flatDown;
@@ -205,11 +215,10 @@ public class Styles{
over = flatOver;
}};
public static ScrollPaneStyle
defaultPane = new ScrollPaneStyle(){{
vScroll = scroll;
vScrollKnob = scrollKnobVerticalBlack;
}},
}};
horizontalPane = new ScrollPaneStyle(){{
vScroll = scroll;
vScrollKnob = scrollKnobVerticalBlack;
@@ -217,20 +226,18 @@ public class Styles{
hScrollKnob = scrollKnobHorizontalBlack;
}};
public static KeybindDialogStyle
defaultKeybindDialog = new KeybindDialogStyle(){{
keyColor = Pal.accent;
keyNameColor = Color.white;
controllerColor = Color.lightGray;
}};
public static SliderStyle
defaultSlider = new SliderStyle(){{
background = slider;
knob = sliderKnob;
knobOver = sliderKnobOver;
knobDown = sliderKnobDown;
}},
}};
vSlider = new SliderStyle(){{
background = sliderVertical;
knob = sliderKnob;
@@ -238,17 +245,15 @@ public class Styles{
knobDown = sliderKnobDown;
}};
public static LabelStyle
defaultLabel = new LabelStyle(){{
font = Fonts.def;
fontColor = Color.white;
}},
}};
outlineLabel = new LabelStyle(){{
font = Fonts.outline;
fontColor = Color.white;
}};
public static TextFieldStyle
defaultField = new TextFieldStyle(){{
font = Fonts.chat;
fontColor = Color.white;
@@ -260,7 +265,7 @@ public class Styles{
cursor = Tex.cursor;
messageFont = Fonts.def;
messageFontColor = Color.gray;
}},
}};
areaField = new TextFieldStyle(){{
font = Fonts.chat;
fontColor = Color.white;
@@ -272,7 +277,6 @@ public class Styles{
messageFontColor = Color.gray;
}};
public static CheckBoxStyle
defaultCheck = new CheckBoxStyle(){{
checkboxOn = checkOn;
checkboxOff = checkOff;
@@ -285,19 +289,19 @@ public class Styles{
disabledFontColor = Color.gray;
}};
public static DialogStyle
defaultDialog = new DialogStyle(){{
stageBackground = black9;
titleFont = Fonts.def;
background = windowEmpty;
titleFontColor = Pal.accent;
}},
}};
fullDialog = new DialogStyle(){{
stageBackground = black;
titleFont = Fonts.def;
background = windowEmpty;
titleFontColor = Pal.accent;
}};
}
private static Drawable createFlatDown(){
AtlasRegion region = Core.atlas.find("flat-down-base");