Skip to content

Commit

Permalink
Merge pull request mrkite#177 from IronException/master
Browse files Browse the repository at this point in the history
Feature single layer mode
  • Loading branch information
mrkite authored Aug 19, 2019
2 parents c367653 + 9577e79 commit 00cc632
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
5 changes: 5 additions & 0 deletions chunkrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ void ChunkRenderer::renderChunk(QSharedPointer<Chunk> chunk) {
int top = depth;
if (top > chunk->highest)
top = chunk->highest;
if (flags & flgSingleLayer)
top = depth;
int highest = 0;
for (int y = top; y >= 0; y--) { // top->down
// perform a one deep scan in SingleLayer mode
if ((flags & flgSingleLayer) && (y < top))
break;
int sec = y >> 4;
ChunkSection *section = chunk->sections[sec];
if (!section) {
Expand Down
4 changes: 4 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ int main(int argc, char *argv[]) {
minutor.setViewCavemode(true);
continue;
}
if (args[i] == "-sl" || args[i] == "--singlelayer")) {
minutor.setSingleLayer(true);
continue;
}
}

minutor.show();
Expand Down
1 change: 1 addition & 0 deletions mapview.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class MapView : public QWidget {
flgCaveMode = 4,
flgDepthShading = 8,
flgShowEntities = 16,
flgSingleLayer = 32,
flgBiomeColors = 64
};

Expand Down
16 changes: 15 additions & 1 deletion minutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ void Minutor::setDepth(int value) {
depth->setValue(value);
}

void Minutor::setSingleLayer(bool value) {
singleLayerAct->setChecked(value);
toggleFlags();
}

void Minutor::toggleFlags() {
int flags = 0;

Expand All @@ -269,6 +274,7 @@ void Minutor::toggleFlags() {
if (caveModeAct->isChecked()) flags |= MapView::flgCaveMode;
if (depthShadingAct->isChecked()) flags |= MapView::flgDepthShading;
if (biomeColorsAct->isChecked()) flags |= MapView::flgBiomeColors;
if (singleLayerAct->isChecked()) flags |= MapView::flgSingleLayer;
mapview->setFlags(flags);

QSet<QString> overlayTypes;
Expand Down Expand Up @@ -382,7 +388,14 @@ void Minutor::createActions() {
biomeColorsAct->setStatusTip(tr("Toggle draw biome colors or block colors"));
connect(biomeColorsAct, SIGNAL(triggered()),
this, SLOT(toggleFlags()));


singleLayerAct = new QAction(tr("&singlelayer"), this);
singleLayerAct->setCheckable(true);
//singleLayerAct->setShortcut(tr("Ctrl+L"));
singleLayerAct->setStatusTip(tr("Toggle single layer on/off"));
connect(singleLayerAct, SIGNAL(triggered()),
this, SLOT(toggleFlags()));

caveModeAct = new QAction(tr("&Cave Mode"), this);
caveModeAct->setCheckable(true);
caveModeAct->setShortcut(tr("Ctrl+C"));
Expand Down Expand Up @@ -516,6 +529,7 @@ void Minutor::createMenus() {
viewMenu->addAction(caveModeAct);
viewMenu->addAction(depthShadingAct);
viewMenu->addAction(biomeColorsAct);
viewMenu->addAction(singleLayerAct);
// [View->Overlay]
structureOverlayMenu = viewMenu->addMenu(tr("&Structure Overlay"));
entityOverlayMenu = viewMenu->addMenu(tr("&Entity Overlay"));
Expand Down
3 changes: 2 additions & 1 deletion minutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Minutor : public QMainWindow {
void setViewCavemode(bool value); // set View->Cave_Mode
void setViewDepthshading(bool value); // set View->Depth_Shading
void setViewBiomeColors(bool value); // set View->Biome_Colors
void setSingleLayer(bool value); // set View->Single_Layer
void setDepth(int value); // set Depth-Slider

MapView *getMapview() const;
Expand Down Expand Up @@ -101,7 +102,7 @@ private slots:
QAction *openAct, *reloadAct, *saveAct, *exitAct;
QAction *jumpSpawnAct;
QList<QAction *>players;
QAction *lightingAct, *mobSpawnAct, *caveModeAct, *depthShadingAct, *biomeColorsAct;
QAction *lightingAct, *mobSpawnAct, *caveModeAct, *depthShadingAct, *biomeColorsAct, *singleLayerAct;
QAction *manageDefsAct;
QAction *refreshAct;
QAction *aboutAct;
Expand Down

0 comments on commit 00cc632

Please sign in to comment.