package com.gamepatriot.framework2d.implementation;

import android.app.Activity;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

import com.gamepatriot.androidframework.framework.AndroidGameData;

/**
 * The GameData class is used to save and load dynamic data associated with the application. 
 * 
 * @see AndroidGameData
 * @author Pete Schmitz, May 8, 2013
 *
 */
public class GameData implements AndroidGameData {
	
	/** The unique save path to use for this application. **/
	public static String SAVE_PATH = "AndroidFramework";
	
	
	//References
	
	/** The reference to this applications {@link Main} object. **/
	private Main main;
	
	
	/**
	 * @param $main		Instantiated main class, primary activity of the application.
	 */
	public GameData(Main $main){
		main = $main;
		
		load();
	}
	
	@Override
	public void save() {
		Editor $editor = main.getSharedPreferences(SAVE_PATH, Activity.MODE_PRIVATE).edit();
		
		//$editor.putInt("levels", levels);
		
		$editor.commit();
	}
	
	@Override
	public void load() {
		SharedPreferences $sharedPreferences = main.getSharedPreferences(SAVE_PATH, Activity.MODE_PRIVATE);
		
		//levels = $sharedPreferences.getInt("levels", DEFAULT_LEVELS);
	}
	
	@Override
	public void clear() {
		Editor $editor = main.getSharedPreferences(SAVE_PATH, Activity.MODE_PRIVATE).edit();
		
		$editor.clear().commit();
	}
	
	@Override
	public void reset() {
		clear();
		load();
	}
	
	
	
}
