private void buildTutorialDialog(String animationPath) { AssetManager manager = AssetManager.getInstance(); StyleHelper helper = StyleHelper.getInstance(); final Dialog tutorial = new Dialog("", StyleHelper.getInstance() .getDialogStyle()); tutorial.clear(); tutorial.fadeDuration = 0f; Table buttonTable = new Table(); Drawable drawable = new TextureRegionDrawable(new TextureRegion( manager.get(animationPath, Texture.class))); // used image button here because it keeps the ratio of the texture ImageButton tutorialImage = new ImageButton(drawable); ImageButton okay = new ImageButton( helper.getImageButtonStyleRound("widgets/icon-check")); okay.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { tutorial.hide(); } }); buttonTable.add(okay).size(100).bottom().right().expand().pad(30); tutorial.stack(tutorialImage, buttonTable).height(500).width(800); tutorial.show(stage); }
/** * Creates the screen of a level within the placement mode. This is the * screen which is presented to the user upon entering a recoloring or * termedit level. * * @param game * the backreference to the central game * @param controller * the game controller, which is responsible for the played level */ public PlacementModeScreen(AlligatorApp game, GameController controller) { super(game); gameController = controller; AssetManager assetManager = AssetManager.getInstance(); assetManager.load(getAssetDirPath() + "textures/pack.atlas", TextureAtlas.class); goalDialog = new Dialog("", StyleHelper.getInstance().getDialogStyle()); fillTable(); final int packageIndex = gameController.getLevel().getPackageIndex(); final LevelPackagesController packagesController = game .getLevelPackagesController(); final LevelPackage pack = packagesController.getLevelPackages().get( packageIndex); setBackground(pack.getDesign()); game.getSettingController().addSettingChangeListener(this); // load graphics for animation/tutorial if (gameController.getLevel().hasAnimation()) { List<String> animations = gameController.getLevel().getAnimation(); for (String animation : animations) { assetManager.load(animation, Texture.class); } } }
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 by the application lifecycle when the game is shut down. Should dispose everything * that was allocated. */ @Override public void dispose() { batch.dispose(); StyleHelper.getInstance().dispose(); // release catching of back key (no idea if necessary) Gdx.input.setCatchBackKey(false); }
private void fillTable() { int i = 0; final int colorsPerRow = 2; for (Color c : cctrl.getUsableColors()) { Button bt = new Button(StyleHelper.getInstance().getDrawable("widgets/button")); ColorButton btn = new ColorButton(c); btn.addListener(new ColorButtonListener()); bt.add(btn).size(60, 60).center(); this.add(bt).size(76, 76).pad(6); i++; if (i % colorsPerRow == 0) { this.row(); } } }
/** * Creates a new popup to offer the possibility to recolor a certain ColoredBoardObect. * * @param editing * @param c * @throws IllegalArgumentException if the given {@link ColoredBoardObject} does not allow * recoloring */ public ColorSelectorPopup(BoardActorLayoutEditing editing, ColoredBoardObject c) { if (!c.isRecolorable()) { throw new IllegalArgumentException( "ColorSelectPopup can only work on ColoredBoardObjects which allow recoloring."); } boardObject = c; messenger = editing.getMessenger(); ActorLayoutConfiguration config = editing.getLayout().getLayoutConfiguration(); cctrl = config.getColorController(); colorBlindEnabled = config.isColorBlindEnabled(); this.setBackground(StyleHelper.getInstance().getDrawable("widgets/button")); setSize(width, height); setTouchable(Touchable.enabled); fillTable(); }
private void fillTable() { StyleHelper helper = StyleHelper.getInstance(); Table leftTable = new Table(); ImageButton menu = new ImageButton( helper.getImageButtonStyleRound("widgets/icon-menu")); ImageButton hint = new ImageButton( helper.getImageButtonStyleRound("widgets/icon-hint")); zoomIn = new ImageButton( helper.getImageButtonStyleRound("widgets/icon-plus")); zoomOut = new ImageButton( helper.getImageButtonStyleRound("widgets/icon-minus")); Button goal = new ImageButton( helper.getImageButtonStyleRound("widgets/icon-goal")); ImageButton startSimulation = new ImageButton(StyleHelper.getInstance() .getImageButtonStyleRound("widgets/icon-next")); startSimulation.addListener(new StartSimulationListener()); // add listeners menu.addListener(new MenuClickListener()); hint.addListener(new HintClickListener()); leftTable.pad(30); leftTable.defaults().space(30); leftTable.add(menu).size(100).top().left(); leftTable.row(); // TODO only activated after some time leftTable.add(hint).expand().size(100).top().left(); leftTable.row(); leftTable.add(goal).expand().size(100).top().left(); leftTable.row(); leftTable.add(zoomIn).size(70).left(); leftTable.row(); leftTable.add(zoomOut).size(70).left(); final ColorController colorController = gameController .getColorController(); final ActorLayoutConfiguration config = new ActorLayoutConfiguration(); config.setColorController(colorController); boardActor = new BoardActor(gameController.getShownBoard(), config); boardActor.setColorBlindEnabled(game.getSettingController() .getCurrentSetting().isColorblindEnabled()); game.getSettingController().addSettingChangeListener(boardActor); // used to make resetting the board via game controller possible gameController.registerPlacementBoardEventListener(boardActor .getBoardEventListener()); final Table boardTable = new Table(); boardTable.add(boardActor).fill().expand(); final Table controlTable = new Table(); controlTable.add(leftTable).expand().fill(); if (gameController.getLevel().getShowObjectBar()) { boardActor.enableLayoutEditing( gameController.getPlacmentBoardEventListener(), true); ObjectBar objectBar = boardActor.getObjectBar(); objectBar.add(startSimulation).size(200); controlTable.add(objectBar).padLeft(30); } else { boardActor.enableLayoutEditing( gameController.getPlacmentBoardEventListener(), false); controlTable.add(startSimulation).bottom().right().size(200) .pad(30); } table.stack(boardTable, controlTable).fill().expand(); onSettingChange(game.getSettingController().getCurrentSetting()); BoardActor goalBoard = new BoardActor(gameController.getLevel() .getGoalBoard(), config); goalBoard.setZoomAndPanEnabled(false); goalBoard.setColorBlindEnabled(game.getSettingController() .getCurrentSetting().isColorblindEnabled()); game.getSettingController().addSettingChangeListener(goalBoard); Table goalTable = new Table(); goalTable.add(goalBoard).size(getViewportHeight()); goal.addListener(new GoalClickListener()); goalDialog.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { goalDialog.hide(); } }); goalDialog.add(goalTable).width(getViewportWidth() - 250) .height(getViewportHeight()); }
private void fillTable() { StyleHelper helper = StyleHelper.getInstance(); ImageButton back = new ImageButton( helper.getImageButtonStyleRound("widgets/icon-back")); Table scrollTable = new Table(); // ScrollPane scroll = new ScrollPane(scrollTable); Label gameplay = new Label(_("settings_title_gameplay"), helper.getLabelStyle(40)); Label zoom = new Label(_("settings_title_zoom"), helper.getLabelStyle()); Label colorBlindness = new Label(_("settings_title_color_blindness"), helper.getLabelStyle()); Label sound = new Label(_("settings_title_sound"), helper.getLabelStyle(40)); Label music = new Label(_("settings_title_music"), helper.getLabelStyle()); Label effects = new Label(_("settings_title_effects"), helper.getLabelStyle()); Label profile = new Label(_("settings_title_profile"), helper.getLabelStyle(40)); zoomCheckBox = new CheckBox("", helper.getCheckBoxStyle()); colorBlindnessCheckBox = new CheckBox("", helper.getCheckBoxStyle()); musicSlider = new Slider(0, 100, 1, false, helper.getSliderStyle()); effectsSlider = new Slider(0, 100, 1, false, helper.getSliderStyle()); musicSlider.setValue(50); effectsSlider.setValue(50); TextButton editProfile = new TextButton( _("settings_button_edit_profile"), helper.getTextButtonStyle()); // add listeners back.addListener(new LogicalPredecessorListener()); SettingListener settingListener = new SettingListener(); zoomCheckBox.addListener(settingListener); colorBlindnessCheckBox.addListener(settingListener); musicSlider.addListener(settingListener); effectsSlider.addListener(settingListener); editProfile.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (game.getProfileController().getCurrentProfile() != null) { Dialog dialog = new EditProfileDialog(); dialog.show(stage); } else { Dialog dialog = new NotificationDialog( _("warning_no_profile_selected")); dialog.show(stage); } } }); scrollTable.defaults().left().space(10); scrollTable.add(gameplay).row(); scrollTable.add(zoom).expandX().padLeft(30); scrollTable.add(zoomCheckBox).size(50).center().row(); scrollTable.add(colorBlindness).expandX().padLeft(30); scrollTable.add(colorBlindnessCheckBox).size(50).center().row(); scrollTable.add(sound).row(); scrollTable.add(music).padLeft(30); scrollTable.add(musicSlider).width(300).height(50).row(); scrollTable.add(effects).padLeft(30); scrollTable.add(effectsSlider).width(300).height(50).row(); scrollTable.add(profile).row(); scrollTable.add(editProfile).width(300).height(75); scrollTable.pad(50).padRight(150); table.add(back).size(100).top().left(); table.add(scrollTable).expand().fill(); table.pad(30); onProfileChange(null); }
public EditProfileDialog() { super("", StyleHelper.getInstance().getDialogStyle()); StyleHelper helper = StyleHelper.getInstance(); Label message = new Label(_("title_edit_profile"), helper.getBlackLabelStyle()); TextButton name = new TextButton(_("edit_profile_button_rename"), helper.getTextButtonStyle()); TextButton avatar = new TextButton( _("edit_profile_button_change_avatar"), helper.getTextButtonStyle()); TextButton delete = new TextButton(_("edit_profile_button_delete"), helper.getTextButtonStyle()); TextButton nothing = new TextButton( _("edit_profile_button_nothing"), helper.getTextButtonStyle()); name.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { game.getProfileSetNameScreen().setIsInEditMode(true); EditProfileDialog.this.hide(); game.showProfileSetNameScreen(false); } }); avatar.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { game.getProfileSetAvatarScreen().setInEditMode(true); EditProfileDialog.this.hide(); game.showProfileSetAvatarScreen("", false); }; }); delete.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Dialog dialog = new YesNoDialog(String.format( _("edit_profile_delete_confirmation"), game .getProfileController() .getCurrentProfileName()), new ConfirmInterface() { @Override public void yes() { game.getProfileController() .deleteCurrentProfile(); game.showSelectProfileScreen(); } @Override public void no() { // TODO Auto-generated method stub } }); dialog.show(stage); EditProfileDialog.this.hide(); } }); nothing.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { EditProfileDialog.this.hide(); }; }); clear(); add(message).center().pad(100).colspan(4).row(); add(name).minWidth(150).height(70).pad(10); add(avatar).minWidth(150).height(70).pad(10); add(delete).minWidth(150).height(70).pad(10); add(nothing).minWidth(150).height(70).pad(10); }