Skip to content

Commit

Permalink
Copy generated files to user defined destination
Browse files Browse the repository at this point in the history
  • Loading branch information
RicBent committed Sep 11, 2018
1 parent 656f26e commit 0bc47d0
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
9 changes: 7 additions & 2 deletions MagikoopaUI/mainwindow.cpp
Expand Up @@ -76,10 +76,15 @@ void MainWindow::appendOutput(const QString& catergory, const QString& text, boo
addIssue(logText, Error);
break;
}
else if (lowerLine.contains("undefined reference to"))
{
addIssue(logText, Error, false);
break;
}
}
}

void MainWindow::addIssue(QString text, IssueType type)
void MainWindow::addIssue(QString text, IssueType type, bool removeLabel)
{
QString iconPath = QCoreApplication::applicationDirPath() + "/magikoopa_data/icons/";
if (type == Warning) iconPath += "warning.png";
Expand All @@ -101,7 +106,7 @@ void MainWindow::addIssue(QString text, IssueType type)
if (ok) column = column_;
}

QString message = text.mid(text.indexOf(' ', index+1));
QString message = text.mid(removeLabel ? text.indexOf(' ', index+1) : index+1);

QListWidgetItem* item = new QListWidgetItem(QIcon(iconPath), QString("%1\n%2, Line %3").arg(message).arg(path).arg(line));
item->setData(Qt::UserRole, path);
Expand Down
2 changes: 1 addition & 1 deletion MagikoopaUI/mainwindow.h
Expand Up @@ -48,7 +48,7 @@ private slots:

void setWorkingDirectory(const QString& path);

void addIssue(QString text, IssueType type);
void addIssue(QString text, IssueType type, bool removeLabel = true);
int m_issueCount;

void clearIssues();
Expand Down
42 changes: 42 additions & 0 deletions MagikoopaUI/patchmaker.cpp
Expand Up @@ -13,6 +13,7 @@
#include <QStringList>
#include <QMessageBox>
#include <QTextStream>
#include <QSettings>

#include "Filesystem/filesystem.h"
#include "exheader.h"
Expand Down Expand Up @@ -129,6 +130,7 @@ void PatchMaker::loaderCompilerDone(int exitCode)
m_loaderHookLinker.clear();
m_loaderHookLinker.setSymTable(&m_loaderSymTable);
m_loaderHookLinker.loadHooks(m_path + "/loader/source");
m_loaderHookLinker.loadHooks(m_path + "/loader/hooks");

quint32 loaderInsertSize = m_loaderSymTable.get("__text_end") - m_loaderSymTable.get("__text_start") + m_loaderHookLinker.extraDataSize();
if (loaderInsertSize > m_loaderMaxSize)
Expand Down Expand Up @@ -384,6 +386,46 @@ void PatchMaker::fixExheader(quint32 newCodeSize)

exHeader.save();

postHook();
}

void PatchMaker::postHook()
{
QFileInfo fInfo(m_path);
QString projName = fInfo.baseName();

// TODO: Make proper project system
QSettings userSetting(m_path + "/" + projName + ".mkproj.user", QSettings::IniFormat);
userSetting.beginGroup("CopyPaths");
m_codeCopyPath = userSetting.value("Code", "").toString();
m_exheaderCopyPath = userSetting.value("Exheader", "").toString();
userSetting.endGroup();

if (!m_codeCopyPath.isEmpty())
{
QFile dest(m_codeCopyPath);
if (dest.exists())
dest.remove();

QFile codeFile(m_path + "/code.bin");
codeFile.copy(m_codeCopyPath);
}

if (!m_exheaderCopyPath.isEmpty())
{
QFile dest(m_exheaderCopyPath);
if (dest.exists())
dest.remove();

QFile exheaderFile(m_path + "/exheader.bin");
exheaderFile.copy(m_exheaderCopyPath);
}

allDone();
}

void PatchMaker::allDone()
{
emit setBusy(false);
emit updateStatus("All done");
}
Expand Down
5 changes: 5 additions & 0 deletions MagikoopaUI/patchmaker.h
Expand Up @@ -47,6 +47,8 @@ private slots:

void insert();
void fixExheader(quint32 newCodeSize);
void postHook();
void allDone();

static quint32 makeBranchOpcode(quint32 src, quint32 dest, bool link);

Expand All @@ -67,6 +69,9 @@ private slots:
quint32 m_loaderMaxSize;
quint32 m_newCodeOffset;
quint32 m_loaderDataOffset;

QString m_codeCopyPath;
QString m_exheaderCopyPath;
};

#endif // PATCHMAKER_H

0 comments on commit 0bc47d0

Please sign in to comment.