40 #include <QIcon> |
40 #include <QIcon> |
41 #include <QFile> |
41 #include <QFile> |
42 #include <QTextStream> |
42 #include <QTextStream> |
43 |
43 |
44 #include "hwform.h" |
44 #include "hwform.h" |
45 #include "sdlkeys.h" |
45 #include "game.h" |
|
46 #include "team.h" |
|
47 #include "netclient.h" |
|
48 #include "teamselect.h" |
|
49 #include "gameuiconfig.h" |
|
50 #include "pages.h" |
46 #include "hwconsts.h" |
51 #include "hwconsts.h" |
47 #include "gameuiconfig.h" |
|
48 |
52 |
49 HWForm::HWForm(QWidget *parent) |
53 HWForm::HWForm(QWidget *parent) |
50 : QMainWindow(parent) |
54 : QMainWindow(parent) |
51 { |
55 { |
52 ui.setupUi(this); |
56 ui.setupUi(this); |
53 TeamNameEdit = new QLineEdit(ui.GBoxTeam); |
|
54 TeamNameEdit->setGeometry(QRect(10, 20, 141, 20)); |
|
55 TeamNameEdit->setMaxLength(15); |
|
56 for(int i = 0; i < 8; i++) |
|
57 { |
|
58 HHNameEdit[i] = new QLineEdit(ui.GBoxHedgehogs); |
|
59 HHNameEdit[i]->setGeometry(QRect(10, 20 + i * 30, 141, 20)); |
|
60 HHNameEdit[i]->setMaxLength(15); |
|
61 } |
|
62 |
|
63 QStringList binds; |
|
64 for(int i = 0; strlen(sdlkeys[i][1]) > 0; i++) |
|
65 { |
|
66 binds << sdlkeys[i][1]; |
|
67 } |
|
68 |
|
69 quint16 widind = 0, top = 0; |
|
70 for(quint8 i = 0; i < BINDS_NUMBER; i++) |
|
71 { |
|
72 LBind[i] = new QLabel(ui.BindsBox->widget(widind)); |
|
73 LBind[i]->setGeometry(QRect(10, top + 3, 70, 20)); |
|
74 LBind[i]->setText(cbinds[i].name); |
|
75 LBind[i]->setAlignment(Qt::AlignRight); |
|
76 CBBind[i] = new QComboBox(ui.BindsBox->widget(widind)); |
|
77 CBBind[i]->setGeometry(QRect(90, top, 80, 20)); |
|
78 CBBind[i]->addItems(binds); |
|
79 if (cbinds[i].chwidget) |
|
80 { |
|
81 top = 0; |
|
82 widind++; |
|
83 } else |
|
84 { |
|
85 top += 28; |
|
86 } |
|
87 } |
|
88 |
|
89 QDir tmpdir; |
|
90 tmpdir.cd(DATA_PATH); |
|
91 tmpdir.cd("Forts"); |
|
92 tmpdir.setFilter(QDir::Files); |
|
93 |
|
94 ui.CBFort->addItems(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L.png"), "\\1")); |
|
95 |
|
96 tmpdir.cd("../Graphics/Graves"); |
|
97 QStringList list = tmpdir.entryList(QStringList("*.png")); |
|
98 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
|
99 { |
|
100 ui.CBGrave->addItem((*it).replace(QRegExp("^(.*).png"), "\\1")); |
|
101 } |
|
102 |
57 |
103 config = new GameUIConfig(this); |
58 config = new GameUIConfig(this); |
104 |
59 |
105 QStringList teamslist = config->GetTeamsList(); |
60 QStringList teamslist = config->GetTeamsList(); |
106 |
61 |
111 } |
66 } |
112 |
67 |
113 for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it ) |
68 for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it ) |
114 { |
69 { |
115 QString tmpTeamStr=(*it).replace(QRegExp("^(.*).cfg$"), "\\1"); |
70 QString tmpTeamStr=(*it).replace(QRegExp("^(.*).cfg$"), "\\1"); |
116 ui.PageLGTeamsSelect->addTeam(tmpTeamStr); |
71 ui.pageMultiplayer->teamsSelect->addTeam(tmpTeamStr); |
117 ui.CBTeamName->addItem(tmpTeamStr); |
72 ui.pageOptions->CBTeamName->addItem(tmpTeamStr); |
118 } |
73 } |
119 |
74 |
120 connect(ui.BtnSPBack, SIGNAL(clicked()), this, SLOT(GoToMain())); |
75 connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer())); |
121 connect(ui.BtnDemosBack, SIGNAL(clicked()), this, SLOT(GoToMain())); |
76 connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup())); |
122 connect(ui.BtnSetupBack, SIGNAL(clicked()), this, SLOT(GoToMain())); |
77 connect(ui.pageMain->BtnMultiplayer, SIGNAL(clicked()), this, SLOT(GoToMultiplayer())); |
123 connect(ui.BtnMPBack, SIGNAL(clicked()), this, SLOT(GoToMain())); |
78 connect(ui.pageMain->BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos())); |
124 connect(ui.BtnNetBack, SIGNAL(clicked()), this, SLOT(GoToMain())); |
79 connect(ui.pageMain->BtnNet, SIGNAL(clicked()), this, SLOT(GoToNet())); |
125 connect(ui.BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer())); |
80 connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(close())); |
126 connect(ui.BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup())); |
81 |
127 connect(ui.BtnMultiplayer, SIGNAL(clicked()), this, SLOT(GoToMultiplayer())); |
82 connect(ui.pageLocalGame->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); |
128 connect(ui.BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos())); |
83 connect(ui.pageLocalGame->BtnSimpleGame, SIGNAL(clicked()), this, SLOT(SimpleGame())); |
129 connect(ui.BtnNet, SIGNAL(clicked()), this, SLOT(GoToNet())); |
84 |
130 connect(ui.BtnNetCFGBack, SIGNAL(clicked()), this, SLOT(GoToNetChat())); |
85 connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave())); |
131 connect(ui.BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam())); |
86 connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard())); |
132 connect(ui.BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam())); |
87 |
133 connect(ui.BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave())); |
88 connect(ui.pageMultiplayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); |
134 connect(ui.BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard())); |
89 |
135 connect(ui.BtnSimpleGame, SIGNAL(clicked()), this, SLOT(SimpleGame())); |
90 connect(ui.pagePlayDemo->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); |
136 connect(ui.BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions())); |
91 connect(ui.pagePlayDemo->BtnPlayDemo, SIGNAL(clicked()), this, SLOT(PlayDemo())); |
137 connect(ui.BtnPlayDemo, SIGNAL(clicked()), this, SLOT(PlayDemo())); |
92 |
138 connect(ui.BtnNetConnect, SIGNAL(clicked()), this, SLOT(NetConnect())); |
93 connect(ui.pageOptions->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); |
139 connect(ui.BtnNetChatDisconnect, SIGNAL(clicked()), this, SLOT(NetDisconnect())); |
94 connect(ui.pageOptions->BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam())); |
140 connect(ui.BtnNetChatJoin, SIGNAL(clicked()), this, SLOT(NetJoin())); |
95 connect(ui.pageOptions->BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam())); |
141 connect(ui.BtnNetChatCreate, SIGNAL(clicked()), this, SLOT(NetCreate())); |
96 connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions())); |
142 connect(ui.BtnNetCFGAddTeam, SIGNAL(clicked()), this, SLOT(NetAddTeam())); |
97 |
143 connect(ui.BtnNetCFGGo, SIGNAL(clicked()), this, SLOT(NetStartGame())); |
98 connect(ui.pageNet->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); |
144 connect(ui.CBGrave, SIGNAL(activated(const QString &)), this, SLOT(CBGrave_activated(const QString &))); |
99 connect(ui.pageNet->BtnNetConnect, SIGNAL(clicked()), this, SLOT(NetConnect())); |
145 connect(ui.CBFort, SIGNAL(activated(const QString &)), this, SLOT(CBFort_activated(const QString &))); |
100 |
|
101 connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), this, SLOT(GoToNetChat())); |
|
102 connect(ui.pageNetGame->BtnAddTeam, SIGNAL(clicked()), this, SLOT(NetAddTeam())); |
|
103 connect(ui.pageNetGame->BtnGo, SIGNAL(clicked()), this, SLOT(NetStartGame())); |
|
104 |
|
105 connect(ui.pageNetChat->BtnDisconnect, SIGNAL(clicked()), this, SLOT(NetDisconnect())); |
|
106 connect(ui.pageNetChat->BtnJoin, SIGNAL(clicked()), this, SLOT(NetJoin())); |
|
107 connect(ui.pageNetChat->BtnCreate, SIGNAL(clicked()), this, SLOT(NetCreate())); |
|
108 |
146 ui.Pages->setCurrentIndex(ID_PAGE_MAIN); |
109 ui.Pages->setCurrentIndex(ID_PAGE_MAIN); |
147 } |
110 } |
148 |
111 |
149 void HWForm::GoToMain() |
112 void HWForm::GoToMain() |
150 { |
113 { |
253 hwnet = new HWNet(config); |
204 hwnet = new HWNet(config); |
254 connect(hwnet, SIGNAL(Connected()), this, SLOT(GoToNetChat())); |
205 connect(hwnet, SIGNAL(Connected()), this, SLOT(GoToNetChat())); |
255 connect(hwnet, SIGNAL(AddGame(const QString &)), this, SLOT(AddGame(const QString &))); |
206 connect(hwnet, SIGNAL(AddGame(const QString &)), this, SLOT(AddGame(const QString &))); |
256 connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter())); |
207 connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter())); |
257 connect(hwnet, SIGNAL(ChangeInTeams(const QStringList &)), this, SLOT(ChangeInNetTeams(const QStringList &))); |
208 connect(hwnet, SIGNAL(ChangeInTeams(const QStringList &)), this, SLOT(ChangeInNetTeams(const QStringList &))); |
258 hwnet->Connect("172.19.5.168", 6667, ui.editNetNick->text()); |
209 hwnet->Connect("172.19.5.168", 6667, ui.pageOptions->editNetNick->text()); |
259 } |
210 } |
260 |
211 |
261 void HWForm::NetDisconnect() |
212 void HWForm::NetDisconnect() |
262 { |
213 { |
263 hwnet->Disconnect(); |
214 hwnet->Disconnect(); |
264 GoToNet(); |
215 GoToNet(); |
265 } |
216 } |
266 |
217 |
267 void HWForm::AddGame(const QString & chan) |
218 void HWForm::AddGame(const QString & chan) |
268 { |
219 { |
269 ui.ChannelsList->addItem(chan); |
220 ui.pageNetChat->ChannelsList->addItem(chan); |
270 } |
221 } |
271 |
222 |
272 void HWForm::NetGameEnter() |
223 void HWForm::NetGameEnter() |
273 { |
224 { |
274 ui.Pages->setCurrentIndex(ID_PAGE_NETCFG); |
225 ui.Pages->setCurrentIndex(ID_PAGE_NETCFG); |