- cleanup of console and button placement in load game menu

This commit is contained in:
Mark Vejvoda
2012-03-20 15:01:18 +00:00
parent 92b135d103
commit 1b8e1af25b
3 changed files with 32 additions and 13 deletions

View File

@@ -48,15 +48,29 @@ void Console::resetFonts() {
font3D=CoreData::getInstance().getConsoleFont3D(); font3D=CoreData::getInstance().getConsoleFont3D();
} }
void Console::addStdMessage(const string &s) { void Console::addStdMessage(const string &s,bool clearOtherLines) {
addLine(Lang::getInstance().get(s)); if(clearOtherLines == true) {
addLineOnly(Lang::getInstance().get(s));
}
else {
addLine(Lang::getInstance().get(s));
}
} }
void Console::addStdScenarioMessage(const string &s) { void Console::addStdScenarioMessage(const string &s,bool clearOtherLines) {
addLine(Lang::getInstance().getScenarioString(s)); if(clearOtherLines == true) {
addLineOnly(Lang::getInstance().getScenarioString(s));
}
else {
addLine(Lang::getInstance().getScenarioString(s));
}
} }
void Console::addLine(string line, bool playSound, int playerIndex, Vec3f textColor, bool teamMode) { void Console::addLineOnly(string line) {
addLine(line,false,-1,Vec3f(1.f, 1.f, 1.f),false,true);
}
void Console::addLine(string line, bool playSound, int playerIndex, Vec3f textColor, bool teamMode,bool clearOtherLines) {
try { try {
if(playSound == true) { if(playSound == true) {
SoundRenderer::getInstance().playFx(CoreData::getInstance().getClickSoundA()); SoundRenderer::getInstance().playFx(CoreData::getInstance().getClickSoundA());
@@ -79,6 +93,10 @@ void Console::addLine(string line, bool playSound, int playerIndex, Vec3f textCo
} }
//printf("info.PlayerIndex = %d, line [%s]\n",info.PlayerIndex,info.originalPlayerName.c_str()); //printf("info.PlayerIndex = %d, line [%s]\n",info.PlayerIndex,info.originalPlayerName.c_str());
if(clearOtherLines == true) {
lines.clear();
storedLines.clear();
}
lines.insert(lines.begin(), info); lines.insert(lines.begin(), info);
if(lines.size() > maxLines) { if(lines.size() > maxLines) {
lines.pop_back(); lines.pop_back();

View File

@@ -97,9 +97,10 @@ public:
ConsoleLineInfo getStoredLineItem(int i) const; ConsoleLineInfo getStoredLineItem(int i) const;
void clearStoredLines(); void clearStoredLines();
void addStdMessage(const string &s); void addStdMessage(const string &s, bool clearOtherLines=false);
void addStdScenarioMessage(const string &s); void addStdScenarioMessage(const string &s,bool clearOtherLines=false);
void addLine(string line, bool playSound= false,int playerIndex=-1,Vec3f textColor=Vec3f(1.f, 1.f, 1.f),bool teamMode=false); void addLineOnly(string line);
void addLine(string line, bool playSound= false,int playerIndex=-1,Vec3f textColor=Vec3f(1.f, 1.f, 1.f),bool teamMode=false,bool clearOtherLines=false);
void addLine(string line, bool playSound,string playerName, Vec3f textColor=Vec3f(1.f, 1.f, 1.f),bool teamMode=false); void addLine(string line, bool playSound,string playerName, Vec3f textColor=Vec3f(1.f, 1.f, 1.f),bool teamMode=false);
void addLine(string line, bool playSound, Vec3f textColor) { addLine(line,playSound,"",textColor,false); } void addLine(string line, bool playSound, Vec3f textColor) { addLine(line,playSound,"",textColor,false); }
void update(); void update();

View File

@@ -36,7 +36,7 @@ MenuStateLoadGame::MenuStateLoadGame(Program *program, MainMenu *mainMenu):
Lang &lang= Lang::getInstance(); Lang &lang= Lang::getInstance();
int buttonWidth = 120; int buttonWidth = 120;
int yPos=30; int yPos=40;
int xPos=20; int xPos=20;
int xSpacing=20; int xSpacing=20;
int slotsToRender=20; int slotsToRender=20;
@@ -199,7 +199,7 @@ void MenuStateLoadGame::mouseClick(int x, int y, MouseButton mouseButton){
soundRenderer.playFx(coreData.getClickSoundB()); soundRenderer.playFx(coreData.getClickSoundB());
if(selectedButton == NULL) { if(selectedButton == NULL) {
Lang &lang= Lang::getInstance(); Lang &lang= Lang::getInstance();
console.addStdMessage("NothingSelected"); console.addStdMessage("NothingSelected",true);
} }
else { else {
string slotname = selectedButton->getText(); string slotname = selectedButton->getText();
@@ -210,7 +210,7 @@ void MenuStateLoadGame::mouseClick(int x, int y, MouseButton mouseButton){
Lang &lang= Lang::getInstance(); Lang &lang= Lang::getInstance();
char szBuf[8096]=""; char szBuf[8096]="";
sprintf(szBuf,lang.get("LoadGameDeletingFile","",true).c_str(),filename.c_str()); sprintf(szBuf,lang.get("LoadGameDeletingFile","",true).c_str(),filename.c_str());
console.addLine(szBuf); console.addLineOnly(szBuf);
for(int i = 0; i < slots.size(); i++) { for(int i = 0; i < slots.size(); i++) {
if(slots[i] == selectedButton) { if(slots[i] == selectedButton) {
@@ -237,7 +237,7 @@ void MenuStateLoadGame::mouseClick(int x, int y, MouseButton mouseButton){
if(selectedButton == NULL) { if(selectedButton == NULL) {
Lang &lang= Lang::getInstance(); Lang &lang= Lang::getInstance();
console.addStdMessage("NothingSelected"); console.addStdMessage("NothingSelected",true);
} }
else { else {
string filename = saveGameDir + selectedButton->getText() + ".xml"; string filename = saveGameDir + selectedButton->getText() + ".xml";
@@ -245,7 +245,7 @@ void MenuStateLoadGame::mouseClick(int x, int y, MouseButton mouseButton){
Lang &lang= Lang::getInstance(); Lang &lang= Lang::getInstance();
char szBuf[8096]=""; char szBuf[8096]="";
sprintf(szBuf,lang.get("LoadGameLoadingFile","",true).c_str(),filename.c_str()); sprintf(szBuf,lang.get("LoadGameLoadingFile","",true).c_str(),filename.c_str());
console.addLine(szBuf); console.addLineOnly(szBuf);
Game::loadGame(filename,program,false); Game::loadGame(filename,program,false);
return; return;