Added sounds
This commit is contained in:
1 parent
c6ba8bd008
commit
124208f2a4
26 files changed
+205
-31
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -76,6 +76,7 @@ function on_bed_sleep()
|
||||
local day = game_api.getIntValue("day")
|
||||
game_api.setIntValue("day", day + 1)
|
||||
print("Setting to day 1----x")
|
||||
game_api.play_sound("audio/587036__antoineromo__bed-sheets.ogg")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -85,6 +86,8 @@ end
|
||||
|
||||
function on_locked_door_click()
|
||||
game_api.start_dialogue("door_locked_dialog001")
|
||||
game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg")
|
||||
--game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
end
|
||||
|
||||
function on_sleep_cutscene()
|
||||
@@ -118,6 +121,8 @@ function alik_door_open_callback()
|
||||
else
|
||||
game_api.switch_navigation(4) --b
|
||||
end
|
||||
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -156,6 +161,8 @@ function on_player_bathroom_click()
|
||||
else
|
||||
game_api.switch_navigation(1) --ca
|
||||
end
|
||||
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -186,7 +193,9 @@ function on_player_door_click()
|
||||
else
|
||||
game_api.switch_navigation(2) --ba
|
||||
end
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -63,6 +63,14 @@ game_api.set_darklands_callbacks(
|
||||
end
|
||||
)
|
||||
|
||||
game_api.set_enter_night_callback(
|
||||
function()
|
||||
game_api.deactivate_interactive_object("car001")
|
||||
game_api.deactivate_interactive_object("car001wheels")
|
||||
game_api.switch_navigation(1)
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
game_api.set_location_callbacks(
|
||||
function()
|
||||
|
||||
@@ -257,25 +257,6 @@ function on_npc_interact(npc_index)
|
||||
game_api.start_dialogue("teacher_dialog007")
|
||||
end
|
||||
end
|
||||
--[[
|
||||
if (player_ghost_aware == 1) then
|
||||
--game_api.setIntValue("player_has_coursework", 1)
|
||||
local player_has_coursework = game_api.getIntValue("player_has_coursework")
|
||||
local player_has_report_card = game_api.getIntValue("player_has_report_card")
|
||||
local report_card_signed = game_api.getIntValue("report_card_signed")
|
||||
|
||||
if (report_card_signed == 1) then
|
||||
game_api.start_dialogue("teacher_dialog004")
|
||||
elseif (player_has_coursework == 1 and player_has_report_card == 1) then
|
||||
game_api.start_dialogue("teacher_dialog005")
|
||||
game_api.remove_item("coursework")
|
||||
game_api.setIntValue("report_card_signed", 1)
|
||||
else
|
||||
game_api.start_dialogue("teacher_dialog007")
|
||||
end
|
||||
else
|
||||
game_api.start_dialogue("teacher_dialog001")
|
||||
end]]
|
||||
end
|
||||
if npc_index == 2 then
|
||||
local report_card_signed = game_api.getIntValue("report_card_signed")
|
||||
@@ -320,12 +301,17 @@ function on_library_door_click()
|
||||
|
||||
if (day == 0) then
|
||||
if game_api.is_dawn() then
|
||||
if not (morning_did_open_door_index == 5) then
|
||||
game_api.start_dialogue("door_dialog007")
|
||||
game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg")
|
||||
end
|
||||
elseif game_api.is_night() then
|
||||
game_api.start_dialogue("door_night_dialog001")
|
||||
game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg")
|
||||
else
|
||||
if (lection_is_over == 0) then
|
||||
game_api.start_dialogue("door_dialog003")
|
||||
game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg")
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -366,9 +352,11 @@ function on_teachers_door_click()
|
||||
game_api.deactivate_interactive_object("Room_Cover_South_3_001")
|
||||
end)
|
||||
game_api.switch_navigation(3)
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
end
|
||||
else
|
||||
game_api.start_dialogue("door_dialog004")
|
||||
game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg")
|
||||
end
|
||||
else
|
||||
if (game_api.is_dawn()) then
|
||||
@@ -384,6 +372,7 @@ function on_teachers_door_click()
|
||||
game_api.deactivate_interactive_object("Room_Cover_Corridor_001")
|
||||
end)
|
||||
game_api.switch_navigation(10)
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
else
|
||||
if (morning_did_open_door_index == 1) then
|
||||
--s1 + s3
|
||||
@@ -393,6 +382,7 @@ function on_teachers_door_click()
|
||||
game_api.deactivate_interactive_object("Room_Cover_South_3_001")
|
||||
end)
|
||||
game_api.switch_navigation(11)
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
elseif (morning_did_open_door_index == 2) then
|
||||
--s2 + s3
|
||||
|
||||
@@ -401,6 +391,7 @@ function on_teachers_door_click()
|
||||
game_api.deactivate_interactive_object("Room_Cover_South_3_001")
|
||||
end)
|
||||
game_api.switch_navigation(15)
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
elseif (morning_did_open_door_index == 5) then
|
||||
--n3 + s3
|
||||
|
||||
@@ -409,6 +400,7 @@ function on_teachers_door_click()
|
||||
game_api.deactivate_interactive_object("Room_Cover_South_3_001")
|
||||
end)
|
||||
game_api.switch_navigation(13)
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
elseif (morning_did_open_door_index == 4) then
|
||||
--n2 + s3
|
||||
|
||||
@@ -417,6 +409,7 @@ function on_teachers_door_click()
|
||||
game_api.deactivate_interactive_object("Room_Cover_South_3_001")
|
||||
end)
|
||||
game_api.switch_navigation(14)
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
elseif (morning_did_open_door_index == 6) then
|
||||
--hall + s3
|
||||
|
||||
@@ -425,6 +418,7 @@ function on_teachers_door_click()
|
||||
game_api.deactivate_interactive_object("Room_Cover_South_3_001")
|
||||
end)
|
||||
game_api.switch_navigation(12)
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
else
|
||||
--Player was in corridor, but tries to open the teacher's door
|
||||
--s3 only
|
||||
@@ -433,6 +427,7 @@ function on_teachers_door_click()
|
||||
game_api.deactivate_interactive_object("Room_Cover_South_3_001")
|
||||
end)
|
||||
game_api.switch_navigation(10)
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -454,6 +449,7 @@ function on_teachers_door_click()
|
||||
end
|
||||
|
||||
game_api.switch_navigation(10)
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -466,7 +462,10 @@ function on_hall_door_click()
|
||||
|
||||
if (day == 0) then
|
||||
if (game_api.is_dawn()) then
|
||||
if not (morning_did_open_door_index == 6) then
|
||||
game_api.start_dialogue("door_dialog007")
|
||||
game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg")
|
||||
end
|
||||
else
|
||||
if (not hall_door_opened) then
|
||||
hall_door_opened = true
|
||||
@@ -478,12 +477,14 @@ function on_hall_door_click()
|
||||
game_api.set_npc_enabled(0, true)
|
||||
game_api.set_npc_enabled(6, true)
|
||||
game_api.npc_rotate_to(6, 180)
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
end
|
||||
end
|
||||
else
|
||||
if (game_api.is_night()) then
|
||||
if not (morning_did_open_door_index == 6) then
|
||||
game_api.start_dialogue("door_dialog001")
|
||||
game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -492,14 +493,19 @@ end
|
||||
function on_s1_door_click()
|
||||
local day = game_api.getIntValue("day")
|
||||
if (day == 0) and(game_api.is_dawn()) then
|
||||
if not (morning_did_open_door_index == 1) then
|
||||
game_api.start_dialogue("door_dialog007")
|
||||
game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg")
|
||||
end
|
||||
else
|
||||
if (game_api.is_night()) then
|
||||
if not (morning_did_open_door_index == 1) then
|
||||
game_api.start_dialogue("door_dialog001")
|
||||
game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg")
|
||||
end
|
||||
else
|
||||
game_api.start_dialogue("door_dialog006")
|
||||
game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -507,14 +513,19 @@ end
|
||||
function on_s2_door_click()
|
||||
local day = game_api.getIntValue("day")
|
||||
if (day == 0) and(game_api.is_dawn()) then
|
||||
if not (morning_did_open_door_index == 2) then
|
||||
game_api.start_dialogue("door_dialog007")
|
||||
game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg")
|
||||
end
|
||||
else
|
||||
if (game_api.is_night()) then
|
||||
if not (morning_did_open_door_index == 2) then
|
||||
game_api.start_dialogue("door_dialog001")
|
||||
game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg")
|
||||
end
|
||||
else
|
||||
game_api.start_dialogue("door_dialog006")
|
||||
game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -522,11 +533,15 @@ end
|
||||
function on_n2_door_click()
|
||||
local day = game_api.getIntValue("day")
|
||||
if (day == 0) and(game_api.is_dawn()) then
|
||||
if not (morning_did_open_door_index == 4) then
|
||||
game_api.start_dialogue("door_dialog007")
|
||||
game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg")
|
||||
end
|
||||
else
|
||||
if (game_api.is_night()) then
|
||||
if not (morning_did_open_door_index == 4) then
|
||||
game_api.start_dialogue("door_dialog001")
|
||||
game_api.play_sound("audio/398751__anthousai__door-lock-01.ogg")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -641,6 +656,7 @@ function on_teacher_arrived_intermediate()
|
||||
game_api.switch_navigation(2)
|
||||
game_api.npc_walk_to(0, 4.94194, 0, 6.64111, on_teacher_arrived)
|
||||
teacher_arrived = true
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
end
|
||||
|
||||
function on_lection_cutscene_fadein_callback()
|
||||
@@ -1226,6 +1242,8 @@ function on_aiperi_opens_door()
|
||||
game_api.start_dialogue("dialog_aiperi_morning001")
|
||||
end)
|
||||
game_api.player_walk_to(0.0, 0.0, 10.0, nil)
|
||||
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
end
|
||||
elseif (morning_can_open_door_index == 5) then
|
||||
if (morning_did_open_door_index == 0) then
|
||||
@@ -1252,6 +1270,8 @@ function on_aiperi_opens_door()
|
||||
game_api.start_dialogue("dialog_aiperi_morning001")
|
||||
end)
|
||||
game_api.player_walk_to(3.52174, 0, 6.28993, nil)
|
||||
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
end
|
||||
elseif (morning_can_open_door_index == 4) then
|
||||
if (morning_did_open_door_index == 0) then
|
||||
@@ -1278,6 +1298,8 @@ function on_aiperi_opens_door()
|
||||
game_api.start_dialogue("dialog_aiperi_morning001")
|
||||
end)
|
||||
game_api.player_walk_to(3.36055, 0, -2.0345, nil)
|
||||
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
end
|
||||
elseif (morning_can_open_door_index == 2) then
|
||||
if (morning_did_open_door_index == 0) then
|
||||
@@ -1304,6 +1326,8 @@ function on_aiperi_opens_door()
|
||||
game_api.start_dialogue("dialog_aiperi_morning001")
|
||||
end)
|
||||
game_api.player_walk_to(-3.63363, 0, -1.50727, nil)
|
||||
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
end
|
||||
elseif (morning_can_open_door_index == 1) then
|
||||
if (morning_did_open_door_index == 0) then
|
||||
@@ -1330,6 +1354,8 @@ function on_aiperi_opens_door()
|
||||
game_api.start_dialogue("dialog_aiperi_morning001")
|
||||
end)
|
||||
game_api.player_walk_to(-3.64494, 0, -9.66711, nil)
|
||||
|
||||
game_api.play_sound("audio/702171__foxfire__door-opening.ogg")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+13
-2
@@ -419,6 +419,17 @@ void Character::update(int64_t deltaMs, const CharacterResolver& resolver) {
|
||||
state.currentState == AnimationState::ACTION_ATTACK_2)) {
|
||||
if (attackTarget != nullptr) {
|
||||
attackTarget->applyDamage(10.f, attackDirectionToTarget());
|
||||
|
||||
if (audioPlayer) {
|
||||
if (state.isPlayer)
|
||||
{
|
||||
audioPlayer->playSoundAsync("audio/547041__cogfirestudios__hit-swing-sword-small-3.ogg");
|
||||
}
|
||||
else
|
||||
{
|
||||
audioPlayer->playSoundAsync("audio/13925__adcbicycle__21.ogg");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1176,8 +1187,8 @@ void Character::drawNightCpuWithShadow(Renderer& renderer,
|
||||
void Character::setupHitSparks(std::shared_ptr<Texture> sparkTexture) {
|
||||
hitSparkEmitter.setTexture(sparkTexture);
|
||||
hitSparkEmitter.setShaderProgramName("spark");
|
||||
hitSparkEmitter.setMaxParticles(64);
|
||||
hitSparkEmitter.setParticleSize(0.08f);
|
||||
hitSparkEmitter.setMaxParticles(128);
|
||||
hitSparkEmitter.setParticleSize(0.02f);
|
||||
hitSparkEmitter.setBiasX(0.0f);
|
||||
hitSparkEmitter.setEmissionRate(1.0e9f);
|
||||
hitSparkEmitter.setSpeedRange(2.0f, 4.0f);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include "dialogue/TranslationDatabase.h"
|
||||
#include "AudioPlayerAsync.h"
|
||||
|
||||
namespace ZL {
|
||||
|
||||
@@ -107,6 +108,7 @@ public:
|
||||
std::string weaponAttachBoneName = "RightHand";
|
||||
|
||||
SparkEmitter hitSparkEmitter;
|
||||
AudioPlayerAsync* audioPlayer;
|
||||
|
||||
static Dialogue::TranslationDatabase nameTranslations;
|
||||
|
||||
|
||||
+6
-4
@@ -16,7 +16,6 @@
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
@@ -258,10 +257,12 @@ namespace ZL
|
||||
menuManager.onItemPickedUp(itemId);
|
||||
const Item* item = ItemRegistry::instance().findById(itemId);
|
||||
if (item) menuManager.showToast(menuManager.toastTextureItemAdded, item->name);
|
||||
audioPlayer->playSoundAsync("audio/831642__ienba__generic-game-pick-up.ogg");
|
||||
};
|
||||
gameState.inventory.onItemRemoved = [this](const std::string& itemId) {
|
||||
const Item* item = ItemRegistry::instance().findById(itemId);
|
||||
if (item) menuManager.showToast(menuManager.toastTextureItemRemoved, item->name);
|
||||
audioPlayer->playSoundAsync("audio/831642__ienba__generic-game-pick-up.ogg");
|
||||
};
|
||||
|
||||
// Wire phone dialogue start function so MenuManager can trigger dialogues.
|
||||
@@ -433,7 +434,7 @@ namespace ZL
|
||||
uniInteriorParams.playerPosition = Eigen::Vector3f(0.942694, 0, -9.63104);
|
||||
|
||||
gameState.locations["uni_interior"] = std::make_shared<Location>(renderer, gameState.inventory);
|
||||
gameState.locations["uni_interior"]->setup(uniInteriorParams, &gameState.questJournal);
|
||||
gameState.locations["uni_interior"]->setup(uniInteriorParams, &gameState.questJournal, audioPlayer.get());
|
||||
gameState.locations["uni_interior"]->scriptEngine.setGlobalStore(&gameState.globalInts);
|
||||
gameState.locations["uni_interior"]->scriptEngine.setGlobalFloatStore(&gameState.globalFloats);
|
||||
gameState.locations["uni_interior"]->requestNightDayTransition = [this](bool isNight, bool isDawn) { gameState.isNight = isNight; gameState.isDawn = isDawn; };
|
||||
@@ -487,7 +488,7 @@ namespace ZL
|
||||
|
||||
|
||||
gameState.locations["uni_exterior"] = std::make_shared<Location>(renderer, gameState.inventory);
|
||||
gameState.locations["uni_exterior"]->setup(uniExteriorParams, &gameState.questJournal);
|
||||
gameState.locations["uni_exterior"]->setup(uniExteriorParams, &gameState.questJournal, audioPlayer.get());
|
||||
gameState.locations["uni_exterior"]->scriptEngine.setGlobalStore(&gameState.globalInts);
|
||||
gameState.locations["uni_exterior"]->scriptEngine.setGlobalFloatStore(&gameState.globalFloats);
|
||||
gameState.locations["uni_exterior"]->requestNightDayTransition = [this](bool isNight, bool isDawn) {
|
||||
@@ -547,7 +548,7 @@ namespace ZL
|
||||
params_dorm.playerPosition = Eigen::Vector3f(6.76345, 0, -14.6022);
|
||||
|
||||
gameState.locations["location_dorm"] = std::make_shared<Location>(renderer, gameState.inventory);
|
||||
gameState.locations["location_dorm"]->setup(params_dorm, &gameState.questJournal);
|
||||
gameState.locations["location_dorm"]->setup(params_dorm, &gameState.questJournal, audioPlayer.get());
|
||||
gameState.locations["location_dorm"]->scriptEngine.setGlobalStore(&gameState.globalInts);
|
||||
gameState.locations["location_dorm"]->scriptEngine.setGlobalFloatStore(&gameState.globalFloats);
|
||||
gameState.locations["location_dorm"]->requestNightDayTransition = [this](bool isNight, bool isDawn) { gameState.isNight = isNight; gameState.isDawn = isDawn; };
|
||||
@@ -1482,6 +1483,7 @@ namespace ZL
|
||||
|
||||
bool Game::startDarklandsTransition()
|
||||
{
|
||||
audioPlayer->playSoundAsync("audio/459618__n-lerche__blow.ogg");
|
||||
if (!gameState.isNight)
|
||||
{
|
||||
currentLocation()->dialogueSystem.startDialogue("darklands_day_dialog001");
|
||||
|
||||
+4
-2
@@ -83,7 +83,7 @@ namespace ZL
|
||||
|
||||
// ---- Setup ----
|
||||
|
||||
void Location::setup(const LocationSetup& params, Quest::QuestJournal* journal)
|
||||
void Location::setup(const LocationSetup& params, Quest::QuestJournal* journal, AudioPlayerAsync* audioPlayer)
|
||||
{
|
||||
|
||||
// Load static game objects
|
||||
@@ -138,6 +138,7 @@ namespace ZL
|
||||
player->state.position = params.playerPosition;
|
||||
player->setTarget(params.playerPosition);
|
||||
player->setupHitSparks(sparkTexture);
|
||||
player->audioPlayer = audioPlayer;
|
||||
std::cout << "Load resurces step 9" << std::endl;
|
||||
|
||||
// Load NPCs from JSON. Aggressive (canAttack) NPCs need a player target
|
||||
@@ -149,6 +150,7 @@ namespace ZL
|
||||
npc->state.homePosition = Eigen::Vector3f(npc->state.position.x(), 0.f, npc->state.position.z());
|
||||
if (npc->state.canAttack) {
|
||||
npc->setupHitSparks(sparkTexture);
|
||||
npc->audioPlayer = audioPlayer;
|
||||
npc->state.attackTargetIndex = CharacterState::kPlayerIndex;
|
||||
}
|
||||
}
|
||||
@@ -179,7 +181,7 @@ namespace ZL
|
||||
npcNameText.reset();
|
||||
}
|
||||
|
||||
scriptEngine.init(this, &inventory, params.scriptPath);
|
||||
scriptEngine.init(this, &inventory, audioPlayer, params.scriptPath);
|
||||
scriptEngine.setQuestJournal(journal);
|
||||
|
||||
dialogueSystem.setOnCutsceneFinished([this](const std::string& cutsceneId) {
|
||||
|
||||
+2
-1
@@ -133,7 +133,7 @@ namespace ZL
|
||||
bool playBattleMusic = false;
|
||||
|
||||
|
||||
void setup(const LocationSetup& params, Quest::QuestJournal* journal);
|
||||
void setup(const LocationSetup& params, Quest::QuestJournal* journal, AudioPlayerAsync* audioPlayer);
|
||||
void setupNavigation(const std::vector<std::string>& paths);
|
||||
bool switchNavigation(int index);
|
||||
InteractiveObject* raycastInteractiveObjects(const Eigen::Vector3f& rayOrigin, const Eigen::Vector3f& rayDir);
|
||||
@@ -170,6 +170,7 @@ namespace ZL
|
||||
friend class LocationEditor;
|
||||
Renderer& renderer;
|
||||
Inventory& inventory;
|
||||
AudioPlayerAsync* audioPlayer;
|
||||
|
||||
private:
|
||||
// ---- Pointer-to-index helpers ----
|
||||
|
||||
+60
-1
@@ -331,25 +331,32 @@ namespace ZL {
|
||||
uiManager.replaceRoot(mainMenuRoot);
|
||||
|
||||
uiManager.setTextButtonCallback("menuStartButton", [this](const std::string&) {
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
enterGameplay();
|
||||
|
||||
});
|
||||
uiManager.setTextButtonCallback("menuAboutButton", [this](const std::string&) {
|
||||
showAboutScreen();
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
});
|
||||
uiManager.setTextButtonCallback("menuSettingsButton", [this](const std::string&) {
|
||||
showSettingsScreen();
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
});
|
||||
uiManager.setTextButtonCallback("menuLanguageButton", [this](const std::string&) {
|
||||
showLanguageScreen();
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
});
|
||||
uiManager.setTextButtonCallback("menuLoadButton", [this](const std::string&) {
|
||||
showLoadGameScreen();
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
});
|
||||
|
||||
|
||||
|
||||
#ifndef EMSCRIPTEN
|
||||
uiManager.setTextButtonCallback("menuExitButton", [this](const std::string&) {
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
Environment::exitGameLoop = true;
|
||||
});
|
||||
#else
|
||||
@@ -362,6 +369,7 @@ namespace ZL {
|
||||
uiManager.setTextButtonCallback("aboutBackButton", [this](const std::string&) {
|
||||
uiManager.popMenu();
|
||||
uiManager.updateAllLayouts();
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -371,6 +379,7 @@ namespace ZL {
|
||||
saveSettings();
|
||||
uiManager.popMenu();
|
||||
uiManager.updateAllLayouts();
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
});
|
||||
|
||||
// Set initial slider positions before registering callbacks so
|
||||
@@ -456,6 +465,7 @@ namespace ZL {
|
||||
uiManager.setTextButtonColor("musicToggleButton", on
|
||||
? std::array<float, 4>{ 0.2f, 0.9f, 0.2f, 1.0f }
|
||||
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
});
|
||||
uiManager.setTextButtonCallback("soundToggleButton", [this](const std::string&) {
|
||||
audioPlayer_.setSoundEnabled(!audioPlayer_.isSoundEnabled());
|
||||
@@ -464,10 +474,12 @@ namespace ZL {
|
||||
uiManager.setTextButtonColor("soundToggleButton", on
|
||||
? std::array<float, 4>{ 0.2f, 0.9f, 0.2f, 1.0f }
|
||||
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
});
|
||||
uiManager.setTextButtonCallback("fullScreenToggleButton", [this, refreshFullscreenToggle](const std::string&) {
|
||||
Environment::setFullscreen(!Environment::isFullscreen);
|
||||
refreshFullscreenToggle();
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -477,14 +489,17 @@ namespace ZL {
|
||||
saveSettings();
|
||||
uiManager.popMenu();
|
||||
uiManager.updateAllLayouts();
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
});
|
||||
|
||||
uiManager.setTextButtonCallback("languageRussianButton", [this](const std::string&) {
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
ZL::g_currentLanguage = ZL::Language::Russian;
|
||||
reloadLocalizedGameContent();
|
||||
saveSettings();
|
||||
});
|
||||
uiManager.setTextButtonCallback("languageEnglishButton", [this](const std::string&) {
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
ZL::g_currentLanguage = ZL::Language::English;
|
||||
reloadLocalizedGameContent();
|
||||
saveSettings();
|
||||
@@ -528,6 +543,7 @@ namespace ZL {
|
||||
uiManager.setTextButtonCallback("loadBackButton", [this](const std::string&) {
|
||||
uiManager.popMenu();
|
||||
uiManager.updateAllLayouts();
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
});
|
||||
|
||||
static const char* kSlotButtons[4] = {
|
||||
@@ -543,6 +559,7 @@ namespace ZL {
|
||||
uiManager.setTextButtonText(kSlotButtons[i], label);
|
||||
}
|
||||
uiManager.setTextButtonCallback(kSlotButtons[i], [this, slot](const std::string&) {
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
if (onLoadGame) onLoadGame(slot);
|
||||
enterGameplay(true);
|
||||
});
|
||||
@@ -555,6 +572,7 @@ namespace ZL {
|
||||
uiManager.setTextButtonCallback("saveBackButton", [this](const std::string&) {
|
||||
uiManager.popMenu();
|
||||
uiManager.updateAllLayouts();
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
});
|
||||
|
||||
static const char* kSlotButtons[4] = {
|
||||
@@ -578,6 +596,7 @@ namespace ZL {
|
||||
? "Empty"
|
||||
: localizedLocationName[info.locationName][ZL::g_currentLanguage] + "\n" + info.savedAt;
|
||||
uiManager.setTextButtonText(buttonName, label);
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -607,6 +626,7 @@ namespace ZL {
|
||||
}
|
||||
uiManager.setButtonCallback(btnName, [this, i](const std::string&) {
|
||||
selectInventoryItem(i);
|
||||
audioPlayer_.playSoundAsync("audio/sound_bag001.ogg");
|
||||
});
|
||||
} else {
|
||||
uiManager.setNodeVisible(btnName, false);
|
||||
@@ -617,6 +637,8 @@ namespace ZL {
|
||||
if (!portrait && !items.empty()) {
|
||||
selectInventoryItem(0);
|
||||
}
|
||||
|
||||
audioPlayer_.playSoundAsync("audio/sound_bag_open.ogg");
|
||||
}
|
||||
|
||||
void MenuManager::selectInventoryItem(int index) {
|
||||
@@ -668,6 +690,7 @@ namespace ZL {
|
||||
for (int i = 0; i < inventoryMenuStackDepth_; ++i) uiManager.popMenu();
|
||||
inventoryMenuStackDepth_ = 0;
|
||||
uiManager.updateAllLayouts();
|
||||
audioPlayer_.playSoundAsync("audio/sound_bag_close.ogg");
|
||||
}
|
||||
|
||||
void MenuManager::openQuestJournal() {
|
||||
@@ -683,6 +706,7 @@ namespace ZL {
|
||||
|
||||
uiManager.setButtonCallback("journalExitButton", [this](const std::string&) {
|
||||
closeQuestJournal();
|
||||
audioPlayer_.playSoundAsync("audio/656126__itsthegoodstuff__paging-through-book.ogg");
|
||||
});
|
||||
|
||||
static const char* kItemNames[9] = {
|
||||
@@ -693,6 +717,7 @@ namespace ZL {
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
uiManager.setTextButtonCallback(kItemNames[i], [this, i](const std::string&) {
|
||||
selectQuestByIndex(i);
|
||||
audioPlayer_.playSoundAsync("audio/255571__stradie__flipping-paper.ogg");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -700,6 +725,8 @@ namespace ZL {
|
||||
if (!portrait && !visibleQuestIds.empty()) {
|
||||
selectQuestByIndex(0);
|
||||
}
|
||||
|
||||
audioPlayer_.playSoundAsync("audio/255571__stradie__flipping-paper.ogg");
|
||||
}
|
||||
|
||||
void MenuManager::closeQuestJournal() {
|
||||
@@ -750,19 +777,24 @@ namespace ZL {
|
||||
|
||||
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
|
||||
closePhoneEntirely();
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
|
||||
uiManager.setButtonCallback("phoneMessenger", [this](const std::string&) {
|
||||
openPhoneMessenger();
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
uiManager.setButtonCallback("phoneBank", [this](const std::string&) {
|
||||
openPhoneBank();
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
uiManager.setButtonCallback("phoneVideo", [this](const std::string&) {
|
||||
openPhoneVideo();
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
uiManager.setButtonCallback("phoneTaxi", [this](const std::string&) {
|
||||
openPhoneTaxi();
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
|
||||
if (gameState_.isNight)
|
||||
@@ -786,6 +818,8 @@ namespace ZL {
|
||||
uiManager.setNodeVisible("phoneTimeNight", false);
|
||||
uiManager.setNodeVisible("phoneTimeDawn", false);
|
||||
}
|
||||
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
}
|
||||
|
||||
void MenuManager::openPhoneMessenger() {
|
||||
@@ -803,19 +837,23 @@ namespace ZL {
|
||||
|
||||
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
|
||||
closePhoneEntirely();
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
|
||||
uiManager.setTextButtonCallback("chat1button", [this](const std::string&) {
|
||||
gameState_.chatUnread[0] = false;
|
||||
openPhoneChatFromList(0, isPortraitMode() ? verticalPhoneChat1Root : phoneChat1Root);
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
uiManager.setTextButtonCallback("chat2button", [this](const std::string&) {
|
||||
gameState_.chatUnread[1] = false;
|
||||
openPhoneChatFromList(1, isPortraitMode() ? verticalPhoneChat2Root : phoneChat2Root);
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
uiManager.setTextButtonCallback("chat3button", [this](const std::string&) {
|
||||
gameState_.chatUnread[2] = false;
|
||||
openPhoneChatFromList(2, isPortraitMode() ? verticalPhoneChat3Root : phoneChat3Root);
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -851,11 +889,13 @@ namespace ZL {
|
||||
|
||||
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
|
||||
closePhoneEntirely();
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
|
||||
uiManager.setButtonCallback("buttonBack", [this](const std::string&) {
|
||||
uiManager.popMenu();
|
||||
uiManager.updateAllLayouts();
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -865,15 +905,16 @@ namespace ZL {
|
||||
|
||||
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
|
||||
closePhoneEntirely();
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
|
||||
uiManager.setButtonCallback("buttonBack", [this](const std::string&) {
|
||||
uiManager.popMenu();
|
||||
uiManager.updateAllLayouts();
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
uiManager.setButtonCallback("videoSkip", [this](const std::string&) {
|
||||
closePhoneEntirely();
|
||||
|
||||
if (gameState_.isNight)
|
||||
{
|
||||
startDialogueFunc("dialog_video002");
|
||||
@@ -887,6 +928,7 @@ namespace ZL {
|
||||
}
|
||||
else
|
||||
{
|
||||
audioPlayer_.playSoundAsync("audio/78564__joedeshon__alarm_clock_ticking_02.ogg");
|
||||
startNightTransitionFunc();
|
||||
}
|
||||
}
|
||||
@@ -911,11 +953,13 @@ namespace ZL {
|
||||
|
||||
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
|
||||
closePhoneEntirely();
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
|
||||
uiManager.setButtonCallback("buttonBack", [this](const std::string&) {
|
||||
uiManager.popMenu();
|
||||
uiManager.updateAllLayouts();
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
uiManager.setButtonCallback("mapGo", [this](const std::string&) {
|
||||
gameState_.tutorialNeedOpenTaxiScreen = false;
|
||||
@@ -927,7 +971,10 @@ namespace ZL {
|
||||
gameState_.money -= 500;
|
||||
closePhoneEntirely();
|
||||
if (startDialogueFunc) startDialogueFunc("dialog_taxi002");
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
}
|
||||
|
||||
void MenuManager::openPhoneChatFromList(int chatIndex, std::shared_ptr<UiNode> chatRoot) {
|
||||
@@ -967,10 +1014,12 @@ namespace ZL {
|
||||
|
||||
uiManager.setButtonCallback("phoneExitButton", [this](const std::string&) {
|
||||
closePhoneScreenFromChat();
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
uiManager.setButtonCallback("phoneMain", [this](const std::string&) {});
|
||||
uiManager.setTextButtonCallback("chatTitleButton", [this](const std::string&) {
|
||||
returnToPhoneChatList();
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
});
|
||||
|
||||
if (chatOpenCallback) {
|
||||
@@ -1054,30 +1103,37 @@ namespace ZL {
|
||||
}
|
||||
|
||||
void MenuManager::showModalMenuScreen() {
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
uiManager.pushMenuFromSavedRoot(modalMenuRoot);
|
||||
uiManager.setButtonCallback("modalExitButton", [this](const std::string&) {
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
uiManager.popMenu();
|
||||
uiManager.updateAllLayouts();
|
||||
});
|
||||
|
||||
uiManager.setButtonCallback("menuCloseButton", [this](const std::string&) {
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
uiManager.popMenu();
|
||||
uiManager.updateAllLayouts();
|
||||
});
|
||||
|
||||
uiManager.setButtonCallback("menuSaveButton", [this](const std::string&) {
|
||||
showSaveGameScreen();
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
});
|
||||
|
||||
uiManager.setButtonCallback("menuLoadButton", [this](const std::string&) {
|
||||
showLoadGameScreen();
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
});
|
||||
|
||||
uiManager.setButtonCallback("menuSettingsButton", [this](const std::string&) {
|
||||
showSettingsScreen();
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
});
|
||||
|
||||
uiManager.setButtonCallback("menuExitButton", [this](const std::string&) {
|
||||
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
|
||||
uiManager.popMenu();
|
||||
showMainMenu();
|
||||
});
|
||||
@@ -1441,6 +1497,7 @@ namespace ZL {
|
||||
|
||||
uiManager.setButtonCallback("inventoryExitButton", [this](const std::string&) {
|
||||
closePortraitInventoryItem();
|
||||
audioPlayer_.playSoundAsync("audio/sound_bag001.ogg");
|
||||
});
|
||||
|
||||
const auto& item = items[index];
|
||||
@@ -1468,6 +1525,7 @@ namespace ZL {
|
||||
|
||||
uiManager.setButtonCallback("journalItemExitButton", [this](const std::string&) {
|
||||
closePortraitJournalItem();
|
||||
audioPlayer_.playSoundAsync("audio/255571__stradie__flipping-paper.ogg");
|
||||
});
|
||||
|
||||
Quest::QuestState* quest = gameState_.questJournal.findQuest(visibleQuestIds[index]);
|
||||
@@ -1656,6 +1714,7 @@ namespace ZL {
|
||||
recomputePhoneChatPositions();
|
||||
}
|
||||
chatUiManager.startPopIn(nodeName, 300.0f);
|
||||
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
|
||||
}
|
||||
|
||||
void MenuManager::setDarklandsMode(bool enabled)
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace ZL {
|
||||
ScriptEngine::ScriptEngine() = default;
|
||||
ScriptEngine::~ScriptEngine() = default;
|
||||
|
||||
void ScriptEngine::init(Location* loc, Inventory* inventory, const std::string& scriptPath) {
|
||||
void ScriptEngine::init(Location* loc, Inventory* inventory, AudioPlayerAsync* audioPlayer, const std::string& scriptPath) {
|
||||
impl = std::make_unique<Impl>();
|
||||
sol::state& lua = impl->lua;
|
||||
|
||||
@@ -773,6 +773,14 @@ namespace ZL {
|
||||
}
|
||||
});
|
||||
|
||||
api.set_function("play_sound",
|
||||
[audioPlayer](const std::string& soundPath) -> void {
|
||||
if (audioPlayer)
|
||||
{
|
||||
audioPlayer->playSoundAsync(soundPath);
|
||||
}
|
||||
});
|
||||
|
||||
lua.script_file(scriptPath);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@
|
||||
#include "quest/QuestJournal.h"
|
||||
#include "external/nlohmann/json.hpp"
|
||||
#include "ISaveable.h"
|
||||
#include "AudioPlayerAsync.h"
|
||||
|
||||
namespace ZL {
|
||||
|
||||
@@ -17,7 +18,7 @@ public:
|
||||
~ScriptEngine();
|
||||
|
||||
// Must be called once, after the Game's NPCs are ready.
|
||||
void init(Location* game, Inventory* inventory, const std::string& scriptPath);
|
||||
void init(Location* game, Inventory* inventory, AudioPlayerAsync* audioPlayer, const std::string& scriptPath);
|
||||
|
||||
// Execute a Lua script file. Logs errors to stderr.
|
||||
void runScript(const std::string& path);
|
||||
|
||||
Reference in new issue
Block a user