mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-12 16:58:57 +00:00
update scrollable tables
- can use mouse wheel if availble to scroll
This commit is contained in:
@@ -6,6 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
import com.badlogic.gdx.utils.IntMap;
|
import com.badlogic.gdx.utils.IntMap;
|
||||||
@@ -29,21 +30,25 @@ public class DeckSelectScene extends UIScene {
|
|||||||
private static DeckSelectScene object;
|
private static DeckSelectScene object;
|
||||||
|
|
||||||
public static DeckSelectScene instance() {
|
public static DeckSelectScene instance() {
|
||||||
if(object==null)
|
if (object == null)
|
||||||
object=new DeckSelectScene();
|
object = new DeckSelectScene();
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeckSelectScene() {
|
public DeckSelectScene() {
|
||||||
super(Forge.isLandscapeMode() ? "ui/deck_selector.json" : "ui/deck_selector_portrait.json");
|
super(Forge.isLandscapeMode() ? "ui/deck_selector.json" : "ui/deck_selector_portrait.json");
|
||||||
|
|
||||||
|
Window window = ui.findActor("deckSlots");
|
||||||
|
Table root = new Table();
|
||||||
layout = new Table();
|
layout = new Table();
|
||||||
stage.addActor(layout);
|
scrollPane = new ScrollPane(layout);
|
||||||
|
|
||||||
header = Controls.newTextraLabel(Forge.getLocalizer().getMessage("lblSelectYourDeck"));
|
header = Controls.newTextraLabel(Forge.getLocalizer().getMessage("lblSelectYourDeck"));
|
||||||
layout.add(header).colspan(2).align(Align.center).pad(2, 5, 2, 5);
|
root.row();
|
||||||
layout.row();
|
root.add(header).colspan(2);
|
||||||
|
root.row();
|
||||||
|
root.add(scrollPane).expand().width(window.getWidth() - 20);
|
||||||
for (int i = 0; i < AdventurePlayer.NUMBER_OF_DECKS; i++)
|
for (int i = 0; i < AdventurePlayer.NUMBER_OF_DECKS; i++)
|
||||||
addDeckSlot(Forge.getLocalizer().getMessage("lblDeck")+": " + (i + 1), i);
|
addDeckSlot(Forge.getLocalizer().getMessage("lblDeck") + ": " + (i + 1), i);
|
||||||
|
|
||||||
textInput = Controls.newTextField("");
|
textInput = Controls.newTextField("");
|
||||||
back = ui.findActor("return");
|
back = ui.findActor("return");
|
||||||
@@ -56,17 +61,15 @@ public class DeckSelectScene extends UIScene {
|
|||||||
showRenameDialog();
|
showRenameDialog();
|
||||||
});
|
});
|
||||||
defColor = ui.findActor("return").getColor();
|
defColor = ui.findActor("return").getColor();
|
||||||
|
window.add(root);
|
||||||
scrollPane = ui.findActor("deckSlots");
|
|
||||||
scrollPane.setActor(layout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showRenameDialog() {
|
private void showRenameDialog() {
|
||||||
|
|
||||||
Dialog dialog = prepareDialog(Forge.getLocalizer().getMessage("lblRenameDeck"),ButtonOk|ButtonAbort,()->DeckSelectScene.this.rename());
|
Dialog dialog = prepareDialog(Forge.getLocalizer().getMessage("lblRenameDeck"), ButtonOk | ButtonAbort, () -> DeckSelectScene.this.rename());
|
||||||
dialog.getContentTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblNameYourSaveFile"))).colspan(2);
|
dialog.getContentTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblNameYourSaveFile"))).colspan(2);
|
||||||
dialog.getContentTable().row();
|
dialog.getContentTable().row();
|
||||||
dialog.getContentTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblName")+": ")).align(Align.left);
|
dialog.getContentTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblName") + ": ")).align(Align.left);
|
||||||
dialog.getContentTable().add(textInput).fillX().expandX();
|
dialog.getContentTable().add(textInput).fillX().expandX();
|
||||||
dialog.getContentTable().row();
|
dialog.getContentTable().row();
|
||||||
showDialog(dialog);
|
showDialog(dialog);
|
||||||
@@ -86,8 +89,8 @@ public class DeckSelectScene extends UIScene {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
layout.add(Controls.newLabel(name)).expandX().pad(2);
|
layout.add(Controls.newLabel(name)).pad(2);
|
||||||
layout.add(button).expandX().pad(2);
|
layout.add(button).fill(true, false).expand(true, false).align(Align.left).expandX().pad(2);
|
||||||
buttons.put(i, button);
|
buttons.put(i, button);
|
||||||
addToSelectable(new Selectable(button));
|
addToSelectable(new Selectable(button));
|
||||||
layout.row();
|
layout.row();
|
||||||
@@ -111,7 +114,6 @@ public class DeckSelectScene extends UIScene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
for (int i = 0; i < AdventurePlayer.NUMBER_OF_DECKS; i++) {
|
for (int i = 0; i < AdventurePlayer.NUMBER_OF_DECKS; i++) {
|
||||||
@@ -122,11 +124,11 @@ public class DeckSelectScene extends UIScene {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
select(Current.player().getSelectedDeckIndex());
|
select(Current.player().getSelectedDeckIndex());
|
||||||
|
performTouch(scrollPane); //can use mouse wheel if available to scroll after selection
|
||||||
super.enter();
|
super.enter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void rename() {
|
private void rename() {
|
||||||
String text = textInput.getText();
|
String text = textInput.getText();
|
||||||
Current.player().renameDeck(text);
|
Current.player().renameDeck(text);
|
||||||
|
|||||||
@@ -48,9 +48,10 @@ public class InventoryScene extends UIScene {
|
|||||||
useButton.setDisabled(true);
|
useButton.setDisabled(true);
|
||||||
deleteButton = ui.findActor("delete");
|
deleteButton = ui.findActor("delete");
|
||||||
itemDescription = ui.findActor("item_description");
|
itemDescription = ui.findActor("item_description");
|
||||||
ScrollPane pane = new ScrollPane(itemDescription);
|
|
||||||
pane.setBounds(itemDescription.getX(), itemDescription.getY(), itemDescription.getWidth() - 5, itemDescription.getHeight() - 5);
|
|
||||||
itemDescription.setAlignment(Align.topLeft);
|
itemDescription.setAlignment(Align.topLeft);
|
||||||
|
itemDescription.setWrap(true);
|
||||||
|
ScrollPane pane = new ScrollPane(itemDescription);
|
||||||
|
pane.setBounds(itemDescription.getX(), itemDescription.getY(), itemDescription.getWidth() - 5, itemDescription.getHeight() - 8);
|
||||||
ui.addActor(pane);
|
ui.addActor(pane);
|
||||||
|
|
||||||
Array<Actor> children = ui.getChildren();
|
Array<Actor> children = ui.getChildren();
|
||||||
@@ -98,7 +99,6 @@ public class InventoryScene extends UIScene {
|
|||||||
columns -= 1;
|
columns -= 1;
|
||||||
if (columns <= 0) columns = 1;
|
if (columns <= 0) columns = 1;
|
||||||
scrollPane.setActor(inventory);
|
scrollPane.setActor(inventory);
|
||||||
itemDescription.setWrap(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showConfirm() {
|
private void showConfirm() {
|
||||||
@@ -210,9 +210,8 @@ public class InventoryScene extends UIScene {
|
|||||||
button.setChecked(false);
|
button.setChecked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
itemDescription.setText(data.name + "\n" + data.getDescription());
|
itemDescription.setText(data.name + "\n[%98]" + data.getDescription());
|
||||||
itemDescription.setWrap(true);
|
performTouch(scrollPaneOfActor(itemDescription)); //can use mouse wheel if available to scroll after selection
|
||||||
itemDescription.layout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateInventory() {
|
private void updateInventory() {
|
||||||
|
|||||||
@@ -154,5 +154,6 @@ public class PlayerStatisticScene extends UIScene {
|
|||||||
scrollContainer.add(entry.getValue().getLeft().toString() + "/" + entry.getValue().getRight().toString()).pad(3, 5, 3, 10).center();
|
scrollContainer.add(entry.getValue().getLeft().toString() + "/" + entry.getValue().getRight().toString()).pad(3, 5, 3, 10).center();
|
||||||
scrollContainer.row();
|
scrollContainer.row();
|
||||||
}
|
}
|
||||||
|
performTouch(scrollPaneOfActor(scrollContainer)); //can use mouse wheel if available to scroll
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -344,6 +344,7 @@ public class SaveLoadScene extends UIScene {
|
|||||||
difficulty.setVisible(false);
|
difficulty.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
performTouch(scrollPane); //can use mouse wheel if available to scroll
|
||||||
super.enter();
|
super.enter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"height": 270
|
"height": 270
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Scroll",
|
"type": "Window",
|
||||||
"name": "deckSlots",
|
"name": "deckSlots",
|
||||||
"x": 15,
|
"x": 15,
|
||||||
"y": 18,
|
"y": 18,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"height": 480
|
"height": 480
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Scroll",
|
"type": "Window",
|
||||||
"name": "deckSlots",
|
"name": "deckSlots",
|
||||||
"x": 4,
|
"x": 4,
|
||||||
"y": 4,
|
"y": 4,
|
||||||
|
|||||||
Reference in New Issue
Block a user