made app resizeable/stretchy; added Spoils manager

This commit is contained in:
4aiman 2024-01-24 18:36:29 +03:00
commit 61d82c5b46
6 changed files with 276 additions and 65 deletions

View file

@ -14,6 +14,14 @@
</XPManifest>
<Icon Value="0"/>
</General>
<VersionInfo>
<UseVersionInfo Value="True"/>
<AutoIncrementBuild Value="True"/>
<MinorVersionNr Value="1"/>
<RevisionNr Value="3"/>
<BuildNr Value="18"/>
<Attributes pvaPrivateBuild="True"/>
</VersionInfo>
<BuildModes>
<Item Name="Debug" Default="True"/>
</BuildModes>

View file

@ -9,7 +9,7 @@
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="mmbn5m"/>
<Filename Value="mmbn5mm"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
@ -46,9 +46,9 @@
<Unit>
<Filename Value="mmbn5m.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="1"/>
<EditorIndex Value="2"/>
<CursorPos X="69" Y="19"/>
<UsageCount Value="32"/>
<UsageCount Value="43"/>
<Loaded Value="True"/>
</Unit>
<Unit>
@ -59,141 +59,149 @@
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
<IsVisibleTab Value="True"/>
<TopLine Value="153"/>
<CursorPos X="45" Y="177"/>
<UsageCount Value="32"/>
<TopLine Value="147"/>
<CursorPos X="17" Y="161"/>
<UsageCount Value="43"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit>
<Unit>
<Filename Value="C:\lazarus\lcl\interfaces\win32\win32listsl.inc"/>
<EditorIndex Value="2"/>
<EditorIndex Value="3"/>
<TopLine Value="128"/>
<CursorPos Y="152"/>
<UsageCount Value="14"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit>
<Unit>
<Filename Value="C:\lazarus\fpc\3.2.2\source\rtl\objpas\sysutils\syshelph.inc"/>
<EditorIndex Value="1"/>
<TopLine Value="147"/>
<CursorPos X="16" Y="161"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit>
</Units>
<JumpHistory HistoryIndex="29">
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="129" Column="22" TopLine="106"/>
<Caret Line="110" Column="9" TopLine="68"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="174" Column="38" TopLine="155"/>
<Caret Line="211" Column="14" TopLine="170"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="133" Column="5" TopLine="98"/>
<Caret Line="213" Column="49" TopLine="171"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="134" Column="5" TopLine="99"/>
<Caret Line="214" Column="49" TopLine="172"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="133" Column="5" TopLine="98"/>
<Caret Line="213" Column="49" TopLine="171"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="118" Column="29" TopLine="87"/>
<Caret Line="214" Column="49" TopLine="172"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="58" Column="75" TopLine="42"/>
<Caret Line="213" Column="49" TopLine="171"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="118" Column="29" TopLine="105"/>
<Caret Line="212" Column="49" TopLine="170"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="152" Column="41" TopLine="129"/>
<Caret Line="213" Column="49" TopLine="171"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="222" Column="48" TopLine="175"/>
<Caret Line="220" Column="49" TopLine="178"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="9" Column="22" TopLine="9"/>
<Caret Line="183" Column="17" TopLine="163"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="28" Column="10"/>
<Caret Line="156" Column="47" TopLine="131"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="8" Column="86"/>
<Caret Line="150" Column="20" TopLine="131"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="38" Column="26" TopLine="14"/>
<Caret Line="157" Column="86" TopLine="135"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="117" Column="3" TopLine="93"/>
<Caret Line="114" Column="23" TopLine="89"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="221" Column="52" TopLine="181"/>
<Caret Line="165" Column="36" TopLine="141"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="214" Column="50" TopLine="195"/>
<Caret Line="227" Column="47" TopLine="195"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="121" Column="134" TopLine="91"/>
<Caret Line="151" Column="59" TopLine="144"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="219" Column="15" TopLine="181"/>
<Caret Line="155" Column="32" TopLine="144"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="220" Column="26" TopLine="181"/>
<Caret Line="126" Column="27" TopLine="121"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="221" Column="24" TopLine="181"/>
<Caret Line="153" Column="42" TopLine="140"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="224" Column="41" TopLine="183"/>
<Caret Line="211" Column="22" TopLine="209"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="225" Column="74" TopLine="184"/>
<Caret Line="235" Column="59" TopLine="211"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="104" Column="12" TopLine="80"/>
<Caret Line="216" TopLine="192"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="108" Column="77" TopLine="80"/>
<Caret Line="116" Column="18" TopLine="85"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="104" Column="26" TopLine="70"/>
<Caret Line="115" Column="24" TopLine="92"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="221" Column="9" TopLine="189"/>
<Caret Line="234" Column="46" TopLine="205"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="133" Column="5" TopLine="85"/>
<Caret Line="235" Column="45" TopLine="211"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="176" Column="33" TopLine="166"/>
<Caret Line="211" Column="11" TopLine="163"/>
</Position>
<Position>
<Filename Value="unit1.pas"/>
<Caret Line="179" Column="28" TopLine="155"/>
<Caret Line="212" Column="53" TopLine="180"/>
</Position>
</JumpHistory>
<RunParams>

Binary file not shown.

View file

@ -78,3 +78,13 @@
3982=Squirrel Comp 16
1536=Higsby's
1422=Squirrel Comp 6
397=Crane Comp
141=Elevator Room
1025=Mission Control
3=Dock
[Spoils]
397=RegUP2,1000z
141=HolyPanl*,RegUP1
401=Vulcan2 C,HP Memory
145=Quake1 A,Snake M

134
unit1.lfm
View file

@ -1,64 +1,158 @@
object Form1: TForm1
Left = 802
Left = 1033
Height = 448
Top = 496
Top = 463
Width = 528
BorderStyle = bsSingle
Caption = 'MMBN5M'
ClientHeight = 448
ClientWidth = 528
Font.CharSet = ANSI_CHARSET
Font.Height = -16
Font.Pitch = fpVariable
Font.Name = 'Liberation Mono'
Font.Pitch = fpFixed
Font.Quality = fqDraft
OnCreate = FormCreate
OnDestroy = FormDestroy
Position = poScreenCenter
LCLVersion = '2.2.6.0'
object room_name_label: TLabel
Left = 120
Height = 21
AnchorSideLeft.Control = start_stop_button
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
Left = 136
Height = 18
Top = 8
Width = 157
Caption = 'Room #0: Lan''s Room '
Width = 320
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Run the game, then press "Start"'
Color = clGradientInactiveCaption
Font.CharSet = ANSI_CHARSET
Font.Height = -16
Font.Pitch = fpFixed
Font.Quality = fqCleartype
ParentColor = False
ParentFont = False
Transparent = False
end
object map_image: TImage
Left = 120
Height = 400
Top = 40
Width = 400
AnchorSideLeft.Control = room_name_label
AnchorSideTop.Control = room_name_label
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 136
Height = 406
Top = 34
Width = 384
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Center = True
OnPaint = map_imagePaint
Proportional = True
Stretch = True
end
object start_stop_button: TSpeedButton
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 8
Height = 30
Top = 8
Width = 100
Width = 120
AllowAllUp = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'Start'
GroupIndex = 1
Transparent = False
OnClick = start_stop_buttonClick
end
object edit_room_button: TButton
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = start_stop_button
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = map_image
Left = 8
Height = 30
Top = 40
Width = 100
Top = 46
Width = 120
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Edit Room'
OnClick = edit_room_buttonClick
TabOrder = 0
end
object spoils_listbox: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = spoils_label
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = map_image
AnchorSideBottom.Control = plus_spoil
Left = 8
Height = 250
Top = 110
Width = 120
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
BorderStyle = bsNone
Color = clGradientInactiveCaption
ItemHeight = 0
OnDblClick = spoils_listboxDblClick
TabOrder = 1
end
object spoils_label: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = edit_room_button
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = map_image
Left = 8
Height = 18
Top = 84
Width = 120
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
Caption = 'Spoils:'
ParentColor = False
end
object plus_spoil: TButton
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 8
Height = 40
Top = 400
Width = 56
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 8
Caption = '+'
OnClick = plus_spoilClick
TabOrder = 2
end
object minus_spoil1: TButton
AnchorSideLeft.Control = plus_spoil
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = map_image
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 72
Height = 40
Top = 400
Width = 56
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = '-'
OnClick = minus_spoil1Click
TabOrder = 3
end
object Timer1: TTimer
Enabled = False
OnTimer = Timer1Timer

105
unit1.pas
View file

@ -6,14 +6,18 @@ interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
Buttons, IniFiles;
Buttons, Grids, IniFiles;
type
{ TForm1 }
TForm1 = class(TForm)
plus_spoil: TButton;
edit_room_button: TButton;
minus_spoil1: TButton;
spoils_label: TLabel;
spoils_listbox: TListBox;
map_image: TImage;
room_name_label: TLabel;
start_stop_button: TSpeedButton;
@ -22,6 +26,9 @@ type
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure map_imagePaint(Sender: TObject);
procedure minus_spoil1Click(Sender: TObject);
procedure plus_spoilClick(Sender: TObject);
procedure spoils_listboxDblClick(Sender: TObject);
procedure start_stop_buttonClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
@ -104,6 +111,8 @@ var
last_room: smallint = -1;
room_name: string;
new_room: bool;
spoils_list: string;
spoils: TStringArray;
{$R *.lfm}
@ -114,6 +123,7 @@ begin
// open ini file and create a list to hold processes
ROOMS := TIniFile.Create('rooms.ini');
process_list := TStringList.Create();
spoils_listbox.Height := 0;
end;
procedure TForm1.FormDestroy(Sender: TObject);
@ -131,8 +141,79 @@ end;
procedure TForm1.map_imagePaint(Sender: TObject);
begin
map_image.Canvas.Brush.Style := bsClear;
map_image.Canvas.Rectangle(0, 0, 400, 400);
//map_image.Canvas.Brush.Style := bsClear;
//map_image.Canvas.Rectangle(0, 0, 400, 400);
end;
procedure TForm1.minus_spoil1Click(Sender: TObject);
var
Txt: string;
i: integer;
begin
if (spoils_listbox.ItemIndex > -1) then
begin
spoils_listbox.Items.Delete(spoils_listbox.ItemIndex);
for i := 0 to spoils_listbox.Items.Count - 1 do
begin
if i < spoils_listbox.Items.Count - 1 then
Txt := Txt + spoils_listbox.Items[i] + ','
else
Txt := Txt + spoils_listbox.Items[i];
end;
ROOMS.WriteString('Spoils', IntToStr(room), Txt);
end;
spoils_listbox.ClearSelection;
end;
procedure TForm1.plus_spoilClick(Sender: TObject);
var
new_spoil_name: string;
var
Txt: string;
i: integer;
begin
if InputQuery('Adding item to Room #' + IntToStr(room), 'Enter item''s name',
new_spoil_name) then
begin
spoils_listbox.Items.Add(new_spoil_name);
for i := 0 to spoils_listbox.Items.Count - 1 do
begin
if i < spoils_listbox.Items.Count - 1 then
Txt := Txt + spoils_listbox.Items[i] + ','
else
Txt := Txt + spoils_listbox.Items[i];
end;
ROOMS.WriteString('Spoils', IntToStr(room), Txt);
end;
spoils_listbox.ClearSelection;
end;
procedure TForm1.spoils_listboxDblClick(Sender: TObject);
var
new_spoil_name: string;
var
Txt: string;
i: integer;
begin
if (spoils_listbox.ItemIndex > -1) then
begin
new_spoil_name := spoils_listbox.Items[spoils_listbox.ItemIndex];
if InputQuery('Editing item in Room #' + IntToStr(room),
'Enter item''s name', new_spoil_name) then
begin
spoils_listbox.Items[spoils_listbox.ItemIndex] := new_spoil_name;
for i := 0 to spoils_listbox.Items.Count - 1 do
begin
if i < spoils_listbox.Items.Count - 1 then
Txt := Txt + spoils_listbox.Items[i] + ','
else
Txt := Txt + spoils_listbox.Items[i];
end;
ROOMS.WriteString('Spoils', IntToStr(room), Txt);
end;
end;
spoils_listbox.ClearSelection;
end;
procedure TForm1.start_stop_buttonClick(Sender: TObject);
@ -168,6 +249,8 @@ end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
spoils_listbox.Height := spoils_listbox.Items.Count * spoils_listbox.ItemHeight;
if hProcess <> 0 then
begin
@ -176,10 +259,18 @@ begin
begin
if (last_room <> room) or (new_room) then
begin
new_room := false;
new_room := False;
last_room := room;
room_name := ROOMS.ReadString('Rooms', IntToStr(room), 'Unknown');
room_name_label.Caption := 'Room #' + IntToStr(room) + ': ' + room_name;
spoils_list := ROOMS.ReadString('Spoils', IntToStr(room), '');
spoils_listbox.Items.Clear;
if (spoils_list <> '') then
begin
spoils := spoils_list.Split(',');
spoils_listbox.Items.AddStrings(spoils);
end;
if FileExists('images/' + room_name + '.png') then
begin
map_image.Picture.LoadFromFile('images/' + room_name + '.png');
@ -192,11 +283,11 @@ begin
end
else
begin
room_name_label.Caption := 'error';
room_name_label.Caption := 'Error. Make sure the game is running';
end;
except
on edit_room_button: Exception do
room_name_label.Caption := 'error';
room_name_label.Caption := 'Error';
end;
end;
@ -211,7 +302,7 @@ begin
new_room_name) then
begin
ROOMS.WriteString('Rooms', IntToStr(room), new_room_name);
new_room := true;
new_room := True;
end;
end;