mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 06:01:17 +02:00
additional data/core/menu/credits.txt file can be given for about screen
This commit is contained in:
@@ -17,43 +17,69 @@
|
|||||||
#include "core_data.h"
|
#include "core_data.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "menu_state_options.h"
|
#include "menu_state_options.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
using namespace std;
|
||||||
|
|
||||||
|
namespace Glest {
|
||||||
|
namespace Game {
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class MenuStateAbout
|
// class MenuStateAbout
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
MenuStateAbout::MenuStateAbout(Program *program, MainMenu *mainMenu) :
|
MenuStateAbout::MenuStateAbout(Program *program, MainMenu *mainMenu) :
|
||||||
MenuState(program, mainMenu, "about") {
|
MenuState(program, mainMenu, "about"){
|
||||||
|
|
||||||
containerName = "About";
|
containerName= "About";
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
|
|
||||||
|
string additionalCredits= loadAdditionalCredits();
|
||||||
|
|
||||||
//init
|
//init
|
||||||
buttonReturn.registerGraphicComponent(containerName,"buttonReturn");
|
buttonReturn.registerGraphicComponent(containerName, "buttonReturn");
|
||||||
buttonReturn.init(460, 100, 125);
|
buttonReturn.init(460, 100, 125);
|
||||||
buttonReturn.setText(lang.get("Return"));
|
buttonReturn.setText(lang.get("Return"));
|
||||||
|
|
||||||
for(int i= 0; i<aboutStringCount1; ++i){
|
labelAdditionalCredits.registerGraphicComponent(containerName, "labelAdditionalCredits");
|
||||||
labelAbout1[i].registerGraphicComponent(containerName,"labelAbout1" + intToStr(i));
|
labelAdditionalCredits.init(500, 700);
|
||||||
labelAbout1[i].init(100, 650-i*20);
|
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));
|
labelAbout1[i].setText(getAboutString1(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i= 0; i<aboutStringCount2; ++i){
|
for(int i= 0; i < aboutStringCount2; ++i){
|
||||||
labelAbout2[i].registerGraphicComponent(containerName,"labelAbout2" + intToStr(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));
|
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<teammateCount; ++i){
|
for(int i= 0; i < aboutStringCount2; ++i){
|
||||||
labelTeammateName[i].registerGraphicComponent(containerName,"labelTeammateName" + intToStr(i));
|
labelAbout2[i].registerGraphicComponent(containerName, "labelAbout2" + intToStr(i));
|
||||||
labelTeammateName[i].init(100+i*180, 500);
|
labelAbout2[i].init(100, 620 - i * 20);
|
||||||
labelTeammateRole[i].registerGraphicComponent(containerName,"labelTeammateRole" + intToStr(i));
|
labelAbout2[i].setText(getAboutString2(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));
|
labelTeammateName[i].setText(getTeammateName(i));
|
||||||
labelTeammateRole[i].setText(getTeammateRole(i));
|
labelTeammateRole[i].setText(getTeammateRole(i));
|
||||||
}
|
}
|
||||||
@@ -70,6 +96,24 @@ MenuStateAbout::MenuStateAbout(Program *program, MainMenu *mainMenu) :
|
|||||||
GraphicComponent::applyAllCustomProperties(containerName);
|
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){
|
void MenuStateAbout::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
|
|
||||||
CoreData &coreData= CoreData::getInstance();
|
CoreData &coreData= CoreData::getInstance();
|
||||||
@@ -89,29 +133,32 @@ void MenuStateAbout::mouseMove(int x, int y, const MouseState *ms){
|
|||||||
void MenuStateAbout::render(){
|
void MenuStateAbout::render(){
|
||||||
Renderer &renderer= Renderer::getInstance();
|
Renderer &renderer= Renderer::getInstance();
|
||||||
|
|
||||||
|
renderer.renderLabel(&labelAdditionalCredits);
|
||||||
renderer.renderButton(&buttonReturn);
|
renderer.renderButton(&buttonReturn);
|
||||||
for(int i= 0; i<aboutStringCount1; ++i){
|
for(int i= 0; i < aboutStringCount1; ++i){
|
||||||
renderer.renderLabel(&labelAbout1[i]);
|
renderer.renderLabel(&labelAbout1[i]);
|
||||||
}
|
}
|
||||||
for(int i= 0; i<aboutStringCount2; ++i){
|
for(int i= 0; i < aboutStringCount2; ++i){
|
||||||
renderer.renderLabel(&labelAbout2[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(&labelTeammateName[i]);
|
||||||
renderer.renderLabel(&labelTeammateRole[i]);
|
renderer.renderLabel(&labelTeammateRole[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(program != NULL) program->renderProgramMsgBox();
|
if(program != NULL)
|
||||||
|
program->renderProgramMsgBox();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateAbout::keyDown(char key) {
|
void MenuStateAbout::keyDown(char key){
|
||||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
Config &configKeys= Config::getInstance(std::pair<ConfigType, ConfigType>(cfgMainKeys, cfgUserKeys));
|
||||||
if(key == configKeys.getCharKey("SaveGUILayout")) {
|
if(key == configKeys.getCharKey("SaveGUILayout")){
|
||||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
bool saved= GraphicComponent::saveAllCustomProperties(containerName);
|
||||||
//Lang &lang= Lang::getInstance();
|
//Lang &lang= Lang::getInstance();
|
||||||
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}}//end namespace
|
}
|
||||||
|
}//end namespace
|
||||||
|
@@ -29,11 +29,14 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
GraphicButton buttonReturn;
|
GraphicButton buttonReturn;
|
||||||
|
GraphicLabel labelAdditionalCredits;
|
||||||
GraphicLabel labelAbout1[aboutStringCount1];
|
GraphicLabel labelAbout1[aboutStringCount1];
|
||||||
GraphicLabel labelAbout2[aboutStringCount2];
|
GraphicLabel labelAbout2[aboutStringCount2];
|
||||||
GraphicLabel labelTeammateName[teammateCount];
|
GraphicLabel labelTeammateName[teammateCount];
|
||||||
GraphicLabel labelTeammateRole[teammateCount];
|
GraphicLabel labelTeammateRole[teammateCount];
|
||||||
|
|
||||||
|
string loadAdditionalCredits();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuStateAbout(Program *program, MainMenu *mainMenu);
|
MenuStateAbout(Program *program, MainMenu *mainMenu);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user