mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
[Mobile] update Adventure inventory
This commit is contained in:
@@ -73,7 +73,7 @@ public class InventoryScene extends UIScene {
|
|||||||
equipButton = ui.findActor("equip");
|
equipButton = ui.findActor("equip");
|
||||||
deleteButton = ui.findActor("delete");
|
deleteButton = ui.findActor("delete");
|
||||||
itemDescription = ui.findActor("item_description");
|
itemDescription = ui.findActor("item_description");
|
||||||
leave.getLabel().setText(Forge.getLocalizer().getMessage("lblLeave"));
|
leave.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
||||||
|
|
||||||
inventoryButtons=new Array<>();
|
inventoryButtons=new Array<>();
|
||||||
equipmentSlots=new HashMap<>();
|
equipmentSlots=new HashMap<>();
|
||||||
@@ -132,7 +132,7 @@ 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);
|
||||||
confirm = new Dialog("\n Delete item", Controls.GetSkin())
|
confirm = new Dialog("\n "+Forge.getLocalizer().getMessage("lblDelete"), Controls.GetSkin())
|
||||||
{
|
{
|
||||||
protected void result(Object object)
|
protected void result(Object object)
|
||||||
{
|
{
|
||||||
@@ -142,11 +142,26 @@ public class InventoryScene extends UIScene {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
confirm.button("Yes", true);
|
confirm.button(Forge.getLocalizer().getMessage("lblYes"), true);
|
||||||
confirm.button("No", false);
|
confirm.button(Forge.getLocalizer().getMessage("lblNo"), false);
|
||||||
ui.addActor(confirm);
|
ui.addActor(confirm);
|
||||||
confirm.hide();
|
confirm.hide();
|
||||||
|
|
||||||
|
itemDescription.setWrap(true);
|
||||||
|
//makes confirm dialog hidden immediately when you open inventory first time..
|
||||||
|
confirm.getColor().a = 0;
|
||||||
|
float bw = scrollPane.getWidth() / 3;
|
||||||
|
deleteButton.setX(scrollPane.getX());
|
||||||
|
deleteButton.setWidth(bw);
|
||||||
|
equipButton.setX(scrollPane.getX()+bw);
|
||||||
|
equipButton.setWidth(bw);
|
||||||
|
leave.setX(equipButton.getX()+bw);
|
||||||
|
leave.setWidth(bw);
|
||||||
|
if (!Forge.isLandscapeMode()) {
|
||||||
|
confirm.getTitleLabel().setFontScaleX(2);
|
||||||
|
itemDescription.setFontScaleX(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.init = true;
|
this.init = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,6 +160,13 @@ public class RewardScene extends UIScene {
|
|||||||
case Shop:
|
case Shop:
|
||||||
doneButton.setText(Forge.getLocalizer().getMessage("lblLeave"));
|
doneButton.setText(Forge.getLocalizer().getMessage("lblLeave"));
|
||||||
goldLabel.setText("Gold:"+Current.player().getGold());
|
goldLabel.setText("Gold:"+Current.player().getGold());
|
||||||
|
float w = 480 - (goldLabel.getPrefWidth() + 10);
|
||||||
|
goldLabel.setPosition(w, 250);
|
||||||
|
if (!Forge.isLandscapeMode()) {
|
||||||
|
goldLabel.setFontScaleX(2);
|
||||||
|
w = 480/2 - goldLabel.getPrefWidth();
|
||||||
|
goldLabel.setPosition(w, 250);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Loot:
|
case Loot:
|
||||||
goldLabel.setText("");
|
goldLabel.setText("");
|
||||||
@@ -185,7 +192,7 @@ public class RewardScene extends UIScene {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cardHeight = Forge.isLandscapeMode() ? bestCardHeight : bestCardHeight * 0.65f;
|
cardHeight = Forge.isLandscapeMode() ? bestCardHeight * 0.90f : bestCardHeight * 0.65f;
|
||||||
cardWidth = bestCardHeight / CARD_WIDTH_TO_HEIGHT;
|
cardWidth = bestCardHeight / CARD_WIDTH_TO_HEIGHT;
|
||||||
|
|
||||||
yOff += (targetHeight - (cardHeight * numberOfRows)) / 2f;
|
yOff += (targetHeight - (cardHeight * numberOfRows)) / 2f;
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public class GameHUD extends Stage {
|
|||||||
private boolean deckPressed = false;
|
private boolean deckPressed = false;
|
||||||
private boolean menuPressed = false;
|
private boolean menuPressed = false;
|
||||||
private boolean statsPressed = false;
|
private boolean statsPressed = false;
|
||||||
|
private boolean inventoryPressed = false;
|
||||||
private UIActor ui;
|
private UIActor ui;
|
||||||
private Touchpad touchpad;
|
private Touchpad touchpad;
|
||||||
private TouchpadStyle touchpadStyle;
|
private TouchpadStyle touchpadStyle;
|
||||||
@@ -72,7 +73,7 @@ public class GameHUD extends Stage {
|
|||||||
statsActor = ui.findActor("statistic");
|
statsActor = ui.findActor("statistic");
|
||||||
statsActor.getLabel().setText(Forge.getLocalizer().getMessage("lblStatus"));
|
statsActor.getLabel().setText(Forge.getLocalizer().getMessage("lblStatus"));
|
||||||
inventoryActor = ui.findActor("inventory");
|
inventoryActor = ui.findActor("inventory");
|
||||||
//todo translate inventoryActor
|
inventoryActor.getLabel().setText(Forge.getLocalizer().getMessage("lblItem"));
|
||||||
gamehud = ui.findActor("gamehud");
|
gamehud = ui.findActor("gamehud");
|
||||||
|
|
||||||
miniMapPlayer = new Image(new Texture(Config.instance().getFile("ui/minimap_player.png")));
|
miniMapPlayer = new Image(new Texture(Config.instance().getFile("ui/minimap_player.png")));
|
||||||
@@ -160,10 +161,14 @@ public class GameHUD extends Stage {
|
|||||||
statsActor.setWidth(80);
|
statsActor.setWidth(80);
|
||||||
statsActor.setX(400);
|
statsActor.setX(400);
|
||||||
statsActor.setY(menuActor.getY() + 35);
|
statsActor.setY(menuActor.getY() + 35);
|
||||||
|
inventoryActor.setHeight(20);
|
||||||
|
inventoryActor.setWidth(80);
|
||||||
|
inventoryActor.setX(400);
|
||||||
|
inventoryActor.setY(statsActor.getY() + 35);
|
||||||
deckActor.setHeight(20);
|
deckActor.setHeight(20);
|
||||||
deckActor.setWidth(80);
|
deckActor.setWidth(80);
|
||||||
deckActor.setX(400);
|
deckActor.setX(400);
|
||||||
deckActor.setY(statsActor.getY() + 35);
|
deckActor.setY(inventoryActor.getY() + 35);
|
||||||
}
|
}
|
||||||
addActor(ui);
|
addActor(ui);
|
||||||
addActor(miniMapPlayer);
|
addActor(miniMapPlayer);
|
||||||
@@ -196,9 +201,11 @@ public class GameHUD extends Stage {
|
|||||||
checkButtonState(deckActor, pointer);
|
checkButtonState(deckActor, pointer);
|
||||||
checkButtonState(menuActor, pointer);
|
checkButtonState(menuActor, pointer);
|
||||||
checkButtonState(statsActor, pointer);
|
checkButtonState(statsActor, pointer);
|
||||||
|
checkButtonState(inventoryActor, pointer);
|
||||||
deckPressed = false;
|
deckPressed = false;
|
||||||
menuPressed = false;
|
menuPressed = false;
|
||||||
statsPressed = false;
|
statsPressed = false;
|
||||||
|
inventoryPressed = false;
|
||||||
return super.touchUp(screenX, screenY, pointer, button);
|
return super.touchUp(screenX, screenY, pointer, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,6 +259,18 @@ public class GameHUD extends Stage {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float inventoryX = inventoryActor.getX();
|
||||||
|
float inventoryY = inventoryActor.getY();
|
||||||
|
float inventoryR = inventoryActor.getRight();
|
||||||
|
float inventoryT = inventoryActor.getTop();
|
||||||
|
float inventoryOriginX = inventoryActor.getOriginX();
|
||||||
|
//inventory button bounds
|
||||||
|
if (c.x>=inventoryX&&c.x<=inventoryR&&c.y>=inventoryY&&c.y<=inventoryT) {
|
||||||
|
if (pointer < 1)
|
||||||
|
inventoryPressed = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
float menuX = menuActor.getX();
|
float menuX = menuActor.getX();
|
||||||
float menuY = menuActor.getY();
|
float menuY = menuActor.getY();
|
||||||
float menuR = menuActor.getRight();
|
float menuR = menuActor.getRight();
|
||||||
@@ -351,6 +370,7 @@ public class GameHUD extends Stage {
|
|||||||
updateVisualState(statsActor, statsPressed);
|
updateVisualState(statsActor, statsPressed);
|
||||||
updateVisualState(menuActor, menuPressed);
|
updateVisualState(menuActor, menuPressed);
|
||||||
updateVisualState(deckActor, deckPressed);
|
updateVisualState(deckActor, deckPressed);
|
||||||
|
updateVisualState(inventoryActor, inventoryPressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture miniMapTexture;
|
Texture miniMapTexture;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.Pixmap;
|
|||||||
import com.badlogic.gdx.graphics.TextureData;
|
import com.badlogic.gdx.graphics.TextureData;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Class to draw directly on a pixmap
|
Class to draw directly on a pixmap
|
||||||
@@ -24,24 +25,31 @@ public abstract class DrawOnPixmap {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawText(Pixmap drawingMap, String text, int x, int y, float width) {
|
public static void drawText(Pixmap drawingMap, String itemText, int x, int y, float width, boolean bigText) {
|
||||||
//used for big numbers on Gold/Life for reward...
|
//used for big numbers on Gold/Life for reward...
|
||||||
BitmapFont font = Controls.getBitmapFont("MiKrollFantasyBig");
|
BitmapFont font = bigText ? Controls.getBitmapFont("MiKrollFantasyBig") : Controls.getBitmapFont("default");
|
||||||
|
|
||||||
BitmapFont.BitmapFontData data = font.getData();
|
BitmapFont.BitmapFontData data = font.getData();
|
||||||
Pixmap source = new Pixmap(Gdx.files.absolute(data.getImagePath(0)));
|
Pixmap source = new Pixmap(Gdx.files.absolute(data.getImagePath(0)));
|
||||||
|
|
||||||
float totalLength =0;
|
String[] split = TextUtil.split(itemText, ' ');
|
||||||
for (char c : text.toCharArray()) {
|
for (int i = 0; i < split.length; i++) {
|
||||||
totalLength += data.getGlyph(c).width;
|
String text = split[i];
|
||||||
}
|
float totalLength =0;
|
||||||
float xOffset = (width - totalLength) / 2;
|
for (char c : text.toCharArray()) {
|
||||||
xOffset += x;
|
totalLength += data.getGlyph(c).width;
|
||||||
for (char c : text.toCharArray()) {
|
}
|
||||||
|
float xOffset = (width - totalLength) / 2;
|
||||||
drawingMap.drawPixmap(source, (int) xOffset, y,
|
float yOffset = y;
|
||||||
data.getGlyph(c).srcX, data.getGlyph(c).srcY, data.getGlyph(c).width, data.getGlyph(c).height);
|
xOffset += x;
|
||||||
xOffset += data.getGlyph(c).width + 1;
|
for (char c : text.toCharArray()) {
|
||||||
|
drawingMap.drawPixmap(source, (int) xOffset, (int) yOffset*(i+1),
|
||||||
|
data.getGlyph(c).srcX, data.getGlyph(c).srcY, data.getGlyph(c).width, data.getGlyph(c).height);
|
||||||
|
xOffset += data.getGlyph(c).width + 1;
|
||||||
|
}
|
||||||
|
if (!bigText) {
|
||||||
|
yOffset += data.getGlyph(' ').height + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
source.dispose();
|
source.dispose();
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
|||||||
|
|
||||||
DrawOnPixmap.draw(drawingMap, backSprite);
|
DrawOnPixmap.draw(drawingMap, backSprite);
|
||||||
Sprite item = reward.getItem().sprite();
|
Sprite item = reward.getItem().sprite();
|
||||||
DrawOnPixmap.draw(drawingMap, (int) ((backSprite.getWidth() / 2f) - item.getWidth() / 2f), (int) ((backSprite.getHeight() / 4f) * 1f), item);
|
DrawOnPixmap.draw(drawingMap, (int) ((backSprite.getWidth() / 2f) - item.getWidth() / 2f), (int) ((backSprite.getHeight() / 4f) * 1.7f), item);
|
||||||
|
DrawOnPixmap.drawText(drawingMap, String.valueOf(reward.getItem().name), 0, (int) ((backSprite.getHeight() / 8f) * 1f), backSprite.getWidth(), false);
|
||||||
|
|
||||||
image=new Texture(drawingMap);
|
image=new Texture(drawingMap);
|
||||||
drawingMap.dispose();
|
drawingMap.dispose();
|
||||||
@@ -106,7 +107,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
|||||||
DrawOnPixmap.draw(drawingMap, backSprite);
|
DrawOnPixmap.draw(drawingMap, backSprite);
|
||||||
Sprite gold = atlas.createSprite("Gold");
|
Sprite gold = atlas.createSprite("Gold");
|
||||||
DrawOnPixmap.draw(drawingMap, (int) ((backSprite.getWidth() / 2f) - gold.getWidth() / 2f), (int) ((backSprite.getHeight() / 4f) * 1f), gold);
|
DrawOnPixmap.draw(drawingMap, (int) ((backSprite.getWidth() / 2f) - gold.getWidth() / 2f), (int) ((backSprite.getHeight() / 4f) * 1f), gold);
|
||||||
DrawOnPixmap.drawText(drawingMap, String.valueOf(reward.getCount()), 0, (int) ((backSprite.getHeight() / 4f) * 2f), backSprite.getWidth());
|
DrawOnPixmap.drawText(drawingMap, String.valueOf(reward.getCount()), 0, (int) ((backSprite.getHeight() / 4f) * 2f), backSprite.getWidth(), true);
|
||||||
|
|
||||||
image=new Texture(drawingMap);
|
image=new Texture(drawingMap);
|
||||||
drawingMap.dispose();
|
drawingMap.dispose();
|
||||||
@@ -121,7 +122,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
|||||||
DrawOnPixmap.draw(drawingMap, backSprite);
|
DrawOnPixmap.draw(drawingMap, backSprite);
|
||||||
Sprite gold = atlas.createSprite("Life");
|
Sprite gold = atlas.createSprite("Life");
|
||||||
DrawOnPixmap.draw(drawingMap, (int) ((backSprite.getWidth() / 2f) - gold.getWidth() / 2f), (int) ((backSprite.getHeight() / 4f) * 1f), gold);
|
DrawOnPixmap.draw(drawingMap, (int) ((backSprite.getWidth() / 2f) - gold.getWidth() / 2f), (int) ((backSprite.getHeight() / 4f) * 1f), gold);
|
||||||
DrawOnPixmap.drawText(drawingMap, String.valueOf(reward.getCount()), 0, (int) ((backSprite.getHeight() / 4f) * 2f), backSprite.getWidth());
|
DrawOnPixmap.drawText(drawingMap, String.valueOf(reward.getCount()), 0, (int) ((backSprite.getHeight() / 4f) * 2f), backSprite.getWidth(), true);
|
||||||
|
|
||||||
image = new Texture(drawingMap);
|
image = new Texture(drawingMap);
|
||||||
drawingMap.dispose();
|
drawingMap.dispose();
|
||||||
|
|||||||
@@ -71,8 +71,13 @@ public class WorldSave {
|
|||||||
SaveFileData mainData=(SaveFileData)oos.readObject();
|
SaveFileData mainData=(SaveFileData)oos.readObject();
|
||||||
currentSave.player.load(mainData.readSubData("player"));
|
currentSave.player.load(mainData.readSubData("player"));
|
||||||
GamePlayerUtil.getGuiPlayer().setName(currentSave.player.getName());
|
GamePlayerUtil.getGuiPlayer().setName(currentSave.player.getName());
|
||||||
currentSave.world.load(mainData.readSubData("world"));
|
try {
|
||||||
WorldStage.getInstance().load(mainData.readSubData("worldStage"));
|
currentSave.world.load(mainData.readSubData("world"));
|
||||||
|
WorldStage.getInstance().load(mainData.readSubData("worldStage"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Generating New World");
|
||||||
|
currentSave.world.generateNew(0);
|
||||||
|
}
|
||||||
|
|
||||||
currentSave.onLoadList.emit();
|
currentSave.onLoadList.emit();
|
||||||
|
|
||||||
@@ -128,6 +133,7 @@ public class WorldSave {
|
|||||||
return currentSave;
|
return currentSave;
|
||||||
//return currentSave = ret;
|
//return currentSave = ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean autoSave() {
|
public boolean autoSave() {
|
||||||
return save("auto save",AUTO_SAVE_SLOT);
|
return save("auto save",AUTO_SAVE_SLOT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -395,11 +395,6 @@
|
|||||||
"selection": "select"
|
"selection": "select"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"com.badlogic.gdx.scenes.scene2d.ui.TextTooltip$TextTooltipStyle": {
|
|
||||||
"default": {
|
|
||||||
"label": "default"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"com.badlogic.gdx.scenes.scene2d.ui.Touchpad$TouchpadStyle": {
|
"com.badlogic.gdx.scenes.scene2d.ui.Touchpad$TouchpadStyle": {
|
||||||
"default": {
|
"default": {
|
||||||
"background": "thinwindow",
|
"background": "thinwindow",
|
||||||
|
|||||||
Reference in New Issue
Block a user