QTfrontend/hwform.cpp
changeset 1419 8650a8f55006
parent 1418 69df8f2a7cba
child 1427 b510f7a74ef6
equal deleted inserted replaced
1418:69df8f2a7cba 1419:8650a8f55006
    29 #include <QCloseEvent>
    29 #include <QCloseEvent>
    30 #include <QCheckBox>
    30 #include <QCheckBox>
    31 #include <QTextBrowser>
    31 #include <QTextBrowser>
    32 #include <QAction>
    32 #include <QAction>
    33 #include <QTimer>
    33 #include <QTimer>
       
    34 #include <QScrollBar>
    34 
    35 
    35 #include "hwform.h"
    36 #include "hwform.h"
    36 #include "game.h"
    37 #include "game.h"
    37 #include "team.h"
    38 #include "team.h"
    38 #include "teamselect.h"
    39 #include "teamselect.h"
    51 HWForm::HWForm(QWidget *parent)
    52 HWForm::HWForm(QWidget *parent)
    52   : QMainWindow(parent), pnetserver(0), pRegisterServer(0), editedTeam(0), hwnet(0)
    53   : QMainWindow(parent), pnetserver(0), pRegisterServer(0), editedTeam(0), hwnet(0)
    53 {
    54 {
    54 	ui.setupUi(this);
    55 	ui.setupUi(this);
    55 
    56 
       
    57 	CustomizePalettes();
       
    58 
    56 	ui.pageOptions->CBResolution->addItems(sdli.getResolutions());
    59 	ui.pageOptions->CBResolution->addItems(sdli.getResolutions());
    57 
    60 
    58 	config = new GameUIConfig(this, cfgdir->absolutePath() + "/hedgewars.ini");
    61 	config = new GameUIConfig(this, cfgdir->absolutePath() + "/hedgewars.ini");
    59 
    62 
    60 	UpdateTeamsLists();
    63 	UpdateTeamsLists();
   145   else {
   148   else {
   146     setWindowState(windowState() & !Qt::WindowFullScreen);
   149     setWindowState(windowState() & !Qt::WindowFullScreen);
   147   }
   150   }
   148 }
   151 }
   149 
   152 
       
   153 void HWForm::CustomizePalettes()
       
   154 {
       
   155 	QList<QScrollBar *> allSBars = findChildren<QScrollBar *>();
       
   156 	QPalette pal = palette();
       
   157 	pal.setColor(QPalette::WindowText, QColor(0xff, 0xcc, 0x00));
       
   158 	pal.setColor(QPalette::Button, QColor(0x00, 0x35, 0x1d));
       
   159 	pal.setColor(QPalette::Base, QColor(0x00, 0x35, 0x1d));
       
   160 	pal.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00));
       
   161 
       
   162 	for (int i = 0; i < allSBars.size(); ++i)
       
   163 		allSBars.at(i)->setPalette(pal);
       
   164 }
       
   165 
   150 void HWForm::UpdateWeapons()
   166 void HWForm::UpdateWeapons()
   151 {
   167 {
   152   // FIXME: rewrite this with boost (or TR1/0x)
   168 	// FIXME: rewrite this with boost (or TR1/0x)
   153   QVector<QComboBox*> combos;
   169 	QVector<QComboBox*> combos;
   154   combos.push_back(ui.pageOptions->WeaponsName);
   170 	combos.push_back(ui.pageOptions->WeaponsName);
   155   combos.push_back(ui.pageMultiplayer->gameCFG->WeaponsName);
   171 	combos.push_back(ui.pageMultiplayer->gameCFG->WeaponsName);
   156   combos.push_back(ui.pageNetGame->pGameCFG->WeaponsName);
   172 	combos.push_back(ui.pageNetGame->pGameCFG->WeaponsName);
   157 
   173 
   158   for(QVector<QComboBox*>::iterator it=combos.begin(); it!=combos.end(); ++it) {
   174 	for(QVector<QComboBox*>::iterator it=combos.begin(); it!=combos.end(); ++it) {
   159     (*it)->clear();
   175 		(*it)->clear();
   160     (*it)->addItems(ui.pageSelectWeapon->pWeapons->getWeaponNames());
   176 		(*it)->addItems(ui.pageSelectWeapon->pWeapons->getWeaponNames());
   161     int pos=(*it)->findText("Default");
   177 		int pos=(*it)->findText("Default");
   162     if (pos!=-1) {
   178 		if (pos!=-1) {
   163       (*it)->setCurrentIndex(pos);
   179 			(*it)->setCurrentIndex(pos);
   164     }
   180 		}
   165   }
   181 	}
   166 }
   182 }
   167 
   183 
   168 void HWForm::NetWeaponNameChanged(const QString& name)
   184 void HWForm::NetWeaponNameChanged(const QString& name)
   169 {
   185 {
   170   QString ammo=ui.pageSelectWeapon->pWeapons->getWeaponsString(ui.pageNetGame->pGameCFG->WeaponsName->currentText());
   186 	QString ammo = ui.pageSelectWeapon->pWeapons->getWeaponsString(
   171   hwnet->onWeaponsNameChanged(name, ammo);
   187 			ui.pageNetGame->pGameCFG->WeaponsName->currentText()
       
   188 			);
       
   189 
       
   190 	hwnet->onWeaponsNameChanged(name, ammo);
   172 }
   191 }
   173 
   192 
   174 void HWForm::UpdateTeamsLists(const QStringList* editable_teams)
   193 void HWForm::UpdateTeamsLists(const QStringList* editable_teams)
   175 {
   194 {
   176 	QStringList teamslist;
   195 	QStringList teamslist;