/**
   * Is called by the application lifecycle on creation. Does all the initialization that hasn't
   * been done by the constructor.
   */
  @Override
  public void create() {
    de.croggle.data.AssetManager.initialize();
    StyleHelper.initialize();
    SoundHelper.initialize();

    if (!HEADLESS) {
      this.batch = new SpriteBatch();
    }

    // catch android back key
    Gdx.input.setCatchBackKey(true);

    // initialize Controllers
    persistenceManager = new PersistenceManager(this);
    statisticController = new StatisticController(this);
    settingController = new SettingController(this);
    profileController = new ProfileController(this);
    soundController = new SoundController();
    levelPackagesController = new LevelPackagesController(this);

    // Not sure how to initialize those.
    achievementController = new AchievementController(this);
    levelPackagesController = new LevelPackagesController(this);

    if (!HEADLESS) {
      // / initialize screens
      mainMenuScreen = new MainMenuScreen(this);
      levelPackagesScreen = new LevelPackagesScreen(this);
      // levelsOverviewScreen = new LevelsOverviewScreen(this, null);
      // placementModeScreen = new PlacementModeScreen(this, null);
      // simulationModeScreen = new SimulationModeScreen(this, null);
      achievementScreen = new AchievementScreen(this);
      settingsScreen = new SettingsScreen(this);
      statisticScreen = new StatisticScreen(this);
      selectProfileScreen = new SelectProfileScreen(this);
      profileSetNameScreen = new ProfileSetNameScreen(this);
      profileSetAvatarScreen = new ProfileSetAvatarScreen(this);
      creditsScreen = new CreditsScreen(this);

      // add onProfileChangeListener
      settingController.addSettingChangeListener(soundController);
      profileController.addProfileChangeListener(settingsScreen);
      profileController.addProfileChangeListener(selectProfileScreen);
      profileController.addProfileChangeListener(mainMenuScreen);
      profileController.addProfileChangeListener(statisticScreen);

      if (profileController.getAllProfiles().isEmpty()) {
        profileSetNameScreen.showBackButton(false);
        setScreen(new LoadingScreen(this, profileSetNameScreen));
      } else {
        setScreen(new LoadingScreen(this, mainMenuScreen));
      }
    }
  }
	@Override
	public void onProfileChange(Profile profile) {
		Setting setting = settingController.getCurrentSetting();
		if (setting != null && areWidgetsInitialized()) {
			musicSlider.setValue(setting.getVolumeMusic() * 100);
			effectsSlider.setValue(setting.getVolumeEffects() * 100);
			zoomCheckBox.setChecked(setting.isZoomEnabled());
			colorBlindnessCheckBox.setChecked(setting.isColorblindEnabled());
		} else if (areWidgetsInitialized()) {
			musicSlider.setValue(50);
			effectsSlider.setValue(50);
			zoomCheckBox.setChecked(false);
			colorBlindnessCheckBox.setChecked(false);

		}

	}