# HG changeset patch # User unc0rr # Date 1257095995 0 # Node ID 41b46f83d088871528d8a0a368b1fa10f564452d # Parent d57af3defd56c136b86e7923216a582c617e5b5b Compete loading teams/hedgehogs part from mission config diff -r d57af3defd56 -r 41b46f83d088 tools/MissionsEditor/MissionsEditor.pro --- a/tools/MissionsEditor/MissionsEditor.pro Fri Oct 30 19:41:39 2009 +0000 +++ b/tools/MissionsEditor/MissionsEditor.pro Sun Nov 01 17:19:55 2009 +0000 @@ -5,8 +5,11 @@ TEMPLATE = app SOURCES += main.cpp \ editor.cpp \ - teamedit.cpp + teamedit.cpp \ + hedgehogedit.cpp HEADERS += editor.h \ - teamedit.h + teamedit.h \ + hedgehogedit.h FORMS += editor.ui \ - teamedit.ui + teamedit.ui \ + hedgehogedit.ui diff -r d57af3defd56 -r 41b46f83d088 tools/MissionsEditor/editor.cpp --- a/tools/MissionsEditor/editor.cpp Fri Oct 30 19:41:39 2009 +0000 +++ b/tools/MissionsEditor/editor.cpp Sun Nov 01 17:19:55 2009 +0000 @@ -8,6 +8,8 @@ { ui->setupUi(this); + reset(); + cbFlags << ui->cbForts << ui->cbMultiWeapon @@ -30,6 +32,15 @@ delete ui; } +void editor::reset() +{ + for(int i = 0; i < 6; ++i) + { + ui->twTeams->setTabEnabled(i, false); + ui->twTeams->widget(i)->setEnabled(false); + } +} + void editor::on_actionLoad_triggered() { QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(), "Missions (*.txt)"); @@ -86,13 +97,29 @@ if (line.startsWith("addteam") && (currTeam < 5)) { ++currTeam; + ui->twTeams->setTabEnabled(currTeam, true); + ui->twTeams->widget(currTeam)->setEnabled(true); + line = line.mid(8); int spacePos = line.indexOf('\x20'); quint32 teamColor = line.left(spacePos).toUInt(); QString teamName = line.mid(spacePos + 1); TeamEdit * te = qobject_cast(ui->twTeams->widget(currTeam)); - te->addTeam(teamName, teamColor); + te->setTeam(teamName, teamColor); + } + else + if (line.startsWith("addhh") && (currTeam >= 0)) + { + line = line.mid(6); + quint32 level = line.left(1).toUInt(); + line = line.mid(2); + int spacePos = line.indexOf('\x20'); + quint32 health = line.left(spacePos).toUInt(); + QString hhName = line.mid(spacePos + 1); + + TeamEdit * te = qobject_cast(ui->twTeams->widget(currTeam)); + te->addHedgehog(level, health, hhName); } else if (line.startsWith("fort") && (currTeam >= 0)) @@ -101,6 +128,23 @@ te->setFort(line.mid(5)); } else + if (line.startsWith("hat") && (currTeam >= 0)) + { + TeamEdit * te = qobject_cast(ui->twTeams->widget(currTeam)); + te->setLastHHHat(line.mid(4)); + } + else + if (line.startsWith("hhcoords") && (currTeam >= 0)) + { + line = line.mid(9); + int spacePos = line.indexOf('\x20'); + int x = line.left(spacePos).toUInt(); + int y = line.mid(spacePos + 1).toInt(); + + TeamEdit * te = qobject_cast(ui->twTeams->widget(currTeam)); + te->setLastHHCoords(x, y); + } + else if (line.startsWith("grave") && (currTeam >= 0)) { TeamEdit * te = qobject_cast(ui->twTeams->widget(currTeam)); diff -r d57af3defd56 -r 41b46f83d088 tools/MissionsEditor/editor.h --- a/tools/MissionsEditor/editor.h Fri Oct 30 19:41:39 2009 +0000 +++ b/tools/MissionsEditor/editor.h Sun Nov 01 17:19:55 2009 +0000 @@ -23,6 +23,7 @@ QList cbFlags; void load(const QString & fileName); + void reset(); private slots: void on_actionLoad_triggered(); diff -r d57af3defd56 -r 41b46f83d088 tools/MissionsEditor/editor.ui --- a/tools/MissionsEditor/editor.ui Fri Oct 30 19:41:39 2009 +0000 +++ b/tools/MissionsEditor/editor.ui Sun Nov 01 17:19:55 2009 +0000 @@ -306,6 +306,9 @@ + + true + 0 diff -r d57af3defd56 -r 41b46f83d088 tools/MissionsEditor/hedgehogedit.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/MissionsEditor/hedgehogedit.cpp Sun Nov 01 17:19:55 2009 +0000 @@ -0,0 +1,43 @@ +#include "hedgehogedit.h" +#include "ui_hedgehogedit.h" + +HedgehogEdit::HedgehogEdit(QWidget *parent) : + QFrame(parent), + m_ui(new Ui::HedgehogEdit) +{ + m_ui->setupUi(this); +} + +HedgehogEdit::~HedgehogEdit() +{ + delete m_ui; +} + +void HedgehogEdit::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + m_ui->retranslateUi(this); + break; + default: + break; + } +} + +void HedgehogEdit::setHedgehog(quint32 level, quint32 health, const QString & name) +{ + m_ui->cbLevel->setCurrentIndex(level); + m_ui->sbHealth->setValue(health); + m_ui->leName->setText(name); +} + +void HedgehogEdit::setHat(const QString & name) +{ + m_ui->leHat->setText(name); +} + +void HedgehogEdit::setCoordinates(int x, int y) +{ + m_ui->pbCoordinates->setText(QString("%1x%2").arg(x).arg(y)); +} diff -r d57af3defd56 -r 41b46f83d088 tools/MissionsEditor/hedgehogedit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/MissionsEditor/hedgehogedit.h Sun Nov 01 17:19:55 2009 +0000 @@ -0,0 +1,27 @@ +#ifndef HEDGEHOGEDIT_H +#define HEDGEHOGEDIT_H + +#include + +namespace Ui { + class HedgehogEdit; +} + +class HedgehogEdit : public QFrame { + Q_OBJECT +public: + HedgehogEdit(QWidget *parent = 0); + ~HedgehogEdit(); + + void setHedgehog(quint32 level = 0, quint32 health = 100, const QString & name = QString()); + void setHat(const QString & name); + void setCoordinates(int x, int y); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::HedgehogEdit *m_ui; +}; + +#endif // HEDGEHOGEDIT_H diff -r d57af3defd56 -r 41b46f83d088 tools/MissionsEditor/hedgehogedit.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/MissionsEditor/hedgehogedit.ui Sun Nov 01 17:19:55 2009 +0000 @@ -0,0 +1,138 @@ + + + HedgehogEdit + + + + 0 + 0 + 400 + 300 + + + + Form + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 3 + + + 3 + + + + + + + + X + + + + + + + 0 + + + + Human + + + + + Level 5 + + + + + Level 4 + + + + + Level 3 + + + + + Level 2 + + + + + Level 1 + + + + + + + + + + + Name + + + + + + + Level + + + + + + + 1 + + + 300 + + + 100 + + + + + + + Health + + + + + + + Hat + + + + + + + Random + + + + + + + Place + + + + + + + + diff -r d57af3defd56 -r 41b46f83d088 tools/MissionsEditor/teamedit.cpp --- a/tools/MissionsEditor/teamedit.cpp Fri Oct 30 19:41:39 2009 +0000 +++ b/tools/MissionsEditor/teamedit.cpp Sun Nov 01 17:19:55 2009 +0000 @@ -6,6 +6,8 @@ m_ui(new Ui::TeamEdit) { m_ui->setupUi(this); + + reset(); } TeamEdit::~TeamEdit() @@ -25,7 +27,15 @@ } } -void TeamEdit::addTeam(const QString & teamName, quint32 color) +void TeamEdit::reset() +{ + QLayout * l = m_ui->scrollArea->widget()->layout(); + + for(int i = 0; i < 8; ++i) + l->itemAt(i)->widget()->setVisible(false); +} + +void TeamEdit::setTeam(const QString & teamName, quint32 color) { m_ui->leTeamName->setText(teamName); } @@ -45,3 +55,44 @@ m_ui->leVoicepack->setText(name); } +void TeamEdit::addHedgehog(quint32 level, quint32 health, const QString & name) +{ + QLayout * l = m_ui->scrollArea->widget()->layout(); + + int i = 0; + while((i < 8) && (l->itemAt(i)->widget()->isVisible())) ++i; + + if(i < 8) + { + HedgehogEdit * he = qobject_cast(l->itemAt(i)->widget()); + he->setHedgehog(level, health, name); + l->itemAt(i)->widget()->setVisible(true); + } +} + +void TeamEdit::setLastHHHat(const QString & name) +{ + QLayout * l = m_ui->scrollArea->widget()->layout(); + + int i = 0; + while((i < 8) && (l->itemAt(i)->widget()->isVisible())) ++i; + + --i; + + HedgehogEdit * he = qobject_cast(l->itemAt(i)->widget()); + he->setHat(name); +} + +void TeamEdit::setLastHHCoords(int x, int y) +{ + QLayout * l = m_ui->scrollArea->widget()->layout(); + + int i = 0; + while((i < 8) && (l->itemAt(i)->widget()->isVisible())) ++i; + + --i; + + HedgehogEdit * he = qobject_cast(l->itemAt(i)->widget()); + he->setCoordinates(x ,y); +} + diff -r d57af3defd56 -r 41b46f83d088 tools/MissionsEditor/teamedit.h --- a/tools/MissionsEditor/teamedit.h Fri Oct 30 19:41:39 2009 +0000 +++ b/tools/MissionsEditor/teamedit.h Sun Nov 01 17:19:55 2009 +0000 @@ -13,9 +13,13 @@ TeamEdit(QWidget *parent = 0); ~TeamEdit(); - void addTeam(const QString & teamName = QString(), quint32 color = 0xdd0000); + void reset(); + void setTeam(const QString & teamName = QString(), quint32 color = 0xdd0000); + void addHedgehog(quint32 level = 0, quint32 health = 100, const QString & name = QString()); void setFort(const QString & name); void setGrave(const QString & name); + void setLastHHHat(const QString & name); + void setLastHHCoords(int x, int y); void setVoicepack(const QString & name); protected: void changeEvent(QEvent *e); diff -r d57af3defd56 -r 41b46f83d088 tools/MissionsEditor/teamedit.ui --- a/tools/MissionsEditor/teamedit.ui Fri Oct 30 19:41:39 2009 +0000 +++ b/tools/MissionsEditor/teamedit.ui Sun Nov 01 17:19:55 2009 +0000 @@ -68,23 +68,66 @@ - - - - - Name + + + + true + + + + + 0 + 0 + 301 + 235 + - - - - Health - - - - - Spawn pos - - + + + 3 + + + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 120 + + + + + + @@ -95,13 +138,6 @@ - - - Delete hedgehog - - - - Qt::Vertical @@ -114,7 +150,7 @@ - + Delete team @@ -123,6 +159,14 @@ + + + HedgehogEdit + QWidget +
hedgehogedit.h
+ 1 +
+