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
19
android/assets/themes/dark.theme
Normal file
19
android/assets/themes/dark.theme
Normal 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"
|
||||||
|
}
|
|
@ -82,5 +82,10 @@ public class Klooni extends Game {
|
||||||
prefs.putBoolean("muteSound", soundsEnabled()).flush();
|
prefs.putBoolean("muteSound", soundsEnabled()).flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void updateTheme(Theme newTheme) {
|
||||||
|
prefs.putString("themeName", newTheme.getName()).flush();
|
||||||
|
theme.update(newTheme.getName());
|
||||||
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,4 +84,12 @@ public class Theme {
|
||||||
void dispose() {
|
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 ShapeRenderer shapeRenderer;
|
||||||
|
|
||||||
private final Theme theme;
|
public final Theme theme;
|
||||||
|
|
||||||
// TODO Use the cell patch given the theme, not basic
|
// TODO Use the cell patch given the theme, not basic
|
||||||
private final NinePatch cellPatch;
|
private final NinePatch cellPatch;
|
||||||
|
|
|
@ -6,6 +6,8 @@ import com.badlogic.gdx.Input;
|
||||||
import com.badlogic.gdx.Screen;
|
import com.badlogic.gdx.Screen;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
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.Stage;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
|
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
||||||
|
@ -87,7 +89,15 @@ public class CustomizeScreen implements Screen {
|
||||||
|
|
||||||
VerticalGroup themesGroup = new VerticalGroup();
|
VerticalGroup themesGroup = new VerticalGroup();
|
||||||
for (Theme theme : Theme.getThemes()) {
|
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);
|
themesGroup.space(8);
|
||||||
|
@ -103,7 +113,7 @@ public class CustomizeScreen implements Screen {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
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);
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
stage.act(Math.min(Gdx.graphics.getDeltaTime(), minDelta));
|
stage.act(Math.min(Gdx.graphics.getDeltaTime(), minDelta));
|
||||||
stage.draw();
|
stage.draw();
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class GameScreen implements Screen, InputProcessor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
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);
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
batch.begin();
|
batch.begin();
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class MainMenuScreen extends InputListener implements Screen {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
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);
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
stage.act(Math.min(Gdx.graphics.getDeltaTime(), minDelta));
|
stage.act(Math.min(Gdx.graphics.getDeltaTime(), minDelta));
|
||||||
stage.draw();
|
stage.draw();
|
||||||
|
|
Loading…
Reference in a new issue