sound effects if new servers are available or player joins. ( new data attention.wav is needed !)

menu navigation is corrected.
camera movement for new menues ( new menu.xml needed! )
This commit is contained in:
Titus Tscharntke 2010-05-16 16:40:21 +00:00
parent 3ba034b8bf
commit a6992ee686
7 changed files with 61 additions and 20 deletions

View File

@ -148,6 +148,7 @@ void CoreData::load(){
clickSoundA.load(dir+"/menu/sound/click_a.wav");
clickSoundB.load(dir+"/menu/sound/click_b.wav");
clickSoundC.load(dir+"/menu/sound/click_c.wav");
attentionSound.load(dir+"/menu/sound/attention.wav");
introMusic.open(dir+"/menu/music/intro_music.ogg");
introMusic.setNext(&menuMusic);
menuMusic.open(dir+"/menu/music/menu_music.ogg");

View File

@ -39,7 +39,8 @@ private:
StrSound menuMusic;
StaticSound clickSoundA;
StaticSound clickSoundB;
StaticSound clickSoundC;
StaticSound clickSoundC;
StaticSound attentionSound;
SoundContainer waterSounds;
Texture2D *logoTexture;
@ -78,6 +79,7 @@ public:
StaticSound *getClickSoundA() {return &clickSoundA;}
StaticSound *getClickSoundB() {return &clickSoundB;}
StaticSound *getClickSoundC() {return &clickSoundC;}
StaticSound *getAttentionSound() {return &attentionSound;}
StaticSound *getWaterSound() {return waterSounds.getRandSound();}
Font2D *getDisplayFont() const {return displayFont;}

View File

@ -46,7 +46,7 @@ struct FormatString {
// =====================================================
MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainMenu,JoinMenu joinMenuInfo, bool openNetworkSlots):
MenuState(program, mainMenu, "join-game") //← set on connected-game
MenuState(program, mainMenu, "connected-game") //← set on connected-game
{
returnMenuInfo=joinMenuInfo;
Lang &lang= Lang::getInstance();

View File

@ -16,6 +16,7 @@
#include "core_data.h"
#include "config.h"
#include "menu_state_new_game.h"
#include "menu_state_masterserver.h"
#include "metrics.h"
#include "network_manager.h"
#include "network_message.h"
@ -45,18 +46,20 @@ struct FormatString {
// class MenuStateCustomGame
// =====================================================
MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, bool openNetworkSlots):
MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, bool openNetworkSlots,bool parentMenuIsMasterserver):
MenuState(program, mainMenu, "new-game")
{
Lang &lang= Lang::getInstance();
NetworkManager &networkManager= NetworkManager::getInstance();
Config &config = Config::getInstance();
parentMenuIsMs=parentMenuIsMasterserver;
needToSetChangedGameSettings = false;
needToRepublishToMasterserver = false;
needToBroadcastServerSettings = false;
lastSetChangedGameSettings = time(NULL);
lastMasterserverPublishing = time(NULL);
soundConnectionCount=0;
vector<string> teamItems, controlItems, results;
@ -226,6 +229,22 @@ MenuStateCustomGame::~MenuStateCustomGame() {
publishToMasterserverThread = NULL;
}
void MenuStateCustomGame::returnToParentMenu(){
needToBroadcastServerSettings = false;
needToRepublishToMasterserver = false;
BaseThread::shutdownAndWait(publishToMasterserverThread);
if(parentMenuIsMs)
{
mainMenu->setState(new MenuStateMasterserver(program, mainMenu));
}
else
{
mainMenu->setState(new MenuStateNewGame(program, mainMenu));
}
}
void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
CoreData &coreData= CoreData::getInstance();
@ -246,11 +265,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
simpleTask();
}
*/
needToBroadcastServerSettings = false;
needToRepublishToMasterserver = false;
BaseThread::shutdownAndWait(publishToMasterserverThread);
mainMenu->setState(new MenuStateNewGame(program, mainMenu));
returnToParentMenu();
}
else if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -482,6 +497,7 @@ void MenuStateCustomGame::update()
bool haveAtLeastOneNetworkClientConnected = false;
bool hasOneNetworkSlotOpen = false;
int currentConnectionCount=0;
Config &config = Config::getInstance();
@ -549,6 +565,7 @@ void MenuStateCustomGame::update()
if(connectionSlot->isConnected())
{
haveAtLeastOneNetworkClientConnected = true;
currentConnectionCount++;
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] B - ctNetwork\n",__FILE__,__FUNCTION__);
string label = connectionSlot->getName();
@ -684,6 +701,11 @@ void MenuStateCustomGame::update()
lastSetChangedGameSettings = time(NULL);
}
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(currentConnectionCount>soundConnectionCount){
SoundRenderer::getInstance().playFx(CoreData::getInstance().getAttentionSound());
}
soundConnectionCount=currentConnectionCount;
}
catch(const std::exception &ex) {
char szBuf[1024]="";

View File

@ -17,7 +17,6 @@
#include "simple_threads.h"
namespace Glest{ namespace Game{
// ===============================
// class MenuStateCustomGame
// ===============================
@ -59,12 +58,15 @@ private:
bool needToBroadcastServerSettings;
string publishToServerInfo;
SimpleTaskThread *publishToMasterserverThread;
bool parentMenuIsMs;
bool soundConnectionCount;
Console console;
ChatManager chatManager;
public:
MenuStateCustomGame(Program *program, MainMenu *mainMenu, bool openNetworkSlots= false);
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,bool openNetworkSlots= false, bool parentMenuIsMasterserver=false);
~MenuStateCustomGame();
void mouseClick(int x, int y, MouseButton mouseButton);
@ -87,6 +89,7 @@ private:
void closeUnusedSlots();
void updateNetworkSlots();
void publishToMasterserver();
void returnToParentMenu();
};
}}//end namespace

View File

@ -125,12 +125,13 @@ void ServerLine::render(){
// =====================================================
MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMenu):
MenuState(program, mainMenu, "root") //← set on masterserver
MenuState(program, mainMenu, "masterserver")
{
Lang &lang= Lang::getInstance();
autoRefreshTime=0;
playServerFoundSound=false;
mainMessageBox.init(lang.get("Ok"));
mainMessageBox.setEnabled(false);
lastRefreshTimer= time(NULL);
@ -155,10 +156,10 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
labelAutoRefresh.setText(lang.get("AutoRefreshRate"));
labelAutoRefresh.init(800,100);
listBoxAutoRefresh.init(800,70);
listBoxAutoRefresh.pushBackItem(lang.get("off"));
listBoxAutoRefresh.pushBackItem("1");
listBoxAutoRefresh.pushBackItem("2");
listBoxAutoRefresh.pushBackItem("3");
listBoxAutoRefresh.pushBackItem(lang.get("Off"));
listBoxAutoRefresh.pushBackItem("10 s");
listBoxAutoRefresh.pushBackItem("20 s");
listBoxAutoRefresh.pushBackItem("30 s");
listBoxAutoRefresh.setSelectedItemIndex(0);
NetworkManager::getInstance().end();
@ -216,7 +217,7 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
soundRenderer.playFx(coreData.getClickSoundB());
BaseThread::shutdownAndWait(updateFromMasterserverThread);
mainMenu->setState(new MenuStateCustomGame(program, mainMenu));
mainMenu->setState(new MenuStateCustomGame(program, mainMenu,true,true));
}
else if(listBoxAutoRefresh.mouseClick(x, y)){
soundRenderer.playFx(coreData.getClickSoundA());
@ -273,6 +274,12 @@ void MenuStateMasterserver::update(){
needUpdateFromServer = true;
lastRefreshTimer= time(NULL);
}
if(playServerFoundSound)
{
SoundRenderer::getInstance().playFx(CoreData::getInstance().getAttentionSound());
playServerFoundSound=false;
}
if(threadedErrorMsg != "") {
std::string sError = threadedErrorMsg;
@ -297,10 +304,11 @@ void MenuStateMasterserver::simpleTask() {
void MenuStateMasterserver::updateServerInfo() {
try {
needUpdateFromServer = false;
//MasterServerInfos masterServerInfos;
int numberOfOldServerLines=serverLines.size();
clearServerLines();
//throw runtime_error("test");
if(Config::getInstance().getString("Masterserver","") != "") {
std::string serverInfo = SystemFlags::getHTTP(Config::getInstance().getString("Masterserver")+"showServersForGlest.php");
@ -336,7 +344,11 @@ void MenuStateMasterserver::updateServerInfo() {
}
}
}
//masterServerInfos.push_back(masterServerInfo);
if(serverLines.size()>numberOfOldServerLines)
{
playServerFoundSound=true;
}
}
catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d, error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());

View File

@ -82,6 +82,7 @@ private:
int autoRefreshTime;
time_t lastRefreshTimer;
SimpleTaskThread *updateFromMasterserverThread;
bool playServerFoundSound;
static DisplayMessageFunction pCB_DisplayMessage;
std::string threadedErrorMsg;