parent
68153878a0
commit
8d1ff2fadd
|
@ -739,14 +739,24 @@ void GraphicComboBox::init(int x, int y, int w, int h, Vec3f textColor){
|
|||
scrollBar.setVisibleStart(0);
|
||||
scrollBar.setLighted(false);
|
||||
scrollBar.setVisible(true);
|
||||
setPopupLineCount(popupLineCount);
|
||||
|
||||
selectedItemIndex=-1;
|
||||
popupShowing=false;
|
||||
lighted=false;
|
||||
preselectedItemIndex=-1;
|
||||
|
||||
}
|
||||
|
||||
void GraphicComboBox::setPopupLineCount(int popupLineCount) {
|
||||
this->popupLineCount = popupLineCount;
|
||||
int scrollBarLength=popupLineCount*popupButtonHeight;
|
||||
int popupYpos=getY()+getH();
|
||||
if( y>200) popupYpos=y-scrollBarLength;
|
||||
scrollBar.setY(popupYpos);
|
||||
scrollBar.setLength(scrollBarLength);
|
||||
scrollBar.setVisibleSize(popupLineCount);
|
||||
}
|
||||
|
||||
const string & GraphicComboBox::getTextNativeTranslation(int index) {
|
||||
if(this->translated_items.empty() == true ||
|
||||
index < 0 ||
|
||||
|
|
|
@ -412,10 +412,7 @@ public:
|
|||
virtual const string &getTextNativeTranslation();
|
||||
|
||||
int getPopupLineCount() const {return popupLineCount;}
|
||||
void setPopupLineCount(int popupLineCount) {
|
||||
this->popupLineCount = popupLineCount;
|
||||
scrollBar.setLength(popupLineCount * popupButtonHeight);
|
||||
}
|
||||
void setPopupLineCount(int popupLineCount);
|
||||
|
||||
int getPopupButtonHeight() const {return popupButtonHeight; }
|
||||
void setPopupButtonHeight(int popupButtonHeight) {
|
||||
|
|
|
@ -323,13 +323,13 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
|||
listBoxMapFilter.setSelectedItemIndex(0);
|
||||
|
||||
//map listBox
|
||||
listBoxMap.registerGraphicComponent(containerName,"listBoxMap");
|
||||
listBoxMap.init(xoffset+100, mapPos, 220);
|
||||
lcomboBoxMap.registerGraphicComponent(containerName,"listBoxMap");
|
||||
lcomboBoxMap.init(xoffset+100, mapPos, 220);
|
||||
// put them all in a set, to weed out duplicates (gbm & mgm with same name)
|
||||
// will also ensure they are alphabetically listed (rather than how the OS provides them)
|
||||
int initialMapSelection = setupMapList("");
|
||||
listBoxMap.setItems(formattedPlayerSortedMaps[0]);
|
||||
listBoxMap.setSelectedItemIndex(initialMapSelection);
|
||||
lcomboBoxMap.setItems(formattedPlayerSortedMaps[0]);
|
||||
lcomboBoxMap.setSelectedItemIndex(initialMapSelection);
|
||||
|
||||
labelMapInfo.registerGraphicComponent(containerName,"labelMapInfo");
|
||||
labelMapInfo.init(xoffset+100, mapPos-labelOffset-10, 200, 40);// position is set by update() !
|
||||
|
@ -1056,7 +1056,7 @@ void MenuStateCustomGame::returnToParentMenu() {
|
|||
|
||||
void MenuStateCustomGame::mouseUp(int x, int y, const MouseButton mouseButton){
|
||||
if (mouseButton == mbLeft) {
|
||||
listBoxMap.mouseUp(x, y);
|
||||
lcomboBoxMap.mouseUp(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1079,7 +1079,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(listBoxMap.mouseClick(x, y)){
|
||||
else if(lcomboBoxMap.mouseClick(x, y)){
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n", getCurrentMapFile().c_str());
|
||||
|
||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
|
@ -1100,7 +1100,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
|
|||
mapPublishingDelayTimer=time(NULL);
|
||||
}
|
||||
}
|
||||
else if(listBoxMap.isDropDownShowing()){
|
||||
else if(lcomboBoxMap.isDropDownShowing()){
|
||||
//do nothing
|
||||
}
|
||||
else {
|
||||
|
@ -2023,10 +2023,10 @@ void MenuStateCustomGame::mouseMove(int x, int y, const MouseState *ms) {
|
|||
}
|
||||
|
||||
if (ms->get(mbLeft)) {
|
||||
listBoxMap.mouseDown(x, y);
|
||||
lcomboBoxMap.mouseDown(x, y);
|
||||
}
|
||||
if (listBoxMap.isDropDownShowing()) {
|
||||
listBoxMap.mouseMove(x, y);
|
||||
if (lcomboBoxMap.isDropDownShowing()) {
|
||||
lcomboBoxMap.mouseMove(x, y);
|
||||
loadMapInfo(Config::getMapPath(getCurrentMapFile(), "", false), &mapInfo, true, false);
|
||||
labelMapInfo.setText(mapInfo.desc);
|
||||
}
|
||||
|
@ -2296,7 +2296,7 @@ void MenuStateCustomGame::render() {
|
|||
renderer.renderLabel(&labelMapInfo);
|
||||
renderer.renderLabel(&labelAdvanced);
|
||||
|
||||
renderer.renderComboBox(&listBoxMap);
|
||||
renderer.renderComboBox(&lcomboBoxMap);
|
||||
renderer.renderListBox(&listBoxTileset);
|
||||
renderer.renderListBox(&listBoxMapFilter);
|
||||
renderer.renderListBox(&listBoxTechTree);
|
||||
|
@ -2490,7 +2490,7 @@ void MenuStateCustomGame::update() {
|
|||
buttonClearBlockedPlayers.setEditable( serverInterface->getServerSocket()->hasBlockedIPAddresses());
|
||||
}
|
||||
|
||||
if(listBoxMap.isDropDownShowing()){
|
||||
if(lcomboBoxMap.isDropDownShowing()){
|
||||
labelMapInfo.setX(0);
|
||||
labelMapInfo.setY(mapPreviewTexture_Y-30);
|
||||
}
|
||||
|
@ -2718,8 +2718,8 @@ void MenuStateCustomGame::update() {
|
|||
label = label + " map";
|
||||
|
||||
if(serverInterface->getSlot(i,true)->getReceivedDataSynchCheck() == true &&
|
||||
lastMapDataSynchError != "map CRC mismatch, " + listBoxMap.getSelectedItem()) {
|
||||
lastMapDataSynchError = "map CRC mismatch, " + listBoxMap.getSelectedItem();
|
||||
lastMapDataSynchError != "map CRC mismatch, " + lcomboBoxMap.getSelectedItem()) {
|
||||
lastMapDataSynchError = "map CRC mismatch, " + lcomboBoxMap.getSelectedItem();
|
||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||
serverInterface->sendTextMessage(lastMapDataSynchError,-1, true,"");
|
||||
}
|
||||
|
@ -4074,8 +4074,8 @@ void MenuStateCustomGame::setupUIFromGameSettings(const GameSettings &gameSettin
|
|||
//printf("#6.2\n");
|
||||
|
||||
listBoxMapFilter.setSelectedItemIndex(0);
|
||||
listBoxMap.setItems(formattedPlayerSortedMaps[mapInfo.players]);
|
||||
listBoxMap.setSelectedItem(formatString(scenarioInfo.mapName));
|
||||
lcomboBoxMap.setItems(formattedPlayerSortedMaps[mapInfo.players]);
|
||||
lcomboBoxMap.setSelectedItem(formatString(scenarioInfo.mapName));
|
||||
}
|
||||
else {
|
||||
//printf("gameSettings.getMapFilter()=%d \n",gameSettings.getMapFilter());
|
||||
|
@ -4085,7 +4085,7 @@ void MenuStateCustomGame::setupUIFromGameSettings(const GameSettings &gameSettin
|
|||
else {
|
||||
listBoxMapFilter.setSelectedItem(intToStr(gameSettings.getMapFilter()));
|
||||
}
|
||||
listBoxMap.setItems(formattedPlayerSortedMaps[gameSettings.getMapFilter()]);
|
||||
lcomboBoxMap.setItems(formattedPlayerSortedMaps[gameSettings.getMapFilter()]);
|
||||
}
|
||||
|
||||
//printf("gameSettings.getMap() [%s] [%s]\n",gameSettings.getMap().c_str(),listBoxMap.getSelectedItem().c_str());
|
||||
|
@ -4093,7 +4093,7 @@ void MenuStateCustomGame::setupUIFromGameSettings(const GameSettings &gameSettin
|
|||
string mapFile = gameSettings.getMap();
|
||||
if(find(mapFiles.begin(),mapFiles.end(),mapFile) != mapFiles.end()) {
|
||||
mapFile = formatString(mapFile);
|
||||
listBoxMap.setSelectedItem(mapFile);
|
||||
lcomboBoxMap.setSelectedItem(mapFile);
|
||||
|
||||
loadMapInfo(Config::getMapPath(getCurrentMapFile(),scenarioDir,true), &mapInfo, true,true);
|
||||
labelMapInfo.setText(mapInfo.desc);
|
||||
|
@ -4685,12 +4685,12 @@ void MenuStateCustomGame::switchToNextMapGroup(const int direction){
|
|||
}
|
||||
}
|
||||
listBoxMapFilter.setSelectedItemIndex(i);
|
||||
listBoxMap.setItems(formattedPlayerSortedMaps[i]);
|
||||
lcomboBoxMap.setItems(formattedPlayerSortedMaps[i]);
|
||||
}
|
||||
|
||||
string MenuStateCustomGame::getCurrentMapFile(){
|
||||
int i=listBoxMapFilter.getSelectedItemIndex();
|
||||
int mapIndex=listBoxMap.getPreselectedItemIndex();
|
||||
int mapIndex=lcomboBoxMap.getPreselectedItemIndex();
|
||||
if(playerSortedMaps[i].empty() == false) {
|
||||
return playerSortedMaps[i].at(mapIndex);
|
||||
}
|
||||
|
@ -4827,7 +4827,7 @@ void MenuStateCustomGame::processScenario() {
|
|||
listBoxTileset.setSelectedItem(formatString(scenarioInfo.tilesetName));
|
||||
|
||||
setupMapList(scenarioInfo.name);
|
||||
listBoxMap.setSelectedItem(formatString(scenarioInfo.mapName));
|
||||
lcomboBoxMap.setSelectedItem(formatString(scenarioInfo.mapName));
|
||||
loadMapInfo(Config::getMapPath(getCurrentMapFile(),scenarioDir,true), &mapInfo, true,true);
|
||||
labelMapInfo.setText(mapInfo.desc);
|
||||
|
||||
|
@ -4956,7 +4956,7 @@ void MenuStateCustomGame::processScenario() {
|
|||
}
|
||||
else {
|
||||
setupMapList("");
|
||||
listBoxMap.setSelectedItem(formatString(formattedPlayerSortedMaps[0][0]));
|
||||
lcomboBoxMap.setSelectedItem(formatString(formattedPlayerSortedMaps[0][0]));
|
||||
loadMapInfo(Config::getMapPath(getCurrentMapFile(),"",true), &mapInfo, true,true);
|
||||
labelMapInfo.setText(mapInfo.desc);
|
||||
|
||||
|
@ -4999,7 +4999,7 @@ void MenuStateCustomGame::SetupUIForScenarios() {
|
|||
checkBoxEnableSwitchTeamMode.setEditable(false);
|
||||
listBoxAISwitchTeamAcceptPercent.setEditable(false);
|
||||
listBoxFallbackCpuMultiplier.setEditable(false);
|
||||
listBoxMap.setEditable(false);
|
||||
lcomboBoxMap.setEditable(false);
|
||||
listBoxTileset.setEditable(false);
|
||||
listBoxMapFilter.setEditable(false);
|
||||
listBoxTechTree.setEditable(false);
|
||||
|
@ -5021,7 +5021,7 @@ void MenuStateCustomGame::SetupUIForScenarios() {
|
|||
checkBoxEnableSwitchTeamMode.setEditable(true);
|
||||
listBoxAISwitchTeamAcceptPercent.setEditable(true);
|
||||
listBoxFallbackCpuMultiplier.setEditable(true);
|
||||
listBoxMap.setEditable(true);
|
||||
lcomboBoxMap.setEditable(true);
|
||||
listBoxTileset.setEditable(true);
|
||||
listBoxMapFilter.setEditable(true);
|
||||
listBoxTechTree.setEditable(true);
|
||||
|
@ -5097,11 +5097,11 @@ int MenuStateCustomGame::setupMapList(string scenario) {
|
|||
loadMapInfo(Config::getMapPath(scenarioInfo.mapName, scenarioDir, true), &mapInfo, false,true);
|
||||
//printf("#6.2\n");
|
||||
listBoxMapFilter.setSelectedItem(intToStr(mapInfo.players));
|
||||
listBoxMap.setItems(formattedPlayerSortedMaps[mapInfo.players]);
|
||||
lcomboBoxMap.setItems(formattedPlayerSortedMaps[mapInfo.players]);
|
||||
}
|
||||
else {
|
||||
listBoxMapFilter.setSelectedItemIndex(0);
|
||||
listBoxMap.setItems(formattedPlayerSortedMaps[0]);
|
||||
lcomboBoxMap.setItems(formattedPlayerSortedMaps[0]);
|
||||
}
|
||||
//printf("#7\n");
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ private:
|
|||
GraphicLabel labelMapInfo;
|
||||
GraphicLabel labelGameName;
|
||||
|
||||
GraphicComboBox listBoxMap;
|
||||
GraphicComboBox lcomboBoxMap;
|
||||
GraphicListBox listBoxFogOfWar;
|
||||
GraphicListBox listBoxTechTree;
|
||||
GraphicListBox listBoxTileset;
|
||||
|
|
|
@ -69,7 +69,7 @@ MenuStateScenario::MenuStateScenario(Program *program, MainMenu *mainMenu,
|
|||
this->dirList = dirList;
|
||||
|
||||
int buttonStartY=50;
|
||||
int buttonStartX=70;
|
||||
int buttonStartX=50;
|
||||
|
||||
buttonReturn.registerGraphicComponent(containerName,"buttonReturn");
|
||||
buttonReturn.init(buttonStartX, buttonStartY, 125);
|
||||
|
@ -85,16 +85,17 @@ MenuStateScenario::MenuStateScenario(Program *program, MainMenu *mainMenu,
|
|||
labelScenario.registerGraphicComponent(containerName,"labelScenario");
|
||||
labelScenario.init(startX, startY);
|
||||
|
||||
listBoxScenario.registerGraphicComponent(containerName,"listBoxScenario");
|
||||
listBoxScenario.init(startX, startY-30, 290);
|
||||
comboBoxScenario.registerGraphicComponent(containerName,"listBoxScenario");
|
||||
comboBoxScenario.init(startX, startY-20, 290);
|
||||
comboBoxScenario.setPopupLineCount(30);
|
||||
|
||||
labelScenarioName.registerGraphicComponent(containerName,"labelScenarioName");
|
||||
labelScenarioName.init(startX, startY-80);
|
||||
labelScenarioName.init(500, startY);
|
||||
labelScenarioName.setFont(CoreData::getInstance().getMenuFontBig());
|
||||
labelScenarioName.setFont3D(CoreData::getInstance().getMenuFontBig3D());
|
||||
|
||||
labelInfo.registerGraphicComponent(containerName,"labelInfo");
|
||||
labelInfo.init(startX, startY-110);
|
||||
labelInfo.init(500, startY-30);
|
||||
labelInfo.setFont(CoreData::getInstance().getMenuFontNormal());
|
||||
labelInfo.setFont3D(CoreData::getInstance().getMenuFontNormal3D());
|
||||
|
||||
|
@ -125,13 +126,13 @@ MenuStateScenario::MenuStateScenario(Program *program, MainMenu *mainMenu,
|
|||
for(int i= 0; i < (int)results.size(); ++i){
|
||||
results[i] = formatString(results[i]);
|
||||
}
|
||||
listBoxScenario.setItems(results);
|
||||
comboBoxScenario.setItems(results);
|
||||
|
||||
try {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] listBoxScenario.getSelectedItemIndex() = %d scenarioFiles.size() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,listBoxScenario.getSelectedItemIndex(),(int)scenarioFiles.size());
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] listBoxScenario.getSelectedItemIndex() = %d scenarioFiles.size() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,comboBoxScenario.getSelectedItemIndex(),(int)scenarioFiles.size());
|
||||
|
||||
if(listBoxScenario.getItemCount() > 0 && listBoxScenario.getSelectedItemIndex() >= 0 && listBoxScenario.getSelectedItemIndex() < (int)scenarioFiles.size()) {
|
||||
string scenarioPath = Scenario::getScenarioPath(dirList, scenarioFiles[listBoxScenario.getSelectedItemIndex()]);
|
||||
if(comboBoxScenario.getItemCount() > 0 && comboBoxScenario.getSelectedItemIndex() >= 0 && comboBoxScenario.getSelectedItemIndex() < (int)scenarioFiles.size()) {
|
||||
string scenarioPath = Scenario::getScenarioPath(dirList, scenarioFiles[comboBoxScenario.getSelectedItemIndex()]);
|
||||
//printf("scenarioPath [%s]\n",scenarioPath.c_str());
|
||||
|
||||
loadScenarioInfo(scenarioPath, &scenarioInfo );
|
||||
|
@ -140,7 +141,7 @@ MenuStateScenario::MenuStateScenario(Program *program, MainMenu *mainMenu,
|
|||
labelScenarioName.setText(scenarioInfo.namei18n);
|
||||
}
|
||||
else {
|
||||
labelScenarioName.setText(listBoxScenario.getSelectedItem());
|
||||
labelScenarioName.setText(comboBoxScenario.getSelectedItem());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,7 +204,6 @@ void MenuStateScenario::cleanupPreviewTexture() {
|
|||
void MenuStateScenario::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||
string advanceToItemStartingWith = "";
|
||||
|
||||
if(mainMessageBox.getEnabled()){
|
||||
int button= 0;
|
||||
|
@ -220,15 +220,6 @@ void MenuStateScenario::mouseClick(int x, int y, MouseButton mouseButton) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if(::Shared::Platform::Window::isKeyStateModPressed(KMOD_SHIFT) == true) {
|
||||
const wchar_t lastKey = ::Shared::Platform::Window::extractLastKeyPressed();
|
||||
// xxx:
|
||||
// string hehe=lastKey;
|
||||
// printf("lastKey = %d [%c] '%s'\n",lastKey,lastKey,hehe);
|
||||
advanceToItemStartingWith = lastKey;
|
||||
}
|
||||
}
|
||||
|
||||
if(buttonReturn.mouseClick(x,y)){
|
||||
soundRenderer.playFx(coreData.getClickSoundA());
|
||||
|
@ -240,18 +231,18 @@ void MenuStateScenario::mouseClick(int x, int y, MouseButton mouseButton) {
|
|||
launchGame();
|
||||
return;
|
||||
}
|
||||
else if(listBoxScenario.mouseClick(x, y,advanceToItemStartingWith)){
|
||||
else if(comboBoxScenario.mouseClick(x, y)){
|
||||
try {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] listBoxScenario.getSelectedItemIndex() = %d scenarioFiles.size() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,listBoxScenario.getSelectedItemIndex(),(int)scenarioFiles.size());
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] listBoxScenario.getSelectedItemIndex() = %d scenarioFiles.size() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,comboBoxScenario.getSelectedItemIndex(),(int)scenarioFiles.size());
|
||||
|
||||
if(listBoxScenario.getItemCount() > 0 && listBoxScenario.getSelectedItemIndex() >= 0 && listBoxScenario.getSelectedItemIndex() < (int)scenarioFiles.size()) {
|
||||
loadScenarioInfo(Scenario::getScenarioPath(dirList, scenarioFiles[listBoxScenario.getSelectedItemIndex()]), &scenarioInfo);
|
||||
if(comboBoxScenario.getItemCount() > 0 && comboBoxScenario.getSelectedItemIndex() >= 0 && comboBoxScenario.getSelectedItemIndex() < (int)scenarioFiles.size()) {
|
||||
loadScenarioInfo(Scenario::getScenarioPath(dirList, scenarioFiles[comboBoxScenario.getSelectedItemIndex()]), &scenarioInfo);
|
||||
labelInfo.setText(scenarioInfo.desc);
|
||||
if(scenarioInfo.namei18n != "") {
|
||||
labelScenarioName.setText(scenarioInfo.namei18n);
|
||||
}
|
||||
else {
|
||||
labelScenarioName.setText(listBoxScenario.getSelectedItem());
|
||||
labelScenarioName.setText(comboBoxScenario.getSelectedItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -273,7 +264,21 @@ void MenuStateScenario::mouseMove(int x, int y, const MouseState *ms){
|
|||
mainMessageBox.mouseMove(x, y);
|
||||
}
|
||||
|
||||
listBoxScenario.mouseMove(x, y);
|
||||
if (ms->get(mbLeft)) {
|
||||
comboBoxScenario.mouseDown(x, y);
|
||||
}
|
||||
if (comboBoxScenario.isDropDownShowing()) {
|
||||
comboBoxScenario.mouseMove(x, y);
|
||||
if(comboBoxScenario.getItemCount() > 0 && comboBoxScenario.getPreselectedItemIndex() >= 0 && comboBoxScenario.getPreselectedItemIndex() < (int)scenarioFiles.size()) {
|
||||
loadScenarioInfo(Scenario::getScenarioPath(dirList, scenarioFiles[comboBoxScenario.getPreselectedItemIndex()]), &scenarioInfo);
|
||||
labelInfo.setText(scenarioInfo.desc);
|
||||
if (scenarioInfo.namei18n != "") {
|
||||
labelScenarioName.setText(scenarioInfo.namei18n);
|
||||
} else {
|
||||
labelScenarioName.setText(comboBoxScenario.getPreselectedItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buttonReturn.mouseMove(x, y);
|
||||
buttonPlayNow.mouseMove(x, y);
|
||||
|
@ -296,7 +301,7 @@ void MenuStateScenario::render(){
|
|||
renderer.renderLabel(&labelScenarioName);
|
||||
|
||||
renderer.renderLabel(&labelScenario);
|
||||
renderer.renderListBox(&listBoxScenario);
|
||||
renderer.renderComboBox(&comboBoxScenario);
|
||||
|
||||
renderer.renderButton(&buttonReturn);
|
||||
renderer.renderButton(&buttonPlayNow);
|
||||
|
@ -327,9 +332,9 @@ void MenuStateScenario::update() {
|
|||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("[%s:%s] Line: %d this->autoloadScenarioName [%s] scenarioPath [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->autoloadScenarioName.c_str(),scenarioPath.c_str());
|
||||
printf("[%s:%s] Line: %d this->autoloadScenarioName [%s] scenarioPath [%s] file [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->autoloadScenarioName.c_str(),scenarioPath.c_str(),scenarioInfo.file.c_str());
|
||||
|
||||
listBoxScenario.setSelectedItem(this->autoloadScenarioName,false);
|
||||
comboBoxScenario.setSelectedItem(this->autoloadScenarioName,false);
|
||||
|
||||
if(listBoxScenario.getSelectedItem() != this->autoloadScenarioName) {
|
||||
if(comboBoxScenario.getSelectedItem() != this->autoloadScenarioName) {
|
||||
mainMessageBoxState=1;
|
||||
showMessageBox( "Could not find scenario name: " + this->autoloadScenarioName, "Scenario Missing", false);
|
||||
this->autoloadScenarioName = "";
|
||||
|
@ -337,12 +342,12 @@ void MenuStateScenario::update() {
|
|||
else {
|
||||
try {
|
||||
this->autoloadScenarioName = "";
|
||||
if(listBoxScenario.getItemCount() > 0 && listBoxScenario.getSelectedItemIndex() >= 0 &&
|
||||
listBoxScenario.getSelectedItemIndex() < (int)scenarioFiles.size()) {
|
||||
if(comboBoxScenario.getItemCount() > 0 && comboBoxScenario.getSelectedItemIndex() >= 0 &&
|
||||
comboBoxScenario.getSelectedItemIndex() < (int)scenarioFiles.size()) {
|
||||
|
||||
printf("[%s:%s] Line: %d scenarioFiles[listBoxScenario.getSelectedItemIndex()] [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,scenarioFiles[listBoxScenario.getSelectedItemIndex()].c_str());
|
||||
printf("[%s:%s] Line: %d scenarioFiles[listBoxScenario.getSelectedItemIndex()] [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,scenarioFiles[comboBoxScenario.getSelectedItemIndex()].c_str());
|
||||
|
||||
loadScenarioInfo(Scenario::getScenarioPath(dirList, scenarioFiles[listBoxScenario.getSelectedItemIndex()]), &scenarioInfo);
|
||||
loadScenarioInfo(Scenario::getScenarioPath(dirList, scenarioFiles[comboBoxScenario.getSelectedItemIndex()]), &scenarioInfo);
|
||||
|
||||
printf("[%s:%s] Line: %d scenarioInfo.file [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,scenarioInfo.file.c_str());
|
||||
|
||||
|
@ -351,7 +356,7 @@ void MenuStateScenario::update() {
|
|||
labelScenarioName.setText(scenarioInfo.namei18n);
|
||||
}
|
||||
else {
|
||||
labelScenarioName.setText(listBoxScenario.getSelectedItem());
|
||||
labelScenarioName.setText(comboBoxScenario.getSelectedItem());
|
||||
}
|
||||
|
||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||
|
@ -409,13 +414,16 @@ void MenuStateScenario::launchGame() {
|
|||
}
|
||||
|
||||
void MenuStateScenario::setScenario(int i) {
|
||||
listBoxScenario.setSelectedItemIndex(i);
|
||||
loadScenarioInfo(Scenario::getScenarioPath(dirList, scenarioFiles[listBoxScenario.getSelectedItemIndex()]), &scenarioInfo);
|
||||
comboBoxScenario.setSelectedItemIndex(i);
|
||||
loadScenarioInfo(Scenario::getScenarioPath(dirList, scenarioFiles[comboBoxScenario.getSelectedItemIndex()]), &scenarioInfo);
|
||||
}
|
||||
|
||||
void MenuStateScenario::loadScenarioInfo(string file, ScenarioInfo *scenarioInfo) {
|
||||
bool isTutorial = Scenario::isGameTutorial(file);
|
||||
|
||||
if( file==""){
|
||||
scenarioInfo->desc="Error: scenario broken! Xml-File Not Found";
|
||||
return;
|
||||
}
|
||||
//printf("[%s:%s] Line: %d file [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,file.c_str());
|
||||
|
||||
Scenario::loadScenarioInfo(file, scenarioInfo, isTutorial);
|
||||
|
@ -428,7 +436,7 @@ void MenuStateScenario::loadScenarioInfo(string file, ScenarioInfo *scenarioInfo
|
|||
void MenuStateScenario::loadScenarioPreviewTexture(){
|
||||
if(enableScenarioTexturePreview == true) {
|
||||
//if(listBoxScenario.getSelectedItemIndex() >= 0) {
|
||||
if(listBoxScenario.getItemCount() > 0 && listBoxScenario.getSelectedItemIndex() >= 0 && listBoxScenario.getSelectedItemIndex() < (int)scenarioFiles.size()) {
|
||||
if(comboBoxScenario.getItemCount() > 0 && comboBoxScenario.getSelectedItemIndex() >= 0 && comboBoxScenario.getSelectedItemIndex() < (int)scenarioFiles.size()) {
|
||||
GameSettings gameSettings;
|
||||
loadGameSettings(&scenarioInfo, &gameSettings);
|
||||
|
||||
|
@ -452,18 +460,18 @@ void MenuStateScenario::loadScenarioPreviewTexture(){
|
|||
}
|
||||
|
||||
void MenuStateScenario::loadGameSettings(const ScenarioInfo *scenarioInfo, GameSettings *gameSettings){
|
||||
if(listBoxScenario.getSelectedItemIndex() < 0) {
|
||||
if(comboBoxScenario.getSelectedItemIndex() < 0) {
|
||||
char szBuf[8096]="";
|
||||
snprintf(szBuf,8096,"listBoxScenario.getSelectedItemIndex() < 0, = %d",listBoxScenario.getSelectedItemIndex());
|
||||
snprintf(szBuf,8096,"listBoxScenario.getSelectedItemIndex() < 0, = %d",comboBoxScenario.getSelectedItemIndex());
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
else if(listBoxScenario.getSelectedItemIndex() >= (int)scenarioFiles.size()) {
|
||||
else if(comboBoxScenario.getSelectedItemIndex() >= (int)scenarioFiles.size()) {
|
||||
char szBuf[8096]="";
|
||||
snprintf(szBuf,8096,"listBoxScenario.getSelectedItemIndex() >= scenarioFiles.size(), = [%d][%d]",listBoxScenario.getSelectedItemIndex(),(int)scenarioFiles.size());
|
||||
snprintf(szBuf,8096,"listBoxScenario.getSelectedItemIndex() >= scenarioFiles.size(), = [%d][%d]",comboBoxScenario.getSelectedItemIndex(),(int)scenarioFiles.size());
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
Scenario::loadGameSettings(dirList,scenarioInfo, gameSettings, formatString(scenarioFiles[listBoxScenario.getSelectedItemIndex()]));
|
||||
Scenario::loadGameSettings(dirList,scenarioInfo, gameSettings, formatString(scenarioFiles[comboBoxScenario.getSelectedItemIndex()]));
|
||||
}
|
||||
|
||||
void MenuStateScenario::showMessageBox(const string &text, const string &header, bool toggle){
|
||||
|
|
|
@ -29,7 +29,7 @@ private:
|
|||
|
||||
GraphicLabel labelInfo;
|
||||
GraphicLabel labelScenario;
|
||||
GraphicListBox listBoxScenario;
|
||||
GraphicComboBox comboBoxScenario;
|
||||
GraphicLabel labelScenarioName;
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ public:
|
|||
|
||||
void launchGame();
|
||||
void setScenario(int i);
|
||||
int getScenarioCount() const { return listBoxScenario.getItemCount(); }
|
||||
int getScenarioCount() const { return comboBoxScenario.getItemCount(); }
|
||||
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
|
||||
|
|
Loading…
Reference in New Issue