Skip to content

Commit

Permalink
Server Favourite Button
Browse files Browse the repository at this point in the history
I'm trying to add a feature while barely knowing what I'm doing...
  • Loading branch information
Atomic-Laboratory authored Apr 7, 2024
1 parent f093f94 commit c22e16d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions core/src/mindustry/ui/dialogs/JoinDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,21 @@ void addHeader(Table[] groupTable, ServerGroup group, boolean hidden, boolean do
head.image().height(3f).growX().color(col);

//button for showing/hiding servers
ImageButton[] image = {null};
image[0] = head.button(hidden ? Icon.eyeOffSmall : Icon.eyeSmall, Styles.grayi, () -> {
ImageButton[] image = {null, null};
image[0] = head.button(Icon.star, new ImageButton.ImageButtonStyle(){{
imageUpColor = group.favorite() ? Pal.accent : Color.lightGray;
imageDownColor = Color.white;
}}, () -> {
group.setFavorite(!group.favorite());
image[0].getStyle().imageUpColor = group.favorite() ? Pal.accent : Pal.lightishGray;
}).size(40f).get();
image[0].getStyle().imageUpColor = group.favorite() ? Pal.accent : Pal.lightishGray;
image[0].addListener(new Tooltip(t -> t.background(Styles.black6).margin(4).label(() -> !group.hidden() ? "@server.shown" : "@server.hidden")));

//button for showing/hiding servers
image[1] = head.button(hidden ? Icon.eyeOffSmall : Icon.eyeSmall, Styles.grayi, () -> {
group.setHidden(!group.hidden());
image[0].getStyle().imageUp = group.hidden() ? Icon.eyeOffSmall : Icon.eyeSmall;
image[1].getStyle().imageUp = group.hidden() ? Icon.eyeOffSmall : Icon.eyeSmall;
if(group.hidden() && !showHidden){
groupTable[0].remove();
}
Expand Down

0 comments on commit c22e16d

Please sign in to comment.