Skip to content

Commit

Permalink
TetrisClassic-20210607.img
Browse files Browse the repository at this point in the history
  • Loading branch information
crozone committed Jun 8, 2021
1 parent fc437dd commit 55d053b
Show file tree
Hide file tree
Showing 13 changed files with 556 additions and 181 deletions.
31 changes: 28 additions & 3 deletions src/Source/CBasicApp.cp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "CTetrisPane.h"
#include "TetrisMessage.h"
#include "CTetrisGameRuleset.h"
#include "TetrisGameMode.h"
#include "PaneHelpers.h"

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -320,27 +321,51 @@ CBasicApp::ListenToMessage(
//
// Populate with rules
//


// Game mode
LPopupButton* gameModePopup = dynamic_cast<LPopupButton*>(
this->mSetupWindow->FindPaneByID(12) // TODO: Move to constant
);
ThrowIfNil_(gameModePopup);

switch(gameModePopup->GetValue()) {
case 1:
gameRuleset.mGameMode = TetrisGameMode::Marathon;
break;
case 2:
gameRuleset.mGameMode = TetrisGameMode::Sprint;
break;
case 3:
gameRuleset.mGameMode = TetrisGameMode::Ultra;
break;
default:
Throw_(-1);
break;
}

// Starting level
LSlider* startingLevelSlider = dynamic_cast<LSlider*>(
this->mSetupWindow->FindPaneByID(14) // TODO: Move to constant
);
ThrowIfNil_(startingLevelSlider);
gameRuleset.mStartingLevel = startingLevelSlider->GetValue();

// Hold piece enabled
LCheckBox* holdPieceCheckbox = dynamic_cast<LCheckBox*>(
this->mSetupWindow->FindPaneByID(23) // TODO: Move to constant
);
ThrowIfNil_(holdPieceCheckbox);
gameRuleset.mEnableHoldPiece = holdPieceCheckbox->GetValue() ? TRUE : FALSE;

// Next pieces lookahead count
LSlider* nextPiecesSlider = dynamic_cast<LSlider*>(
this->mSetupWindow->FindPaneByID(24) // TODO: Move to constant
);
ThrowIfNil_(nextPiecesSlider);
// TODO: Make game logic actually respect mPieceBagLookahead
gameRuleset.mPieceBagLookahead = nextPiecesSlider->GetValue();

// TODO: Rotation System
// Rotation System
LPopupButton* rotationSystemPopup = dynamic_cast<LPopupButton*>(
this->mSetupWindow->FindPaneByID(21) // TODO: Move to constant
);
Expand All @@ -360,7 +385,7 @@ CBasicApp::ListenToMessage(
gameRuleset.mScoringSystem = TetrisScoringSystem::OriginalSega;
break;
default:
Throw_(10); // TODO: Move to constant
Throw_(-1);
break;
}

Expand Down
Loading

0 comments on commit 55d053b

Please sign in to comment.