k-key to switch off sound while waiting for players in connected state too. Sound is automatically switched on if a new player connects, just like in custom menu. By this you can wait in headless servers without hearing music/missing players.
This commit is contained in:
parent
81cc68305c
commit
f89707f708
|
@ -62,6 +62,8 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
||||||
broadcastServerSettingsDelayTimer=0;
|
broadcastServerSettingsDelayTimer=0;
|
||||||
lastGameSettingsReceivedCount=0;
|
lastGameSettingsReceivedCount=0;
|
||||||
|
|
||||||
|
soundConnectionCount=0;
|
||||||
|
|
||||||
this->factionVideo = NULL;
|
this->factionVideo = NULL;
|
||||||
currentTechName_factionPreview="";
|
currentTechName_factionPreview="";
|
||||||
currentFactionName_factionPreview="";
|
currentFactionName_factionPreview="";
|
||||||
|
@ -404,6 +406,10 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
||||||
buttonRestoreLastSettings.init(480, 180, 220);
|
buttonRestoreLastSettings.init(480, 180, 220);
|
||||||
buttonRestoreLastSettings.setText(lang.get("ReloadLastGameSettings"));
|
buttonRestoreLastSettings.setText(lang.get("ReloadLastGameSettings"));
|
||||||
|
|
||||||
|
// write hint to console:
|
||||||
|
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||||
|
|
||||||
|
console.addLine(lang.get("To switch off music press") + " - \"" + configKeys.getString("ToggleMusic") + "\"");
|
||||||
chatManager.init(&console, -1,true);
|
chatManager.init(&console, -1,true);
|
||||||
|
|
||||||
GraphicComponent::applyAllCustomProperties(containerName);
|
GraphicComponent::applyAllCustomProperties(containerName);
|
||||||
|
@ -2532,6 +2538,27 @@ void MenuStateConnectedGame::update() {
|
||||||
//console732
|
//console732
|
||||||
console.update();
|
console.update();
|
||||||
|
|
||||||
|
// check for need to switch music on again
|
||||||
|
GameSettings *gameSettings = clientInterface->getGameSettingsPtr();
|
||||||
|
int currentConnectionCount=0;
|
||||||
|
for(int i=0; i < GameConstants::maxPlayers; ++i) {
|
||||||
|
if(gameSettings->getNetworkPlayerName(i) != "" &&
|
||||||
|
gameSettings->getNetworkPlayerName(i) != GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME)
|
||||||
|
{
|
||||||
|
currentConnectionCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(currentConnectionCount > soundConnectionCount){
|
||||||
|
soundConnectionCount = currentConnectionCount;
|
||||||
|
SoundRenderer::getInstance().playFx(CoreData::getInstance().getAttentionSound());
|
||||||
|
//switch on music again!!
|
||||||
|
Config &config = Config::getInstance();
|
||||||
|
float configVolume = (config.getInt("SoundVolumeMusic") / 100.f);
|
||||||
|
CoreData::getInstance().getMenuMusic()->setVolume(configVolume);
|
||||||
|
}
|
||||||
|
soundConnectionCount = currentConnectionCount;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(const runtime_error &ex) {
|
catch(const runtime_error &ex) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
|
@ -2707,6 +2734,23 @@ void MenuStateConnectedGame::keyDown(SDL_KeyboardEvent key) {
|
||||||
if(isKeyPressed(configKeys.getSDLKey("ShowFullConsole"),key) == true) {
|
if(isKeyPressed(configKeys.getSDLKey("ShowFullConsole"),key) == true) {
|
||||||
showFullConsole= true;
|
showFullConsole= true;
|
||||||
}
|
}
|
||||||
|
else if(isKeyPressed(configKeys.getSDLKey("ToggleMusic"),key) == true) {
|
||||||
|
Config &config = Config::getInstance();
|
||||||
|
Lang &lang= Lang::getInstance();
|
||||||
|
|
||||||
|
float configVolume = (config.getInt("SoundVolumeMusic") / 100.f);
|
||||||
|
float currentVolume = CoreData::getInstance().getMenuMusic()->getVolume();
|
||||||
|
if(currentVolume > 0) {
|
||||||
|
CoreData::getInstance().getMenuMusic()->setVolume(0.f);
|
||||||
|
console.addLine(lang.get("GameMusic") + " " + lang.get("Off"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
CoreData::getInstance().getMenuMusic()->setVolume(configVolume);
|
||||||
|
//If the config says zero, use the default music volume
|
||||||
|
//gameMusic->setVolume(configVolume ? configVolume : 0.9);
|
||||||
|
console.addLine(lang.get("GameMusic"));
|
||||||
|
}
|
||||||
|
}
|
||||||
//else if(key == configKeys.getCharKey("SaveGUILayout")) {
|
//else if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||||
else if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
else if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
||||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
||||||
|
|
|
@ -103,6 +103,8 @@ private:
|
||||||
time_t lastSetChangedGameSettings;
|
time_t lastSetChangedGameSettings;
|
||||||
bool updateDataSynchDetailText;
|
bool updateDataSynchDetailText;
|
||||||
|
|
||||||
|
int soundConnectionCount;
|
||||||
|
|
||||||
//Console console;
|
//Console console;
|
||||||
ChatManager chatManager;
|
ChatManager chatManager;
|
||||||
bool showFullConsole;
|
bool showFullConsole;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user