Skip to content

Commit

Permalink
25.1.23
Browse files Browse the repository at this point in the history
[Engine]
* Fix some compiler warnings.
* Rename some functions.
* Add 'Texture.Manifest' API function to read texture data from a Json object.
* Add 'Texture.ImageUT' which is same as 'Texture.Create' but allows custom initialisation of tile set.

[Diggers]
* Move all texture tile co-ordinates data to 'data.lua' so we can run a scale on them all at once.

[Assets]
* Remove font manifests.
* Update API documentation.
  • Loading branch information
Mhatxotic committed Jan 23, 2025
1 parent 064bd66 commit 5fb4a40
Show file tree
Hide file tree
Showing 43 changed files with 1,053 additions and 613 deletions.
20 changes: 9 additions & 11 deletions diggers/src/bank.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ local Fade, GameProc, GetGameTicks, HaveZogsToWin, InitLobby, IsButtonPressed,
SellSpecifiedItems, SetBottomRightTip, SetCallbacks, SetCursor,
aGemsAvailable, aObjectActions, aObjectData, aObjectDirections, aObjectJobs,
aObjectTypes, fontSpeech, texSpr;
-- Assets required --------------------------------------------------------- --
local aAssets<const> = { { T = 1, F = "bank", P = { 80, 94, 0, 0, 0 } },
{ T = 7, F = "bank" } };
-- Locals ------------------------------------------------------------------ --
local aBankerData, -- Banker data
local aAssets, -- Required assets
aBankerData, -- Banker data
aDigger, -- Currently selected digger
aPlayer, -- Owner of digger
bGameWon, -- Game is won?
Expand All @@ -44,9 +42,10 @@ local aBankerData, -- Banker data
iSpeechTimer, strTip, -- Speech timer and trip
iTreasureValueModifier, -- Modified treasure value
strBankerSpeech, -- Speech bubble text
texBank, -- Bank texture
tileBG, -- Background tile
tileSpeech; -- Speech tile
texBank; -- Bank texture
-- Tile data (See data.hpp/aAssetsData.bank.P) ----------------------------- --
local tileBG = 12; -- Background tile
local tileSpeech = 13; -- Speech tile
-- Mouse over events ------------------------------------------------------- --
local function MsOvFTarg() return IsMouseInBounds(25,113,87,183) end;
local function MsOvHabbish() return IsMouseInBounds(129,95,191,184) end;
Expand Down Expand Up @@ -248,10 +247,6 @@ local function OnLoaded(aResources)
-- Load texture. We only have 12 animations, discard all the other tiles
-- as we're using the same bitmap for other sized textures.
texBank = aResources[1];
texBank:TileSTC(12);
-- Cache background and speech bubble co-ordinates
tileBG = texBank:TileA(208, 312, 512, 512);
tileSpeech = texBank:TileA(0, 488, 112, 512);
-- Get treasure value modifier
iTreasureValueModifier = GetGameTicks() // 18000;
-- Banker data
Expand Down Expand Up @@ -307,6 +302,9 @@ local function OnReady(GetAPI)
"SetKeys", "aGemsAvailable", "aObjectActions", "aObjectData",
"aObjectDirections", "aObjectJobs", "aObjectTypes", "fontSpeech",
"texSpr");
-- Setup required assets
local aAssetsData<const> = GetAPI("aAssetsData");
aAssets = { aAssetsData.bank, aAssetsData.bankm };
-- Check slot key event callbacks
local function GoCheckSlot(iSlot)
if iSpeechTimer <= 0 then SetCheckSell(iSlot, aBankerData[iSlot]) end;
Expand Down
26 changes: 13 additions & 13 deletions diggers/src/book.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ local iPagesPerTexture<const> = 20;
local iTotalPages<const> = 88; -- Maximum number of pages
local iTotalPagesM1<const> = iTotalPages - 1; -- Maximum " minus one
-- Locals ------------------------------------------------------------------ --
local aPOIData; -- Points of interest data
local aAssets, -- Assets required
aLobbyMusic, -- Lobby music asset
aLobbyClosedTexture, -- Lobby closed texture asset
aPageAsset, -- Book page asset
aPOIData; -- Points of interest data
local bCoverPage = true; -- Cover page was displayed?
local fcbFinish, -- Callback to call to exit
fcbCoverInput, -- Input callback for cover page
Expand All @@ -45,12 +49,6 @@ local iCArrow, iCExit, iCOK, iCSelect, -- Cursor ids
iSClick, iSSelect; -- Sound effects used
local strExitTip, strTip, -- Tip strings
texBook, texLobby, texPage; -- Book, lobby and page texture handles
-- Assets ------------------------------------------------------------------ --
local aBookTexture<const> = { T = 2, F = "book", P = { 0 } };
local aLobbyOpenTexture<const> = { T = 7, F = "lobby", P = { 0 } };
local aLobbyClosedTexture<const> = { T = 2, F = "lobbyc", P = { 0 } };
local aAssets<const> = { aBookTexture, false };
local aPageAsset<const> = { { T = 1, F = false, P = { 255, 200, 0, 0, 0 } } };
-- Book render callback ---------------------------------------------------- --
local function PageRender()
-- Render book background, spine and backdrop
Expand Down Expand Up @@ -208,9 +206,6 @@ end
local function OnCoverLoadResources(aResources)
-- Set texture and setup tiles
texBook = aResources[1];
texBook:TileSTC(0);
texBook:TileA( 0, 0, 304, 200); -- Cover
texBook:TileA(305, 0, 360, 200); -- Spine
-- Call supplimental load routine depending if we're in-game or not
fcbOnCoverLoadResources(aResources[2]);
-- Input book proc
Expand Down Expand Up @@ -283,8 +278,6 @@ local function OnCoverResoucesLoadedLobby(texHandle)
-- Get lobby texture and setup background tile. This will be nil if loading
-- from in-game so it doesn't matter. Already handled.
texLobby = texHandle;
texLobby:TileSTC(1);
texLobby:TileS(0, 0, 272, 428, 512);
end
-- In-Game cover resources laoded ------------------------------------------ --
local function OnCoverResoucesLoadedInGame(musHandle)
Expand All @@ -296,7 +289,7 @@ local function InitBookInGame()
-- Set text for exit tip
strExitTip = "BACK TO GAME";
-- Load just the book texture
aAssets[2] = aLobbyOpenTexture;
aAssets[2] = aLobbyMusic;
-- Set specific behaviour from in-game
fcbOnCoverLoadResources = OnCoverResoucesLoadedInGame;
fcbOnCoverPageLoaded = OnCoverPageLoadedInGame;
Expand Down Expand Up @@ -338,6 +331,13 @@ local function OnReady(GetAPI)
"LoadResources", "PlayMusic", "PlayStaticSound", "RenderInterface",
"RenderShadow", "SetBottomRightTip", "SetBottomRightTipAndShadow",
"SetCallbacks", "SetCursor", "SetKeys");
-- Prepare assets
local aAssetsData<const> = GetAPI("aAssetsData");
local aBookTexture<const> = aAssetsData.book;
aLobbyMusic = aAssetsData.lobbym;
aLobbyClosedTexture = aAssetsData.lobbyc;
aAssets = { aBookTexture, false };
aPageAsset = { aAssetsData.bookpage };
-- POI Callbacks
local function GoContents() LoadPage(1) end;
local function GoLast() LoadPage(iBookPage - 1) end;
Expand Down
37 changes: 9 additions & 28 deletions diggers/src/cntrl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ local Fade, IsButtonReleased, IsMouseInBounds, IsMouseNotInBounds,
SetBottomRightTipAndShadow, SetCallbacks, SetCursor, SetKeys,
aGlobalData, fontSpeech;
-- Locals ------------------------------------------------------------------ --
local aAssets; -- Assets required
local aFlashCache; -- Hot point flash data
local aFlashData; -- Active hot point
local aMouseOverEvents; -- Hotpoint data
Expand All @@ -34,12 +35,11 @@ local sMsg; -- Controller speech message
local sTip; -- Current bottom right tip
local texCon; -- Controller texture
local texLobby; -- Lobby texture
local tileBook, tileCon, tileConAnim; -- Book and controller character tiles
local tileFile, tileFish, tileMap; -- File, fish and map tiles
local tileRace, tileSpeech; -- Race select and speech tiles
-- Assets required --------------------------------------------------------- --
local aAssets<const> = { { T = 2, F = "lobbyc", P = { 0 } },
{ T = 2, F = "cntrl", P = { 0 } } };
-- Tile ids (see data.lua/aAssetsData.cntrl.P) ----------------------------- --
local tileConAnim<const> = 1; local tileCon<const> = 5;
local tileSpeech<const> = 6; local tileFish<const> = 7;
local tileMap<const> = 12; local tileRace<const> = 14;
local tileBook<const> = 16; local tileFile<const> = 18;
-- Render callback --------------------------------------------------------- --
local function RenderCon()
-- Frame timer slowed down
Expand Down Expand Up @@ -136,30 +136,8 @@ end
local function OnLoaded(aResources)
-- Setup lobby texture
texLobby = aResources[1];
texLobby:TileSTC(1);
texLobby:TileS(0, 0, 272, 428, 512);
-- Setup controller texture
texCon = aResources[2];
tileConAnim = texCon:TileA(0, 0, 160, 84);
texCon:TileA(0, 85, 160, 169);
texCon:TileA(0, 170, 160, 254);
texCon:TileA(0, 255, 160, 339);
-- Cache other tiles
tileCon = texCon:TileA(208, 312, 512, 512); -- [0](1)
tileSpeech = texCon:TileA(356, 250, 512, 274); -- [0](1)
tileFish = texCon:TileA(273, 275, 320, 311); -- [0](5)
texCon:TileA(321, 275, 368, 311); -- [1]
texCon:TileA(369, 275, 416, 311); -- [2]
texCon:TileA(417, 275, 464, 311); -- [3]
texCon:TileA(465, 275, 512, 311); -- [4]
tileMap = texCon:TileA( 0, 412, 63, 453); -- [0](2)
texCon:TileA( 64, 412, 127, 453); -- [1]
tileRace = texCon:TileA(128, 409, 160, 453); -- [0](2)
texCon:TileA(161, 409, 193, 453); -- [1]
tileBook = texCon:TileA( 0, 454, 79, 485); -- [0](2)
texCon:TileA( 80, 454, 159, 485); -- [1]
tileFile = texCon:TileA( 0, 486, 95, 512); -- [0](2)
texCon:TileA( 96, 486, 191, 512); -- [1]
-- Data for flashing textures to help the player know what to do
aFlashCache = {
[tileMap] = { tileMap, 9, 9 }, [tileRace] = { tileRace, 232, 160 },
Expand Down Expand Up @@ -228,6 +206,9 @@ local function OnReady(GetAPI)
"IsMouseNotInBounds", "LoadResources", "PlayStaticSound",
"RenderShadow", "SetBottomRightTipAndShadow", "SetCallbacks",
"SetCursor", "SetKeys", "aGlobalData", "fontSpeech");
-- Set assets data
local aAssetsData<const> = GetAPI("aAssetsData");
aAssets = { aAssetsData.lobbyc, aAssetsData.cntrl };
-- Mouse over events
local function MouseOverMap() return IsMouseInBounds(9, 9, 57, 52) end;
local function MouseOverBook() return IsMouseInBounds(9, 176, 76, 207) end;
Expand Down
16 changes: 10 additions & 6 deletions diggers/src/credits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ local DeInitLevel, Fade, GameProc, GetMusic, InitScore, LoadLevel,
RenderTerrain, SelectObject, SetCallbacks, SetCursor, aCreditsData,
aCreditsXData, aEndLoadData, aLevelTypesData, aLevelsData, aObjectTypes,
aObjects, aPlayers, fontLarge, fontLittle;
-- Assets required --------------------------------------------------------- --
local aAssets<const> = { { T = 2, F = "vignette", P = { 0 } } };
-- Other locals ------------------------------------------------------------ --
local aAssets; -- Assets required
local aEndLevelData<const> = { n = "END", f = "end", t = false };
-- Init ending screen functions -------------------------------------------- --
local function InitCredits(bRolling)
Expand All @@ -38,6 +38,8 @@ local function InitCredits(bRolling)
-- Build levels to pick from
local aLevels<const> = { };
for iI = 1, #aLevelsData do aLevels[1 + #aLevels] = iI end;
-- Credits input procedure
local function EmptyFunction() end
-- Init rolling credits
local function InitRollingCredits(strMusic)
-- Credit data and current absolute position on-screen
Expand Down Expand Up @@ -132,12 +134,10 @@ local function InitCredits(bRolling)
-- Keep viewport in top left
LockViewPort();
end
-- Credits input procedure
local function ExtraInput() end
-- When faded out to title? Load demo level
LoadLevel(aEndLevelData, strMusic, nil, nil,
true, aObjectTypes.DIGRANDOM, true, ExtraProc, RenderExtra,
ExtraInput);
EmptyFunction);
end
-- Load demo levels
local function LoadDemoLevel(iCreditId, strMusic)
Expand Down Expand Up @@ -220,7 +220,8 @@ local function InitCredits(bRolling)
end
-- Load demo level
LoadLevel(iLevelId, strMusic, nil, nil, true,
aObjectTypes.DIGRANDOM, true, CreditsProc, fcbCreditsRender, nil);
aObjectTypes.DIGRANDOM, true, CreditsProc, fcbCreditsRender,
EmptyFunction);
end
-- Load first level or credits
if bRolling then InitRollingCredits("credits");
Expand All @@ -243,6 +244,9 @@ local function OnReady(GetAPI)
"SelectObject", "SetCallbacks", "SetCursor", "aCreditsData",
"aCreditsXData", "aLevelTypesData", "aLevelsData", "aObjectTypes",
"aObjects", "aPlayers", "fontLarge", "fontLittle");
-- Setup required assets
local aAssetsData<const> = GetAPI("aAssetsData");
aAssets = { aAssetsData.credits };
-- Set ending level load data
aEndLevelData.t = aLevelTypesData[4];
end
Expand Down
Loading

0 comments on commit 5fb4a40

Please sign in to comment.