revalidate options overlay when skin changes

This commit is contained in:
yugecin 2018-08-28 21:55:07 +02:00
parent b540be8736
commit dd2ac9c1f2
No known key found for this signature in database
GPG Key ID: 2C5AC035A7068E44

View File

@ -27,6 +27,7 @@ import org.lwjgl.input.Keyboard;
import org.newdawn.slick.*; import org.newdawn.slick.*;
import org.newdawn.slick.gui.TextField; import org.newdawn.slick.gui.TextField;
import yugecin.opsudance.events.ResolutionChangedListener; import yugecin.opsudance.events.ResolutionChangedListener;
import yugecin.opsudance.events.SkinChangedListener;
import yugecin.opsudance.options.*; import yugecin.opsudance.options.*;
import yugecin.opsudance.utils.FontUtil; import yugecin.opsudance.utils.FontUtil;
@ -34,10 +35,11 @@ import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Random; import java.util.Random;
import static itdelatrisu.opsu.GameImage.*;
import static yugecin.opsudance.core.InstanceContainer.*; import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*; import static yugecin.opsudance.options.Options.*;
public class OptionsOverlay implements ResolutionChangedListener { public class OptionsOverlay implements ResolutionChangedListener, SkinChangedListener {
private static final float BG_ALPHA = 0.7f; private static final float BG_ALPHA = 0.7f;
private static final float LINEALPHA = 0.8f; private static final float LINEALPHA = 0.8f;
@ -178,6 +180,7 @@ public class OptionsOverlay implements ResolutionChangedListener {
scrollHandler.setAllowOverScroll(true); scrollHandler.setAllowOverScroll(true);
displayContainer.addResolutionChangedListener(this); displayContainer.addResolutionChangedListener(this);
skinservice.addSkinChangedListener(this);
} }
@Override @Override
@ -188,6 +191,14 @@ public class OptionsOverlay implements ResolutionChangedListener {
} }
} }
@Override
public void onSkinChanged(String name) {
this.dirty = true;
if (this.active) {
this.revalidate();
}
}
public boolean isActive() { public boolean isActive() {
return this.active; return this.active;
} }
@ -233,9 +244,10 @@ public class OptionsOverlay implements ResolutionChangedListener {
controlImageSize = (int) (Fonts.MEDIUM.getLineHeight() * 0.7f); controlImageSize = (int) (Fonts.MEDIUM.getLineHeight() * 0.7f);
controlImagePadding = (optionHeight - controlImageSize) / 2; controlImagePadding = (optionHeight - controlImageSize) / 2;
sliderBallImg = GameImage.CONTROL_SLIDER_BALL.getImage().getScaledCopy(controlImageSize, controlImageSize); final int s = controlImageSize;
checkOnImg = GameImage.CONTROL_CHECK_ON.getImage().getScaledCopy(controlImageSize, controlImageSize); sliderBallImg = CONTROL_SLIDER_BALL.getScaledImage(s, s);
checkOffImg = GameImage.CONTROL_CHECK_OFF.getImage().getScaledCopy(controlImageSize, controlImageSize); checkOnImg = CONTROL_CHECK_ON.getScaledImage(s, s);
checkOffImg = CONTROL_CHECK_OFF.getScaledImage(s, s);
int navTotalHeight = 0; int navTotalHeight = 0;
dropdownMenus.clear(); dropdownMenus.clear();
@ -1175,5 +1187,4 @@ public class OptionsOverlay implements ResolutionChangedListener {
void onLeaveOptionsMenu(); void onLeaveOptionsMenu();
void onSaveOption(Option option); void onSaveOption(Option option);
} }
} }