some chat changes and custom game with NetworkFramePeriod
This commit is contained in:
parent
10202792a3
commit
d14f013491
|
@ -26,7 +26,7 @@ using namespace Shared::Platform;
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
const string mailString= "contact_game@glest.org";
|
const string mailString= "contact_game@glest.org";
|
||||||
const string glestVersionString= "v3.3.5-alpha3";
|
const string glestVersionString= "v3.3.5-alpha5";
|
||||||
|
|
||||||
string getCrashDumpFileName(){
|
string getCrashDumpFileName(){
|
||||||
return "glest" + glestVersionString + ".dmp";
|
return "glest" + glestVersionString + ".dmp";
|
||||||
|
|
|
@ -93,19 +93,29 @@ void ChatManager::keyDown(char key){
|
||||||
}
|
}
|
||||||
|
|
||||||
if(key==vkReturn){
|
if(key==vkReturn){
|
||||||
if(editEnabled){
|
SDL_keysym keystate = Window::getKeystate();
|
||||||
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
|
if(keystate.mod & (KMOD_LALT | KMOD_RALT)){
|
||||||
|
// alt+enter is ignored
|
||||||
editEnabled= false;
|
|
||||||
if(!text.empty()) {
|
|
||||||
console->addLine(Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + ": " + text);
|
|
||||||
gameNetworkInterface->sendTextMessage(Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + ": "+
|
|
||||||
text, teamMode? thisTeamIndex: -1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
editEnabled= true;
|
{
|
||||||
text.clear();
|
if(editEnabled){
|
||||||
|
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
|
||||||
|
if(!text.empty()) {
|
||||||
|
console->addLine(Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + ": " + text);
|
||||||
|
gameNetworkInterface->sendTextMessage(Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + ": "+
|
||||||
|
text, teamMode? thisTeamIndex: -1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
editEnabled= false;
|
||||||
|
}
|
||||||
|
text.clear();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
editEnabled= true;
|
||||||
|
text.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(key==vkBack){
|
else if(key==vkBack){
|
||||||
|
|
|
@ -150,6 +150,10 @@ void MainMenu::keyDown(char key){
|
||||||
state->keyDown(key);
|
state->keyDown(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainMenu::keyUp(char key){
|
||||||
|
state->keyUp(key);
|
||||||
|
}
|
||||||
|
|
||||||
void MainMenu::keyPress(char c){
|
void MainMenu::keyPress(char c){
|
||||||
state->keyPress(c);
|
state->keyPress(c);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,8 +91,9 @@ public:
|
||||||
virtual void mouseDownLeft(int x, int y);
|
virtual void mouseDownLeft(int x, int y);
|
||||||
virtual void mouseDownRight(int x, int y);
|
virtual void mouseDownRight(int x, int y);
|
||||||
virtual void keyDown(char key);
|
virtual void keyDown(char key);
|
||||||
|
virtual void keyUp(char key);
|
||||||
virtual void keyPress(char key);
|
virtual void keyPress(char key);
|
||||||
|
|
||||||
void setState(MenuState *state);
|
void setState(MenuState *state);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -117,6 +118,7 @@ public:
|
||||||
virtual void update(){};
|
virtual void update(){};
|
||||||
virtual void keyDown(char key){};
|
virtual void keyDown(char key){};
|
||||||
virtual void keyPress(char c){};
|
virtual void keyPress(char c){};
|
||||||
|
virtual void keyUp(char key){};
|
||||||
|
|
||||||
const Camera *getCamera() const {return &camera;}
|
const Camera *getCamera() const {return &camera;}
|
||||||
};
|
};
|
||||||
|
|
|
@ -380,7 +380,7 @@ void MenuStateConnectedGame::render(){
|
||||||
renderer.renderListBox(&listBoxTechTree);
|
renderer.renderListBox(&listBoxTechTree);
|
||||||
|
|
||||||
renderer.renderChatManager(&chatManager);
|
renderer.renderChatManager(&chatManager);
|
||||||
renderer.renderConsole(&console);
|
renderer.renderConsole(&console,true);
|
||||||
}
|
}
|
||||||
catch(const std::exception &ex) {
|
catch(const std::exception &ex) {
|
||||||
char szBuf[1024]="";
|
char szBuf[1024]="";
|
||||||
|
@ -762,4 +762,9 @@ void MenuStateConnectedGame::keyPress(char c)
|
||||||
chatManager.keyPress(c);
|
chatManager.keyPress(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuStateConnectedGame::keyUp(char key)
|
||||||
|
{
|
||||||
|
chatManager.keyUp(key);
|
||||||
|
}
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -82,6 +82,7 @@ public:
|
||||||
|
|
||||||
virtual void keyDown(char key);
|
virtual void keyDown(char key);
|
||||||
virtual void keyPress(char c);
|
virtual void keyPress(char c);
|
||||||
|
virtual void keyUp(char key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -78,9 +78,9 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
vector<string> teamItems, controlItems, results;
|
vector<string> teamItems, controlItems, results;
|
||||||
|
|
||||||
//create
|
//create
|
||||||
buttonReturn.init(300, 180, 125);
|
buttonReturn.init(250, 180, 125);
|
||||||
buttonRestoreLastSettings.init(440, 180, 125);
|
buttonRestoreLastSettings.init(250+130, 180, 200);
|
||||||
buttonPlayNow.init(580, 180, 125);
|
buttonPlayNow.init(250+130+205, 180, 125);
|
||||||
|
|
||||||
int setupPos=610;
|
int setupPos=610;
|
||||||
int mapHeadPos=330;
|
int mapHeadPos=330;
|
||||||
|
@ -151,9 +151,9 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
labelTechTree.init(600, mapHeadPos);
|
labelTechTree.init(600, mapHeadPos);
|
||||||
|
|
||||||
|
|
||||||
labelPublishServer.init(300, networkHeadPos, 100);
|
labelPublishServer.init(190, networkHeadPos, 100);
|
||||||
labelPublishServer.setText(lang.get("PublishServer"));
|
labelPublishServer.setText(lang.get("PublishServer"));
|
||||||
listBoxPublishServer.init(300, networkPos, 100);
|
listBoxPublishServer.init(200, networkPos, 100);
|
||||||
listBoxPublishServer.pushBackItem(lang.get("Yes"));
|
listBoxPublishServer.pushBackItem(lang.get("Yes"));
|
||||||
listBoxPublishServer.pushBackItem(lang.get("No"));
|
listBoxPublishServer.pushBackItem(lang.get("No"));
|
||||||
if(openNetworkSlots)
|
if(openNetworkSlots)
|
||||||
|
@ -161,14 +161,26 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
else
|
else
|
||||||
listBoxPublishServer.setSelectedItemIndex(1);
|
listBoxPublishServer.setSelectedItemIndex(1);
|
||||||
|
|
||||||
|
// Network Frame Period
|
||||||
|
labelNetworkFramePeriod.init(440, networkHeadPos, 80);
|
||||||
|
labelNetworkFramePeriod.setText(lang.get("NetworkFramePeriod"));
|
||||||
|
listBoxNetworkFramePeriod.init(450, networkPos, 80);
|
||||||
|
listBoxNetworkFramePeriod.pushBackItem("10");
|
||||||
|
listBoxNetworkFramePeriod.pushBackItem("20");
|
||||||
|
listBoxNetworkFramePeriod.pushBackItem("30");
|
||||||
|
listBoxNetworkFramePeriod.pushBackItem("40");
|
||||||
|
listBoxNetworkFramePeriod.setSelectedItem("20");
|
||||||
|
|
||||||
|
|
||||||
// Enable Server Controlled AI
|
// Enable Server Controlled AI
|
||||||
labelEnableServerControlledAI.init(600, networkHeadPos, 80);
|
labelEnableServerControlledAI.init(690, networkHeadPos, 80);
|
||||||
listBoxEnableServerControlledAI.init(600, networkPos, 80);
|
labelEnableServerControlledAI.setText(lang.get("EnableServerControlledAI"));
|
||||||
|
listBoxEnableServerControlledAI.init(700, networkPos, 80);
|
||||||
listBoxEnableServerControlledAI.pushBackItem(lang.get("Yes"));
|
listBoxEnableServerControlledAI.pushBackItem(lang.get("Yes"));
|
||||||
listBoxEnableServerControlledAI.pushBackItem(lang.get("No"));
|
listBoxEnableServerControlledAI.pushBackItem(lang.get("No"));
|
||||||
listBoxEnableServerControlledAI.setSelectedItemIndex(0);
|
listBoxEnableServerControlledAI.setSelectedItemIndex(0);
|
||||||
|
|
||||||
labelNetworkFramePeriod.init(420, networkHeadPos, 80);
|
|
||||||
|
|
||||||
//list boxes
|
//list boxes
|
||||||
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
||||||
|
@ -242,7 +254,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
labelTeam.setText(lang.get("Team"));
|
labelTeam.setText(lang.get("Team"));
|
||||||
|
|
||||||
labelEnableObserverMode.setText(lang.get("EnableObserverMode"));
|
labelEnableObserverMode.setText(lang.get("EnableObserverMode"));
|
||||||
labelEnableServerControlledAI.setText(lang.get("EnableServerControlledAI"));
|
|
||||||
|
|
||||||
loadMapInfo(Map::getMapPath(mapFiles[listBoxMap.getSelectedItemIndex()]), &mapInfo);
|
loadMapInfo(Map::getMapPath(mapFiles[listBoxMap.getSelectedItemIndex()]), &mapInfo);
|
||||||
|
|
||||||
|
@ -273,8 +285,6 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
labelNetworkFramePeriod.setText(lang.get("NetworkFramePeriod") + " " + intToStr(gameSettings.getNetworkFramePeriod()));
|
|
||||||
|
|
||||||
//chatManager.init(&console, world.getThisTeamIndex());
|
//chatManager.init(&console, world.getThisTeamIndex());
|
||||||
chatManager.init(&console, -1);
|
chatManager.init(&console, -1);
|
||||||
|
|
||||||
|
@ -516,6 +526,10 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
needToRepublishToMasterserver = true;
|
needToRepublishToMasterserver = true;
|
||||||
soundRenderer.playFx(coreData.getClickSoundC());
|
soundRenderer.playFx(coreData.getClickSoundC());
|
||||||
}
|
}
|
||||||
|
else if(listBoxNetworkFramePeriod.mouseClick(x, y)){
|
||||||
|
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||||
|
soundRenderer.playFx(coreData.getClickSoundC());
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
for(int i=0; i<mapInfo.players; ++i) {
|
for(int i=0; i<mapInfo.players; ++i) {
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||||
|
@ -601,6 +615,7 @@ void MenuStateCustomGame::mouseMove(int x, int y, const MouseState *ms){
|
||||||
listBoxEnableObserverMode.mouseMove(x, y);
|
listBoxEnableObserverMode.mouseMove(x, y);
|
||||||
listBoxEnableServerControlledAI.mouseMove(x, y);
|
listBoxEnableServerControlledAI.mouseMove(x, y);
|
||||||
labelNetworkFramePeriod.mouseMove(x, y);
|
labelNetworkFramePeriod.mouseMove(x, y);
|
||||||
|
listBoxNetworkFramePeriod.mouseMove(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::render(){
|
void MenuStateCustomGame::render(){
|
||||||
|
@ -646,7 +661,7 @@ void MenuStateCustomGame::render(){
|
||||||
renderer.renderListBox(&listBoxEnableObserverMode);
|
renderer.renderListBox(&listBoxEnableObserverMode);
|
||||||
|
|
||||||
renderer.renderChatManager(&chatManager);
|
renderer.renderChatManager(&chatManager);
|
||||||
renderer.renderConsole(&console);
|
renderer.renderConsole(&console,true);
|
||||||
if(listBoxPublishServer.getEditable())
|
if(listBoxPublishServer.getEditable())
|
||||||
{
|
{
|
||||||
renderer.renderListBox(&listBoxPublishServer);
|
renderer.renderListBox(&listBoxPublishServer);
|
||||||
|
@ -654,6 +669,7 @@ void MenuStateCustomGame::render(){
|
||||||
renderer.renderListBox(&listBoxEnableServerControlledAI);
|
renderer.renderListBox(&listBoxEnableServerControlledAI);
|
||||||
renderer.renderLabel(&labelEnableServerControlledAI);
|
renderer.renderLabel(&labelEnableServerControlledAI);
|
||||||
renderer.renderLabel(&labelNetworkFramePeriod);
|
renderer.renderLabel(&labelNetworkFramePeriod);
|
||||||
|
renderer.renderListBox(&listBoxNetworkFramePeriod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1136,7 +1152,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
||||||
}
|
}
|
||||||
gameSettings->setFactionCount(factionCount);
|
gameSettings->setFactionCount(factionCount);
|
||||||
gameSettings->setEnableServerControlledAI(listBoxEnableServerControlledAI.getSelectedItemIndex() == 0);
|
gameSettings->setEnableServerControlledAI(listBoxEnableServerControlledAI.getSelectedItemIndex() == 0);
|
||||||
|
gameSettings->setNetworkFramePeriod((listBoxNetworkFramePeriod.getSelectedItemIndex()+1)*10);
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] gameSettings->getTileset() = [%s]\n",__FILE__,__FUNCTION__,gameSettings->getTileset().c_str());
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] gameSettings->getTileset() = [%s]\n",__FILE__,__FUNCTION__,gameSettings->getTileset().c_str());
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] gameSettings->getTech() = [%s]\n",__FILE__,__FUNCTION__,gameSettings->getTech().c_str());
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] gameSettings->getTech() = [%s]\n",__FILE__,__FUNCTION__,gameSettings->getTech().c_str());
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] gameSettings->getMap() = [%s]\n",__FILE__,__FUNCTION__,gameSettings->getMap().c_str());
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] gameSettings->getMap() = [%s]\n",__FILE__,__FUNCTION__,gameSettings->getMap().c_str());
|
||||||
|
@ -1222,7 +1238,7 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
|
||||||
gameSettings.setFogOfWar(properties.getBool("FogOfWar"));
|
gameSettings.setFogOfWar(properties.getBool("FogOfWar"));
|
||||||
gameSettings.setEnableObserverModeAtEndGame(properties.getBool("EnableObserverModeAtEndGame"));
|
gameSettings.setEnableObserverModeAtEndGame(properties.getBool("EnableObserverModeAtEndGame"));
|
||||||
gameSettings.setEnableServerControlledAI(properties.getBool("EnableServerControlledAI","false"));
|
gameSettings.setEnableServerControlledAI(properties.getBool("EnableServerControlledAI","false"));
|
||||||
gameSettings.setNetworkFramePeriod(properties.getBool("NetworkFramePeriod",intToStr(GameConstants::networkFramePeriod).c_str()));
|
gameSettings.setNetworkFramePeriod(properties.getInt("NetworkFramePeriod",intToStr(GameConstants::networkFramePeriod).c_str())/10*10);
|
||||||
|
|
||||||
gameSettings.setThisFactionIndex(properties.getInt("FactionThisFactionIndex"));
|
gameSettings.setThisFactionIndex(properties.getInt("FactionThisFactionIndex"));
|
||||||
gameSettings.setFactionCount(properties.getInt("FactionCount"));
|
gameSettings.setFactionCount(properties.getInt("FactionCount"));
|
||||||
|
@ -1265,7 +1281,9 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
|
||||||
listBoxEnableObserverMode.setSelectedItem(gameSettings.getEnableObserverModeAtEndGame() == true ? lang.get("Yes") : lang.get("No"));
|
listBoxEnableObserverMode.setSelectedItem(gameSettings.getEnableObserverModeAtEndGame() == true ? lang.get("Yes") : lang.get("No"));
|
||||||
listBoxEnableServerControlledAI.setSelectedItem(gameSettings.getEnableServerControlledAI() == true ? lang.get("Yes") : lang.get("No"));
|
listBoxEnableServerControlledAI.setSelectedItem(gameSettings.getEnableServerControlledAI() == true ? lang.get("Yes") : lang.get("No"));
|
||||||
|
|
||||||
labelNetworkFramePeriod.setText(lang.get("NetworkFramePeriod") + " " + intToStr(gameSettings.getNetworkFramePeriod()));
|
labelNetworkFramePeriod.setText(lang.get("NetworkFramePeriod"));
|
||||||
|
|
||||||
|
listBoxNetworkFramePeriod.setSelectedItem(intToStr(gameSettings.getNetworkFramePeriod()/10*10));
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
@ -1483,6 +1501,11 @@ void MenuStateCustomGame::keyPress(char c)
|
||||||
chatManager.keyPress(c);
|
chatManager.keyPress(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuStateCustomGame::keyUp(char key)
|
||||||
|
{
|
||||||
|
chatManager.keyUp(key);
|
||||||
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::showMessageBox(const string &text, const string &header, bool toggle){
|
void MenuStateCustomGame::showMessageBox(const string &text, const string &header, bool toggle){
|
||||||
if(!toggle){
|
if(!toggle){
|
||||||
mainMessageBox.setEnabled(false);
|
mainMessageBox.setEnabled(false);
|
||||||
|
|
|
@ -36,7 +36,7 @@ private:
|
||||||
GraphicLabel labelMapInfo;
|
GraphicLabel labelMapInfo;
|
||||||
GraphicLabel labelEnableObserverMode;
|
GraphicLabel labelEnableObserverMode;
|
||||||
GraphicLabel labelEnableServerControlledAI;
|
GraphicLabel labelEnableServerControlledAI;
|
||||||
GraphicLabel labelNetworkFramePeriod;
|
|
||||||
|
|
||||||
GraphicListBox listBoxMap;
|
GraphicListBox listBoxMap;
|
||||||
GraphicListBox listBoxFogOfWar;
|
GraphicListBox listBoxFogOfWar;
|
||||||
|
@ -62,6 +62,9 @@ private:
|
||||||
GraphicMessageBox mainMessageBox;
|
GraphicMessageBox mainMessageBox;
|
||||||
int mainMessageBoxState;
|
int mainMessageBoxState;
|
||||||
|
|
||||||
|
GraphicListBox listBoxNetworkFramePeriod;
|
||||||
|
GraphicLabel labelNetworkFramePeriod;
|
||||||
|
|
||||||
|
|
||||||
bool needToSetChangedGameSettings;
|
bool needToSetChangedGameSettings;
|
||||||
time_t lastSetChangedGameSettings;
|
time_t lastSetChangedGameSettings;
|
||||||
|
@ -92,6 +95,8 @@ public:
|
||||||
|
|
||||||
virtual void keyDown(char key);
|
virtual void keyDown(char key);
|
||||||
virtual void keyPress(char c);
|
virtual void keyPress(char c);
|
||||||
|
virtual void keyUp(char key);
|
||||||
|
|
||||||
|
|
||||||
virtual void simpleTask();
|
virtual void simpleTask();
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,7 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float width = static_cast<float> (fontInfo->per_char[p].rbearing - fontInfo->per_char[p].lbearing);
|
float width = static_cast<float>(fontInfo->per_char[p].width); //( fontInfo->per_char[p].rbearing - fontInfo->per_char[p].lbearing);
|
||||||
if(width <= 0) {
|
if(width <= 0) {
|
||||||
width = static_cast<float>(6);
|
width = static_cast<float>(6);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue