mirror of
https://github.com/glest/glest-source.git
synced 2025-10-01 18:06:44 +02:00
- bugfix when reloading saved settings and item doesn't exist in listbox (thanks tomryen)
This commit is contained in:
@@ -334,6 +334,16 @@ void GraphicListBox::setEditable(bool editable){
|
|||||||
GraphicComponent::setEditable(editable);
|
GraphicComponent::setEditable(editable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GraphicListBox::hasItem(string item) const {
|
||||||
|
bool result = false;
|
||||||
|
vector<string>::const_iterator iter= find(items.begin(), items.end(), item);
|
||||||
|
if(iter != items.end()) {
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void GraphicListBox::setSelectedItem(string item, bool errorOnMissing){
|
void GraphicListBox::setSelectedItem(string item, bool errorOnMissing){
|
||||||
vector<string>::iterator iter;
|
vector<string>::iterator iter;
|
||||||
|
|
||||||
|
@@ -205,6 +205,8 @@ public:
|
|||||||
void setSelectedItem(string item, bool errorOnMissing=true);
|
void setSelectedItem(string item, bool errorOnMissing=true);
|
||||||
void setEditable(bool editable);
|
void setEditable(bool editable);
|
||||||
|
|
||||||
|
bool hasItem(string item) const;
|
||||||
|
|
||||||
virtual void setY(int y);
|
virtual void setY(int y);
|
||||||
|
|
||||||
virtual bool mouseMove(int x, int y);
|
virtual bool mouseMove(int x, int y);
|
||||||
|
@@ -2699,7 +2699,9 @@ void MenuStateCustomGame::setupUIFromGameSettings(const GameSettings &gameSettin
|
|||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d] gameSettings.getFactionCount() = %d\n",__FILE__,__FUNCTION__,__LINE__,gameSettings.getFactionCount());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d] gameSettings.getFactionCount() = %d\n",__FILE__,__FUNCTION__,__LINE__,gameSettings.getFactionCount());
|
||||||
|
|
||||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||||
listBoxControls[i].setSelectedItemIndex(gameSettings.getFactionControl(i));
|
if(gameSettings.getFactionControl(i) < listBoxControls[i].getItemCount()) {
|
||||||
|
listBoxControls[i].setSelectedItemIndex(gameSettings.getFactionControl(i));
|
||||||
|
}
|
||||||
updateResourceMultiplier(i);
|
updateResourceMultiplier(i);
|
||||||
listBoxRMultiplier[i].setSelectedItemIndex(gameSettings.getResourceMultiplierIndex(i));
|
listBoxRMultiplier[i].setSelectedItemIndex(gameSettings.getResourceMultiplierIndex(i));
|
||||||
listBoxTeams[i].setSelectedItemIndex(gameSettings.getTeam(i));
|
listBoxTeams[i].setSelectedItemIndex(gameSettings.getTeam(i));
|
||||||
@@ -2710,7 +2712,12 @@ void MenuStateCustomGame::setupUIFromGameSettings(const GameSettings &gameSettin
|
|||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] factionName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,factionName.c_str());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] factionName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,factionName.c_str());
|
||||||
|
|
||||||
listBoxFactions[i].setSelectedItem(factionName);
|
if(listBoxFactions[i].hasItem(factionName) == true) {
|
||||||
|
listBoxFactions[i].setSelectedItem(factionName);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
listBoxFactions[i].setSelectedItem(formatString(GameConstants::RANDOMFACTION_SLOTNAME));
|
||||||
|
}
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] i = %d, gameSettings.getNetworkPlayerName(i) [%s]\n",__FILE__,__FUNCTION__,__LINE__,i,gameSettings.getNetworkPlayerName(i).c_str());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] i = %d, gameSettings.getNetworkPlayerName(i) [%s]\n",__FILE__,__FUNCTION__,__LINE__,i,gameSettings.getNetworkPlayerName(i).c_str());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user