/**
   * 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));
      }
    }
  }
	private void fillTable() {
		StyleHelper helper = StyleHelper.getInstance();

		Table scrollTable = new Table();
		ImageButton newProfile = new ImageButton(
				helper.getImageButtonStyle("widgets/icon-plus"));

		newProfile.addListener(new NewProfileClickListener());

		scrollTable.defaults().width(500).height(100).space(10);
		
		scrollTable.padTop(30);
		for (Profile profile : profileController.getAllProfiles()) {
			TextButton profileButton = new TextButton(profile.getName(),
					helper.getTextButtonStyle());
			scrollTable.add(profileButton);
			scrollTable.row();
			profileButton.addListener(new ChangeProfileClickListener());
		}

		
		scrollTable.add(newProfile);

		scrollTable.padBottom(15);
		ScrollPane scrollPane = new ScrollPane(scrollTable);
		table.add(scrollPane).expand().fill();
	}
  /**
   * Is called after create() is done, means after the asset manager is done loading. TODO is called
   * by the loading screen, which is ugly
   */
  public void created() {
    soundController.addToPlaylist("music1.mp3");
    soundController.startPlaylist();

    profileController.loadLastActiveProfile();
  }