private void toggleHelp() { if (help != null) { clearHelp(); return; } final int nbMonsters = monsters.size(); /* Prepare the String to display */ final IColoredString<Color> cs = new IColoredString.Impl<Color>(); cs.append("Still ", null); final Color nbColor; if (nbMonsters <= 1) /* Green */ nbColor = Color.GREEN; else if (nbMonsters <= 5) /* Orange */ nbColor = Color.ORANGE; else /* Red */ nbColor = Color.RED; cs.appendInt(nbMonsters, nbColor); cs.append(" monster" + (nbMonsters == 1 ? "" : "s") + " to kill", null); IColoredString<Color> helping1 = new IColoredString.Impl<Color>("Use numpad or vi-keys (hjklyubn) to move.", Color.WHITE); IColoredString<Color> helping2 = new IColoredString.Impl<Color>( "Use ? for help, f to change colors, q to quit.", Color.WHITE); IColoredString<Color> helping3 = new IColoredString.Impl<Color>( "Click the top or bottom border of the lower message box to scroll.", Color.WHITE); final Actor a; /* * Use TextPanel. There's less work to do than with * GroupCombinedPanel, and we can use a more legible variable-width font. * It doesn't seem like it when reading this code, but this actually does * much more than GroupCombinedPanel, because we do line wrapping and * justifying, without having to worry about sizes since TextPanel lays * itself out. */ TextCellFactory tf = DefaultResources.getStretchableFont() // .setSmoothingMultiplier(2f / (INTERNAL_ZOOM + 1f)) .width(cellWidth + 1) .height(cellHeight + 5) .initBySize(); final TextPanel<Color> tp = new TextPanel<Color>(new GDXMarkup(), tf); tp.backgroundColor = SColor.DARK_SLATE_GRAY; final List<IColoredString<Color>> text = new ArrayList<IColoredString<Color>>(); text.add(cs); /* No need to call IColoredString::wrap, TextPanel does it on its own */ text.add(helping1); text.add(helping2); text.add(helping3); final float w = width * cellWidth, aw = helping3.length() * tf.width() * 0.8f * INTERNAL_ZOOM; final float h = height * cellHeight, ah = tf.height() * 7f * INTERNAL_ZOOM; tp.init(aw, ah, text); a = tp.getScrollPane(); final float x = (w - aw) / 2f; final float y = (h - ah) / 2f; a.setPosition(x, y); stage.setScrollFocus(a); help = a; stage.addActor(a); }