-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WaypointDialog -- show all waypoints in current sector, with ability …
…to toggle visual navigation to them * Calculate skill level progress % correctly * InputDialog -- will be used to rename map waypoints & for other things that may require user input
- Loading branch information
1 parent
8f9ef16
commit b9d1564
Showing
21 changed files
with
201 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package hitonoriol.madsand.gui.dialogs; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import com.badlogic.gdx.scenes.scene2d.ui.Table; | ||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; | ||
import com.badlogic.gdx.scenes.scene2d.ui.TextField; | ||
|
||
import hitonoriol.madsand.Gui; | ||
import hitonoriol.madsand.dialog.GameDialog; | ||
|
||
public class InputDialog extends GameDialog { | ||
private static final float PAD = Gui.BTN_HEIGHT * 0.65f; | ||
private static final String DEF_TITLE = "Input"; | ||
private TextField textField = new TextField("", Gui.skin); | ||
|
||
public InputDialog(String title, String prompt, Consumer<String> inputConsumer) { | ||
makeBordered(); | ||
centerTitle(); | ||
setTitle(title); | ||
if (prompt != null) | ||
add(prompt).height(Gui.FONT_S).padBottom(PAD).row(); | ||
add(textField).size(250, Gui.BTN_HEIGHT).padBottom(PAD).row(); | ||
TextButton okBtn = new TextButton("Confirm", Gui.skin); | ||
Gui.setAction(okBtn, () -> { | ||
inputConsumer.accept(textField.getText()); | ||
remove(); | ||
}); | ||
Table btnTable = getButtonTable(); | ||
btnTable.add(okBtn).padRight(5); | ||
btnTable.add(createCloseButton()); | ||
add(btnTable); | ||
} | ||
|
||
public InputDialog(String title, Consumer<String> inputConsumer) { | ||
this(title, null, inputConsumer); | ||
} | ||
|
||
public InputDialog(Consumer<String> inputConsumer) { | ||
this(DEF_TITLE, inputConsumer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
core/src/hitonoriol/madsand/gui/dialogs/WaypointDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package hitonoriol.madsand.gui.dialogs; | ||
|
||
import static hitonoriol.madsand.Gui.*; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import com.badlogic.gdx.scenes.scene2d.ui.Table; | ||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; | ||
import com.badlogic.gdx.utils.Align; | ||
|
||
import hitonoriol.madsand.Gui; | ||
import hitonoriol.madsand.MadSand; | ||
import hitonoriol.madsand.dialog.GameDialog; | ||
import hitonoriol.madsand.gui.widgets.AutoFocusScrollPane; | ||
import hitonoriol.madsand.map.object.Waypoint; | ||
|
||
public class WaypointDialog extends GameDialog { | ||
private Table container = new Table(Gui.skin); | ||
public WaypointDialog() { | ||
centerTitle(); | ||
setTitle("Waypoints in this sector"); | ||
makeBordered(); | ||
container.align(Align.topLeft); | ||
add(new AutoFocusScrollPane(container)).size(ENTRY_WIDTH * 3.1f, 350).row(); | ||
List<Waypoint> waypoints = MadSand.world().getCurLoc() | ||
.getObjects().stream() | ||
.map(object -> object.as(Waypoint.class).orElse(null)) | ||
.filter(waypoint -> waypoint != null) | ||
.collect(Collectors.toList()); | ||
if (waypoints.isEmpty()) | ||
container.add("There are no GPS waypoints in this sector!"); | ||
else { | ||
container.add(createWaypointEntry()).padBottom(ENTRY_PAD * 2).row(); | ||
waypoints.forEach(waypoint -> container.add(createWaypointEntry(waypoint)).align(Align.left).row()); | ||
} | ||
skipLine(); | ||
addCloseButton(); | ||
} | ||
|
||
private final static float ENTRY_WIDTH = 225, ENTRY_PAD = 10; | ||
|
||
private Table createWaypointEntry(Waypoint waypoint) { | ||
Table entry = new Table(Gui.skin); | ||
entry.defaults().width(ENTRY_WIDTH).height(FONT_S).padRight(ENTRY_PAD); | ||
/* Create table header */ | ||
if (waypoint == null) { | ||
setFontSize(entry.add("Name").getActor(), FONT_M); | ||
setFontSize(entry.add("Position").getActor(), FONT_M); | ||
setFontSize(entry.add("Toggle navigation").getActor(), FONT_M); | ||
return entry; | ||
} | ||
entry.add(waypoint.name); | ||
entry.add(waypoint.getPosition().toString()); | ||
TextButton toggleBtn = updateButton(new TextButton("", Gui.skin), waypoint); | ||
entry.add(toggleBtn).size(ENTRY_WIDTH, BTN_HEIGHT); | ||
Gui.setAction(toggleBtn, () -> { | ||
waypoint.toggleArrow(); | ||
updateButton(toggleBtn, waypoint); | ||
toFront(); | ||
}); | ||
return entry; | ||
} | ||
|
||
private Table createWaypointEntry() { | ||
return createWaypointEntry(null); | ||
} | ||
|
||
private TextButton updateButton(TextButton button, Waypoint waypoint) { | ||
button.setText(waypoint.hasArrow() ? "Deactivate" : "Activate"); | ||
return button; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.