Skip to content

Commit

Permalink
添加最终结果显示对话框(点击结果图标弹出)并修复基岩版计算错误的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinosaur-MC committed Oct 11, 2024
1 parent 2a28470 commit c2fd797
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
9 changes: 7 additions & 2 deletions calculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,13 @@ void Calculator::Alg_Hamming()
{
while(item_triangle.at(i).count() > 1)
{
Item tm = item_triangle[i].takeFirst();
flow[flow_step++] = ItemPool::preForge(tm, item_triangle[i].takeFirst(), additional_mode);
Item a = item_triangle[i].takeFirst();
Item b = item_triangle[i].takeFirst();
flow[flow_step++] = ItemPool::preForge(a, b, additional_mode);
}
if (item_triangle.at(i).count() == 1 && i + 1 < item_triangle.count())
{
item_triangle[i + 1].append(item_triangle[i].takeFirst());
}
}
Step s = flow[flow_step - 1];
Expand Down
8 changes: 2 additions & 6 deletions itempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ Step ItemPool::preForge(Item A, Item B, ForgeMode mode)
cost += Basic::ench_table[Basic::searchTable(B.ench[i].name)].multiplier[0] * combine(B.ench[i].name, A.ench[q].lvl, B.ench[i].lvl);
} else {
if (B.name == ID_ECB)
cost += Basic::ench_table[Basic::searchTable(B.ench[i].name)].multiplier[1] * (combine(B.ench[i].name, A.ench[q].lvl, B.ench[i].lvl - A.ench[i].lvl));
cost += Basic::ench_table[Basic::searchTable(B.ench[i].name)].multiplier[1] * (combine(B.ench[i].name, A.ench[q].lvl, B.ench[i].lvl) - A.ench[i].lvl);
else
cost += Basic::ench_table[Basic::searchTable(B.ench[i].name)].multiplier[0] * (combine(B.ench[i].name, A.ench[q].lvl, B.ench[i].lvl - A.ench[i].lvl));
cost += Basic::ench_table[Basic::searchTable(B.ench[i].name)].multiplier[0] * (combine(B.ench[i].name, A.ench[q].lvl, B.ench[i].lvl) - A.ench[i].lvl);
}
} else {
if (B.name == ID_ECB)
Expand Down Expand Up @@ -406,10 +406,6 @@ Item ItemPool::forge(Item A, Item B)
int q = Basic::searchEnch(A.ench, A_el, B.ench[i].name);
if (q != -1) {
A.ench[q].lvl = combine(B.ench[i].name, A.ench[q].lvl, B.ench[q].lvl);
// if(A.ench[q].lvl == B.ench[i].lvl && A.ench[q].lvl != Basic::ench_table[Basic::searchTable(A.ench[q].name)].mlvl)
// A.ench[q].lvl++;
// else if(A.ench[q].lvl < B.ench[i].lvl)
// A.ench[q].lvl = B.ench[i].lvl;
} else {
int k = 0;
while (k < INIT_LENGTH && A.ench[k].name != "")
Expand Down
28 changes: 28 additions & 0 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#include <QUrl>
#include <QDesktopServices>
#include <QTextEdit>
#include <QLayout>

using namespace std;

Expand Down Expand Up @@ -204,7 +206,33 @@ MainWindow::MainWindow(QWidget *parent)
FileOperate fo;
fo.saveExport();
});
connect(ui->OutputItem, &QPushButton::clicked, this, [=](){
QString info;
info += "- Name: " + Basic::OutputItem.name.replace('\n', ' ') + "\n";
info += "- Durability: " + QString::number(Basic::OutputItem.duration) + "\n";
info += "- Penalty: " + QString::number(Basic::OutputItem.penalty) + "\n";
info += "- Enchs: \n";
for (int i = 0; i < INIT_LENGTH; i++)
{
if (Basic::OutputItem.ench[i].name.isEmpty())
break;
info += "\t- " + Basic::OutputItem.ench[i].name + " " + Basic::IntToRoman(Basic::OutputItem.ench[i].lvl) + "\n";
}

QDialog dialog(this);
dialog.setWindowTitle("Details");
QPoint p = this->geometry().center();
dialog.setGeometry(p.x() - 256, p.y() - 256, 512, 512);
QVBoxLayout layout(&dialog);
layout.setContentsMargins(8, 8, 8, 8);
QTextEdit text(&dialog);
layout.addWidget(&text);
text.setMarkdown(info);
text.setReadOnly(true);
dialog.setModal(true);
dialog.show();
dialog.exec();
});

//Initialze & Load Files
initialize();
Expand Down

0 comments on commit c2fd797

Please sign in to comment.