org.newdawn.slick.gui.TextField Java Examples
The following examples show how to use
org.newdawn.slick.gui.TextField.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OptionsOverlay.java From opsu-dance with GNU General Public License v3.0 | 6 votes |
public OptionsOverlay(OptionTab[] sections) { this.backButtonListener = BackButton.Listener.fromOverlay(this::exit); this.installedOptionListeners = new ArrayList<>(); this.sections = sections; this.dirty = true; dropdownMenus = new HashMap<>(); visibleDropdownMenus = new LinkedList<>(); searchField = new TextField(null, 0, 0, 0, 0); searchField.setMaxLength(20); scrollHandler = new KineticScrolling(); scrollHandler.setAllowOverScroll(true); displayContainer.addResolutionChangedListener(this); skinservice.addSkinChangedListener(this); }
Example #2
Source File: SavedStateTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.Game#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { state = new SavedState("testdata"); nameValue = state.getString("name","DefaultName"); ageValue = (int) state.getNumber("age",64); name = new TextField(container,container.getDefaultFont(),100,100,300,20,this); age = new TextField(container,container.getDefaultFont(),100,150,201,20,this); }
Example #3
Source File: OptionsOverlay.java From opsu with GNU General Public License v3.0 | 4 votes |
/** * Creates the options overlay. * @param container the game container * @param groups the option groups * @param listener the event listener */ public OptionsOverlay(GameContainer container, OptionGroup[] groups, OptionsOverlayListener listener) { super(container); this.container = container; this.groups = groups; this.listener = listener; this.input = container.getInput(); this.containerWidth = container.getWidth(); this.containerHeight = container.getHeight(); // control images this.iconSize = (int) (18 * GameImage.getUIscale()); this.sliderBallImg = GameImage.CONTROL_SLIDER_BALL.getImage().getScaledCopy(iconSize, iconSize); this.checkOnImg = GameImage.CONTROL_CHECK_ON.getImage().getScaledCopy(iconSize, iconSize); this.checkOffImg = GameImage.CONTROL_CHECK_OFF.getImage().getScaledCopy(iconSize, iconSize); int searchImgSize = (int) (Fonts.LARGE.getLineHeight() * 0.75f); this.searchImg = GameImage.SEARCH.getImage().getScaledCopy(searchImgSize, searchImgSize); boolean isWidescreen = (int) (container.getAspectRatio() * 1000) > 1500; // 1333 = 4:3, 1777 = 16:9 // overlay positions this.x = 0; this.y = 0; this.targetWidth = (int) (containerWidth * (isWidescreen ? 0.4f : 0.5f)); this.height = containerHeight; // option positions float navIconWidthRatio = isWidescreen ? 0.046875f : 0.065f; // non-widescreen ratio is not accurate navButtonSize = (int) (container.getWidth() * navIconWidthRatio); navIndicatorWidth = navButtonSize / 10; navTargetWidth = (int) (targetWidth * 0.45f) - navButtonSize; this.paddingRight = (int) (containerWidth * 0.009375f); // not so accurate this.paddingLeft = navButtonSize + (int) (containerWidth * 0.0180f); // not so accurate this.paddingTextLeft = paddingLeft + LINE_WIDTH + (int) (containerWidth * 0.00625f); // not so accurate this.optionStartX = paddingTextLeft; this.textOptionsY = Fonts.LARGE.getLineHeight() * 2; this.textChangeY = textOptionsY + Fonts.LARGE.getLineHeight(); this.searchY = textChangeY + Fonts.MEDIUM.getLineHeight() * 2; this.textSearchYOffset = Fonts.MEDIUM.getLineHeight() / 2; this.optionStartY = searchY + Fonts.MEDIUM.getLineHeight() + Fonts.LARGE.getLineHeight(); int paddingX = 24; this.optionWidth = targetWidth - paddingX * 2; this.optionHeight = (int) (Fonts.MEDIUM.getLineHeight() * 1.3f); this.optionGroupPadding = (int) (Fonts.LARGE.getLineHeight() * 1.5f); this.optionTextOffsetY = (int) ((optionHeight - Fonts.MEDIUM.getLineHeight()) / 2f); this.controlImageSize = (int) (Fonts.MEDIUM.getLineHeight() * 0.7f); this.controlImagePadding = (optionHeight - controlImageSize) / 2; // back button int backSize = Fonts.XLARGE.getLineHeight() * 2 / 3; Image backArrow = GameImage.CHEVRON_LEFT.getImage().getScaledCopy(backSize, backSize); this.backButton = new MenuButton(backArrow, 0, 0); backButton.setHoverExpand(1.5f); // restart button Image restartImg = GameImage.UPDATE.getImage().getScaledCopy(backSize, backSize); this.restartButton = new MenuButton(restartImg, 0, 0); restartButton.setHoverAnimationDuration(2000); restartButton.setHoverRotate(360); // search field this.searchField = new TextField(container, null, 0, 0, 0, 0); searchField.setMaxLength(20); // kinetic scrolling this.scrolling = new KineticScrolling(); scrolling.setAllowOverScroll(true); // calculate offset for navigation bar icons int navTotalHeight = 0; for (OptionGroup group : groups) { if (group.getOptions() == null) { navTotalHeight += navButtonSize; } } navStartY = (height - navTotalHeight) / 2; }
Example #4
Source File: UserSelectOverlay.java From opsu with GNU General Public License v3.0 | 4 votes |
/** * Creates the user selection overlay. * @param container the game container * @param listener the event listener */ public UserSelectOverlay(GameContainer container, UserSelectOverlayListener listener) { super(container); this.listener = listener; this.input = container.getInput(); this.containerWidth = container.getWidth(); this.containerHeight = container.getHeight(); // overlay positions this.x = containerWidth / 3; this.y = 0; this.width = containerWidth / 3; this.height = containerHeight; // user positions this.titleY = Fonts.LARGE.getLineHeight() * 2; this.usersStartX = (width - UserButton.getWidth()) / 2; this.usersStartY = (int) (titleY + Fonts.XLARGE.getLineHeight() * 1.5f); this.usersPaddingY = UserButton.getHeight() / 10; // new user this.newUser = new User("", UserList.DEFAULT_ICON); this.newUserButton = new UserButton( (int) (this.x + usersStartX), (int) (this.y + usersStartY + Fonts.MEDIUMBOLD.getLineHeight()), Color.white ); newUserButton.setUser(newUser); newUserButton.setHoverAnimationDuration(400); newUserButton.setHoverAnimationEquation(AnimationEquation.LINEAR); // new user text field this.textField = new TextField(container, null, 0, 0, 0, 0); textField.setMaxLength(UserList.MAX_USER_NAME_LENGTH); // user icons this.userIcons = new MenuButton[UserButton.getIconCount()]; for (int i = 0; i < userIcons.length; i++) { userIcons[i] = new MenuButton(UserButton.getIconImage(i), 0, 0); userIcons[i].setHoverFade(0.5f); } // edit user this.editUserButton = new UserButton( (int) (this.x + usersStartX), (int) (this.y + usersStartY), Color.white ); // delete user deleteUserButton = new UserButton( (int) (this.x + usersStartX), (int) (this.y + usersStartY + UserButton.getHeight() + usersPaddingY), Colors.RED_HOVER ); deleteUserButton.setHoverAnimationBase(0.5f); // kinetic scrolling this.scrolling = new KineticScrolling(); scrolling.setAllowOverScroll(true); }