QTfrontend/ui/widget/selectWeapon.cpp
changeset 13196 f93658732448
parent 13195 7d9462d49d4c
child 13314 fe85ba81b01b
equal deleted inserted replaced
13195:7d9462d49d4c 13196:f93658732448
   109                 wconf->setValue(keys[i], fixWeaponSet(old_wconf.value(keys[i]).toString()));
   109                 wconf->setValue(keys[i], fixWeaponSet(old_wconf.value(keys[i]).toString()));
   110                 QFile file(cfgdir->absolutePath() + "/Schemes/Ammo/" + keys[i] + ".hwa");
   110                 QFile file(cfgdir->absolutePath() + "/Schemes/Ammo/" + keys[i] + ".hwa");
   111                 if (file.open(QIODevice::WriteOnly)) {
   111                 if (file.open(QIODevice::WriteOnly)) {
   112                     QTextStream stream( &file );
   112                     QTextStream stream( &file );
   113                     stream << old_wconf.value(keys[i]).toString() << endl;
   113                     stream << old_wconf.value(keys[i]).toString() << endl;
       
   114                     file.close();
   114                 }
   115                 }
   115                 imported++;
   116                 imported++;
   116             }
   117             }
   117         }
   118         }
   118         qDebug("%d weapon scheme(s) imported.", imported);
   119         qDebug("%d weapon scheme(s) imported.", imported);
   129         {
   130         {
   130             if (schemes[i] == "." || schemes[i] == "..") continue;
   131             if (schemes[i] == "." || schemes[i] == "..") continue;
   131 
   132 
   132             QFile file(cfgdir->absolutePath() + "/Schemes/Ammo/" + schemes[i]);
   133             QFile file(cfgdir->absolutePath() + "/Schemes/Ammo/" + schemes[i]);
   133             QString config;
   134             QString config;
   134 
       
   135             if (file.open(QIODevice::ReadOnly)) {
   135             if (file.open(QIODevice::ReadOnly)) {
   136                 QTextStream stream( &file );
   136                 QTextStream stream( &file );
   137                 stream >> config;
   137                 stream >> config;
       
   138                 file.close();
   138             }
   139             }
   139 
   140 
   140             wconf->setValue(schemes[i].remove(".hwa"), fixWeaponSet(config));
   141             // Chop off file name suffix
       
   142             QString schemeName = schemes[i];
       
   143             if (schemeName.endsWith(".hwa", Qt::CaseInsensitive)) {
       
   144                 schemeName.chop(4);
       
   145             }
       
   146             wconf->setValue(schemeName, fixWeaponSet(config));
   141         }
   147         }
   142     }
   148     }
   143 
   149 
   144     QString currentState = *cDefaultAmmoStore;
   150     QString currentState = *cDefaultAmmoStore;
   145 
   151 
   298     wconf->setValue(m_name->text(), stateFull);
   304     wconf->setValue(m_name->text(), stateFull);
   299     QFile file(cfgdir->absolutePath() + "/Schemes/Ammo/" + m_name->text()+ ".hwa");
   305     QFile file(cfgdir->absolutePath() + "/Schemes/Ammo/" + m_name->text()+ ".hwa");
   300     if (file.open(QIODevice::WriteOnly)) {
   306     if (file.open(QIODevice::WriteOnly)) {
   301         QTextStream stream( &file );
   307         QTextStream stream( &file );
   302         stream << stateFull << endl;
   308         stream << stateFull << endl;
       
   309         file.close();
   303     }
   310     }
   304     emit weaponsEdited(curWeaponsName, m_name->text(), stateFull);
   311     emit weaponsEdited(curWeaponsName, m_name->text(), stateFull);
   305 }
   312 }
   306 
   313 
   307 int SelWeaponWidget::operator [] (unsigned int weaponIndex) const
   314 int SelWeaponWidget::operator [] (unsigned int weaponIndex) const