mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-12 16:58:57 +00:00
Merge pull request #2678 from kevlahnota/newmaster2
fix dialog voiceFile not playing on Android
This commit is contained in:
@@ -281,41 +281,23 @@ public class MapStage extends GameStage {
|
|||||||
FImageComplex cardArt = CardRenderer.getCardArt(dp.getHighestCMCCard());
|
FImageComplex cardArt = CardRenderer.getCardArt(dp.getHighestCMCCard());
|
||||||
if (cardArt != null) {
|
if (cardArt != null) {
|
||||||
Image art = new Image(cardArt.getTextureRegion());
|
Image art = new Image(cardArt.getTextureRegion());
|
||||||
art.setWidth(57);
|
art.setWidth(58);
|
||||||
art.setHeight(41);
|
art.setHeight(46);
|
||||||
art.setPosition(23, 30);
|
art.setPosition(25, 43);
|
||||||
Image image = new Image(FSkinImage.ADV_DECKBOX.getTextureRegion());
|
Image image = new Image(FSkinImage.ADV_DECKBOX.getTextureRegion());
|
||||||
image.setWidth(60);
|
image.setWidth(60);
|
||||||
image.setHeight(50);
|
image.setHeight(80);
|
||||||
image.setPosition(22, 22);
|
image.setPosition(24, 10);
|
||||||
ColorSet colorSet = DeckProxy.getColorIdentity(deck);
|
ColorSet colorSet = DeckProxy.getColorIdentity(deck);
|
||||||
TypingLabel deckColors = Controls.newTypingLabel(Controls.colorIdToTypingString(colorSet, false).toUpperCase());
|
TypingLabel deckColors = Controls.newTypingLabel(Controls.colorIdToTypingString(colorSet, true).toUpperCase());
|
||||||
deckColors.skipToTheEnd();
|
deckColors.skipToTheEnd();
|
||||||
deckColors.setAlignment(Align.left);
|
deckColors.setAlignment(Align.center);
|
||||||
float padding;
|
deckColors.setPosition(14, 44);
|
||||||
switch (colorSet.countColors()) {
|
|
||||||
case 1:
|
|
||||||
padding = 24f;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
padding = 18f;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
padding = 12f;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
padding = 6f;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
padding = 0f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
deckColors.setPosition(22 + padding, 15);
|
|
||||||
TextraLabel deckname = Controls.newTextraLabel(deck.getName());
|
TextraLabel deckname = Controls.newTextraLabel(deck.getName());
|
||||||
deckname.setAlignment(Align.bottom);
|
deckname.setAlignment(Align.center);
|
||||||
deckname.setWrap(true);
|
deckname.setWrap(true);
|
||||||
deckname.setWidth(100);
|
deckname.setWidth(80);
|
||||||
deckname.setPosition(0, 75);
|
deckname.setPosition(14, 28);
|
||||||
Group group = new Group();
|
Group group = new Group();
|
||||||
group.addActor(art);
|
group.addActor(art);
|
||||||
group.addActor(image);
|
group.addActor(image);
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package forge.adventure.util;
|
package forge.adventure.util;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.audio.Music;
|
||||||
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||||
@@ -16,8 +19,9 @@ import forge.adventure.stage.MapStage;
|
|||||||
import forge.card.ColorSet;
|
import forge.card.ColorSet;
|
||||||
import forge.localinstance.properties.ForgePreferences;
|
import forge.localinstance.properties.ForgePreferences;
|
||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
import forge.sound.AudioClip;
|
import forge.sound.SoundSystem;
|
||||||
import forge.util.Localizer;
|
import forge.util.Localizer;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MapDialog
|
* MapDialog
|
||||||
@@ -45,8 +49,7 @@ public class MapDialog {
|
|||||||
public MapDialog(String S, MapStage stage, int parentID) {
|
public MapDialog(String S, MapStage stage, int parentID) {
|
||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
this.parentID = parentID;
|
this.parentID = parentID;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
|
|
||||||
if (S.isEmpty()) {
|
if (S.isEmpty()) {
|
||||||
System.err.print("Dialog error. Dialog property is empty.\n");
|
System.err.print("Dialog error. Dialog property is empty.\n");
|
||||||
@@ -54,31 +57,80 @@ public class MapDialog {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.data = JSONStringLoader.parse(Array.class, DialogData.class, S, defaultJSON);
|
this.data = JSONStringLoader.parse(Array.class, DialogData.class, S, defaultJSON);
|
||||||
}
|
} catch (Exception exception) {
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static AudioClip audio=null;
|
|
||||||
|
Pair<FileHandle, Music> audio = null;
|
||||||
|
float fade = 1f;
|
||||||
|
|
||||||
|
void unload() {
|
||||||
|
if (audio != null) {
|
||||||
|
audio.getRight().setOnCompletionListener(null);
|
||||||
|
audio.getRight().stop();
|
||||||
|
Forge.getAssets().manager().unload(audio.getLeft().path());
|
||||||
|
audio = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void disposeAudio() {
|
||||||
|
disposeAudio(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void disposeAudio(boolean fadeout) {
|
||||||
|
if (fadeout) {
|
||||||
|
final float[] v = {1f};
|
||||||
|
for (int i = 10; i > 1; i--) {
|
||||||
|
float delay = i * 0.1f;
|
||||||
|
float j = i;
|
||||||
|
Timer.schedule(new Timer.Task() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
v[0] -= 0.1f;
|
||||||
|
if (v[0] < 0.1f)
|
||||||
|
v[0] = 0.1f;
|
||||||
|
if (audio != null && j == 2) {
|
||||||
|
unload();
|
||||||
|
} else if (audio != null && j == 10) {
|
||||||
|
audio.getRight().setVolume(v[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, delay);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void loadDialog(DialogData dialog) { //Displays a dialog with dialogue and possible choices.
|
private void loadDialog(DialogData dialog) { //Displays a dialog with dialogue and possible choices.
|
||||||
setEffects(dialog.action);
|
setEffects(dialog.action);
|
||||||
Dialog D = stage.getDialog();
|
Dialog D = stage.getDialog();
|
||||||
Localizer L = Forge.getLocalizer();
|
Localizer L = Forge.getLocalizer();
|
||||||
D.getContentTable().clear(); D.getButtonTable().clear(); //Clear tables to start fresh.
|
D.getContentTable().clear();
|
||||||
|
D.getButtonTable().clear(); //Clear tables to start fresh.
|
||||||
D.clearListeners();
|
D.clearListeners();
|
||||||
String text; //Check for localized string (locname), otherwise print text.
|
String text; //Check for localized string (locname), otherwise print text.
|
||||||
if (dialog.loctext != null && !dialog.loctext.isEmpty()) text = L.getMessage(dialog.loctext);
|
if (dialog.loctext != null && !dialog.loctext.isEmpty()) text = L.getMessage(dialog.loctext);
|
||||||
else text = dialog.text;
|
else text = dialog.text;
|
||||||
if(audio!=null)
|
disposeAudio();
|
||||||
audio.stop();
|
if (dialog.voiceFile != null) {
|
||||||
if(dialog.voiceFile!=null)
|
FileHandle file = Gdx.files.absolute(Config.instance().getFilePath(dialog.voiceFile));
|
||||||
{
|
if (file.exists()) {
|
||||||
audio = AudioClip.createClip(Config.instance().getFilePath(dialog.voiceFile));
|
audio = Pair.of(file, Forge.getAssets().getMusic(file));
|
||||||
if(audio!=null)
|
}
|
||||||
audio.play(FModel.getPreferences().getPrefInt(ForgePreferences.FPref.UI_VOL_SOUNDS)/100f);
|
if (audio != null) {
|
||||||
|
int vol = FModel.getPreferences().getPrefInt(ForgePreferences.FPref.UI_VOL_MUSIC);
|
||||||
|
if (vol > 0) {
|
||||||
|
fadeOut();
|
||||||
|
audio.getRight().play();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fadeIn();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fadeIn();
|
||||||
}
|
}
|
||||||
TypingLabel A = Controls.newTypingLabel(text);
|
TypingLabel A = Controls.newTypingLabel(text);
|
||||||
A.setWrap(true);
|
A.setWrap(true);
|
||||||
@@ -127,12 +179,44 @@ public class MapDialog {
|
|||||||
stage.hideDialog();
|
stage.hideDialog();
|
||||||
else
|
else
|
||||||
stage.showDialog();
|
stage.showDialog();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
stage.hideDialog();
|
stage.hideDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fadeIn() {
|
||||||
|
disposeAudio(true);
|
||||||
|
if (fade >= 1f)
|
||||||
|
return;
|
||||||
|
for (int i = 10; i > 1; i--) {
|
||||||
|
float delay = i * 0.1f;
|
||||||
|
Timer.schedule(new Timer.Task() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
fade += 0.1f;
|
||||||
|
if (fade > 1f)
|
||||||
|
fade = 1f;
|
||||||
|
SoundSystem.instance.fadeModifier(fade);
|
||||||
|
}
|
||||||
|
}, delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void fadeOut() {
|
||||||
|
for (int i = 10; i > 1; i--) {
|
||||||
|
float delay = i * 0.1f;
|
||||||
|
Timer.schedule(new Timer.Task() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
fade -= 0.1f;
|
||||||
|
if (fade < 0.1f)
|
||||||
|
fade = 0.1f;
|
||||||
|
SoundSystem.instance.fadeModifier(fade);
|
||||||
|
}
|
||||||
|
}, delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void activate() { //Method for actors to show their dialogues.
|
public void activate() { //Method for actors to show their dialogues.
|
||||||
for (DialogData dialog : data) {
|
for (DialogData dialog : data) {
|
||||||
if (isConditionOk(dialog.condition)) {
|
if (isConditionOk(dialog.condition)) {
|
||||||
@@ -211,8 +295,7 @@ public class MapDialog {
|
|||||||
} else if (condition.not) return false;
|
} else if (condition.not) return false;
|
||||||
}
|
}
|
||||||
if (condition.colorIdentity != null && !condition.colorIdentity.isEmpty()) { //Check for player's color ID.
|
if (condition.colorIdentity != null && !condition.colorIdentity.isEmpty()) { //Check for player's color ID.
|
||||||
if(player.getColorIdentity().hasAllColors(ColorSet.fromNames(condition.colorIdentity.toCharArray()).getColor()))
|
if (player.getColorIdentity().hasAllColors(ColorSet.fromNames(condition.colorIdentity.toCharArray()).getColor())) {
|
||||||
{
|
|
||||||
if (!condition.not) return false;
|
if (!condition.not) return false;
|
||||||
} else if (condition.not) return false;
|
} else if (condition.not) return false;
|
||||||
}
|
}
|
||||||
@@ -242,8 +325,11 @@ public class MapDialog {
|
|||||||
int val = condition.getQuestFlag.val;
|
int val = condition.getQuestFlag.val;
|
||||||
int QF = player.getQuestFlag(key);
|
int QF = player.getQuestFlag(key);
|
||||||
if (!player.checkQuestFlag(key)) return false; //If the quest is not ongoing, stop.
|
if (!player.checkQuestFlag(key)) return false; //If the quest is not ongoing, stop.
|
||||||
if(!checkFlagCondition(QF, cond, val)) { if(!condition.not) return false; }
|
if (!checkFlagCondition(QF, cond, val)) {
|
||||||
else { if(condition.not) return false; }
|
if (!condition.not) return false;
|
||||||
|
} else {
|
||||||
|
if (condition.not) return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (condition.checkQuestFlag != null && !condition.checkQuestFlag.isEmpty()) {
|
if (condition.checkQuestFlag != null && !condition.checkQuestFlag.isEmpty()) {
|
||||||
if (!player.checkQuestFlag(condition.checkQuestFlag)) {
|
if (!player.checkQuestFlag(condition.checkQuestFlag)) {
|
||||||
@@ -256,8 +342,11 @@ public class MapDialog {
|
|||||||
int val = condition.getMapFlag.val;
|
int val = condition.getMapFlag.val;
|
||||||
int QF = stage.getQuestFlag(key);
|
int QF = stage.getQuestFlag(key);
|
||||||
if (!stage.checkQuestFlag(key)) return false; //If the quest is not ongoing, stop.
|
if (!stage.checkQuestFlag(key)) return false; //If the quest is not ongoing, stop.
|
||||||
if(!checkFlagCondition(QF, cond, val)) { if(!condition.not) return false; }
|
if (!checkFlagCondition(QF, cond, val)) {
|
||||||
else { if(condition.not) return false; }
|
if (!condition.not) return false;
|
||||||
|
} else {
|
||||||
|
if (condition.not) return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (condition.checkMapFlag != null && !condition.checkMapFlag.isEmpty()) {
|
if (condition.checkMapFlag != null && !condition.checkMapFlag.isEmpty()) {
|
||||||
if (!stage.checkQuestFlag(condition.checkMapFlag)) {
|
if (!stage.checkQuestFlag(condition.checkMapFlag)) {
|
||||||
@@ -267,14 +356,26 @@ public class MapDialog {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkFlagCondition(int flag, String condition, int value) {
|
private boolean checkFlagCondition(int flag, String condition, int value) {
|
||||||
switch (condition.toUpperCase()) {
|
switch (condition.toUpperCase()) {
|
||||||
default: case "EQUALS": case"EQUAL": case "=":
|
default:
|
||||||
|
case "EQUALS":
|
||||||
|
case "EQUAL":
|
||||||
|
case "=":
|
||||||
if (flag == value) return true;
|
if (flag == value) return true;
|
||||||
case "LESSTHAN": case "<": if(flag < value) return true;
|
case "LESSTHAN":
|
||||||
case "MORETHAN": case ">": if(flag > value) return true;
|
case "<":
|
||||||
case "LE_THAN": case "<=": if(flag <= value) return true;
|
if (flag < value) return true;
|
||||||
case "ME_THAN": case ">=": if(flag >= value) return true;
|
case "MORETHAN":
|
||||||
|
case ">":
|
||||||
|
if (flag > value) return true;
|
||||||
|
case "LE_THAN":
|
||||||
|
case "<=":
|
||||||
|
if (flag <= value) return true;
|
||||||
|
case "ME_THAN":
|
||||||
|
case ">=":
|
||||||
|
if (flag >= value) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 71 KiB |
@@ -270,7 +270,7 @@ public enum FSkinProp {
|
|||||||
//adventure icons
|
//adventure icons
|
||||||
ICO_MANASHARD (new int[] {2, 304, 100, 100}, PropType.ADVENTURE),
|
ICO_MANASHARD (new int[] {2, 304, 100, 100}, PropType.ADVENTURE),
|
||||||
ICO_ADVLOGO (new int[] {2, 2, 300, 300}, PropType.ADVENTURE),
|
ICO_ADVLOGO (new int[] {2, 2, 300, 300}, PropType.ADVENTURE),
|
||||||
ICO_ADVDECKBOX (new int[] {107, 427, 195, 175}, PropType.ADVENTURE),
|
ICO_ADVDECKBOX (new int[] {111, 365, 192, 240}, PropType.ADVENTURE),
|
||||||
|
|
||||||
//menu icon
|
//menu icon
|
||||||
ICO_MENU_GALAXY (new int[] {0, 1520, 80, 80}, PropType.ICON),
|
ICO_MENU_GALAXY (new int[] {0, 1520, 80, 80}, PropType.ICON),
|
||||||
|
|||||||
Reference in New Issue
Block a user