--- a/hedgewars/uLand.pas Tue Jan 23 16:59:05 2007 +0000
+++ b/hedgewars/uLand.pas Tue Jan 23 18:54:09 2007 +0000
@@ -171,6 +171,7 @@
px:= x;
py:= y
end;
+ DrawLine(px, py, hwRound(x2), hwRound(y2), Color)
end;
end;
--- a/hedgewars/uLandTemplates.pas Tue Jan 23 16:59:05 2007 +0000
+++ b/hedgewars/uLandTemplates.pas Tue Jan 23 18:54:09 2007 +0000
@@ -31,13 +31,26 @@
canMirror, canFlip: boolean;
end;
-const Template0Points: array[0..4] of TSDL_Rect =
+const Template0Points: array[0..17] of TSDL_Rect =
(
- (x: 400; y: 1100; w: 1; h: 1),
- (x: 250; y: 400; w: 200; h: 200),
- (x: 923; y: 620; w: 200; h: 400),
- (x: 1600; y: 400; w: 200; h: 200),
- (x: 1450; y: 1100; w: 1; h: 1)
+ (x: 410; y: 1024; w: 1; h: 1),
+ (x: 160; y: 760; w: 130; h: 170),
+ (x: 342; y: 706; w: 316; h: 150),
+ (x: 238; y: 386; w: 270; h: 180),
+ (x: 246; y: 176; w: 242; h: 156),
+ (x: 622; y: 128; w: 480; h: 300),
+ (x: 806; y: 468; w: 152; h: 324),
+ (x: 650; y: 1024; w: 500; h: 1),
+ (x: 1250; y: 1100; w: 1; h: 1),
+ (x: 1490; y: 1024; w: 1; h: 1),
+ (x: 1452; y: 904; w: 74; h: 12),
+ (x: 1248; y: 575; w: 68; h: 425),
+ (x: 1426; y: 592; w: 140; h: 142),
+ (x: 1310; y: 192; w: 150; h: 350),
+ (x: 1588; y: 194; w: 148; h: 332),
+ (x: 1618; y: 472; w: 276; h: 314),
+ (x: 1710; y: 850; w: 130; h: 86),
+ (x: 1734; y: 1024; w: 1; h: 1)
);
Template0FPoints: array[0..0] of TPoint =
(
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/templates/main.cpp Tue Jan 23 18:54:09 2007 +0000
@@ -0,0 +1,11 @@
+#include <QApplication>
+
+#include "mainform.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MyWindow *mainWin = new MyWindow;
+ mainWin->show();
+ return app.exec();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/templates/mainform.cpp Tue Jan 23 18:54:09 2007 +0000
@@ -0,0 +1,102 @@
+#include <QGridLayout>
+#include <QImage>
+#include <QPixmap>
+#include <QMessageBox>
+#include <QFile>
+#include <QTextStream>
+#include <QRegExp>
+#include <QDebug>
+#include "mainform.h"
+
+MyWindow::MyWindow(QWidget * parent, Qt::WFlags flags)
+ : QMainWindow(parent, flags)
+
+{
+ QWidget * centralWidget = new QWidget(this);
+ QGridLayout * mainlayout = new QGridLayout(centralWidget);
+ mainlayout->setMargin(1);
+ mainlayout->setSpacing(1);
+
+ sa_xy = new QScrollArea(centralWidget);
+ xy = new PixLabel();
+ xy->setFixedSize(1024, 512);
+ sa_xy->setWidget(xy);
+
+ mainlayout->addWidget(sa_xy, 0, 0, 1, 4);
+
+ setCentralWidget(centralWidget);
+
+ buttAdd = new QPushButton(centralWidget);
+ buttAdd->setText(tr("Add"));
+ mainlayout->addWidget(buttAdd, 1, 0);
+
+ buttCode = new QPushButton(centralWidget);
+ buttCode->setText(tr("Code"));
+ mainlayout->addWidget(buttCode, 1, 1);
+
+ buttSave = new QPushButton(centralWidget);
+ buttSave->setText(tr("Save"));
+ mainlayout->addWidget(buttSave, 1, 3);
+
+ buttLoad = new QPushButton(centralWidget);
+ buttLoad->setText(tr("Load"));
+ mainlayout->addWidget(buttLoad, 1, 2);
+
+ connect(buttAdd, SIGNAL(clicked()), xy, SLOT(AddRect()));
+ connect(buttCode, SIGNAL(clicked()), this, SLOT(Code()));
+ connect(buttSave, SIGNAL(clicked()), this, SLOT(Save()));
+ connect(buttLoad, SIGNAL(clicked()), this, SLOT(Load()));
+}
+
+void MyWindow::Code()
+{
+ if (xy->rects.size())
+ {
+ QFile f("template.pas");
+ if (!f.open(QIODevice::WriteOnly))
+ {
+ QMessageBox::information(this, tr("Error"),
+ tr("Cannot save"));
+ return ;
+ }
+
+ QTextStream stream(&f);
+ stream << QString("const Template0Points: array[0..%1] of TSDL_Rect =").arg(xy->rects.size() - 1) << endl;
+ stream << " (" << endl;
+ for(int i = 0; i < xy->rects.size(); i++)
+ {
+ QRect r = xy->rects[i].normalized();
+ stream << QString(" (x: %1; y: %2; w: %3; h: %4),").
+ arg(r.x() * 2, 4).arg(r.y() * 2, 4).arg(r.width() * 2, 4).arg(r.height() * 2, 4) << endl;
+ }
+ stream << " );" << endl;
+ f.close();
+ }
+}
+
+void MyWindow::Save()
+{
+ if (xy->rects.size())
+ {
+ QFile f("rects.txt");
+ if (!f.open(QIODevice::WriteOnly))
+ {
+ QMessageBox::information(this, tr("Error"),
+ tr("Cannot save"));
+ return ;
+ }
+
+ QTextStream stream(&f);
+ for(int i = 0; i < xy->rects.size(); i++)
+ {
+ QRect r = xy->rects[i].normalized();
+ stream << r.x() << " " << r.y() << " " << r.width() << " " << r.height() << endl;
+ }
+ f.close();
+ }
+}
+
+void MyWindow::Load()
+{
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/templates/mainform.h Tue Jan 23 18:54:09 2007 +0000
@@ -0,0 +1,29 @@
+#include <QScrollArea>
+#include <QMainWindow>
+#include <QLabel>
+#include <QListWidget>
+#include <QPushButton>
+#include "pixlabel.h"
+
+class MyWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+
+ MyWindow(QWidget * parent = 0, Qt::WFlags flags = 0);
+
+private:
+
+ QScrollArea * sa_xy;
+ PixLabel * xy;
+ QPushButton * buttAdd;
+ QPushButton * buttCode;
+ QPushButton * buttSave;
+ QPushButton * buttLoad;
+
+private slots:
+ void Code();
+ void Save();
+ void Load();
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/templates/pixlabel.cpp Tue Jan 23 18:54:09 2007 +0000
@@ -0,0 +1,45 @@
+#include <QPainter>
+#include <QPen>
+#include "pixlabel.h"
+
+PixLabel::PixLabel()
+ : QLabel(0)
+{
+
+}
+
+void PixLabel::paintEvent(QPaintEvent * event)
+{
+ QLabel::paintEvent(event);
+ QPainter p(this);
+
+ p.fillRect(QRect(0, 0, 1024, 512), QBrush(Qt::black));
+
+ p.setPen(QPen(Qt::white));
+ p.drawRects(rects.toVector());
+
+ if (rects.size())
+ {
+ p.setPen(QPen(Qt::yellow));
+ p.drawRect(rects.last());
+ }
+}
+
+void PixLabel::mousePressEvent(QMouseEvent * e)
+{
+ if (!rects.empty())
+ {
+ if (e->button() == Qt::LeftButton)
+ rects[rects.size() - 1].moveTopLeft(QPoint(e->x(), e->y()));
+ else
+ if (e->button() == Qt::RightButton)
+ rects[rects.size() - 1].setBottomRight(QPoint(e->x(), e->y()));
+ repaint();
+ }
+}
+
+void PixLabel::AddRect()
+{
+ rects.push_back(QRect(0, 0, 1, 1));
+ repaint();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/templates/pixlabel.h Tue Jan 23 18:54:09 2007 +0000
@@ -0,0 +1,21 @@
+#include <QLabel>
+#include <QRect>
+#include <QList>
+#include <QMouseEvent>
+
+class PixLabel : public QLabel
+{
+ Q_OBJECT
+
+public:
+
+ PixLabel();
+ QList<QRect> rects;
+
+public slots:
+ void AddRect();
+
+private:
+ void paintEvent(QPaintEvent * event);
+ void mousePressEvent(QMouseEvent * e);
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/templates/templates.pro Tue Jan 23 18:54:09 2007 +0000
@@ -0,0 +1,12 @@
+######################################################################
+# Automatically generated by qmake (2.01a) ?? 23. ??? 20:44:46 2007
+######################################################################
+
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+HEADERS += mainform.h pixlabel.h
+SOURCES += main.cpp mainform.cpp pixlabel.cpp