Skip to content

Commit

Permalink
Added settings for displaying / playing radio messages.
Browse files Browse the repository at this point in the history
- updated gameplay setting screen with flex styling
  • Loading branch information
nkrisztian89 committed Dec 31, 2024
1 parent c136707 commit da2be55
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/config/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.5.5-dev:1249 (2024.12.30.)",
"version": "0.5.5-dev:1250 (2024.12.31.)",
"debugVersion": false,
"logVerbosity": 1,
"platform": "web",
Expand Down
3 changes: 3 additions & 0 deletions src/config/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@
"battle": {
"battleRenderFPS": 60,
"simulationStepsPerSecond": 60,
"showGenericRadioMessages": true,
"playGenericRadioMessages": true,
"playMissionRadioMessages": true,
"showReadyMessage": true,
"particlePoolPrefillFactor": 0.2,
"projectilePoolPrefillFactor": 0.75,
Expand Down
7 changes: 6 additions & 1 deletion src/config/strings/strings-hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,9 @@
"many": "sok",
"easy": "könnyű",
"hard": "nehéz",
"custom": "egyéni"
"custom": "egyéni",
"missionOnly": "csak statikus",
"all": "mindig"
},
"generalSettings": {
"backButton": "Vissza a menübe",
Expand Down Expand Up @@ -855,6 +857,7 @@
"title": "Játékmenet beállítások",
"hudTitle": "HUD",
"cameraTitle": "Kamera",
"radioTitle": "Rádióüzenetek",
"controlsTitle": "Irányítás",
"otherTitle": "Egyéb",
"targetHealthAtCenter": "Célpont állapota mindig középen:",
Expand All @@ -866,6 +869,8 @@
"preferredShipView": "Alapértelmezett hadihajó nézet:",
"demoViewSwitching": "Automatikus nézetváltogatás demo módban:",
"defaultSalvoMode": "Alapértelmezett sortűz mód rakétákhoz:",
"showGenericRadioMessages": "Gépi pilóták dinamikus rádióüzeneteinek kiírása:",
"playRadioMessages": "Rádióüzenetek hangjának lejátszása:",
"showReadyMessage": "Küldetés kezdetén üzenet mutatása:"
},
"controller": {
Expand Down
7 changes: 6 additions & 1 deletion src/config/strings/strings-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,9 @@
"many": "tanti",
"easy": "facile",
"hard": "difficile",
"custom": "personalizzato"
"custom": "personalizzato",
"missionOnly": "non dinamici",
"all": "tutti"
},
"generalSettings": {
"backButton": "Torna al menu",
Expand Down Expand Up @@ -786,6 +788,7 @@
"title": "Impostazioni di gioco",
"hudTitle": "HUD",
"cameraTitle": "Visuale",
"radioTitle": "Messaggi radio",
"controlsTitle": "Controlli",
"otherTitle": "Altre",
"targetHealthAtCenter": "Barra di integrità del bersaglio sempre al centro:",
Expand All @@ -797,6 +800,8 @@
"preferredShipView": "Vista dell'astronave preferita:",
"demoViewSwitching": "Cambio automatico di visuale in modalità dimostrazione:",
"defaultSalvoMode": "Modalità missile in serie per impostazione predefinita:",
"showGenericRadioMessages": "Mostra il testo dei messaggi radio dinamici dei piloti AI:",
"playRadioMessages": "Riproduci la voce fuori campo per i messaggi radio:",
"showReadyMessage": "Mostra messaggio 'pronto' all'inizio delle missioni:"
},
"controller": {
Expand Down
7 changes: 6 additions & 1 deletion src/config/strings/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,9 @@
"many": "many",
"easy": "easy",
"hard": "hard",
"custom": "custom"
"custom": "custom",
"missionOnly": "non-dynamic only",
"all": "all"
},
"generalSettings": {
"backButton": "Back to menu",
Expand Down Expand Up @@ -807,6 +809,7 @@
"title": "Gameplay settings",
"hudTitle": "HUD",
"cameraTitle": "Camera",
"radioTitle": "Radio messages",
"controlsTitle": "Controls",
"otherTitle": "Other",
"targetHealthAtCenter": "Target integrity bar always at center:",
Expand All @@ -818,6 +821,8 @@
"preferredShipView": "Preferred ship view:",
"demoViewSwitching": "Automatic view switching in demo mode:",
"defaultSalvoMode": "Missile salvo mode by default:",
"showGenericRadioMessages": "Show the text of dynamic radio messages by AI pilots:",
"playRadioMessages": "Play the voice-over for radio messages:",
"showReadyMessage": "Show ready message at the start of missions:"
},
"controller": {
Expand Down
37 changes: 22 additions & 15 deletions src/data/screens/gameplay-settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,29 @@
<h1 id="title" class="translatable"></h1>
</div>
<div class="gameplay pageContent">
<div class="gameplaySettingsContainer">
<h2 id="hudTitle" class="translatable settings"></h2>
<div id="hudSettingsDiv" class="contentWide"></div>
<div class="gameplaySettingsColumn">
<div class="gameplaySettingsContainer">
<h2 id="hudTitle" class="translatable settings"></h2>
<div id="hudSettingsDiv" class="contentWide"></div>
</div>
<div class="gameplaySettingsContainer">
<h2 id="controlsTitle" class="translatable settings"></h2>
<div id="controlsSettingsDiv" class="contentWide"></div>
</div>
</div>
<div class="gameplaySettingsContainer">
<h2 id="cameraTitle" class="translatable settings"></h2>
<div id="cameraSettingsDiv" class="contentWide"></div>
</div>
<br>
<div class="gameplaySettingsContainer">
<h2 id="controlsTitle" class="translatable settings"></h2>
<div id="controlsSettingsDiv" class="contentWide"></div>
</div>
<div class="gameplaySettingsContainer">
<h2 id="otherTitle" class="translatable settings"></h2>
<div id="otherSettingsDiv" class="contentWide"></div>
<div class="gameplaySettingsColumn">
<div class="gameplaySettingsContainer">
<h2 id="cameraTitle" class="translatable settings"></h2>
<div id="cameraSettingsDiv" class="contentWide"></div>
</div>
<div class="gameplaySettingsContainer">
<h2 id="radioTitle" class="translatable settings"></h2>
<div id="radioSettingsDiv" class="contentWide"></div>
</div>
<div class="gameplaySettingsContainer">
<h2 id="otherTitle" class="translatable settings"></h2>
<div id="otherSettingsDiv" class="contentWide"></div>
</div>
</div>
</div>
<div class="footer separatorBar">
Expand Down
22 changes: 22 additions & 0 deletions src/js/armada/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,28 @@ define([
type: "number",
defaultValue: 60
},
/**
* Whether to show the text of generic radio messages transmitted by AI pilots in the messages
* panel.
*/
SHOW_GENERIC_RADIO_MESSAGES: {
name: "showGenericRadioMessages",
type: "boolean"
},
/**
* Whether to play the sound samples for the generic radio messages transmitted by AI pilots.
*/
PLAY_GENERIC_RADIO_MESSAGES: {
name: "playGenericRadioMessages",
type: "boolean"
},
/**
* Whether to play the sound samples for the radio messages defined in the mission file.
*/
PLAY_MISSION_RADIO_MESSAGES: {
name: "playMissionRadioMessages",
type: "boolean"
},
/**
* Whether to show the popup infobox with the ready message at the start of battles
*/
Expand Down
75 changes: 54 additions & 21 deletions src/js/armada/screens/battle.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,21 @@ define([
* @type Number
*/
_lastRadioType,
/**
* Cached value of the setting of whether to play the sound effects for generic radio messages.
* @type Boolean
*/
_playGenericRadioMessages,
/**
* Cached value of the setting of whether to play the sound effects for mission radio messages.
* @type Boolean
*/
_playMissionRadioMessages,
/**
* Cached value of the setting of whether to display the text for generic AI radio messages.
* @type Boolean
*/
_showGenericRadioMessages,
/**
* Whether the radio message queue has been updated since its message text has been assembled (we display multiple messages in a merged string)
* @type Boolean
Expand Down Expand Up @@ -1696,21 +1711,29 @@ define([
/** @type DOMHighResTimeStamp */
now,
/** @type Number */
index = -1;
index = -1,
/** @type SoundEffectResource */
resource;
if (_spacecraft && craft && craft.isAlive() && !craft.isAway() && !craft.isHostile(this)) {
now = performance.now();
if ((_messageSource !== this) && ((now - _lastRadioTime > config.getSetting(config.BATTLE_SETTINGS.MIN_VOICE_MESSAGE_DELAY_FOR_SAME_TYPE)) ||
((data.messageType !== _lastRadioType) && (now - _lastRadioTime > config.getSetting(config.BATTLE_SETTINGS.MIN_VOICE_MESSAGE_DELAY_FOR_DIFFERENT_TYPE))))) {
if (!_playingMissionVoiceSound) {
// play the voice sample immediately, regardless of whether or not the text is shown
index = _genericVoiceSounds[data.voice][data.messageType].play(resources.SoundCategory.VOICE) + 1;
message = {
text: strings.get(strings.RADIO.PREFIX, _voiceMessages[data.messageType] + index),
source: this,
silent: true,
queue: RADIO_QUEUE
};
_battleScreen.queueHUDMessage(message, true);
if (_playGenericRadioMessages || _showGenericRadioMessages) {
resource = _genericVoiceSounds[data.voice][data.messageType];
// play the voice sample immediately, regardless of whether or not the text is shown
index = 1 + (_playGenericRadioMessages ?
resource.play(resources.SoundCategory.VOICE) :
resource.getRandomSampleIndex());
message = {
text: strings.get(strings.RADIO.PREFIX, _voiceMessages[data.messageType] + index),
source: this,
silent: _playGenericRadioMessages,
appearAnimation: !_playGenericRadioMessages,
queue: RADIO_QUEUE
};
_battleScreen.queueHUDMessage(message, true);
}
_lastRadioTime = now;
_lastRadioType = data.messageType;
}
Expand Down Expand Up @@ -2806,6 +2829,9 @@ define([
BattleScreen.prototype.setActive = function (active) {
screens.HTMLScreen.prototype.setActive.call(this, active);
if (active) {
_playGenericRadioMessages = config.getBattleSetting(config.BATTLE_SETTINGS.PLAY_GENERIC_RADIO_MESSAGES);
_playMissionRadioMessages = config.getBattleSetting(config.BATTLE_SETTINGS.PLAY_MISSION_RADIO_MESSAGES);
_showGenericRadioMessages = config.getBattleSetting(config.BATTLE_SETTINGS.SHOW_GENERIC_RADIO_MESSAGES);
if (WAKE_LOCK_SUPPORTED && !_wakeLock) {
navigator.wakeLock.request("screen").then(function (wakeLock) {
_wakeLock = wakeLock;
Expand Down Expand Up @@ -3912,16 +3938,18 @@ define([
if (messageQueue[0].new) {
_playingMissionVoiceSound = false;
// playing the voice-over for this message if it exists
if (_missionVoiceSounds[messageQueue[0].id]) {
_missionVoiceSounds[messageQueue[0].id].play(resources.SoundCategory.VOICE, undefined, undefined, undefined, true);
_playingMissionVoiceSound = true;
messageQueue[0].silent = true;
} else if (messageQueue[0].source) {
j = ai.getVoiceOfSpacecraft(messageQueue[0].source);
if ((j >= 0) && _missionPilotVoiceSounds[j][messageQueue[0].id]) {
_missionPilotVoiceSounds[j][messageQueue[0].id].play(resources.SoundCategory.VOICE, undefined, undefined, undefined, true);
if (_playMissionRadioMessages) {
if (_missionVoiceSounds[messageQueue[0].id]) {
_missionVoiceSounds[messageQueue[0].id].play(resources.SoundCategory.VOICE, undefined, undefined, undefined, true);
_playingMissionVoiceSound = true;
messageQueue[0].silent = true;
} else if (messageQueue[0].source) {
j = ai.getVoiceOfSpacecraft(messageQueue[0].source);
if ((j >= 0) && _missionPilotVoiceSounds[j][messageQueue[0].id]) {
_missionPilotVoiceSounds[j][messageQueue[0].id].play(resources.SoundCategory.VOICE, undefined, undefined, undefined, true);
_playingMissionVoiceSound = true;
messageQueue[0].silent = true;
}
}
}
// playing the generic short message sound
Expand All @@ -3930,6 +3958,7 @@ define([
}
messageQueue[0].new = false;
}
skip = false;
// setting text
if (MESSAGE_QUEUES[i] === RADIO_QUEUE) {
// for the radio queue, multiple messages are displayed together
Expand All @@ -3944,7 +3973,12 @@ define([
j--;
}
}
_messageText.setText(text);
if (_showGenericRadioMessages) {
_messageText.setText(text);
} else {
_messageText.setText("");
skip = true;
}
_radioQueueChanged = false;
}
} else {
Expand Down Expand Up @@ -3975,9 +4009,8 @@ define([
}
_messageText.setColor(color);
// transmission source
_messageSource = messageQueue[0].source;
_messageSource = (messageQueue[0].timeLeft > 0) ? messageQueue[0].source : null;
// managing timing
skip = false;
if (!messageQueue[0].permanent) {
if ((messageQueue[0] === _newHostilesMessage)) {
messageQueue[0].timeLeft = _newHostilesAlertTimeLeft;
Expand Down
Loading

0 comments on commit da2be55

Please sign in to comment.