-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgui.cpp
56 lines (53 loc) · 1.14 KB
/
gui.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "gui.h"
#include "ui_gui.h"
#include <QtCore>
gui::gui(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::gui)
{
ui->setupUi(this);
ui->tvbots->setModel(&botList);
connect(ui->pbaddbot,SIGNAL(clicked()),this,SLOT(addBots()));
connect(ui->pbquit,SIGNAL(clicked()),this,SLOT(quit()));
}
gui::~gui()
{
delete ui;
}
void gui::quit()
{
exit(0);
}
void gui::majtable()
{
}
void gui::remBot()
{
}
void gui::addBots()
{
int bnb = ui->sbbotnb->value();
if (bnb==1)
{
createBot(ui->lename->text());
} else if (bnb>1) {
for (int i=0; i<bnb; i++)
{
createBot(ui->lename->text()+QString::number(i+1));
}
}
}
void gui::createBot(QString name)
{
if (botList.find(name)==botList.size())
{
GameApp * newBot = new GameApp(name);
newBot->run(name,ui->leaddress->text(),ui->leport->text());
botList[name]=newBot;
ui->tvbots->setModel(&botList);
} else {
qDebug() << "Bot already playing :" << name;
}
QModelIndex a;
qDebug() << "table view columns :" << botList.columnCount(a) << "rows :" << botList.rowCount(a);
}