additional data/core/menu/credits.txt file can be given for about screen
This commit is contained in:
parent
5613be6128
commit
03d706db11
|
@ -17,43 +17,69 @@
|
|||
#include "core_data.h"
|
||||
#include "config.h"
|
||||
#include "menu_state_options.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
using namespace std;
|
||||
|
||||
namespace Glest {
|
||||
namespace Game {
|
||||
|
||||
// =====================================================
|
||||
// class MenuStateAbout
|
||||
// =====================================================
|
||||
|
||||
MenuStateAbout::MenuStateAbout(Program *program, MainMenu *mainMenu) :
|
||||
MenuState(program, mainMenu, "about") {
|
||||
MenuState(program, mainMenu, "about"){
|
||||
|
||||
containerName = "About";
|
||||
containerName= "About";
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
|
||||
string additionalCredits= loadAdditionalCredits();
|
||||
|
||||
//init
|
||||
buttonReturn.registerGraphicComponent(containerName,"buttonReturn");
|
||||
buttonReturn.registerGraphicComponent(containerName, "buttonReturn");
|
||||
buttonReturn.init(460, 100, 125);
|
||||
buttonReturn.setText(lang.get("Return"));
|
||||
|
||||
for(int i= 0; i<aboutStringCount1; ++i){
|
||||
labelAbout1[i].registerGraphicComponent(containerName,"labelAbout1" + intToStr(i));
|
||||
labelAbout1[i].init(100, 650-i*20);
|
||||
labelAbout1[i].setText(getAboutString1(i));
|
||||
|
||||
labelAdditionalCredits.registerGraphicComponent(containerName, "labelAdditionalCredits");
|
||||
labelAdditionalCredits.init(500, 700);
|
||||
labelAdditionalCredits.setText(additionalCredits);
|
||||
|
||||
if(additionalCredits == NULL){
|
||||
for(int i= 0; i < aboutStringCount1; ++i){
|
||||
labelAbout1[i].registerGraphicComponent(containerName, "labelAbout1" + intToStr(i));
|
||||
labelAbout1[i].init(100, 750 - i * 20);
|
||||
labelAbout1[i].setText(getAboutString1(i));
|
||||
}
|
||||
|
||||
for(int i= 0; i < aboutStringCount2; ++i){
|
||||
labelAbout2[i].registerGraphicComponent(containerName, "labelAbout2" + intToStr(i));
|
||||
labelAbout2[i].init(450, 650 - i * 20);
|
||||
labelAbout2[i].setText(getAboutString2(i));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i= 0; i < aboutStringCount1; ++i){
|
||||
labelAbout1[i].registerGraphicComponent(containerName, "labelAbout1" + intToStr(i));
|
||||
labelAbout1[i].init(100, 700 - i * 20);
|
||||
labelAbout1[i].setText(getAboutString1(i));
|
||||
}
|
||||
|
||||
for(int i= 0; i < aboutStringCount2; ++i){
|
||||
labelAbout2[i].registerGraphicComponent(containerName, "labelAbout2" + intToStr(i));
|
||||
labelAbout2[i].init(100, 620 - i * 20);
|
||||
labelAbout2[i].setText(getAboutString2(i));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i= 0; i<aboutStringCount2; ++i){
|
||||
labelAbout2[i].registerGraphicComponent(containerName,"labelAbout2" + intToStr(i));
|
||||
labelAbout2[i].init(460, 650-i*20);
|
||||
labelAbout2[i].setText(getAboutString2(i));
|
||||
}
|
||||
|
||||
for(int i= 0; i<teammateCount; ++i){
|
||||
labelTeammateName[i].registerGraphicComponent(containerName,"labelTeammateName" + intToStr(i));
|
||||
labelTeammateName[i].init(100+i*180, 500);
|
||||
labelTeammateRole[i].registerGraphicComponent(containerName,"labelTeammateRole" + intToStr(i));
|
||||
labelTeammateRole[i].init(100+i*180, 520);
|
||||
for(int i= 0; i < teammateCount; ++i){
|
||||
labelTeammateName[i].registerGraphicComponent(containerName, "labelTeammateName" + intToStr(i));
|
||||
labelTeammateName[i].init(100 + i * 180, 500);
|
||||
labelTeammateRole[i].registerGraphicComponent(containerName, "labelTeammateRole" + intToStr(i));
|
||||
labelTeammateRole[i].init(100 + i * 180, 520);
|
||||
labelTeammateName[i].setText(getTeammateName(i));
|
||||
labelTeammateRole[i].setText(getTeammateRole(i));
|
||||
}
|
||||
|
@ -70,15 +96,33 @@ MenuStateAbout::MenuStateAbout(Program *program, MainMenu *mainMenu) :
|
|||
GraphicComponent::applyAllCustomProperties(containerName);
|
||||
}
|
||||
|
||||
string MenuStateAbout::loadAdditionalCredits(){
|
||||
string data_path= getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
if(data_path != ""){
|
||||
endPathWithSlash(data_path);
|
||||
}
|
||||
string result= "";
|
||||
const string dir= data_path + "data/core/menu/credits.txt";
|
||||
ifstream file(dir.c_str());
|
||||
std::string buffer;
|
||||
while(!file.eof()){
|
||||
getline(file, buffer);
|
||||
result+= buffer + "\n";
|
||||
}
|
||||
std::cout << buffer << std::endl;
|
||||
file.close();
|
||||
return result;
|
||||
}
|
||||
|
||||
void MenuStateAbout::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||
|
||||
if(buttonReturn.mouseClick(x, y)){
|
||||
soundRenderer.playFx(coreData.getClickSoundA());
|
||||
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -89,29 +133,32 @@ void MenuStateAbout::mouseMove(int x, int y, const MouseState *ms){
|
|||
void MenuStateAbout::render(){
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
|
||||
renderer.renderLabel(&labelAdditionalCredits);
|
||||
renderer.renderButton(&buttonReturn);
|
||||
for(int i= 0; i<aboutStringCount1; ++i){
|
||||
for(int i= 0; i < aboutStringCount1; ++i){
|
||||
renderer.renderLabel(&labelAbout1[i]);
|
||||
}
|
||||
for(int i= 0; i<aboutStringCount2; ++i){
|
||||
for(int i= 0; i < aboutStringCount2; ++i){
|
||||
renderer.renderLabel(&labelAbout2[i]);
|
||||
}
|
||||
for(int i= 0; i<teammateCount; ++i){
|
||||
for(int i= 0; i < teammateCount; ++i){
|
||||
renderer.renderLabel(&labelTeammateName[i]);
|
||||
renderer.renderLabel(&labelTeammateRole[i]);
|
||||
}
|
||||
|
||||
if(program != NULL) program->renderProgramMsgBox();
|
||||
if(program != NULL)
|
||||
program->renderProgramMsgBox();
|
||||
|
||||
}
|
||||
|
||||
void MenuStateAbout::keyDown(char key) {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
if(key == configKeys.getCharKey("SaveGUILayout")) {
|
||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
||||
void MenuStateAbout::keyDown(char key){
|
||||
Config &configKeys= Config::getInstance(std::pair<ConfigType, ConfigType>(cfgMainKeys, cfgUserKeys));
|
||||
if(key == configKeys.getCharKey("SaveGUILayout")){
|
||||
bool saved= GraphicComponent::saveAllCustomProperties(containerName);
|
||||
//Lang &lang= Lang::getInstance();
|
||||
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||
}
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
}
|
||||
}//end namespace
|
||||
|
|
|
@ -29,11 +29,14 @@ public:
|
|||
|
||||
private:
|
||||
GraphicButton buttonReturn;
|
||||
GraphicLabel labelAdditionalCredits;
|
||||
GraphicLabel labelAbout1[aboutStringCount1];
|
||||
GraphicLabel labelAbout2[aboutStringCount2];
|
||||
GraphicLabel labelTeammateName[teammateCount];
|
||||
GraphicLabel labelTeammateRole[teammateCount];
|
||||
|
||||
string loadAdditionalCredits();
|
||||
|
||||
public:
|
||||
MenuStateAbout(Program *program, MainMenu *mainMenu);
|
||||
|
||||
|
|
Loading…
Reference in New Issue