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