Skip to content

Commit

Permalink
updated for 1.4.4.9, added editor and xnb2png utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkite committed Jan 23, 2023
1 parent 5511698 commit 7e1f500
Show file tree
Hide file tree
Showing 51 changed files with 4,382 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ build/
[Bb]in/
[Oo]bj/
[Tt]erra[Ff]irma.app/
build-*

# Visual Studio profiler
*.psess
Expand Down
2 changes: 1 addition & 1 deletion config/config.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Installer>
<Name>Terrafirma</Name>
<Version>3.1.9</Version>
<Version>3.1.10</Version>
<Title>Terrafirma Installer</Title>
<Publisher>Sean Kasun</Publisher>
<StartMenuDir>Terrafirma</StartMenuDir>
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
terrafirma (3.1.10) focal; urgency=medium

* Updated for 1.4.4.9

-- Sean Kasun <[email protected]> Sun, 22 Jan 2023 23:12:35 -0700

terrafirma (3.1.9) focal; urgency=medium

* Updated for 1.4.3.6
Expand Down
44 changes: 44 additions & 0 deletions editor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
cmake_minimum_required(VERSION 3.16)

project(editor VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6 REQUIRED COMPONENTS Widgets)
qt_standard_project_setup()

add_executable(editor
tfcfg.cpp
tfcfg.ui
tileeditor.cpp
tileeditor.ui
tilevareditor.cpp
tilevareditor.ui
walleditor.cpp
walleditor.ui
itemeditor.cpp
itemeditor.ui
prefixeditor.cpp
prefixeditor.ui
npceditor.cpp
npceditor.ui
globaleditor.cpp
globaleditor.ui
headereditor.cpp
headereditor.ui
main.cpp
)

qt_add_resources(editor "data"
PREFIX "/data"
FILES ../res/tiles.json ../res/walls.json ../res/items.json
../res/prefixes.json ../res/npcs.json ../res/globals.json ../res/header.json)

target_link_libraries(editor PRIVATE
Qt6::Widgets)

set_target_properties(editor PROPERTIES
WIN32_EXECUTABLE ON
MACOSX_BUNDLE ON
)
43 changes: 43 additions & 0 deletions editor/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
This is the editor for terrafirma config files.

Here are the terraria class points of interest:

Terraria.IO.WorldFile.LoadWorld_Version2

Terraria.ID.ItemID

Terraria.ID.NPCID
Terraria.ID.NPCHeadID

Terraria.Terraria.Item
this.createTile = 137;
this.DefaultToPlaceableTile(629, 0);

Terraria.ID.TileID
for missing tile id names

Terraria.ID.WallID
for missing wall id names

Terraria.ID.TileID.Sets
DrawFlipMode - flip flag
ChecksForMerge - merge flag
Grass - grass flag

Terraria.ID.WallID.Sets
BlendType - blend

Terraria.Terraria.Main
Main.tileSolid - solid flag
Main.tileStone - stone flag
Main.tilePile - pile flag
Main.tileMergeDirt - dirt flag
Main.tileBrick - brick flag
Main.tileMoss - moss flag
Main.tileLargeFrames - large flag
Main.tileBlockLight - !trans flag
Main.wallLargeFrames - Large number
BannerToItem() - NPC Banner

Terraria.Graphics.Light
TileLightScanner.ApplyTileLight() - light
30 changes: 30 additions & 0 deletions editor/globaleditor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/** @copyright 2023 Sean Kasun */
#include <QColorDialog>
#include "globaleditor.h"
#include "ui_globaleditor.h"

GlobalEditor::GlobalEditor(QJsonObject obj, QWidget *parent) : QDialog(parent), ui(new Ui::GlobalEditor), obj(obj) {
ui->setupUi(this);
ui->id->setText(obj["id"].toString());
ui->color->setText(obj["color"].toString());
}

GlobalEditor::~GlobalEditor() {
delete ui;
}

void GlobalEditor::changeColor() {
QColor orig = QColor(obj["color"].toString("#000000"));
auto color = QColorDialog::getColor(orig, this);
if (color.isValid()) {
ui->color->setText(color.name());
}
}

void GlobalEditor::done(int r) {
if (r == QDialog::Accepted) {
obj["id"] = ui->id->text();
obj["color"] = ui->color->text();
}
QDialog::done(r);
}
25 changes: 25 additions & 0 deletions editor/globaleditor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/** @copyright 2023 Sean Kasun */
#pragma once

#include <QDialog>
#include <QJsonObject>

namespace Ui {
class GlobalEditor;
}

class GlobalEditor : public QDialog {
Q_OBJECT

public:
explicit GlobalEditor(QJsonObject obj, QWidget *parent = nullptr);
~GlobalEditor();
QJsonObject obj;

public slots:
void changeColor();
void done(int r);

private:
Ui::GlobalEditor *ui;
};
107 changes: 107 additions & 0 deletions editor/globaleditor.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GlobalEditor</class>
<widget class="QDialog" name="GlobalEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>115</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="iDLabel">
<property name="text">
<string>ID</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="id"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="colorLabel">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="color"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>GlobalEditor</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>GlobalEditor</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>color</sender>
<signal>clicked()</signal>
<receiver>GlobalEditor</receiver>
<slot>changeColor()</slot>
<hints>
<hint type="sourcelabel">
<x>220</x>
<y>53</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>57</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>changeColor()</slot>
</slots>
</ui>
42 changes: 42 additions & 0 deletions editor/headereditor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/** @copyright 2023 Sean Kasun */
#include "headereditor.h"
#include "ui_headereditor.h"

HeaderEditor::HeaderEditor(QJsonObject obj, QWidget *parent) : QDialog(parent), ui(new Ui::HeaderEditor), obj(obj) {
ui->setupUi(this);
ui->name->setText(obj["name"].toString());
ui->type->setCurrentText(obj["type"].toString());
if (obj.contains("num")) {
ui->array->setText(tr("%1").arg(obj["num"].toInt()));
} else {
ui->array->setText(obj["relnum"].toString());
}
ui->min->setText(tr("%1").arg(obj["min"].toInt(88)));
}

HeaderEditor::~HeaderEditor() {
delete ui;
}

void HeaderEditor::done(int r) {
if (r == QDialog::Accepted) {
obj["name"] = ui->name->text();
obj["type"] = ui->type->currentText();
obj.remove("num");
obj.remove("relnum");
bool isNum;
auto num = ui->array->text().toInt(&isNum);
if (isNum) {
obj["num"] = num;
} else if (!ui->array->text().isEmpty()) {
obj["relnum"] = ui->array->text();
}
auto min = ui->min->text().toInt();
if (min == 88) {
obj.remove("min");
} else {
obj["min"] = min;
}
}
QDialog::done(r);
}
24 changes: 24 additions & 0 deletions editor/headereditor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/** @copyright 2023 Sean Kasun */
#pragma once

#include <QDialog>
#include <QJsonObject>

namespace Ui {
class HeaderEditor;
}

class HeaderEditor : public QDialog {
Q_OBJECT

public:
explicit HeaderEditor(QJsonObject obj, QWidget *parent = nullptr);
~HeaderEditor();
QJsonObject obj;

public slots:
void done(int r);

private:
Ui::HeaderEditor *ui;
};
Loading

0 comments on commit 7e1f500

Please sign in to comment.