Add dark theme, use its background, allow changing theme

This commit is contained in:
Lonami Exo 2017-01-30 18:37:06 +01:00
parent a681fbaccd
commit 382a41c06b
7 changed files with 47 additions and 5 deletions

View file

@ -0,0 +1,19 @@
{
"name": "Dark",
"price": 0,
"colors": {
"background": "333333ff",
"buttons": [
"03c13dff",
"007da4ff",
"c23a20ff",
"956fd6ff"
],
"cells": [
"7931bfff", "4c87aeff", "3aa853ff",
"1e984dff", "2e749bff", "db5500ff", "d88109ff",
"d9294dff", "ac342bff"
]
},
"cell_texture": "basic.png"
}

View file

@ -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
}

View file

@ -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;
}
}

View file

@ -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;

View file

@ -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();

View file

@ -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();

View file

@ -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();