mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
Update NewGameScene
- Hint TextButton -> ImageButton - add Random Avatar Listener - update NameGenerator Listener - update disabled Menu text - use AsyncAudio for Android
This commit is contained in:
@@ -51,6 +51,7 @@ import com.badlogic.gdx.Version;
|
|||||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||||
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
|
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
|
||||||
import com.badlogic.gdx.backends.android.AndroidAudio;
|
import com.badlogic.gdx.backends.android.AndroidAudio;
|
||||||
|
import com.badlogic.gdx.backends.android.AsynchronousAndroidAudio;
|
||||||
import com.getkeepsafe.relinker.ReLinker;
|
import com.getkeepsafe.relinker.ReLinker;
|
||||||
import de.cketti.fileprovider.PublicFileProvider;
|
import de.cketti.fileprovider.PublicFileProvider;
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
@@ -122,7 +123,8 @@ public class Main extends AndroidApplication {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AndroidAudio createAudio(Context context, AndroidApplicationConfiguration config) {
|
public AndroidAudio createAudio(Context context, AndroidApplicationConfiguration config) {
|
||||||
return super.createAudio(context, config);
|
return new AsynchronousAndroidAudio(context, config);
|
||||||
|
//return super.createAudio(context, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ package forge.adventure.scene;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.github.tommyettinger.textra.TextraButton;
|
|
||||||
import com.github.tommyettinger.textra.TextraLabel;
|
import com.github.tommyettinger.textra.TextraLabel;
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
import forge.adventure.data.DialogData;
|
import forge.adventure.data.DialogData;
|
||||||
@@ -48,17 +48,17 @@ public class NewGameScene extends MenuScene {
|
|||||||
private final TextraLabel starterEditionLabel;
|
private final TextraLabel starterEditionLabel;
|
||||||
private final Array<String> custom;
|
private final Array<String> custom;
|
||||||
private final TextraLabel colorLabel;
|
private final TextraLabel colorLabel;
|
||||||
private final TextraButton difficultyHelp;
|
private final ImageButton difficultyHelp;
|
||||||
private DialogData difficultySummary;
|
private DialogData difficultySummary;
|
||||||
private final TextraButton modeHelp;
|
private final ImageButton modeHelp;
|
||||||
private DialogData modeSummary;
|
private DialogData modeSummary;
|
||||||
|
private final Random rand = new Random();
|
||||||
|
|
||||||
private final Array<AdventureModes> modes = new Array<>();
|
private final Array<AdventureModes> modes = new Array<>();
|
||||||
|
|
||||||
private NewGameScene() {
|
private NewGameScene() {
|
||||||
|
|
||||||
super(Forge.isLandscapeMode() ? "ui/new_game.json" : "ui/new_game_portrait.json");
|
super(Forge.isLandscapeMode() ? "ui/new_game.json" : "ui/new_game_portrait.json");
|
||||||
|
|
||||||
gender = ui.findActor("gender");
|
gender = ui.findActor("gender");
|
||||||
selectedName = ui.findActor("nameField");
|
selectedName = ui.findActor("nameField");
|
||||||
selectedName.setText(NameGenerator.getRandomName(gender.getCurrentIndex() > 0 ? "Female" : "Male", "Any", ""));
|
selectedName.setText(NameGenerator.getRandomName(gender.getCurrentIndex() > 0 ? "Female" : "Male", "Any", ""));
|
||||||
@@ -127,13 +127,12 @@ public class NewGameScene extends MenuScene {
|
|||||||
modeNames[i] = modes.get(i).getName();
|
modeNames[i] = modes.get(i).getName();
|
||||||
mode.setTextList(modeNames);
|
mode.setTextList(modeNames);
|
||||||
|
|
||||||
gender.setTextList(new String[]{Forge.getLocalizer().getMessage("lblMale"), Forge.getLocalizer().getMessage("lblFemale")});
|
gender.setTextList(new String[]{Forge.getLocalizer().getMessage("lblMale") + "[%120][CYAN] \u2642",
|
||||||
|
Forge.getLocalizer().getMessage("lblFemale") + "[%120][MAGENTA] \u2640"});
|
||||||
gender.addListener(new ClickListener() {
|
gender.addListener(new ClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void clicked(InputEvent event, float x, float y) {
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
//gender should be either Male or Female
|
nameTT = 0.8f;
|
||||||
String val = gender.getCurrentIndex() > 0 ? "Female" : "Male";
|
|
||||||
selectedName.setText(NameGenerator.getRandomName(val, "Any", ""));
|
|
||||||
super.clicked(event, x, y);
|
super.clicked(event, x, y);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -150,6 +149,13 @@ public class NewGameScene extends MenuScene {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
race = ui.findActor("race");
|
race = ui.findActor("race");
|
||||||
|
race.addListener(new ClickListener() {
|
||||||
|
@Override
|
||||||
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
|
avatarTT = 0.7f;
|
||||||
|
super.clicked(event, x, y);
|
||||||
|
}
|
||||||
|
});
|
||||||
race.addListener(event -> NewGameScene.this.updateAvatar());
|
race.addListener(event -> NewGameScene.this.updateAvatar());
|
||||||
race.setTextList(HeroListData.getRaces());
|
race.setTextList(HeroListData.getRaces());
|
||||||
difficulty = ui.findActor("difficulty");
|
difficulty = ui.findActor("difficulty");
|
||||||
@@ -167,9 +173,7 @@ public class NewGameScene extends MenuScene {
|
|||||||
difficulty.setTextList(diffList);
|
difficulty.setTextList(diffList);
|
||||||
difficulty.setCurrentIndex(startingDifficulty);
|
difficulty.setCurrentIndex(startingDifficulty);
|
||||||
|
|
||||||
Random rand = new Random();
|
generateAvatar();
|
||||||
avatarIndex = rand.nextInt();
|
|
||||||
updateAvatar();
|
|
||||||
gender.setCurrentIndex(rand.nextInt());
|
gender.setCurrentIndex(rand.nextInt());
|
||||||
colorId.setCurrentIndex(rand.nextInt());
|
colorId.setCurrentIndex(rand.nextInt());
|
||||||
race.setCurrentIndex(rand.nextInt());
|
race.setCurrentIndex(rand.nextInt());
|
||||||
@@ -189,6 +193,34 @@ public class NewGameScene extends MenuScene {
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float avatarT = 1f, avatarTT = 1f;
|
||||||
|
float nameT = 1f, nameTT = 1f;
|
||||||
|
@Override
|
||||||
|
public void act(float delta) {
|
||||||
|
super.act(delta);
|
||||||
|
if (avatarT > avatarTT) {
|
||||||
|
avatarTT += (delta / 0.5f);
|
||||||
|
generateAvatar();
|
||||||
|
} else {
|
||||||
|
avatarTT = avatarT;
|
||||||
|
}
|
||||||
|
if (nameT > nameTT) {
|
||||||
|
nameTT += (delta / 0.5f);
|
||||||
|
generateName();
|
||||||
|
} else {
|
||||||
|
nameTT = nameT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void generateAvatar() {
|
||||||
|
avatarIndex = rand.nextInt();
|
||||||
|
updateAvatar();
|
||||||
|
}
|
||||||
|
private void generateName() {
|
||||||
|
//gender should be either Male or Female
|
||||||
|
String val = gender.getCurrentIndex() > 0 ? "Female" : "Male";
|
||||||
|
selectedName.setText(NameGenerator.getRandomName(val, "Any", ""));
|
||||||
|
}
|
||||||
|
|
||||||
boolean started = false;
|
boolean started = false;
|
||||||
|
|
||||||
public boolean start() {
|
public boolean start() {
|
||||||
|
|||||||
@@ -694,8 +694,8 @@ public class GameHUD extends Stage {
|
|||||||
setVisibility(shards, visible);
|
setVisibility(shards, visible);
|
||||||
setVisibility(money, visible);
|
setVisibility(money, visible);
|
||||||
setVisibility(blank, visible);
|
setVisibility(blank, visible);
|
||||||
setDisabled(exitToWorldMapActor, !MapStage.getInstance().isInMap(), "[%120][+ExitToWorldMap]", "---");
|
setDisabled(exitToWorldMapActor, !MapStage.getInstance().isInMap(), "[%120][+ExitToWorldMap]", "\uFF0F");
|
||||||
setDisabled(bookmarkActor, !MapStage.getInstance().isInMap(), "[%120][+Bookmark]", "---");
|
setDisabled(bookmarkActor, !MapStage.getInstance().isInMap(), "[%120][+Bookmark]", "\uFF0F");
|
||||||
setAlpha(avatarborder, visible);
|
setAlpha(avatarborder, visible);
|
||||||
setAlpha(avatar, visible);
|
setAlpha(avatar, visible);
|
||||||
setAlpha(deckActor, visible);
|
setAlpha(deckActor, visible);
|
||||||
@@ -810,8 +810,8 @@ public class GameHUD extends Stage {
|
|||||||
public boolean act(float v) {
|
public boolean act(float v) {
|
||||||
if (exitDungeon) {
|
if (exitDungeon) {
|
||||||
MapStage.getInstance().exitDungeon();
|
MapStage.getInstance().exitDungeon();
|
||||||
setDisabled(exitToWorldMapActor, true, "[%120][+ExitToWorldMap]", "---");
|
setDisabled(exitToWorldMapActor, true, "[%120][+ExitToWorldMap]", "\uFF0F");
|
||||||
setDisabled(bookmarkActor, true, "[%120][+Bookmark]", "---");
|
setDisabled(bookmarkActor, true, "[%120][+Bookmark]", "\uFF0F");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -458,6 +458,11 @@
|
|||||||
"down": "right_down",
|
"down": "right_down",
|
||||||
"focused": "right_f"
|
"focused": "right_f"
|
||||||
},
|
},
|
||||||
|
"roundhint": {
|
||||||
|
"up": "unpressedround",
|
||||||
|
"down": "pressedround",
|
||||||
|
"focused": "unpressedround"
|
||||||
|
},
|
||||||
"item_frame": {
|
"item_frame": {
|
||||||
"imageCheckedOver": "item_frame_selected_hover",
|
"imageCheckedOver": "item_frame_selected_hover",
|
||||||
"up": "item_frame",
|
"up": "item_frame",
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
@@ -65,14 +65,14 @@
|
|||||||
"yOffset": 8
|
"yOffset": 8
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextButton",
|
"type": "ImageButton",
|
||||||
"name": "difficultyHelp",
|
"name": "difficultyHelp",
|
||||||
"text": "[GOLD]?",
|
"style": "roundhint",
|
||||||
"selectable": true,
|
"selectable": true,
|
||||||
"width": 16,
|
"width": 12,
|
||||||
"height": 16,
|
"height": 15,
|
||||||
"x": 145,
|
"x": 145,
|
||||||
"yOffset": -16
|
"yOffset": -17
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "Label",
|
||||||
@@ -93,14 +93,14 @@
|
|||||||
"yOffset": 8
|
"yOffset": 8
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextButton",
|
"type": "ImageButton",
|
||||||
"name": "modeHelp",
|
"name": "modeHelp",
|
||||||
"text": "[GOLD]?",
|
"style": "roundhint",
|
||||||
"selectable": true,
|
"selectable": true,
|
||||||
"width": 16,
|
"width": 12,
|
||||||
"height": 16,
|
"height": 15,
|
||||||
"x": 145,
|
"x": 145,
|
||||||
"yOffset": -16
|
"yOffset": -17
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "Label",
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
"width": 128,
|
"width": 128,
|
||||||
"height": 24,
|
"height": 24,
|
||||||
"x": 16,
|
"x": 16,
|
||||||
"y": 140
|
"y": 148
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "Label",
|
||||||
@@ -65,14 +65,14 @@
|
|||||||
"yOffset": 8
|
"yOffset": 8
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextButton",
|
"type": "ImageButton",
|
||||||
"name": "difficultyHelp",
|
"name": "difficultyHelp",
|
||||||
"text": "[GOLD]?",
|
"style": "roundhint",
|
||||||
"selectable": true,
|
"selectable": true,
|
||||||
"width": 24,
|
"width": 12,
|
||||||
"height": 24,
|
"height": 15,
|
||||||
"x": 72,
|
"x": 80,
|
||||||
"yOffset": -24
|
"yOffset": -17
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "Label",
|
||||||
@@ -93,14 +93,14 @@
|
|||||||
"yOffset": 8
|
"yOffset": 8
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextButton",
|
"type": "ImageButton",
|
||||||
"name": "modeHelp",
|
"name": "modeHelp",
|
||||||
"text": "[GOLD]?",
|
"style": "roundhint",
|
||||||
"selectable": true,
|
"selectable": true,
|
||||||
"width": 24,
|
"width": 12,
|
||||||
"height": 24,
|
"height": 15,
|
||||||
"x": 72,
|
"x": 80,
|
||||||
"yOffset": -24
|
"yOffset": -17
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Label",
|
"type": "Label",
|
||||||
|
|||||||
Reference in New Issue
Block a user