Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cubiomes-viewer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ SOURCES += \
src/tabbiomes.cpp \
src/tablocations.cpp \
src/tabstructures.cpp \
src/tabslime.cpp \
src/mainwindow.cpp \
src/main.cpp \
src/util.cpp \
Expand Down Expand Up @@ -197,6 +198,7 @@ HEADERS += \
src/tabbiomes.h \
src/tablocations.h \
src/tabstructures.h \
src/tabslime.h \
src/mainwindow.h \
src/util.h \
src/widgets.h \
Expand All @@ -220,7 +222,8 @@ FORMS += \
src/rangedialog.ui \
src/tabbiomes.ui \
src/tablocations.ui \
src/tabstructures.ui
src/tabstructures.ui \
src/tabslime.ui

RESOURCES += \
rc/icons.qrc \
Expand Down
Binary file modified rc/lang/zh_CN.qm
Binary file not shown.
704 changes: 468 additions & 236 deletions rc/lang/zh_CN.ts

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions src/gotodialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QClipboard>
#include <QDoubleValidator>
#include <QKeyEvent>
#include <QRegularExpression>

static bool g_animate;

Expand Down Expand Up @@ -34,6 +35,59 @@ GotoDialog::~GotoDialog()
delete ui;
}

bool GotoDialog::parseCoordinates(const QString &input, qreal &x, qreal &z)
{
QString text = input.trimmed();
if (text.isEmpty())
return false;

// 移除 /tp 命令前缀(如果存在)
if (text.startsWith("/tp", Qt::CaseInsensitive))
{
text = text.mid(3).trimmed();
}

// 使用正则表达式提取所有数字
QRegularExpression numberRegex("-?\\d+\\.?\\d*");
QRegularExpressionMatchIterator matches = numberRegex.globalMatch(text);

QList<qreal> numbers;
while (matches.hasNext())
{
QRegularExpressionMatch match = matches.next();
bool ok;
qreal num = match.captured().toDouble(&ok);
if (ok)
{
numbers.append(num);
}
}

// 需要至少2个数字(x和z)
if (numbers.size() < 2)
return false;

// 第一个数字是x,最后一个数字是z(忽略中间的y坐标)
x = numbers.first();
z = numbers.last();

return true;
}

void GotoDialog::on_buttonInterpret_clicked()
{
QString coordInput = ui->lineCoordInput->text().trimmed();
if (!coordInput.isEmpty())
{
qreal x, z;
if (parseCoordinates(coordInput, x, z))
{
ui->lineX->setText(QString::asprintf("%.1f", x));
ui->lineZ->setText(QString::asprintf("%.1f", z));
}
}
}

void GotoDialog::on_buttonBox_clicked(QAbstractButton *button)
{
QDialogButtonBox::StandardButton b = ui->buttonBox->standardButton(button);
Expand All @@ -57,6 +111,7 @@ void GotoDialog::on_buttonBox_clicked(QAbstractButton *button)
ui->lineX->setText("0");
ui->lineZ->setText("0");
ui->lineScale->setText("16");
ui->lineCoordInput->clear();
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/gotodialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class GotoDialog : public QDialog
private slots:
void on_lineScale_textChanged(const QString &text);
void on_buttonBox_clicked(QAbstractButton *button);
void on_buttonInterpret_clicked();

private:
bool parseCoordinates(const QString &input, qreal &x, qreal &z);

private:
Ui::GotoDialog *ui;
Expand Down
33 changes: 33 additions & 0 deletions src/gotodialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
<ui version="4.0">
<class>GotoDialog</class>
<widget class="QDialog" name="GotoDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>344</width>
<height>149</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
Expand All @@ -20,6 +28,31 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_coordInput">
<item>
<widget class="QLabel" name="label_coordInput">
<property name="text">
<string>coord text:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineCoordInput">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonInterpret">
<property name="text">
<string>Interpret</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="frame">
<layout class="QHBoxLayout" name="horizontalLayout">
Expand Down
57 changes: 51 additions & 6 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "presetdialog.h"
#include "tabbiomes.h"
#include "tablocations.h"
#include "tabslime.h"
#include "tabstructures.h"
#include "util.h"
#include "world.h"
Expand All @@ -33,6 +34,7 @@
#include <QLibraryInfo>
#include <QMenu>
#include <QMetaType>
#include <QSet>
#include <QSettings>
#include <QStandardPaths>
#include <QTreeWidget>
Expand Down Expand Up @@ -97,6 +99,7 @@ MainWindow::MainWindow(QString sessionpath, QString resultspath, QWidget *parent
ui->tabContainerSearch->addTab(new TabLocations(this), tr("Locations"));
ui->tabContainer->addTab(new TabBiomes(this), tr("Biomes"));
ui->tabContainer->addTab(new TabStructures(this), tr("Structures"));
ui->tabContainer->addTab(new TabSlime(this), tr("Slime"));

laction.resize(LOPT_MAX);
laction[LOPT_BIOMES] = ui->actionBiomes;
Expand Down Expand Up @@ -891,14 +894,42 @@ void MainWindow::on_actionRedistribute_triggered()
std::vector<Condition> conds = formCond->getConditions();
if (!conds.empty())
{
// Collect save IDs of quad conditions (main conditions)
QSet<int> quadMainIds;
for (const Condition& c : conds)
{
const FilterInfo& ft = g_filterinfo.list[c.type];
if (ft.cat == CAT_QUAD)
quadMainIds.insert(c.save);
}

// Filter out auto-generated second conditions for quad conditions
// These are F_HUT or F_MONUMENT with count=4, rmax=256, and relative pointing to a quad main condition
std::vector<Condition> filteredConds;
for (const Condition& c : conds)
{
bool isAutoGenerated = false;
if ((c.type == F_HUT || c.type == F_MONUMENT) && c.count == 4 && c.rmax == 256)
{
if (c.relative > 0 && quadMainIds.contains(c.relative))
{
isAutoGenerated = true;
}
}
if (!isAutoGenerated)
{
filteredConds.push_back(c);
}
}

QMap<int, int> ids;
for (int i = 0, n = conds.size(); i < n; i++)
ids.insert(conds[i].save, ids.size()+1);
for (int i = 0, n = conds.size(); i < n; i++)
if (conds[i].relative && !ids.contains(conds[i].relative))
ids.insert(conds[i].relative, ids.size()+1);
for (int i = 0, n = filteredConds.size(); i < n; i++)
ids.insert(filteredConds[i].save, ids.size()+1);
for (int i = 0, n = filteredConds.size(); i < n; i++)
if (filteredConds[i].relative && !ids.contains(filteredConds[i].relative))
ids.insert(filteredConds[i].relative, ids.size()+1);
formCond->on_buttonRemoveAll_clicked();
for (Condition& c : conds)
for (Condition& c : filteredConds)
{
c.save = ids[c.save];
c.relative = ids[c.relative];
Expand Down Expand Up @@ -1091,6 +1122,20 @@ void MainWindow::onActionMapToggled(int sopt, bool show)
if (sopt == D_PORTAL) // overworld portals should also control nether
getMapView()->setShow(D_PORTALN, show);
getMapView()->setShow(sopt, show);

// 当关闭史莱姆区块显示时,清除TabSlime中绘制的红圈
if (sopt == D_SLIME && !show)
{
for (int i = 0; i < ui->tabContainer->count(); i++)
{
TabSlime *tabSlime = qobject_cast<TabSlime*>(ui->tabContainer->widget(i));
if (tabSlime)
{
tabSlime->clearSlimeShapes();
break;
}
}
}
}

void MainWindow::onActionBiomeLayerSelect(int mode, int disp)
Expand Down
Loading