mirror of
https://github.com/glest/glest-source.git
synced 2025-08-17 21:51:17 +02:00
additional data/core/menu/credits.txt file can be given for about screen
This commit is contained in:
@@ -17,10 +17,14 @@
|
||||
#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
|
||||
@@ -32,22 +36,44 @@ MenuStateAbout::MenuStateAbout(Program *program, MainMenu *mainMenu) :
|
||||
containerName= "About";
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
string additionalCredits= loadAdditionalCredits();
|
||||
|
||||
//init
|
||||
buttonReturn.registerGraphicComponent(containerName, "buttonReturn");
|
||||
buttonReturn.init(460, 100, 125);
|
||||
buttonReturn.setText(lang.get("Return"));
|
||||
|
||||
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, 650-i*20);
|
||||
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(460, 650-i*20);
|
||||
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 < teammateCount; ++i){
|
||||
labelTeammateName[i].registerGraphicComponent(containerName, "labelTeammateName" + intToStr(i));
|
||||
@@ -70,6 +96,24 @@ 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();
|
||||
@@ -89,6 +133,7 @@ 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){
|
||||
renderer.renderLabel(&labelAbout1[i]);
|
||||
@@ -101,7 +146,8 @@ void MenuStateAbout::render(){
|
||||
renderer.renderLabel(&labelTeammateRole[i]);
|
||||
}
|
||||
|
||||
if(program != NULL) program->renderProgramMsgBox();
|
||||
if(program != NULL)
|
||||
program->renderProgramMsgBox();
|
||||
|
||||
}
|
||||
|
||||
@@ -114,4 +160,5 @@ void MenuStateAbout::keyDown(char key) {
|
||||
}
|
||||
}
|
||||
|
||||
}}//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);
|
||||
|
||||
|
Reference in New Issue
Block a user