Skip to content

Commit

Permalink
Merge pull request #18 from JC3/dev
Browse files Browse the repository at this point in the history
1.7.1 copy as emoji
  • Loading branch information
JC3 authored May 7, 2023
2 parents bd142ce + 9444275 commit 80694ca
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 15 deletions.
53 changes: 53 additions & 0 deletions blueprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,56 @@ void Blueprint::generateBlueprintString () const {
bpString_ = "VCB+AAAA" + QString::fromLatin1(hashBase64) + QString::fromLatin1(rawBase64);

}


QString Blueprint::toDiscordEmoji () const {

static const QMap<Ink,QString> EmojiMap = {
{ And, "and" },
{ Annotation, "ann" },
{ Buffer, "bfr" },
{ Cross, "crs" },
{ Filler, "fil" },
{ LED, "led" },
{ LatchOff, "lt0" },
{ LatchOn, "lt1" },
{ Nand, "nan" },
{ Nor, "nor" },
{ Not, "not" },
{ Or, "or" },
{ Read, "rd" },
{ Write, "wr" },
{ Xnor, "xnr" },
{ Xor, "xor" },
{ Trace1, "t00" },
{ Trace2, "t01" },
{ Trace3, "t02" },
{ Trace4, "t03" },
{ Trace5, "t04" },
{ Trace6, "t05" },
{ Trace7, "t06" },
{ Trace8, "t07" },
{ Trace9, "t08" },
{ Trace10, "t09" },
{ Trace11, "t10" },
{ Trace12, "t11" },
{ Trace13, "t12" },
{ Trace14, "t13" },
{ Trace15, "t14" },
{ Trace16, "t15" },
{ Empty, "pd" }
};

QString emojistr = ":pd:\n";
for (int y = 0; y < height(); ++ y) {
for (int x = 0; x < width(); ++ x) {
Ink ink = get(x, y);
emojistr += ":" + EmojiMap.value(ink, "vcb") + ":";
}
emojistr += "\n";
}

return emojistr;

}

15 changes: 15 additions & 0 deletions blueprint.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,25 @@ class Blueprint : public QObject {
int height () const { return layers_.first().height(); }
Ink getPixel (Layer which, int x, int y) const;
Ink get (int x, int y) const { return getPixel(Logic, x, y); }
// utilities
QString toDiscordEmoji () const;
private:
mutable QString bpString_;
QMap<Layer,QImage> layers_;
void generateBlueprintString () const;
};

inline bool operator < (const Blueprint::Ink &a, const Blueprint::Ink &b) {
if (a.red() != b.red())
return a.red() < b.red();
else if (a.green() != b.green())
return a.green() < b.green();
else if (a.blue() != b.blue())
return a.blue() < b.blue();
else if (a.alpha() != b.alpha())
return a.alpha() < b.alpha();
else
return false;
}

#endif // BLUEPRINT_H
13 changes: 0 additions & 13 deletions compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,19 +286,6 @@ void Compiler::compileBlueprint (const Blueprint *bp) {

}

static bool operator < (const QColor &a, const QColor &b) {
if (a.red() != b.red())
return a.red() < b.red();
else if (a.green() != b.green())
return a.green() < b.green();
else if (a.blue() != b.blue())
return a.blue() < b.blue();
else if (a.alpha() != b.alpha())
return a.alpha() < b.alpha();
else
return false;
}

Compiler::Component Compiler::Comp (Blueprint::Ink ink) {

static const QMap<Blueprint::Ink,Component> m = {
Expand Down
12 changes: 12 additions & 0 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ void MainWindow::on_btnConvertBP_clicked()
}


void MainWindow::on_btnConvertEmoji_clicked()
{
try {
Blueprint bp(ui_->txtConvertedBP->toPlainText());
QString emoji = bp.toDiscordEmoji();
QGuiApplication::clipboard()->setText(emoji);
} catch (const std::exception &x) {
QMessageBox::critical(this, "Error", x.what());
}
}


void MainWindow::on_btnLoadROMFile_clicked()
{
try {
Expand Down
2 changes: 2 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ private slots:

void on_btnMiscX11_clicked();

void on_btnConvertEmoji_clicked();

private:

struct FontDesc {
Expand Down
9 changes: 8 additions & 1 deletion mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<widget class="QWidget" name="tabConvert">
<attribute name="title">
Expand Down Expand Up @@ -48,6 +48,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnConvertEmoji">
<property name="text">
<string>Copy As Discord Emoji</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
Expand Down
2 changes: 1 addition & 1 deletion vcbtool.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
QMAKE_TARGET_DESCRIPTION = "VCB Tool"
VERSION = 1.7.0
VERSION = 1.7.1
DEFINES += VCBTOOL_VERSION='\\"$$VERSION\\"'

QT += core gui
Expand Down

0 comments on commit 80694ca

Please sign in to comment.