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 yugecin.opsudance.events.ResolutionChangedListener;
|
||||
import yugecin.opsudance.events.SkinChangedListener;
|
||||
|
||||
import java.io.StringWriter;
|
||||
|
||||
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
|
||||
*/
|
||||
|
@ -34,6 +36,7 @@ public abstract class BaseOpsuState implements OpsuState, ResolutionChangedListe
|
|||
|
||||
public BaseOpsuState() {
|
||||
displayContainer.addResolutionChangedListener(this);
|
||||
skinservice.addSkinChangedListener(this);
|
||||
}
|
||||
|
||||
protected void revalidate() {
|
||||
|
@ -51,8 +54,17 @@ public abstract class BaseOpsuState implements OpsuState, ResolutionChangedListe
|
|||
public void render(Graphics g) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSkinChanged(String name) {
|
||||
makeDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResolutionChanged(int w, int h) {
|
||||
makeDirty();
|
||||
}
|
||||
|
||||
private void makeDirty() {
|
||||
if (isCurrentState) {
|
||||
revalidate();
|
||||
return;
|
||||
|
|
|
@ -19,6 +19,5 @@ package yugecin.opsudance.events;
|
|||
|
||||
public interface SkinChangedListener
|
||||
{
|
||||
void onSkinChanged(String stringName);
|
||||
|
||||
void onSkinChanged(String name);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user