Skip to content

Commit 3ca0f71

Browse files
committed
Fixed bug with the random Difficulty selection. Started adding an About window.
1 parent bc473f8 commit 3ca0f71

File tree

5 files changed

+32
-18
lines changed

5 files changed

+32
-18
lines changed

SokoGenerator.pro.user

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE QtCreatorProject>
3-
<!-- Written by QtCreator 3.6.0, 2016-03-25T22:03:27. -->
3+
<!-- Written by QtCreator 3.6.0, 2016-03-29T13:16:12. -->
44
<qtcreator>
55
<data>
66
<variable>EnvironmentId</variable>
@@ -526,14 +526,17 @@
526526
<value type="int">13</value>
527527
<value type="int">14</value>
528528
</valuelist>
529-
<value type="int" key="PE.EnvironmentAspect.Base">-1</value>
529+
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
530530
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
531-
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
532-
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
533-
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
534-
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Executable</value>
531+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">SokoGenerator</value>
535532
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
536-
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
533+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/RBrNx/Documents/Qt Projects/SokoGenerator/SokoGenerator/SokoGenerator.pro</value>
534+
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
535+
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
536+
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">SokoGenerator.pro</value>
537+
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
538+
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
539+
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
537540
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
538541
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
539542
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>

mainwindow.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ MainWindow::MainWindow(QWidget *parent):QMainWindow(parent),ui(new Ui::MainWindo
1313
ui->label_GenerationTime->setText("Current Generation Time: 00:00:00");
1414
ui->progressBar->setValue(0);
1515
ui->list_LevelSet->setContextMenuPolicy(Qt::CustomContextMenu);
16-
ui->lineEdit_GeneratorSeed->setValidator(new QIntValidator(0,999999999,this));
16+
ui->lineEdit_GeneratorSeed->setValidator(new QIntValidator(0,9999999999,this));
1717
ui->lineEdit_GeneratorSeed->setText(0000000000);
1818

1919
connect(&Generator, SIGNAL(changeProgressBar(float)), this, SLOT(changeProgressBar(float)));
@@ -391,3 +391,15 @@ void MainWindow::on_lineEdit_GeneratorSeed_textEdited(const QString &arg1)
391391
{
392392
genSeed = arg1.toInt();
393393
}
394+
395+
void MainWindow::on_actionAbout_SokoGenerator_triggered()
396+
{
397+
QMessageBox::about(this, "About SokoGenrator", "<img src=':/tileset/textures/box_shipped.png' align = 'left'></img>"
398+
"<p>"
399+
"<h2>SokoGenerator 1.0</h2>"
400+
"<h4>Developed by Conor Watson</h4>"
401+
"<h4>Special Thanks to Pavel Klavik</h4>"
402+
"<h4>Written using C++ and QT</h4>"
403+
"<h4>MIT License SokoGenerator 2016</h4>"
404+
"</p>");
405+
}

mainwindow.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ private slots:
8585

8686
void on_lineEdit_GeneratorSeed_textEdited(const QString &arg1);
8787

88+
void on_actionAbout_SokoGenerator_triggered();
89+
8890
signals:
8991
void stopThread();
9092
};

mainwindow.ui

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@
541541
<string>File</string>
542542
</property>
543543
<addaction name="actionNew"/>
544-
<addaction name="actionOpen"/>
545544
<addaction name="separator"/>
546545
<addaction name="actionSave_As"/>
547546
<addaction name="actionClose"/>
@@ -561,11 +560,6 @@
561560
<string>New</string>
562561
</property>
563562
</action>
564-
<action name="actionOpen">
565-
<property name="text">
566-
<string>Open</string>
567-
</property>
568-
</action>
569563
<action name="actionSave_As">
570564
<property name="text">
571565
<string>Save As</string>

sokogenerator.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ SokoGenerator::ull SokoGenerator::randomNumber(ull min, ull max, int divisor){
8080

8181
void SokoGenerator::generateLevel(){
8282
generator.seed(chrono::steady_clock::now().time_since_epoch().count());
83-
if(genSeed == 0){ genSeed = distribution(generator); }
83+
if(genSeed == 0){
84+
while(genSeed > 999999999 || genSeed == 0){
85+
genSeed = distribution(generator);
86+
}
87+
}
8488
srand(genSeed);
8589
emit displayGenSeed();
8690
int _levels;
@@ -114,8 +118,7 @@ void SokoGenerator::generateLevel(int roomWidth, int roomHeight, int noOfBoxes,
114118
int _roomW, _roomH, _Boxes;
115119
QString _difficulty;
116120
if(noOfBoxes == 0){ _Boxes = randomNumber(3, 6); } else { _Boxes = noOfBoxes; }
117-
if(difficulty == 0){ difficulty = randomNumber(1, 5); } else { difficulty = difficulty; }
118-
_difficulty = difficulties[difficulty-1];
121+
if(difficulty != 0){ difficulty = randomNumber(1, 5); _difficulty = difficulties[difficulty-1]; }
119122
if(roomWidth == 0){ _roomW = randomNumber(3, 15, 3); } else { _roomW = roomWidth; }
120123
if(roomHeight == 0){
121124
if(_roomW == 3){ _roomH = randomNumber(6, 15, 3); }
@@ -139,7 +142,7 @@ void SokoGenerator::generateLevel(int roomWidth, int roomHeight, int noOfBoxes,
139142
newLevel.solution = cSolToString(sol);
140143
diffAnalyser = new DifficultyAnalyser;
141144
newLevel.difficulty = diffAnalyser->calculateDifficulty(newLevel);
142-
if(newLevel.difficulty != _difficulty){ generationSuccessful = false; }
145+
if(newLevel.difficulty != _difficulty && difficulty != 0){ generationSuccessful = false; }
143146
delete diffAnalyser;
144147
}
145148
qDebug() << "Generation Successful: " << generationSuccessful;

0 commit comments

Comments
 (0)