mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Support tapping card to activate its first option
This commit is contained in:
@@ -92,6 +92,19 @@ public class FList<E> extends FScrollPane {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object getItemAt(int index) {
|
||||||
|
int count = 0;
|
||||||
|
for (ListGroup group : groups) {
|
||||||
|
for (ListItem item : group.items) {
|
||||||
|
if (index == count) {
|
||||||
|
return item.value;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void setListItemRenderer(ListItemRenderer<E> renderer0) {
|
public void setListItemRenderer(ListItemRenderer<E> renderer0) {
|
||||||
renderer = renderer0;
|
renderer = renderer0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,11 +42,8 @@ public class VCardZoom extends FOverlay {
|
|||||||
});
|
});
|
||||||
optionList.setListItemRenderer(new ListItemRenderer<Object>() {
|
optionList.setListItemRenderer(new ListItemRenderer<Object>() {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public boolean tap(Object value, float x, float y, int count) {
|
public boolean tap(Object value, float x, float y, int count) {
|
||||||
if (controller.selectOption(orderedCards.get(selectedIndex), value)) {
|
selectOption(value);
|
||||||
hide();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,6 +115,13 @@ public class VCardZoom extends FOverlay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private void selectOption(Object option) {
|
||||||
|
if (option == null || controller.selectOption(orderedCards.get(selectedIndex), option)) {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setSelectedIndex(int selectedIndex0) {
|
private void setSelectedIndex(int selectedIndex0) {
|
||||||
if (selectedIndex0 < 0) {
|
if (selectedIndex0 < 0) {
|
||||||
selectedIndex0 = 0;
|
selectedIndex0 = 0;
|
||||||
@@ -133,6 +137,8 @@ public class VCardZoom extends FOverlay {
|
|||||||
slider.frontPanel.setCard(selectedCard);
|
slider.frontPanel.setCard(selectedCard);
|
||||||
slider.leftPanel.setCard(selectedIndex > 0 ? orderedCards.get(selectedIndex - 1) : null);
|
slider.leftPanel.setCard(selectedIndex > 0 ? orderedCards.get(selectedIndex - 1) : null);
|
||||||
slider.rightPanel.setCard(selectedIndex < orderedCards.size() - 1 ? orderedCards.get(selectedIndex + 1) : null);
|
slider.rightPanel.setCard(selectedIndex < orderedCards.size() - 1 ? orderedCards.get(selectedIndex + 1) : null);
|
||||||
|
slider.leftPanel.setVisible(slider.leftPanel.getCard() != null);
|
||||||
|
slider.rightPanel.setVisible(slider.rightPanel.getCard() != null);
|
||||||
|
|
||||||
optionList.clear();
|
optionList.clear();
|
||||||
List<?> options = controller.getOptions(selectedCard);
|
List<?> options = controller.getOptions(selectedCard);
|
||||||
@@ -186,12 +192,18 @@ public class VCardZoom extends FOverlay {
|
|||||||
frontPanel = add(new FCardPanel() {
|
frontPanel = add(new FCardPanel() {
|
||||||
@Override
|
@Override
|
||||||
public boolean tap(float x, float y, int count) {
|
public boolean tap(float x, float y, int count) {
|
||||||
hide();
|
selectOption(optionList.getItemAt(0));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean tap(float x, float y, int count) {
|
||||||
|
hide(); //hide if area around panels tapped
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLayout(float width, float height) {
|
protected void doLayout(float width, float height) {
|
||||||
float backPanelHeight = height * 0.8f;
|
float backPanelHeight = height * 0.8f;
|
||||||
|
|||||||
Reference in New Issue
Block a user