2010-03-18 21:26:40 +00:00
|
|
|
|
// ==============================================================
|
|
|
|
|
// This file is part of Glest (www.glest.org)
|
|
|
|
|
//
|
2010-04-21 23:13:39 +00:00
|
|
|
|
// Copyright (C) 2001-2005 Marti<74>o Figueroa
|
2010-03-18 21:26:40 +00:00
|
|
|
|
//
|
|
|
|
|
// You can redistribute this code and/or modify it under
|
|
|
|
|
// the terms of the GNU General Public License as published
|
|
|
|
|
// by the Free Software Foundation; either version 2 of the
|
|
|
|
|
// License, or (at your option) any later version
|
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
|
|
#include "menu_state_new_game.h"
|
|
|
|
|
|
|
|
|
|
#include "renderer.h"
|
|
|
|
|
#include "sound_renderer.h"
|
|
|
|
|
#include "core_data.h"
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "menu_state_custom_game.h"
|
|
|
|
|
#include "menu_state_scenario.h"
|
|
|
|
|
#include "menu_state_root.h"
|
|
|
|
|
#include "metrics.h"
|
|
|
|
|
#include "network_manager.h"
|
|
|
|
|
#include "network_message.h"
|
|
|
|
|
#include "auto_test.h"
|
|
|
|
|
#include "socket.h"
|
|
|
|
|
|
|
|
|
|
#include "leak_dumper.h"
|
|
|
|
|
|
|
|
|
|
namespace Glest{ namespace Game{
|
|
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
|
// class MenuStateNewGame
|
|
|
|
|
// =====================================================
|
|
|
|
|
|
|
|
|
|
MenuStateNewGame::MenuStateNewGame(Program *program, MainMenu *mainMenu):
|
|
|
|
|
MenuState(program, mainMenu, "root")
|
|
|
|
|
{
|
2010-09-09 21:07:39 +00:00
|
|
|
|
containerName = "NewGame";
|
2010-03-18 21:26:40 +00:00
|
|
|
|
Lang &lang= Lang::getInstance();
|
|
|
|
|
|
2010-09-09 06:42:39 +00:00
|
|
|
|
buttonCustomGame.registerGraphicComponent(containerName,"buttonCustomGame");
|
2010-03-18 21:26:40 +00:00
|
|
|
|
buttonCustomGame.init(425, 350, 150);
|
2010-09-09 06:42:39 +00:00
|
|
|
|
buttonScenario.registerGraphicComponent(containerName,"buttonScenario");
|
2010-03-18 21:26:40 +00:00
|
|
|
|
buttonScenario.init(425, 310, 150);
|
2010-09-09 06:42:39 +00:00
|
|
|
|
buttonTutorial.registerGraphicComponent(containerName,"buttonTutorial");
|
2010-03-18 21:26:40 +00:00
|
|
|
|
buttonTutorial.init(425, 270, 150);
|
2010-09-09 06:42:39 +00:00
|
|
|
|
buttonReturn.registerGraphicComponent(containerName,"buttonReturn");
|
2010-03-18 21:26:40 +00:00
|
|
|
|
buttonReturn.init(425, 230, 150);
|
|
|
|
|
|
|
|
|
|
buttonCustomGame.setText(lang.get("CustomGame"));
|
|
|
|
|
buttonScenario.setText(lang.get("Scenario"));
|
|
|
|
|
buttonTutorial.setText(lang.get("Tutorial"));
|
|
|
|
|
buttonReturn.setText(lang.get("Return"));
|
|
|
|
|
|
2010-09-09 06:42:39 +00:00
|
|
|
|
GraphicComponent::applyAllCustomProperties(containerName);
|
|
|
|
|
|
2010-03-18 21:26:40 +00:00
|
|
|
|
NetworkManager::getInstance().end();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MenuStateNewGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|
|
|
|
|
|
|
|
|
CoreData &coreData= CoreData::getInstance();
|
|
|
|
|
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
|
|
|
|
|
|
|
|
|
if(buttonCustomGame.mouseClick(x, y)){
|
|
|
|
|
soundRenderer.playFx(coreData.getClickSoundB());
|
|
|
|
|
mainMenu->setState(new MenuStateCustomGame(program, mainMenu));
|
|
|
|
|
}
|
|
|
|
|
else if(buttonScenario.mouseClick(x, y)){
|
|
|
|
|
soundRenderer.playFx(coreData.getClickSoundB());
|
|
|
|
|
mainMenu->setState(new MenuStateScenario(program, mainMenu, Config::getInstance().getPathListForType(ptScenarios)));
|
|
|
|
|
}
|
|
|
|
|
else if(buttonTutorial.mouseClick(x, y)){
|
|
|
|
|
soundRenderer.playFx(coreData.getClickSoundB());
|
|
|
|
|
mainMenu->setState(new MenuStateScenario(program, mainMenu, Config::getInstance().getPathListForType(ptTutorials)));
|
|
|
|
|
}
|
|
|
|
|
else if(buttonReturn.mouseClick(x, y)){
|
|
|
|
|
soundRenderer.playFx(coreData.getClickSoundB());
|
|
|
|
|
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MenuStateNewGame::mouseMove(int x, int y, const MouseState *ms){
|
|
|
|
|
buttonCustomGame.mouseMove(x, y);
|
|
|
|
|
buttonScenario.mouseMove(x, y);
|
|
|
|
|
buttonTutorial.mouseMove(x, y);
|
|
|
|
|
buttonReturn.mouseMove(x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MenuStateNewGame::render(){
|
|
|
|
|
Renderer &renderer= Renderer::getInstance();
|
|
|
|
|
|
|
|
|
|
renderer.renderButton(&buttonCustomGame);
|
|
|
|
|
renderer.renderButton(&buttonScenario);
|
|
|
|
|
renderer.renderButton(&buttonTutorial);
|
|
|
|
|
renderer.renderButton(&buttonReturn);
|
2010-07-08 08:29:51 +00:00
|
|
|
|
|
|
|
|
|
if(program != NULL) program->renderProgramMsgBox();
|
2010-03-18 21:26:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MenuStateNewGame::update(){
|
|
|
|
|
if(Config::getInstance().getBool("AutoTest")){
|
|
|
|
|
AutoTest::getInstance().updateNewGame(program, mainMenu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-09 21:07:39 +00:00
|
|
|
|
void MenuStateNewGame::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"))+ "]");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-18 21:26:40 +00:00
|
|
|
|
}}//end namespace
|