Skip to content

Commit

Permalink
Added new inventory scene.
Browse files Browse the repository at this point in the history
  • Loading branch information
devapromix committed Jan 12, 2025
1 parent 59b6480 commit f483cc3
Showing 8 changed files with 218 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -15,3 +15,4 @@ sources/Scenes/__history/
/sources/Game/__history
/*.txt
/sources/*.dres
/temp
4 changes: 3 additions & 1 deletion sources/Elinor.dpr
Original file line number Diff line number Diff line change
@@ -53,7 +53,9 @@ uses
Elinor.Scene.Barracks in 'Scenes\Elinor.Scene.Barracks.pas',
Elinor.Spells.Types in 'Elinor.Spells.Types.pas',
Elinor.Factions in 'Game\Elinor.Factions.pas',
Elinor.Spellbook in 'Game\Elinor.Spellbook.pas';
Elinor.Spellbook in 'Game\Elinor.Spellbook.pas',
Elinor.Scene.Skills in 'Scenes\Elinor.Scene.Skills.pas',
Elinor.Scene.Inventory in 'Scenes\Elinor.Scene.Inventory.pas';

{$R *.res}

6 changes: 4 additions & 2 deletions sources/Elinor.dproj
Original file line number Diff line number Diff line change
@@ -152,6 +152,8 @@
<DCCReference Include="Elinor.Spells.Types.pas"/>
<DCCReference Include="Game\Elinor.Factions.pas"/>
<DCCReference Include="Game\Elinor.Spellbook.pas"/>
<DCCReference Include="Scenes\Elinor.Scene.Skills.pas"/>
<DCCReference Include="Scenes\Elinor.Scene.Inventory.pas"/>
<RcItem Include="Resources\Sprites\frame.passive.png">
<ResourceType>RCDATA</ResourceType>
<ResourceId>FRAME_PASSIVE</ResourceId>
@@ -240,7 +242,7 @@
</Excluded_Packages>
</Delphi.Personality>
<Deployment Version="3">
<DeployFile LocalName="Resources\Sprites\frame.active.png" Configuration="Debug" Class="ProjectFile">
<DeployFile LocalName="Resources\Sprites\frame.main.png" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
@@ -258,7 +260,7 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Resources\Sprites\frame.main.png" Configuration="Debug" Class="ProjectFile">
<DeployFile LocalName="Resources\Sprites\frame.active.png" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
193 changes: 193 additions & 0 deletions sources/Scenes/Elinor.Scene.Inventory.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
unit Elinor.Scene.Inventory;

interface

uses
Vcl.Controls,
System.Classes,
Elinor.Scene.Frames,
Elinor.Scene.Base.Party,
Elinor.Button,
Elinor.Resources,
Elinor.Party,
Elinor.Scenes;

type
TSceneInventory = class(TSceneBaseParty)
private type
TButtonEnum = (btClose);
private const
ButtonText: array [TButtonEnum] of TResEnum = (reTextClose);
private
Button: array [TButtonEnum] of TButton;
ConfirmGold: Integer;
ConfirmParty: TParty;
ConfirmPartyPosition: TPosition;
public
constructor Create;
destructor Destroy; override;
procedure Render; override;
procedure Update(var Key: Word); override;
procedure Timer; override;
procedure MouseDown(AButton: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
class procedure ShowScene(AParty: TParty;
const ACloseSceneEnum: TSceneEnum);
class procedure HideScene;
end;

implementation

uses
System.Math,
System.SysUtils,
Elinor.Scene.Settlement,
Elinor.Scene.Party,
Elinor.Scene.Party2,
Elinor.Saga,
Elinor.Frame,
Elinor.Creatures;

var
ShowResources: Boolean;
CurrentParty: TParty;
CloseSceneEnum: TSceneEnum;

{ TSceneInventory }

class procedure TSceneInventory.ShowScene(AParty: TParty;
const ACloseSceneEnum: TSceneEnum);
begin
CurrentParty := AParty;
CloseSceneEnum := ACloseSceneEnum;
ShowResources := AParty = TLeaderParty.Leader;
if ShowResources then
begin
ActivePartyPosition := TLeaderParty.GetPosition;
end
else
ActivePartyPosition := AParty.GetRandomPosition;
Game.Show(scInventory);
Game.MediaPlayer.PlaySound(mmSettlement);
end;

class procedure TSceneInventory.HideScene;
begin
Game.MediaPlayer.PlaySound(mmClick);
Game.MediaPlayer.PlaySound(mmSettlement);
Game.Show(CloseSceneEnum);
end;

constructor TSceneInventory.Create;
var
LButtonEnum: TButtonEnum;
LLeft, LWidth: Integer;
begin
inherited Create(reWallpaperSettlement);
LWidth := ResImage[reButtonDef].Width + 4;
LLeft := ScrWidth - ((LWidth * (Ord(High(TButtonEnum)) + 1)) div 2);
for LButtonEnum := Low(TButtonEnum) to High(TButtonEnum) do
begin
Button[LButtonEnum] := TButton.Create(LLeft, DefaultButtonTop,
ButtonText[LButtonEnum]);
Inc(LLeft, LWidth);
if (LButtonEnum = btClose) then
Button[LButtonEnum].Sellected := True;
end;
end;

destructor TSceneInventory.Destroy;
var
LButtonEnum: TButtonEnum;
begin
for LButtonEnum := Low(TButtonEnum) to High(TButtonEnum) do
FreeAndNil(Button[LButtonEnum]);
inherited;
end;

procedure TSceneInventory.MouseDown(AButton: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
inherited;
case AButton of
mbLeft:
begin
{ if Button[btHeal].MouseDown then
Heal
else if Button[btRevive].MouseDown then
Revive
else if Button[btParty].MouseDown then
ShowPartyScene
else } if Button[btClose].MouseDown then
HideScene;
end;
end;
end;

procedure TSceneInventory.MouseMove(Shift: TShiftState; X, Y: Integer);
var
LButtonEnum: TButtonEnum;
begin
inherited;
for LButtonEnum := Low(TButtonEnum) to High(TButtonEnum) do
Button[LButtonEnum].MouseMove(X, Y);
end;

procedure TSceneInventory.Render;

procedure RenderParty;
var
LPosition: TPosition;
begin
if (CurrentParty <> nil) then
for LPosition := Low(TPosition) to High(TPosition) do
DrawUnit(LPosition, CurrentParty, TFrame.Col(LPosition, psLeft),
TFrame.Row(LPosition), False, True);
end;

procedure RenderCharacterInfo;
var
LCreatureEnum: TCreatureEnum;
begin
LCreatureEnum := CurrentParty.Creature[ActivePartyPosition].Enum;
TextTop := TFrame.Row(0) + 6;
TextLeft := TFrame.Col(2) + 12;
if (LCreatureEnum <> crNone) then
DrawCreatureInfo(CurrentParty.Creature[ActivePartyPosition]);
end;

procedure RenderButtons;
var
LButtonEnum: TButtonEnum;
begin
for LButtonEnum := Low(TButtonEnum) to High(TButtonEnum) do
Button[LButtonEnum].Render;
end;

begin
inherited;

DrawTitle(reTitleInventory);
RenderParty;
// RenderCharacterInfo;

RenderButtons;
end;

procedure TSceneInventory.Timer;
begin
inherited;

end;

procedure TSceneInventory.Update(var Key: Word);
begin
inherited;
case Key of
K_ESCAPE, K_ENTER:
HideScene;
end;
end;

end.
5 changes: 3 additions & 2 deletions sources/Scenes/Elinor.Scene.Map.pas
Original file line number Diff line number Diff line change
@@ -52,7 +52,8 @@ implementation
Elinor.Scene.Scenario,
Elinor.PathFind,
Elinor.Scene.Party2,
Elinor.Spells;
Elinor.Spells,
Elinor.Scene.Inventory;

{ TSceneMap }

@@ -161,7 +162,7 @@ procedure TSceneMap.MouseMove(Shift: TShiftState; X, Y: Integer);

procedure TSceneMap.ShowInventoryScene;
begin
// TSceneParty.Show(Party[TLeaderParty.LeaderPartyIndex], scMap, True);
TSceneInventory.ShowScene(Party[TLeaderParty.LeaderPartyIndex], scMap);
end;

procedure TSceneMap.ShowAbilitiesScene;
5 changes: 3 additions & 2 deletions sources/Scenes/Elinor.Scene.Party2.pas
Original file line number Diff line number Diff line change
@@ -50,7 +50,8 @@ implementation
Elinor.Statistics,
DisciplesRL.Scene.Hire,
Elinor.Scene.Settlement,
Elinor.Scene.Spellbook;
Elinor.Scene.Spellbook,
Elinor.Scene.Inventory;

var
ShowResources: Boolean;
@@ -93,7 +94,7 @@ destructor TSceneParty2.Destroy;

procedure TSceneParty2.ShowInventoryScene;
begin

TSceneInventory.ShowScene(CurrentParty, scParty);
end;

procedure TSceneParty2.MouseDown(AButton: TMouseButton; Shift: TShiftState;
7 changes: 7 additions & 0 deletions sources/Scenes/Elinor.Scene.Skills.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
unit Elinor.Scene.Skills;

interface

implementation

end.
6 changes: 4 additions & 2 deletions sources/Scenes/Elinor.Scenes.pas
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ interface
type
TSceneEnum = (scHire, scHire2, scMenu, scMap, scParty, scSettlement, scBattle,
scSpellbook, scDifficulty, scScenario, scRace, scLeader, scTemple,
scBarracks);
scBarracks, scInventory);

const
ScreenWidth = 1344;
@@ -218,7 +218,8 @@ implementation
Elinor.Spellbook,
Elinor.Scene.Party2,
Elinor.Scene.Hire,
Elinor.Factions;
Elinor.Factions,
Elinor.Scene.Inventory;

type
TButtonEnum = (btOk, btCancel);
@@ -798,6 +799,7 @@ constructor TScenes.Create;
FScene[scHire] := TSceneHire.Create;
FScene[scHire2] := TSceneRecruit.Create;
FScene[scParty] := TSceneParty2.Create;
FScene[scInventory] := TSceneInventory.Create;
FScene[scBattle] := TSceneBattle2.Create;
FScene[scSettlement] := TSceneSettlement.Create;
FScene[scSpellbook] := TSceneSpellbook.Create;

0 comments on commit f483cc3

Please sign in to comment.