Skip to content

Commit

Permalink
Several fixes for 4.0 + github actions
Browse files Browse the repository at this point in the history
* fixed several bugs with the 4.0 changes
* fixed headless mode, so the eventloop actually starts
* added github action for a windows build
* removed triggers tab
* updated metainfo
  • Loading branch information
Cubitect committed Jan 21, 2024
1 parent 01fa706 commit fa28986
Show file tree
Hide file tree
Showing 23 changed files with 534 additions and 219 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/windows-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Windows Release

on:
push:
branches:
- 'main'
tags:
- 'v*'

defaults:
run:
shell: cmd

env:
PROG: cubiomes-viewer
SOURCE_DIR: ${{github.workspace}}

jobs:
build:
runs-on: windows-2019

steps:
- name: (1) Checkout repo
uses: actions/checkout@v4
with:
submodules: recursive

- name: (2) Get all tags for correct version determination
working-directory: ${{env.SOURCE_DIR}}
run: |
git fetch --all --tags -f
- name: (3) Install Qt
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: '5.15.2'
host: 'windows'
target: 'desktop'
arch: 'win64_mingw81'
archives: 'x86_64 qtbase qttools'
cache: true
setup-python: false

- name: (4) Build
working-directory: ${{env.SOURCE_DIR}}
run: |
qmake CONFIG+=release ${{env.SOURCE_DIR}}
mingw32-make
- name: (5) Deploy
working-directory: ${{env.SOURCE_DIR}}
run: |
mkdir ${{env.PROG}}
copy ${{env.SOURCE_DIR}}\release\${{env.PROG}}.exe ${{env.PROG}}
windeployqt --dir ${{env.PROG}} ${{env.SOURCE_DIR}}\release\${{env.PROG}}.exe --compiler-runtime --no-translations --no-system-d3d-compiler --no-opengl-sw --no-angle
- name: (6) Save build artifact
uses: actions/upload-artifact@v4
with:
name: ${{env.PROG}}-${{github.ref_name}}-win
path: ${{env.SOURCE_DIR}}\${{env.PROG}}

2 changes: 1 addition & 1 deletion etc/com.github.cubitect.cubiomes-viewer.desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Desktop Entry]
Type=Application
Name=Cubiomes Viewer
Comment=An efficient graphical Minecraft seed finder and map viewer
Comment=Minecraft seed finder and map viewer
Exec=cubiomes-viewer
Icon=com.github.cubitect.cubiomes-viewer
Terminal=false
Expand Down
19 changes: 16 additions & 3 deletions etc/com.github.cubitect.cubiomes-viewer.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,26 @@

<developer_name>Cubitect</developer_name>
<name>Cubiomes Viewer</name>
<summary>An efficient Minecraft seed finder and map viewer.</summary>
<summary>Minecraft seed finder and map viewer</summary>
<description>
<p>Cubiomes Viewer offers highly customizable seed-finding utilities and a map viewer for the biome and structure generation of Minecraft Java Edition for the main releases up to 1.21.</p>
<p>Cubiomes Viewer offers highly customizable seed-finding utilities and a map viewer for the biome and structure generation of Minecraft Java Edition for the main releases up to 1.20.</p>
</description>

<releases>
<release version="4.0.dev0" date="2024-01.??">
<release version="4.0.0" date="2024-01-??">
<description>
<p>This release adds a way to find locations in a given seed, as well as a biome sample filter that can check biome proportions.</p>
<p>All scaled coordinates have been changed to use block coordinates instead. Scaled iterators now have scaling option.</p>
<p>Changes:</p>
<ul>
<li>Added Locations tab to look for position in the current seed</li>
<li>Added biome samples filter to check biome proportions</li>
<li>Added outline display for the area of selected conditions</li>
<li>Added "from-visible" to conditions editor</li>
<li>Added headless mode to search seeds without a GUI using --nogui</li>
<li>Removed Triggers tab, since the Locations tab replaces the functionality</li>
</ul>
</description>
</release>
</releases>

Expand Down
4 changes: 4 additions & 0 deletions src/conditiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,9 @@ void ConditionDialog::updateBiomeSelection()
}
else if (ft.cat == CAT_BIOMES && wi.mc > MC_B1_7 && wi.mc <= MC_1_17)
{
//int scale = ui->comboScale->currentData().toInt();
//ui->comboScale->addItem(tr(""));

int layerId = ft.layer;
if (layerId == 0)
{
Expand Down Expand Up @@ -992,6 +995,7 @@ void ConditionDialog::onAccept()
}
}
}
c.step = ui->comboScale->currentData().toInt();
c.count = ui->checkSamplePos->isChecked() ? 1 : 0;
c.converage = ui->lineCoverage->text().toFloat() / 100.0;
c.confidence = ui->lineConfidence->text().toFloat() / 100.0;
Expand Down
24 changes: 17 additions & 7 deletions src/conditiondialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -618,23 +618,33 @@ QPushButton:hover {
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0">
<widget class="QCheckBox" name="checkMatchAny">
<item row="2" column="1">
<widget class="QCheckBox" name="checkApprox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p style=&quot;white-space:pre&quot;&gt;Satisfied if &lt;span style=&quot; font-weight:600;&quot;&gt;any&lt;/span&gt; of the checked biomes are present&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Enables optimizations that trade some accuracy for speed</string>
</property>
<property name="text">
<string>Match any</string>
<string>Approximate</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkApprox">
<widget class="QCheckBox" name="checkMatchAny">
<property name="toolTip">
<string>Enables optimizations that trade some accuracy for speed</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p style=&quot;white-space:pre&quot;&gt;Satisfied if &lt;span style=&quot; font-weight:600;&quot;&gt;any&lt;/span&gt; of the checked biomes are present&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Approximate</string>
<string>Match any</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboScale"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Biome scale:</string>
</property>
</widget>
</item>
Expand Down
3 changes: 3 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ void Config::reset()
smoothMotion = true;
showBBoxes = true;
restoreSession = true;
restoreWindow = false;
checkForUpdates = false;
autosaveCycle = 10;
uistyle = STYLE_SYSTEM;
Expand Down Expand Up @@ -371,6 +372,7 @@ void Config::load(QSettings& settings)
smoothMotion = settings.value("config/smoothMotion", smoothMotion).toBool();
showBBoxes = settings.value("config/showBBoxes", showBBoxes).toBool();
restoreSession = settings.value("config/restoreSession", restoreSession).toBool();
restoreWindow = settings.value("config/restoreWindow", restoreWindow).toBool();
checkForUpdates = settings.value("config/checkForUpdates", checkForUpdates).toBool();
autosaveCycle = settings.value("config/autosaveCycle", autosaveCycle).toInt();
uistyle = settings.value("config/uistyle", uistyle).toInt();
Expand All @@ -393,6 +395,7 @@ void Config::save(QSettings& settings)
settings.setValue("config/smoothMotion", smoothMotion);
settings.setValue("config/showBBoxes", showBBoxes);
settings.setValue("config/restoreSession", restoreSession);
settings.setValue("config/restoreWindow", restoreWindow);
settings.setValue("config/checkForUpdates", checkForUpdates);
settings.setValue("config/autosaveCycle", autosaveCycle);
settings.setValue("config/uistyle", uistyle);
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ struct Config
bool smoothMotion;
bool showBBoxes;
bool restoreSession;
bool restoreWindow;
bool checkForUpdates;
int autosaveCycle;
int uistyle;
Expand Down
2 changes: 2 additions & 0 deletions src/configdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void ConfigDialog::initConfig(Config *config)
ui->checkSmooth->setChecked(config->smoothMotion);
ui->checkBBoxes->setChecked(config->showBBoxes);
ui->checkRestore->setChecked(config->restoreSession);
ui->checkWindowPos->setChecked(config->restoreWindow);
ui->checkUpdates->setChecked(config->checkForUpdates);
ui->checkAutosave->setChecked(config->autosaveCycle != 0);
if (config->autosaveCycle)
Expand All @@ -96,6 +97,7 @@ Config ConfigDialog::getConfig()
conf.smoothMotion = ui->checkSmooth->isChecked();
conf.showBBoxes = ui->checkBBoxes->isChecked();
conf.restoreSession = ui->checkRestore->isChecked();
conf.restoreWindow = ui->checkWindowPos->isChecked();
conf.checkForUpdates = ui->checkUpdates->isChecked();
conf.autosaveCycle = ui->checkAutosave->isChecked() ? ui->spinAutosave->value() : 0;
conf.uistyle = ui->comboStyle->currentIndex();
Expand Down
23 changes: 15 additions & 8 deletions src/configdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,7 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkAutosave">
<property name="text">
<string>Autosave every:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QSpinBox" name="spinAutosave">
<property name="suffix">
<string> min</string>
Expand All @@ -225,6 +218,20 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkAutosave">
<property name="text">
<string>Autosave every:</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="checkWindowPos">
<property name="text">
<string>Restore window position</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
20 changes: 13 additions & 7 deletions src/formconditions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ FormConditions::FormConditions(QWidget *parent)
}

qRegisterMetaType< Condition >("Condition");
// qRegisterMetaTypeStreamOperators< Condition >("Condition");
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
qRegisterMetaTypeStreamOperators< Condition >("Condition");
#endif
}

FormConditions::~FormConditions()
Expand Down Expand Up @@ -156,6 +158,10 @@ int FormConditions::getIndex(int idx) const
return 0;
}

void FormConditions::clearSelection()
{
ui->listConditions->clearSelection();
}

QListWidgetItem *FormConditions::lockItem(QListWidgetItem *item)
{
Expand Down Expand Up @@ -425,13 +431,13 @@ void FormConditions::addItemCondition(QListWidgetItem *item, Condition cond, int

if (cond.type >= F_QH_IDEAL && cond.type <= F_QH_BARELY)
{
Condition cq = cond;
Condition cq;
memset(&cq, 0, sizeof(cq));
cq.type = F_HUT;
//cq.x1 = -128; cq.z1 = -128;
//cq.x2 = +128; cq.z2 = +128;
// use 256 to avoid confusion when this restriction is removed
cq.x1 = -256; cq.z1 = -256;
cq.x2 = +256; cq.z2 = +256;
cq.rmax = 256;
cq.relative = cond.save;
cq.save = cond.save+1;
cq.count = 4;
Expand All @@ -440,13 +446,13 @@ void FormConditions::addItemCondition(QListWidgetItem *item, Condition cond, int
}
else if (cond.type == F_QM_90 || cond.type == F_QM_95)
{
Condition cq = cond;
Condition cq;
memset(&cq, 0, sizeof(cq));
cq.type = F_MONUMENT;
//cq.x1 = -160; cq.z1 = -160;
//cq.x2 = +160; cq.z2 = +160;
// use 256 to avoid confusion when this restriction is removed
cq.x1 = -256; cq.z1 = -256;
cq.x2 = +256; cq.z2 = +256;
cq.rmax = 256;
cq.relative = cond.save;
cq.save = cond.save+1;
cq.count = 4;
Expand Down
2 changes: 2 additions & 0 deletions src/formconditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class FormConditions : public QWidget
void updateSensitivity();
int getIndex(int idx) const;

void clearSelection();

QListWidgetItem *lockItem(QListWidgetItem *item);
void setItemCondition(QListWidget *list, QListWidgetItem *item, Condition *cond);
void editCondition(QListWidgetItem *item);
Expand Down
24 changes: 20 additions & 4 deletions src/formgen48.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,26 @@ void FormGen48::updateAutoUi()
}
else
{
ui->lineEditX1->setText(QString::number(cond.x1));
ui->lineEditZ1->setText(QString::number(cond.z1));
ui->lineEditX2->setText(QString::number(cond.x2));
ui->lineEditZ2->setText(QString::number(cond.z2));
int x1, z1, x2, z2;
if (cond.rmax > 0)
{
int rmax = cond.rmax - 1;
x1 = -rmax >> 9;
z1 = -rmax >> 9;
x2 = +rmax >> 9;
z2 = +rmax >> 9;
}
else
{
x1 = cond.x1 >> 9;
z1 = cond.z1 >> 9;
x2 = cond.x2 >> 9;
z2 = cond.z2 >> 9;
}
ui->lineEditX1->setText(QString::number(x1));
ui->lineEditZ1->setText(QString::number(z1));
ui->lineEditX2->setText(QString::number(x2));
ui->lineEditZ2->setText(QString::number(z2));
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/formsearchcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,8 @@ void FormSearchControl::searchResult(uint64_t seed)
qbuf.push_back(seed);
if (ui->checkStop->isChecked())
{
stopSearch();
searchResultsAdd(qbuf, false);
qbuf.clear();
return;
}

Expand Down Expand Up @@ -657,7 +658,7 @@ int FormSearchControl::searchResultsAdd(std::vector<uint64_t> seeds, bool counto

int addcnt = n - ns;
if (ui->checkStop->isChecked() && addcnt)
sthread.abort = true;
stopSearch();

if (addcnt)
emit resultsAdded(addcnt);
Expand Down
9 changes: 4 additions & 5 deletions src/headless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ static QTextStream& qOut()
return out;
}

Headless::Headless(QString sessionpath, QString resultspath)
: QObject(nullptr)
Headless::Headless(QString sessionpath, QString resultspath, QObject *parent)
: QThread(parent)
, sthread(nullptr)
, sessionpath(sessionpath)
, resultfile(resultspath)
, resultstream(stdout)
{
sthread.isdone = true;
QTimer::singleShot(0, this, SLOT(start()));

QSettings settings(APP_STRING, APP_STRING);
g_extgen.load(settings);
Expand Down Expand Up @@ -124,7 +123,7 @@ bool Headless::loadSession(QString sessionpath)
return true;
}

void Headless::start()
void Headless::run()
{
qOut() << "Condition summary:\n";
for (const Condition& cond : qAsConst(session.cv))
Expand Down Expand Up @@ -172,7 +171,7 @@ void Headless::searchFinish(bool done)
qOut() << "Search done!\n";
qOut() << "Stopping event loop.\n";
qOut().flush();
QApplication::quit();
emit finished();
}


Expand Down
Loading

0 comments on commit fa28986

Please sign in to comment.