1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-11-13 07:15:28 +03:00

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

View File

@ -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);
}

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)));

View File

@ -23,281 +23,285 @@ 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(),
flatOver = whiteui.tint(Color.valueOf("454545"));
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 ButtonStyle
defaultb = new ButtonStyle(){{
down = buttonDown;
up = button;
over = buttonOver;
disabled = buttonDisabled;
}},
waveb = new ButtonStyle(){{
up = buttonEdge4;
over = buttonEdgeOver4;
disabled = buttonEdge4;
}};
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 TextButtonStyle
defaultt = new TextButtonStyle(){{
over = buttonOver;
disabled = buttonDisabled;
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
down = buttonDown;
up = button;
}},
squaret = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
over = buttonSquareOver;
disabled = buttonDisabled;
down = buttonSquareDown;
up = buttonSquare;
}},
nodet = new TextButtonStyle(){{
disabled = button;
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
up = buttonOver;
over = buttonDown;
}},
cleart = new TextButtonStyle(){{
over = flatOver;
font = Fonts.def;
fontColor = Color.white;
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;
over = flatDown;
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
}},
clearTogglet = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
checked = flatDown;
down = flatDown;
up = black;
over = flatOver;
disabled = black;
disabledFontColor = Color.gray;
}},
clearToggleMenut = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
checked = flatDown;
down = flatDown;
up = clear;
over = flatOver;
disabled = black;
disabledFontColor = Color.gray;
}},
togglet = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
checked = buttonDown;
down = buttonDown;
up = button;
over = buttonOver;
disabled = buttonDisabled;
disabledFontColor = Color.gray;
}};
defaultb = new ButtonStyle(){{
down = buttonDown;
up = button;
over = buttonOver;
disabled = buttonDisabled;
}};
waveb = new ButtonStyle(){{
up = buttonEdge4;
over = buttonEdgeOver4;
disabled = buttonEdge4;
}};
public static ImageButtonStyle
defaulti = new ImageButtonStyle(){{
down = buttonDown;
up = button;
over = buttonOver;
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;
up = none;
over = flatOver;
}};
defaultt = new TextButtonStyle(){{
over = buttonOver;
disabled = buttonDisabled;
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
down = buttonDown;
up = button;
}};
squaret = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
over = buttonSquareOver;
disabled = buttonDisabled;
down = buttonSquareDown;
up = buttonSquare;
}};
nodet = new TextButtonStyle(){{
disabled = button;
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
up = buttonOver;
over = buttonDown;
}};
cleart = new TextButtonStyle(){{
over = flatOver;
font = Fonts.def;
fontColor = Color.white;
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;
over = flatDown;
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
}};
clearTogglet = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
checked = flatDown;
down = flatDown;
up = black;
over = flatOver;
disabled = black;
disabledFontColor = Color.gray;
}};
clearToggleMenut = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
checked = flatDown;
down = flatDown;
up = clear;
over = flatOver;
disabled = black;
disabledFontColor = Color.gray;
}};
togglet = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
checked = buttonDown;
down = buttonDown;
up = button;
over = buttonOver;
disabled = buttonDisabled;
disabledFontColor = Color.gray;
}};
public static ScrollPaneStyle
defaultPane = new ScrollPaneStyle(){{
vScroll = scroll;
vScrollKnob = scrollKnobVerticalBlack;
}},
horizontalPane = new ScrollPaneStyle(){{
vScroll = scroll;
vScrollKnob = scrollKnobVerticalBlack;
hScroll = scrollHorizontal;
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;
knobOver = sliderKnobOver;
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;
disabledFontColor = Color.gray;
disabledBackground = underlineDisabled;
selection = Tex.selection;
background = underline;
invalidBackground = underlineRed;
cursor = Tex.cursor;
messageFont = Fonts.def;
messageFontColor = Color.gray;
}},
areaField = new TextFieldStyle(){{
font = Fonts.chat;
fontColor = Color.white;
disabledFontColor = Color.gray;
selection = Tex.selection;
background = underline;
cursor = Tex.cursor;
messageFont = Fonts.def;
messageFontColor = Color.gray;
}};
defaulti = new ImageButtonStyle(){{
down = buttonDown;
up = button;
over = buttonOver;
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;
up = none;
over = flatOver;
}};
public static CheckBoxStyle
defaultCheck = new CheckBoxStyle(){{
checkboxOn = checkOn;
checkboxOff = checkOff;
checkboxOnOver = checkOnOver;
checkboxOver = checkOver;
checkboxOnDisabled = checkOnDisabled;
checkboxOffDisabled = checkDisabled;
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
}};
defaultPane = new ScrollPaneStyle(){{
vScroll = scroll;
vScrollKnob = scrollKnobVerticalBlack;
}};
horizontalPane = new ScrollPaneStyle(){{
vScroll = scroll;
vScrollKnob = scrollKnobVerticalBlack;
hScroll = scrollHorizontal;
hScrollKnob = scrollKnobHorizontalBlack;
}};
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;
}};
defaultKeybindDialog = new KeybindDialogStyle(){{
keyColor = Pal.accent;
keyNameColor = Color.white;
controllerColor = Color.lightGray;
}};
defaultSlider = new SliderStyle(){{
background = slider;
knob = sliderKnob;
knobOver = sliderKnobOver;
knobDown = sliderKnobDown;
}};
vSlider = new SliderStyle(){{
background = sliderVertical;
knob = sliderKnob;
knobOver = sliderKnobOver;
knobDown = sliderKnobDown;
}};
defaultLabel = new LabelStyle(){{
font = Fonts.def;
fontColor = Color.white;
}};
outlineLabel = new LabelStyle(){{
font = Fonts.outline;
fontColor = Color.white;
}};
defaultField = new TextFieldStyle(){{
font = Fonts.chat;
fontColor = Color.white;
disabledFontColor = Color.gray;
disabledBackground = underlineDisabled;
selection = Tex.selection;
background = underline;
invalidBackground = underlineRed;
cursor = Tex.cursor;
messageFont = Fonts.def;
messageFontColor = Color.gray;
}};
areaField = new TextFieldStyle(){{
font = Fonts.chat;
fontColor = Color.white;
disabledFontColor = Color.gray;
selection = Tex.selection;
background = underline;
cursor = Tex.cursor;
messageFont = Fonts.def;
messageFontColor = Color.gray;
}};
defaultCheck = new CheckBoxStyle(){{
checkboxOn = checkOn;
checkboxOff = checkOff;
checkboxOnOver = checkOnOver;
checkboxOver = checkOver;
checkboxOnDisabled = checkOnDisabled;
checkboxOffDisabled = checkDisabled;
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
}};
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");