mark states as dirty when the skin changes
This commit is contained in:
parent
8d109df629
commit
5a057a229e
|
@ -19,13 +19,15 @@ package yugecin.opsudance.core.state;
|
||||||
|
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import yugecin.opsudance.events.ResolutionChangedListener;
|
import yugecin.opsudance.events.ResolutionChangedListener;
|
||||||
|
import yugecin.opsudance.events.SkinChangedListener;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
||||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||||
|
|
||||||
public abstract class BaseOpsuState implements OpsuState, ResolutionChangedListener {
|
public abstract class BaseOpsuState implements OpsuState, ResolutionChangedListener,
|
||||||
|
SkinChangedListener
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* state is dirty when resolution or skin changed but hasn't rendered yet
|
* state is dirty when resolution or skin changed but hasn't rendered yet
|
||||||
*/
|
*/
|
||||||
|
@ -34,6 +36,7 @@ public abstract class BaseOpsuState implements OpsuState, ResolutionChangedListe
|
||||||
|
|
||||||
public BaseOpsuState() {
|
public BaseOpsuState() {
|
||||||
displayContainer.addResolutionChangedListener(this);
|
displayContainer.addResolutionChangedListener(this);
|
||||||
|
skinservice.addSkinChangedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void revalidate() {
|
protected void revalidate() {
|
||||||
|
@ -51,8 +54,17 @@ public abstract class BaseOpsuState implements OpsuState, ResolutionChangedListe
|
||||||
public void render(Graphics g) {
|
public void render(Graphics g) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSkinChanged(String name) {
|
||||||
|
makeDirty();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResolutionChanged(int w, int h) {
|
public void onResolutionChanged(int w, int h) {
|
||||||
|
makeDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void makeDirty() {
|
||||||
if (isCurrentState) {
|
if (isCurrentState) {
|
||||||
revalidate();
|
revalidate();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -19,6 +19,5 @@ package yugecin.opsudance.events;
|
||||||
|
|
||||||
public interface SkinChangedListener
|
public interface SkinChangedListener
|
||||||
{
|
{
|
||||||
void onSkinChanged(String stringName);
|
void onSkinChanged(String name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user