/** * Creates a new HUDSystem object * * @param batch - the batch that had been being drawn to before this system * @param commandUI - the command system * @param level - the level to represent * @param screen - a rectangle containing the region that is visible on the screen */ public HUDSystem(DrawingBatch batch, CommandUISystem commandUI, Level level, Rectangle screen) { super(6); this.batch = batch; this.commandUI = commandUI; this.level = level; this.screen = screen; tooltipManager = new TooltipManager(); tooltipManager.initialTime = 0.00f; tooltipManager.subsequentTime = tooltipManager.initialTime; tooltipManager.resetTime = 0.00f; tooltipManager.hideAll(); messageEntities = new LinkedList<>(); buttons = new ArrayList<>(); }
/** Since main tooltip manager instance cannot be changed globally with a regular setter, this method modifies it * using reflection. * * @param tooltipManager will be returned on {@link TooltipManager#getInstance()} calls. */ public static void setDefaultTooltipManager(final TooltipManager tooltipManager) { try { // We have to set the app field, as it is validated by the static getter. Reflection.setFieldValue(ClassReflection.getDeclaredField(TooltipManager.class, "app"), null, Gdx.app); Reflection.setFieldValue(ClassReflection.getDeclaredField(TooltipManager.class, "instance"), null, tooltipManager); } catch (final ReflectionException exception) { throw new GdxRuntimeException("Unable to set default tooltip manager.", exception); } }
/** Since main tooltip manager instance cannot be changed globally with a regular setter, this method modifies it * using reflection. * * @param tooltipManager will be returned on {@link TooltipManager#getInstance()} calls. * @throws GdxRuntimeException if unable to change manager. */ public static void setDefaultTooltipManager(final TooltipManager tooltipManager) { try { TooltipManager.getInstance(); Reflection.setFieldValue(ClassReflection.getDeclaredField(TooltipManager.class, "instance"), null, tooltipManager); } catch (final ReflectionException exception) { throw new GdxRuntimeException("Unable to set default tooltip manager.", exception); } }
@Override protected Actor getNewInstanceOfActor(final LmlActorBuilder builder) { final TooltipManager manager = getTooltipManager((TooltipLmlActorBuilder) builder); final TooltipTable table = TooltipTable.create(getSkin(builder), manager); tooltip = table.getTooltip(); return table; }
/** @param builder contains tooltip building data. * @return an instance of tooltip manager with the ID selected by the builder or default tooltip manager. * @throws LmlParsingException if parser is strict and the ID is invalid. */ protected TooltipManager getTooltipManager(final TooltipLmlActorBuilder builder) { TooltipManager manager = getParser().getData().getTooltipManager(builder.getTooltipManager()); if (manager == null) { getParser().throwErrorIfStrict("Could not find tooltip manager for name: " + builder.getTooltipManager()); manager = TooltipManager.getInstance(); } return manager; }
/** @param skin used to construct table. * @param tooltipManager used to construct tooltip. * @return a new TooltipTable instance with a fully initiated tooltip accessible with {@link #getTooltip()} * method. */ public static TooltipTable create(final Skin skin, final TooltipManager tooltipManager) { final Tooltip<TooltipTable> tooltip = new Tooltip<TooltipTable>(null, tooltipManager); final TooltipTable content = new TooltipTable(skin, tooltip); tooltip.setActor(content); return content; }
public TooltipManager getManager() { return manager; }
public void setManager(TooltipManager manager) { this.manager = manager; }
private void initDefaults() { if (Utils.isMac()) System.setProperty("java.awt.headless", "true"); skin.getFont("font").getData().markupEnabled = true; //copy defaults.json to temp folder if it doesn't exist FileHandle fileHandle = Gdx.files.local("texturepacker/defaults.json"); if (!fileHandle.exists()) { Gdx.files.internal("defaults.json").copyTo(fileHandle); } ibeamListener = new IbeamListener(); projectData = new ProjectData(); projectData.setMain(this); projectData.randomizeId(); projectData.setMaxUndos(30); dialogFactory = new DialogFactory(this); undoableManager = new UndoableManager(this); desktopWorker.attachLogListener(); desktopWorker.sizeWindowToFit(800, 800, 50, Gdx.graphics); desktopWorker.centerWindow(Gdx.graphics); desktopWorker.setCloseListener(() -> { dialogFactory.showCloseDialog(); return false; }); loadingAnimation = new AnimatedDrawable(.05f); loadingAnimation.addDrawable(skin.getDrawable("loading_0")); loadingAnimation.addDrawable(skin.getDrawable("loading_1")); loadingAnimation.addDrawable(skin.getDrawable("loading_2")); loadingAnimation.addDrawable(skin.getDrawable("loading_3")); loadingAnimation.addDrawable(skin.getDrawable("loading_4")); loadingAnimation.addDrawable(skin.getDrawable("loading_5")); loadingAnimation.addDrawable(skin.getDrawable("loading_6")); loadingAnimation.addDrawable(skin.getDrawable("loading_7")); projectData.getAtlasData().clearTempData(); handListener = new HandListener(); tooltipManager = new TooltipManager(); tooltipManager.animations = false; tooltipManager.initialTime = .4f; tooltipManager.resetTime = 0.0f; tooltipManager.subsequentTime = 0.0f; tooltipManager.hideAll(); tooltipManager.instant(); }
public TooltipManager getTooltipManager() { return tooltipManager; }
/** @param tooltipManager will be accessible with the default ID. */ void setDefaultTooltipManager(TooltipManager tooltipManager);
@Override public void addTooltipManager(final String name, final TooltipManager tooltipManager) { tooltipManagers.put(name, tooltipManager); }
@Override public void setDefaultTooltipManager(final TooltipManager tooltipManager) { tooltipManagers.put(DEFAULT_KEY, tooltipManager); }
@Override public TooltipManager getTooltipManager(final String name) { return tooltipManagers.get(name, TooltipManager.getInstance()); }
@Override public TooltipManager getDefaultTooltipManager() { return tooltipManagers.get(DEFAULT_KEY, TooltipManager.getInstance()); }
/** @param defaultTooltipManager will be set as the default {@link TooltipManager} instance used when no ID is * specified. * @return this for chaining. */ public LmlParserBuilder tooltipManager(final TooltipManager defaultTooltipManager) { parser.getData().setDefaultTooltipManager(defaultTooltipManager); return this; }
/** @param name ID of the registered manager. Implementation might make the ID ignore case, so be careful not to * repeat IDs for multiple managers. * @param tooltipManager will be accessible with the chosen ID. */ void addTooltipManager(String name, TooltipManager tooltipManager);
/** @param name ID of the manager. Might ignore case. * @return manager associated with the passed ID. */ TooltipManager getTooltipManager(String name);
/** @return tooltip manager associated with the default ID. By default, returns LibGDX static tooltip manager * instance. */ TooltipManager getDefaultTooltipManager();