Skip to content

Commit

Permalink
Option to enable or disable state control. State control is enabled b…
Browse files Browse the repository at this point in the history
…y default. If state control is disabled:

 * Loading replays is not allowed
 * Backing up time is not allowed
 * Frame advancing while paused is not allowed
 * A single skill assignment may be used while paused

If state control is enabled, "-" key backs up the game one second.  If state control is disabled, "-" key decreases the release rate.
  • Loading branch information
AaronKelley committed Jun 15, 2020
1 parent 94ee81b commit 5b4c33a
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 68 deletions.
13 changes: 9 additions & 4 deletions PlayerSourceTrad/GameConfigScreen.pas
Expand Up @@ -289,12 +289,13 @@ function TGameConfigScreen.GetScreenText: string;

Add('1) Show Particles: ' + OnOffText(GameParams.ShowParticles));
Add('2) Lemmix Trap Bug: ' + OnOffText(GameParams.LemmixTrapBug));
Add('3) State Control: ' + OnOffText(GameParams.StateControlEnabled));
if fLookForLVLOption then
Add('3) Look For LVL Files: ' + OnOffText(GameParams.LookForLVLFiles));
Add('4) Look For LVL Files: ' + OnOffText(GameParams.LookForLVLFiles));
if fCustOptions then
begin
{$ifdef cust}{$ifndef flexi}
Add('4) Mechanics: ' + MechText(GameParams.Mechanics));
Add('5) Mechanics: ' + MechText(GameParams.Mechanics));
ts := GameParams.LevelPack;
while (Length(ts) < 18) do
ts := ' ' + ts;
Expand Down Expand Up @@ -414,6 +415,9 @@ procedure TGameConfigScreen.Form_KeyPress(Sender: TObject; var Key: Char);
7: begin
LemmixTrapBug := not LemmixTrapBug;
end;
8: begin
StateControlEnabled := not StateControlEnabled;
end;
end;
BuildScreen;
end;
Expand All @@ -424,8 +428,9 @@ procedure TGameConfigScreen.Form_KeyPress(Sender: TObject; var Key: Char);
case lChar of
'1' : SwitchOption(1);
'2' : SwitchOption(7);
'3' : if fLookForLVLOption then SwitchOption(2);
'4' : if fCustOptions then SwitchOption(6);
'3' : SwitchOption(8);
'4' : if fLookForLVLOption then SwitchOption(2);
'5' : if fCustOptions then SwitchOption(6);
'Q' : if fCustOptions then SwitchOption(4);
'W' : if fCustOptions then SwitchOption(5);
'E' : if fTestModeOptions then SwitchOption(3);
Expand Down
24 changes: 20 additions & 4 deletions PlayerSourceTrad/GameControl.pas
Expand Up @@ -71,7 +71,8 @@ TGameResultsRec = record
moLookForLVLFiles, // 6
// moUseSystemCursor, // 7
moLemmixTrapBug,
mo9, mo10, mo11, mo12, mo13, mo14, mo15,
moStateControlEnabled,
mo10, mo11, mo12, mo13, mo14, mo15,
mo16, mo17, mo18, mo19, mo20, mo21, mo22, mo23,
mo24, mo25, mo26, mo27, mo28, mo29, mo30, mo31
);
Expand All @@ -85,7 +86,8 @@ TGameResultsRec = record
moSaveState,
moHyperJumps,
// moCheatCodes,
moShowParticles
moShowParticles,
moStateControlEnabled
{$ifdef cust}, moLemmixTrapBug{$endif}

// moLookForLVLFiles
Expand Down Expand Up @@ -122,6 +124,8 @@ TDosGameParams = class(TPersistent)
procedure SetUseSystemCursor(const Value: Boolean);
function GetLemmixTrapBug: Boolean;
procedure SetLemmixTrapBug(Value: Boolean);
function GetStateControlEnabled: Boolean;
procedure SetStateControlEnabled(Value: Boolean);
public
// this is initialized by appcontroller
MainDatFile : string;
Expand Down Expand Up @@ -190,7 +194,6 @@ TDosGameParams = class(TPersistent)
property DumpMode: boolean read fDumpMode write fDumpMode;
published
{ easy readable published props for streaming to inifile }
//property HyperJumpsEnabled: Boolean read GetHyperJumpsEnabled write SetHyperJumpsEnabled;
property CheatCodesEnabled: Boolean read GetCheatCodesEnabled write SetCheatCodesEnabled;
property MusicEnabled: Boolean read GetMusicEnabled write SetMusicEnabled;
property SoundEnabled: Boolean read GetSoundEnabled write SetSoundEnabled;
Expand All @@ -201,7 +204,7 @@ TDosGameParams = class(TPersistent)
property ExternalPrefix: String read fExternalPrefix write fExternalPrefix;{$endif}{$endif}
property LemmixTrapBug: boolean read GetLemmixTrapBug write SetLemmixTrapBug;
{$ifdef testmode}property QuickTestMode: Integer read fQuickTestMode write fQuickTestMode;{$endif}
// property UseSystemCursor: Boolean read GetUseSystemCursor write SetUseSystemCursor;
property StateControlEnabled: Boolean read GetStateControlEnabled write SetStateControlEnabled;

{ zoom }
property ZoomFactor: Integer read fZoomFactor write fZoomFactor;
Expand Down Expand Up @@ -284,6 +287,11 @@ function TDosGameParams.GetLemmixTrapBug: Boolean;
Result := moLemmixTrapBug in MiscOptions;
end;

function TDosGameParams.GetStateControlEnabled: Boolean;
begin
Result := moStateControlEnabled in MiscOptions;
end;

procedure TDosGameParams.LoadFromIniFile(const aFileName: string);
begin
IniToObject(aFileName, 'GameSettings', Self, False);
Expand Down Expand Up @@ -342,6 +350,14 @@ procedure TDosGameParams.SetLemmixTrapBug(Value: Boolean);
end;
end;

procedure TDosGameParams.SetStateControlEnabled(Value: Boolean);
begin
case Value of
False: Exclude(MiscOptions, moStateControlEnabled);
True: Include(MiscOptions, moStateControlEnabled);
end;
end;

function TDosGameParams.GetUseSystemCursor: Boolean;
begin
// Result := moUseSystemCursor in MiscOptions;
Expand Down
97 changes: 39 additions & 58 deletions PlayerSourceTrad/GameWindow.pas
Expand Up @@ -365,7 +365,11 @@ procedure TGameWindow.Form_KeyDown(Sender: TObject; var Key: Word; Shift: TShift
VK_F9: SetSelectedSkill(spbMiner, True);
VK_F10: SetSelectedSkill(spbDigger, True);
VK_F11: SetSelectedSkill(spbPause);
189: SetSelectedSkill(spbSlower, True); // minus button
189: // minus button
begin
if not GameParams.StateControlEnabled then
SetSelectedSkill(spbSlower, True);
end;
187: SetSelectedSkill(spbFaster, True); // plus button
// 48 through 56 correspond to the '0' through '8' keys
48: SetSelectedSkill(spbPause);
Expand Down Expand Up @@ -412,7 +416,11 @@ procedure TGameWindow.Form_KeyUp(Sender: TObject; var Key: Word; Shift: TShiftSt
case Key of
VK_F1 : SetSelectedSkill(spbSlower, False);
VK_F2 : SetSelectedSkill(spbFaster, False);
189 : SetSelectedSkill(spbSlower, False); // minus button
189 : // minus button
begin
if not GameParams.StateControlEnabled then
SetSelectedSkill(spbSlower, False);
end;
187 : SetSelectedSkill(spbFaster, False); // plus button
VK_LEFT : GameScroll := gsNone;
VK_RIGHT : GameScroll := gsNone;
Expand Down Expand Up @@ -467,7 +475,7 @@ procedure TGameWindow.Img_MouseDown(Sender: TObject; Button: TMouseButton;
if HandleClick then
begin
Game.ProcessSkillAssignment;
if Game.Paused then
if Game.Paused and GameParams.StateControlEnabled then
ForceUpdateOneFrame := True;
end;
end;
Expand Down Expand Up @@ -719,8 +727,8 @@ procedure TGameWindow.Form_KeyPress(Sender: TObject; var Key: Char);
end;

// go back approximately 1 game second
'[':
if Game.Playing then
'-':
if GameParams.StateControlEnabled and Game.Playing then
begin
if not Game.HyperSpeed then
begin
Expand All @@ -733,7 +741,7 @@ procedure TGameWindow.Form_KeyPress(Sender: TObject; var Key: Char);

// go back 1 frame
'B':
if Game.Playing then
if GameParams.StateControlEnabled and Game.Playing then
begin
if not Game.HyperSpeed then
begin
Expand Down Expand Up @@ -767,7 +775,8 @@ procedure TGameWindow.Form_KeyPress(Sender: TObject; var Key: Char);
'I': SaveShot;

// load replay file
'L': LoadReplay;
'L': if GameParams.StateControlEnabled then
LoadReplay;

// enable/disable music
'M': begin
Expand All @@ -781,7 +790,7 @@ procedure TGameWindow.Form_KeyPress(Sender: TObject; var Key: Char);

// do next frame if paused
'N': {if LemmixDebugMode then}
if Game.Paused then
if GameParams.StateControlEnabled and Game.Paused then
//if Game.Replaying then
ForceUpdateOneFrame := True;

Expand Down Expand Up @@ -809,7 +818,8 @@ procedure TGameWindow.Form_KeyPress(Sender: TObject; var Key: Char);
'P': Game.SetSelectedSkill(spbPause);

// start replay
'R': StartReplay;
'R': if GameParams.StateControlEnabled then
StartReplay;

// enable/disable sounds
'S': begin
Expand All @@ -824,60 +834,31 @@ procedure TGameWindow.Form_KeyPress(Sender: TObject; var Key: Char);

'Z': with Game do
begin
RegainControl;
case SelectedSkill of
spbUmbrella: SetSelectedSkill(spbClimber, True);
spbExplode: SetSelectedSkill(spbUmbrella, True);
spbBlocker: SetSelectedSkill(spbExplode, True);
spbBuilder: SetSelectedSkill(spbBlocker, True);
spbBasher: SetSelectedSkill(spbBuilder, True);
spbMiner: SetSelectedSkill(spbBasher, True);
spbDigger: SetSelectedSkill(spbMiner, True);
end;
RegainControl;
case SelectedSkill of
spbUmbrella: SetSelectedSkill(spbClimber, True);
spbExplode: SetSelectedSkill(spbUmbrella, True);
spbBlocker: SetSelectedSkill(spbExplode, True);
spbBuilder: SetSelectedSkill(spbBlocker, True);
spbBasher: SetSelectedSkill(spbBuilder, True);
spbMiner: SetSelectedSkill(spbBasher, True);
spbDigger: SetSelectedSkill(spbMiner, True);
end;
end;

'X': with Game do
begin
RegainControl;
case SelectedSkill of
spbClimber: SetSelectedSkill(spbUmbrella, True);
spbUmbrella: SetSelectedSkill(spbExplode, True);
spbExplode: SetSelectedSkill(spbBlocker, True);
spbBlocker: SetSelectedSkill(spbBuilder, True);
spbBuilder: SetSelectedSkill(spbBasher, True);
spbBasher: SetSelectedSkill(spbMiner, True);
spbMiner: SetSelectedSkill(spbDigger, True);
RegainControl;
case SelectedSkill of
spbClimber: SetSelectedSkill(spbUmbrella, True);
spbUmbrella: SetSelectedSkill(spbExplode, True);
spbExplode: SetSelectedSkill(spbBlocker, True);
spbBlocker: SetSelectedSkill(spbBuilder, True);
spbBuilder: SetSelectedSkill(spbBasher, True);
spbBasher: SetSelectedSkill(spbMiner, True);
spbMiner: SetSelectedSkill(spbDigger, True);
end;
end;
end;

// first stab at time pause support
//'Z': Game.DoTimePause := not Game.DoTimePause;

// --------- UPPERCASE ------------

// disable/enable changing the selected skillbutton with mouse when paused
// 'C': if LemmixDebugMode then
// Game.SkillButtonsDisabledWhenPaused := not Game.SkillButtonsDisabledWhenPaused;


{'F':
begin
if Game.Playing then
begin
if not Game.HyperSpeed then
begin
//windows.beep(448, 3);
Game.HyperSpeedBegin;
Game.TargetIteration := Game.CurrentIteration + 17*60;
end
else begin
Game.HyperSpeedEnd;
end;
end;
end; }



end;
end;
Expand Down
13 changes: 11 additions & 2 deletions PlayerSourceTrad/LemGame.pas
Expand Up @@ -436,6 +436,7 @@ TLemmingGame = class(TComponent)
fSlowingDownReleaseRate : Boolean;
fSpeedingUpReleaseRate : Boolean;
fPaused : Boolean;
fPausedSkillAssignmentAllowed : Boolean;
MaxNumLemmings : Integer;
CurrReleaseRate : Integer;
CurrClimberCount : Integer;
Expand Down Expand Up @@ -649,6 +650,7 @@ TLemmingGame = class(TComponent)
property MiniMapBuffer: TBitmap32 read fMiniMapBuffer;
property Options: TDosGameOptions read fOptions write SetOptions default DOSORIG_GAMEOPTIONS;
property Paused: Boolean read fPaused write fPaused;
property PausedSkillAssignmentAllowed: Boolean read fPausedSkillAssignmentAllowed write fPausedSkillAssignmentAllowed;
property Playing: Boolean read fPlaying write fPlaying;
property Renderer: TRenderer read fRenderer;
property Replaying: Boolean read fReplaying;
Expand Down Expand Up @@ -1173,6 +1175,7 @@ procedure TLemmingGame.Start(aReplay: Boolean = False);
fSlowingDownReleaseRate := False;
fSpeedingUpReleaseRate := False;
fPaused := False;
fPausedSkillAssignmentAllowed := True;
UserSetNuking := False;
ExploderAssignInProgress := False;
Index_LemmingToBeNuked := 0;
Expand Down Expand Up @@ -3563,8 +3566,13 @@ function TLemmingGame.ProcessSkillAssignment: Boolean;

if Lemming1 <> nil then
begin
fCheckWhichLemmingOnly := False;
Result := AssignSkill(Lemming1, Lemming2, Sel);
if (not Paused) or fPausedSkillAssignmentAllowed then
begin
fCheckWhichLemmingOnly := False;
Result := AssignSkill(Lemming1, Lemming2, Sel);
if Paused and (not (moStateControlEnabled in fGameParams.MiscOptions)) then
fPausedSkillAssignmentAllowed := False;
end;
end;
end;
end;
Expand Down Expand Up @@ -3796,6 +3804,7 @@ procedure TLemmingGame.SetSelectedSkill(Value: TSkillPanelButton; MakeActive: Bo
False:
begin
Paused := True;
PausedSkillAssignmentAllowed := True;
FastForward := False;
RecordStartPause;
//HyperSpeedEnd;
Expand Down

0 comments on commit 5b4c33a

Please sign in to comment.