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.AndroidApplicationConfiguration;
|
||||
import com.badlogic.gdx.backends.android.AndroidAudio;
|
||||
import com.badlogic.gdx.backends.android.AsynchronousAndroidAudio;
|
||||
import com.getkeepsafe.relinker.ReLinker;
|
||||
import de.cketti.fileprovider.PublicFileProvider;
|
||||
import forge.Forge;
|
||||
@@ -122,7 +123,8 @@ public class Main extends AndroidApplication {
|
||||
|
||||
@Override
|
||||
public AndroidAudio createAudio(Context context, AndroidApplicationConfiguration config) {
|
||||
return super.createAudio(context, config);
|
||||
return new AsynchronousAndroidAudio(context, config);
|
||||
//return super.createAudio(context, config);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,12 +3,12 @@ package forge.adventure.scene;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
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.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.github.tommyettinger.textra.TextraButton;
|
||||
import com.github.tommyettinger.textra.TextraLabel;
|
||||
import forge.Forge;
|
||||
import forge.adventure.data.DialogData;
|
||||
@@ -48,17 +48,17 @@ public class NewGameScene extends MenuScene {
|
||||
private final TextraLabel starterEditionLabel;
|
||||
private final Array<String> custom;
|
||||
private final TextraLabel colorLabel;
|
||||
private final TextraButton difficultyHelp;
|
||||
private final ImageButton difficultyHelp;
|
||||
private DialogData difficultySummary;
|
||||
private final TextraButton modeHelp;
|
||||
private final ImageButton modeHelp;
|
||||
private DialogData modeSummary;
|
||||
private final Random rand = new Random();
|
||||
|
||||
private final Array<AdventureModes> modes = new Array<>();
|
||||
|
||||
private NewGameScene() {
|
||||
|
||||
super(Forge.isLandscapeMode() ? "ui/new_game.json" : "ui/new_game_portrait.json");
|
||||
|
||||
gender = ui.findActor("gender");
|
||||
selectedName = ui.findActor("nameField");
|
||||
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();
|
||||
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() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
//gender should be either Male or Female
|
||||
String val = gender.getCurrentIndex() > 0 ? "Female" : "Male";
|
||||
selectedName.setText(NameGenerator.getRandomName(val, "Any", ""));
|
||||
nameTT = 0.8f;
|
||||
super.clicked(event, x, y);
|
||||
}
|
||||
});
|
||||
@@ -150,6 +149,13 @@ public class NewGameScene extends MenuScene {
|
||||
}
|
||||
});
|
||||
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.setTextList(HeroListData.getRaces());
|
||||
difficulty = ui.findActor("difficulty");
|
||||
@@ -167,9 +173,7 @@ public class NewGameScene extends MenuScene {
|
||||
difficulty.setTextList(diffList);
|
||||
difficulty.setCurrentIndex(startingDifficulty);
|
||||
|
||||
Random rand = new Random();
|
||||
avatarIndex = rand.nextInt();
|
||||
updateAvatar();
|
||||
generateAvatar();
|
||||
gender.setCurrentIndex(rand.nextInt());
|
||||
colorId.setCurrentIndex(rand.nextInt());
|
||||
race.setCurrentIndex(rand.nextInt());
|
||||
@@ -189,6 +193,34 @@ public class NewGameScene extends MenuScene {
|
||||
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;
|
||||
|
||||
public boolean start() {
|
||||
|
||||
@@ -694,8 +694,8 @@ public class GameHUD extends Stage {
|
||||
setVisibility(shards, visible);
|
||||
setVisibility(money, visible);
|
||||
setVisibility(blank, visible);
|
||||
setDisabled(exitToWorldMapActor, !MapStage.getInstance().isInMap(), "[%120][+ExitToWorldMap]", "---");
|
||||
setDisabled(bookmarkActor, !MapStage.getInstance().isInMap(), "[%120][+Bookmark]", "---");
|
||||
setDisabled(exitToWorldMapActor, !MapStage.getInstance().isInMap(), "[%120][+ExitToWorldMap]", "\uFF0F");
|
||||
setDisabled(bookmarkActor, !MapStage.getInstance().isInMap(), "[%120][+Bookmark]", "\uFF0F");
|
||||
setAlpha(avatarborder, visible);
|
||||
setAlpha(avatar, visible);
|
||||
setAlpha(deckActor, visible);
|
||||
@@ -810,8 +810,8 @@ public class GameHUD extends Stage {
|
||||
public boolean act(float v) {
|
||||
if (exitDungeon) {
|
||||
MapStage.getInstance().exitDungeon();
|
||||
setDisabled(exitToWorldMapActor, true, "[%120][+ExitToWorldMap]", "---");
|
||||
setDisabled(bookmarkActor, true, "[%120][+Bookmark]", "---");
|
||||
setDisabled(exitToWorldMapActor, true, "[%120][+ExitToWorldMap]", "\uFF0F");
|
||||
setDisabled(bookmarkActor, true, "[%120][+Bookmark]", "\uFF0F");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -458,6 +458,11 @@
|
||||
"down": "right_down",
|
||||
"focused": "right_f"
|
||||
},
|
||||
"roundhint": {
|
||||
"up": "unpressedround",
|
||||
"down": "pressedround",
|
||||
"focused": "unpressedround"
|
||||
},
|
||||
"item_frame": {
|
||||
"imageCheckedOver": "item_frame_selected_hover",
|
||||
"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
|
||||
},
|
||||
{
|
||||
"type": "TextButton",
|
||||
"type": "ImageButton",
|
||||
"name": "difficultyHelp",
|
||||
"text": "[GOLD]?",
|
||||
"style": "roundhint",
|
||||
"selectable": true,
|
||||
"width": 16,
|
||||
"height": 16,
|
||||
"width": 12,
|
||||
"height": 15,
|
||||
"x": 145,
|
||||
"yOffset": -16
|
||||
"yOffset": -17
|
||||
},
|
||||
{
|
||||
"type": "Label",
|
||||
@@ -93,14 +93,14 @@
|
||||
"yOffset": 8
|
||||
},
|
||||
{
|
||||
"type": "TextButton",
|
||||
"type": "ImageButton",
|
||||
"name": "modeHelp",
|
||||
"text": "[GOLD]?",
|
||||
"style": "roundhint",
|
||||
"selectable": true,
|
||||
"width": 16,
|
||||
"height": 16,
|
||||
"width": 12,
|
||||
"height": 15,
|
||||
"x": 145,
|
||||
"yOffset": -16
|
||||
"yOffset": -17
|
||||
},
|
||||
{
|
||||
"type": "Label",
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
"width": 128,
|
||||
"height": 24,
|
||||
"x": 16,
|
||||
"y": 140
|
||||
"y": 148
|
||||
},
|
||||
{
|
||||
"type": "Label",
|
||||
@@ -65,14 +65,14 @@
|
||||
"yOffset": 8
|
||||
},
|
||||
{
|
||||
"type": "TextButton",
|
||||
"type": "ImageButton",
|
||||
"name": "difficultyHelp",
|
||||
"text": "[GOLD]?",
|
||||
"style": "roundhint",
|
||||
"selectable": true,
|
||||
"width": 24,
|
||||
"height": 24,
|
||||
"x": 72,
|
||||
"yOffset": -24
|
||||
"width": 12,
|
||||
"height": 15,
|
||||
"x": 80,
|
||||
"yOffset": -17
|
||||
},
|
||||
{
|
||||
"type": "Label",
|
||||
@@ -93,14 +93,14 @@
|
||||
"yOffset": 8
|
||||
},
|
||||
{
|
||||
"type": "TextButton",
|
||||
"type": "ImageButton",
|
||||
"name": "modeHelp",
|
||||
"text": "[GOLD]?",
|
||||
"style": "roundhint",
|
||||
"selectable": true,
|
||||
"width": 24,
|
||||
"height": 24,
|
||||
"x": 72,
|
||||
"yOffset": -24
|
||||
"width": 12,
|
||||
"height": 15,
|
||||
"x": 80,
|
||||
"yOffset": -17
|
||||
},
|
||||
{
|
||||
"type": "Label",
|
||||
|
||||
Reference in New Issue
Block a user