mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Merge pull request #3362 from kevlahnota/newmaster2
Quest location on MapViewScene
This commit is contained in:
@@ -1,80 +1,122 @@
|
|||||||
package forge.adventure.scene;
|
package forge.adventure.scene;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||||
|
import com.github.tommyettinger.textra.TextraButton;
|
||||||
|
import com.github.tommyettinger.textra.TypingLabel;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
|
import forge.adventure.data.AdventureQuestData;
|
||||||
|
import forge.adventure.pointofintrest.PointOfInterest;
|
||||||
import forge.adventure.stage.GameHUD;
|
import forge.adventure.stage.GameHUD;
|
||||||
import forge.adventure.stage.WorldStage;
|
import forge.adventure.stage.WorldStage;
|
||||||
|
import forge.adventure.util.Controls;
|
||||||
import forge.adventure.util.Current;
|
import forge.adventure.util.Current;
|
||||||
import forge.adventure.world.WorldSave;
|
import forge.adventure.world.WorldSave;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the rewards of a fight or a treasure
|
* Displays the rewards of a fight or a treasure
|
||||||
*/
|
*/
|
||||||
public class MapViewScene extends UIScene {
|
public class MapViewScene extends UIScene {
|
||||||
private static MapViewScene object;
|
private static MapViewScene object;
|
||||||
private final ScrollPane scroll;
|
private final ScrollPane scroll;
|
||||||
private final Image img;
|
private final Image img;
|
||||||
private Texture miniMapTexture;
|
private Texture miniMapTexture;
|
||||||
private final Image miniMapPlayer;
|
private final Image miniMapPlayer;
|
||||||
|
private final Group table;
|
||||||
|
private final List<TypingLabel> labels;
|
||||||
|
private int index = -1;
|
||||||
|
private float avatarX = 0, avatarY = 0;
|
||||||
|
|
||||||
public static MapViewScene instance() {
|
public static MapViewScene instance() {
|
||||||
if(object==null)
|
if (object == null)
|
||||||
object=new MapViewScene();
|
object = new MapViewScene();
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MapViewScene() {
|
private MapViewScene() {
|
||||||
super(Forge.isLandscapeMode() ? "ui/map.json" : "ui/map_portrait.json");
|
super(Forge.isLandscapeMode() ? "ui/map.json" : "ui/map_portrait.json");
|
||||||
|
|
||||||
|
|
||||||
ui.onButtonPress("done", this::done);
|
ui.onButtonPress("done", this::done);
|
||||||
|
ui.onButtonPress("quest", this::scroll);
|
||||||
scroll = ui.findActor("map");
|
scroll = ui.findActor("map");
|
||||||
Group table=new Group();
|
labels = Lists.newArrayList();
|
||||||
|
table = new Group();
|
||||||
scroll.setActor(table);
|
scroll.setActor(table);
|
||||||
img=new Image();
|
img = new Image();
|
||||||
miniMapPlayer=new Image();
|
miniMapPlayer = new Image();
|
||||||
img.setPosition(0,0);
|
img.setPosition(0, 0);
|
||||||
table.addActor(img);
|
table.addActor(img);
|
||||||
table.addActor(miniMapPlayer);
|
table.addActor(miniMapPlayer);
|
||||||
//img.setFillParent(true);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean done() {
|
public boolean done() {
|
||||||
GameHUD.getInstance().getTouchpad().setVisible(false);
|
GameHUD.getInstance().getTouchpad().setVisible(false);
|
||||||
|
for (Actor a : table.getChildren()) {
|
||||||
|
if (a instanceof TypingLabel)
|
||||||
|
a.remove();
|
||||||
|
}
|
||||||
|
labels.clear();
|
||||||
|
index = -1;
|
||||||
Forge.switchToLast();
|
Forge.switchToLast();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean scroll() {
|
||||||
|
if (!labels.isEmpty()) {
|
||||||
|
index++;
|
||||||
|
if (index >= labels.size()) {
|
||||||
|
index = -1;
|
||||||
|
scroll.scrollTo(avatarX, avatarY, miniMapPlayer.getWidth(), miniMapPlayer.getHeight(), true, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
TypingLabel label = labels.get(index);
|
||||||
|
scroll.scrollTo(label.getX(), label.getY(), miniMapPlayer.getWidth(), miniMapPlayer.getHeight(), true, true);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
if(miniMapTexture!=null)
|
if (miniMapTexture != null)
|
||||||
miniMapTexture.dispose();
|
miniMapTexture.dispose();
|
||||||
miniMapTexture=new Texture(WorldSave.getCurrentSave().getWorld().getBiomeImage());
|
miniMapTexture = new Texture(WorldSave.getCurrentSave().getWorld().getBiomeImage());
|
||||||
//img.setSize(miniMapTexture.getWidth(),miniMapTexture.getHeight());
|
img.setSize(WorldSave.getCurrentSave().getWorld().getBiomeImage().getWidth(), WorldSave.getCurrentSave().getWorld().getBiomeImage().getHeight());
|
||||||
img.setSize(WorldSave.getCurrentSave().getWorld().getBiomeImage().getWidth(),WorldSave.getCurrentSave().getWorld().getBiomeImage().getHeight());
|
img.getParent().setSize(WorldSave.getCurrentSave().getWorld().getBiomeImage().getWidth(), WorldSave.getCurrentSave().getWorld().getBiomeImage().getHeight());
|
||||||
img.getParent().setSize(WorldSave.getCurrentSave().getWorld().getBiomeImage().getWidth(),WorldSave.getCurrentSave().getWorld().getBiomeImage().getHeight());
|
|
||||||
img.setDrawable(new TextureRegionDrawable(miniMapTexture));
|
img.setDrawable(new TextureRegionDrawable(miniMapTexture));
|
||||||
miniMapPlayer.setDrawable(new TextureRegionDrawable(Current.player().avatar()));
|
miniMapPlayer.setDrawable(new TextureRegionDrawable(Current.player().avatar()));
|
||||||
|
miniMapPlayer.setSize(Current.player().avatar().getRegionWidth(), Current.player().avatar().getRegionHeight());
|
||||||
int yPos = (int) WorldStage.getInstance().getPlayerSprite().getY();
|
avatarX = getMapX(WorldStage.getInstance().getPlayerSprite().getX()) - miniMapPlayer.getWidth() / 2;
|
||||||
int xPos = (int) WorldStage.getInstance().getPlayerSprite().getX();
|
avatarY = getMapY(WorldStage.getInstance().getPlayerSprite().getY()) - miniMapPlayer.getHeight() / 2;
|
||||||
int xPosMini = (int) (((float) xPos / (float) WorldSave.getCurrentSave().getWorld().getTileSize() / (float) WorldSave.getCurrentSave().getWorld().getWidthInTiles()) * img.getWidth());
|
miniMapPlayer.setPosition(avatarX, avatarY);
|
||||||
int yPosMini = (int) (((float) yPos / (float) WorldSave.getCurrentSave().getWorld().getTileSize() / (float) WorldSave.getCurrentSave().getWorld().getHeightInTiles()) * img.getHeight());
|
|
||||||
|
|
||||||
miniMapPlayer.setSize(Current.player().avatar().getRegionWidth(),Current.player().avatar().getRegionHeight());
|
|
||||||
miniMapPlayer.setPosition( xPosMini - miniMapPlayer.getWidth()/2, yPosMini - miniMapPlayer.getHeight()/2);
|
|
||||||
miniMapPlayer.layout();
|
miniMapPlayer.layout();
|
||||||
scroll.scrollTo(xPosMini - miniMapPlayer.getWidth()/2, yPosMini - miniMapPlayer.getHeight()/2,miniMapPlayer.getWidth(),
|
scroll.scrollTo(avatarX, avatarY, miniMapPlayer.getWidth(), miniMapPlayer.getHeight(), true, true);
|
||||||
miniMapPlayer.getHeight(),true,true);
|
for (AdventureQuestData adq : Current.player().getQuests()) {
|
||||||
//img.setAlign(Align.center);
|
PointOfInterest poi = adq.getTargetPOI();
|
||||||
|
if (poi != null) {
|
||||||
|
TypingLabel label = Controls.newTypingLabel("[%?BLACKEN][+GPS]{GRADIENT=RED;WHITE;1;1}>" + adq.name + "{ENDGRADIENT}");
|
||||||
|
labels.add(label);
|
||||||
|
table.addActor(label);
|
||||||
|
label.setPosition(getMapX(poi.getPosition().x) - label.getWidth() / 2, getMapY(poi.getPosition().y) - label.getHeight() / 2);
|
||||||
|
label.skipToTheEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TextraButton questButton = ui.findActor("quest");
|
||||||
|
if (questButton != null) {
|
||||||
|
questButton.setDisabled(labels.isEmpty());
|
||||||
|
}
|
||||||
super.enter();
|
super.enter();
|
||||||
}
|
}
|
||||||
|
float getMapX(float posX) {
|
||||||
|
return (posX / (float) WorldSave.getCurrentSave().getWorld().getTileSize() / (float) WorldSave.getCurrentSave().getWorld().getWidthInTiles()) * img.getWidth();
|
||||||
|
}
|
||||||
|
float getMapY(float posY) {
|
||||||
|
return (posY / (float) WorldSave.getCurrentSave().getWorld().getTileSize() / (float) WorldSave.getCurrentSave().getWorld().getHeightInTiles()) * img.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -441,6 +441,9 @@ Flip
|
|||||||
LogBook
|
LogBook
|
||||||
xy: 240, 912
|
xy: 240, 912
|
||||||
size: 16, 16
|
size: 16, 16
|
||||||
|
GPS
|
||||||
|
xy: 464, 0
|
||||||
|
size: 16, 16
|
||||||
UnderworldCookbook
|
UnderworldCookbook
|
||||||
xy: 304, 960
|
xy: 304, 960
|
||||||
size: 16, 16
|
size: 16, 16
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 280 KiB After Width: | Height: | Size: 273 KiB |
@@ -8,16 +8,26 @@
|
|||||||
"name": "map",
|
"name": "map",
|
||||||
"width": 480,
|
"width": 480,
|
||||||
"height": 270
|
"height": 270
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextButton",
|
"type": "TextButton",
|
||||||
"name": "done",
|
"name": "done",
|
||||||
"text": "[%80]tr(lblBack)",
|
"text": "[%80]tr(lblBack)",
|
||||||
"binding": "Back",
|
"binding": "Back",
|
||||||
"width": 48,
|
"width": 60,
|
||||||
"height": 20,
|
"height": 20,
|
||||||
"x": 5,
|
"x": 5,
|
||||||
"y": 245
|
"y": 245
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "TextButton",
|
||||||
|
"name": "quest",
|
||||||
|
"text": "[%80]tr(lblQuest)",
|
||||||
|
"binding": "Use",
|
||||||
|
"width": 60,
|
||||||
|
"height": 20,
|
||||||
|
"x": 415,
|
||||||
|
"y": 245
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -8,15 +8,24 @@
|
|||||||
"name": "map",
|
"name": "map",
|
||||||
"width": 270,
|
"width": 270,
|
||||||
"height": 480
|
"height": 480
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextButton",
|
"type": "TextButton",
|
||||||
"name": "done",
|
"name": "done",
|
||||||
"text": "[%80]tr(lblBack)",
|
"text": "[%80]tr(lblBack)",
|
||||||
"width": 48,
|
"width": 60,
|
||||||
"height": 20,
|
"height": 20,
|
||||||
"x": 5,
|
"x": 5,
|
||||||
"y": 455
|
"y": 455
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "TextButton",
|
||||||
|
"name": "quest",
|
||||||
|
"text": "[%80]tr(lblQuest)",
|
||||||
|
"width": 60,
|
||||||
|
"height": 20,
|
||||||
|
"x": 205,
|
||||||
|
"y": 455
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user