Skip to content

Commit

Permalink
25.1.29
Browse files Browse the repository at this point in the history
[Engine]
* Fix 'Fbo:GetMatix()' not returning the proper width and height of the frame buffer object.

[Diggers]
* Update more modules to support the new input event system.
* Fix bug when changing window size showing the texture out of bounds on the zone select screen.
* Map screen now requires holding mouse button to scroll and the horizontal scrolling zones are now relative to the window edges.
* Post-mortem screen horizontal scrolling zones are now relative to the window edges.
* Add keys to scroll map on zone select screen.
* Always show the zone title first when hovering over different zones on the selection map.
* Expand tip drawing function.
* Add difficultly level text to zone selection screen.
  • Loading branch information
Mhatxotic committed Jan 29, 2025
1 parent 553aa27 commit 0a62f72
Show file tree
Hide file tree
Showing 20 changed files with 1,258 additions and 1,134 deletions.
56 changes: 26 additions & 30 deletions diggers/src/bank.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ local CoreTicks<const>, UtilBlank<const>, UtilIsTable<const> =
-- Diggers function and data aliases --------------------------------------- --
local Fade, GameProc, GetActiveObject, GetGameTicks, HaveZogsToWin, InitLobby,
LoadResources, PlayMusic, PlayStaticSound, RenderInterface, RenderShadow,
SellSpecifiedItems, SetBottomRightTip, SetCallbacks, SetHotSpot, SetKeys,
RenderTip, SellSpecifiedItems, SetCallbacks, SetHotSpot, SetKeys,
aGemsAvailable, aObjectActions, aObjectData, aObjectDirections, aObjectJobs,
aObjectTypes, fontSpeech, texSpr;
-- Locals ------------------------------------------------------------------ --
Expand All @@ -37,7 +37,7 @@ local aAssets, -- Required assets
iSTrade, -- Trade sound effect id
iSpeechBubbleX, iSpeechBubbleY, -- Speech bubble position
iSpeechTextX, iSpeechTextY, -- Speech text position
iSpeechTimer, strTip, -- Speech timer and trip
iSpeechTimer, -- Speech timer
iTreasureValueModifier, -- Modified treasure value
strBankerSpeech, -- Speech bubble text
texBank; -- Bank texture
Expand Down Expand Up @@ -88,12 +88,14 @@ local function SetSpeech(iId, iHoldTime, iSfxId, strMsg, fcbOnComplete)
iSpeechTextX, iSpeechTextY = unpack(aBankerData[iId][8]);
-- Finish callback
local function OnComplete()
-- Call completion function
if fcbOnComplete then fcbOnComplete() end;
-- Enable hotspots again
SetHotSpot(iHotSpotId);
-- Enable keys again
SetKeys(true, iKeyBankId);
-- Call completion function if set
if fcbOnComplete then fcbOnComplete();
-- No completion function
else
-- Enable hotspots and keys again
SetHotSpot(iHotSpotId);
SetKeys(true, iKeyBankId);
end
end
-- Set event when speech completed
fcbSpeechCallback = OnComplete;
Expand Down Expand Up @@ -149,12 +151,6 @@ end
local function GoSellFTarg() Sell(1) end;
local function GoSellHabbish() Sell(2) end;
local function GoSellGrablin() Sell(3) end;
-- Hover tip callbacks ----------------------------------------------------- --
local function HoverWait() sTip = "WAIT..." end;
local function HoverPrice() sTip = "CHECK VALUE" end;
local function HoverSell() sTip = "SELL GEMS" end;
local function HoverBank() sTip = "BANK" end;
local function HoverExit() sTip = "GO TO LOBBY" end;
-- Exit bank to lobby ------------------------------------------------------ --
local function GoToLobby()
-- Play sound and exit to game
Expand Down Expand Up @@ -192,7 +188,7 @@ local function ProcRender()
fontSpeech:PrintC(iSpeechTextX, iSpeechTextY, strBankerSpeech);
end
-- Render tip
SetBottomRightTip(sTip);
RenderTip();
end
-- Main bank procedure ----------------------------------------------------- --
local function ProcLogic()
Expand Down Expand Up @@ -225,7 +221,7 @@ local function OnAssetsLoaded(aResources)
-- Initialise banker data
RefreshData();
-- No speech bubbles, reset win notification and set empty tip
iSpeechTimer, strTip = 0, "";
iSpeechTimer = 0;
-- Set colour of speech text
fontSpeech:SetCRGB(0, 0, 0.25);
-- Speech render data and message
Expand Down Expand Up @@ -264,18 +260,18 @@ local function OnScriptLoaded(GetAPI)
-- Grab imports
Fade, GameProc, GetActiveObject, GetGameTicks, HaveZogsToWin, InitLobby,
LoadResources, PlayMusic, PlayStaticSound, RegisterHotSpot, RegisterKeys,
RenderInterface, RenderShadow, SellSpecifiedItems, SetBottomRightTip,
RenderInterface, RenderShadow, RenderTip, SellSpecifiedItems,
SetCallbacks, SetHotSpot, SetKeys, aAssetsData, aCursorIdData,
aGemsAvailable, aObjectActions, aObjectData, aObjectDirections,
aObjectJobs, aObjectTypes, aSfxData, fontSpeech, texSpr =
GetAPI("Fade", "GameProc", "GetActiveObject", "GetGameTicks",
"HaveZogsToWin", "InitLobby", "LoadResources", "PlayMusic",
"PlayStaticSound", "RegisterHotSpot", "RegisterKeys",
"RenderInterface", "RenderShadow", "SellSpecifiedItems",
"SetBottomRightTip", "SetCallbacks", "SetHotSpot", "SetKeys",
"aAssetsData", "aCursorIdData", "aGemsAvailable", "aObjectActions",
"aObjectData", "aObjectDirections", "aObjectJobs", "aObjectTypes",
"aSfxData", "fontSpeech", "texSpr");
"RenderInterface", "RenderShadow", "RenderTip", "SellSpecifiedItems",
"SetCallbacks", "SetHotSpot", "SetKeys", "aAssetsData",
"aCursorIdData", "aGemsAvailable", "aObjectActions", "aObjectData",
"aObjectDirections", "aObjectJobs", "aObjectTypes", "aSfxData",
"fontSpeech", "texSpr");
-- Setup required assets
aAssets = { aAssetsData.bank, aAssetsData.bankm };
-- Set sound effect ids
Expand All @@ -286,14 +282,14 @@ local function OnScriptLoaded(GetAPI)
aCursorIdData.SELECT, aCursorIdData.EXIT;
-- Register hotspots
iHotSpotId = RegisterHotSpot({
{ 25, 113, 62, 70, 0, iCSelect, HoverSell, false, GoSellFTarg },
{ 129, 95, 62, 89, 0, iCSelect, HoverSell, false, GoSellHabbish },
{ 234, 97, 61, 87, 0, iCSelect, HoverSell, false, GoSellGrablin },
{ 40, 24, 33, 17, 0, iCSelect, HoverPrice, false, GoPriceFTarg },
{ 144, 24, 33, 17, 0, iCSelect, HoverPrice, false, GoPriceHabbish },
{ 248, 24, 33, 17, 0, iCSelect, HoverPrice, false, GoPriceGrablin },
{ 8, 8, 304, 200, 0, 0, HoverBank, false, false },
{ 0, 0, 0, 240, 3, iCExit, HoverExit, false, GoToLobby }
{ 25, 113, 62, 70, 0, iCSelect, "SELL 1ST", false, GoSellFTarg },
{ 129, 95, 62, 89, 0, iCSelect, "SELL 2ND", false, GoSellHabbish },
{ 234, 97, 61, 87, 0, iCSelect, "SELL 3RD", false, GoSellGrablin },
{ 40, 24, 33, 17, 0, iCSelect, "CHECK 1ST", false, GoPriceFTarg },
{ 144, 24, 33, 17, 0, iCSelect, "CHECK 2ND", false, GoPriceHabbish },
{ 248, 24, 33, 17, 0, iCSelect, "CHECK 3RD", false, GoPriceGrablin },
{ 8, 8, 304, 200, 0, 0, "BANK", false, false },
{ 0, 0, 0, 240, 3, iCExit, "GO TO LOBBY", false, GoToLobby }
});
-- Register keybinds
local aKeys<const> = Input.KeyCodes;
Expand Down
56 changes: 27 additions & 29 deletions diggers/src/book.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
local UtilBlank<const>, UtilClampInt<const> = Util.Blank, Util.ClampInt;
-- Diggers function and data aliases --------------------------------------- --
local Fade, GameProc, InitCon, InitContinueGame, LoadResources, PlayMusic,
PlayStaticSound, RenderInterface, RenderShadow, SetBottomRightTip,
SetBottomRightTipAndShadow, SetCallbacks, SetHotSpot, SetKeys;
PlayStaticSound, RenderInterface, RenderShadow, RenderTip, RenderTipShadow,
SetTip, SetCallbacks, SetHotSpot, SetKeys;
-- Consts ------------------------------------------------------------------ --
-- Pages each sized 510x200 stored inside texture sized 1024^2. OpenGL 3.2
-- guarantees us that 1024^2 textures are supported by every renderer.
Expand All @@ -41,7 +41,7 @@ local iFilePage, iTilePage, -- File id and tile id
iKeyBankStartId, -- Key bank to set when cover page load
iLoadPage, -- Current physical page
iSClick, iSSelect; -- Sound effects used
local strExitTip, strPage, sTip, -- Tip strings
local strExitTip, strPage, -- Tip strings
texBook, texLobby, texPage; -- Book, lobby and page texture handles
-- Book render callback ---------------------------------------------------- --
local function ProcRenderPage()
Expand Down Expand Up @@ -69,7 +69,7 @@ local function OnPageAssetsLoaded(aResource, fcbOnComplete)
SetCallbacks(fcbProcLogic, ProcRenderPage, nil);
end
-- Page loader function ---------------------------------------------------- --
local function LoadPage(iPage, fcbOnComplete)
local function LoadPage(fcbOnComplete)
-- Set and clamp requested page
iPage = UtilClampInt(iPage, 0, iTotalPagesM1);
local iPageP1<const> = 1 + iPage;
Expand All @@ -80,37 +80,35 @@ local function LoadPage(iPage, fcbOnComplete)
iFilePage, iTilePage = iLoadPage, iPage % iPagesPerTexture;
-- Update page number
strPage = "PAGE "..iPageP1.."/"..iTotalPages;
sTip = strPage;
SetTip(strPage);
-- No need to do anything else
return;
end
-- Set displayed page number and assign the tip to it
strPage = "LOADING P"..iPageP1;
sTip = strPage;
SetTip(strPage);
-- Load the specified texture with the page image
aPageAsset[1].F = "e/"..iLoadPage;
LoadResources("Book"..iLoadPage,
aPageAsset, OnPageAssetsLoaded, fcbOnComplete);
end
-- Switch page with sound -------------------------------------------------- --
local function GoAdjustPage(iPage)
local function GoAdjustPage(iNewPage)
-- Play the sound
PlayStaticSound(iSClick);
-- Set the page
iPage = iNewPage;
-- Load the specified new page
LoadPage(iPage);
LoadPage();
end
-- Book button action callbacks -------------------------------------------- --
local function GoExit() fcbFinish() end
local function GoIndex() GoAdjustPage(1) end;
local function GoLast() GoAdjustPage(iPage - 1) end;
local function GoNext() GoAdjustPage(iPage + 1) end;
-- Hot spot hover callbacks ------------------------------------------------ --
local function HoverCover() sTip = "OPEN BOOK" end;
local function HoverExit() sTip = strExitTip end;
local function HoverIndex() sTip = "INDEX PAGE" end;
local function HoverNext() sTip = "NEXT PAGE" end;
local function HoverLast() sTip = "LAST PAGE" end;
local function HoverIdle() sTip = strPage end;
-- Hover functions (dynamic) ----------------------------------------------- --
local function HoverExit() SetTip(strExitTip) end;
local function HoverIdle() SetTip(strPage) end;
-- Scroll wheel callback --------------------------------------------------- --
local function Scroll(nX, nY)
if nY < 0 then GoLast() elseif nY > 0 then GoNext() end;
Expand Down Expand Up @@ -141,7 +139,7 @@ local function ProcRenderBackInGame()
-- Render game interface
RenderInterface();
-- Draw tip
SetBottomRightTip(sTip);
RenderTip();
-- Render shadow
RenderShadow(8, 8, 312, 208);
end
Expand All @@ -150,7 +148,7 @@ local function ProcRenderBackLobby()
-- Render static background
texLobby:BlitLT(-54, 0);
-- Draw tip and return
SetBottomRightTipAndShadow(sTip);
RenderTipShadow();
end
-- Cover loaded in-game supplimental callback ------------------------------ --
local function OnPageAssetsPostInGame()
Expand Down Expand Up @@ -232,7 +230,7 @@ local function OnAssetsLoaded(aResources, fcbProcCustomHandle)
-- Call supplimental load routine depending if we're in-game or not
fcbProcCustomHandle(aResources[2]);
-- Load current page
LoadPage(iPage, OnPageAssetsPost);
LoadPage(OnPageAssetsPost);
end
-- Init book screen function ----------------------------------------------- --
local function InitBook(bFromInGame)
Expand Down Expand Up @@ -273,12 +271,12 @@ local function OnScriptLoaded(GetAPI)
-- Grab imports
Fade, GameProc, InitCon, InitContinueGame, LoadResources, PlayMusic,
PlayStaticSound, RegisterHotSpot, RegisterKeys, RenderInterface,
RenderShadow, SetBottomRightTip, SetBottomRightTipAndShadow, SetCallbacks,
SetHotSpot, SetKeys, aAssetsData, aCursorIdData, aSfxData =
RenderShadow, RenderTip, RenderTipShadow, SetCallbacks, SetHotSpot,
SetKeys, SetTip, aAssetsData, aCursorIdData, aSfxData =
GetAPI("Fade", "GameProc", "InitCon", "InitContinueGame",
"LoadResources", "PlayMusic", "PlayStaticSound", "RegisterHotSpot",
"RegisterKeys", "RenderInterface", "RenderShadow", "SetBottomRightTip",
"SetBottomRightTipAndShadow", "SetCallbacks", "SetHotSpot", "SetKeys",
"RegisterKeys", "RenderInterface", "RenderShadow", "RenderTip",
"RenderTipShadow", "SetCallbacks", "SetHotSpot", "SetKeys", "SetTip",
"aAssetsData", "aCursorIdData", "aSfxData");
-- Prepare assets
local aTexture<const> = aAssetsData.book;
Expand All @@ -305,16 +303,16 @@ local function OnScriptLoaded(GetAPI)
aCursorIdData.OK, aCursorIdData.SELECT, aCursorIdData.EXIT;
-- Set points of interest data for cover
iHotSpotCoverId = RegisterHotSpot({
{ 8, 8, 304, 200, 0, iCOK, HoverCover, false, GoOpen },
{ 0, 0, 0, 240, 3, iCExit, HoverExit, false, GoExit }
{ 8, 8, 304, 200, 0, iCOK, "OPEN BOOK", false, GoOpen },
{ 0, 0, 0, 240, 3, iCExit, HoverExit, false, GoExit }
});
-- Set points of interest data
iHotSpotPageId = RegisterHotSpot({
{ 17, 70, 37, 22, 0, iCSelect, HoverIndex, Scroll, GoIndex },
{ 17, 96, 37, 22, 0, iCSelect, HoverNext, Scroll, GoNext },
{ 17, 122, 37, 22, 0, iCSelect, HoverLast, Scroll, GoLast },
{ 8, 8, 304, 200, 0, 0, HoverIdle, Scroll, false },
{ 0, 0, 0, 240, 3, iCExit, HoverExit, Scroll, GoExit }
{ 17, 70, 37, 22, 0, iCSelect, "INDEX PAGE", Scroll, GoIndex },
{ 17, 96, 37, 22, 0, iCSelect, "NEXT PAGE", Scroll, GoNext },
{ 17, 122, 37, 22, 0, iCSelect, "LAST PAGE", Scroll, GoLast },
{ 8, 8, 304, 200, 0, 0, HoverIdle, Scroll, false },
{ 0, 0, 0, 240, 3, iCExit, HoverExit, Scroll, GoExit }
});
end
-- Exports and imports ----------------------------------------------------- --
Expand Down
39 changes: 16 additions & 23 deletions diggers/src/cntrl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ local unpack<const> = table.unpack;
local CoreTicks<const> = Core.Ticks;
-- Diggers function and data aliases --------------------------------------- --
local Fade, InitBook, InitFile, InitLobby, InitMap, InitRace, PlayStaticSound,
LoadResources, RenderShadow, SetBottomRightTipAndShadow, SetCallbacks,
SetHotSpot, SetKeys, aGlobalData, fontSpeech;
LoadResources, RenderShadow, RenderTipShadow, SetCallbacks, SetHotSpot,
SetKeys, aGlobalData, fontSpeech;
-- Locals ------------------------------------------------------------------ --
local aAssets, -- Assets required
aFlashCache, -- Hot point flash data
Expand All @@ -32,7 +32,6 @@ local aAssets, -- Assets required
iSpeechTimer, -- Time to show controller speech.
iSSelect, -- Select sound effect id
sMsg, -- Controller speech message
sTip, -- Current bottom right tip
texCon, -- Controller texture
texLobby; -- Lobby texture
-- Tile ids (see data.lua/aAssetsData.cntrl.P) ----------------------------- --
Expand Down Expand Up @@ -65,7 +64,7 @@ local function ProcRender()
iSpeechTimer = iSpeechTimer - 1;
end
-- Draw tip
SetBottomRightTipAndShadow(sTip);
RenderTipShadow();
end
-- Controller logic -------------------------------------------------------- --
local function ProcLogic()
Expand Down Expand Up @@ -101,13 +100,6 @@ local function GoFile() GoTransition(InitFile) end;
local function GoLobby() GoTransition(InitLobby, true) end;
local function GoMap() GoTransition(InitMap) end;
local function GoRace() GoTransition(InitRace) end;
-- Hot spot hover functions ------------------------------------------------ --
local function HoverBook() sTip = "THE BOOK" end;
local function HoverIdle() sTip = "CONTROLLER" end;
local function HoverFile() sTip = "LOAD/SAVE" end;
local function HoverLobby() sTip = "GO TO LOBBY" end;
local function HoverMap() sTip = "SELECT ZONE" end;
local function HoverRace() sTip = "SELECT RACE" end;
-- When controller screen has faded in? ------------------------------------ --
local function OnFadedIn()
-- Set keybank and hotspots
Expand All @@ -128,9 +120,9 @@ local function OnAssetsLoaded(aResources)
[tileBook] = { tileBook, 9, 176 }, [tileFile] = { tileFile, 73, 181 },
};
-- Set empty tip and speech timer
sTip, iSpeechTimer, sMsg, aFlashData, aSpeechList, iSpeechListCount,
iSpeechTimer, sMsg, aFlashData, aSpeechList, iSpeechListCount,
iSpeechListLoop, iSpeechIndex, iLastHotpoint =
nil, 0, nil, nil, { }, 60, 0, 0, 0;
0, nil, nil, { }, 60, 0, 0, 0;
-- Add a speech item
local function AddSpeechItem(sString, iId)
aSpeechList[iSpeechListCount] = { sString, aFlashCache[iId] };
Expand Down Expand Up @@ -197,13 +189,13 @@ local function OnScriptLoaded(GetAPI)
-- Grab imports
Fade, InitBook, InitFile, InitLobby, InitMap, InitRace, LoadResources,
PlayStaticSound, RegisterHotSpot, RegisterKeys, RenderShadow,
SetBottomRightTipAndShadow, SetCallbacks, SetCursor, SetHotSpot, SetKeys,
RenderTipShadow, SetCallbacks, SetCursor, SetHotSpot, SetKeys,
aAssetsData, aCursorIdData, aGlobalData, aSfxData, fontSpeech =
GetAPI("Fade", "InitBook", "InitFile", "InitLobby", "InitMap",
"InitRace", "LoadResources", "PlayStaticSound", "RegisterHotSpot",
"RegisterKeys", "RenderShadow", "SetBottomRightTipAndShadow",
"SetCallbacks", "SetCursor", "SetHotSpot", "SetKeys", "aAssetsData",
"aCursorIdData", "aGlobalData", "aSfxData", "fontSpeech");
"RegisterKeys", "RenderShadow", "RenderTipShadow", "SetCallbacks",
"SetCursor", "SetHotSpot", "SetKeys", "aAssetsData", "aCursorIdData",
"aGlobalData", "aSfxData", "fontSpeech");
-- Set assets data
aAssets = { aAssetsData.lobbyc, aAssetsData.cntrl };
-- Set sound effect ids
Expand All @@ -212,16 +204,17 @@ local function OnScriptLoaded(GetAPI)
local iCSelect<const>, iCExit<const> =
aCursorIdData.SELECT, aCursorIdData.EXIT;
-- Set up hotspots data
-- Hot spot hover functions ------------------------------------------------ --
local aHSMap<const>, aHSBook<const>, aHSFile<const>,
aHSCntrl<const>, aHSExit<const> =
{ 9, 9, 48, 52, 0, iCSelect, HoverMap, false, GoMap },
{ 9, 176, 67, 31, 0, iCSelect, HoverBook, false, GoBook },
{ 76, 182, 87, 25, 0, iCSelect, HoverFile, false, GoFile },
{ 8, 8, 304, 200, 0, 0, HoverIdle, false, false },
{ 0, 0, 0, 240, 3, iCExit, HoverLobby, false, GoLobby }
{ 9, 9, 48, 52, 0, iCSelect, "SELECT ZONE", false, GoMap },
{ 9, 176, 67, 31, 0, iCSelect, "THE BOOK", false, GoBook },
{ 76, 182, 87, 25, 0, iCSelect, "LOAD/SAVE", false, GoFile },
{ 8, 8, 304, 200, 0, 0, "CONTROLLER", false, false },
{ 0, 0, 0, 240, 3, iCExit, "GO TO LOBBY", false, GoLobby }
-- Register hotspots for new game
iHotSpotIdNew = RegisterHotSpot({ aHSMap, aHSBook, aHSFile,
{ 242, 160, 19, 123, 0, iCSelect, HoverRace, false, GoRace },
{ 242, 160, 19, 123, 0, iCSelect, "SELECT RACE", false, GoRace },
aHSCntrl, aHSExit });
-- Register hotspots for continue game
iHotSpotIdCont =
Expand Down
Loading

0 comments on commit 0a62f72

Please sign in to comment.