Sunday, 27 April 2014

Writing a StrPix-like program with Lazarus – 8

Rather than have the moveables’ object ID numbers displayed we will display their names.

We will store their names in a text file with each name on a separate line and where the line number matches the object ID if we consider the first line as line 0.

We could hard code the names into the program but reading them from a file means that new names can be added for new objects and the names changed if needed.

Saturday, 26 April 2014

Writing a StrPix-like program with Lazarus – 7

We will delete Edit1 we placed on the form in the previous post since it was only to test that we could access data from the Wad.version and not part of our program’s design.

Go to Window>Form1 to display the form.

Click on Edit1 to select it and then press the delete key to delete it.

Deleting the control does not remove the code that references it in TForm1.FileOpenAcccept so go to that procedure and delete the two lines we added to display the version number in Edit1.

Friday, 25 April 2014

Writing a StrPix-like program with Lazarus – 6

Our program copies the *.wad file into memory and then reads the file in memory and extracts the data into a variable named Wad which is declared in the TombRaiderWAD unit.

Since the implementation section of unit1 includes TombRaiderWAD in the uses clause, the variable Wad can be used in any of the functions or procedures in unit1’s implementation section.

The variable Wad is declared as type TWAD and we can inspect this type in the TombRaiderWAD unit to see what information is available in the Wad variable.

Create or edit tut1.raw with GIMP

The file tut1.raw and other *.raw files that have the same name as the wad files contain the sky texture for a level.

Like uklogo.raw which contains the game’s logo, these can be created or edited in GIMP.

Editing uklogo.raw is discussed in another post so I will only discuss the settings that need to change for the raw sky images.

In GIMP go to File>Open and navigate to the raw sky image.

Before clicking the Open button in the Open File dialog, expand the Select File Type dropdown and select Raw image data.

Do not mistakenly select raw image which is for raw images from digital cameras.

Writing a StrPix-like program with Lazarus – 5

To add IceBerg’s code for reading a *.wad file to our program, with our project open in Lazarus, go to the File menu and select Open.

In the Open File dialog, navigate to the WadExplorer source code folder (WADE11sources) we copied to our Lazarus projects folder.

Select and open TombRaiderWad.pas which contains all the code necessary to read a *.wad file.

IceBergsWadUnit

Monday, 21 April 2014

Writing a StrPix-like program with Lazarus – 4

Make sure the the form designer window is visible. If it is not you can use the Window menu and select the form window, “Form1” in our case, or you can press the Toggle Form/Unit button to switch to the form window. This button is only enabled if the unit displayed in the source editor has a form.

ToggleFormUnit

Writing a StrPix-like program with Lazarus – 3

Create a folder somewhere on your PC for your Lazarus projects. I named my folder Typhon32 Projects.

Extract the WadExplorer source code zip file and copy the folder into your Lazarus projects folder.

Do the same with the other source code zip files you downloaded. With the StrPix code you need to also unzip the shared folder inside the StrPix folder.

image


Sunday, 20 April 2014

Writing a StrPix-like program with Lazarus – 2

To write a program to modify a *.wad we need some *.wad files. If you don’t have TRLE installed you can get it from any of the links below. The *.wad files are found in the graphics folder. TRLE was also included on a separate disc with Tomb Raider Chronicles (TR5) for PC.

http://www.skribblerz.com/editortools.htm

http://www.tombraiderchronicles.com/tr5/editor/index.html

http://www.aspidetr.com/tools/tomb-raider-level-editor/tomb-raider-level-editor-windows-vista-xp/

If you don’t want to install TRLE you can download some *.wad files at this link.

http://www.skribblerz.com/resources.htm

Writing a StrPix-like program with Lazarus – 1

StrPix is a program used in the TRLE (Tomb Raider Level Editor) community.

tombraiderforums Level Editor forum

trle.net 

The program is used to import models into a TRLE *.wad file and to also texture and add other attributes to the models like shine and collision.

 A *.wad file stores the geometry, texture and animation data for the objects in a TRLE game.

StrPix was written in the Delphi language by TurboPascal.

TurboPascal released the source code but since the latest Delphi IDE (integrated development environment) is expensive and any cheap older versions or free versions are difficult to buy or find, it is probably necessary to write a new program from scratch to add new features or fix bugs or update it for new operating systems.

Lazarus is a free, open source IDE for the FreePascal language and FreePascal is based on Delphi.

Lazarus can open and convert simple Delphi projects to its own format but I have been unable to successfully convert any of the TRLE Delphi programs by TurboPascal (StrPix) or IceBerg (WadExplorer) or RaiderCroft (PixStr).

No matter, we can still copy most of the code.

This series of posts will hopefully also show how simple it is to start programming with Lazarus and serve as a Lazarus tutorial for beginners.

next

Friday, 18 April 2014

TRLE File Formats cutseq.pak

Program: Official tomb4.exe
Description: Contains animation data for cutscenes
Document Version: 1.0

TRLE File Formats *.trw

Program: WadMerger
Description: Animation Editor custom import/export format for animations
Document Version: 0.1

Wednesday, 16 April 2014

FreePascal programming notes #3

If you place a TImage inside a scrollbox, using the mousewheel does not scroll the TImage when the mouse is over the TImage.

If the mouse is inside the scrollbox but not over the TImage the TImage scrolls as expected with the mousewheel.

Note this may only be a problem on Windows.

Here is my workaround.

Create a handler for the scrollbox’s MouseWheelEvent with the following code.

procedure TForm1.ScrollBox1MouseWheel(Sender: TObject; Shift: TShiftState;
  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
var
  inc : integer;
begin
  inc := 16; // choose a value for the increment you desire
  if WheelDelta > 0 then inc := -16;
  ScrollBox1.VertScrollBar.Position := ScrollBox1.VertScrollBar.Position + inc;
end;
Set this procedure as the image’s MouseWheelEvent handler also.

Now the image should scroll the same when the mouse is over the image or over the scrollbox.

Note that right clicking on the scrollbox’s scrollbar will popup a menu with some options but this will not be the case for the image.