Skip to content

Commit

Permalink
Improve Run button with default Run Mode and Stop icon (#282)
Browse files Browse the repository at this point in the history
- User can start a contest using the Run button's dropdown list.
- This default Run Mode will be identified using a bold font in the
dropdown list.
- The default run mode will be retained in the MorseRunner.ini file
across MR invocations.
- Subsequent pushes of the Run button will start the selected Run mode.
- Once started, the Run button will be renamed to "Stop" along with a
red Stop icon.
- When user pushes the red Stop icon, simulation will stop and the
button will be renamed to "Run" along with its green Start icon.
  • Loading branch information
w7sst authored Mar 10, 2024
2 parents b3cbe3b + 176f577 commit 958fb2d
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 47 deletions.
4 changes: 4 additions & 0 deletions Ini.pas
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ TContestDefinition = record

Duration: integer = 30;
RunMode: TRunMode = rmStop;
DefaultRunMode: TRunMode = rmPileUp;
HiScore: integer;
CompDuration: integer = 60;

Expand Down Expand Up @@ -385,6 +386,8 @@ procedure FromIni(cb : TErrMessageCallback);
MainForm.CheckBox6.Checked := ReadBool(SEC_BND, 'Lids', Lids);
MainForm.ReadCheckBoxes;

V := ReadInteger(SEC_TST, 'DefaultRunMode', Ord(DefaultRunMode));
MainForm.SetDefaultRunMode(Max(Ord(rmPileUp), Min(Ord(rmHst), V)));
Duration := ReadInteger(SEC_TST, 'Duration', Duration);
MainForm.SpinEdit2.Value := Duration;
HiScore := ReadInteger(SEC_TST, 'HiScore', HiScore);
Expand Down Expand Up @@ -480,6 +483,7 @@ procedure ToIni;
WriteBool(SEC_BND, 'Flutter', Flutter);
WriteBool(SEC_BND, 'Lids', Lids);

WriteInteger(SEC_TST, 'DefaultRunMode', Ord(DefaultRunMode));
WriteInteger(SEC_TST, 'Duration', Duration);
WriteInteger(SEC_TST, 'HiScore', HiScore);
WriteInteger(SEC_TST, 'CompetitionDuration', CompDuration);
Expand Down
90 changes: 45 additions & 45 deletions Main.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@ object MainForm: TMainForm
Left = 384
Top = 176
Bitmap = {
494C01010A00D800040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C01010B00D800040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000003000000001002000000000000030
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
Expand All @@ -1606,105 +1606,105 @@ object MainForm: TMainForm
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000FFFF000000000000000000007F7F7F007F7F7F007F7F
7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F
7F007F7F7F007F7F7F00FFFFFF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
7F007F7F7F007F7F7F00FFFFFF0000000000000000002B1BEE00241CED00241C
ED00241CED00241CED00241CED00241CED00241CED00241CED00241CED00241C
ED00241CED00241CED0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFF000000000000FFFFFF007F7F
7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F
7F007F7F7F0000000000FFFF000000000000000000007F7F7F00FFFFFF000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000007F7F7F00FFFFFF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000007F7F7F00FFFFFF000000000000000000241CED00241CED00241C
ED00241CED00241CED00241CED00241CED00241CED00241CED00241CED00241C
ED002B1BEE00241CED0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFF000000000000FFFFFF000000
0000000000000000000000000000000000000000000000000000000000000000
00007F7F7F0000000000FFFF000000000000000000007F7F7F00FFFFFF000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000007F7F7F00FFFFFF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000007F7F7F00FFFFFF000000000000000000241CED00241CED00241C
ED00241CED00241CED00241CED00241CED00241CED00241CED00241CED00241C
ED00241CED00241CED0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFF000000000000FFFFFF000000
0000000000000000000000000000000000000000000000000000000000000000
00007F7F7F0000000000FFFF000000000000000000007F7F7F00FFFFFF000000
00000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000
0000000000007F7F7F00FFFFFF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000007F7F7F00FFFFFF000000000000000000241CED00241CED00241C
ED00241CED00241CEE00241CED00241CED00241CED00241CED00241CED00241C
ED00241CED00241CED0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFF000000000000FFFFFF000000
0000000000000000000000000000000000000000000000000000000000000000
00007F7F7F0000000000FFFF000000000000000000007F7F7F00FFFFFF000000
0000000000007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F00FFFFFF000000
0000000000007F7F7F00FFFFFF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000007F7F7F00FFFFFF000000000000000000241CED00241CED00241C
ED00241CED00241CED00241CED00251DED00241CED00241CED00241CED00241C
ED00241CED00241CED0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFF000000000000FFFFFF000000
0000000000000000000000000000000000000000000000000000000000000000
00007F7F7F0000000000FFFF000000000000000000007F7F7F00FFFFFF000000
0000000000007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F00FFFFFF000000
0000000000007F7F7F00FFFFFF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000007F7F7F00FFFFFF000000000000000000241CED00241CED00241C
ED00241CED00241CED00241CED00241CED00241CED00241CED00241CED00241C
ED00241CED00241CED0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFF000000000000FFFFFF000000
0000000000000000000000000000000000000000000000000000000000000000
00007F7F7F0000000000FFFF000000000000000000007F7F7F00FFFFFF000000
0000000000007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F00FFFFFF000000
0000000000007F7F7F00FFFFFF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000007F7F7F00FFFFFF000000000000000000241CED00241CED00241C
ED00241CED00241CED00241CED00241CEE00241CED00241CED00241CED00241C
ED00241CED00241CED0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFF000000000000FFFFFF000000
0000000000000000000000000000000000000000000000000000000000000000
00007F7F7F0000000000FFFF000000000000000000007F7F7F00FFFFFF000000
0000000000007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F00FFFFFF000000
0000000000007F7F7F00FFFFFF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000007F7F7F00FFFFFF000000000000000000241CED00241CED00241C
ED00241CED00241CED00241CED00241CED00241CED00241CED00241CED00241C
ED00241CED00241CED0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFF000000000000FFFFFF000000
0000000000000000000000000000000000000000000000000000000000000000
00007F7F7F0000000000FFFF000000000000000000007F7F7F00FFFFFF000000
0000000000007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F00000000000000
0000000000007F7F7F00FFFFFF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000007F7F7F00FFFFFF000000000000000000241CED00241CED00241C
ED00241CED00241CED00241CED00241CED00241CED00241CED00241CED00241C
ED00241CED00241CED0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFF000000000000FFFFFF000000
0000000000000000000000000000000000000000000000000000000000000000
00007F7F7F0000000000FFFF000000000000000000007F7F7F00FFFFFF000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000007F7F7F00FFFFFF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000007F7F7F00FFFFFF000000000000000000241CED00241CED00241C
ED00241CED00241CED00241CED00241CED00241CED00241CED00241CED00241C
ED00241CED00241CED0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFF000000000000FFFFFF000000
0000000000000000000000000000000000000000000000000000000000000000
00007F7F7F0000000000FFFF000000000000000000007F7F7F00FFFFFF000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000007F7F7F00FFFFFF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000007F7F7F00FFFFFF000000000000000000241CED00241CED00241C
ED00241CED00241CEC00241CED00241CED00241CED00241CED00241CED00241C
ED00241CED00241CED0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFF000000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0000000000FFFF000000000000000000007F7F7F00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF007F7F7F00FFFFFF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
FF00FFFFFF007F7F7F00FFFFFF0000000000000000002A1BEE00241CED00241C
ED00241CED00241CED00241CED00241CED00241CED00241CED00241CED00241C
ED00241CED00241CED0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFF000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000FFFF000000000000000000007F7F7F007F7F7F007F7F
7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F
7F007F7F7F007F7F7F0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
7F007F7F7F007F7F7F00000000000000000000000000241CED00241CED00241C
ED00241CED00241CED00241CED00241CED00241CED00241CED00241CED00241C
ED00241CED00241CED0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFF0000FFFF0000FFFF0000FFFF
0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF
Expand Down Expand Up @@ -1972,11 +1972,11 @@ object MainForm: TMainForm
7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F7F007F7F
7F007F7F7F00000000000000000000000000424D3E000000000000003E000000
2800000040000000300000000100010000000000800100000000000000000000
000000000000000000000000FFFFFF00FFFFFFFF000000000001C00100000000
000180010000000000019FF9000000001FF19FF9000000001FF19C1900000000
1831981900000000183198190000000018319819000000001831981900000000
18319839000000001FF19FF9000000001FF19FF9000000000001800100000000
00018003000000000001FFFF00000000FFFFC001FFFFFFFF800380020001C001
000000000000000000000000FFFFFF00FFFFFFFFFFFF00000001C00180010000
000180018001000000019FF9800100001FF19FF9800100001FF19C1980010000
1831981980010000183198198001000018319819800100001831981980010000
18319839800100001FF19FF9800100001FF19FF9800100000001800180010000
00018003800100000001FFFFFFFF0000FFFFC001FFFFFFFF800380020001C001
00013924000180010001382400019FF9000138041FF19FF90001380C1FF19E39
0001200018319C19000100001831981900010FF01831981900010FF018319839
00010FF018319C7900010FF01FF19FF900010FF01FF19FF900010FF000018001
Expand Down
23 changes: 21 additions & 2 deletions Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ TMainForm = class(TForm)
procedure Advance;
procedure SetContest(AContestNum: TSimContest);
function SetMyExchange(const AExchange: string) : Boolean;
procedure SetDefaultRunMode(V : Integer);
procedure SetMySerialNR;
procedure SetQsk(Value: boolean);
procedure SetWpm(AWpm : integer);
Expand Down Expand Up @@ -1197,6 +1198,21 @@ procedure TMainForm.UpdateTitleBar;
end;


procedure TMainForm.SetDefaultRunMode(V : Integer);
begin
if (V >= Ord(rmPileUp)) and (V <= Ord(rmHst)) then
DefaultRunMode := TRunMode(V)
else
DefaultRunMode := rmPileUp;

assert(PopupMenu1.Items[0].Tag = Ord(rmPileUp));
assert(PopupMenu1.Items[1].Tag = Ord(rmSingle));
assert(PopupMenu1.Items[2].Tag = Ord(rmWpx));
assert(PopupMenu1.Items[3].Tag = Ord(rmHst));
PopupMenu1.Items[Ord(DefaultRunMode)-1].Default := True;
end;


procedure TMainForm.SetMySerialNR;
begin
assert(Tst.Me.SentExchTypes.Exch2 = etSerialNr);
Expand Down Expand Up @@ -1648,7 +1664,8 @@ procedure TMainForm.Edit1Change(Sender: TObject);

procedure TMainForm.RunMNUClick(Sender: TObject);
begin
Run(TRunMode((Sender as TComponent).Tag));
SetDefaultRunMode((Sender as TComponent).Tag);
Run(DefaultRunMode);
end;


Expand Down Expand Up @@ -1762,6 +1779,8 @@ procedure TMainForm.Run(Value: TRunMode);
EnableCtl(ExchangeEdit, BStop and ActiveContest.ExchFieldEditable);
EnableCtl(SpinEdit2, BStop);
SetToolbuttonDown(ToolButton1, not BStop);
ToolButton1.Caption := IfThen(BStop, 'Run', 'Stop');
ToolButton1.ImageIndex := IfThen(BStop, 0, 10);

//condition checkboxes
EnableCtl(CheckBox2, not BCompet);
Expand Down Expand Up @@ -1881,7 +1900,7 @@ procedure TMainForm.Run(Value: TRunMode);
procedure TMainForm.RunBtnClick(Sender: TObject);
begin
if RunMode = rmStop then
Run(rmPileUp)
Run(DefaultRunMode)
else
Tst.FStopPressed := true;
end;
Expand Down

0 comments on commit 958fb2d

Please sign in to comment.