Commit 2fe4baa1 authored by Lukas Marik's avatar Lukas Marik

#767 set scrollFocus in stage for actual screen when menu is hidden, and set...

#767 set scrollFocus in stage for actual screen when menu is hidden, and set scrollFocus in menu when is open, set mouse wheel scroll in CrimeScene, InTheDarkness, Encyclopedia, Statistics HallOfFame. In the Encyclopedia screen set scroll focus layout by mouse position
parent 9f557210
......@@ -199,6 +199,12 @@ public class CrimeSceneGame extends AbstractTablexiaGame<CrimeSceneGameState> {
setUpSizeAndPositionOfComponents();
}
@Override
public void setScrollableLayoutFocus() {
if(actionsStripWidget != null)
actionsStripWidget.setScrollFocus();
}
@Override
protected List<SummaryMessage> getSummaryMessageForGameResult(Game game) {
return Arrays.asList(new SummaryMessage(SummaryImage.STATS,
......
......@@ -361,6 +361,12 @@ public class InTheDarknessGame extends AbstractTablexiaGame<List<MapWidget>> imp
alignScreenContent();
}
@Override
public void setScrollableLayoutFocus() {
if(actionsStripWidget != null)
actionsStripWidget.setScrollFocus();
}
@Override
protected List<SummaryMessage> getSummaryMessageForGameResult(Game game) {
return Arrays.asList(new SummaryMessage(SummaryImage.STATS, getFormattedText("result_errors_count", game.getGameScore(SCORE_KEY_ERRORS_COUNT, "0"))));
......
......@@ -32,6 +32,7 @@ import net.engio.mbassy.listener.Handler;
import java.util.HashMap;
import java.util.Map;
import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.bus.event.SubMenuControlEvent;
......@@ -137,6 +138,7 @@ public class MainMenu extends AbstractMenu {
scrollPaneContainer.width(background.getWidth() - MENU_PADDING);
scrollPane.setScrollingDisabled(true, false);
Tablexia.getActualScreen().getStage().setScrollFocus(scrollPane);
}
private void performMenuAction(IMenuItem menuItem) {
......@@ -161,10 +163,13 @@ public class MainMenu extends AbstractMenu {
if(scrollPane == null || scrollPane.isScrollY() == !disable)
return;
if(disable)
scrollPane.setScrollingDisabled(true,true);
else
scrollPane.setScrollingDisabled(true,false);
if(disable) {
scrollPane.setScrollingDisabled(true, true);
Tablexia.getActualScreen().setScrollableLayoutFocus();
}else {
scrollPane.setScrollingDisabled(true, false);
Tablexia.getActualScreen().getStage().setScrollFocus(scrollPane);
}
scrollPane.layout();
}
......
......@@ -237,6 +237,7 @@ public class UserMenu extends AbstractMenu {
layoutContainer.setActor(container);
scrollPane.setScrollingDisabled(true,false);
Tablexia.getActualScreen().getStage().setScrollFocus(scrollPane);
}
private void showSyncDialog(final String syncUUID) {
......@@ -419,8 +420,10 @@ public class UserMenu extends AbstractMenu {
if(disable){
scrollPane.setScrollingDisabled(true,true);
Tablexia.getActualScreen().setScrollableLayoutFocus();
}else {
scrollPane.setScrollingDisabled(true,false);
Tablexia.getActualScreen().getStage().setScrollFocus(scrollPane);
}
scrollPane.layout();
......
......@@ -579,6 +579,8 @@ public abstract class AbstractTablexiaScreen<T> extends ScreenAdapter {
return ComponentScaleUtil.isUnderThreshold();
}
public void setScrollableLayoutFocus() {}
//////////////////////////// INPUT PROCESSORS
......
......@@ -110,6 +110,13 @@ public class AboutScreen extends AbstractTablexiaScreen<Void> {
screenState.put(SCREEN_STATE_SCROLL_POSITION_Y, String.valueOf(contentScrollPane.getScrollPercentY()));
}
@Override
public void setScrollableLayoutFocus() {
if(contentScrollPane != null){
getStage().setScrollFocus(contentScrollPane);
}
}
@Override
protected void screenLoaded(Map<String, String> screenState) {
TextureRegionDrawable backgroundTexture = new TextureRegionDrawable(getColorTextureRegion(DEFAULT_BACKGROUND_COLOR));
......@@ -151,6 +158,7 @@ public class AboutScreen extends AbstractTablexiaScreen<Void> {
getStage().addActor(backgroundTable);
getStage().addActor(contentScrollPane);
getStage().addActor(contentStack);
getStage().setScrollFocus(contentScrollPane);
contentStack.setDebug(TablexiaSettings.getInstance().isShowBoundingBoxes(), true);
}
......
......@@ -22,6 +22,7 @@ import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
......@@ -101,6 +102,7 @@ public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
private Music playedMusic;
private PlaybackStateButton musicButton;
private ResizeFontListener resizeFontListener;
private float rightPanePosition;
private static EncyclopediaFont actualRegularFont = EncyclopediaFont.DEFAULT_REGULAR;
private static EncyclopediaFont actualBoldFont = EncyclopediaFont.DEFAULT_BOLD;
private static EncyclopediaFont actualHeaderFont = EncyclopediaFont.DEFAULT_HEADER;
......@@ -119,6 +121,13 @@ public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
return new ExtendViewport(TablexiaSettings.getWorldSize(), TablexiaSettings.getMinWorldHeight());
}
@Override
public void setScrollableLayoutFocus() {
if(menuScrollPane != null){
getStage().setScrollFocus(contentScrollPane);
}
}
@Override
protected void screenPaused(Map<String, String> screenState) {
if (menuScrollPane.getScrollPercentY() != Float.NaN) {
......@@ -168,6 +177,9 @@ public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
contentScrollPane.updateVisualScroll();
}
prepareMouseListener();
getStage().setScrollFocus(contentScrollPane);
contentStack.pack();
}
......@@ -224,7 +236,7 @@ public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
menuScrollPane.setSize(rightPanelWidth, getViewportHeight() * MENU_RELATIVE_HEIGHT);
rightPanePosition = getViewportWidth() - rightPanelWidth;
buttonsPanel = new ResizableWidgetGroup();
buttonsPanel.setSize(rightPanelWidth, getViewportHeight() * (1 - MENU_RELATIVE_HEIGHT));
......@@ -232,7 +244,7 @@ public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
rightPanelStack = new Table();
rightPanel = new Table();
rightPanel.setPosition(getViewportWidth() - rightPanelWidth, getViewportHeight());
rightPanel.setPosition(rightPanePosition, getViewportHeight());
rightPanel.setSize(rightPanelWidth, getViewportHeight());
rightPanel.add(menuScrollPane);
rightPanel.row();
......@@ -247,6 +259,28 @@ public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
}
private void prepareMouseListener() {
if (TablexiaSettings.getInstance().getPlatform() == TablexiaSettings.Platform.DESKTOP) {
container.addListener(new InputListener() {
@Override
public boolean mouseMoved(InputEvent event, float x, float y) {
if (x > rightPanePosition && getStage().getScrollFocus() != menuScrollPane) {
getStage().setScrollFocus(menuScrollPane);
return true;
} else if (x < rightPanePosition && getStage().getScrollFocus() != contentScrollPane) {
getStage().setScrollFocus(contentScrollPane);
return true;
}
return false;
}
});
}
}
private void prepareButtons() {
TablexiaButton btnFontPlus = new StandardTablexiaButton(FONT_PLUS_TEXT, StandardTablexiaButton.TablexiaButtonType.BLUE)
.setButtonBounds(BUTTONS_MARGIN_LEFT, RIGHT_BUTTONS_PAD_BOTTOM, FONT_BUTTON_WIDTH, FONT_BUTTON_WIDTH)
......
......@@ -177,6 +177,13 @@ public class HallOfFameScreen extends AbstractTablexiaScreen<Map<ITrophyDefiniti
screenState.put(SCREEN_STATE_SCROLL_POSITION_X, String.valueOf(scrollPane.getScrollPercentX()));
}
@Override
public void setScrollableLayoutFocus() {
if(scrollPane != null){
getStage().setScrollFocus(scrollPane);
}
}
// GFX
@Override
protected void prepareScreenAtlases(List<String> atlasesNames) {
......@@ -213,6 +220,8 @@ public class HallOfFameScreen extends AbstractTablexiaScreen<Map<ITrophyDefiniti
}
handleMouseRankUpDialog();
getStage().setScrollFocus(scrollPane);
}
@Override
......
......@@ -210,6 +210,13 @@ public class StatisticsScreen extends AbstractTablexiaScreen<Void> {
screenState.put(SCREEN_STATE_SWITCH_KEY, String.valueOf(graphStyle == GraphStyle.DAILY ? 0 : 2));
}
@Override
public void setScrollableLayoutFocus() {
if(scrollPane != null){
getStage().setScrollFocus(scrollPane);
}
}
@Override
protected void screenLoaded(Map<String, String> screenState) {
getStage().setDebugAll(TablexiaSettings.getInstance().isShowBoundingBoxes());
......@@ -359,6 +366,7 @@ public class StatisticsScreen extends AbstractTablexiaScreen<Void> {
}
getStage().addActor(content);
getStage().setScrollFocus(scrollPane);
screenResized(0, 0);
......
......@@ -351,7 +351,13 @@ public class ActionsStripWidget extends Group implements ActionListener {
}
});
tablexiaGame.getStage().setScrollFocus(scrollPane);
setScrollFocus();
}
public void setScrollFocus(){
if(scrollPane != null) {
tablexiaGame.getStage().setScrollFocus(scrollPane);
}
}
private void moveScrollOffset(float offset, Runnable finishHandler) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment