summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-09-12 14:57:44 +0200
committerTreeki <treeki@gmail.com>2012-09-12 14:57:44 +0200
commit3189ca5efc5826405bf2e9c7d9949ad5ea9a8a10 (patch)
treed10e8cd4e462db28dd3c2f995905c4df57a20fed
parentbe8b56a7f0a8f6ba5456a099b61d032fd8aa2f61 (diff)
downloadLayoutStudio-3189ca5efc5826405bf2e9c7d9949ad5ea9a8a10.tar.gz
LayoutStudio-3189ca5efc5826405bf2e9c7d9949ad5ea9a8a10.zip
initial un-exporter version
-rw-r--r--LayoutStudio.pro42
-rw-r--r--icons/bounding.pngbin416 -> 0 bytes
-rw-r--r--icons/pane.pngbin418 -> 0 bytes
-rw-r--r--icons/picture.pngbin530 -> 0 bytes
-rw-r--r--icons/textbox.pngbin428 -> 0 bytes
-rw-r--r--icons/window.pngbin532 -> 0 bytes
-rw-r--r--layoutgl/texturemanager.cpp31
-rw-r--r--layoutgl/texturemanager.h33
-rw-r--r--layoutgl/widget.cpp500
-rw-r--r--layoutgl/widget.h53
-rw-r--r--lscolorpicker.cpp47
-rw-r--r--lscolorpicker.h27
-rw-r--r--lsglobals.cpp52
-rw-r--r--lsglobals.h38
-rw-r--r--lslayoutwindow.cpp193
-rw-r--r--lslayoutwindow.h77
-rw-r--r--lsmainwindow.cpp309
-rw-r--r--lsmainwindow.h76
-rw-r--r--lsmaterialeditor.cpp78
-rw-r--r--lsmaterialeditor.h48
-rw-r--r--lsmaterialeditors.h408
-rw-r--r--lsmaterialmodel.cpp23
-rw-r--r--lsmaterialmodel.h25
-rw-r--r--lspackagemodel.cpp163
-rw-r--r--lspackagemodel.h45
-rw-r--r--lspaneeditor.cpp420
-rw-r--r--lspaneeditor.h106
-rw-r--r--lsrlytexporter.cpp1176
-rw-r--r--lsrlytexporter.h8
-rw-r--r--lsscenemodel.cpp201
-rw-r--r--lsscenemodel.h46
-rw-r--r--lsseteditor.cpp60
-rw-r--r--lsseteditor.h160
-rw-r--r--lstexcoordseteditor.cpp174
-rw-r--r--lstexcoordseteditor.h40
-rw-r--r--lyt/animation.cpp220
-rw-r--r--lyt/animation.h68
-rw-r--r--lyt/materials/tevswaptable.cpp8
-rw-r--r--lyt/textbox.cpp13
-rw-r--r--lyt/textbox.h4
-rw-r--r--main.cpp93
-rw-r--r--resources.qrc9
-rw-r--r--wii/common.cpp23
-rw-r--r--wii/common.h2
44 files changed, 1558 insertions, 3541 deletions
diff --git a/LayoutStudio.pro b/LayoutStudio.pro
index 890250c..cd34307 100644
--- a/LayoutStudio.pro
+++ b/LayoutStudio.pro
@@ -1,12 +1,10 @@
# -------------------------------------------------
# Project created by QtCreator 2010-10-03T04:03:27
# -------------------------------------------------
-QT += opengl
+QT += xml
TARGET = LayoutStudio
TEMPLATE = app
SOURCES += main.cpp \
- lsmainwindow.cpp \
- lsglobals.cpp \
lyt/packagebase.cpp \
lyt/directorypackage.cpp \
lyt/layout.cpp \
@@ -33,20 +31,10 @@ SOURCES += main.cpp \
wii/filesystem.cpp \
lyt/archivepackage.cpp \
wii/stringtablebuilder.cpp \
- layoutgl/texturemanager.cpp \
- layoutgl/widget.cpp \
wii/texpalette.cpp \
- lspackagemodel.cpp \
- lslayoutwindow.cpp \
- lsscenemodel.cpp \
- lspaneeditor.cpp \
- lstexcoordseteditor.cpp \
- lsmaterialeditor.cpp \
- lscolorpicker.cpp \
- lsmaterialmodel.cpp \
- lsseteditor.cpp
-HEADERS += lsmainwindow.h \
- lsglobals.h \
+ lsrlytexporter.cpp \
+ lyt/animation.cpp
+HEADERS += \
lyt/packagebase.h \
lyt/directorypackage.h \
lyt/layout.h \
@@ -75,28 +63,12 @@ HEADERS += lsmainwindow.h \
lyt/archivepackage.h \
wii/stringtablebuilder.h \
lyt/materials/materialcontainer.h \
- layoutgl/texturemanager.h \
- layoutgl/widget.h \
wii/texpalette.h \
wii/gx.h \
- lspackagemodel.h \
- lslayoutwindow.h \
- lsscenemodel.h \
- lspaneeditor.h \
- lstexcoordseteditor.h \
- lsmaterialeditor.h \
- lscolorpicker.h \
- lsmaterialmodel.h \
- lsseteditor.h \
- lsmaterialeditors.h
-FORMS +=
-RESOURCES += resources.qrc
+ lsrlytexporter.h \
+ lyt/animation.h
+
OTHER_FILES += \
- icons/window.png \
- icons/textbox.png \
- icons/picture.png \
- icons/pane.png \
- icons/bounding.png \
README.markdown \
LICENSE.txt
diff --git a/icons/bounding.png b/icons/bounding.png
deleted file mode 100644
index 0f8978a..0000000
--- a/icons/bounding.png
+++ /dev/null
Binary files differ
diff --git a/icons/pane.png b/icons/pane.png
deleted file mode 100644
index aa61650..0000000
--- a/icons/pane.png
+++ /dev/null
Binary files differ
diff --git a/icons/picture.png b/icons/picture.png
deleted file mode 100644
index 11ee52c..0000000
--- a/icons/picture.png
+++ /dev/null
Binary files differ
diff --git a/icons/textbox.png b/icons/textbox.png
deleted file mode 100644
index e6d7915..0000000
--- a/icons/textbox.png
+++ /dev/null
Binary files differ
diff --git a/icons/window.png b/icons/window.png
deleted file mode 100644
index 055e90a..0000000
--- a/icons/window.png
+++ /dev/null
Binary files differ
diff --git a/layoutgl/texturemanager.cpp b/layoutgl/texturemanager.cpp
deleted file mode 100644
index 80a8186..0000000
--- a/layoutgl/texturemanager.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "texturemanager.h"
-
-LGLTextureManager::LGLTextureManager() {
-}
-
-void LGLTextureManager::setup(QGLWidget *gl, const LYTLayout *layout) {
- // TODO: code to cleanup previous stuff
-
- //m_gl = gl;
- m_layout = layout;
- m_package = &layout->package();
-
- QStringList textures = layout->generateTextureRefs();
-
- foreach (const QString &texName, textures) {
- qDebug() << texName;
-
- QByteArray tplData = m_package->getTexture(texName);
-
- QDataStream tplStream(tplData);
- WiiTexPalette tpl(tplStream);
-
- const QImage &image = tpl.textures.first().image;
- image.save(QString("tpl/%2__%1.png").arg(texName).arg((int)tpl.textures.first().format));
- // dirty, dirty hack, TODO: FIXME
- GLuint tex = gl->bindTexture(image, GL_TEXTURE_2D);
-
- m_textures.insert(texName, tex);
- m_images.insert(texName, image);
- }
-}
diff --git a/layoutgl/texturemanager.h b/layoutgl/texturemanager.h
deleted file mode 100644
index 07b7739..0000000
--- a/layoutgl/texturemanager.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef TEXTUREMANAGER_H
-#define TEXTUREMANAGER_H
-
-#include "wii/texpalette.h"
-#include "lyt/layout.h"
-#include <QGLContext>
-#include <QHash>
-
-class LGLTextureManager {
-public:
- LGLTextureManager();
-
- void setup(QGLWidget *gl, const LYTLayout *layout);
-
-private:
- const QGLContext *m_gl;
- const LYTLayout *m_layout;
- const LYTPackageBase *m_package;
-
- QHash<QString, GLuint> m_textures;
- QHash<QString, QImage> m_images;
-
-public:
- GLuint glTextureForName(const QString name) const {
- return m_textures.value(name);
- }
-
- QImage imageForName(const QString name) const {
- return m_images.value(name);
- }
-};
-
-#endif // TEXTUREMANAGER_H
diff --git a/layoutgl/widget.cpp b/layoutgl/widget.cpp
deleted file mode 100644
index 32789f5..0000000
--- a/layoutgl/widget.cpp
+++ /dev/null
@@ -1,500 +0,0 @@
-#include "widget.h"
-
-LGLWidget::LGLWidget(QWidget *parent) :
- QGLWidget(parent), m_layout(0) {
-}
-
-
-void LGLWidget::setLayout(LYTLayout *layout) {
- // TODO: cleanup stuff for previous layout
-
- m_layout = layout;
- resize(layout->width + 64, layout->height + 64);
-}
-
-
-void LGLWidget::initializeGL() {
- qDebug() << "initialising GL";
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glEnable(GL_TEXTURE_2D);
-
- // this makes texture transparency work
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- // makes glColor value blend with textures
- glEnable(GL_COLOR_MATERIAL);
-
- m_texMgr.setup(this, m_layout);
-}
-
-
-void LGLWidget::resizeGL(int w, int h) {
- glViewport(0, 0, (GLint)w, (GLint)h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-
- float halfW = w / 2.0f, halfH = h / 2.0f;
-
- glOrtho(-halfW, halfW, -halfH, halfH, -100, 100);
- glMatrixMode(GL_MODELVIEW);
-}
-
-
-void LGLWidget::paintGL() {
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- if (m_layout == 0)
- return;
-
- glLoadIdentity();
-
- renderPane(m_layout->rootPane, 255);
-
- // now, debugging/editing aids
- // first off reset the textures
- for (int i = 0; i < 8; i++) {
- glActiveTexture(GL_TEXTURE0+i);
- glDisable(GL_TEXTURE_2D);
- }
- glActiveTexture(GL_TEXTURE0);
-
- glColor3ub(255, 0, 0);
- float halfW = m_layout->width / 2.0f;
- float halfH = m_layout->height / 2.0f;
-
- const float lineExtension = 12.0f;
- glBegin(GL_QUADS);
-
- // top line
- glVertex2f(-halfW - 1.0f - lineExtension, halfH + 1.0f);
- glVertex2f(halfW + 1.0f + lineExtension, halfH + 1.0f);
- glVertex2f(halfW + 1.0f + lineExtension, halfH);
- glVertex2f(-halfW - 1.0f - lineExtension, halfH);
- // bottom line
- glVertex2f(-halfW - 1.0f - lineExtension, -halfH);
- glVertex2f(halfW + 1.0f + lineExtension, -halfH);
- glVertex2f(halfW + 1.0f + lineExtension, -halfH - 1.0f);
- glVertex2f(-halfW - 1.0f - lineExtension, -halfH - 1.0f);
- // left line
- glVertex2f(-halfW - 1.0f, halfH + 1.0f + lineExtension);
- glVertex2f(-halfW, halfH + 1.0f + lineExtension);
- glVertex2f(-halfW, -halfH - 1.0f - lineExtension);
- glVertex2f(-halfW - 1.0f, -halfH - 1.0f - lineExtension);
- // right line
- glVertex2f(halfW, halfH + 1.0f + lineExtension);
- glVertex2f(halfW + 1.0f, halfH + 1.0f + lineExtension);
- glVertex2f(halfW + 1.0f, -halfH - 1.0f - lineExtension);
- glVertex2f(halfW, -halfH - 1.0f - lineExtension);
-
- // centre: horizontal
- glVertex2f(-lineExtension, 0.5f);
- glVertex2f(lineExtension, 0.5f);
- glVertex2f(lineExtension, -0.5f);
- glVertex2f(-lineExtension, -0.5f);
- // centre: vertical
- glVertex2f(-0.5f, lineExtension);
- glVertex2f(0.5f, lineExtension);
- glVertex2f(0.5f, -lineExtension);
- glVertex2f(-0.5f, -lineExtension);
-
- glEnd();
-}
-
-void LGLWidget::renderPane(const LYTPane *pane, quint8 parentAlpha) {
- if (!pane->visible)
- return;
-
- glPushMatrix();
-
- glScalef(pane->xScale, pane->yScale, 1.0f);
- glRotatef(pane->xRot, 1.0f, 0.0f, 0.0f);
- glRotatef(pane->yRot, 0.0f, 1.0f, 0.0f);
- glRotatef(pane->zRot, 0.0f, 0.0f, 1.0f);
- glTranslatef(pane->xTrans, pane->yTrans, pane->zTrans);
- //qDebug() << "Translating by" << pane->xTrans << pane->yTrans << pane->zTrans;
-
- quint8 effectiveAlpha = (parentAlpha == 255) ? pane->alpha : ((pane->alpha * parentAlpha) / 255);
-
- switch (pane->type()) {
- case LYTPane::PictureType:
- drawPicture((LYTPicture*)pane, effectiveAlpha);
- break;
- case LYTPane::WindowType:
- drawWindow((LYTWindow*)pane, effectiveAlpha);
- break;
- }
-
- quint8 childrenAlpha = pane->influencedAlpha ? effectiveAlpha : 255;
- foreach (const LYTPane *childPane, pane->children)
- renderPane(childPane, childrenAlpha);
-
- //qDebug() << "Popping";
- glPopMatrix();
-}
-
-void LGLWidget::drawPicture(const LYTPicture *pic, quint8 effectiveAlpha) {
- float dX = pic->drawnVertexX();
- float dY = pic->drawnVertexY();
- //qDebug() << "Drawing" << dX << dY << pic->width << pic->height;
-
- useMaterial(pic->materialName);
-
- drawQuad(dX, dY, pic->width, pic->height, pic->texCoords, pic->vtxColours, effectiveAlpha);
-
- //glColor3ub(255, 255, 255);
- //renderText(dX, (dY-pic->height)+10, 0, pic->name);
-}
-
-struct TexFlipBit {
- quint8 bits[8];
- quint8 one, two;
-};
-
-static const TexFlipBit TextureFlipInfo[6] = {
- {{0,0,1,0,0,1,1,1},0,1},
- {{1,0,0,0,1,1,0,1},0,1},
- {{0,1,1,1,0,0,1,0},0,1},
- {{0,1,0,0,1,1,1,0},1,0},
- {{1,1,0,1,1,0,0,0},0,1},
- {{1,0,1,1,0,0,0,1},1,0}
-};
-
-void LGLWidget::dealWithWindowFrame(LYTTexCoords &coords, const QString &materialName,
- int flipType, float pieceWidth, float pieceHeight,
- int rep1, int rep2, int rep3, int rep4) {
- // What are you DOING Nintendo.. the code for this is a mess!
- // I seriously don't get it.
- // I am also using a terrible hack here.
- const TexFlipBit &info = TextureFlipInfo[flipType];
-
- qreal *hack = (qreal*)(&coords.coord[0]);
-
- float assign1 = info.bits[rep1 + info.one];
- hack[rep1 + info.one] = assign1;
- hack[rep3 + info.one] = assign1;
-
- float assign2 = info.bits[rep1 + info.two];
- hack[rep1 + info.two] = assign2;
- hack[rep2 + info.two] = assign2;
-
- float texSize[2];
- getTextureSize(materialName, &texSize[0], &texSize[1]);
-
- float assign3 = info.bits[rep1 + info.one] + (pieceWidth / ((info.bits[rep2 + info.one] - info.bits[rep1 + info.one]) * texSize[info.one]));
- hack[rep2 + info.one] = assign3;
- hack[rep4 + info.one] = assign3;
-
- float assign4 = info.bits[rep1 + info.two] + (pieceHeight / ((info.bits[rep3 + info.two] - info.bits[rep1 + info.two]) * texSize[info.two]));
- hack[rep3 + info.two] = assign4;
- hack[rep4 + info.two] = assign4;
-}
-
-void LGLWidget::drawWindow(const LYTWindow *wnd, quint8 effectiveAlpha) {
- float dX = wnd->drawnVertexX();
- float dY = wnd->drawnVertexY();
-
- // get the frame size
- float frameLeft, frameTop, frameRight, frameBottom;
-
- switch (wnd->frames.count()) {
- case 1:
- float oneW, oneH;
- getTextureSize(wnd->frames.at(0)->materialName, &oneW, &oneH);
- frameLeft = frameRight = oneW;
- frameTop = frameBottom = oneH;
- break;
- case 4: case 8:
- getTextureSize(wnd->frames.at(0)->materialName, &frameLeft, &frameTop);
- getTextureSize(wnd->frames.at(3)->materialName, &frameRight, &frameBottom);
- break;
- }
-
- // draw the content
- useMaterial(wnd->contentMaterialName);
- //qDebug() << "content material:" << wnd->contentMaterialName;
- drawQuad(
- dX + frameLeft - wnd->contentOverflowLeft,
- dY - frameTop + wnd->contentOverflowTop,
- ((wnd->contentOverflowLeft + (wnd->width - frameLeft)) - frameRight) + wnd->contentOverflowRight,
- ((wnd->contentOverflowTop + (wnd->height - frameTop)) - frameBottom) + wnd->contentOverflowBottom,
- wnd->contentTexCoords, wnd->contentVtxColours, effectiveAlpha);
-
- // deal with the frame
- LYTTexCoords texCoords;
-
- switch (wnd->frames.count()) {
- case 1:
- {
- const LYTWindowFrame &frame = *wnd->frames.first();
- const LYTMaterial &mat = getMaterial(frame.materialName);
-
- if (!mat.texMaps.empty()) {
- useMaterial(mat);
-
- // top left
- float pieceWidth = wnd->width - frameRight;
- float pieceHeight = frameTop;
-
- dealWithWindowFrame(texCoords, frame.materialName, 0, pieceWidth, pieceHeight, 0, 2, 4, 6);
- drawQuad(dX, dY, pieceWidth, pieceHeight, 1, &texCoords, 0, effectiveAlpha);
-
- // top right
- pieceWidth = frameRight;
- pieceHeight = wnd->height - frameBottom;
-
- dealWithWindowFrame(texCoords, frame.materialName, 1, pieceWidth, pieceHeight, 2, 0, 6, 4);
-
- drawQuad(dX + wnd->width - frameRight, dY, pieceWidth, pieceHeight,
- 1, &texCoords, 0, effectiveAlpha);
-
- // bottom left
- pieceWidth = frameLeft;
- pieceHeight = wnd->height - frameTop;
-
- dealWithWindowFrame(texCoords, frame.materialName, 2, pieceWidth, pieceHeight, 4, 6, 0, 2);
-
- drawQuad(dX, dY - frameTop, pieceWidth, pieceHeight,
- 1, &texCoords, 0, effectiveAlpha);
-
- // bottom right
- pieceWidth = wnd->width - frameLeft;
- pieceHeight = frameBottom;
-
- dealWithWindowFrame(texCoords, frame.materialName, 4, pieceWidth, pieceHeight, 6, 4, 2, 0);
-
- drawQuad(dX + frameLeft, dY - wnd->height + frameBottom, pieceWidth, pieceHeight,
- 1, &texCoords, 0, effectiveAlpha);
- }
- }
- break;
- case 4:
- {
- // top left
- const LYTWindowFrame &fTL = *wnd->frames.at(0);
- const LYTMaterial &mTL = getMaterial(fTL.materialName);
-
- if (!mTL.texMaps.empty()) {
- useMaterial(mTL);
-
- float pieceWidth = wnd->width - frameRight;
- float pieceHeight = frameTop;
-
- dealWithWindowFrame(texCoords, fTL.materialName, fTL.type, pieceWidth, pieceHeight, 0, 2, 4, 6);
- drawQuad(dX, dY, pieceWidth, pieceHeight, 1, &texCoords, 0, effectiveAlpha);
- }
-
- // top right
- const LYTWindowFrame &fTR = *wnd->frames.at(1);
- const LYTMaterial &mTR = getMaterial(fTR.materialName);
-
- if (!mTR.texMaps.empty()) {
- useMaterial(mTR);
-
- float pieceWidth = frameRight;
- float pieceHeight = wnd->height - frameBottom;
-
- dealWithWindowFrame(texCoords, fTR.materialName, fTR.type, pieceWidth, pieceHeight, 2, 0, 6, 4);
-
- drawQuad(dX + wnd->width - frameRight, dY, pieceWidth, pieceHeight,
- 1, &texCoords, 0, effectiveAlpha);
- }
-
- // bottom left
- const LYTWindowFrame &fBL = *wnd->frames.at(2);
- const LYTMaterial &mBL = getMaterial(fBL.materialName);
-
- if (!mBL.texMaps.empty()) {
- useMaterial(mBL);
-
- float pieceWidth = frameLeft;
- float pieceHeight = wnd->height - frameTop;
-
- dealWithWindowFrame(texCoords, fBL.materialName, fBL.type, pieceWidth, pieceHeight, 4, 6, 0, 2);
-
- drawQuad(dX, dY - frameTop, pieceWidth, pieceHeight,
- 1, &texCoords, 0, effectiveAlpha);
- }
-
- const LYTWindowFrame &fBR = *wnd->frames.at(3);
- const LYTMaterial &mBR = getMaterial(fBR.materialName);
-
- // bottom right
- if (!mBR.texMaps.empty()) {
- useMaterial(mBR);
-
- float pieceWidth = wnd->width - frameLeft;
- float pieceHeight = frameBottom;
-
- dealWithWindowFrame(texCoords, fBR.materialName, fBR.type, pieceWidth, pieceHeight, 6, 4, 2, 0);
-
- drawQuad(dX + frameLeft, dY - wnd->height + frameBottom, pieceWidth, pieceHeight,
- 1, &texCoords, 0, effectiveAlpha);
- }
- }
- break;
- case 8:
- {
- qDebug() << "WHOA!!!";
- // top left
- const LYTWindowFrame &fTL = *wnd->frames.at(0);
- const LYTMaterial &mTL = getMaterial(fTL.materialName);
-
- if (!mTL.texMaps.empty()) {
- useMaterial(mTL);
-
- dealWithWindowFrame(texCoords, fTL.materialName, fTL.type, frameLeft, frameTop, 0, 2, 4, 6);
- drawQuad(dX, dY, frameLeft, frameTop, 1, &texCoords, 0, effectiveAlpha);
- }
-
- // top right
- const LYTWindowFrame &fTR = *wnd->frames.at(1);
- const LYTMaterial &mTR = getMaterial(fTR.materialName);
-
- if (!mTR.texMaps.empty()) {
- useMaterial(mTR);
-
- dealWithWindowFrame(texCoords, fTR.materialName, fTR.type, frameRight, frameTop, 2, 0, 6, 4);
-
- drawQuad(dX + wnd->width - frameRight, dY, frameRight, frameTop,
- 1, &texCoords, 0, effectiveAlpha);
- }
-
- // bottom left
- const LYTWindowFrame &fBL = *wnd->frames.at(2);
- const LYTMaterial &mBL = getMaterial(fBL.materialName);
-
- if (!mBL.texMaps.empty()) {
- useMaterial(mBL);
-
- dealWithWindowFrame(texCoords, fBL.materialName, fBL.type, frameLeft, frameBottom, 4, 6, 0, 2);
-
- drawQuad(dX, dY - frameTop, frameLeft, frameBottom,
- 1, &texCoords, 0, effectiveAlpha);
- }
-
- const LYTWindowFrame &fBR = *wnd->frames.at(3);
- const LYTMaterial &mBR = getMaterial(fBR.materialName);
-
- // bottom right
- if (!mBR.texMaps.empty()) {
- useMaterial(mBR);
-
- dealWithWindowFrame(texCoords, fBR.materialName, fBR.type, frameRight, frameBottom, 6, 4, 2, 0);
-
- drawQuad(dX + frameLeft, dY - wnd->height + frameBottom, frameRight, frameBottom,
- 1, &texCoords, 0, effectiveAlpha);
- }
- }
- default:
- qDebug() << "unhandled window frame count" << wnd->frames.count();
- }
-}
-
-static GLint GLWrapModes[] = {
- GL_CLAMP_TO_EDGE, // Clamp
- GL_REPEAT, // Repeat
- GL_MIRRORED_REPEAT, // Mirror
-};
-
-void LGLWidget::useMaterial(const QString &materialName) {
- const LYTMaterial *mat = m_layout->materials.getMaterialByName(materialName);
-
- useMaterial(*mat);
-}
-
-void LGLWidget::useMaterial(const LYTMaterial &mat) {
- int cutAt = mat.texMaps.count();
-
- for (int i = 0; i < cutAt; i++) {
- const LYTTexMap &texMap = mat.texMaps.at(i);
-
- const QString &texName = texMap.textureName;
- GLuint texID = m_texMgr.glTextureForName(texName);
-
- glActiveTexture(GL_TEXTURE0 + i);
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, texID);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GLWrapModes[texMap.wrap_s]);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GLWrapModes[texMap.wrap_t]);
-
- // is there a matching TexSRT?
- // TODO: fix this
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
-
- if (mat.texSRTs.count() > i) {
- const LYTTexSRT &srt = mat.texSRTs.at(i);
-
- glScalef(srt.xScale, srt.yScale, 1.0f);
- // rotate?
- glTranslatef(srt.xTrans, -srt.yTrans, 0.0f);
- }
-
- glMatrixMode(GL_MODELVIEW);
- }
-
- for (int i = cutAt; i < 8; i++) {
- glActiveTexture(GL_TEXTURE0 + i);
- glDisable(GL_TEXTURE_2D);
- }
-
- glActiveTexture(GL_TEXTURE0);
-}
-
-void LGLWidget::drawQuad(float x, float y, float w, float h, const QVector<LYTTexCoords> &texCoords, const QColor *colours, uchar alpha) {
- drawQuad(x, y, w, h, texCoords.count(), texCoords.constData(), colours, alpha);
-}
-
-void LGLWidget::drawQuad(float x, float y, float w, float h, int texCoordCount, const LYTTexCoords *texCoords, const QColor *colours, uchar alpha) {
- if (!colours)
- glColor4ub(255, 255, 255, alpha);
-
- glBegin(GL_QUADS);
-
- for (int i = 0; i < texCoordCount; i++)
- glMultiTexCoord2f(GL_TEXTURE0_ARB+i, texCoords[i].coord[0].x(), 1.0f-texCoords[i].coord[0].y());
-
- if (colours)
- glColor4ub(colours[0].red(), colours[0].green(), colours[0].blue(), (colours[0].alpha() * alpha) / 255);
- glVertex2f(x, y);
-
- for (int i = 0; i < texCoordCount; i++)
- glMultiTexCoord2f(GL_TEXTURE0_ARB+i, texCoords[i].coord[1].x(), 1.0f-texCoords[i].coord[1].y());
-
- if (colours)
- glColor4ub(colours[1].red(), colours[1].green(), colours[1].blue(), (colours[1].alpha() * alpha) / 255);
- glVertex2f(x + w, y);
-
- for (int i = 0; i < texCoordCount; i++)
- glMultiTexCoord2f(GL_TEXTURE0_ARB+i, texCoords[i].coord[3].x(), 1.0f-texCoords[i].coord[3].y());
-
- if (colours)
- glColor4ub(colours[3].red(), colours[3].green(), colours[3].blue(), (colours[3].alpha() * alpha) / 255);
- glVertex2f(x + w, y - h);
-
- for (int i = 0; i < texCoordCount; i++)
- glMultiTexCoord2f(GL_TEXTURE0_ARB+i, texCoords[i].coord[2].x(), 1.0f-texCoords[i].coord[2].y());
-
- if (colours)
- glColor4ub(colours[2].red(), colours[2].green(), colours[2].blue(), (colours[2].alpha() * alpha) / 255);
- glVertex2f(x, y - h);
-
- glEnd();
-}
-
-
-void LGLWidget::getTextureSize(const QString &materialName, float *w, float *h) {
- const LYTMaterial *mat = m_layout->materials.getMaterialByName(materialName);
-
- if (mat->texMaps.count() == 0) {
- *w = 0.0f;
- *h = 0.0f;
- } else {
- const LYTTexMap &tm = mat->texMaps.first();
-
- QImage img = m_texMgr.imageForName(tm.textureName);
- *w = img.width();
- *h = img.height();
- }
-}
-
diff --git a/layoutgl/widget.h b/layoutgl/widget.h
deleted file mode 100644
index 1c7aaf1..0000000
--- a/layoutgl/widget.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef WIDGET_H
-#define WIDGET_H
-
-#include <QGLWidget>
-
-#include "lyt/layout.h"
-#include "layoutgl/texturemanager.h"
-
-class LGLWidget : public QGLWidget
-{
- Q_OBJECT
-public:
- explicit LGLWidget(QWidget *parent = 0);
-
- void setLayout(LYTLayout *layout);
-
-protected:
- void initializeGL();
- void resizeGL(int w, int h);
- void paintGL();
-
- LYTLayout *m_layout;
-
- void renderPane(const LYTPane *pane, quint8 parentAlpha);
-
- void drawPicture(const LYTPicture *pic, quint8 effectiveAlpha);
- void drawWindow(const LYTWindow *wnd, quint8 effectiveAlpha);
-
- const LYTMaterial &getMaterial(const QString &materialName) {
- return *m_layout->materials.getMaterialByName(materialName);
- }
-
- void useMaterial(const QString &materialName);
- void useMaterial(const LYTMaterial &material);
-
- void drawQuad(float x, float y, float w, float h, const QVector<LYTTexCoords> &texCoords, const QColor *colours, uchar alpha);
- void drawQuad(float x, float y, float w, float h, int texCoordCount, const LYTTexCoords *texCoords, const QColor *colours, uchar alpha);
-
- void getTextureSize(const QString &materialName, float *w, float *h);
-
- void dealWithWindowFrame(LYTTexCoords &coords, const QString &materialName, int flipType,
- float pieceWidth, float pieceHeight,
- int rep1, int rep2, int rep3, int rep4);
-
- LGLTextureManager m_texMgr;
-
-signals:
-
-public slots:
-
-};
-
-#endif // WIDGET_H
diff --git a/lscolorpicker.cpp b/lscolorpicker.cpp
deleted file mode 100644
index 553728e..0000000
--- a/lscolorpicker.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "lscolorpicker.h"
-#include <QColorDialog>
-
-LSColorPicker::LSColorPicker(QWidget *parent) :
- QToolButton(parent) {
-
- connect(this, SIGNAL(clicked()), SLOT(tryAndChoose()));
- setColor(QColor::fromRgb(255,255,255,255));
-}
-
-void LSColorPicker::setColor(QColor newCol) {
- m_color = newCol;
- refreshButton();
-}
-
-void LSColorPicker::tryAndChoose() {
- QColor newCol = QColorDialog::getColor(
- m_color, this,
- "Pick a Colour",
- QColorDialog::ShowAlphaChannel);
-
- if (newCol.isValid() && newCol != m_color) {
- QColor oldCol = m_color;
- m_color = newCol;
- refreshButton();
- emit colorPicked(newCol, oldCol);
- }
-}
-
-
-void LSColorPicker::refreshButton() {
- setStyleSheet(QString("QToolButton { background-color: rgba(%1,%2,%3,%4); }")
- .arg(m_color.red())
- .arg(m_color.green())
- .arg(m_color.blue())
- .arg(m_color.alpha()));
-
- setText(QString("RGBA (#%5%6%7%8)\n%1,%2,%3,%4")
- .arg(m_color.red())
- .arg(m_color.green())
- .arg(m_color.blue())
- .arg(m_color.alpha())
- .arg(m_color.red(), 2, 16, (QChar)'0')
- .arg(m_color.green(), 2, 16, (QChar)'0')
- .arg(m_color.blue(), 2, 16, (QChar)'0')
- .arg(m_color.alpha(), 2, 16, (QChar)'0'));
-}
diff --git a/lscolorpicker.h b/lscolorpicker.h
deleted file mode 100644
index 7f16c57..0000000
--- a/lscolorpicker.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef LSCOLORPICKER_H
-#define LSCOLORPICKER_H
-
-#include <QToolButton>
-
-class LSColorPicker : public QToolButton
-{
- Q_OBJECT
-public:
- explicit LSColorPicker(QWidget *parent = 0);
-
- QColor color() const { return m_color; }
- void setColor(QColor newCol);
-
-private:
- QColor m_color;
-
-private slots:
- void tryAndChoose();
- void refreshButton();
-
-signals:
- void colorPicked(QColor newCol, QColor oldCol);
-
-};
-
-#endif // LSCOLORPICKER_H
diff --git a/lsglobals.cpp b/lsglobals.cpp
deleted file mode 100644
index 07f505e..0000000
--- a/lsglobals.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- This file is part of LayoutStudio (http://github.com/Treeki/LayoutStudio)
- Copyright (c) 2010 Treeki (treeki@gmail.com)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, version 2.0.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License 2.0 for more details.
-
- You should have received a copy of the GNU General Public License 2.0
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*******************************************************************************/
-
-#include "lsglobals.h"
-
-bool LSGlobals::m_loaded = false;
-QHash<QString, QIcon> LSGlobals::m_icons;
-
-
-bool LSGlobals::setup() {
- if (m_loaded)
- return false;
-
-
-
- // Load icons
- loadIcon("pane");
- loadIcon("picture");
- loadIcon("textbox");
- loadIcon("bounding");
- loadIcon("window");
-
-
-
- m_loaded = true;
- return true;
-}
-
-
-bool LSGlobals::loadIcon(QString name) {
- m_icons[name] = QIcon(QString(":icons/%1").arg(name));
- return true;
-}
-
-
-QIcon LSGlobals::getIcon(QString name) {
- return m_icons.value(name);
-}
diff --git a/lsglobals.h b/lsglobals.h
deleted file mode 100644
index 342384b..0000000
--- a/lsglobals.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- This file is part of LayoutStudio (http://github.com/Treeki/LayoutStudio)
- Copyright (c) 2010 Treeki (treeki@gmail.com)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, version 2.0.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License 2.0 for more details.
-
- You should have received a copy of the GNU General Public License 2.0
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*******************************************************************************/
-
-#ifndef LSGLOBALS_H
-#define LSGLOBALS_H
-
-#include <QtGui/QIcon>
-#include <QtCore/QHash>
-
-class LSGlobals {
-public:
- static bool setup();
-
- static QIcon getIcon(QString name);
-
-private:
- static bool m_loaded;
-
- static QHash<QString, QIcon> m_icons;
-
- static bool loadIcon(QString name);
-};
-
-#endif // LSGLOBALS_H
diff --git a/lslayoutwindow.cpp b/lslayoutwindow.cpp
deleted file mode 100644
index 3fe84ad..0000000
--- a/lslayoutwindow.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-#include "lslayoutwindow.h"
-#include "lsscenemodel.h"
-#include "lsmaterialmodel.h"
-#include "lspaneeditor.h"
-#include "lsmaterialeditor.h"
-#include "layoutgl/widget.h"
-#include <QGridLayout>
-#include <QFormLayout>
-#include <QGroupBox>
-#include <QScrollArea>
-
-LSLayoutWindow::LSLayoutWindow(LYTPackageBase *pkg, const QString &layoutName, QWidget *parent) :
- QMainWindow(parent) {
-
- m_layoutName = layoutName;
- m_package = pkg;
- m_loadingSettings = true;
-
- m_tabWidget = new QTabWidget(this);
- setCentralWidget(m_tabWidget);
-
- QWidget *w;
-
- // prepare the Settings tab
- w = new QWidget(this);
- QGridLayout *sgrid = new QGridLayout(w);
-
- QGroupBox *sizeGroup = new QGroupBox("Layout Size", this);
- sgrid->addWidget(sizeGroup, 0, 0, 1, 2);
-
- QFormLayout *sizeForm = new QFormLayout(sizeGroup);
-
- m_widthBox = new QDoubleSpinBox(this);
- m_widthBox->setRange(0.0, 1000.0);
- m_heightBox = new QDoubleSpinBox(this);
- m_heightBox->setRange(0.0, 1000.0);
-
- sizeForm->addRow("Width", m_widthBox);
- sizeForm->addRow("Height", m_heightBox);
-
- connect(m_widthBox, SIGNAL(valueChanged(double)), SLOT(handleWidthChanged(double)));
- connect(m_heightBox, SIGNAL(valueChanged(double)), SLOT(handleHeightChanged(double)));
-
-
- QGroupBox *grpGroup = new QGroupBox("Groups", this);
-
- sgrid->addWidget(grpGroup, 1, 0, 1, 2);
- sgrid->setRowStretch(1, 1);
-
- m_tabWidget->addTab(w, "Layout");
-
- // prepare the Scene Graph tab
- m_sceneSplitter = new QSplitter(this);
-
- w = new QWidget(this);
- QGridLayout *ggrid = new QGridLayout(w);
-
- m_searchBox = new QLineEdit(this);
- m_searchBox->setPlaceholderText("Search panes...");
-
- m_clearSearchButton = new QPushButton("Clear", this);
-
- m_sceneGraph = new QTreeView(this);
- m_sceneGraph->setHeaderHidden(true);
- m_sceneSearchList = new QListView(this);
- m_sceneListSwitcher = new QStackedLayout;
- m_sceneListSwitcher->addWidget(m_sceneGraph);
- m_sceneListSwitcher->addWidget(m_sceneSearchList);
-
- ggrid->addWidget(m_searchBox, 0, 0, 1, 1);
- ggrid->addWidget(m_clearSearchButton, 0, 1, 1, 1);
- ggrid->addLayout(m_sceneListSwitcher, 1, 0, 1, 2);
-
- QWidget *switcherWidget = new QWidget(this);
- m_paneEditorSwitcher = new QStackedLayout(switcherWidget);
-
- m_paneEditor = new LSPaneEditor(switcherWidget);
-
- m_paneEditorSwitcher->addWidget(new QLabel("Choose a pane to edit from the left.", switcherWidget));
- m_paneEditorSwitcher->addWidget(m_paneEditor);
-
- m_sceneSplitter->addWidget(w);
- m_sceneSplitter->addWidget(switcherWidget);
- m_sceneSplitter->setCollapsible(1, false);
-
- m_tabWidget->addTab(m_sceneSplitter, "Scene Graph");
-
-
- // prepare the materials tab
- m_materialSplitter = new QSplitter(this);
-
- w = new QWidget(this);
- QGridLayout *mgrid = new QGridLayout(w);
-
- m_addMaterialButton = new QPushButton("Add", w);
- m_removeMaterialButton = new QPushButton("Remove", w);
- m_materialList = new QListView(w);
-
- mgrid->addWidget(m_materialList, 0, 0, 1, 2);
- mgrid->addWidget(m_addMaterialButton, 1, 0, 1, 1);
- mgrid->addWidget(m_removeMaterialButton, 1, 1, 1, 1);
-
- QScrollArea *matScroller = new QScrollArea(m_materialSplitter);
- m_materialEditor = new LSMaterialEditor(matScroller);
-
- m_materialSplitter->addWidget(w);
- m_materialSplitter->addWidget(matScroller);
- m_materialSplitter->setCollapsible(1, false);
-
- matScroller->setWidget(m_materialEditor);
-
- m_tabWidget->addTab(m_materialSplitter, "Materials");
-
-
- // get the resource
- m_layout = new LYTLayout(*m_package, m_layoutName);
-
- m_widthBox->setValue(m_layout->width);
- m_heightBox->setValue(m_layout->height);
-
- LSSceneModel *scnModel = new LSSceneModel(m_layout, true, this);
-
- m_sceneGraph->setSelectionMode(QAbstractItemView::ExtendedSelection);
- m_sceneGraph->setDragEnabled(true);
- m_sceneGraph->setAcceptDrops(true);
- m_sceneGraph->setDropIndicatorShown(true);
- m_sceneGraph->setModel(scnModel);
- m_sceneGraph->expandAll();
- connect(m_sceneGraph->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(selectedPaneChanged(QModelIndex,QModelIndex)));
-
- LSMaterialModel *matModel = new LSMaterialModel(&m_layout->materials, this);
-
- m_materialList->setSelectionMode(QAbstractItemView::SingleSelection);
- m_materialList->setModel(matModel);
- connect(m_materialList->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(selectedMaterialChanged(QModelIndex,QModelIndex)));
-
- setWindowTitle(m_layoutName);
-
-
- // finally make the widget
- m_renderer = new LGLWidget();
- m_renderer->setLayout(m_layout);
- m_renderer->setWindowTitle(QString("Preview: %1").arg(m_layoutName));
- m_renderer->setWindowFlags(
- Qt::CustomizeWindowHint |
- Qt::WindowTitleHint |
- Qt::WindowMinimizeButtonHint);
- m_renderer->show();
-
- connect(m_paneEditor, SIGNAL(mustRedrawLayout()), m_renderer, SLOT(updateGL()));
- connect(scnModel, SIGNAL(paneVisibilityChanged()), m_renderer, SLOT(updateGL()));
-
- // clean up here
- setAttribute(Qt::WA_DeleteOnClose);
-
- m_loadingSettings = false;
-}
-
-LSLayoutWindow::~LSLayoutWindow() {
- m_renderer->close();
- delete m_renderer;
- delete m_layout;
-}
-
-
-void LSLayoutWindow::selectedPaneChanged(const QModelIndex &current, const QModelIndex &previous) {
- (void)previous;
- LYTPane *pane = (LYTPane*)current.internalPointer();
-
- m_paneEditor->setPane(pane);
- m_paneEditorSwitcher->setCurrentIndex(1);
-}
-
-void LSLayoutWindow::selectedMaterialChanged(const QModelIndex &current, const QModelIndex &previous) {
- (void)previous;
- LYTMaterial *mat = m_layout->materials.getMaterialByIndex(current.row());
-
- m_materialEditor->setMaterial(mat);
-}
-
-
-void LSLayoutWindow::handleWidthChanged(double v) {
- m_layout->width = v;
- if (!m_loadingSettings)
- m_renderer->updateGL();
-}
-
-void LSLayoutWindow::handleHeightChanged(double v) {
- m_layout->height = v;
- if (!m_loadingSettings)
- m_renderer->updateGL();
-}
-
diff --git a/lslayoutwindow.h b/lslayoutwindow.h
deleted file mode 100644
index cd3c6ec..0000000
--- a/lslayoutwindow.h
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef LSLAYOUTWINDOW_H
-#define LSLAYOUTWINDOW_H
-
-#include <QMainWindow>
-#include <QTabWidget>
-#include <QDoubleSpinBox>
-#include <QTreeView>
-#include <QStackedLayout>
-#include <QPushButton>
-#include <QLineEdit>
-#include <QListView>
-#include <QSplitter>
-#include "lyt/packagebase.h"
-#include "lyt/layout.h"
-class LSPaneEditor;
-class LSMaterialEditor;
-class LGLWidget;
-
-class LSLayoutWindow : public QMainWindow {
- Q_OBJECT
-public:
- explicit LSLayoutWindow(LYTPackageBase *pkg, const QString &layoutName, QWidget *parent = 0);
- ~LSLayoutWindow();
-
- QString layoutName() const { return m_layoutName; }
- // TODO: set layoutname method
-
- LYTLayout *editedLayout() const { return m_layout; }
-
-private:
- QString m_layoutName;
- LYTPackageBase *m_package;
- LYTLayout *m_layout;
-
- LGLWidget *m_renderer;
-
- QTabWidget *m_tabWidget;
-
- // settings
- QDoubleSpinBox *m_widthBox, *m_heightBox;
-
- // scene graph
- QSplitter *m_sceneSplitter;
-
- QStackedLayout *m_sceneListSwitcher;
- QLineEdit *m_searchBox;
- QPushButton *m_clearSearchButton;
- QTreeView *m_sceneGraph;
- QListView *m_sceneSearchList;
-
- QStackedLayout *m_paneEditorSwitcher;
- LSPaneEditor *m_paneEditor;
-
- bool m_loadingSettings;
-
- // material things
- QSplitter *m_materialSplitter;
-
- QListView *m_materialList;
- QPushButton *m_addMaterialButton;
- QPushButton *m_removeMaterialButton;
-
- LSMaterialEditor *m_materialEditor;
-
-private slots:
- void handleWidthChanged(double v);
- void handleHeightChanged(double v);
- void selectedPaneChanged(const QModelIndex &current, const QModelIndex &previous);
- void selectedMaterialChanged(const QModelIndex &current, const QModelIndex &previous);
-
-signals:
-
-public slots:
-
-};
-
-#endif // LSLAYOUTWINDOW_H
diff --git a/lsmainwindow.cpp b/lsmainwindow.cpp
deleted file mode 100644
index 1d13a50..0000000
--- a/lsmainwindow.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
-/*******************************************************************************
- This file is part of LayoutStudio (http://github.com/Treeki/LayoutStudio)
- Copyright (c) 2010 Treeki (treeki@gmail.com)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, version 2.0.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License 2.0 for more details.
-
- You should have received a copy of the GNU General Public License 2.0
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*******************************************************************************/
-
-#include "lsmainwindow.h"
-#include <QAction>
-#include <QMenuBar>
-#include <QFileDialog>
-#include <QInputDialog>
-#include <QMessageBox>
-#include "lyt/archivepackage.h"
-#include "lslayoutwindow.h"
-
-LSMainWindow::LSMainWindow(QWidget *parent) : QMainWindow(parent) {
- m_package = 0;
- m_dirty = false;
- m_isSaved = false;
-
- createActions();
-
- m_view = new QTreeView(this);
- m_view->setHeaderHidden(true);
- setCentralWidget(m_view);
-
- connect(m_view, SIGNAL(activated(QModelIndex)), SLOT(handleItemActivated(QModelIndex)));
-
- newArchive();
-}
-
-LSMainWindow::~LSMainWindow() {
- if (m_package)
- delete m_package;
-}
-
-
-void LSMainWindow::createActions() {
- m_newArchiveAction = new QAction("&New Archive", this);
- m_openArchiveAction = new QAction("&Open Archive...", this);
- m_saveAction = new QAction("&Save", this);
- m_saveArchiveAsAction = new QAction("Save Archive &As...", this);
-
- m_newArchiveAction->setShortcuts(QKeySequence::New);
- m_openArchiveAction->setShortcuts(QKeySequence::Open);
- m_saveAction->setShortcuts(QKeySequence::Save);
- m_saveArchiveAsAction->setShortcuts(QKeySequence::SaveAs);
-
- connect(m_newArchiveAction, SIGNAL(triggered()), SLOT(newArchive()));
- connect(m_openArchiveAction, SIGNAL(triggered()), SLOT(openArchive()));
- connect(m_saveAction, SIGNAL(triggered()), SLOT(save()));
- connect(m_saveArchiveAsAction, SIGNAL(triggered()), SLOT(saveArchiveAs()));
-
- m_addLayoutAction = new QAction("New &Layout...", this);
- m_addAnimationAction = new QAction("New &Animation...", this);
- m_addTextureAction = new QAction("New &Texture...", this);
- m_importNewAction = new QAction("&New Item...", this);
- m_importAction = new QAction("&Replace This Item...", this);
- m_exportAction = new QAction("&Export to File...", this);
- m_renameAction = new QAction("Re&name Item...", this);
- m_removeAction = new QAction("&Remove Item...", this);
-
- m_addActionMapper = new QSignalMapper(this);
- m_addActionMapper->setMapping(m_addLayoutAction, (int)LYTPackageBase::Layout);
- m_addActionMapper->setMapping(m_addAnimationAction, (int)LYTPackageBase::Animation);
- m_addActionMapper->setMapping(m_addTextureAction, (int)LYTPackageBase::Texture);
-
- connect(m_addLayoutAction, SIGNAL(triggered()), m_addActionMapper, SLOT(map()));
- connect(m_addAnimationAction, SIGNAL(triggered()), m_addActionMapper, SLOT(map()));
- connect(m_addTextureAction, SIGNAL(triggered()), m_addActionMapper, SLOT(map()));
- connect(m_addActionMapper, SIGNAL(mapped(int)), SLOT(handleAddSomething(int)));
-
- connect(m_renameAction, SIGNAL(triggered()), SLOT(handleRenameItem()));
- connect(m_removeAction, SIGNAL(triggered()), SLOT(handleRemoveItem()));
-
- QMenuBar *bar = menuBar();
- QMenu *m;
-
- m = bar->addMenu("&File");
- m->addAction(m_newArchiveAction);
- m->addAction(m_openArchiveAction);
- m->addAction(m_saveAction);
- m->addAction(m_saveArchiveAsAction);
-
- m = bar->addMenu("&Edit");
- m->addAction(m_addLayoutAction);
- m->addAction(m_addAnimationAction);
- m->addAction(m_addTextureAction);
- m->addSeparator();
- QMenu *importMenu = m->addMenu("&Import from File");
- importMenu->addAction(m_importNewAction);
- importMenu->addAction(m_importAction);
- m->addAction(m_exportAction);
- m->addSeparator();
- m->addAction(m_renameAction);
- m->addAction(m_removeAction);
-}
-
-
-void LSMainWindow::handleAddSomething(int whatToAdd) {
- LYTPackageBase::ItemType what = (LYTPackageBase::ItemType)whatToAdd;
-
- const char *typeName;
- QString extension;
- switch (what) {
- case LYTPackageBase::Layout:
- typeName = "layout";
- extension = ".brlyt";
- break;
- case LYTPackageBase::Animation:
- typeName = "animation";
- extension = ".brlan";
- break;
- case LYTPackageBase::Texture:
- typeName = "texture";
- extension = ".tpl";
- break;
- default: return;
- }
-
- QString name = QInputDialog::getText(this,
- "Add Item",
- QString("Name this %1:").arg(typeName));
-
- if (!name.isEmpty()) {
- QByteArray data = LYTPackageBase::createSkeletonItem(what);
- if (!name.endsWith(extension))
- name.append(extension);
-
- m_package->write(what, name, data);
- }
-}
-
-
-void LSMainWindow::handleRemoveItem() {
- QString what = selectedItem();
- LYTPackageBase::ItemType whatType = selectedItemType();
-
- if (!what.isEmpty()) {
- QString confirmText = QString("Are you sure you want to delete '%1'? You'll lose it forever...!").arg(what);
-
- int confirm = QMessageBox::question(this,
- "Confirm Removal",
- confirmText,
- QMessageBox::Yes,
- QMessageBox::No);
-
- if (confirm == QMessageBox::Yes) {
- m_package->remove(whatType, what);
- }
- }
-}
-
-
-void LSMainWindow::handleRenameItem() {
- QString what = selectedItem();
- LYTPackageBase::ItemType whatType = selectedItemType();
-
- if (!what.isEmpty()) {
- QString newName = QInputDialog::getText(this,
- "Rename Item",
- QString("Enter a new name:"),
- QLineEdit::NoEcho,
- what);
-
- if (!newName.isEmpty()) {
- m_package->rename(whatType, what, newName);
- }
- }
-}
-
-
-QString LSMainWindow::selectedItem() const {
- QModelIndex idx = m_view->currentIndex();
- return m_model->itemNameForIndex(idx);
-}
-
-LYTPackageBase::ItemType LSMainWindow::selectedItemType() const {
- QModelIndex idx = m_view->currentIndex();
- return m_model->itemTypeForIndex(idx);
-}
-
-
-void LSMainWindow::handleItemActivated(const QModelIndex &index) {
- QString what = selectedItem();
- LYTPackageBase::ItemType whatType = selectedItemType();
-
- if (what.isEmpty())
- return;
-
- switch (whatType) {
- case LYTPackageBase::Layout:
- LSLayoutWindow *w = new LSLayoutWindow(m_package, what);
- w->show();
- break;
- }
-}
-
-
-bool LSMainWindow::ensureSaved() {
- // TODO
- return false;
-}
-
-void LSMainWindow::updateTitleBar() {
- QString title;
- if (m_isSaved)
- title = m_package->description();
- else
- title = "[Unsaved]";
-
- if (m_dirty)
- title.append('*');
- title.append(" - LayoutStudio");
-
- setWindowTitle(title);
- setWindowModified(m_dirty);
-}
-
-void LSMainWindow::newArchive() {
- if (ensureSaved())
- return;
-
- LYTArchivePackage *pkg = new LYTArchivePackage;
- setCurrentPackage(pkg);
-
- m_dirty = false;
- m_isSaved = false;
- updateTitleBar();
-}
-
-void LSMainWindow::openArchive() {
- if (ensureSaved())
- return;
-
- QString path = QFileDialog::getOpenFileName(this,
- "Open a Layout Archive",
- QString(),
- "Wii Archives (*.arc)"
- );
-
- if (path.isEmpty())
- return;
-
- LYTArchivePackage *pkg = new LYTArchivePackage(path);
- setCurrentPackage(pkg);
-
- m_dirty = false;
- m_isSaved = true;
- updateTitleBar();
-}
-
-void LSMainWindow::save() {
- // TODO: check that m_package is an arc
- if (m_isSaved) {
- m_dirty = false;
- m_package->savePackage();
- updateTitleBar();
- } else {
- saveArchiveAs();
- }
-}
-
-void LSMainWindow::saveArchiveAs() {
- // TODO: check that m_package is an arc
- QString newPath = QFileDialog::getSaveFileName(this,
- "Save Layout Archive",
- QString(),
- "Wii Archives (*.arc)"
- );
-
- if (newPath.isEmpty())
- return;
-
- LYTArchivePackage *pkg = (LYTArchivePackage*)m_package;
- pkg->setFilename(newPath);
- pkg->savePackage();
-
- m_dirty = false;
- m_isSaved = true;
- updateTitleBar();
-}
-
-
-void LSMainWindow::setCurrentPackage(LYTPackageBase *pkg) {
- m_package = pkg;
-
- QItemSelectionModel *oldSel = m_view->selectionModel();
- QAbstractItemModel *model = m_view->model();
-
- m_model = new LSPackageModel(pkg, this);
- m_view->setModel(m_model);
-
- if (model)
- delete model;
- if (oldSel)
- delete oldSel;
-}
diff --git a/lsmainwindow.h b/lsmainwindow.h
deleted file mode 100644
index 639725b..0000000
--- a/lsmainwindow.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- This file is part of LayoutStudio (http://github.com/Treeki/LayoutStudio)
- Copyright (c) 2010 Treeki (treeki@gmail.com)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, version 2.0.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License 2.0 for more details.
-
- You should have received a copy of the GNU General Public License 2.0
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*******************************************************************************/
-
-#ifndef LSMAINWINDOW_H
-#define LSMAINWINDOW_H
-
-#include "lyt/packagebase.h"
-#include "lspackagemodel.h"
-#include <QMainWindow>
-#include <QTreeView>
-#include <QSignalMapper>
-
-class LSMainWindow : public QMainWindow {
- Q_OBJECT
-public:
- LSMainWindow(QWidget *parent = 0);
- ~LSMainWindow();
-
-protected:
- bool ensureSaved();
-
-public:
- void updateTitleBar();
-
-public slots:
- void newArchive();
- void openArchive();
- void save();
- void saveArchiveAs();
-
-private slots:
- void handleAddSomething(int whatToAdd);
- void handleRenameItem();
- void handleRemoveItem();
- void handleItemActivated(const QModelIndex &index);
-
-private:
- LYTPackageBase *m_package;
- void setCurrentPackage(LYTPackageBase *pkg);
-
- void createActions();
- QAction *m_newArchiveAction, *m_openArchiveAction, *m_saveArchiveAsAction;
- QAction *m_saveAction;
-
- QAction *m_addLayoutAction, *m_addAnimationAction;
- QAction *m_addTextureAction;
- QSignalMapper *m_addActionMapper;
- QAction *m_importNewAction, *m_importAction;
- QAction *m_renameAction, *m_removeAction, *m_exportAction;
-
- LSPackageModel *m_model;
- QTreeView *m_view;
-
- bool m_dirty;
- bool m_isSaved;
-
-protected:
- QString selectedItem() const;
- LYTPackageBase::ItemType selectedItemType() const;
-};
-
-#endif // LSMAINWINDOW_H
diff --git a/lsmaterialeditor.cpp b/lsmaterialeditor.cpp
deleted file mode 100644
index 9494837..0000000
--- a/lsmaterialeditor.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-#include "lsmaterialeditor.h"
-#include "lsmaterialeditors.h"
-#include <QGroupBox>
-
-LSMaterialEditor::LSMaterialEditor(QWidget *parent) :
- QWidget(parent) {
-
- QGridLayout *grid = new QGridLayout(this);
- int gridRow = 0;
-
- m_nameEntry = new QLineEdit(this);
-
- grid->addWidget(new QLabel("Name:", this), gridRow, 0, 1, 1);
- grid->addWidget(m_nameEntry, gridRow, 1, 1, 1);
- gridRow++;
-
- // TEV colour box
- QGroupBox *tevCBox = new QGroupBox("TEV Colours", this);
- QGridLayout *tevCLayout = new QGridLayout(tevCBox);
-
- tevCLayout->addWidget(new QLabel("Initial Registers:", tevCBox), 0, 0, 1, 4);
- tevCLayout->addWidget(new QLabel("Constant:", tevCBox), 2, 0, 1, 4);
-
- for (int i = 0; i < 7; i++) {
- m_colourPickers[i] = new LSColorPicker(tevCBox);
- bool isKonst = (i >= 3);
- tevCLayout->addWidget(m_colourPickers[i], isKonst?3:1, isKonst?(i-3):i, 1, 1);
- }
-
- grid->addWidget(tevCBox, gridRow, 0, 1, 2);
- gridRow++;
-
- // TEV stages
- QGroupBox *stageBox = new QGroupBox("TEV Stages", this);
- QVBoxLayout *stageLayout = new QVBoxLayout(stageBox);
-
- m_tevStageSetEditor = new LSSetEditor<LYTTevStage, LSTevStageEditor>(16, stageBox);
- stageLayout->addWidget(m_tevStageSetEditor);
-
- grid->addWidget(stageBox, gridRow, 0, 1, 2);
- gridRow++;
-
- // finish it all up
- grid->setRowStretch(gridRow, 1);
-
-
- m_currentlyLoadingMaterial = false;
- m_material = 0;
-}
-
-void LSMaterialEditor::setMaterial(LYTMaterial *mat) {
- m_currentlyLoadingMaterial = true;
- m_material = mat;
-
- m_nameEntry->setText(mat->name);
-
- for (int i = 0; i < 3; i++)
- m_colourPickers[i]->setColor(mat->colours[i]);
- for (int i = 0; i < 4; i++)
- m_colourPickers[i+3]->setColor(mat->tevKColour[i]);
-
- m_tevStageSetEditor->setData(&mat->tevStages);
-
- m_currentlyLoadingMaterial = false;
-}
-
-
-void LSMaterialEditor::handleNameChanged(QString value) {
-
-}
-
-void LSMaterialEditor::handleSaveChangedName() {
-
-}
-
-void LSMaterialEditor::handleColourPicked(QColor value) {
-
-}
diff --git a/lsmaterialeditor.h b/lsmaterialeditor.h
deleted file mode 100644
index 95c21f4..0000000
--- a/lsmaterialeditor.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef LSMATERIALEDITOR_H
-#define LSMATERIALEDITOR_H
-
-#include <QWidget>
-#include <QGridLayout>
-#include <QLabel>
-#include <QLineEdit>
-#include "lyt/materials/materialcontainer.h"
-#include "lscolorpicker.h"
-#include "lsseteditor.h"
-
-class LSTexMapEditor;
-class LSTexSRTEditor;
-class LSTexCoordGenEditor;
-class LSIndTexSRTEditor;
-class LSIndTexStageEditor;
-class LSTevStageEditor;
-
-class LSMaterialEditor : public QWidget {
- Q_OBJECT
-public:
- explicit LSMaterialEditor(QWidget *parent = 0);
-
-private:
- QLineEdit *m_nameEntry;
-
- LSColorPicker *m_colourPickers[7];
-
- bool m_currentlyLoadingMaterial;
- LYTMaterial *m_material;
-
- LSSetEditor<LYTTevStage, LSTevStageEditor> *m_tevStageSetEditor;
-
-private slots:
- void handleNameChanged(QString value);
- void handleSaveChangedName();
-
- void handleColourPicked(QColor value);
-
-signals:
- void mustRedrawLayout();
-
-public slots:
- void setMaterial(LYTMaterial *mat);
-
-};
-
-#endif // LSMATERIALEDITOR_H
diff --git a/lsmaterialeditors.h b/lsmaterialeditors.h
deleted file mode 100644
index 4dafe64..0000000
--- a/lsmaterialeditors.h
+++ /dev/null
@@ -1,408 +0,0 @@
-#ifndef LSMATERIALEDITORS_H
-#define LSMATERIALEDITORS_H
-
-#include "lsseteditor.h"
-#include "lyt/materials/material.h"
-#include <QLabel>
-#include <QComboBox>
-#include <QCheckBox>
-#include <QGridLayout>
-#include <QFormLayout>
-
-class LSTevStageEditor : public LSSetEntryEditorBase<LYTTevStage> {
- Q_OBJECT
-
- QComboBox *m_texCoord, *m_colour, *m_texMap;
- QCheckBox *m_disableTex;
-
- QComboBox *m_rasSwapMode, *m_texSwapMode;
-
- QComboBox *m_colourInA, *m_colourInB, *m_colourInC, *m_colourInD;
-
- QComboBox *m_colourOp, *m_colourBias, *m_colourScale, *m_colourOutReg;
- QCheckBox *m_colourClamp;
- QComboBox *m_colourConst;
-
- QComboBox *m_alphaInA, *m_alphaInB, *m_alphaInC, *m_alphaInD;
-
- QComboBox *m_alphaOp, *m_alphaBias, *m_alphaScale, *m_alphaOutReg;
- QCheckBox *m_alphaClamp;
- QComboBox *m_alphaConst;
-
- QComboBox *m_indStage, *m_indFormat, *m_indBias, *m_indMatrix;
- QComboBox *m_indWrapS, *m_indWrapT, *m_indAlphaSel;
- QCheckBox *m_indAddPrev, *m_indUtcLod;
-
-public:
- explicit LSTevStageEditor(QWidget *parent = 0) :
- LSSetEntryEditorBase(parent) {
-
- // Order
- m_texCoord = new QComboBox(this);
- m_texCoord->addItem("No TexCoord");
- for (int i = 0; i < 8; i++)
- m_texCoord->addItem(QString("TexCoord %1").arg(i));
-
- m_colour = new QComboBox(this);
- m_colour->addItem("Ignore Rasterised Colour");
- m_colour->addItem("Colour Channel 0");
- m_colour->addItem("Colour Channel 1");
- m_colour->addItem("Zero Colour");
- m_colour->addItem("Alpha Bump(?)");
- m_colour->addItem("Alpha BumpN(?)");
-
- m_texMap = new QComboBox(this);
- m_texMap->addItem("No TexMap");
- for (int i = 0; i < 8; i++)
- m_texMap->addItem(QString("TexMap %1").arg(i));
-
- m_disableTex = new QCheckBox("Disable Texture Lookup", this);
-
- // SwapModes
- m_rasSwapMode = new QComboBox(this);
- m_texSwapMode = new QComboBox(this);
- for (int i = 0; i < 4; i++) {
- m_rasSwapMode->addItem(QString("Swap Mode Table %1").arg(i));
- m_texSwapMode->addItem(QString("Swap Mode Table %1").arg(i));
- }
-
- // Colour in
- static const char *colIn[] = {
- "Colour Reg0", "Colour Reg1", "Colour Reg2", "Colour Reg3",
- "Alpha Reg0", "Alpha Reg1", "Alpha Reg2", "Alpha Reg3",
- "Texture Colour", "Texture Alpha",
- "Rasterised Colour", "Rasterised Alpha",
- "1.0", "0.5", "0.0", "Constant Colour"
- };
-
- m_colourInA = new QComboBox(this);
- m_colourInB = new QComboBox(this);
- m_colourInC = new QComboBox(this);
- m_colourInD = new QComboBox(this);
-
- for (int i = 0; i < 16; i++) {
- m_colourInA->addItem(colIn[i]);
- m_colourInB->addItem(colIn[i]);
- m_colourInC->addItem(colIn[i]);
- m_colourInD->addItem(colIn[i]);
- }
-
- // Colour op
- m_colourOp = new QComboBox(this);
- m_colourOp->addItem("Add: (d + ((1.0 - c)*a + c*b) + bias) * scale");
- m_colourOp->addItem("Sub: (d - ((1.0 - c)*a + c*b) + bias) * scale");
- m_colourOp->addItem("Comp_R8_GT: d + ((a[R] > b[R]) ? c : 0)");
- m_colourOp->addItem("Comp_R8_EQ: d + ((a[R] == b[R]) ? c : 0)");
- m_colourOp->addItem("Comp_GR16_GT: d + ((a[GR] > b[GR]) ? c : 0)");
- m_colourOp->addItem("Comp_GR16_EQ: d + ((a[GR] == b[GR]) ? c : 0)");
- m_colourOp->addItem("Comp_BGR24_GT: d + ((a[BGR] > b[BGR]) ? c : 0)");
- m_colourOp->addItem("Comp_BGR24_EQ: d + ((a[BGR] == b[BGR]) ? c : 0)");
- m_colourOp->addItem("Comp_RGB8_GT: Some crap");
- m_colourOp->addItem("Comp_RGB8_EQ: Some crap");
-
- m_colourBias = new QComboBox(this);
- m_colourBias->addItem("Zero");
- m_colourBias->addItem("+0.5");
- m_colourBias->addItem("-0.5");
-
- m_colourScale = new QComboBox(this);
- m_colourScale->addItem("x1");
- m_colourScale->addItem("x2");
- m_colourScale->addItem("x4");
- m_colourScale->addItem("x0.5");
-
- m_colourClamp = new QCheckBox("Clamp between 0.0 and 1.0", this);
-
- m_colourOutReg = new QComboBox(this);
- m_colourOutReg->addItem("Register 0");
- m_colourOutReg->addItem("Register 1");
- m_colourOutReg->addItem("Register 2");
- m_colourOutReg->addItem("Register 3 (Final output)");
-
- static const char *colConst[] = {
- "Constant 0", "Constant 1", "Constant 2", "Constant 3",
- "Const 0 Red", "Const 1 Red", "Const 2 Red", "Const 3 Red",
- "Const 0 Green", "Const 1 Green", "Const 2 Green", "Const 3 Green",
- "Const 0 Blue", "Const 1 Blue", "Const 2 Blue", "Const 3 Blue",
- "Const 0 Alpha", "Const 1 Alpha", "Const 2 Alpha", "Const 3 Alpha",
- "1.0", "0.875", "0.75", "0.625",
- "0.5", "0.375", "0.25", "0.125"
- };
- m_colourConst = new QComboBox(this);
- for (int i = 0; i < 28; i++)
- m_colourConst->addItem(colConst[i]);
-
- // Alpha in
- static const char *alphIn[] = {
- "Alpha Reg0", "Alpha Reg1", "Alpha Reg2", "Alpha Reg3",
- "Texture Alpha", "Rasterised Alpha",
- "0.0", "Constant alpha"
- };
-
- m_alphaInA = new QComboBox(this);
- m_alphaInB = new QComboBox(this);
- m_alphaInC = new QComboBox(this);
- m_alphaInD = new QComboBox(this);
-
- for (int i = 0; i < 8; i++) {
- m_alphaInA->addItem(alphIn[i]);
- m_alphaInB->addItem(alphIn[i]);
- m_alphaInC->addItem(alphIn[i]);
- m_alphaInD->addItem(alphIn[i]);
- }
-
- // alpha op
- m_alphaOp = new QComboBox(this);
- m_alphaOp->addItem("Add: (d + ((1.0 - c)*a + c*b) + bias) * scale");
- m_alphaOp->addItem("Sub: (d - ((1.0 - c)*a + c*b) + bias) * scale");
- m_alphaOp->addItem("Comp_R8_GT: d + ((a[R] > b[R]) ? c : 0)");
- m_alphaOp->addItem("Comp_R8_EQ: d + ((a[R] == b[R]) ? c : 0)");
- m_alphaOp->addItem("Comp_GR16_GT: d + ((a[GR] > b[GR]) ? c : 0)");
- m_alphaOp->addItem("Comp_GR16_EQ: d + ((a[GR] == b[GR]) ? c : 0)");
- m_alphaOp->addItem("Comp_BGR24_GT: d + ((a[BGR] > b[BGR]) ? c : 0)");
- m_alphaOp->addItem("Comp_BGR24_EQ: d + ((a[BGR] == b[BGR]) ? c : 0)");
- m_alphaOp->addItem("Comp_RGB8_GT: Some crap");
- m_alphaOp->addItem("Comp_RGB8_EQ: Some crap");
-
- m_alphaBias = new QComboBox(this);
- m_alphaBias->addItem("Zero");
- m_alphaBias->addItem("+0.5");
- m_alphaBias->addItem("-0.5");
-
- m_alphaScale = new QComboBox(this);
- m_alphaScale->addItem("x1");
- m_alphaScale->addItem("x2");
- m_alphaScale->addItem("x4");
- m_alphaScale->addItem("x0.5");
-
- m_alphaClamp = new QCheckBox("Clamp between 0.0 and 1.0", this);
-
- m_alphaOutReg = new QComboBox(this);
- m_alphaOutReg->addItem("Register 0");
- m_alphaOutReg->addItem("Register 1");
- m_alphaOutReg->addItem("Register 2");
- m_alphaOutReg->addItem("Register 3 (Final output)");
-
- static const char *alphConst[] = {
- "Const 0 Red", "Const 1 Red", "Const 2 Red", "Const 3 Red",
- "Const 0 Green", "Const 1 Green", "Const 2 Green", "Const 3 Green",
- "Const 0 Blue", "Const 1 Blue", "Const 2 Blue", "Const 3 Blue",
- "Const 0 Alpha", "Const 1 Alpha", "Const 2 Alpha", "Const 3 Alpha",
- "1.0", "0.875", "0.75", "0.625",
- "0.5", "0.375", "0.25", "0.125"
- };
- m_alphaConst = new QComboBox(this);
- for (int i = 0; i < 24; i++)
- m_alphaConst->addItem(alphConst[i]);
-
-
- // Indirect crap
- m_indStage = new QComboBox(this);
- for (int i = 0; i < 4; i++)
- m_indStage->addItem(QString("Stage %1").arg(i));
-
- m_indFormat = new QComboBox(this);
- m_indFormat->addItem("8 bits");
- m_indFormat->addItem("5 bits");
- m_indFormat->addItem("4 bits");
- m_indFormat->addItem("3 bits");
-
- m_indBias = new QComboBox(this);
- m_indBias->addItem("No bias");
- m_indBias->addItem("Bias S");
- m_indBias->addItem("Bias T");
- m_indBias->addItem("Bias S, T");
- m_indBias->addItem("Bias U");
- m_indBias->addItem("Bias S, U");
- m_indBias->addItem("Bias T, U");
- m_indBias->addItem("Bias S, T, U");
-
- m_indMatrix = new QComboBox(this);
- m_indMatrix->addItem("No matrix");
- m_indMatrix->addItem("Matrix 0");
- m_indMatrix->addItem("Matrix 1");
- m_indMatrix->addItem("Matrix 2");
- m_indMatrix->addItem("Matrix S0");
- m_indMatrix->addItem("Matrix S1");
- m_indMatrix->addItem("Matrix S2");
- m_indMatrix->addItem("Matrix T0");
- m_indMatrix->addItem("Matrix T1");
- m_indMatrix->addItem("Matrix T2");
-
- static const char *IndWraps[] = {
- "No wrap",
- "Wrap 256", "Wrap 128", "Wrap 64", "Wrap 32", "Wrap 16",
- "Zero"
- };
- m_indWrapS = new QComboBox(this);
- m_indWrapT = new QComboBox(this);
-
- for (int i = 0; i < 7; i++) {
- m_indWrapS->addItem(IndWraps[i]);
- m_indWrapT->addItem(IndWraps[i]);
- }
-
- m_indAddPrev = new QCheckBox("Add previous", this);
- m_indUtcLod = new QCheckBox("UTC LOD", this);
-
- m_indAlphaSel = new QComboBox(this);
- m_indAlphaSel->addItem("No bump alpha");
- m_indAlphaSel->addItem("From S");
- m_indAlphaSel->addItem("From T");
- m_indAlphaSel->addItem("From U");
-
- // Now put together the whole thing
- QFormLayout *layout = new QFormLayout(this);
-
- layout->addRow("Texture Map", m_texMap);
- layout->addWidget(m_disableTex);
- layout->addRow("Texture Coordinates", m_texCoord);
- layout->addRow("Rasterised Colour Channel", m_colour);
-
- layout->addRow("Texture Swap Mode Table", m_texSwapMode);
- layout->addRow("Rast. Swap Mode Table", m_rasSwapMode);
-
- layout->addWidget(new QLabel("<b>Colour Computation:</b>", this));
- layout->addRow("Input A", m_colourInA);
- layout->addRow("Input B", m_colourInB);
- layout->addRow("Input C", m_colourInC);
- layout->addRow("Input D", m_colourInD);
- layout->addRow("Constant", m_colourConst);
-
- layout->addRow("Equation", m_colourOp);
- layout->addRow("Bias", m_colourBias);
- layout->addRow("Scale", m_colourScale);
- layout->addWidget(m_colourClamp);
- layout->addRow("Output Register", m_colourOutReg);
-
- layout->addWidget(new QLabel("<b>Alpha Computation:</b>", this));
- layout->addRow("Input A", m_alphaInA);
- layout->addRow("Input B", m_alphaInB);
- layout->addRow("Input C", m_alphaInC);
- layout->addRow("Input D", m_alphaInD);
- layout->addRow("Constant", m_alphaConst);
-
- layout->addRow("Equation", m_alphaOp);
- layout->addRow("Bias", m_alphaBias);
- layout->addRow("Scale", m_alphaScale);
- layout->addWidget(m_alphaClamp);
- layout->addRow("Output Register", m_alphaOutReg);
-
- layout->addWidget(new QLabel("<b>Indirect Textures:</b>", this));
- layout->addRow("Indirect Stage", m_indStage);
- layout->addRow("Format", m_indFormat);
- layout->addRow("Bias", m_indBias);
- layout->addRow("Matrix", m_indMatrix);
- layout->addRow("Wrap S", m_indWrapS);
- layout->addRow("Wrap S", m_indWrapT);
- layout->addWidget(m_indAddPrev);
- layout->addWidget(m_indUtcLod);
- layout->addRow("Alpha Sel", m_indAlphaSel);
-
- }
-
- void loadEntryFrom(const LYTTevStage &entry) {
- m_texCoord->setCurrentIndex(entry.texCoord == 0xFF ? 0 : (entry.texCoord + 1));
-
- // TEV order
- quint8 actualTexMap = (entry.texMap & 0xFF);
- bool disableTexMap = (entry.texMap & 0x100) != 0;
- m_texMap->setCurrentIndex(actualTexMap == 0xFF ? 0 : (actualTexMap + 1));
- m_disableTex->setChecked(disableTexMap);
-
- static const int ColourIndices[] = {
- -1, -1, -1, -1, 1, 2, 3, 4, 5
- };
-
- if (entry.colour == 0xFF)
- m_colour->setCurrentIndex(0);
- else if (entry.colour > 8)
- m_colour->setCurrentIndex(-1);
- else
- m_colour->setCurrentIndex(ColourIndices[entry.colour]);
-
-
- // swapmode
- m_rasSwapMode->setCurrentIndex(entry.rasSwapMode);
- m_texSwapMode->setCurrentIndex(entry.texSwapMode);
-
- // colour in
- static const int ColInIndices[] = {
- 3, 7, 0, 4, 1, 5, 2, 6,
- 8, 9, 10, 11, 12, 13, 14, 15
- };
- m_colourInA->setCurrentIndex(ColInIndices[entry.colourInA]);
- m_colourInB->setCurrentIndex(ColInIndices[entry.colourInB]);
- m_colourInC->setCurrentIndex(ColInIndices[entry.colourInC]);
- m_colourInD->setCurrentIndex(ColInIndices[entry.colourInD]);
-
- // colour op
- static const int OpIndices[] = {
- 0, 1, -1, -1, -1, -1, -1, -1,
- 2, 3, 4, 5, 6, 7, 8, 9
- };
- m_colourOp->setCurrentIndex(OpIndices[entry.colourOp]);
-
- m_colourBias->setCurrentIndex(entry.colourBias);
- m_colourScale->setCurrentIndex(entry.colourScale);
- m_colourClamp->setChecked(entry.colourClamp);
-
- static const int RegIndices[] = {
- 3, 0, 1, 2
- };
- m_colourOutReg->setCurrentIndex(RegIndices[entry.colourOutReg]);
-
- static const int KCSelIndices[] = {
- 20, 21, 22, 23, 24, 25, 26, 27,
- -1, -1, -1, -1,
- 0, 1, 2, 3,
- 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
- };
- m_colourConst->setCurrentIndex(KCSelIndices[entry.colourConst]);
-
- // alpha in
- static const int AlphInIndices[] = {
- 3, 0, 1, 2, 4, 5, 6, 7,
- -1, -1, -1, -1, -1, -1, -1, -1
- };
- m_alphaInA->setCurrentIndex(AlphInIndices[entry.alphaInA]);
- m_alphaInB->setCurrentIndex(AlphInIndices[entry.alphaInB]);
- m_alphaInC->setCurrentIndex(AlphInIndices[entry.alphaInC]);
- m_alphaInD->setCurrentIndex(AlphInIndices[entry.alphaInD]);
-
- // alpha op
- m_alphaOp->setCurrentIndex(OpIndices[entry.alphaOp]);
-
- m_alphaBias->setCurrentIndex(entry.alphaBias);
- m_alphaScale->setCurrentIndex(entry.alphaScale);
- m_alphaClamp->setChecked(entry.alphaClamp);
-
- m_alphaOutReg->setCurrentIndex(RegIndices[entry.alphaOutReg]);
-
- static const int KASelIndices[] = {
- 16, 17, 18, 19, 20, 21, 22, 23,
- -1, -1, -1, -1, -1, -1, -1, -1,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
- };
- m_alphaConst->setCurrentIndex(KCSelIndices[entry.alphaConst]);
-
-
- // indirect crap
- static const int IndMtxIndices[] = {
- 0, 1, 2, 3, -1, 4, 5, 6, -1, 7, 8, 9, -1, -1, -1, -1
- };
-
- m_indStage->setCurrentIndex(entry.indStage);
- m_indFormat->setCurrentIndex(entry.indFormat);
- m_indBias->setCurrentIndex(entry.indBias);
- m_indMatrix->setCurrentIndex(IndMtxIndices[entry.indMatrix]);
- m_indWrapS->setCurrentIndex(entry.indWrapS);
- m_indWrapT->setCurrentIndex(entry.indWrapT);
- m_indAddPrev->setChecked(entry.indAddPrev);
- m_indUtcLod->setChecked(entry.indUtcLod);
- m_indAlphaSel->setCurrentIndex(entry.indAlphaSel);
- }
-};
-
-
-#endif // LSMATERIALEDITORS_H
diff --git a/lsmaterialmodel.cpp b/lsmaterialmodel.cpp
deleted file mode 100644
index 37f8f58..0000000
--- a/lsmaterialmodel.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "lsmaterialmodel.h"
-
-LSMaterialModel::LSMaterialModel(LYTMaterialContainer *container, QObject *parent) :
- QAbstractListModel(parent)
-{
- m_container = container;
-}
-
-
-int LSMaterialModel::rowCount(const QModelIndex &parent) const {
- return m_container->count();
-}
-
-QVariant LSMaterialModel::data(const QModelIndex &index, int role) const {
- if (index.isValid()) {
- switch (role) {
- case Qt::DisplayRole:
- return m_container->getNameOfIndex(index.row());
- }
- }
-
- return QVariant();
-}
diff --git a/lsmaterialmodel.h b/lsmaterialmodel.h
deleted file mode 100644
index 6b75fd6..0000000
--- a/lsmaterialmodel.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef LSMATERIALMODEL_H
-#define LSMATERIALMODEL_H
-
-#include <QAbstractListModel>
-#include "lyt/materials/materialcontainer.h"
-
-class LSMaterialModel : public QAbstractListModel
-{
- Q_OBJECT
-public:
- explicit LSMaterialModel(LYTMaterialContainer *container, QObject *parent = 0);
-
- int rowCount(const QModelIndex &parent) const;
- QVariant data(const QModelIndex &index, int role) const;
-
-private:
- LYTMaterialContainer *m_container;
-
-signals:
-
-public slots:
-
-};
-
-#endif // LSMATERIALMODEL_H
diff --git a/lspackagemodel.cpp b/lspackagemodel.cpp
deleted file mode 100644
index 9580e91..0000000
--- a/lspackagemodel.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-#include "lspackagemodel.h"
-
-struct ContentKind {
- LYTPackageBase::ItemType type;
- QString name;
-};
-
-static const ContentKind ContentKinds[4] = {
- {LYTPackageBase::Layout, "Layouts"},
- {LYTPackageBase::Animation, "Animations"},
- {LYTPackageBase::Texture, "Textures"},
- {LYTPackageBase::Font, "Fonts"},
-};
-const int ContentKindCount = 4;
-
-static int ContentKindForType(LYTPackageBase::ItemType type) {
- switch (type) {
- case LYTPackageBase::Layout: return 0;
- case LYTPackageBase::Animation: return 1;
- case LYTPackageBase::Texture: return 2;
- case LYTPackageBase::Font: return 3;
- }
- return -1;
-}
-
-LSPackageModel::LSPackageModel(LYTPackageBase *pkg, QObject *parent) :
- QAbstractItemModel(parent)
-{
- m_package = pkg;
-
- m_caches = new QStringList[ContentKindCount];
- for (int i = 0; i < ContentKindCount; i++) {
- m_caches[i] = pkg->list(ContentKinds[i].type);
- m_caches[i].sort();
- }
-
- connect(pkg, SIGNAL(fileWasAdded(LYTPackageBase::ItemType,QString)), SLOT(handleFileWasAdded(LYTPackageBase::ItemType,QString)));
- //connect(pkg, SIGNAL(fileWasModified(LYTPackageBase::ItemType,QString)), SLOT(handleFileWasModified(LYTPackageBase::ItemType,QString)));
- connect(pkg, SIGNAL(fileWasRemoved(LYTPackageBase::ItemType,QString)), SLOT(handleFileWasRemoved(LYTPackageBase::ItemType,QString)));
- connect(pkg, SIGNAL(fileWasRenamed(LYTPackageBase::ItemType,QString,QString)), SLOT(handleFileWasRenamed(LYTPackageBase::ItemType,QString,QString)));
-}
-
-LSPackageModel::~LSPackageModel() {
- delete[] m_caches;
-}
-
-
-QModelIndex LSPackageModel::index(int row, int column, const QModelIndex &parent) const {
- if (!hasIndex(row, column, parent))
- return QModelIndex();
-
- if (!parent.isValid())
- return createIndex(row, column, 0);
-
- return createIndex(row, column, parent.row() + 1);
-}
-
-QModelIndex LSPackageModel::parent(const QModelIndex &child) const {
- if (!child.isValid())
- return QModelIndex();
-
- if (child.internalId() > 0)
- return createIndex(child.internalId() - 1, 0, 0);
- else
- return QModelIndex();
-}
-
-int LSPackageModel::rowCount(const QModelIndex &parent) const {
- if (!parent.isValid())
- return ContentKindCount;
- else if (parent.internalId() > 0)
- return 0; // an actual item
- else
- return m_caches[parent.row()].count();
-}
-
-int LSPackageModel::columnCount(const QModelIndex &parent) const {
- return 1;
-}
-
-QVariant LSPackageModel::data(const QModelIndex &index, int role) const {
- if (!index.isValid())
- return QVariant();
- if (role != Qt::DisplayRole)
- return QVariant();
-
- int whatIs = index.internalId();
- if (whatIs == 0)
- return ContentKinds[index.row()].name;
- else
- return m_caches[whatIs - 1].at(index.row());
-}
-
-
-void LSPackageModel::handleFileWasAdded(LYTPackageBase::ItemType type, QString name) {
- int kind = ContentKindForType(type);
-
- QStringList newCache = m_caches[kind];
- newCache.append(name);
- newCache.sort();
-
- // where was this added?
- int idx = newCache.indexOf(name);
- beginInsertRows(createIndex(kind, 0, 0), idx, idx);
- m_caches[kind] = newCache;
- endInsertRows();
-}
-
-void LSPackageModel::handleFileWasRemoved(LYTPackageBase::ItemType type, QString name) {
- int kind = ContentKindForType(type);
-
- int idx = m_caches[kind].indexOf(name);
- beginRemoveRows(createIndex(kind, 0, 0), idx, idx);
- m_caches[kind].removeAt(idx);
- endRemoveRows();
-}
-
-void LSPackageModel::handleFileWasRenamed(LYTPackageBase::ItemType type, QString from, QString to) {
- int kind = ContentKindForType(type);
-
- QStringList newCache = m_caches[kind];
- int fromIdx = newCache.indexOf(from);
-
- // this is really a mess, but I cannot think of a better way to do it
- // first, make a new cache, but don't store it to m_caches yet...
- newCache[fromIdx] = to;
- newCache.sort();
-
- // and now, get the to Index...
- int toIdx = newCache.indexOf(to);
- // if the new index is less than the old one, then leave it that way
- // if the new index is the same as the old one, that's fine, do nothing
- // if the new index is more than the old one... add 1 to it to take into
- // account that the old one is no longer around when it was computed BUT Qt
- // expects it to be
- // did that make sense? probably not, oh well
- if (toIdx > fromIdx)
- toIdx++;
-
- QModelIndex whatChanged = createIndex(fromIdx, 0, kind + 1);
- emit dataChanged(whatChanged, whatChanged);
-
- QModelIndex parent = createIndex(kind, 0, 0);
-
- if (toIdx != fromIdx)
- beginMoveRows(parent, fromIdx, fromIdx, parent, toIdx);
- m_caches[kind] = newCache;
- if (toIdx != fromIdx)
- endMoveRows();
-}
-
-
-QString LSPackageModel::itemNameForIndex(const QModelIndex &index) const {
- if (index.internalId() > 0)
- return m_caches[index.internalId() - 1].at(index.row());
- return QString();
-}
-
-LYTPackageBase::ItemType LSPackageModel::itemTypeForIndex(const QModelIndex &index) const {
- if (index.internalId() > 0)
- return ContentKinds[index.internalId() - 1].type;
- return (LYTPackageBase::ItemType)-1;
-}
diff --git a/lspackagemodel.h b/lspackagemodel.h
deleted file mode 100644
index 58ad62d..0000000
--- a/lspackagemodel.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef LSPACKAGEMODEL_H
-#define LSPACKAGEMODEL_H
-
-#include <QAbstractItemModel>
-#include "lyt/packagebase.h"
-
-class LSPackageModel : public QAbstractItemModel {
- Q_OBJECT
-public:
- explicit LSPackageModel(LYTPackageBase *pkg, QObject *parent = 0);
- ~LSPackageModel();
-
- LYTPackageBase *package() const { return m_package; }
-
- QModelIndex index(int row, int column, const QModelIndex &parent) const;
- QModelIndex parent(const QModelIndex &child) const;
- int rowCount(const QModelIndex &parent) const;
- int columnCount(const QModelIndex &parent) const;
- QVariant data(const QModelIndex &index, int role) const;
-
- QString itemNameForIndex(const QModelIndex &index) const;
- LYTPackageBase::ItemType itemTypeForIndex(const QModelIndex &index) const;
-
-signals:
-
-private slots:
- //void handleAboutToAddFile(LYTPackageBase::ItemType type, QString name);
- //void handleAboutToRemoveFile(LYTPackageBase::ItemType type, QString name);
- //void handleAboutToRenameFile(LYTPackageBase::ItemType type, QString from, QString to);
- //void handleAboutToModifyFile(LYTPackageBase::ItemType type, QString name);
-
- void handleFileWasAdded(LYTPackageBase::ItemType type, QString name);
- void handleFileWasRemoved(LYTPackageBase::ItemType type, QString name);
- void handleFileWasRenamed(LYTPackageBase::ItemType type, QString from, QString to);
- //void handleFileWasModified(LYTPackageBase::ItemType type, QString name);
-
-public slots:
-
-protected:
- LYTPackageBase *m_package;
-
- QStringList *m_caches;
-};
-
-#endif // LSPACKAGEMODEL_H
diff --git a/lspaneeditor.cpp b/lspaneeditor.cpp
deleted file mode 100644
index b58f683..0000000
--- a/lspaneeditor.cpp
+++ /dev/null
@@ -1,420 +0,0 @@
-#include "lspaneeditor.h"
-#include "lstexcoordseteditor.h"
-#include <QGroupBox>
-#include <QColorDialog>
-
-#include "lyt/bounding.h"
-#include "lyt/picture.h"
-#include "lyt/textbox.h"
-#include "lyt/window.h"
-
-LSPaneEditor::LSPaneEditor(QWidget *parent) :
- QWidget(parent) {
-
- m_headingLabel = new QLabel(this);
-
- m_addChildButton = new QToolButton(this);
- m_addChildButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
- m_addChildButton->setPopupMode(QToolButton::InstantPopup);
- m_addChildButton->setText("Add Child Pane");
-
- m_addChildMenu = new QMenu(m_addChildButton);
- m_addChildMenu->addSeparator();
- m_addChildButton->setMenu(m_addChildMenu);
-
- m_removeButton = new QToolButton(this);
- m_removeButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
- m_removeButton->setText("Remove This Pane");
-
- m_tabs = new QTabWidget(this);
-
- QGridLayout *layout = new QGridLayout(this);
-
- layout->addWidget(m_headingLabel, 0, 0, 1, 1);
- layout->setColumnStretch(0, 1);
- layout->addWidget(m_addChildButton, 0, 1, 1, 1);
- layout->addWidget(m_removeButton, 0, 2, 1, 1);
-
- layout->addWidget(m_tabs, 1, 0, 1, 3);
-
-
- createPaneTab();
- createPictureTab();
-
- m_currentlyLoadingPane = false;
- m_pane = 0;
-}
-
-void LSPaneEditor::createPaneTab() {
- m_paneTab = new QWidget(this);
- m_tabs->addTab(m_paneTab, "Pane");
-
-
- QGridLayout *gLayout;
-
- // Properties Box
- QGroupBox *propBox = new QGroupBox("Basic Properties", m_paneTab);
- gLayout = new QGridLayout(propBox);
-
- m_nameEntry = new QLineEdit(propBox);
- m_nameEntry->setMaxLength(16);
- connect(m_nameEntry, SIGNAL(textChanged(QString)), SLOT(handleNameChanged(QString)));
-
- m_userDataEntry = new QLineEdit(propBox);
- m_userDataEntry->setMaxLength(8);
- connect(m_userDataEntry, SIGNAL(textChanged(QString)), SLOT(handleUserDataChanged(QString)));
-
- m_alpha = new QSpinBox(propBox);
- m_alpha->setRange(0, 255);
- connect(m_alpha, SIGNAL(valueChanged(int)), SLOT(handleAlphaChanged(int)));
-
- m_influencedAlpha = new QCheckBox("Influenced Alpha", propBox);
- connect(m_influencedAlpha, SIGNAL(toggled(bool)), SLOT(handleInfluencedAlphaChanged(bool)));
-
- // Column 0
- gLayout->addWidget(new QLabel("Name:", propBox), 0, 0, 1, 1);
- gLayout->addWidget(m_nameEntry, 0, 1, 1, 1);
- gLayout->addWidget(new QLabel("User Data:", propBox), 1, 0, 1, 1);
- gLayout->addWidget(m_userDataEntry, 1, 1, 1, 1);
-
- // Colunm 1
- gLayout->addWidget(new QLabel("Alpha:", propBox), 0, 2, 1, 1);
- gLayout->addWidget(m_alpha, 0, 3, 1, 1);
- gLayout->addWidget(m_influencedAlpha, 1, 3, 1, 1);
-
-
- // Geometry Box
- QGroupBox *geoBox = new QGroupBox("Geometry", m_paneTab);
- gLayout = new QGridLayout(geoBox);
-
- m_width = new QDoubleSpinBox(geoBox);
- m_width->setRange(-100000.0, 100000.0);
- connect(m_width, SIGNAL(valueChanged(double)), SLOT(handleWidthChanged(double)));
- m_height = new QDoubleSpinBox(geoBox);
- m_height->setRange(-100000.0, 100000.0);
- connect(m_height, SIGNAL(valueChanged(double)), SLOT(handleHeightChanged(double)));
-
- m_horzOrigin = new QComboBox(geoBox);
- m_horzOrigin->addItem("Left");
- m_horzOrigin->addItem("Center");
- m_horzOrigin->addItem("Right");
- connect(m_horzOrigin, SIGNAL(currentIndexChanged(int)), SLOT(handleHorzOriginChanged(int)));
-
- m_vertOrigin = new QComboBox(geoBox);
- m_vertOrigin->addItem("Top");
- m_vertOrigin->addItem("Center");
- m_vertOrigin->addItem("Bottom");
- connect(m_vertOrigin, SIGNAL(currentIndexChanged(int)), SLOT(handleVertOriginChanged(int)));
-
- m_widescreen = new QCheckBox("Widescreen", this);
- connect(m_widescreen, SIGNAL(toggled(bool)), SLOT(handleWidescreenChanged(bool)));
- //m_visible = new QCheckBox("Visible", this);
- //connect(m_visible, SIGNAL(toggled(bool)), SLOT(handleVisibleChanged(bool)));
-
- // Column 0
- gLayout->addWidget(new QLabel("Width:", geoBox), 0, 0, 1, 1);
- gLayout->addWidget(m_width, 0, 1, 1, 1);
- gLayout->addWidget(new QLabel("Height:", geoBox), 1, 0, 1, 1);
- gLayout->addWidget(m_height, 1, 1, 1, 1);
-
- // Column 1
- gLayout->addWidget(new QLabel("Horizontal Origin:", geoBox), 0, 2, 1, 1);
- gLayout->addWidget(m_horzOrigin, 0, 3, 1, 1);
- gLayout->addWidget(new QLabel("Vertical Origin:", geoBox), 1, 2, 1, 1);
- gLayout->addWidget(m_vertOrigin, 1, 3, 1, 1);
-
- // Row 2
- gLayout->addWidget(m_widescreen, 2, 0, 1, 2);
- //gLayout->addWidget(m_visible, 2, 2, 1, 2);
-
-
- // Positioning Box
- QGroupBox *posBox = new QGroupBox("Positioning", m_paneTab);
- gLayout = new QGridLayout(posBox);
-
- for (int i = 0; i < 8; i++) {
- m_transSpinBoxes[i] = new QDoubleSpinBox(posBox);
- m_transSpinBoxes[i]->setDecimals(3);
- m_transSpinBoxes[i]->setRange(-100000.0, 100000.0);
- }
-
- for (int i = 0; i < 3; i++) {
- m_rotSpinBoxes[i]->setSingleStep(10.0);
- }
-
- connect(m_transX, SIGNAL(valueChanged(double)), SLOT(handleTransXChanged(double)));
- connect(m_transY, SIGNAL(valueChanged(double)), SLOT(handleTransYChanged(double)));
- connect(m_transZ, SIGNAL(valueChanged(double)), SLOT(handleTransZChanged(double)));
- connect(m_rotX, SIGNAL(valueChanged(double)), SLOT(handleRotXChanged(double)));
- connect(m_rotY, SIGNAL(valueChanged(double)), SLOT(handleRotYChanged(double)));
- connect(m_rotZ, SIGNAL(valueChanged(double)), SLOT(handleRotZChanged(double)));
- connect(m_scaleX, SIGNAL(valueChanged(double)), SLOT(handleScaleXChanged(double)));
- connect(m_scaleY, SIGNAL(valueChanged(double)), SLOT(handleScaleYChanged(double)));
-
- gLayout->addWidget(new QLabel("Translation:", posBox), 0, 0, 1, 1);
- gLayout->addWidget(m_transX, 0, 1, 1, 1);
- gLayout->addWidget(m_transY, 0, 2, 1, 1);
- gLayout->addWidget(m_transZ, 0, 3, 1, 1);
- gLayout->addWidget(new QLabel("Rotation:", posBox), 1, 0, 1, 1);
- gLayout->addWidget(m_rotX, 1, 1, 1, 1);
- gLayout->addWidget(m_rotY, 1, 2, 1, 1);
- gLayout->addWidget(m_rotZ, 1, 3, 1, 1);
- gLayout->addWidget(new QLabel("Scale:", posBox), 2, 0, 1, 1);
- gLayout->addWidget(m_scaleX, 2, 1, 1, 1);
- gLayout->addWidget(m_scaleY, 2, 2, 1, 1);
-
-
- // put it all together into one
-
- QVBoxLayout *layout = new QVBoxLayout(m_paneTab);
- layout->addWidget(propBox);
- layout->addWidget(geoBox);
- layout->addWidget(posBox);
- layout->addStretch(1);
-}
-
-
-void LSPaneEditor::createPictureTab() {
- m_pictureTab = new QWidget(this);
- m_tabs->addTab(m_pictureTab, "Picture");
-
-
- QGroupBox *tcBox = new QGroupBox("Texture Coordinates", m_pictureTab);
- QVBoxLayout *tcLayout = new QVBoxLayout(tcBox);
-
- m_picTexCoordEditor = new LSTexCoordSetEditor(tcBox);
- tcLayout->addWidget(m_picTexCoordEditor);
-
- connect(m_picTexCoordEditor, SIGNAL(coordsEdited()), SIGNAL(mustRedrawLayout()));
-
-
- QGroupBox *vcBox = new QGroupBox("Vertex Colours", m_pictureTab);
- QGridLayout *vcLayout = new QGridLayout(vcBox);
-
- for (int i = 0; i < 4; i++) {
- m_picColourButtons[i] = new LSColorPicker(this);
- connect(m_picColourButtons[i], SIGNAL(colorPicked(QColor,QColor)), SLOT(handlePicColourPicked(QColor)));
- }
-
- vcLayout->addWidget(m_picColourButtons[0], 0, 0, 1, 1);
- vcLayout->addWidget(m_picColourButtons[1], 0, 2, 1, 1);
- vcLayout->addWidget(m_picColourButtons[2], 2, 0, 1, 1);
- vcLayout->addWidget(m_picColourButtons[3], 2, 2, 1, 1);
-
- // TODO: material
-
- // put it all together into one
-
- QVBoxLayout *layout = new QVBoxLayout(m_pictureTab);
- layout->addWidget(tcBox);
- layout->addWidget(vcBox);
- layout->addStretch(1);
-}
-
-
-void LSPaneEditor::setPane(LYTPane *pane) {
- m_currentlyLoadingPane = true;
- m_pane = pane;
-
- // General pane tab
-
- m_nameEntry->setText(pane->name);
- m_userDataEntry->setText(pane->userdata);
-
- m_alpha->setValue(pane->alpha);
- m_influencedAlpha->setChecked(pane->influencedAlpha);
-
-
- m_width->setValue(pane->width);
- m_height->setValue(pane->height);
-
- m_horzOrigin->setCurrentIndex((int)pane->horzOrigin);
- m_vertOrigin->setCurrentIndex((int)pane->vertOrigin);
-
- m_widescreen->setChecked(pane->isWidescreen);
- //m_visible->setChecked(pane->visible);
-
-
- m_transX->setValue(pane->xTrans);
- m_transY->setValue(pane->yTrans);
- m_transZ->setValue(pane->zTrans);
-
- m_rotX->setValue(pane->xRot);
- m_rotY->setValue(pane->yRot);
- m_rotZ->setValue(pane->zRot);
-
- m_scaleX->setValue(pane->xScale);
- m_scaleY->setValue(pane->yScale);
-
-
- // Type-specific tabs
-
- LYTPane::PaneTypes type = pane->type();
- m_tabs->setTabEnabled(m_tabs->indexOf(m_pictureTab), type == LYTPane::PictureType);
-
- switch (type) {
- case LYTPane::PictureType:
- LYTPicture *pic = (LYTPicture*)pane;
-
- m_picTexCoordEditor->setCoordPtr(&pic->texCoords);
-
- for (int i = 0; i < 4; i++) {
- LSColorPicker *button = m_picColourButtons[i];
- button->setColor(pic->vtxColours[i]);
- }
-
- break;
- }
-
-
- m_currentlyLoadingPane = false;
-}
-
-
-void LSPaneEditor::handleNameChanged(QString value) {
- if (!m_currentlyLoadingPane) {
- m_pane->name = value;
- emit mustRedrawLayout();
- }
-}
-
-void LSPaneEditor::handleUserDataChanged(QString value) {
- if (!m_currentlyLoadingPane) {
- m_pane->userdata = value;
- emit mustRedrawLayout();
- }
-}
-
-void LSPaneEditor::handleAlphaChanged(int value) {
- if (!m_currentlyLoadingPane) {
- m_pane->alpha = (quint8)value;
- emit mustRedrawLayout();
- }
-}
-
-void LSPaneEditor::handleInfluencedAlphaChanged(bool value) {
- if (!m_currentlyLoadingPane) {
- m_pane->influencedAlpha = value;
- emit mustRedrawLayout();
- }
-}
-
-void LSPaneEditor::handleWidthChanged(double value) {
- if (!m_currentlyLoadingPane) {
- m_pane->width = value;
- emit mustRedrawLayout();
- }
-}
-
-void LSPaneEditor::handleHeightChanged(double value) {
- if (!m_currentlyLoadingPane) {
- m_pane->height = value;
- emit mustRedrawLayout();
- }
-}
-
-void LSPaneEditor::handleHorzOriginChanged(int value) {
- if (!m_currentlyLoadingPane) {
- m_pane->horzOrigin = (LYTPane::OriginType)value;
- emit mustRedrawLayout();
- }
-}
-
-void LSPaneEditor::handleVertOriginChanged(int value) {
- if (!m_currentlyLoadingPane) {
- m_pane->vertOrigin = (LYTPane::OriginType)value;
- emit mustRedrawLayout();
- }
-}
-
-void LSPaneEditor::handleWidescreenChanged(bool value) {
- if (!m_currentlyLoadingPane) {
- m_pane->isWidescreen = value;
- emit mustRedrawLayout();
- }
-}
-
-/*void LSPaneEditor::handleVisibleChanged(bool value) {
- if (!m_currentlyLoadingPane) {
- m_pane->visible = value;
- emit mustRedrawLayout();
- }
-}*/
-
-void LSPaneEditor::handleTransXChanged(double value) {
- if (!m_currentlyLoadingPane) {
- m_pane->xTrans = value;
- emit mustRedrawLayout();
- }
-}
-
-void LSPaneEditor::handleTransYChanged(double value) {
- if (!m_currentlyLoadingPane) {
- m_pane->yTrans = value;
- emit mustRedrawLayout();
- }
-}
-
-void LSPaneEditor::handleTransZChanged(double value) {
- if (!m_currentlyLoadingPane) {
- m_pane->zTrans = value;
- emit mustRedrawLayout();
- }
-}
-
-void LSPaneEditor::handleRotXChanged(double value) {
- if (!m_currentlyLoadingPane) {
- m_pane->xRot = value;
- emit mustRedrawLayout();
- }
-}
-
-void LSPaneEditor::handleRotYChanged(double value) {
- if (!m_currentlyLoadingPane) {
- m_pane->yRot = value;
- emit mustRedrawLayout();
- }
-}
-
-void LSPaneEditor::handleRotZChanged(double value) {
- if (!m_currentlyLoadingPane) {
- m_pane->zRot = value;
- emit mustRedrawLayout();
- }
-}
-
-void LSPaneEditor::handleScaleXChanged(double value) {
- if (!m_currentlyLoadingPane) {
- m_pane->xScale = value;
- emit mustRedrawLayout();
- }
-}
-
-void LSPaneEditor::handleScaleYChanged(double value) {
- if (!m_currentlyLoadingPane) {
- m_pane->yScale = value;
- emit mustRedrawLayout();
- }
-}
-
-void LSPaneEditor::handlePicColourPicked(QColor value) {
- // make sure ...
- if (m_pane->type() != LYTPane::PictureType)
- return;
-
- LSColorPicker *button = (LSColorPicker*)sender();
- int index = -1;
- for (int i = 0; i < 4; i++)
- if (m_picColourButtons[i] == button) {
- index = i;
- break;
- }
-
- if (index == -1)
- return;
-
- m_picture->vtxColours[index] = value;
-
- emit mustRedrawLayout();
-}
-
diff --git a/lspaneeditor.h b/lspaneeditor.h
deleted file mode 100644
index a1faa2c..0000000
--- a/lspaneeditor.h
+++ /dev/null
@@ -1,106 +0,0 @@
-#ifndef LSPANEEDITOR_H
-#define LSPANEEDITOR_H
-
-#include <QWidget>
-#include <QGridLayout>
-#include <QTabWidget>
-#include <QMenu>
-#include <QToolButton>
-#include <QLabel>
-#include <QLineEdit>
-#include <QDoubleSpinBox>
-#include <QComboBox>
-#include <QCheckBox>
-#include "lyt/pane.h"
-#include "lscolorpicker.h"
-class LSTexCoordSetEditor;
-
-class LYTPicture;
-
-class LSPaneEditor : public QWidget {
- Q_OBJECT
-public:
- explicit LSPaneEditor(QWidget *parent = 0);
-
-private:
- QLabel *m_headingLabel;
- QTabWidget *m_tabs;
-
- QToolButton *m_addChildButton;
- QMenu *m_addChildMenu;
- QToolButton *m_removeButton;
-
-
- // Main pane tab
- QWidget *m_paneTab;
-
- QLineEdit *m_nameEntry, *m_userDataEntry;
- QSpinBox *m_alpha;
- QCheckBox *m_influencedAlpha;
-
- QDoubleSpinBox *m_width, *m_height;
- QComboBox *m_horzOrigin, *m_vertOrigin;
- QCheckBox *m_widescreen; //, *m_visible;
-
- union {
- QDoubleSpinBox *m_srtSpinBoxes[8];
- struct {
- QDoubleSpinBox *m_transSpinBoxes[3];
- QDoubleSpinBox *m_rotSpinBoxes[3];
- QDoubleSpinBox *m_scaleSpinBoxes[2];
- };
- struct {
- QDoubleSpinBox *m_transX, *m_transY, *m_transZ;
- QDoubleSpinBox *m_rotX, *m_rotY, *m_rotZ;
- QDoubleSpinBox *m_scaleX, *m_scaleY;
- };
- };
-
- // Picture tab
- QWidget *m_pictureTab;
-
- LSTexCoordSetEditor *m_picTexCoordEditor;
- LSColorPicker *m_picColourButtons[4];
-
-
- void createPaneTab();
- void createPictureTab();
-
-
- bool m_currentlyLoadingPane;
- union {
- LYTPane *m_pane;
- LYTPicture *m_picture;
- };
-
-private slots:
- void handleNameChanged(QString value);
- void handleUserDataChanged(QString value);
- void handleAlphaChanged(int value);
- void handleInfluencedAlphaChanged(bool value);
- void handleWidthChanged(double value);
- void handleHeightChanged(double value);
- void handleHorzOriginChanged(int value);
- void handleVertOriginChanged(int value);
- void handleWidescreenChanged(bool value);
- //void handleVisibleChanged(bool value);
- void handleTransXChanged(double value);
- void handleTransYChanged(double value);
- void handleTransZChanged(double value);
- void handleRotXChanged(double value);
- void handleRotYChanged(double value);
- void handleRotZChanged(double value);
- void handleScaleXChanged(double value);
- void handleScaleYChanged(double value);
-
- void handlePicColourPicked(QColor value);
-
-signals:
- void mustRedrawLayout();
-
-public slots:
- void setPane(LYTPane *pane);
-
-};
-
-#endif // LSPANEEDITOR_H
diff --git a/lsrlytexporter.cpp b/lsrlytexporter.cpp
new file mode 100644
index 0000000..42fb587
--- /dev/null
+++ b/lsrlytexporter.cpp
@@ -0,0 +1,1176 @@
+#include "lsrlytexporter.h"
+#include "lyt/layout.h"
+#include "wii/texpalette.h"
+#include <QXmlStreamWriter>
+#include <QDir>
+#include <QFile>
+#include <QSet>
+#include <QMapIterator>
+
+static void collectPanesForList(QList<LYTPane *> *list, LYTPane *pane) {
+ list->append(pane);
+
+ foreach (LYTPane *p, pane->children)
+ collectPanesForList(list, p);
+}
+
+static void outputPaneTree(QXmlStreamWriter *w, LYTPane *pane) {
+ w->writeStartElement("paneTree");
+ w->writeAttribute("name", pane->name);
+
+ foreach (LYTPane *p, pane->children)
+ outputPaneTree(w, p);
+
+ w->writeEndElement();
+}
+
+static void writeTexCoordSet(QXmlStreamWriter &w, const LYTTexCoords &set) {
+ w.writeStartElement("texCoord");
+
+ static const char *vnames[] = {
+ "texLT", "texRT", "texLB", "texRB"
+ };
+ for (int i = 0; i < 4; i++) {
+ w.writeEmptyElement(vnames[i]);
+ w.writeAttribute("s", QString::number(set.coord[i].x()));
+ w.writeAttribute("t", QString::number(set.coord[i].y()));
+ }
+
+ w.writeEndElement(); // texCoord
+}
+
+static void writeAttribColour(QXmlStreamWriter &w, const QColor &c, bool hasAlpha=true) {
+ w.writeAttribute("r", QString::number(c.red()));
+ w.writeAttribute("g", QString::number(c.green()));
+ w.writeAttribute("b", QString::number(c.blue()));
+ if (hasAlpha)
+ w.writeAttribute("a", QString::number(c.alpha()));
+}
+
+static void writeAttribColourNoAlpha(QXmlStreamWriter &w, const QColor &c) {
+ writeAttribColour(w, c, false);
+}
+
+static bool isMaterialDetailed(const LYTMaterial &mat) {
+ int chk = 0;
+ if (mat.hasAlphaCompare) chk += 1;
+ if (mat.hasBlendMode) chk += 1;
+ if (mat.hasChanCtrl) chk += 1;
+ if (mat.hasMatCol) chk += 1;
+ if (mat.hasTevSwapTable) chk += 1;
+ if (chk == 0) return false;
+ if (chk == 5) return true;
+ qWarning("HUH????");
+ return false;
+}
+
+static void writeMaterial(QXmlStreamWriter &w, const LYTMaterial &mat, QSet<QString> &usedNames) {
+ bool isDetail = mat.hasChanCtrl;
+
+ QString matname = mat.name;
+ while (usedNames.contains(matname)) {
+ matname[0] = QChar(matname.at(0).unicode() + 1);
+ if (matname[0] == ('Z'+1))
+ matname[0] = 'a';
+ if (matname[0] == ('z'+1))
+ matname[0] = 'A';
+ }
+ usedNames.insert(matname);
+
+ w.writeStartElement("material");
+ w.writeAttribute("name", matname);
+ {
+ w.writeEmptyElement("blackColor");
+ writeAttribColourNoAlpha(w, mat.colours[0]);
+ w.writeEmptyElement("whiteColor");
+ writeAttribColourNoAlpha(w, mat.colours[1]);
+
+ static const char *Filters[] = {"Near", "Linear"};
+ static const char *Wraps[] = {"Clamp", "Repeat", "Mirror"};
+
+ foreach (const LYTTexMap &tm, mat.texMaps) {
+ w.writeEmptyElement("texMap");
+
+ QString niceName = tm.textureName;
+ niceName.replace(".tpl", "");
+ w.writeAttribute("imageName", niceName);
+ w.writeAttribute("wrap_s", Wraps[tm.wrap_s]);
+ w.writeAttribute("wrap_t", Wraps[tm.wrap_t]);
+ w.writeAttribute("filterMin", Filters[tm.min_filter]);
+ w.writeAttribute("filterMax", Filters[tm.mag_filter]);
+ // Left out on purpose: paletteName
+ }
+
+ foreach (const LYTTexSRT &srt, mat.texSRTs) {
+ w.writeStartElement("texMatrix");
+ w.writeAttribute("rotate", QString::number(srt.rotate));
+
+ w.writeEmptyElement("scale");
+ w.writeAttribute("x", QString::number(srt.xScale));
+ w.writeAttribute("y", QString::number(srt.yScale));
+
+ w.writeEmptyElement("translate");
+ w.writeAttribute("x", QString::number(srt.xTrans));
+ w.writeAttribute("y", QString::number(srt.yTrans));
+
+ w.writeEndElement(); // texMatrix
+ }
+
+ foreach (const LYTTexCoordGen &cg, mat.texCoordGens) {
+ w.writeEmptyElement("texCoordGen");
+ w.writeAttribute("func", (cg.genType == 1 ? "Mtx2x4" : "ERROR"));
+ w.writeAttribute("srcParam", (cg.src>=4 && cg.src<=11)?QString("Tex%1").arg(cg.src-4):"ERROR");
+ int fixMtx = (cg.mtx == 60) ? -1 : ((cg.mtx / 3) - 10);
+ w.writeAttribute("matrix", QString::number(fixMtx));
+ }
+
+ // this is most likely INCORRECT.
+ w.writeEmptyElement("textureStage");
+ w.writeAttribute("texMap", "0");
+ w.writeAttribute("texCoordGen", "0");
+
+ w.writeEmptyElement("texBlendRatio");
+ w.writeAttribute("color", "255");
+
+ // TODO: textureStage, texBlendRatio, indirectStages(MaterialWarp),..?
+ }
+ w.writeEndElement(); // material
+
+ w.writeStartElement("materialRevo");
+ w.writeAttribute("name", matname);
+ if (isDetail) {
+ w.writeAttribute("tevStageNum", QString::number(mat.tevStages.count()));
+ w.writeAttribute("indirectStageNum", QString::number(mat.indTexStages.count()));
+ }
+ {
+ qDebug("Chk: %c%c%c%c%c %d,%d,%d,%d,%d,%d",
+ mat.hasAlphaCompare?'x':'_',
+ mat.hasBlendMode?'x':'_',
+ mat.hasChanCtrl?'x':'_',
+ mat.hasMatCol?'x':'_',
+ mat.hasTevSwapTable?'x':'_',
+ mat.indTexSRTs.count(),
+ mat.indTexStages.count(),
+ mat.tevStages.count(),
+ mat.texCoordGens.count(),
+ mat.texMaps.count(),
+ mat.texSRTs.count());
+
+ w.writeEmptyElement("channelControl");
+ w.writeAttribute("channel", "Color0");
+ w.writeAttribute("materialSource", mat.hasChanCtrl?(mat.chanCtrl.colourMatSrc==0?"Register":"Vertex"):"Vertex");
+
+ w.writeEmptyElement("channelControl");
+ w.writeAttribute("channel", "Alpha0");
+ w.writeAttribute("materialSource", mat.hasChanCtrl?(mat.chanCtrl.colourMatSrc==0?"Register":"Vertex"):"Vertex");
+
+ w.writeEmptyElement("matColReg");
+ writeAttribColour(w, mat.hasMatCol ? mat.matCol : QColor::fromRgb(255,255,255,255));
+
+ for (int i = 0; i < 3; i++) {
+ w.writeEmptyElement("tevColReg");
+ writeAttribColour(w, mat.colours[i]);
+ }
+
+ for (int i = 0; i < 4; i++) {
+ w.writeEmptyElement("tevConstReg");
+ writeAttribColour(w, mat.tevKColour[i]);
+ }
+
+ // blehhhhhhhhhhhh DRY!!!
+ static const char *Filters[] = {"Near", "Linear"};
+ static const char *Wraps[] = {"Clamp", "Repeat", "Mirror"};
+
+ foreach (const LYTTexMap &tm, mat.texMaps) {
+ w.writeEmptyElement("texMap");
+
+ QString niceName = tm.textureName;
+ niceName.replace(".tpl", "");
+ w.writeAttribute("imageName", niceName);
+ w.writeAttribute("wrap_s", Wraps[tm.wrap_s]);
+ w.writeAttribute("wrap_t", Wraps[tm.wrap_t]);
+ w.writeAttribute("filterMin", Filters[tm.min_filter]);
+ w.writeAttribute("filterMax", Filters[tm.mag_filter]);
+ // Left out on purpose: paletteName
+ }
+
+ foreach (const LYTTexSRT &srt, mat.texSRTs) {
+ w.writeStartElement("texMatrix");
+ w.writeAttribute("rotate", QString::number(srt.rotate));
+
+ w.writeEmptyElement("scale");
+ w.writeAttribute("x", QString::number(srt.xScale));
+ w.writeAttribute("y", QString::number(srt.yScale));
+
+ w.writeEmptyElement("translate");
+ w.writeAttribute("x", QString::number(srt.xTrans));
+ w.writeAttribute("y", QString::number(srt.yTrans));
+
+ w.writeEndElement(); // texMatrix
+ }
+
+ foreach (const LYTTexCoordGen &cg, mat.texCoordGens) {
+ w.writeEmptyElement("texCoordGen");
+ w.writeAttribute("func", (cg.genType == 1 ? "Mtx2x4" : "ERROR"));
+ w.writeAttribute("srcParam", (cg.src>=4 && cg.src<=11)?QString("Tex%1").arg(cg.src-4):"ERROR");
+ int fixMtx = (cg.mtx == 60) ? -1 : ((cg.mtx / 3) - 10);
+ w.writeAttribute("matrix", QString::number(fixMtx));
+ }
+ // end horrible lack of DRY
+
+ if (mat.hasTevSwapTable) {
+ static const char *Swaps[] = {"Red","Green","Blue","Alpha"};
+ for (int i = 0; i < 4; i++) {
+ w.writeEmptyElement("swapTable");
+ w.writeAttribute("r", Swaps[mat.tevSwapTable.mode[i].red]);
+ w.writeAttribute("g", Swaps[mat.tevSwapTable.mode[i].green]);
+ w.writeAttribute("b", Swaps[mat.tevSwapTable.mode[i].blue]);
+ w.writeAttribute("a", Swaps[mat.tevSwapTable.mode[i].alpha]);
+ }
+ } else {
+ for (int i = 0; i < 4; i++) {
+ w.writeEmptyElement("swapTable");
+ w.writeAttribute("r", "Red");
+ w.writeAttribute("g", "Green");
+ w.writeAttribute("b", "Blue");
+ w.writeAttribute("a", "Alpha");
+ }
+ }
+
+ foreach (const LYTTexSRT &srt, mat.indTexSRTs) {
+ w.writeStartElement("indirectMatrix");
+ w.writeAttribute("rotate", QString::number(srt.rotate));
+
+ w.writeEmptyElement("scale");
+ w.writeAttribute("x", QString::number(srt.xScale));
+ w.writeAttribute("y", QString::number(srt.yScale));
+
+ w.writeEmptyElement("translate");
+ w.writeAttribute("x", QString::number(srt.xTrans));
+ w.writeAttribute("y", QString::number(srt.yTrans));
+
+ w.writeEndElement(); // texMatrix
+ }
+
+ static const char *IndScale[] = {
+ "V1","V2","V4","V8","V16","V32","V64","V128","V256"
+ };
+ foreach (const LYTIndirectStage &ist, mat.indTexStages) {
+ w.writeEmptyElement("indirectStage");
+ w.writeAttribute("texMap", QString::number(ist.texMap));
+ w.writeAttribute("texCoord", QString::number(ist.texCoord));
+ w.writeAttribute("scale_s", IndScale[ist.wrap_s]);
+ w.writeAttribute("scale_t", IndScale[ist.wrap_t]);
+ }
+
+ // for no indirects? no idea
+ if (mat.indTexSRTs.count() == 0) {
+ for (int i = 0; i < 3; i++) {
+ w.writeStartElement("indirectMatrix");
+ w.writeAttribute("rotate", "0");
+
+ w.writeEmptyElement("scale");
+ w.writeAttribute("x", "1");
+ w.writeAttribute("y", "1");
+
+ w.writeEmptyElement("translate");
+ w.writeAttribute("x", "0");
+ w.writeAttribute("y", "0");
+
+ w.writeEndElement(); // indirectMatrix
+ }
+ }
+
+ if (mat.indTexStages.count() == 0) {
+ for (int i = 0; i < 4; i++) {
+ w.writeEmptyElement("indirectStage");
+ w.writeAttribute("texMap", "0");
+ w.writeAttribute("texCoordGen", "0");
+ w.writeAttribute("scale_s", "V1");
+ w.writeAttribute("scale_t", "V1");
+ }
+ }
+
+ // the rest
+
+ static const char *TevCChan[] = {
+ "xERR","xERR","xERR","xERR","Color0a0","xERR",
+ "ColorZero","xERR","xERR"
+ };
+ static const char *CArg[] = {
+ "CPrev","APrev","C0","A0","C1","A1","C2","A2",
+ "TexC","TexA","RasC","RasA","V1_0","V0_5","Konst","V0"
+ };
+ static const char *AArg[] = {
+ "APrev","A0","A1","A2","TexA","RasA","Konst","V0"
+ };
+ static const char *KCSel[] = {
+ "V8_8","V7_8","V6_8","V5_8","V4_8","V3_8","V2_8","V1_8",
+ "xERR","xERR","xERR","xERR",
+ "K0","K1","K2","K3",
+ "K0_r","K1_r","K2_r","K3_r",
+ "K0_g","K1_g","K2_g","K3_g",
+ "K0_b","K1_b","K2_b","K3_b",
+ "K0_a","K1_a","K2_a","K3_a"
+ };
+ static const char *KASel[] = {
+ "V8_8","V7_8","V6_8","V5_8","V4_8","V3_8","V2_8","V1_8",
+ "xERR","xERR","xERR","xERR","xERR","xERR","xERR","xERR",
+ "K0_r","K1_r","K2_r","K3_r",
+ "K0_g","K1_g","K2_g","K3_g",
+ "K0_b","K1_b","K2_b","K3_b",
+ "K0_a","K1_a","K2_a","K3_a"
+ };
+ static const char *ColOp[] = {
+ "Add","Sub","x","x","x","x","x","x",
+ "Comp_r8_gt","Comp_r8_eq",
+ "Comp_gr16_gt","Comp_gr16_eq",
+ "Comp_bgr24_gt","Comp_bgr24_eq",
+ "Comp_rgb8_gt","Comp_rgb8_eq"
+ };
+ static const char *AlOp[] = {
+ "Add","Sub","x","x","x","x","x","x",
+ "Comp_r8_gt","Comp_r8_eq",
+ "Comp_gr16_gt","Comp_gr16_eq",
+ "Comp_bgr24_gt","Comp_bgr24_eq",
+ "Comp_a8_gt","Comp_a8_eq"
+ };
+ static const char *Bias[] = {"V0", "P0_5", "M0_5"};
+ static const char *Scale[] = {"V1", "V2", "V4", "V1_2"};
+ static const char *Reg[] = {"Prev", "Reg0", "Reg1", "Reg2"};
+ foreach (const LYTTevStage &st, mat.tevStages) {
+ w.writeStartElement("tevStage");
+ w.writeAttribute("colorChannel", (st.colour==-1)?"ColorNull":TevCChan[st.colour]);
+ w.writeAttribute("texMap", QString::number(st.texMap));
+ w.writeAttribute("texCoordGen", QString::number(st.texCoord));
+ w.writeAttribute("rasColSwap", QString::number(st.rasSwapMode));
+ w.writeAttribute("texColSwap", QString::number(st.texSwapMode));
+
+ w.writeEmptyElement("color");
+ w.writeAttribute("a", CArg[st.colourInA]);
+ w.writeAttribute("b", CArg[st.colourInB]);
+ w.writeAttribute("c", CArg[st.colourInC]);
+ w.writeAttribute("d", CArg[st.colourInD]);
+ w.writeAttribute("konst", KCSel[st.colourConst]);
+ w.writeAttribute("op", ColOp[st.colourOp]);
+ w.writeAttribute("bias", Bias[st.colourBias]);
+ w.writeAttribute("scale", Scale[st.colourScale]);
+ w.writeAttribute("clamp", st.colourClamp?"true":"false");
+ w.writeAttribute("outReg", Reg[st.colourOutReg]);
+
+ w.writeEmptyElement("alpha");
+ w.writeAttribute("a", AArg[st.alphaInA]);
+ w.writeAttribute("b", AArg[st.alphaInB]);
+ w.writeAttribute("c", AArg[st.alphaInC]);
+ w.writeAttribute("d", AArg[st.alphaInD]);
+ w.writeAttribute("konst", KASel[st.alphaConst]);
+ w.writeAttribute("op", AlOp[st.alphaOp]);
+ w.writeAttribute("bias", Bias[st.alphaBias]);
+ w.writeAttribute("scale", Scale[st.alphaScale]);
+ w.writeAttribute("clamp", st.alphaClamp?"true":"false");
+ w.writeAttribute("outReg", Reg[st.alphaOutReg]);
+
+ static const char *IFormat[] = {"V8","V5","V4","V3"};
+ static const char *IBias[] = {"None","S","T","ST","U","SU","TU","STU"};
+ static const char *IMtx[] = {"Off","V0","V1","V2","x","S0","S1","S2","x","T0","T1","T2"};
+ static const char *IWrap[] = {"Off","V256","V128","V64","V32","V16","V0"};
+
+ w.writeEmptyElement("indirect");
+ w.writeAttribute("indStage", QString::number(st.indStage));
+ w.writeAttribute("format", IFormat[st.indFormat]);
+ w.writeAttribute("bias", IBias[st.indBias]);
+ w.writeAttribute("matrix", IMtx[st.indMatrix]);
+ w.writeAttribute("wrap_s", IWrap[st.indWrapS]);
+ w.writeAttribute("wrap_t", IWrap[st.indWrapT]);
+ w.writeAttribute("addPrev", st.indAddPrev?"true":"false");
+ w.writeAttribute("utcLod", st.indUtcLod?"true":"false");
+ if (st.indAlphaSel != 0)
+ qFatal("indAlphaSel not off!");
+ w.writeAttribute("alpha", "Off");
+
+ w.writeEndElement(); // tevStage
+ }
+
+ // wtf bbq
+ if (mat.tevStages.count() == 0) {
+ // todo: different for >1 texture? must check.
+ w.writeStartElement("tevStage");
+ w.writeAttribute("colorChannel", "Color0a0");
+ w.writeAttribute("texMap", "-1");
+ w.writeAttribute("texCoordGen", "-1");
+ w.writeAttribute("rasColSwap", "0");
+ w.writeAttribute("texColSwap", "0");
+
+ w.writeEmptyElement("color");
+ w.writeAttribute("a", "RasC");
+ w.writeAttribute("b", "V0");
+ w.writeAttribute("c", "V0");
+ w.writeAttribute("d", "V0");
+ w.writeAttribute("konst", "K0");
+ w.writeAttribute("op", "Add");
+ w.writeAttribute("bias", "V0");
+ w.writeAttribute("scale", "V1");
+ w.writeAttribute("clamp", "true");
+ w.writeAttribute("outReg", "Prev");
+
+ w.writeEmptyElement("alpha");
+ w.writeAttribute("a", "RasA");
+ w.writeAttribute("b", "V0");
+ w.writeAttribute("c", "V0");
+ w.writeAttribute("d", "V0");
+ w.writeAttribute("konst", "K0_a");
+ w.writeAttribute("op", "Add");
+ w.writeAttribute("bias", "V0");
+ w.writeAttribute("scale", "V1");
+ w.writeAttribute("clamp", "true");
+ w.writeAttribute("outReg", "Prev");
+
+ w.writeEmptyElement("indirect");
+ w.writeAttribute("indStage", "0");
+ w.writeAttribute("format", "V8");
+ w.writeAttribute("bias", "STU");
+ w.writeAttribute("matrix", "Off");
+ w.writeAttribute("wrap_s", "Off");
+ w.writeAttribute("wrap_t", "Off");
+ w.writeAttribute("addPrev", "false");
+ w.writeAttribute("alpha", "Off");
+ w.writeAttribute("utcLod", "false");
+
+ w.writeEndElement(); // tevStage
+ }
+
+ if (mat.hasAlphaCompare) {
+ static const char *Compare[] = {"Never","Less","Equal","LEqual","Greater","NEqual","GEqual","Always"};
+ static const char *AlphaOp[] = {"And","Or","Xor","Xnor"};
+ w.writeEmptyElement("alphaCompare");
+ w.writeAttribute("comp0", Compare[mat.alphaCompare.comp0]);
+ w.writeAttribute("ref0", QString::number(mat.alphaCompare.ref0));
+ w.writeAttribute("op", AlphaOp[mat.alphaCompare.op]);
+ w.writeAttribute("comp1", Compare[mat.alphaCompare.comp1]);
+ w.writeAttribute("ref1", QString::number(mat.alphaCompare.ref1));
+ } else {
+ w.writeEmptyElement("alphaCompare");
+ w.writeAttribute("comp0", "Always");
+ w.writeAttribute("ref0", "0");
+ w.writeAttribute("op", "And");
+ w.writeAttribute("comp1", "Always");
+ w.writeAttribute("ref1", "0");
+ }
+
+ if (mat.hasBlendMode) {
+ static const char *BmType[] = {"None","Blend","Logic","Subtract"};
+ static const char *SrcFactor[] = {"V0","V1_0","DstClr","InvDstClr","SrcAlpha","InvSrcAlpha","DstAlpha","InvDstAlpha"};
+ static const char *DstFactor[] = {"V0","V1_0","SrcClr","InvSrcClr","SrcAlpha","InvSrcAlpha","DstAlpha","InvDstAlpha"};
+ static const char *LogicOp[] = {
+ "Clear", "And", "RevAnd", "Copy",
+ "InvAnd", "NoOp", "Xor", "Or",
+ "Nor", "Equiv", "Inv", "RevOr",
+ "InvCopy", "InvOr", "Nand", "Set"
+ };
+ w.writeEmptyElement("blendMode");
+ w.writeAttribute("type", BmType[mat.blendMode.type]);
+ w.writeAttribute("srcFactor", SrcFactor[mat.blendMode.srcFactor]);
+ w.writeAttribute("dstFactor", DstFactor[mat.blendMode.destFactor]);
+ w.writeAttribute("op", LogicOp[mat.blendMode.op]);
+ } else {
+ w.writeEmptyElement("blendMode");
+ w.writeAttribute("type", "Blend");
+ w.writeAttribute("srcFactor", "SrcAlpha");
+ w.writeAttribute("dstFactor", "InvSrcAlpha");
+ w.writeAttribute("op", "Copy");
+ }
+
+ // what have I missed...? tevStageNum attrib?, displayFace attrib?,
+ // indirectStageNum attrib?
+ }
+ w.writeEndElement(); // materialRevo
+}
+
+static void exportRlyt(LYTLayout *layout, QIODevice *output, const QMap<QString, GX::TextureFormat> &texFormats) {
+ QXmlStreamWriter w(output);
+ w.setAutoFormatting(true);
+
+ w.writeStartDocument();
+
+ w.writeStartElement("nw4r_layout");
+ w.writeDefaultNamespace("http://www.nintendo.co.jp/NW4R/LayoutEditor");
+ w.writeAttribute("version", "1.2.0");
+
+ w.writeStartElement("head");
+ {
+ w.writeEmptyElement("create");
+ w.writeAttribute("user", "someone");
+ w.writeAttribute("host", "somewhere");
+ w.writeAttribute("date", "2006-07-26T10:20:54.551+09:00");
+ w.writeAttribute("source", "");
+
+ w.writeEmptyElement("title");
+
+ w.writeEmptyElement("comment");
+
+ w.writeEmptyElement("generator");
+ w.writeAttribute("name", "LayoutStudio");
+ w.writeAttribute("version", "NONE_OF_YOUR_BUSINESS");
+ }
+ w.writeEndElement(); // head
+
+ w.writeStartElement("body");
+ w.writeStartElement("rlyt");
+
+
+ // Stuff begins here
+ QSet<QString> usedNames;
+
+ static const char *PaneKinds[] = {
+ "Null", "Picture", "TextBox", "Window", "Bounding"
+ };
+ static const char *HorzOrigin[] = {"Left", "Center", "Right"};
+ static const char *VertOrigin[] = {"Top", "Center", "Bottom"};
+
+ w.writeStartElement("paneSet");
+ {
+ // Collect pane list
+ QList<LYTPane *> paneList;
+ collectPanesForList(&paneList, layout->rootPane);
+
+ // now write them all
+ foreach (LYTPane *p, paneList) {
+ w.writeStartElement("pane");
+ w.writeAttribute("kind", PaneKinds[(int)p->type()]);
+ w.writeAttribute("name", p->name);
+ w.writeAttribute("visible", p->visible?"true":"false");
+ w.writeAttribute("locked", "false");
+ w.writeAttribute("alpha", QString::number(p->alpha));
+ if (p->influencedAlpha)
+ w.writeAttribute("influencedAlpha", "true");
+ if (p->isWidescreen)
+ w.writeAttribute("locationAdjust", "true");
+ {
+ w.writeEmptyElement("comment");
+
+ w.writeEmptyElement("basePositionType");
+ w.writeAttribute("x", HorzOrigin[(int)p->horzOrigin]);
+ w.writeAttribute("y", VertOrigin[(int)p->vertOrigin]);
+
+ w.writeEmptyElement("translate");
+ w.writeAttribute("x", QString::number(p->xTrans));
+ w.writeAttribute("y", QString::number(p->yTrans));
+ w.writeAttribute("z", QString::number(p->zTrans));
+
+ w.writeEmptyElement("rotate");
+ w.writeAttribute("x", QString::number(p->xRot));
+ w.writeAttribute("y", QString::number(p->yRot));
+ w.writeAttribute("z", QString::number(p->zRot));
+
+ w.writeEmptyElement("scale");
+ w.writeAttribute("x", QString::number(p->xScale));
+ w.writeAttribute("y", QString::number(p->yScale));
+
+ w.writeEmptyElement("size");
+ w.writeAttribute("x", QString::number(p->width));
+ w.writeAttribute("y", QString::number(p->height));
+
+
+ if (p->type() == LYTPane::PictureType) {
+ LYTPicture *pic = (LYTPicture*)p;
+
+ const LYTMaterial &mat = *(layout->materials.getMaterialByName(pic->materialName));
+
+ w.writeStartElement("picture");
+ w.writeAttribute("detailSetting", isMaterialDetailed(mat)?"true":"false");
+
+ static const char *vnames[] = {
+ "vtxColLT", "vtxColRT", "vtxColLB", "vtxColRB"
+ };
+ for (int i = 0; i < 4; i++) {
+ w.writeEmptyElement(vnames[i]);
+ writeAttribColour(w, pic->vtxColours[i]);
+ }
+
+ for (int i = 0; i < pic->texCoords.count(); i++)
+ writeTexCoordSet(w, pic->texCoords.at(i));
+
+ writeMaterial(w, mat, usedNames);
+
+ w.writeEndElement(); // picture
+
+ } else if (p->type() == LYTPane::TextBoxType) {
+ LYTTextBox *tb = (LYTTextBox*)p;
+
+ static const char *TextAlignments[] = {
+ "Synchronous", "Left", "Center", "Right"
+ };
+
+ w.writeStartElement("textBox");
+ w.writeAttribute("font", tb->fontName);
+ w.writeAttribute("textAlignment", TextAlignments[(int)tb->alignment]);
+ w.writeAttribute("lineSpace", QString::number(tb->lineSpace));
+ w.writeAttribute("charSpace", QString::number(tb->charSpace));
+ w.writeAttribute("allocateStringLength", QString::number(tb->bufferLength));
+
+ w.writeEmptyElement("fontSize");
+ w.writeAttribute("x", QString::number(tb->fontSizeX));
+ w.writeAttribute("y", QString::number(tb->fontSizeY));
+
+ w.writeTextElement("text", tb->text);
+
+ w.writeEmptyElement("topColor");
+ writeAttribColour(w, tb->colour1);
+
+ w.writeEmptyElement("bottomColor");
+ writeAttribColour(w, tb->colour2);
+
+ w.writeEmptyElement("positionType");
+ w.writeAttribute("x", HorzOrigin[(int)tb->textHorzPos]);
+ w.writeAttribute("y", VertOrigin[(int)tb->textVertPos]);
+
+ writeMaterial(w, *(layout->materials.getMaterialByName(tb->materialName)), usedNames);
+
+ w.writeEndElement(); // textBox
+
+ } else if (p->type() == LYTPane::WindowType) {
+ LYTWindow *win = (LYTWindow*)p;
+
+ w.writeStartElement("window");
+
+ w.writeStartElement("content");
+ {
+ const LYTMaterial &mat = *(layout->materials.getMaterialByName(win->contentMaterialName));
+ w.writeAttribute("detailSetting", isMaterialDetailed(mat)?"true":"false");
+
+ static const char *vnames[] = {
+ "vtxColLT", "vtxColRT", "vtxColLB", "vtxColRB"
+ };
+ for (int i = 0; i < 4; i++) {
+ w.writeEmptyElement(vnames[i]);
+ writeAttribColour(w, win->contentVtxColours[i]);
+ }
+
+ foreach (const LYTTexCoords &set, win->contentTexCoords)
+ writeTexCoordSet(w, set);
+
+ writeMaterial(w, mat, usedNames);
+ }
+ w.writeEndElement(); // content
+
+ const char *wframetypes[] = {
+ "CornerLT", "CornerRT", "CornerLB", "CornerRB",
+ "FrameT", "FrameB", "FrameL", "FrameR"
+ };
+ int frameidx = 0;
+ foreach (const LYTWindowFrame *fr, win->frames) {
+ const LYTMaterial &fmat = *(layout->materials.getMaterialByName(fr->materialName));
+
+ w.writeStartElement("frame");
+ w.writeAttribute("frameType", wframetypes[frameidx]);
+ w.writeAttribute("detailSetting", isMaterialDetailed(fmat)?"true":"false");
+
+ static const char *tflipNames[] = {
+ "None", "FlipH", "FlipV", "Rotate90", "Rotate180", "Rotate270"
+ };
+ w.writeTextElement("textureFlip", tflipNames[(int)fr->type]);
+
+ writeMaterial(w, fmat, usedNames);
+
+ w.writeEndElement(); // frame
+
+ frameidx++;
+ }
+
+ w.writeEmptyElement("contentInflation");
+ w.writeAttribute("l", QString::number(win->contentOverflowLeft));
+ w.writeAttribute("r", QString::number(win->contentOverflowRight));
+ w.writeAttribute("t", QString::number(win->contentOverflowTop));
+ w.writeAttribute("b", QString::number(win->contentOverflowBottom));
+
+ w.writeEndElement(); // window
+
+ } else if (p->type() == LYTPane::BoundingType) {
+ w.writeEmptyElement("bounding");
+ }
+
+
+ w.writeStartElement("userData");
+ w.writeEmptyElement("string");
+ w.writeEndElement();
+ }
+ w.writeEndElement(); // pane
+ }
+ }
+ w.writeEndElement(); // paneSet
+
+
+ // Now, the hierarchy
+ w.writeStartElement("paneHierarchy");
+ {
+ outputPaneTree(&w, layout->rootPane);
+ }
+ w.writeEndElement(); // paneHierarchy
+
+
+ w.writeStartElement("groupSet");
+ {
+ w.writeStartElement("group");
+ w.writeAttribute("name", "RootGroup");
+ {
+ foreach (LYTGroup *g, layout->groups) {
+ w.writeStartElement("group");
+ w.writeAttribute("name", g->name);
+ {
+ foreach (LYTPane *p, g->panes) {
+ w.writeEmptyElement("paneRef");
+ w.writeAttribute("name", p->name);
+ }
+ w.writeEmptyElement("comment");
+ }
+ w.writeEndElement(); // group
+ }
+
+ w.writeEmptyElement("comment");
+ }
+ w.writeEndElement(); // group
+ }
+ w.writeEndElement(); // groupSet
+
+
+ w.writeStartElement("screenSetting");
+ w.writeAttribute("origin", "Normal");
+ {
+ w.writeEmptyElement("layoutSize");
+ w.writeAttribute("x", QString::number(layout->width));
+ w.writeAttribute("y", QString::number(layout->height));
+
+ w.writeStartElement("backGround");
+ {
+ w.writeEmptyElement("color");
+ w.writeAttribute("r", "169");
+ w.writeAttribute("g", "169");
+ w.writeAttribute("b", "169");
+ w.writeAttribute("a", "255");
+ }
+ w.writeEndElement(); // backGround
+
+ w.writeStartElement("grid");
+ w.writeAttribute("thickLineInterval", "40");
+ w.writeAttribute("thinDivisionNum", "4");
+ w.writeAttribute("visible", "true");
+ w.writeAttribute("moveMethod", "Grid");
+ {
+ w.writeEmptyElement("color");
+ w.writeAttribute("r", "128");
+ w.writeAttribute("g", "128");
+ w.writeAttribute("b", "64");
+ w.writeAttribute("a", "128");
+ }
+ w.writeEndElement(); // grid
+ }
+ w.writeEndElement(); // screenSetting
+
+
+ const char *TexFormats[] = {
+ "I4", "I8", "IA4", "IA8", "RGB565", "RGB5A3", "RGBA8",
+ "xxx", "C4x", "C8x", "C14x", "xxx", "xxx", "xxx", "CMPR"
+ };
+
+ QStringList texfiles = layout->generateTextureRefs();
+ foreach (const QString &texfile, texfiles) {
+ QString stripname = texfile;
+ stripname.replace(".tpl", "");
+
+ w.writeEmptyElement("textureFile");
+ w.writeAttribute("imagePath", QString("texture\\%1.tga").arg(stripname));
+ w.writeAttribute("format", TexFormats[(int)texFormats.value(stripname)]);
+ }
+
+
+ // find out all the fonts that are used
+ QStringList fonts;
+ layout->rootPane->addFontRefsToList(fonts);
+
+ foreach (const QString &fontfile, fonts) {
+ w.writeEmptyElement("fontFile");
+ w.writeAttribute("path", QString("..\\fonts\\%1").arg(fontfile));
+ }
+
+
+ // Finish up
+
+
+ w.writeEndElement(); // rlyt
+ w.writeEndElement(); // body
+
+ w.writeEndDocument();
+}
+
+
+static void exportTexture(const WiiTPLTexture &tex, QIODevice *outputDevice) {
+ QDataStream out(outputDevice);
+ out.setByteOrder(QDataStream::LittleEndian);
+
+ out << (quint8)0x14; // ID length
+ out << (quint8)0; // no colour map
+ out << (quint8)2; // uncompressed true colour
+ WritePadding(5, out); // colour map spec, not used
+ out << (quint16)0; // X origin
+ out << (quint16)0; // Y origin
+ out << (quint16)tex.image.width(); // width
+ out << (quint16)tex.image.height(); // height
+ out << (quint8)32; // bit depth
+ out << (quint8)8; // alpha channel, direction (dir not used)
+
+ out.writeRawData("NW4R_Tga Ver1.0\0\0\0\xc1\xb0", 0x14);
+
+ // put together the image
+ for (int y = tex.image.height() - 1; y >= 0; y--) {
+ const QRgb *line = (const QRgb*)tex.image.scanLine(y);
+ for (int x = 0; x < tex.image.width(); x++) {
+ out << (quint32)line[x];
+ }
+ }
+
+ // now, data...
+ static const char *TexFormats[] = {
+ "i4", "i8", "ia4", "ia8", "rgb565", "rgb5a3", "rgba8",
+ "XXX", "c4", "c8", "c14", "XXX", "XXX", "XXX", "cmpr"
+ };
+
+ out.setByteOrder(QDataStream::BigEndian);
+
+ // format block
+ out.writeRawData("nw4r_tfm", 8);
+ const char *tfm = TexFormats[(int)tex.format];
+ quint32 tfm_size = 12 + qstrlen(tfm);
+ out << tfm_size;
+ out.writeRawData(tfm, qstrlen(tfm));
+
+ // end block
+ out.writeRawData("nw4r_end", 8);
+ out << (quint32)12;
+}
+
+#include "lyt/animation.h"
+
+static int AnimKeyFor(LYTAnimPiece::Type type, const LYTAnimEntry &entry) {
+ switch (type) {
+ case LYTAnimPiece::TexSRTAnim:
+ case LYTAnimPiece::IndTexSRTAnim:
+ case LYTAnimPiece::TexPatAnim:
+ return (entry.id << 8) | entry.target;
+ default:
+ return entry.target;
+ }
+}
+
+struct AnimExportThing {
+ QVector<LYTAnimHermiteKey> hermites;
+ QVector<LYTAnimStepKey> steps;
+ QStringList refRes;
+};
+
+void LSExportPackage(LYTPackageBase *pkg, QString dirStr) {
+ QDir dir(dirStr);
+ if (!dir.exists())
+ dir.mkpath(".");
+
+ if (!dir.exists("texture"))
+ dir.mkdir("texture");
+
+ QMap<QString, GX::TextureFormat> texFormats;
+
+ QStringList texes = pkg->listTextures();
+ foreach (const QString &tplName, texes) {
+ if (!tplName.endsWith(".tpl"))
+ continue;
+
+ QByteArray tplData = pkg->getTexture(tplName);
+ QDataStream ds(tplData);
+ WiiTexPalette tpl(ds);
+
+ const WiiTPLTexture &tex = tpl.textures.first();
+
+ QString texName = tplName;
+ texName.replace(".tpl", "");
+
+ texFormats.insert(texName, tex.format);
+
+ QFile tgaFile(dir.filePath(QString("texture/%1.tga").arg(texName)));
+ tgaFile.open(QFile::WriteOnly);
+ exportTexture(tex, &tgaFile);
+ tgaFile.close();
+ }
+
+ QString brlytName = pkg->listLayouts().first();
+ QString lytName = brlytName;
+ lytName.replace(".brlyt", "");
+
+ LYTLayout layout(*pkg, brlytName);
+
+ QFile rlytFile(dir.filePath(QString("%1.rlyt").arg(lytName)));
+ rlytFile.open(QFile::WriteOnly);
+ exportRlyt(&layout, &rlytFile, texFormats);
+ rlytFile.close();
+
+
+ // Now handle the rlan
+ QStringList brlans = pkg->listAnims();
+ QMap<int, LYTAnimation *> animPtrsByTag;
+ foreach (const QString &brlanName, brlans) {
+ if (!brlanName.endsWith(".brlan"))
+ continue;
+
+ QByteArray brlanData = pkg->getAnim(brlanName);
+ LYTAnimation *anim = new LYTAnimation(brlanData);
+
+ animPtrsByTag.insert(anim->sourceTagNumber, anim);
+ }
+
+ QFile rlanFile(dir.filePath(QString("%1.rlan").arg(lytName)));
+ rlanFile.open(QFile::WriteOnly);
+ QXmlStreamWriter aw(&rlanFile);
+
+ aw.setAutoFormatting(true);
+ aw.writeStartDocument();
+
+ aw.writeStartElement("nw4r_layout");
+ aw.writeDefaultNamespace("http://www.nintendo.co.jp/NW4R/LayoutEditor");
+ aw.writeAttribute("version", "1.2.0");
+
+ aw.writeStartElement("head");
+ {
+ aw.writeEmptyElement("create");
+ aw.writeAttribute("user", "someone");
+ aw.writeAttribute("host", "somewhere");
+ aw.writeAttribute("date", "2006-07-26T10:20:54.551+09:00");
+ aw.writeAttribute("source", "");
+
+ aw.writeEmptyElement("title");
+
+ aw.writeEmptyElement("comment");
+
+ aw.writeEmptyElement("generator");
+ aw.writeAttribute("name", "LayoutStudio");
+ aw.writeAttribute("version", "NONE_OF_YOUR_BUSINESS");
+ }
+ aw.writeEndElement(); // head
+
+ aw.writeStartElement("body");
+ {
+ int minFrame = 0x7fffffff, maxFrame = -1;
+ foreach (const LYTAnimation *anim, animPtrsByTag) {
+ aw.writeStartElement("animTag");
+ aw.writeAttribute("name", anim->name);
+ aw.writeAttribute("startFrame", QString::number(anim->sourceStartFrame));
+ aw.writeAttribute("endFrame", QString::number(anim->sourceEndFrame));
+ aw.writeAttribute("fileName", anim->name);
+ aw.writeAttribute("descendingBind", anim->recursiveBind?"true":"false");
+ aw.writeAttribute("animLoop", anim->loop?"Loop":"OneTime");
+
+ if (anim->sourceStartFrame < minFrame)
+ minFrame = anim->sourceStartFrame;
+ if (anim->sourceEndFrame > maxFrame)
+ maxFrame = anim->sourceEndFrame;
+
+ aw.writeEmptyElement("comment");
+
+ foreach (const LYTAnimGroupInfo &grp, anim->groups) {
+ aw.writeEmptyElement("group");
+ aw.writeAttribute("name", grp.name);
+ }
+
+ aw.writeEndElement(); // animTag
+ }
+
+ // This is probably not the most efficient way to do this
+ // but who gives a shit
+ QSet<LYTAnimPiece::Type> usedAnimTypes;
+ foreach (const LYTAnimation *anim, animPtrsByTag) {
+ foreach (const LYTAnimBlock &block, anim->blocks) {
+ foreach (const LYTAnimPiece &piece, block.pieces) {
+ usedAnimTypes.insert(piece.type);
+ }
+ }
+ }
+
+ // Now do processing for each type
+ static const char *AnimTypes[] = {
+ "PainSRT", "TextureSRT", "Visibility", "VertexColor",
+ "MaterialColor", "TexturePattern", "IndTextureSRT"
+ };
+ foreach (LYTAnimPiece::Type type, usedAnimTypes) {
+ aw.writeStartElement("rlan");
+ aw.writeAttribute("animType", AnimTypes[(int)type]);
+ aw.writeAttribute("startFrame", QString::number(minFrame));
+ aw.writeAttribute("endFrame", QString::number(maxFrame));
+ aw.writeAttribute("convertStartFrame", QString::number(minFrame));
+ aw.writeAttribute("convertEndFrame", QString::number(maxFrame));
+
+ // collect the contents
+ QMap<QString,bool> contentsUsed;
+
+ foreach (const LYTAnimation *anim, animPtrsByTag) {
+ foreach (const LYTAnimBlock &block, anim->blocks) {
+ foreach (const LYTAnimPiece &piece, block.pieces) {
+ if (piece.type == type)
+ contentsUsed.insert(block.name, true);
+ }
+ }
+ }
+
+ // now put them together!
+ QMapIterator<QString,bool> contentsUsedIter(contentsUsed);
+ while (contentsUsedIter.hasNext()) {
+ contentsUsedIter.next();
+
+ aw.writeStartElement("animContent");
+ aw.writeAttribute("name", contentsUsedIter.key());
+
+ // Collect the targets being used
+ QMap<int,AnimExportThing> targetsUsed;
+ foreach (const LYTAnimation *anim, animPtrsByTag) {
+ foreach (const LYTAnimBlock &block, anim->blocks) {
+ if (block.name != contentsUsedIter.key())
+ continue;
+
+ foreach (const LYTAnimPiece &piece, block.pieces) {
+ if (piece.type != type)
+ continue;
+
+ foreach (const LYTAnimEntry &entry, piece.entries) {
+ int key = AnimKeyFor(type, entry);
+ if (!targetsUsed.contains(key))
+ targetsUsed.insert(key, AnimExportThing());
+
+ AnimExportThing &thing = targetsUsed[key];
+ if (entry.curveType == 0)
+ qFatal("what!");
+ else if (entry.curveType == 1) {
+ // step keys
+ foreach (const LYTAnimStepKey &key, entry.stepKeys) {
+ LYTAnimStepKey newKey = key;
+ newKey.frame += anim->sourceStartFrame;
+ thing.steps.append(newKey);
+ }
+ } else if (entry.curveType == 2) {
+ // hermite keys
+ foreach (const LYTAnimHermiteKey &key, entry.keys) {
+ LYTAnimHermiteKey newKey = key;
+ newKey.frame += anim->sourceStartFrame;
+ thing.hermites.append(newKey);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Now export them...
+ QMapIterator<int,AnimExportThing> tuIter(targetsUsed);
+ while (tuIter.hasNext()) {
+ tuIter.next();
+
+ // assemble the start tag
+ int ak = tuIter.key();
+
+ static const char *PainTargets[] = {
+ "TranslateX", "TranslateY", "TranslateZ",
+ "RotateX", "RotateY", "RotateZ",
+ "ScaleX", "ScaleY",
+ "SizeW", "SizeH"
+ };
+
+ static const char *VtxColTargets[] = {
+ "LT_r", "LT_g", "LT_b", "LT_a",
+ "RT_r", "RT_g", "RT_b", "RT_a",
+ "LB_r", "LB_g", "LB_b", "LB_a",
+ "RB_r", "RB_g", "RB_b", "RB_a",
+ "PaneAlpha"
+ };
+
+ static const char *MatColTargets[] = {
+ "MatColor0_r", "MatColor0_g", "MatColor0_b", "MatColor0_a",
+ "TevColor0_r", "TevColor0_g", "TevColor0_b", "TevColor0_a",
+ "TevColor1_r", "TevColor1_g", "TevColor1_b", "TevColor1_a",
+ "TevColor2_r", "TevColor2_g", "TevColor2_b", "TevColor2_a",
+ "TevKonst0_r", "TevKonst0_g", "TevKonst0_b", "TevKonst0_a",
+ "TevKonst1_r", "TevKonst1_g", "TevKonst1_b", "TevKonst1_a",
+ "TevKonst2_r", "TevKonst2_g", "TevKonst2_b", "TevKonst2_a",
+ "TevKonst3_r", "TevKonst3_g", "TevKonst3_b", "TevKonst3_a"
+ };
+
+ static const char *SRTTargets[] = {
+ "TranslateS", "TranslateT", "Rotate", "ScaleS", "ScaleT"
+ };
+
+ static const char *PatTargets[] = {
+ "Image", "Palette"
+ };
+
+ switch (type) {
+ case LYTAnimPiece::PaneAnim:
+ aw.writeStartElement("animPainSRTTarget");
+ aw.writeAttribute("target", PainTargets[ak]);
+ break;
+ case LYTAnimPiece::VisAnim:
+ aw.writeStartElement("animVisibilityTarget");
+ aw.writeAttribute("target", "Visibility");
+ break;
+ case LYTAnimPiece::VtxClrAnim:
+ aw.writeStartElement("animVertexColorTarget");
+ aw.writeAttribute("target", VtxColTargets[ak]);
+ break;
+ case LYTAnimPiece::MatClrAnim:
+ aw.writeStartElement("animMaterialColorTarget");
+ aw.writeAttribute("target", MatColTargets[ak]);
+ break;
+ case LYTAnimPiece::TexSRTAnim:
+ aw.writeStartElement("animTexSRTTarget");
+ aw.writeAttribute("id", QString::number(ak>>8));
+ aw.writeAttribute("target", SRTTargets[ak&0xFF]);
+ break;
+ case LYTAnimPiece::IndTexSRTAnim:
+ aw.writeStartElement("animIndTexSRTTarget");
+ aw.writeAttribute("id", QString::number(ak>>8));
+ aw.writeAttribute("target", SRTTargets[ak&0xFF]);
+ break;
+ case LYTAnimPiece::TexPatAnim:
+ aw.writeStartElement("animTexPatternTarget");
+ aw.writeAttribute("id", QString::number(ak>>8));
+ aw.writeAttribute("target", PatTargets[ak&0xFF]);
+
+ //foreach (const QString &bee, )
+ break;
+ }
+
+ foreach (const LYTAnimHermiteKey &key, tuIter.value().hermites) {
+ aw.writeEmptyElement("key");
+ aw.writeAttribute("frame", QString::number(key.frame));
+ aw.writeAttribute("value", QString::number(key.value));
+ aw.writeAttribute("slope", QString::number(key.slope));
+ }
+
+ foreach (const LYTAnimStepKey &key, tuIter.value().steps) {
+ aw.writeEmptyElement("key");
+ aw.writeAttribute("frame", QString::number(key.frame));
+ aw.writeAttribute("value", QString::number(key.value));
+ aw.writeAttribute("slopeType", "Step");
+ }
+
+ aw.writeEndElement(); // target thing
+ }
+
+ aw.writeEndElement(); // animContent
+ }
+
+ aw.writeEndElement(); // rlan
+ }
+ }
+ aw.writeEndElement(); // body
+
+ aw.writeEndElement(); // nw4r_layout
+
+ aw.writeEndDocument();
+
+ rlanFile.close();
+
+ qDeleteAll(animPtrsByTag.begin(), animPtrsByTag.end());
+}
diff --git a/lsrlytexporter.h b/lsrlytexporter.h
new file mode 100644
index 0000000..ede8e6b
--- /dev/null
+++ b/lsrlytexporter.h
@@ -0,0 +1,8 @@
+#ifndef LSRLYTEXPORTER_H
+#define LSRLYTEXPORTER_H
+
+#include "lyt/packagebase.h"
+
+void LSExportPackage(LYTPackageBase *pkg, QString dir);
+
+#endif // LSRLYTEXPORTER_H
diff --git a/lsscenemodel.cpp b/lsscenemodel.cpp
deleted file mode 100644
index 1e55cdd..0000000
--- a/lsscenemodel.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-#include "lsscenemodel.h"
-#include "lsglobals.h"
-
-LSSceneModel::LSSceneModel(LYTLayout *layout, bool exposeVisibility, QObject *parent) :
- QAbstractItemModel(parent), m_exposesVisibility(exposeVisibility)
-{
- m_layout = layout;
-
- m_paneIcons[LYTPane::PaneType] = LSGlobals::getIcon("pane");
- m_paneIcons[LYTPane::PictureType] = LSGlobals::getIcon("picture");
- m_paneIcons[LYTPane::TextBoxType] = LSGlobals::getIcon("textbox");
- m_paneIcons[LYTPane::WindowType] = LSGlobals::getIcon("window");
- m_paneIcons[LYTPane::BoundingType] = LSGlobals::getIcon("bounding");
-
- m_movingPaneParent = 0;
-}
-
-LSSceneModel::~LSSceneModel() {
- if (m_movingPaneParent)
- delete m_movingPaneParent;
-}
-
-
-QModelIndex LSSceneModel::index(int row, int column, const QModelIndex &parent) const {
- if (!hasIndex(row, column, parent))
- return QModelIndex();
-
- if (!parent.isValid())
- return createIndex(row, column, m_layout->rootPane);
-
- // what's the parent..?
- LYTPane *parentPane = (LYTPane*)parent.internalPointer();
- LYTPane *pane = parentPane->children.at(row);
- return createIndex(row, column, pane);
-}
-
-QModelIndex LSSceneModel::parent(const QModelIndex &child) const {
- if (!child.isValid())
- return QModelIndex();
-
- LYTPane *childPane = (LYTPane*)child.internalPointer();
- LYTPane *parentPane = childPane->parent;
- if (parentPane) {
- LYTPane *parentParentPane = parentPane->parent;
- int index = parentParentPane ? parentParentPane->children.indexOf(parentPane) : 0;
- return createIndex(index, 0, parentPane);
- } else {
- return QModelIndex();
- }
-}
-
-int LSSceneModel::rowCount(const QModelIndex &parent) const {
- if (!parent.isValid()) {
- return 1; // the root pane
- }
-
- LYTPane *parentPane = (LYTPane*)parent.internalPointer();
- return parentPane->children.count();
-}
-
-int LSSceneModel::columnCount(const QModelIndex &parent) const {
- (void)parent;
- return 1;
-}
-
-QVariant LSSceneModel::data(const QModelIndex &index, int role) const {
- LYTPane *pane = (LYTPane*)index.internalPointer();
- if (pane) {
- switch (role) {
- case Qt::DisplayRole:
- return pane->name;
- case Qt::DecorationRole:
- return m_paneIcons[pane->type()];
- }
-
- if (m_exposesVisibility && role == Qt::CheckStateRole) {
- return pane->visible ? Qt::Checked : Qt::Unchecked;
- }
- }
- return QVariant();
-}
-
-bool LSSceneModel::setData(const QModelIndex &index, const QVariant &value, int role) {
- if (m_exposesVisibility && role == Qt::CheckStateRole) {
- LYTPane *pane = (LYTPane*)index.internalPointer();
-
- bool newVisible = value.toBool();
- if (pane->visible != newVisible) {
- pane->visible = newVisible;
- emit dataChanged(index, index);
- emit paneVisibilityChanged();
- }
- }
-
- return false;
-}
-
-
-Qt::ItemFlags LSSceneModel::flags(const QModelIndex &index) const {
- Qt::ItemFlags flag;
- flag = Qt::ItemIsEnabled | Qt::ItemIsSelectable |
- Qt::ItemIsDropEnabled;
-
- if (index.isValid() && index.parent().isValid())
- flag |= Qt::ItemIsDragEnabled;
-
- if (m_exposesVisibility)
- flag |= Qt::ItemIsUserCheckable;
-
- return flag;
-}
-
-
-Qt::DropActions LSSceneModel::supportedDropActions() const {
- return Qt::MoveAction;
-}
-
-
-// I am doing a terrible, terrible, terrible thing here.
-// I hate drag-and-drop.
-
-// As far as I can see, insertRows and removeRows are ONLY called by Qt when
-// dragging something. So instead of doing a real insertion/removal... I'll
-// store the intended destination, and once I'm told what pane needs to be
-// removed (moved) I do the whole thing at once.
-
-bool LSSceneModel::insertRows(int row, int count, const QModelIndex &parent) {
- qDebug("LSSceneModel::insertRows(%d, %d, something)", row, count);
-
- if (m_movingPaneParent) {
- qWarning("huh, already moving something? dunno");
- return false;
- }
-
- if (!parent.isValid()) {
- qWarning("can't move stuff to the top level");
- return false;
- }
-
- m_movingPaneParent = new QPersistentModelIndex(parent);
- m_movingPaneRow = row;
- m_movingPaneCount = count;
-
- return true;
-}
-
-bool LSSceneModel::removeRows(int row, int count, const QModelIndex &parent) {
- qDebug("LSSceneModel::removeRows(%d, %d, something)", row, count);
-
- if (!m_movingPaneParent) {
- qWarning("huh, not moving anything / nothing left to move? dunno");
- return false;
- }
-
- // detach all the existing panes
- LYTPane *parentPane = (LYTPane*)parent.internalPointer();
-
- QVector<LYTPane *> removingPanes;
- removingPanes.reserve(count);
-
- beginRemoveRows(parent, row, row + count - 1);
- for (int i = 0; i < count; i++) {
- removingPanes.append(parentPane->children.at(row));
- parentPane->children.removeAt(row);
- }
- endRemoveRows();
-
- // now add them in their new homes!
- LYTPane *newParentPane = (LYTPane*)m_movingPaneParent->internalPointer();
-
- // note: compensate for the offset: if we're moving the thing within the
- // same parent and the destination row is higher than the source row, then
- // removing the source row will have changed the index of the row the user
- // actually wanted to move the moved row to... what a terrible sentence :|
- if (*m_movingPaneParent == parent && m_movingPaneRow > row)
- m_movingPaneRow -= count;
-
- beginInsertRows(*m_movingPaneParent, m_movingPaneRow, m_movingPaneRow + count - 1);
-
- for (int i = 0; i < count; i++) {
- LYTPane *pane = removingPanes.at(i);
-
- pane->parent = newParentPane;
- newParentPane->children.insert(m_movingPaneRow, pane);
-
- m_movingPaneRow++;
- }
-
- endInsertRows();
-
- // clean up if needed
- m_movingPaneCount -= count;
-
- if (m_movingPaneCount <= 0) {
- delete m_movingPaneParent;
- m_movingPaneParent = 0;
- }
-
- return true;
-}
-
diff --git a/lsscenemodel.h b/lsscenemodel.h
deleted file mode 100644
index e089e46..0000000
--- a/lsscenemodel.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef LSSCENEMODEL_H
-#define LSSCENEMODEL_H
-
-#include <QAbstractItemModel>
-#include <QIcon>
-#include "lyt/layout.h"
-
-class LSSceneModel : public QAbstractItemModel {
- Q_OBJECT
-public:
- explicit LSSceneModel(LYTLayout *layout, bool exposeVisibility, QObject *parent = 0);
- ~LSSceneModel();
-
- LYTLayout *layout() const { return m_layout; }
-
- QModelIndex index(int row, int column, const QModelIndex &parent) const;
- QModelIndex parent(const QModelIndex &child) const;
- int rowCount(const QModelIndex &parent) const;
- int columnCount(const QModelIndex &parent) const;
- QVariant data(const QModelIndex &index, int role) const;
- bool setData(const QModelIndex &index, const QVariant &value, int role);
-
- Qt::ItemFlags flags(const QModelIndex &index) const;
- Qt::DropActions supportedDropActions() const;
-
- bool insertRows(int row, int count, const QModelIndex &parent);
- bool removeRows(int row, int count, const QModelIndex &parent);
-
-private:
- LYTLayout *m_layout;
-
- QIcon m_paneIcons[LYTPane::PaneTypeCount];
-
- QPersistentModelIndex *m_movingPaneParent;
- int m_movingPaneRow, m_movingPaneCount;
-
- bool m_exposesVisibility;
-
-signals:
- void paneVisibilityChanged();
-
-public slots:
-
-};
-
-#endif // LSSCENEMODEL_H
diff --git a/lsseteditor.cpp b/lsseteditor.cpp
deleted file mode 100644
index bc63476..0000000
--- a/lsseteditor.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-#include "lsseteditor.h"
-#include <QGridLayout>
-#include <QLabel>
-
-_LSSetEditorBase::_LSSetEditorBase(int maxEntries, QWidget *parent) :
- QWidget(parent) {
-
- m_maxEntries = maxEntries;
- m_loadingThings = 0;
-}
-
-
-void _LSSetEditorBase::handleEntrySelected(int index) {
- if (!m_loadingThings)
- showEntry(index);
-}
-
-
-void _LSSetEditorBase::handleEntryCountChanged(int count) {
- if (!m_loadingThings) {
- int oldCount = m_chooser->count();
- if (oldCount == count)
- return;
-
- changeEntryCountTo(count);
- resizeDataListTo(count);
-
- // moving from 0 to something...?
- if (oldCount == 0) {
- m_chooser->setCurrentIndex(0);
- showEntry(0);
- }
-
- emit dataEdited();
- }
-}
-
-
-void _LSSetEditorBase::setup(QWidget *eWidget) {
- m_loadingThings++;
-
- m_entryCount = new QSpinBox(this);
- m_entryCount->setRange(0, m_maxEntries);
- connect(m_entryCount, SIGNAL(valueChanged(int)), SLOT(handleEntryCountChanged(int)));
-
- m_chooser = new QComboBox(this);
- connect(m_chooser, SIGNAL(currentIndexChanged(int)), SLOT(handleEntrySelected(int)));
-
- QGridLayout *layout = new QGridLayout(this);
-
- layout->addWidget(new QLabel("Count:", this), 0, 0, 1, 1);
- layout->addWidget(m_entryCount, 0, 1, 1, 1);
- layout->setColumnMinimumWidth(2, 10);
- layout->addWidget(m_chooser, 0, 3, 1, 1);
- layout->setColumnStretch(3, 1);
-
- layout->addWidget(eWidget, 1, 0, 1, 4);
-
- m_loadingThings--;
-}
diff --git a/lsseteditor.h b/lsseteditor.h
deleted file mode 100644
index 0b09ca6..0000000
--- a/lsseteditor.h
+++ /dev/null
@@ -1,160 +0,0 @@
-#ifndef LSSETEDITOR_H
-#define LSSETEDITOR_H
-
-#include <QWidget>
-#include <QSpinBox>
-#include <QComboBox>
-
-class _LSSetEntryEditorBaseBase : public QWidget {
- Q_OBJECT
-protected:
- explicit _LSSetEntryEditorBaseBase(QWidget *parent = 0) :
- QWidget(parent) { }
-
-signals:
- void dataEdited();
-};
-
-// class prototype
-template <typename TData, typename TWidget>
-class LSSetEditor;
-
-template <typename TData>
-class LSSetEntryEditorBase : public _LSSetEntryEditorBaseBase {
-protected:
- explicit LSSetEntryEditorBase(QWidget *parent = 0) :
- _LSSetEntryEditorBaseBase(parent) { }
-
-public:
- void setCurrentEntry(TData &entry) {
- m_currentEntry = &entry;
- loadEntryFrom(entry);
- }
-
-private:
- TData *m_currentEntry;
-
-protected:
- virtual void loadEntryFrom(const TData &entry) = 0;
- TData *currentEntry() const { return m_currentEntry; }
-};
-
-
-
-
-class _LSSetEditorBase : public QWidget {
- Q_OBJECT
-public:
- explicit _LSSetEditorBase(int maxEntries, QWidget *parent = 0);
-
-protected:
- int m_maxEntries;
- QSpinBox *m_entryCount;
- QComboBox *m_chooser;
-
- QWidget *m_setEditorWidget;
-
- int m_loadingThings;
-
- void setup(QWidget *eWidget);
-
- virtual void changeEntryCountTo(int count) = 0;
- virtual void showEntry(int index) = 0;
- virtual void resizeDataListTo(int count) = 0;
-
-private slots:
- void handleEntryCountChanged(int count);
- void handleEntrySelected(int index);
-
-signals:
- void dataEdited();
-
-};
-
-template <typename TData, typename TWidget>
-class LSSetEditor : public _LSSetEditorBase {
-public:
- explicit LSSetEditor(int maxEntries, QWidget *parent = 0) :
- _LSSetEditorBase(maxEntries, parent) {
-
- TWidget *w = new TWidget(this);
- setup(w);
-
- m_setEditorWidget = w;
- m_typedSetEditorWidget = w;
-
- LSSetEntryEditorBase<TData> *checkMe = w;
- connect(checkMe, SIGNAL(dataEdited()), SIGNAL(dataEdited()));
- }
-
- void setData(QList<TData> *newData) {
- m_loadingThings++;
-
- m_data = newData;
- m_entryCount->setValue(newData->count());
- changeEntryCountTo(newData->count());
-
- m_chooser->setCurrentIndex(newData->count() ? 0 : -1);
- showEntry(newData->count() ? 0 : -1);
-
- m_loadingThings--;
- }
-
-protected:
- QList<TData> *m_data;
- TWidget *m_typedSetEditorWidget;
-
- void changeEntryCountTo(int count) {
- m_loadingThings++;
-
- int existingCount = m_chooser->count();
-
- if (existingCount > count) {
- // remove something
- int nowSelected = m_chooser->currentIndex();
-
- if (nowSelected >= count) {
- // oops, we'll need to select something else
- showEntry(count - 1);
- m_chooser->setCurrentIndex(count - 1);
- }
-
- for (int i = (existingCount - 1); i >= count; i--)
- m_chooser->removeItem(i);
-
- } else if (count > existingCount) {
- // add something
-
- for (int i = existingCount; i < count; i++)
- m_chooser->addItem(QString("Set %1").arg(i + 1));
- }
-
- m_loadingThings--;
- }
-
- void resizeDataListTo(int count) {
- m_data->reserve(count);
-
- while (m_data->count() < count)
- m_data->append(TData());
- while (m_data->count() > count)
- m_data->removeLast();
- }
-
- void showEntry(int index) {
- m_loadingThings++;
-
- if (index == -1) {
- m_setEditorWidget->setEnabled(false);
- } else {
- m_setEditorWidget->setEnabled(true);
- TData &entry = (*m_data)[index];
- m_typedSetEditorWidget->setCurrentEntry(entry);
- }
- }
-};
-
-
-
-
-#endif // LSSETEDITOR_H
diff --git a/lstexcoordseteditor.cpp b/lstexcoordseteditor.cpp
deleted file mode 100644
index e8173a0..0000000
--- a/lstexcoordseteditor.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-#include "lstexcoordseteditor.h"
-#include <QLabel>
-#include <QHBoxLayout>
-#include <QGridLayout>
-
-LSTexCoordSetEditor::LSTexCoordSetEditor(QWidget *parent) :
- QWidget(parent) {
-
- m_loadingThings = 1;
-
- m_coordCount = new QSpinBox(this);
- m_coordCount->setRange(0, 8);
- connect(m_coordCount, SIGNAL(valueChanged(int)), SLOT(handleCoordCountChanged(int)));
-
- m_chooser = new QComboBox(this);
- connect(m_chooser, SIGNAL(currentIndexChanged(int)), SLOT(handleSetSelected(int)));
-
- for (int i = 0; i < 8; i++) {
- m_coordEntry[i] = new QDoubleSpinBox(this);
- m_coordEntry[i]->setRange(-10000000.0, 10000000.0);
- connect(m_coordEntry[i], SIGNAL(valueChanged(double)), SLOT(handleCoordChanged(double)));
- }
-
-
- QHBoxLayout *topLayout = new QHBoxLayout;
- topLayout->addWidget(new QLabel("Count:", this));
- topLayout->addWidget(m_coordCount);
- topLayout->addSpacing(10);
- topLayout->addWidget(m_chooser, 1);
-
- // Layout:
- // 0 1 2 3 4
- // 0 <Chooser>
- // 1 x y x y
- // 2
- // 3 x y x y
-
- QGridLayout *layout = new QGridLayout(this);
- layout->addLayout(topLayout, 0, 0, 1, 5);
-
- layout->addWidget(m_coordEntry[0], 1, 0, 1, 1);
- layout->addWidget(m_coordEntry[1], 1, 1, 1, 1);
-
- layout->addWidget(m_coordEntry[2], 1, 3, 1, 1);
- layout->addWidget(m_coordEntry[3], 1, 4, 1, 1);
-
- layout->addWidget(m_coordEntry[4], 3, 0, 1, 1);
- layout->addWidget(m_coordEntry[5], 3, 1, 1, 1);
-
- layout->addWidget(m_coordEntry[6], 3, 3, 1, 1);
- layout->addWidget(m_coordEntry[7], 3, 4, 1, 1);
-
- layout->setColumnMinimumWidth(2, 25);
- layout->setRowMinimumHeight(2, 10);
-
- m_loadingThings--;
-}
-
-
-void LSTexCoordSetEditor::setCoordPtr(QVector<LYTTexCoords> *coords) {
- m_loadingThings++;
-
- m_targetCoords = coords;
-
- m_coordCount->setValue(coords->count());
-
- changeChooserCountTo(coords->count());
-
- m_chooser->setCurrentIndex(coords->count() ? 0 : -1);
- showCoordSet(coords->count() ? 0 : -1);
-
- m_loadingThings--;
-}
-
-void LSTexCoordSetEditor::changeChooserCountTo(int count) {
- m_loadingThings++;
-
- int existingCount = m_chooser->count();
-
- if (existingCount > count) {
- // remove something
- int nowSelected = m_chooser->currentIndex();
-
- if (nowSelected >= count) {
- // oops, we'll need to select something else
- showCoordSet(count - 1);
- m_chooser->setCurrentIndex(count - 1);
- }
-
- for (int i = (existingCount - 1); i >= count; i--)
- m_chooser->removeItem(i);
-
- } else if (count > existingCount) {
- // add something
-
- for (int i = existingCount; i < count; i++)
- m_chooser->addItem(QString("Set %1").arg(i + 1));
- }
-
- m_loadingThings--;
-}
-
-void LSTexCoordSetEditor::showCoordSet(int index) {
- m_loadingThings++;
-
- bool doesExist = (index != -1);
-
- for (int i = 0; i < 8; i++)
- m_coordEntry[i]->setEnabled(doesExist);
-
- if (doesExist) {
- const LYTTexCoords &set = m_targetCoords->at(index);
-
- for (int i = 0; i < 4; i++) {
- m_coordEntry[i*2]->setValue(set.coord[i].x());
- m_coordEntry[i*2+1]->setValue(set.coord[i].y());
- }
- }
-
- m_loadingThings--;
-}
-
-
-void LSTexCoordSetEditor::handleSetSelected(int index) {
- if (!m_loadingThings)
- showCoordSet(index);
-}
-
-void LSTexCoordSetEditor::handleCoordCountChanged(int count) {
- if (!m_loadingThings) {
- int oldCount = m_targetCoords->count();
- if (oldCount == count)
- return;
-
- changeChooserCountTo(count);
- m_targetCoords->resize(count);
-
- // moving from 0 to something...?
- if (oldCount == 0) {
- m_chooser->setCurrentIndex(0);
- showCoordSet(0);
- }
-
- emit coordsEdited();
- }
-}
-
-void LSTexCoordSetEditor::handleCoordChanged(double value) {
- if (!m_loadingThings) {
- // this code is.. kind of hacky.
-
- int whatID = -1;
- for (int i = 0; i < 8; i++)
- if (m_coordEntry[i] == sender()) {
- whatID = i;
- break;
- }
-
- if (whatID >= 0) {
- int coordIdx = m_chooser->currentIndex();
- if (coordIdx == -1)
- return;
-
- LYTTexCoords &coord = (*m_targetCoords)[coordIdx];
-
- if ((whatID % 2) == 1)
- coord.coord[whatID / 2].setY(value);
- else
- coord.coord[whatID / 2].setX(value);
-
- emit coordsEdited();
- }
- }
-}
diff --git a/lstexcoordseteditor.h b/lstexcoordseteditor.h
deleted file mode 100644
index 5d7d567..0000000
--- a/lstexcoordseteditor.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef LSTEXCOORDSETEDITOR_H
-#define LSTEXCOORDSETEDITOR_H
-
-#include <QWidget>
-#include <QComboBox>
-#include <QDoubleSpinBox>
-#include "lyt/common.h"
-
-class LSTexCoordSetEditor : public QWidget
-{
- Q_OBJECT
-public:
- explicit LSTexCoordSetEditor(QWidget *parent = 0);
-
- void setCoordPtr(QVector<LYTTexCoords> *coords);
-
-private:
- QVector<LYTTexCoords> *m_targetCoords;
- QSpinBox *m_coordCount;
- QComboBox *m_chooser;
- QDoubleSpinBox *m_coordEntry[8];
-
- int m_loadingThings;
-
- void changeChooserCountTo(int count);
- void showCoordSet(int index);
-
-private slots:
- void handleCoordCountChanged(int count);
- void handleSetSelected(int index);
- void handleCoordChanged(double value);
-
-signals:
- void coordsEdited();
-
-public slots:
-
-};
-
-#endif // LSTEXCOORDSETEDITOR_H
diff --git a/lyt/animation.cpp b/lyt/animation.cpp
new file mode 100644
index 0000000..d5e87d3
--- /dev/null
+++ b/lyt/animation.cpp
@@ -0,0 +1,220 @@
+#include "animation.h"
+#include "lyt/binaryfile.h"
+
+LYTAnimation::~LYTAnimation() {
+
+}
+
+LYTAnimation::LYTAnimation(QByteArray data) {
+ LYTBinaryFile file(data);
+
+ foreach (const LYTBinaryFileSection &section, file.sections) {
+ switch (section.magic.value) {
+ case 'pat1': {
+ // Info
+ QDataStream in(section.data);
+ InitDataStream(in);
+
+ quint16 groupCount;
+ quint32 nameOffset, groupOffset;
+ quint8 flag;
+
+ in >> sourceTagNumber;
+ in >> groupCount;
+ in >> nameOffset;
+ in >> groupOffset;
+ in >> sourceStartFrame;
+ in >> sourceEndFrame;
+ in >> flag;
+
+ qDebug() << "Source: Tag:" << sourceTagNumber << "- Frames:" << sourceStartFrame << "to" << sourceEndFrame;
+ qDebug() << "Groups: Offset" << groupOffset << ", count" << groupCount << "- Name offset:" << nameOffset;
+
+ recursiveBind = ((flag & 1) != 0);
+ qDebug() << "Flag:" << flag << "; Recursive bind:" << recursiveBind;
+
+ in.device()->seek(nameOffset - 8);
+ // a royal hack
+ name = ReadFixedLengthASCII(in, groupOffset-nameOffset);
+ qDebug() << "Rlan name:" << name;
+
+ groups.reserve(groupCount);
+ in.device()->seek(groupOffset - 8);
+
+ for (int i = 0; i < groupCount; i++) {
+ LYTAnimGroupInfo info;
+ info.name = ReadFixedLengthASCII(in, 17);
+ in >> info.unusedFlag;
+ in.skipRawData(2);
+ groups.append(info);
+
+ qDebug() << "Group name:" << info.name;
+ }
+
+ break;
+ }
+
+ case 'pai1': {
+ // Bits
+ QDataStream in(section.data);
+ InitDataStream(in);
+
+ quint8 loop;
+ quint16 fileCount, blockCount;
+ quint32 offsetOffset;
+
+ in >> frameSize;
+ in >> loop;
+ in.skipRawData(1);
+ in >> fileCount;
+ in >> blockCount;
+ in >> offsetOffset;
+
+ qDebug() << "Loop:" << loop << "- File count:" << fileCount << ", Block count:" << blockCount;
+ qDebug() << "Offset Offset:" << offsetOffset;
+
+ this->loop = (loop & 1);
+
+ importedFiles.reserve(fileCount);
+
+ for (int i = 0; i < fileCount; i++) {
+ quint32 offs;
+ in >> offs;
+
+ qint64 saveMe = in.device()->pos();
+ in.device()->seek(offs-8);
+ importedFiles.append(ReadVariableLengthASCII(in));
+ in.device()->seek(saveMe);
+
+ qDebug() << "Imported file:" << importedFiles.last();
+ }
+
+ // Now, each block
+ in.device()->seek(offsetOffset-8);
+ blocks.reserve(blockCount);
+
+ for (int i = 0; i < blockCount; i++) {
+ quint32 blockOffs;
+ in >> blockOffs;
+ qint64 saveInList = in.device()->pos();
+ in.device()->seek(blockOffs - 8);
+
+ // Block.
+ LYTAnimBlock block;
+ block.name = ReadFixedLengthASCII(in, 20);
+ quint8 pieceCount, type;
+ in >> pieceCount;
+ in >> type;
+ in.skipRawData(2);
+
+ block.isMaterial = (type == 1);
+
+ qDebug() << "Block @ " << QString::number(blockOffs,16) << ":" << block.name << "- Piece Count:" << pieceCount << "- Type:" << type << "IsMaterial:" << block.isMaterial;
+
+ // Now, the piece list
+ block.pieces.reserve(pieceCount);
+
+ for (int j = 0; j < pieceCount; j++) {
+ quint32 pieceOffs;
+ in >> pieceOffs;
+ qint64 saveInList2 = in.device()->pos();
+ in.device()->seek(blockOffs + pieceOffs - 8);
+
+ // Piece
+ LYTAnimPiece piece;
+ Magic pieceMagic(0);
+ in >> pieceMagic.value;
+
+ switch (pieceMagic.value) {
+ case 'RLPA': piece.type = piece.PaneAnim; break;
+ case 'RLTS': piece.type = piece.TexSRTAnim; break;
+ case 'RLVI': piece.type = piece.VisAnim; break;
+ case 'RLVC': piece.type = piece.VtxClrAnim; break;
+ case 'RLMC': piece.type = piece.MatClrAnim; break;
+ case 'RLTP': piece.type = piece.TexPatAnim; break;
+ case 'RLIM': piece.type = piece.IndTexSRTAnim; break;
+ }
+
+ quint8 entryCount;
+ in >> entryCount;
+ in.skipRawData(3);
+ qDebug("Piece: %c%c%c%c, Entry Count: %d", pieceMagic.str[3], pieceMagic.str[2], pieceMagic.str[1], pieceMagic.str[0], entryCount);
+
+ piece.entries.reserve(entryCount);
+
+ // ANOTHER LIST ARGHHHH
+ for (int k = 0; k < entryCount; k++) {
+ quint32 entryOffs;
+ in >> entryOffs;
+ qint64 saveInList3 = in.device()->pos();
+ in.device()->seek(blockOffs + pieceOffs + entryOffs - 8);
+
+ // Entry
+ LYTAnimEntry entry;
+ in >> entry.id;
+ in >> entry.target;
+ in >> entry.curveType;
+ in.skipRawData(1);
+
+ quint16 keyCount;
+ quint32 keyOffset;
+
+ in >> keyCount;
+ in.skipRawData(2);
+ in >> keyOffset;
+
+ qDebug() << "Entry ID:" << entry.id << "Target:" << entry.target << "CurveType:" << entry.curveType << "KeyCount:" << keyCount << "KeyOffset:" << keyOffset;
+
+ in.device()->seek(blockOffs + pieceOffs + entryOffs + keyOffset - 8);
+
+ if (piece.type == piece.TexPatAnim || piece.type == piece.VisAnim) {
+ entry.stepKeys.reserve(keyCount);
+
+ for (int l = 0; l < keyCount; l++) {
+ // Step Key
+ LYTAnimStepKey key;
+ in >> key.frame;
+ in >> key.value;
+ in.skipRawData(2);
+ qDebug() << "Step Key:" << key.frame << key.value;
+
+ entry.stepKeys.append(key);
+ }
+
+ } else {
+ entry.keys.reserve(keyCount);
+
+ for (int l = 0; l < keyCount; l++) {
+ // Key
+ LYTAnimHermiteKey key;
+ in >> key.frame;
+ in >> key.value;
+ in >> key.slope;
+ qDebug() << "Key:" << key.frame << key.value << key.slope;
+
+ entry.keys.append(key);
+ }
+ }
+
+ piece.entries.append(entry);
+ in.device()->seek(saveInList3);
+ }
+
+ block.pieces.append(piece);
+ in.device()->seek(saveInList2);
+ }
+
+ blocks.append(block);
+ in.device()->seek(saveInList);
+ }
+
+ break;
+ }
+
+ case 'pah1':
+ // Share
+ qFatal("AnimShare unsupported");
+ break;
+ }
+ }
+}
diff --git a/lyt/animation.h b/lyt/animation.h
new file mode 100644
index 0000000..efd626a
--- /dev/null
+++ b/lyt/animation.h
@@ -0,0 +1,68 @@
+#ifndef LYTANIMATION_H
+#define LYTANIMATION_H
+
+#include <QString>
+#include <QVector>
+#include <QList>
+#include <QStringList>
+
+struct LYTAnimGroupInfo {
+ QString name;
+ quint8 unusedFlag;
+};
+
+struct LYTAnimStepKey {
+ float frame;
+ quint16 value;
+};
+
+struct LYTAnimHermiteKey {
+ float frame, value, slope;
+};
+
+struct LYTAnimEntry {
+ quint8 id, target, curveType;
+ QVector<LYTAnimHermiteKey> keys;
+ QVector<LYTAnimStepKey> stepKeys;
+};
+
+struct LYTAnimPiece {
+ enum Type {
+ PaneAnim = 0,
+ TexSRTAnim,
+ VisAnim,
+ VtxClrAnim,
+ MatClrAnim,
+ TexPatAnim,
+ IndTexSRTAnim
+ };
+
+ Type type;
+ QList<LYTAnimEntry> entries;
+};
+
+struct LYTAnimBlock {
+ QString name;
+ bool isMaterial;
+ QList<LYTAnimPiece> pieces;
+};
+
+class LYTAnimation {
+public:
+ LYTAnimation(QByteArray data);
+ ~LYTAnimation();
+
+ QString name;
+ quint16 sourceTagNumber;
+ quint16 sourceStartFrame, sourceEndFrame;
+ bool recursiveBind;
+
+ QList<LYTAnimGroupInfo> groups;
+
+ quint16 frameSize;
+ bool loop;
+ QStringList importedFiles;
+ QList<LYTAnimBlock> blocks;
+};
+
+#endif // LYTANIMATION_H
diff --git a/lyt/materials/tevswaptable.cpp b/lyt/materials/tevswaptable.cpp
index a13a491..9121b78 100644
--- a/lyt/materials/tevswaptable.cpp
+++ b/lyt/materials/tevswaptable.cpp
@@ -50,10 +50,10 @@ void LYTTevSwapTable::readFromDataStream(QDataStream &in) {
quint8 val;
in >> (quint8&)val;
- mode[i].red = BitExtract(val, 2, 32 - 8);
- mode[i].green = BitExtract(val, 2, 32 - 6);
- mode[i].blue = BitExtract(val, 2, 32 - 4);
- mode[i].alpha = BitExtract(val, 2, 32 - 2);
+ mode[i].red = BitExtract(val, 2, 32 - 2);
+ mode[i].green = BitExtract(val, 2, 32 - 4);
+ mode[i].blue = BitExtract(val, 2, 32 - 6);
+ mode[i].alpha = BitExtract(val, 2, 32 - 8);
}
}
diff --git a/lyt/textbox.cpp b/lyt/textbox.cpp
index e943963..c845618 100644
--- a/lyt/textbox.cpp
+++ b/lyt/textbox.cpp
@@ -39,7 +39,7 @@ void LYTTextBox::dumpToDebug(bool showHeading) const {
qDebug() << "- Text:" << text;
qDebug() << "- Buffer Length:" << bufferLength;
qDebug() << "- Material:" << materialName << "- Font:" << fontName;
- qDebug() << "- Alignment:" << alignment << "- Alignment Override:" << alignmentOverride;
+ //qDebug() << "- Alignment:" << alignment << "- Alignment Override:" << alignmentOverride;
qDebug() << "- Colours:" << colour1 << "--" << colour2;
qDebug() << "- Font Size:" << fontSizeX << "x" << fontSizeY;
qDebug() << "- Char Space:" << charSpace << "- Line Space:" << lineSpace;
@@ -61,8 +61,8 @@ void LYTTextBox::writeToDataStream(QDataStream &out) const {
out << (quint16)materialNum;
out << (quint16)fontNum;
- out << (quint8)alignment;
- out << (quint8)alignmentOverride;
+ out << (quint8)(((int)textHorzPos) + (((int)textVertPos) * 3));
+ out << (quint8)alignment;
WritePadding(2, out);
@@ -110,8 +110,11 @@ void LYTTextBox::readFromDataStream(QDataStream &in) {
materialName = m_layout.materials.getNameOfIndex(materialNum);
fontName = m_layout.m_fontRefs.at(fontNum);
- in >> (quint8&)alignment;
- in >> (quint8&)alignmentOverride;
+ quint8 whatpos;
+ in >> (quint8&)whatpos;
+ textHorzPos = (OriginType)(whatpos % 3);
+ textVertPos = (OriginType)(whatpos / 3);
+ in >> (quint8&)alignment;
in.skipRawData(2); // padding
diff --git a/lyt/textbox.h b/lyt/textbox.h
index c61ef3a..564325d 100644
--- a/lyt/textbox.h
+++ b/lyt/textbox.h
@@ -42,8 +42,8 @@ public:
QString materialName;
QString fontName;
- quint8 alignment;
- quint8 alignmentOverride;
+ OriginType textHorzPos, textVertPos;
+ quint8 alignment;
QColor colour1;
QColor colour2;
diff --git a/main.cpp b/main.cpp
index e2fb2f7..a8ae533 100644
--- a/main.cpp
+++ b/main.cpp
@@ -15,9 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
-#include <QtGui/QApplication>
-#include "lsmainwindow.h"
-#include "lsglobals.h"
+#include <QCoreApplication>
#include "lyt/directorypackage.h"
#include "lyt/archivepackage.h"
@@ -27,60 +25,49 @@
#include "wii/archiveu8.h"
-#include "layoutgl/widget.h"
+#include <QDir>
-int main(int argc, char *argv[]) {
- QApplication a(argc, argv);
-
- LSGlobals::setup();
-
- LSMainWindow w;
- w.show();
-
- return a.exec();
-
- /*QFile file("H:\\ISOs\\NSMBWii\\Extracted\\Layout\\continue\\continue.arc");
- file.open(QFile::ReadOnly);
- QByteArray arc = file.readAll();
- file.close();*/
+#include "lsrlytexporter.h"
+#include <QFile>
+#include <QStringList>
+#include <cstdio>
- //LYTArchivePackage package("H:\\ISOs\\NSMBWii\\Extracted\\Layout\\continue\\continue.arc");
- QString blah1 = "preGame";
- //QString blah = "preGame/preGame.arc";
- QString blah = QString("%1/%1.arc").arg(blah1);
- QString cpath;
- if (QFile::exists("/home/me/Games/Newer/ISO/files/Layout/" + blah)) {
- cpath = "/home/me/Games/Newer/ISO/files/Layout/" + blah;
+#include "lyt/animation.h"
+int main(int argc, char *argv[]) {
+ QCoreApplication a(argc, argv);
+
+ QStringList args = a.arguments();
+ if (args.count() == 4 && args.at(1) == "export") {
+ LYTArchivePackage eArc(args.at(2));
+ LSExportPackage(&eArc, args.at(3));
+ } else if (args.count() == 4 && args.at(1) == "export-dir") {
+ QDir dir(args.at(2));
+ QDir outDir(args.at(3));
+ QStringList filters("*.arc");
+ QStringList things = dir.entryList(filters);
+ foreach (const QString &thing, things) {
+ LYTArchivePackage eArc(dir.filePath(thing));
+ QString niceName = thing;
+ niceName.replace(".arc", "");
+ LSExportPackage(&eArc, outDir.filePath("exp_"+niceName));
+ }
+ } else if (args.count() == 4 && args.at(1) == "export-nsmb") {
+ QDir dir(args.at(2));
+ QDir outDir(args.at(3));
+ QStringList filters("*.arc");
+ QStringList things = dir.entryList(filters);
+ foreach (const QString &thing, things) {
+ QString niceName = thing;
+ niceName.replace(".arc", "");
+ QDir inDir = dir;
+ inDir.cd(niceName);
+ LYTArchivePackage eArc(inDir.filePath(thing));
+ LSExportPackage(&eArc, outDir.filePath("exp_"+niceName));
+ }
} else {
- cpath = "Z:\\stuff\\Games\\Newer\\ISO\\files\\Layout\\" + blah;
+ std::printf("LayoutStudio command-line un-exporter");
}
- LYTArchivePackage package(cpath);
- LYTLayout layout(package, package.listLayouts().first());
- //LYTLayout layout(package, "continue_05.brlyt");
- //QByteArray brlyt = layout.pack();
- //QFile file("H:\\ISOs\\NSMBWii\\Extracted\\Layout\\continue\\continue\\arc\\blyt\\continue_05_repack.brlyt");
- //file.open(QFile::WriteOnly);
- //file.write(brlyt);
- //file.close();
- //package.writeLayout("continue_05.brlyt", brlyt);
- //package.savePackage();
-
-
- //LYTDirectoryPackage package("H:\\ISOs\\NSMBWii\\Extracted\\Layout\\continue\\continue\\arc");
- //LYTLayout layout(package, "continue_05.brlyt");
- //LYTDirectoryPackage package("H:\\ISOs\\TP\\banner\\arc_extr");
- //LYTDirectoryPackage package("/mnt/h/ISOs/TP/banner/arc_extr");
- //LYTDirectoryPackage package("/mnt/h/ISOs/hbm/InetChannelNew/0001000148414450/00000000_app_OUT/meta/banner_bin_OUT/arc");
- //LYTDirectoryPackage package("/mnt/h/ISOs/CSWii/BannerTools/0001000157435645/00000000_app_OUT/meta/banner_bin_OUT/arc");
- //LYTLayout layout(package, "banner.brlyt");
-
- //LSMainWindow w;
- w.show();
-
- LGLWidget w2;
- w2.setLayout(&layout);
- w2.show();
- return a.exec();
+ return 0;
}
diff --git a/resources.qrc b/resources.qrc
deleted file mode 100644
index 15cc40a..0000000
--- a/resources.qrc
+++ /dev/null
@@ -1,9 +0,0 @@
-<RCC>
- <qresource prefix="/icons">
- <file alias="bounding">icons/bounding.png</file>
- <file alias="pane">icons/pane.png</file>
- <file alias="picture">icons/picture.png</file>
- <file alias="textbox">icons/textbox.png</file>
- <file alias="window">icons/window.png</file>
- </qresource>
-</RCC>
diff --git a/wii/common.cpp b/wii/common.cpp
index 8f552b3..4ea59a0 100644
--- a/wii/common.cpp
+++ b/wii/common.cpp
@@ -131,4 +131,27 @@ void WriteFixedLengthASCII(QDataStream &out, const QString str, int length) {
out.writeRawData(paddedStr.constData(), paddedStr.length());
}
+QString ReadVariableLengthASCII(QDataStream &in) {
+ qint64 savedPos = in.device()->pos();
+ int stringLength = 0;
+ char check;
+
+ in >> (quint8&)check;
+ while (check != 0) {
+ stringLength += 1;
+ in >> (quint8&)check;
+ }
+
+ // now read the string
+ char *buffer = new char[stringLength];
+
+ in.device()->seek(savedPos);
+ in.readRawData(buffer, stringLength);
+
+ QString output = QString::fromAscii(buffer, stringLength);
+
+ delete[] buffer;
+
+ return output;
+}
diff --git a/wii/common.h b/wii/common.h
index b440841..792ae27 100644
--- a/wii/common.h
+++ b/wii/common.h
@@ -108,4 +108,6 @@ void WriteStringList(QDataStream &out, QStringList list);
QString ReadFixedLengthASCII(QDataStream &in, int length);
void WriteFixedLengthASCII(QDataStream &out, QString str, int length);
+QString ReadVariableLengthASCII(QDataStream &in);
+
#endif // WIICOMMON_H