void RegularBattleScene::setupGui() { int nslots = data()->numberOfSlots(); gui.nick.resize(nslots); gui.level.resize(nslots); gui.gender.resize(nslots); gui.bars.resize(nslots); gui.status.resize(nslots); QVBoxLayout *l= new QVBoxLayout(this); l->setMargin(0); /* As anyway the GraphicsZone is a fixed size, it's useless to resize that part, might as well let the chat be resized */ l->setSizeConstraint(QLayout::SetFixedSize); QHBoxLayout *firstLine = new QHBoxLayout(); l->addLayout(firstLine); QHBoxLayout *midzone = new QHBoxLayout(); l->addLayout(midzone); QHBoxLayout *lastLine = new QHBoxLayout(); l->addLayout(lastLine); QVBoxLayout *teamAndName[2]; for (int i = 0; i < 2; i++) { teamAndName[i] = new QVBoxLayout(); teamAndName[i]->addLayout(createTeamLayout(gui.pokeballs[i])); teamAndName[i]->addWidget(gui.trainers[i] = new QLabel(data()->name(i)),0, Qt::AlignRight); gui.trainers[i]->setObjectName("TrainerNick"); } firstLine->addWidget(gui.fullBars[opponent()] = createFullBarLayout(nslots, opponent())); firstLine->addLayout(teamAndName[opponent()]); gui.zone = new GraphicsZone(data(), gui.theme); /* Make the code below more generic? */ QVBoxLayout *midme = new QVBoxLayout(); midzone->addLayout(midme); midme->addStretch(100); gui.timers[myself()] = new QProgressBar(); gui.timers[myself()]->setObjectName("TimeOut"); //for style sheets gui.timers[myself()]->setRange(0,300); QLabel *mybox = new QLabel(); mybox->setObjectName("MyTrainerBox"); mybox->setFixedSize(82,82); mybox->setPixmap(gui.theme->trainerSprite(data()->avatar(myself()))); midme->addWidget(gui.timers[myself()]); midme->addWidget(mybox); midzone->addWidget(gui.zone); QVBoxLayout *midopp = new QVBoxLayout(); midzone->addLayout(midopp); midopp->addStretch(100); gui.timers[opponent()] = new QProgressBar(); gui.timers[opponent()]->setObjectName("TimeOut"); //for style sheets gui.timers[opponent()]->setRange(0,300); QLabel *oppbox = new QLabel(); oppbox->setPixmap(gui.theme->trainerSprite(data()->avatar(opponent()))); oppbox->setObjectName("OppTrainerBox"); oppbox->setFixedSize(82,82); midopp->addWidget(oppbox); midopp->addWidget(gui.timers[opponent()]); lastLine->addLayout(teamAndName[myself()]); lastLine->addWidget(gui.fullBars[myself()] = createFullBarLayout(nslots, myself())); QTimer *t = new QTimer (this); t->start(200); connect(t, SIGNAL(timeout()), SLOT(updateTimers())); }
void RegularBattleScene::setupGui() { int nslots = data()->numberOfSlots(); gui.nick.resize(nslots); gui.level.resize(nslots); gui.gender.resize(nslots); gui.bars.resize(nslots); gui.status.resize(nslots); QGridLayout *window = new QGridLayout(this); window->setSizeConstraint(QLayout::SetFixedSize); QVBoxLayout *team[2]; QVBoxLayout *name[2]; for (int i = 0; i < 2; i++) { team[i] = new QVBoxLayout(); team[i]->addLayout(createTeamLayout(gui.pokeballs[i])); name[i] = new QVBoxLayout(); name[i]->addWidget(gui.trainers[i] = new QLabel(data()->name(i)),0, Qt::AlignRight); gui.trainers[i]->setObjectName("TrainerNick"); } gui.zone = new GraphicsZone(data(), gui.theme); /* Set up our data */ QVBoxLayout *midme = new QVBoxLayout(); gui.timers[myself()] = new QProgressBar(); gui.timers[myself()]->setObjectName("TimeOut"); //for style sheets gui.timers[myself()]->setRange(0, data()->rated() ? ratedTime : unratedTime); QLabel *mybox = new QLabel(); mybox->setObjectName("MyTrainerBox"); mybox->setFixedSize(82,82); mybox->setPixmap(gui.theme->trainerSprite(data()->avatar(myself()))); midme->addLayout(team[myself()]); midme->addWidget(gui.timers[myself()]); midme->addWidget(mybox); midme->addLayout(name[myself()]); /* Set up Opponent's data */ QVBoxLayout *midopp = new QVBoxLayout(); gui.timers[opponent()] = new QProgressBar(); gui.timers[opponent()]->setObjectName("TimeOut"); //for style sheets gui.timers[opponent()]->setRange(0, data()->rated() ? ratedTime : unratedTime); QLabel *oppbox = new QLabel(); oppbox->setPixmap(gui.theme->trainerSprite(data()->avatar(opponent()))); oppbox->setObjectName("OppTrainerBox"); oppbox->setFixedSize(82,82); midopp->addLayout(name[opponent()]); midopp->addWidget(oppbox); midopp->addWidget(gui.timers[opponent()]); midopp->addLayout(team[opponent()]); /* Field must be at least 215 pixels tall otherwise the side elements will collide, causing display issues */ gui.zone->setMinimumSize(400,240); gui.zone->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); gui.zone->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); /* Arrange everything */ window->addLayout(midopp,0,4,3,1,Qt::AlignTop); window->addWidget(gui.fullBars[opponent()] = createFullBarLayout(nslots, opponent()),0,1,1,3,Qt::AlignRight); window->addWidget(gui.zone,1,1,2,3); window->addWidget(gui.fullBars[myself()] = createFullBarLayout(nslots, myself()),3,1,1,3,Qt::AlignLeft); window->addLayout(midme,1,0,3,1,Qt::AlignBottom); QTimer *t = new QTimer (this); t->start(200); connect(t, SIGNAL(timeout()), SLOT(updateTimers())); }