Add dark theme, use its background, allow changing theme
This commit is contained in:
parent
a681fbaccd
commit
382a41c06b
7 changed files with 47 additions and 5 deletions
|
@ -82,5 +82,10 @@ public class Klooni extends Game {
|
|||
prefs.putBoolean("muteSound", soundsEnabled()).flush();
|
||||
}
|
||||
|
||||
public static void updateTheme(Theme newTheme) {
|
||||
prefs.putString("themeName", newTheme.getName()).flush();
|
||||
theme.update(newTheme.getName());
|
||||
}
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
|
|
@ -84,4 +84,12 @@ public class Theme {
|
|||
void dispose() {
|
||||
|
||||
}
|
||||
|
||||
public void glClearBackground() {
|
||||
Gdx.gl.glClearColor(background.r, background.g, background.b, background.a);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class ThemeCard extends Actor {
|
|||
|
||||
private final ShapeRenderer shapeRenderer;
|
||||
|
||||
private final Theme theme;
|
||||
public final Theme theme;
|
||||
|
||||
// TODO Use the cell patch given the theme, not basic
|
||||
private final NinePatch cellPatch;
|
||||
|
|
|
@ -6,6 +6,8 @@ import com.badlogic.gdx.Input;
|
|||
import com.badlogic.gdx.Screen;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
||||
|
@ -87,7 +89,15 @@ public class CustomizeScreen implements Screen {
|
|||
|
||||
VerticalGroup themesGroup = new VerticalGroup();
|
||||
for (Theme theme : Theme.getThemes()) {
|
||||
themesGroup.addActor(new ThemeCard(layout, theme));
|
||||
final ThemeCard card = new ThemeCard(layout, theme);
|
||||
card.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
Klooni.updateTheme(card.theme);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
themesGroup.addActor(card);
|
||||
}
|
||||
|
||||
themesGroup.space(8);
|
||||
|
@ -103,7 +113,7 @@ public class CustomizeScreen implements Screen {
|
|||
|
||||
@Override
|
||||
public void render(float delta) {
|
||||
Gdx.gl.glClearColor(0.7f, 0.9f, 0.9f, 1);
|
||||
Klooni.theme.glClearBackground();
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
stage.act(Math.min(Gdx.graphics.getDeltaTime(), minDelta));
|
||||
stage.draw();
|
||||
|
|
|
@ -62,7 +62,7 @@ public class GameScreen implements Screen, InputProcessor {
|
|||
|
||||
@Override
|
||||
public void render(float delta) {
|
||||
Gdx.gl.glClearColor(0.9f, 0.9f, 0.9f, 1f);
|
||||
Klooni.theme.glClearBackground();
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
batch.begin();
|
||||
|
|
|
@ -70,7 +70,7 @@ public class MainMenuScreen extends InputListener implements Screen {
|
|||
|
||||
@Override
|
||||
public void render(float delta) {
|
||||
Gdx.gl.glClearColor(0.9f, 0.9f, 0.7f, 1);
|
||||
Klooni.theme.glClearBackground();
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
stage.act(Math.min(Gdx.graphics.getDeltaTime(), minDelta));
|
||||
stage.draw();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue