- completed screen UI work. F11 will save current menu UI config to ini file, F5 will cause a reload of INI realtime
This commit is contained in:
parent
7f9c9cde28
commit
6a24ca3ad0
|
@ -41,6 +41,8 @@ HotKeySelectedUnitsStop=S
|
|||
HotKeyToggleOSMouseEnabled=/
|
||||
ChatTeamMode=H
|
||||
ToggleMusic=K
|
||||
SaveGUILayout=vkF11
|
||||
ReloadINI=vkF5
|
||||
|
||||
; === propertyMap File ===
|
||||
|
||||
|
|
|
@ -46,13 +46,20 @@ GraphicComponent::GraphicComponent(std::string containerName, std::string objNam
|
|||
editable= true;
|
||||
}
|
||||
|
||||
void GraphicComponent::clearRegisteredComponents() {
|
||||
GraphicComponent::registeredGraphicComponentList.clear();
|
||||
void GraphicComponent::clearRegisteredComponents(std::string containerName) {
|
||||
if(containerName == "") {
|
||||
GraphicComponent::registeredGraphicComponentList.clear();
|
||||
}
|
||||
else {
|
||||
GraphicComponent::registeredGraphicComponentList[containerName].clear();
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicComponent::registerGraphicComponent(std::string containerName, std::string objName) {
|
||||
instanceName = objName;
|
||||
registeredGraphicComponentList[containerName][objName] = this;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] registered [%s] [%s] count = %d\n",__FILE__,__FUNCTION__,__LINE__,containerName.c_str(),instanceName.c_str(),registeredGraphicComponentList[containerName].size());
|
||||
}
|
||||
|
||||
GraphicComponent * GraphicComponent::findRegisteredComponent(std::string containerName, std::string objName) {
|
||||
|
@ -109,6 +116,71 @@ void GraphicComponent::applyCustomProperties(std::string containerName) {
|
|||
}
|
||||
}
|
||||
|
||||
bool GraphicComponent::saveAllCustomProperties(std::string containerName) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] registered [%s] count = %d\n",__FILE__,__FUNCTION__,__LINE__,containerName.c_str(),registeredGraphicComponentList[containerName].size());
|
||||
|
||||
bool foundPropertiesToSave = false;
|
||||
std::map<std::string, std::map<std::string, GraphicComponent *> >::iterator iterFind1 = GraphicComponent::registeredGraphicComponentList.find(containerName);
|
||||
if(iterFind1 != GraphicComponent::registeredGraphicComponentList.end()) {
|
||||
for(std::map<std::string, GraphicComponent *>::iterator iterFind2 = iterFind1->second.begin();
|
||||
iterFind2 != iterFind1->second.end(); iterFind2++) {
|
||||
bool saved = iterFind2->second->saveCustomProperties(containerName);
|
||||
foundPropertiesToSave = (saved || foundPropertiesToSave);
|
||||
}
|
||||
}
|
||||
|
||||
if(foundPropertiesToSave == true) {
|
||||
Config &config = Config::getInstance();
|
||||
config.save();
|
||||
}
|
||||
|
||||
return foundPropertiesToSave;
|
||||
}
|
||||
|
||||
bool GraphicComponent::saveCustomProperties(std::string containerName) {
|
||||
bool savedChange = false;
|
||||
if(instanceName != "") {
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for [%s] [%s]\n",__FILE__,__FUNCTION__,__LINE__,containerName.c_str(),instanceName.c_str());
|
||||
|
||||
std::map<std::string, std::map<std::string, GraphicComponent *> >::iterator iterFind1 = GraphicComponent::registeredGraphicComponentList.find(containerName);
|
||||
if(iterFind1 != GraphicComponent::registeredGraphicComponentList.end()) {
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] looking for [%s]\n",__FILE__,__FUNCTION__,__LINE__,instanceName.c_str());
|
||||
|
||||
std::map<std::string, GraphicComponent *>::iterator iterFind2 = iterFind1->second.find(instanceName);
|
||||
if(iterFind2 != iterFind1->second.end()) {
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] FOUND [%s]\n",__FILE__,__FUNCTION__,__LINE__,instanceName.c_str());
|
||||
|
||||
Config &config = Config::getInstance();
|
||||
|
||||
//string languageToken = config.getString("Lang");
|
||||
|
||||
//if(dynamic_cast<GraphicButton *>(iterFind2->second) != NULL) {
|
||||
GraphicComponent *ctl = dynamic_cast<GraphicComponent *>(iterFind2->second);
|
||||
|
||||
// First check default overrides
|
||||
config.setInt(containerName + "_" + iterFind2->first + "_x",ctl->x);
|
||||
config.setInt(containerName + "_" + iterFind2->first + "_y",ctl->y);
|
||||
config.setInt(containerName + "_" + iterFind2->first + "_w",ctl->w);
|
||||
config.setInt(containerName + "_" + iterFind2->first + "_h",ctl->h);
|
||||
|
||||
savedChange = true;
|
||||
// Now check language specific overrides
|
||||
//ctl->x = config.getInt(containerName + "_" + iterFind2->first + "_x_" + languageToken, intToStr(ctl->x).c_str());
|
||||
//ctl->y = config.getInt(containerName + "_" + iterFind2->first + "_y_" + languageToken, intToStr(ctl->y).c_str());
|
||||
//ctl->w = config.getInt(containerName + "_" + iterFind2->first + "_w_" + languageToken, intToStr(ctl->w).c_str());
|
||||
//ctl->h = config.getInt(containerName + "_" + iterFind2->first + "_h_" + languageToken, intToStr(ctl->h).c_str());
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return savedChange;
|
||||
}
|
||||
|
||||
void GraphicComponent::init(int x, int y, int w, int h) {
|
||||
this->x= x;
|
||||
this->y= y;
|
||||
|
|
|
@ -57,12 +57,15 @@ public:
|
|||
GraphicComponent(std::string containerName="", std::string objName="");
|
||||
virtual ~GraphicComponent(){}
|
||||
|
||||
static void clearRegisteredComponents();
|
||||
static void clearRegisteredComponents(std::string containerName="");
|
||||
void registerGraphicComponent(std::string containerName, std::string objName);
|
||||
static GraphicComponent * findRegisteredComponent(std::string containerName, std::string objName);
|
||||
static void applyAllCustomProperties(std::string containerName);
|
||||
void applyCustomProperties(std::string containerName);
|
||||
|
||||
static bool saveAllCustomProperties(std::string containerName);
|
||||
bool saveCustomProperties(std::string containerName);
|
||||
|
||||
void init(int x, int y, int w, int h);
|
||||
|
||||
int getX() const {return x;}
|
||||
|
|
|
@ -52,6 +52,17 @@ const string defaultNotFoundValue = "~~NOT FOUND~~";
|
|||
|
||||
map<ConfigType,Config> Config::configList;
|
||||
|
||||
Config::Config() {
|
||||
fileLoaded.first = false;
|
||||
fileLoaded.second = false;
|
||||
cfgType.first = cfgMainGame;
|
||||
cfgType.second = cfgUserGame;
|
||||
fileName.first = "";
|
||||
fileName.second = "";
|
||||
fileLoaded.first = false;
|
||||
fileLoaded.second = false;
|
||||
}
|
||||
|
||||
Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist) {
|
||||
fileLoaded.first = false;
|
||||
fileLoaded.second = false;
|
||||
|
@ -106,13 +117,42 @@ Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> f
|
|||
|
||||
Config &Config::getInstance(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist) {
|
||||
if(configList.find(type.first) == configList.end()) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Config config(type, file, fileMustExist);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
configList.insert(map<ConfigType,Config>::value_type(type.first,config));
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
return configList.find(type.first)->second;
|
||||
}
|
||||
|
||||
void Config::CopyAll(Config *src, Config *dest) {
|
||||
|
||||
dest->properties = src->properties;
|
||||
dest->cfgType = src->cfgType;
|
||||
dest->fileName = src->fileName;
|
||||
dest->fileLoaded = src->fileLoaded;
|
||||
}
|
||||
|
||||
void Config::reload() {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
std::pair<ConfigType,ConfigType> type = std::make_pair(cfgMainGame,cfgUserGame);
|
||||
Config newconfig(type, std::make_pair("glest.ini","glestuser.ini"), std::make_pair(true,false));
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Config &oldconfig = configList.find(type.first)->second;
|
||||
CopyAll(&newconfig, &oldconfig);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void Config::save(const string &path){
|
||||
if(fileLoaded.second == true) {
|
||||
if(path != "") {
|
||||
|
@ -227,6 +267,42 @@ char Config::translateStringToCharKey(const string &value) const {
|
|||
else if(value == "vkEscape") {
|
||||
result = vkEscape;
|
||||
}
|
||||
else if(value == "vkF1") {
|
||||
result = vkF1;
|
||||
}
|
||||
else if(value == "vkF2") {
|
||||
result = vkF2;
|
||||
}
|
||||
else if(value == "vkF3") {
|
||||
result = vkF3;
|
||||
}
|
||||
else if(value == "vkF4") {
|
||||
result = vkF4;
|
||||
}
|
||||
else if(value == "vkF5") {
|
||||
result = vkF5;
|
||||
}
|
||||
else if(value == "vkF6") {
|
||||
result = vkF6;
|
||||
}
|
||||
else if(value == "vkF7") {
|
||||
result = vkF7;
|
||||
}
|
||||
else if(value == "vkF8") {
|
||||
result = vkF8;
|
||||
}
|
||||
else if(value == "vkF9") {
|
||||
result = vkF9;
|
||||
}
|
||||
else if(value == "vkF10") {
|
||||
result = vkF10;
|
||||
}
|
||||
else if(value == "vkF11") {
|
||||
result = vkF11;
|
||||
}
|
||||
else if(value == "vkF12") {
|
||||
result = vkF12;
|
||||
}
|
||||
else {
|
||||
string sError = "Unsupported key translation" + value;
|
||||
throw runtime_error(sError.c_str());
|
||||
|
|
|
@ -44,16 +44,20 @@ private:
|
|||
|
||||
static map<ConfigType,Config> configList;
|
||||
|
||||
private:
|
||||
protected:
|
||||
Config();
|
||||
Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist);
|
||||
|
||||
char translateStringToCharKey(const string &value) const;
|
||||
|
||||
static void CopyAll(Config *src,Config *dest);
|
||||
|
||||
public:
|
||||
static Config &getInstance(std::pair<ConfigType,ConfigType> type = std::make_pair(cfgMainGame,cfgUserGame) ,
|
||||
std::pair<string,string> file = std::make_pair("glest.ini","glestuser.ini") ,
|
||||
std::pair<bool,bool> fileMustExist = std::make_pair(true,false) );
|
||||
void save(const string &path="");
|
||||
void reload();
|
||||
|
||||
int getInt(const string &key,const char *defaultValueIfNotFound=NULL) const;
|
||||
bool getBool(const string &key,const char *defaultValueIfNotFound=NULL) const;
|
||||
|
|
|
@ -357,6 +357,10 @@ void MainWindow::eventKeyDown(char key){
|
|||
bool showDebugUI = renderer.getShowDebugUI();
|
||||
renderer.setShowDebugUI(!showDebugUI);
|
||||
}
|
||||
else if(key == configKeys.getCharKey("ReloadINI")) {
|
||||
Config &config = Config::getInstance();
|
||||
config.reload();
|
||||
}
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
|
|
@ -189,6 +189,7 @@ bool MainMenu::isInSpecialKeyCaptureEvent() {
|
|||
MenuState::MenuState(Program *program, MainMenu *mainMenu, const string &stateName){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
this->containerName="";
|
||||
this->program= program;
|
||||
this->mainMenu= mainMenu;
|
||||
|
||||
|
@ -233,7 +234,7 @@ MenuState::MenuState(Program *program, MainMenu *mainMenu, const string &stateNa
|
|||
|
||||
MenuState::~MenuState() {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
GraphicComponent::clearRegisteredComponents();
|
||||
GraphicComponent::clearRegisteredComponents(this->containerName);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
|
|
|
@ -119,6 +119,8 @@ protected:
|
|||
MainMenu *mainMenu;
|
||||
Camera camera;
|
||||
|
||||
const char *containerName;
|
||||
|
||||
public:
|
||||
MenuState(Program *program, MainMenu *mainMenu, const string &stateName);
|
||||
virtual ~MenuState();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "menu_state_root.h"
|
||||
#include "sound_renderer.h"
|
||||
#include "core_data.h"
|
||||
#include "config.h"
|
||||
#include "menu_state_options.h"
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
@ -25,11 +26,10 @@ namespace Glest{ namespace Game{
|
|||
// class MenuStateAbout
|
||||
// =====================================================
|
||||
|
||||
const char *MenuStateAbout::containerName = "About";
|
||||
MenuStateAbout::MenuStateAbout(Program *program, MainMenu *mainMenu) :
|
||||
MenuState(program, mainMenu, "about") {
|
||||
|
||||
MenuStateAbout::MenuStateAbout(Program *program, MainMenu *mainMenu):
|
||||
MenuState(program, mainMenu, "about")
|
||||
{
|
||||
containerName = "About";
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
//init
|
||||
|
@ -105,4 +105,13 @@ void MenuStateAbout::render(){
|
|||
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Glest{ namespace Game{
|
|||
|
||||
class MenuStateAbout: public MenuState{
|
||||
public:
|
||||
static const char *containerName;
|
||||
static const int aboutStringCount1= 3;
|
||||
static const int aboutStringCount2= 3;
|
||||
static const int teammateCount= 9;
|
||||
|
@ -41,6 +40,7 @@ public:
|
|||
void mouseClick(int x, int y, MouseButton mouseButton);
|
||||
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||
void render();
|
||||
virtual void keyDown(char key);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -45,11 +45,10 @@ struct FormatString {
|
|||
// class MenuStateConnectedGame
|
||||
// =====================================================
|
||||
|
||||
const char *MenuStateConnectedGame::containerName = "ClientConnectedGame";
|
||||
|
||||
MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainMenu,JoinMenu joinMenuInfo, bool openNetworkSlots):
|
||||
MenuState(program, mainMenu, "connected-game") //← set on connected-game
|
||||
MenuState(program, mainMenu, "connected-game")
|
||||
{
|
||||
containerName = "ClientConnectedGame";
|
||||
switchSetupRequestFlagType |= ssrft_NetworkPlayerName;
|
||||
updateDataSynchDetailText = false;
|
||||
|
||||
|
@ -1081,7 +1080,7 @@ bool MenuStateConnectedGame::hasNetworkGameSettings()
|
|||
|
||||
void MenuStateConnectedGame::keyDown(char key) {
|
||||
if(activeInputLabel!=NULL) {
|
||||
if(key==vkBack){
|
||||
if(key==vkBack) {
|
||||
string text= activeInputLabel->getText();
|
||||
if(text.size()>1){
|
||||
text.erase(text.end()-2);
|
||||
|
@ -1096,12 +1095,17 @@ void MenuStateConnectedGame::keyDown(char key) {
|
|||
else {
|
||||
//send key to the chat manager
|
||||
chatManager.keyDown(key);
|
||||
if(!chatManager.getEditEnabled()){
|
||||
if(chatManager.getEditEnabled() == false) {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
|
||||
if(key == configKeys.getCharKey("ShowFullConsole")) {
|
||||
showFullConsole= true;
|
||||
}
|
||||
else 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"))+ "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ enum JoinMenu{
|
|||
|
||||
class MenuStateConnectedGame: public MenuState {
|
||||
private:
|
||||
static const char *containerName;
|
||||
GraphicButton buttonDisconnect;
|
||||
GraphicButton buttonPlayNow;
|
||||
GraphicLabel labelControl;
|
||||
|
|
|
@ -45,13 +45,12 @@ struct FormatString {
|
|||
// class MenuStateCustomGame
|
||||
// =====================================================
|
||||
|
||||
const char *MenuStateCustomGame::containerName = "CustomGame";
|
||||
|
||||
MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, bool openNetworkSlots,bool parentMenuIsMasterserver):
|
||||
MenuState(program, mainMenu, "new-game")
|
||||
MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, bool openNetworkSlots,bool parentMenuIsMasterserver) :
|
||||
MenuState(program, mainMenu, "new-game")
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
containerName = "CustomGame";
|
||||
activeInputLabel=NULL;
|
||||
showGeneralError = false;
|
||||
generalErrorToShow = "---";
|
||||
|
@ -2151,7 +2150,7 @@ void MenuStateCustomGame::keyDown(char key) {
|
|||
else {
|
||||
//send key to the chat manager
|
||||
chatManager.keyDown(key);
|
||||
if(!chatManager.getEditEnabled()) {
|
||||
if(chatManager.getEditEnabled() == false) {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
|
||||
if(key == configKeys.getCharKey("ShowFullConsole")) {
|
||||
|
@ -2175,7 +2174,11 @@ void MenuStateCustomGame::keyDown(char key) {
|
|||
console.addLine(lang.get("GameMusic"));
|
||||
}
|
||||
}
|
||||
|
||||
else 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"))+ "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2213,7 +2216,7 @@ void MenuStateCustomGame::keyUp(char key) {
|
|||
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
|
||||
if(chatManager.getEditEnabled()){
|
||||
if(chatManager.getEditEnabled()) {
|
||||
//send key to the chat manager
|
||||
chatManager.keyUp(key);
|
||||
}
|
||||
|
|
|
@ -24,9 +24,6 @@ namespace Glest{ namespace Game{
|
|||
|
||||
class MenuStateCustomGame : public MenuState, public SimpleTaskCallbackInterface {
|
||||
private:
|
||||
|
||||
static const char *containerName;
|
||||
|
||||
GraphicButton buttonReturn;
|
||||
GraphicButton buttonPlayNow;
|
||||
GraphicButton buttonRestoreLastSettings;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "sound_renderer.h"
|
||||
#include "core_data.h"
|
||||
#include "menu_state_options.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
@ -24,11 +24,10 @@ namespace Glest{ namespace Game{
|
|||
// class MenuStateGraphicInfo
|
||||
// =====================================================
|
||||
|
||||
const char *MenuStateGraphicInfo::containerName = "GraphicInfo";
|
||||
|
||||
MenuStateGraphicInfo::MenuStateGraphicInfo(Program *program, MainMenu *mainMenu):
|
||||
MenuState(program, mainMenu, "info")
|
||||
{
|
||||
containerName = "GraphicInfo";
|
||||
buttonReturn.registerGraphicComponent(containerName,"buttonReturn");
|
||||
buttonReturn.init(387, 70, 125);
|
||||
|
||||
|
@ -74,4 +73,13 @@ void MenuStateGraphicInfo::render(){
|
|||
renderer.renderLabel(&labelMoreInfo);
|
||||
}
|
||||
|
||||
void MenuStateGraphicInfo::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
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Glest{ namespace Game{
|
|||
|
||||
class MenuStateGraphicInfo: public MenuState {
|
||||
private:
|
||||
static const char *containerName;
|
||||
GraphicButton buttonReturn;
|
||||
GraphicLabel labelInfo;
|
||||
GraphicLabel labelMoreInfo;
|
||||
|
@ -36,6 +35,7 @@ public:
|
|||
void mouseClick(int x, int y, MouseButton mouseButton);
|
||||
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||
void render();
|
||||
virtual void keyDown(char key);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -41,11 +41,10 @@ const int MenuStateJoinGame::foundServersIndex= 2;
|
|||
|
||||
const string MenuStateJoinGame::serverFileName= "servers.ini";
|
||||
|
||||
const char *MenuStateJoinGame::containerName = "JoinGame";
|
||||
|
||||
MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool connect, Ip serverIp):
|
||||
MenuState(program, mainMenu, "join-game")
|
||||
{
|
||||
containerName = "JoinGame";
|
||||
abortAutoFind = false;
|
||||
autoConnectToServer = false;
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
@ -468,10 +467,12 @@ void MenuStateJoinGame::keyDown(char key){
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c][%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||
|
||||
ClientInterface* clientInterface= NetworkManager::getInstance().getClientInterface();
|
||||
if(!clientInterface->isConnected())
|
||||
{
|
||||
if(clientInterface->isConnected() == false) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(key==vkBack) {
|
||||
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
|
||||
if(key == vkBack) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
string text= labelServerIp.getText();
|
||||
|
||||
|
@ -481,23 +482,37 @@ void MenuStateJoinGame::keyDown(char key){
|
|||
|
||||
labelServerIp.setText(text);
|
||||
}
|
||||
else 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"))+ "]");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//send key to the chat manager
|
||||
chatManager.keyDown(key);
|
||||
|
||||
if(chatManager.getEditEnabled() == false) {
|
||||
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"))+ "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MenuStateJoinGame::keyPress(char c){
|
||||
ClientInterface* clientInterface= NetworkManager::getInstance().getClientInterface();
|
||||
|
||||
if(!clientInterface->isConnected())
|
||||
{
|
||||
if(clientInterface->isConnected() == false) {
|
||||
int maxTextSize= 16;
|
||||
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
|
||||
if(c>='0' && c<='9'){
|
||||
|
||||
if(labelServerIp.getText().size()<maxTextSize){
|
||||
|
|
|
@ -31,7 +31,6 @@ class NetworkMessageIntro;
|
|||
|
||||
class MenuStateJoinGame: public MenuState, public DiscoveredServersInterface {
|
||||
private:
|
||||
static const char *containerName;
|
||||
static const int newServerIndex;
|
||||
static const int newPrevServerIndex;
|
||||
static const int foundServersIndex;
|
||||
|
|
|
@ -31,14 +31,12 @@
|
|||
namespace Glest{ namespace Game{
|
||||
|
||||
DisplayMessageFunction MenuStateMasterserver::pCB_DisplayMessage = NULL;
|
||||
const char *MenuStateMasterserver::containerName = "MasterServer";
|
||||
|
||||
// =====================================================
|
||||
// class ServerLine
|
||||
// =====================================================
|
||||
|
||||
ServerLine::ServerLine( MasterServerInfo *mServerInfo, int lineIndex) {
|
||||
const char *containerName = MenuStateMasterserver::containerName;
|
||||
ServerLine::ServerLine( MasterServerInfo *mServerInfo, int lineIndex, const char * containerName) {
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
index=lineIndex;
|
||||
|
@ -150,6 +148,7 @@ void ServerLine::render(){
|
|||
MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMenu):
|
||||
MenuState(program, mainMenu, "masterserver")
|
||||
{
|
||||
containerName = "MasterServer";
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
@ -509,7 +508,7 @@ void MenuStateMasterserver::updateServerInfo() {
|
|||
}
|
||||
|
||||
safeMutex.Lock();
|
||||
serverLines.push_back(new ServerLine( masterServerInfo, i));
|
||||
serverLines.push_back(new ServerLine( masterServerInfo, i, containerName));
|
||||
safeMutex.ReleaseLock(true);
|
||||
}
|
||||
else {
|
||||
|
@ -608,6 +607,11 @@ void MenuStateMasterserver::keyDown(char key) {
|
|||
console.addLine(lang.get("GameMusic"));
|
||||
}
|
||||
}
|
||||
else 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"))+ "]");
|
||||
}
|
||||
}
|
||||
|
||||
//CoreData::getInstance().getMenuMusic()->setVolume(strToInt(listBoxVolumeMusic.getSelectedItem())/100.f);
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
GraphicLabel externalConnectPort;
|
||||
|
||||
public:
|
||||
ServerLine( MasterServerInfo *mServerInfo, int lineIndex);
|
||||
ServerLine( MasterServerInfo *mServerInfo, int lineIndex, const char *containerName);
|
||||
virtual ~ServerLine();
|
||||
MasterServerInfo *getMasterServerInfo() const {return masterServerInfo;}
|
||||
const int getIndex() const {return index;}
|
||||
|
@ -70,8 +70,6 @@ typedef vector<ServerLine*> ServerLines;
|
|||
typedef vector<MasterServerInfo*> MasterServerInfos;
|
||||
|
||||
class MenuStateMasterserver : public MenuState, public SimpleTaskCallbackInterface {
|
||||
public:
|
||||
static const char *containerName;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -32,11 +32,10 @@ namespace Glest{ namespace Game{
|
|||
// class MenuStateNewGame
|
||||
// =====================================================
|
||||
|
||||
const char *MenuStateNewGame::containerName = "NewGame";
|
||||
|
||||
MenuStateNewGame::MenuStateNewGame(Program *program, MainMenu *mainMenu):
|
||||
MenuState(program, mainMenu, "root")
|
||||
{
|
||||
containerName = "NewGame";
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
buttonCustomGame.registerGraphicComponent(containerName,"buttonCustomGame");
|
||||
|
@ -105,4 +104,13 @@ void MenuStateNewGame::update(){
|
|||
}
|
||||
}
|
||||
|
||||
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"))+ "]");
|
||||
}
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Glest{ namespace Game{
|
|||
|
||||
class MenuStateNewGame: public MenuState{
|
||||
private:
|
||||
static const char *containerName;
|
||||
GraphicButton buttonCustomGame;
|
||||
GraphicButton buttonScenario;
|
||||
GraphicButton buttonTutorial;
|
||||
|
@ -36,6 +35,7 @@ public:
|
|||
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||
void update();
|
||||
void render();
|
||||
virtual void keyDown(char key);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -28,11 +28,10 @@ namespace Glest{ namespace Game{
|
|||
// =====================================================
|
||||
// class MenuStateOptions
|
||||
// =====================================================
|
||||
const char *MenuStateOptions::containerName = "Options";
|
||||
|
||||
MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||
MenuState(program, mainMenu, "config")
|
||||
{
|
||||
containerName = "Options";
|
||||
Lang &lang= Lang::getInstance();
|
||||
Config &config= Config::getInstance();
|
||||
//modeinfos=list<ModeInfo> ();
|
||||
|
@ -456,6 +455,15 @@ void MenuStateOptions::keyPress(char c){
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
if(c == configKeys.getCharKey("SaveGUILayout")) {
|
||||
bool saved = GraphicComponent::saveAllCustomProperties(containerName);
|
||||
//Lang &lang= Lang::getInstance();
|
||||
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MenuStateOptions::render(){
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Glest{ namespace Game{
|
|||
|
||||
class MenuStateOptions: public MenuState{
|
||||
private:
|
||||
static const char *containerName;
|
||||
|
||||
GraphicButton buttonOk;
|
||||
GraphicButton buttonAbort;
|
||||
|
|
|
@ -34,11 +34,10 @@ namespace Glest{ namespace Game{
|
|||
// class MenuStateRoot
|
||||
// =====================================================
|
||||
|
||||
const char *MenuStateRoot::containerName = "MainMenu";
|
||||
|
||||
MenuStateRoot::MenuStateRoot(Program *program, MainMenu *mainMenu):
|
||||
MenuState(program, mainMenu, "root")
|
||||
{
|
||||
containerName = "MainMenu";
|
||||
Lang &lang= Lang::getInstance();
|
||||
int i=375;
|
||||
|
||||
|
@ -203,6 +202,12 @@ void MenuStateRoot::keyDown(char key) {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
program->exit();
|
||||
}
|
||||
else 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"))+ "]");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MenuStateRoot::showMessageBox(const string &text, const string &header, bool toggle){
|
||||
|
|
|
@ -25,9 +25,6 @@ class GraphicMessageBox;
|
|||
|
||||
class MenuStateRoot: public MenuState{
|
||||
private:
|
||||
|
||||
static const char *containerName;
|
||||
|
||||
GraphicButton buttonNewGame;
|
||||
GraphicButton buttonJoinGame;
|
||||
GraphicButton buttonMasterserverGame;
|
||||
|
|
|
@ -34,9 +34,11 @@ using namespace Shared::Xml;
|
|||
MenuStateScenario::MenuStateScenario(Program *program, MainMenu *mainMenu, const vector<string> &dirList, string autoloadScenarioName):
|
||||
MenuState(program, mainMenu, "scenario")
|
||||
{
|
||||
containerName = "Scenario";
|
||||
Lang &lang= Lang::getInstance();
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
|
||||
mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox");
|
||||
mainMessageBox.init(lang.get("Ok"));
|
||||
mainMessageBox.setEnabled(false);
|
||||
mainMessageBoxState=0;
|
||||
|
@ -46,13 +48,20 @@ MenuStateScenario::MenuStateScenario(Program *program, MainMenu *mainMenu, const
|
|||
|
||||
this->dirList = dirList;
|
||||
|
||||
labelInfo.registerGraphicComponent(containerName,"labelInfo");
|
||||
labelInfo.init(350, 350);
|
||||
labelInfo.setFont(CoreData::getInstance().getMenuFontNormal());
|
||||
|
||||
buttonReturn.registerGraphicComponent(containerName,"buttonReturn");
|
||||
buttonReturn.init(350, 200, 125);
|
||||
|
||||
buttonPlayNow.registerGraphicComponent(containerName,"buttonPlayNow");
|
||||
buttonPlayNow.init(525, 200, 125);
|
||||
|
||||
listBoxScenario.registerGraphicComponent(containerName,"listBoxScenario");
|
||||
listBoxScenario.init(350, 400, 190);
|
||||
|
||||
labelScenario.registerGraphicComponent(containerName,"labelScenario");
|
||||
labelScenario.init(350, 430);
|
||||
|
||||
buttonReturn.setText(lang.get("Return"));
|
||||
|
@ -74,6 +83,8 @@ MenuStateScenario::MenuStateScenario(Program *program, MainMenu *mainMenu, const
|
|||
loadScenarioInfo(Scenario::getScenarioPath(dirList, scenarioFiles[listBoxScenario.getSelectedItemIndex()]), &scenarioInfo );
|
||||
labelInfo.setText(scenarioInfo.desc);
|
||||
|
||||
GraphicComponent::applyAllCustomProperties(containerName);
|
||||
|
||||
networkManager.init(nrServer);
|
||||
}
|
||||
|
||||
|
@ -324,4 +335,13 @@ void MenuStateScenario::showMessageBox(const string &text, const string &header,
|
|||
}
|
||||
}
|
||||
|
||||
void MenuStateScenario::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
|
||||
|
|
|
@ -61,6 +61,8 @@ public:
|
|||
void setScenario(int i);
|
||||
int getScenarioCount() const { return listBoxScenario.getItemCount(); }
|
||||
|
||||
virtual void keyDown(char key);
|
||||
|
||||
private:
|
||||
|
||||
void loadScenarioInfo(string file, ScenarioInfo *scenarioInfo);
|
||||
|
|
|
@ -95,6 +95,18 @@ const char vkDown = -10;
|
|||
const char vkReturn = -11;
|
||||
const char vkBack = -12;
|
||||
const char vkTab = -13;
|
||||
const char vkF1 = -14;
|
||||
const char vkF2 = -15;
|
||||
const char vkF3 = -16;
|
||||
const char vkF4 = -17;
|
||||
const char vkF5 = -18;
|
||||
const char vkF6 = -19;
|
||||
const char vkF7 = -20;
|
||||
const char vkF8 = -21;
|
||||
const char vkF9 = -22;
|
||||
const char vkF10 = -23;
|
||||
const char vkF11 = -24;
|
||||
const char vkF12 = -25;
|
||||
|
||||
enum WindowStyle{
|
||||
wsFullscreen,
|
||||
|
|
|
@ -184,6 +184,7 @@ bool Window::handleEvent() {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_KEYUP:
|
||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
@ -192,6 +193,8 @@ bool Window::handleEvent() {
|
|||
Window::isKeyPressedDown = false;
|
||||
keystate = event.key.keysym;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] KEY_UP, Raw SDL key [%d] mod [%d] unicode [%d] scancode [%d]\n",__FILE__,__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.scancode);
|
||||
|
||||
if(global_window) {
|
||||
global_window->eventKeyUp(getKey(event.key.keysym,true));
|
||||
}
|
||||
|
@ -569,6 +572,8 @@ MouseButton Window::getMouseButton(int sdlButton) {
|
|||
}
|
||||
|
||||
char Window::getKey(SDL_keysym keysym,bool skipSpecialKeys) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] keysym.sym [%d] skipSpecialKeys = %d.\n",__FILE__,__FUNCTION__,__LINE__,keysym.sym,skipSpecialKeys);
|
||||
|
||||
if(skipSpecialKeys == false) {
|
||||
switch(keysym.sym) {
|
||||
case SDLK_LALT:
|
||||
|
@ -615,6 +620,42 @@ char Window::getKey(SDL_keysym keysym,bool skipSpecialKeys) {
|
|||
return vkTab;
|
||||
case SDLK_BACKSPACE:
|
||||
return vkBack;
|
||||
case SDLK_F1:
|
||||
return vkF1;
|
||||
break;
|
||||
case SDLK_F2:
|
||||
return vkF2;
|
||||
break;
|
||||
case SDLK_F3:
|
||||
return vkF3;
|
||||
break;
|
||||
case SDLK_F4:
|
||||
return vkF4;
|
||||
break;
|
||||
case SDLK_F5:
|
||||
return vkF5;
|
||||
break;
|
||||
case SDLK_F6:
|
||||
return vkF6;
|
||||
break;
|
||||
case SDLK_F7:
|
||||
return vkF7;
|
||||
break;
|
||||
case SDLK_F8:
|
||||
return vkF8;
|
||||
break;
|
||||
case SDLK_F9:
|
||||
return vkF9;
|
||||
break;
|
||||
case SDLK_F10:
|
||||
return vkF10;
|
||||
break;
|
||||
case SDLK_F11:
|
||||
return vkF11;
|
||||
break;
|
||||
case SDLK_F12:
|
||||
return vkF12;
|
||||
break;
|
||||
case SDLK_0:
|
||||
return '0';
|
||||
case SDLK_1:
|
||||
|
|
Loading…
Reference in New Issue