QTfrontend/mapContainer.cpp
changeset 331 6bfc326e4976
parent 329 4c3aad46baa5
child 452 45fbb9df0c99
equal deleted inserted replaced
330:09cfe028a629 331:6bfc326e4976
    79   if(!index) {
    79   if(!index) {
    80     changeImage();
    80     changeImage();
    81     return;
    81     return;
    82   }
    82   }
    83 
    83 
       
    84   loadMap(index);
       
    85 
       
    86   emit mapChanged(chooseMap->currentText());
       
    87 }
       
    88 
       
    89 void HWMapContainer::loadMap(int index)
       
    90 {
    84   QPixmap mapImage;
    91   QPixmap mapImage;
    85   if(!mapImage.load(datadir->absolutePath() + "/Maps/" + chooseMap->currentText() + "/map.png")) {
    92   if(!mapImage.load(datadir->absolutePath() + "/Maps/" + chooseMap->currentText() + "/map.png")) {
    86     changeImage();
    93     changeImage();
    87     chooseMap->setCurrentIndex(0);
    94     chooseMap->setCurrentIndex(0);
    88     return;
    95     return;
    92   if (mapCfgFile.open(QFile::ReadOnly)) {
    99   if (mapCfgFile.open(QFile::ReadOnly)) {
    93     QTextStream input(&mapCfgFile);
   100     QTextStream input(&mapCfgFile);
    94     input >> theme;
   101     input >> theme;
    95     mapCfgFile.close();
   102     mapCfgFile.close();
    96   }
   103   }
    97   emit mapChanged(chooseMap->currentText());
       
    98 }
   104 }
    99 
   105 
   100 void HWMapContainer::changeImage()
   106 void HWMapContainer::changeImage()
   101 {
   107 {
   102   pMap = new HWMap();
   108   pMap = new HWMap();
   132 	changeImage();
   138 	changeImage();
   133 }
   139 }
   134 
   140 
   135 void HWMapContainer::setMap(const QString & map)
   141 void HWMapContainer::setMap(const QString & map)
   136 {
   142 {
   137 
   143 	int id = chooseMap->findText(map);
       
   144 	if(id >= 0) {
       
   145 		chooseMap->setCurrentIndex(id);
       
   146 		loadMap(id);
       
   147 	}
   138 }
   148 }
   139 
   149 
   140 void HWMapContainer::setTheme(const QString & theme)
   150 void HWMapContainer::setTheme(const QString & theme)
   141 {
   151 {
   142 	this->theme = theme;
   152 	this->theme = theme;