diff --git a/forge-m-base/src/forge/assets/FSkinColor.java b/forge-m-base/src/forge/assets/FSkinColor.java index d7a6df47551..4cd28006a3c 100644 --- a/forge-m-base/src/forge/assets/FSkinColor.java +++ b/forge-m-base/src/forge/assets/FSkinColor.java @@ -145,12 +145,12 @@ public class FSkinColor { if (brightnessDelta != NO_BRIGHTNESS_DELTA) { if (brightnessDelta < 0) { for (int i = 0; i > brightnessDelta; i--) { - color = FSkinColor.stepColor(color, 10); + color = FSkinColor.stepColor(color, -20); } } else { for (int i = 0; i < brightnessDelta; i++) { - color = FSkinColor.stepColor(color, -10); + color = FSkinColor.stepColor(color, 20); } } } diff --git a/forge-m-base/src/forge/screens/match/views/VLog.java b/forge-m-base/src/forge/screens/match/views/VLog.java index ca12f98b689..59a046a0a97 100644 --- a/forge-m-base/src/forge/screens/match/views/VLog.java +++ b/forge-m-base/src/forge/screens/match/views/VLog.java @@ -1,13 +1,32 @@ package forge.screens.match.views; +import java.util.List; + +import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; + +import forge.Forge.Graphics; +import forge.assets.FSkinColor; +import forge.assets.FSkinFont; +import forge.assets.FSkinColor.Colors; import forge.game.GameLog; +import forge.game.GameLogEntry; +import forge.game.GameLogEntryType; import forge.menu.FDropDown; +import forge.model.FModel; +import forge.toolbox.FDisplayObject; +import forge.utils.ForgePreferences.FPref; public class VLog extends FDropDown { - private final GameLog model; - - public VLog(GameLog model0) { - model = model0; + private static final float PADDING = 5; + private static final FSkinFont FONT = FSkinFont.get(11); + private static final FSkinColor ALT_ROW_COLOR = FSkinColor.get(Colors.CLR_ZEBRA); + private static final FSkinColor ROW_COLOR = ALT_ROW_COLOR.darker(); + private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT); + + private final GameLog log; + + public VLog(GameLog log0) { + log = log0; } @Override @@ -15,9 +34,72 @@ public class VLog extends FDropDown { return false; } + @Override + protected void drawBackground(Graphics g) { + float w = getWidth(); + float h = getHeight(); + g.fillRect(ROW_COLOR, 0, 0, w, h); //can fill background with main row color since drop down will never be taller than number of rows + } + @Override protected ScrollBounds updateAndGetPaneSize(float maxWidth, float maxVisibleHeight) { - - return new ScrollBounds(maxWidth, maxVisibleHeight); + clear(); + + GameLogEntryType logVerbosityFilter = GameLogEntryType.valueOf(FModel.getPreferences().getPref(FPref.DEV_LOG_ENTRY_TYPE)); + List logEntrys = log.getLogEntries(logVerbosityFilter); + + LogEntryDisplay logEntryDisplay; + float width = maxWidth - getMenuTab().getScreenPosition().x; //stretch from tab to edge of screen + + float y = 1; + float height; + if (logEntrys.isEmpty()) { + logEntryDisplay = add(new LogEntryDisplay("[Empty]", false)); + height = logEntryDisplay.getMinHeight(width); + logEntryDisplay.setBounds(0, y, width, height); + y += height; + } + else { + boolean isAltRow = false; + for (int i = logEntrys.size() - 1; i >= 0; i--) { //show latest entry on bottom + logEntryDisplay = add(new LogEntryDisplay(logEntrys.get(i).message, isAltRow)); + height = logEntryDisplay.getMinHeight(width); + logEntryDisplay.setBounds(0, y, width, height); + isAltRow = !isAltRow; + y += height; + } + } + + return new ScrollBounds(width, y + 1); + } + + private class LogEntryDisplay extends FDisplayObject { + private final String text; + private final boolean isAltRow; + + private LogEntryDisplay(String text0, boolean isAltRow0) { + text = text0; + isAltRow = isAltRow0; + } + + private float getMinHeight(float width) { + width -= 2 * PADDING; //account for left and right insets + float height = FONT.getFont().getWrappedBounds(text, width).height; + height += 2 * PADDING; + return Math.round(height); + } + + @Override + public void draw(Graphics g) { + float w = getWidth(); + float h = getHeight(); + + if (isAltRow) { + g.fillRect(ALT_ROW_COLOR, 0, 0, w, h); + } + + //use full height without padding so text not scaled down + g.drawText(text, FONT, FORE_COLOR, PADDING, PADDING, w - 2 * PADDING, h, true, HAlignment.LEFT, false); + } } }