package com.kangacult.octogone;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;

public class GamePrefs {
	// Make the class a Singleton
	public static final GamePrefs instance = new GamePrefs();

	// Game preferences
	public boolean fullScreen;
	public boolean gamePadEnable;
	public float hScore;
	public int hWave;

	// Saving
	private Preferences prefs;

	// Singleton
	public GamePrefs() {
		prefs = Gdx.app.getPreferences("octo-gone.5.prefs");
	}

	// Load up game variables
	public void load() {
		// Game variables
		fullScreen = prefs.getBoolean("fullscreen", false);
		gamePadEnable = prefs.getBoolean("gamepad", true);
		hScore = prefs.getFloat("hScore", 0.0f);
		hWave = prefs.getInteger("hWave", 0);
	}

	public void highScore(float cScore)
	{
		if (cScore > hScore) {
			hScore = cScore;
		}
	}

	public void highWave(int cWave)
	{
		if (cWave > hWave) {
			hWave = cWave;
		}
	}

	// Save game variables
	public void saveSettings() {
		// Game variables
		prefs.putBoolean("fullscreen", fullScreen);
		prefs.putBoolean("gamepad", fullScreen);
		prefs.putFloat("hScore", hScore);
		prefs.putInteger("hWave", hWave);
		// Flush to confirm
		prefs.flush();
	}
}
