mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-28 15:57:59 +03:00

commit77d0865c8a
Author: Nemoel-Tomo <tomo_669@hotmail.com> Date: Sun Feb 16 08:20:58 2025 +0100 Waterfall emitter formatting fix (#1570) commit92329741ad
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Sat Feb 15 07:46:37 2025 +0100 Clarify EmitSpotLight description commit562637f599
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Fri Feb 14 23:10:40 2025 +0100 Fixed #1574 commita64825b6f1
Author: Sezz <sezzary@outlook.com> Date: Fri Feb 14 04:30:00 2025 +1100 Add missing shift in EmitParticle() commit455d547de7
Author: Sezz <sezzary@outlook.com> Date: Fri Feb 14 04:25:55 2025 +1100 Add lock to parallel task class commit918237113f
Author: Sezz <sezzary@outlook.com> Date: Thu Feb 13 14:59:16 2025 +1100 Make script utils more idiomatic to C++ commitb78376b0ab
Author: Sezz <sezzary@outlook.com> Date: Thu Feb 13 12:44:06 2025 +1100 Use correct angle conversion in EmitPatricle() commit3e00302ade
Author: Sezz <sezzary@outlook.com> Date: Thu Feb 13 05:38:56 2025 +1100 Update Rotation.cpp commitf1c1fd2f63
Author: Sezz <sezzary@outlook.com> Date: Thu Feb 13 04:12:34 2025 +1100 Add Lerp() method to script Rotation class commit6ef9675bcb
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Wed Feb 12 09:08:45 2025 +0100 Update CHANGELOG.md commitca56f62f54
Author: Sezz <sezzary@outlook.com> Date: Wed Feb 12 18:59:54 2025 +1100 Multithreading (#1541) * Create Worker class for multithreading * Update TombEngine.vcxproj * Rename GetWorkerCount() to GetThreadCount() * Add ProcessInParallel template for vectors * Add multiThreaded flag to settings, process sprites in parallel * Update Flow.Settings.html * Refine WorkerManager class conventions; deinit threads properly * Don't require explicit destruction * Address basic PR notes * Update Worker.cpp * Simplify ThreadManager class * Add method for running single task * Use singleton pattern; use more appropriate Controller suffix * Update WorkerController template method * Revise method * Handle exception in ~WorkerController() * Grammar * Correctly init single-threaded mode * Update CHANGELOG.md * Defer thread init until g_GameFlow is valid * unsigned int -> int * Rename class --------- Co-authored-by: Lwmte <3331699+Lwmte@users.noreply.github.com> commitd37ac17a39
Author: Sezz <sezzary@outlook.com> Date: Wed Feb 12 17:36:12 2025 +1100 Formatting commit62ce2f043d
Author: Sezz <sezzary@outlook.com> Date: Tue Feb 11 18:05:07 2025 +1100 Fix bridges moving the player when the player is underwater commit0bb9af9894
Author: Sezz <sezzary@outlook.com> Date: Tue Feb 11 17:31:51 2025 +1100 puzzle_keys.cpp formatting commit7d18d7506f
Author: davidmarr <116632612+davidmarr@users.noreply.github.com> Date: Sun Feb 9 15:58:15 2025 +0100 Update Type module (#1569) * Update VolumeObject.cpp fixed Volume:GetActive() method * Update CHANGELOG.md * function description LevelFuncs.OnUseItem * Revert "function description LevelFuncs.OnUseItem" This reverts commit2478afca68
. * Update Type.lua commit909f631c2f
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Sat Feb 8 11:04:40 2025 +0100 Fixed mistake in electricity rendering commita840c2200c
Merge:2c6331f58
a31faffec
Author: Sezz <sezzary@outlook.com> Date: Sat Feb 8 02:58:13 2025 +1100 Merge branch 'develop' of https://github.com/MontyTRC89/TombEngine into develop commit2c6331f583
Author: Sezz <sezzary@outlook.com> Date: Sat Feb 8 02:58:03 2025 +1100 Deprecate CalculateDistance() script function commita31faffec5
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Fri Feb 7 08:31:14 2025 +0100 Update CHANGELOG.md commit1f81ccf44d
Author: TrainWrack <120750885+TrainWrack@users.noreply.github.com> Date: Thu Feb 6 18:05:25 2025 -0500 Diary module (TEN side) (#1509) * Update to bug report form * Update bug_report.yaml * Update AUTHORS.md - Tomo (general coding, special FX coding, bug fixing) * Update CHANGELOG.md * Update CHANGELOG.md * Update bug_report.yaml * Add files via upload * Add files via upload * Add ID_DIARY_SPRITES (1384) and DIARY_ENTRY_SPRITES (1385) * Delete Scripts/Engine/Diarymodule.lua * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Delete Scripts/Engine/CustomBar.lua * Add files via upload * Update CustomDiary.lua * Add files via upload * Add files via upload * Add files via upload * Update CustomDiary.lua * Upload * Update CHANGELOG.md * Revisions * Doc revisions * Remove GameVars.Engine everywhere. * Added error warnings by integrating type module * Update bug_report.yaml * Fixed the bug with GameVars resetting each level. * Added .Engine back. * Added missing checks. * Removed nil from textOptions loop * Added full TEN name for printlogs. * LatestChanges * Added section for import. --------- Co-authored-by: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> commit34ff933e5b
Author: Sezz <sezzary@outlook.com> Date: Thu Feb 6 18:48:45 2025 +1100 Update LogicHandler.cpp commit5500b13659
Author: Sezz <sezzary@outlook.com> Date: Thu Feb 6 18:47:33 2025 +1100 Update LogicHandler.cpp commitacb1bb1518
Author: Sezz <sezzary@outlook.com> Date: Thu Feb 6 18:46:16 2025 +1100 Enforce proper convention for the few Lua table constants that didn't use it yet commit89d5b74298
Author: TrainWrack <120750885+TrainWrack@users.noreply.github.com> Date: Thu Feb 6 02:09:53 2025 -0500 Fix Trigger Triggerer (#1565) * Fix * Update CHANGELOG.md * Update trigger.cpp --------- Co-authored-by: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> commit8316062e3a
Merge:5f447d95c
599a651b6
Author: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> Date: Thu Feb 6 06:03:41 2025 +0000 Merge branch 'develop' of https://github.com/MontyTRC89/TombEngine into develop commit5f447d95c5
Author: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> Date: Thu Feb 6 06:03:18 2025 +0000 Fix stopwatch display in inventory (due to removal of trademarked item) Now the trademarked item from Tomb Raider Chronicles has been removed and replaced with the stopwatch from Tomb Raider III commit599a651b6f
Author: Sezz <sezzary@outlook.com> Date: Thu Feb 6 16:56:19 2025 +1100 Update lens flare and starfield Lua docs commit94ede801bc
Author: Sezz <sezzary@outlook.com> Date: Thu Feb 6 16:35:59 2025 +1100 Misc. script doc tidying; move some script classes to namespaces commitbe8048407e
Author: TrainWrack <120750885+TrainWrack@users.noreply.github.com> Date: Wed Feb 5 23:51:35 2025 -0500 Underwater keys/puzzles (#1529) * Update to bug report form * Update bug_report.yaml * Update AUTHORS.md - Tomo (general coding, special FX coding, bug fixing) * Update CHANGELOG.md * Update CHANGELOG.md * Update bug_report.yaml * First Push * Updae LaraStruct to use animation 280 * Update puzzles_keys.cpp * Update CHANGELOG.md * Squashed commit of the following: commite50a4f8c27
Author: TrainWrack <120750885+TrainWrack@users.noreply.github.com> Date: Wed Dec 25 20:07:56 2024 -0500 Doc Revision commit39a6e713ce
Author: TrainWrack <120750885+TrainWrack@users.noreply.github.com> Date: Wed Dec 25 20:02:47 2024 -0500 Doc revisions commitc330343820
Author: TrainWrack <120750885+TrainWrack@users.noreply.github.com> Date: Wed Dec 25 19:52:59 2024 -0500 Update CHANGELOG.md commitad62d7b605
Author: TrainWrack <120750885+TrainWrack@users.noreply.github.com> Date: Wed Dec 25 19:42:32 2024 -0500 Check commite135195641
Author: TrainWrack <120750885+TrainWrack@users.noreply.github.com> Date: Wed Dec 25 19:26:23 2024 -0500 First Commit commit4a6c6ee270
Author: TrainWrack <120750885+TrainWrack@users.noreply.github.com> Date: Wed Dec 25 19:19:05 2024 -0500 Update EffectsFunctions.cpp * Revert "Squashed commit of the following:" This reverts commitff2e49c6ed
. * Formatting. * Formatting. * Update CHANGELOG.md --------- Co-authored-by: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> Co-authored-by: Nemoel-Tomo <tomo_669@hotmail.com> Co-authored-by: Jakub <kubabilinski03@gmail.com> Co-authored-by: Jakub <80340234+Jakub768@users.noreply.github.com> Co-authored-by: Lwmte <3331699+Lwmte@users.noreply.github.com> Co-authored-by: TrainWreck <barry@DESKTOP-HC53CPN> commit106787d911
Author: Sezz <sezzary@outlook.com> Date: Thu Feb 6 04:34:28 2025 +1100 Doc corrections commit737f5aa742
Author: Sezz <sezzary@outlook.com> Date: Thu Feb 6 04:28:58 2025 +1100 Make getters const commit2b41ae743a
Author: Sezz <sezzary@outlook.com> Date: Thu Feb 6 02:35:16 2025 +1100 Tidy up Lua doc for Static class commit437ce7c139
Author: Sezz <sezzary@outlook.com> Date: Thu Feb 6 01:22:59 2025 +1100 Complete short -> int conversions for Lua commit237ceca0f4
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Wed Feb 5 08:04:23 2025 +0100 Fixed custom shatter sounds commit64e0c303ba
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Tue Feb 4 20:58:09 2025 +0100 Update CHANGELOG.md commitd2b692cb3b
Author: Sezz <sezzary@outlook.com> Date: Mon Feb 3 16:15:41 2025 +1100 ShadowMode::Lara -> ShadowMode::Player commitebb20121ac
Author: Sezz <sezzary@outlook.com> Date: Sat Feb 1 23:57:54 2025 +1100 -1 -> NO_VALUE and other formatting commit4a6f30a152
Author: Jakub <80340234+Jakub768@users.noreply.github.com> Date: Sat Feb 1 12:07:10 2025 +0000 Update LICENSE commit45d46e0e6b
Author: Sezz <sezzary@outlook.com> Date: Sat Feb 1 22:55:35 2025 +1100 Fix display pickup string not being interpolated in 60FPS mode commit903fdf288f
Author: Sezz <sezzary@outlook.com> Date: Sat Feb 1 22:40:50 2025 +1100 Optimise BitField class (#1511) * Optimise BitField class * DebugBuild -> DEBUG_BUILD * Fix merge error commit48902b00a9
Author: TrainWrack <120750885+TrainWrack@users.noreply.github.com> Date: Sat Feb 1 06:23:04 2025 -0500 Emit air bubble exposed (#1537) * Update to bug report form * Update bug_report.yaml * Update AUTHORS.md - Tomo (general coding, special FX coding, bug fixing) * Update CHANGELOG.md * Update CHANGELOG.md * Update bug_report.yaml * Update EffectsFunctions.cpp * First Commit * Check * Update CHANGELOG.md * Doc revisions * Doc Revision * Update EffectsFunctions.cpp * Remove room from arguements. * Doc clarification. * Make Size and Amplitude Optional * Update EffectsFunctions.cpp --------- Co-authored-by: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> Co-authored-by: Nemoel-Tomo <tomo_669@hotmail.com> Co-authored-by: Jakub <kubabilinski03@gmail.com> Co-authored-by: Jakub <80340234+Jakub768@users.noreply.github.com> Co-authored-by: Lwmte <3331699+Lwmte@users.noreply.github.com> Co-authored-by: Sezz <sezzary@outlook.com> commitfa0e125f59
Author: TrainWrack <120750885+TrainWrack@users.noreply.github.com> Date: Sat Feb 1 06:22:49 2025 -0500 Emit particle upgrade (#1542) * Update to bug report form * Update bug_report.yaml * Update AUTHORS.md - Tomo (general coding, special FX coding, bug fixing) * Update CHANGELOG.md * Update CHANGELOG.md * Update bug_report.yaml * Expose ObjectSlot * Docs * Code Update * FinalPush * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md * Expose startRot * Expose startRot * Remove Space. * Code cleanup, revise doc comment * Nicer defaults in doc --------- Co-authored-by: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> Co-authored-by: Nemoel-Tomo <tomo_669@hotmail.com> Co-authored-by: Jakub <kubabilinski03@gmail.com> Co-authored-by: Jakub <80340234+Jakub768@users.noreply.github.com> Co-authored-by: Lwmte <3331699+Lwmte@users.noreply.github.com> Co-authored-by: Sezz <sezzary@outlook.com> commitbcbe216508
Author: Sezz <sezzary@outlook.com> Date: Sat Feb 1 20:17:11 2025 +1100 Update Vec3.cpp commit06c33908d9
Author: Sezz <sezzary@outlook.com> Date: Sat Feb 1 20:13:34 2025 +1100 Explicit conversion commitc99b8abf25
Author: Sezz <sezzary@outlook.com> Date: Sat Feb 1 20:01:55 2025 +1100 Add Translate() functions to script Vec2 and Vec3 classes commitd8c646fabd
Author: Sezz <sezzary@outlook.com> Date: Sat Feb 1 17:47:29 2025 +1100 Start restructuring script Moveable class commit98b01ff64a
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Thu Jan 30 22:25:57 2025 +0100 Fixed #1562 commitd163d1ec30
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Mon Jan 27 19:27:08 2025 +0100 Fixed #1558 commit6ef8a562e5
Author: Sezz <sezzary@outlook.com> Date: Tue Jan 28 04:10:12 2025 +1100 Update doc comment for moveable commitd919e16790
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Sat Jan 25 23:03:28 2025 +0100 Fixed player model submerging into the floor while swimming underwater commitfaf17cd03a
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Fri Jan 24 23:18:14 2025 +0100 Fixed #1557 commit5f402e380b
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Fri Jan 24 22:55:08 2025 +0100 Fixed #1556 commitae20a49eb2
Author: Sezz <sezzary@outlook.com> Date: Thu Jan 23 17:02:26 2025 +1100 Update VS hint comments for various classes commitfb97628ac9
Author: Sezz <sezzary@outlook.com> Date: Thu Jan 23 16:48:46 2025 +1100 Add `Scale` field to `Pose` class (#1546) * Reapply "Add functional Scale field to Pose class" This reverts commit92305a5d25
. * Update lara.cpp commitfc0c260ea1
Author: Sezz <sezzary@outlook.com> Date: Thu Jan 23 15:25:09 2025 +1100 Update script Rotation class and its doc commit0dd0061a94
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Tue Jan 21 20:55:57 2025 +0100 Update CHANGELOG.md commit7735f660ab
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Tue Jan 21 20:49:32 2025 +0100 Fixed #1553 commit5764965230
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Tue Jan 21 20:47:06 2025 +0100 Fixed #1554 commitb55675b9ce
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Tue Jan 21 20:46:47 2025 +0100 Fixed #1552 commit7be096f86a
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Sun Jan 19 05:41:05 2025 +0100 Fixed dynamic light shadows not being handled correctly commitdb2649e936
Author: Sezz <sezzary@outlook.com> Date: Sat Jan 18 19:54:04 2025 +1100 Fix two block platform sometimes not traversing room portals correctly; cleanup commitff41900bd9
Author: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> Date: Sun Jan 12 16:35:44 2025 +0000 Updated to reflect develop branch after merging Pull Request commit2a89abe66d
Author: Nemoel-Tomo <tomo_669@hotmail.com> Date: Sun Jan 12 17:15:45 2025 +0100 Tr1 electric ball (#1413) Implementation of the Electric Ball from Tomb Raider I, inside Level 5: St Francis Folly commita97548467e
Author: Nemoel-Tomo <tomo_669@hotmail.com> Date: Fri Jan 10 23:27:48 2025 +0100 Waterfall_Emitter (#1359) * waterfall emitter. warning for the test I changed waterfallmist object * test * update * update * update * formatting * formatting * formatting * update mist color * import develop * bugfix sprite * added mor sprite particles * waterfall intensity * update waterfall to be more filled * update * Create a new sprite sequence for waterfall * Fixed texture order * removed GetParticleDistanceFade() from waterfall * Order * Update Particle struct; update waterfall * Update Particle struct * Simplify waterfall emitter * Simplify waterfall emitter * Simplify waterfall emitter * Simplify * Fix waterfall density; move sprite slot * Update Waterfall.cpp * fixed some small bugs with the waterfall after simplify * commit * imported develop 60fps branch * fixed waterfall errors * update * commit * update/test * update Waterfall * fixed last bugs * formatting * added option for sound * update * update, fixing errors * update * formatting * Formatting * fixed color issue, now only savegame is left * formatting * added new fields to savegame * targetpos is now Vector3 * import develop * Fixes according to GH notes + move waterfall-specific code out of effects.cpp * Rollback object ID rename, add missing enum * renamed ID_WATERFALL_ into ID_WATERFALL_SPRITES * fixed SpriteSeqID for spark in spark.cpp * Update CHANGELOG.md * rewritten waterfall code * Update waterfall impact point --------- Co-authored-by: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> Co-authored-by: Sezz <sezzary@outlook.com> Co-authored-by: Lwmte <3331699+Lwmte@users.noreply.github.com> commitbfe07f6e21
Author: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> Date: Sun Jan 5 16:45:30 2025 +0000 Bump version in Lua API for development commit4dce157665
Author: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> Date: Sun Jan 5 16:27:38 2025 +0000 Bump Tomb Editor version for next dev cycle Amended also in the Development branch for TE commitc25c7a1c96
Author: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> Date: Sun Jan 5 15:10:17 2025 +0000 Update CHANGELOG.md commit2da7401c28
Author: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> Date: Sun Jan 5 15:09:41 2025 +0000 Update changelog with template for the next version. commit66d7e51f5d
Author: Stranger1992 <84292688+Stranger1992@users.noreply.github.com> Date: Sat Jan 4 18:41:11 2025 +0000 Bump dev version to 1.7.2 This has been done to draw a line post-release and any commits after this to form the next release. Version number may change. commitcebc0175c9
Author: Sezz <sezzary@outlook.com> Date: Sat Jan 4 17:03:46 2025 +1100 Move splash effect to its own file commitb81b28039c
Author: Sezz <sezzary@outlook.com> Date: Sat Jan 4 16:03:07 2025 +1100 Fix gravity being applied when vaulting on the same frame as the player lands commit5444ede2a8
Author: Sezz <sezzary@outlook.com> Date: Sat Jan 4 15:51:52 2025 +1100 Reliably stop at edge when running at it while holding Walk commit43d5bb9639
Author: Sezz <sezzary@outlook.com> Date: Fri Jan 3 23:31:59 2025 +1100 Update CHANGELOG.md commitfb7e4dce70
Merge:9baf5222f
12ac1219e
Author: Sezz <sezzary@outlook.com> Date: Fri Jan 3 23:06:28 2025 +1100 Merge branch 'develop' of https://github.com/MontyTRC89/TombEngine into develop commit9baf5222f8
Author: Sezz <sezzary@outlook.com> Date: Fri Jan 3 23:06:25 2025 +1100 Reset IsAirborne flag properly when exiting fly cheat commit12ac1219e9
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Thu Jan 2 13:10:57 2025 +0100 Update spark.cpp commit7f071b5ec5
Author: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Thu Jan 2 11:15:04 2025 +0100 Port additional ricochet effect from tomb4
1574 lines
No EOL
82 KiB
Lua
1574 lines
No EOL
82 KiB
Lua
-----
|
|
--- Diaries:
|
|
-- The module provides functions to create and manage Diaries. It maintains diary definitions and entries through all levels and hubs.
|
|
-- Each diary is accessed by the object that was used to create it.
|
|
--
|
|
-- Example usage:
|
|
--
|
|
-- local CustomDiary = require("Engine.CustomDiary")
|
|
--
|
|
-- --This function creates a diary from the DiarySetup.lua template file in script folder
|
|
-- CustomDiary.ImportDiary("DiarySetup")
|
|
--
|
|
-- --This method gets the diary that was created with the DIARY_ITEM object and stores it in variable diary.
|
|
-- local diary = CustomDiary.Get(TEN.Objects.ObjID.DIARY_ITEM)
|
|
-- --This method opens the diary on the 3rd page
|
|
-- diary:showDiary(3)
|
|
--
|
|
-- @luautil Diary
|
|
|
|
local Type = require("Engine.Type")
|
|
|
|
local CustomDiary = {}
|
|
CustomDiary.__index = CustomDiary
|
|
|
|
LevelFuncs.Engine.Diaries = {}
|
|
GameVars.Engine.Diaries = GameVars.Engine.Diaries or {}
|
|
GameVars.Engine.LastUsedDiary = GameVars.Engine.LastUsedDiary or nil
|
|
|
|
--- Imports diary from an external file. There are different types that must be defined. (diary, background, controls, pageNumbers, notification, image, text, narration). Each of the section's arguements are the same as the functions described in this documentation.
|
|
-- Refer to DiarySetup.lua file for a sample script.
|
|
-- @tparam string fileName Name of file in the script folder without extension to import the diary from.
|
|
|
|
function CustomDiary.ImportDiary(fileName)
|
|
|
|
if not Type.IsString(fileName) then
|
|
TEN.Util.PrintLog("'fileName' is in an incorrect format. Expected a string type in function 'CustomDiary.ImportDiary' for the diary system.", Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
local importDiary = nil
|
|
local diaryObject = nil
|
|
local unlockCount = 1
|
|
local diaryData = require(fileName)
|
|
|
|
--Create the diary
|
|
for _, entry in ipairs(diaryData) do
|
|
if entry.type == "diary" then
|
|
|
|
if not Type.IsNumber(entry.object) or ((entry.object < 596 or entry.object > 611) and entry.object ~= 986) then
|
|
TEN.Util.PrintLog("Invalid object slot. Please use a pickup object slot in the range PICKUP_ITEM1 (596) to PICKUP_ITEM 16 (611) or DIARY_ITEM (986). Error in template data for diary entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.objectIdBg) or entry.objectIdBg < 1353 or entry.objectIdBg > 1400 then
|
|
TEN.Util.PrintLog("Invalid objectIdBg slot. Please use a sprite slot. Error in template data for diary entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.spriteIdBg) then
|
|
TEN.Util.PrintLog("'spriteIdBg' is not a number. Error in template data for diary entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsColor(entry.colorBg) then
|
|
TEN.Util.PrintLog("'colorBg' is not in a Color format. Error in template data for diary entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsVec2(entry.pos) then
|
|
TEN.Util.PrintLog("'pos' is not a Vec2. Error in template data for diary entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.rot) then
|
|
TEN.Util.PrintLog("'rot' is not a number. Error in template data for diary entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsVec2(entry.scale) then
|
|
TEN.Util.PrintLog("'scale' is not a Vec2. Error in template data for diary entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.alignMode) or entry.alignMode < 0 or entry.alignMode > 8 then
|
|
TEN.Util.PrintLog("'alignMode' is not a valid View.AlignMode type. Error in template data for diary entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.blendMode) or entry.blendMode < 0 or entry.blendMode > 11 then
|
|
TEN.Util.PrintLog("'blendMode' is not a valid Effects.BlendID type. Error in template data for diary entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.scaleMode) and entry.scaleMode < 0 or entry.scaleMode > 2 then
|
|
TEN.Util.PrintLog("'scaleMode' is not a valid View.ScaleMode type. Error in template data for diary entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.alpha) or entry.alpha < 0 or entry.alpha > 255 then
|
|
TEN.Util.PrintLog("'alpha' is not a number or not within range (0-255). Error in template data for diary entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.pageSound) or entry.pageSound <=0 then
|
|
TEN.Util.PrintLog("'pageSound' is not a valid number. Error in template data for diary entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.exitSound) or entry.exitSound <=0 then
|
|
TEN.Util.PrintLog("'exitSound' is not a valid number. Error in template data for diary entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.pagesToUnlock) or entry.pagesToUnlock <=0 then
|
|
TEN.Util.PrintLog("'pagesToUnlock' is not a valid page number. Error in template data for diary entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
CustomDiary.Create(
|
|
entry.object,
|
|
entry.objectIdBg,
|
|
entry.spriteIdBg,
|
|
entry.colorBg,
|
|
entry.pos,
|
|
entry.rot,
|
|
entry.scale,
|
|
entry.alignMode,
|
|
entry.scaleMode,
|
|
entry.blendMode,
|
|
entry.alpha,
|
|
entry.pageSound,
|
|
entry.exitSound
|
|
)
|
|
|
|
unlockCount = entry.pagesToUnlock
|
|
diaryObject = entry.object
|
|
end
|
|
end
|
|
|
|
--Start the diary
|
|
CustomDiary.Status(true)
|
|
importDiary = CustomDiary.Get(diaryObject)
|
|
|
|
for _, entry in ipairs(diaryData) do
|
|
if entry.type == "background" then
|
|
|
|
if not Type.IsNumber(entry.objectIdBg) or entry.objectIdBg < 1353 or entry.objectIdBg > 1400 then
|
|
TEN.Util.PrintLog("Invalid objectIdBg slot. Please use a sprite slot. Error in template data for background entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.spriteIdBg) then
|
|
TEN.Util.PrintLog("'spriteIdBg' is not a number. Error in template data for background entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsColor(entry.colorBg) then
|
|
TEN.Util.PrintLog("'colorBg' is not in a Color format. Error in template data for background entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsVec2(entry.pos) then
|
|
TEN.Util.PrintLog("'pos' is not a Vec2. Error in template data for background entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.rot) then
|
|
TEN.Util.PrintLog("'rot' is not a number. Error in template data for background entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsVec2(entry.scale) then
|
|
TEN.Util.PrintLog("'scale' is not a Vec2. Error in template data for background entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.alignMode) or entry.alignMode < 0 or entry.alignMode > 8 then
|
|
TEN.Util.PrintLog("'alignMode' is not a valid View.AlignMode type. Error in template data for background entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.blendMode) or entry.blendMode < 0 or entry.blendMode > 11 then
|
|
TEN.Util.PrintLog("'blendMode' is not a valid Effects.BlendID type. Error in template data for background entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.scaleMode) and entry.scaleMode < 0 or entry.scaleMode > 2 then
|
|
TEN.Util.PrintLog("'scaleMode' is not a valid View.ScaleMode type. Error in template data for background entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.alpha) or entry.alpha < 0 or entry.alpha > 255 then
|
|
TEN.Util.PrintLog("'alpha' is not a number or not within range (0-255). Error in template data for background entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
importDiary:AddBackground(
|
|
entry.objectIdBg,
|
|
entry.spriteIdBg,
|
|
entry.colorBg,
|
|
entry.pos,
|
|
entry.rot,
|
|
entry.scale,
|
|
entry.alignMode,
|
|
entry.scaleMode,
|
|
entry.blendMode,
|
|
entry.alpha
|
|
)
|
|
elseif entry.type == "pageNumbers" then
|
|
|
|
if not Type.IsNumber(entry.pageNoType) or entry.pageNoType < 1 or entry.pageNoType > 2 then
|
|
TEN.Util.PrintLog("'pageNoType' is not a a valid option (1 or 2). Error in template data for page numbers entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsString(entry.prefix) then
|
|
TEN.Util.PrintLog("'prefix' is not a a string. Error in template data for page numbers entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsString(entry.separator) then
|
|
TEN.Util.PrintLog("'separator' is not a a string. Error in template data for page numbers entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsVec2(entry.textPos) then
|
|
TEN.Util.PrintLog("'textPos' is not a a Vec2. Error in template data for page numbers entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsTable(entry.textOptions) then
|
|
TEN.Util.PrintLog("'textOptions' is not a table. Error in template data for page numbers entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
else
|
|
for _, data in pairs(entry.textOptions) do
|
|
if type(data) ~= "number" or data < 0 or data > 3 then
|
|
TEN.Util.PrintLog("Data in 'textOptions' table is not a valid Strings.DisplayStringOption type. Error in template data for page numbers entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
end
|
|
end
|
|
|
|
if not Type.IsNumber(entry.textScale) then
|
|
TEN.Util.PrintLog("'textScale' is not a number. Error in template data for page numbers entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsColor(entry.textColor) then
|
|
TEN.Util.PrintLog("'textColor' is not in a Color format. Error in template data for page numbers entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
importDiary:CustomizePageNumbers(
|
|
entry.pageNoType,
|
|
entry.prefix,
|
|
entry.separator,
|
|
entry.textPos,
|
|
entry.textOptions,
|
|
entry.textScale,
|
|
entry.textColor
|
|
)
|
|
elseif entry.type == "controls" then
|
|
if not Type.IsString(entry.string1) then
|
|
TEN.Util.PrintLog("'string1' is not a string. Error in template data for controls entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
if not Type.IsString(entry.string2) then
|
|
TEN.Util.PrintLog("'string2' is not a string. Error in template data for controls entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
if not Type.IsString(entry.string3) then
|
|
TEN.Util.PrintLog("'string3' is not a string. Error in template data for controls entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
if not Type.IsString(entry.string4) then
|
|
TEN.Util.PrintLog("'string4' is not a string. Error in template data for controls entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
if not Type.IsString(entry.separator) then
|
|
TEN.Util.PrintLog("'separator' is not a string. Error in template data for controls entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
if not Type.IsVec2(entry.textPos) then
|
|
TEN.Util.PrintLog("'textPos' is not a Vec2. Error in template data for controls entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsTable(entry.textOptions) then
|
|
TEN.Util.PrintLog("'textOptions' is not a table. Error in template data for controls entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
else
|
|
for _, data in pairs(entry.textOptions) do
|
|
if type(data) ~= "number" or data < 0 or data > 3 then
|
|
TEN.Util.PrintLog("Data in 'textOptions' table is not a valid Strings.DisplayStringOption type. Error in template data for controls entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
end
|
|
end
|
|
|
|
if not Type.IsNumber(entry.textScale) then
|
|
TEN.Util.PrintLog("'textScale' is not a number. Error in template data for controls entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsColor(entry.textColor) then
|
|
TEN.Util.PrintLog("'textColor' is not in a Color format. Error in template data for controls entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
importDiary:CustomizeControls(
|
|
entry.textPos,
|
|
entry.textOptions,
|
|
entry.textScale,
|
|
entry.textColor)
|
|
importDiary:CustomizeControlsText(
|
|
entry.string1,
|
|
entry.string2,
|
|
entry.string3,
|
|
entry.string4,
|
|
entry.separator)
|
|
elseif entry.type == "notification" then
|
|
if not Type.IsNumber(entry.notificationTime) or entry.notificationTime <=0 then
|
|
TEN.Util.PrintLog("'notificationTime' is not a valid number. Error in template data for notification entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.objectId) or entry.objectId < 1353 or entry.objectId > 1400 then
|
|
TEN.Util.PrintLog("Invalid objectId slot. Please use a sprite slot. Error in template data for notification entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.spriteId) then
|
|
TEN.Util.PrintLog("'spriteId' is not a number. Error in template data for notification entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsColor(entry.color) then
|
|
TEN.Util.PrintLog("'color' is not in a Color format. Error in template data for notification entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsVec2(entry.pos) then
|
|
TEN.Util.PrintLog("'pos' is not a Vec2. Error in template data for notification entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.rot) then
|
|
TEN.Util.PrintLog("'rot' is not a number. Error in template data for notification entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsVec2(entry.scale) then
|
|
TEN.Util.PrintLog("'scale' is not a Vec2. Error in template data for notification entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.alignMode) or entry.alignMode < 0 or entry.alignMode > 8 then
|
|
TEN.Util.PrintLog("'alignMode' is not a valid View.AlignMode type. Error in template data for notification entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.blendMode) or entry.blendMode < 0 or entry.blendMode > 11 then
|
|
TEN.Util.PrintLog("'blendMode' is not a valid Effects.BlendID type. Error in template data for notification entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.scaleMode) and entry.scaleMode < 0 or entry.scaleMode > 2 then
|
|
TEN.Util.PrintLog("'scaleMode' is not a valid View.ScaleMode type. Error in template data for notification entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.notificationSound) or entry.notificationSound <=0 then
|
|
TEN.Util.PrintLog("'notificationSound' is not a valid number. Error in template data for notification entry. Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
importDiary:CustomizeNotification(
|
|
entry.notificationTime,
|
|
entry.objectId,
|
|
entry.spriteId,
|
|
entry.color,
|
|
entry.pos,
|
|
entry.rot,
|
|
entry.scale,
|
|
entry.alignMode,
|
|
entry.scaleMode,
|
|
entry.blendMode,
|
|
entry.notificationSound
|
|
)
|
|
elseif entry.type == "image" then
|
|
|
|
if not Type.IsNumber(entry.pageIndex) or entry.pageIndex <=0 then
|
|
TEN.Util.PrintLog("'pageIndex' is not a valid page number. Error in template data for image entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.objectId) or entry.objectId < 1353 or entry.objectId > 1400 then
|
|
TEN.Util.PrintLog("Invalid objectId slot. Please use a sprite slot. Error in template data for image entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.spriteId) then
|
|
TEN.Util.PrintLog("'spriteId' is not a number. Error in template data for image entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsColor(entry.color) then
|
|
TEN.Util.PrintLog("'color' is not in a Color format. Error in template data for image entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsVec2(entry.pos) then
|
|
TEN.Util.PrintLog("'pos' is not a Vec2. Error in template data for image entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.rot) then
|
|
TEN.Util.PrintLog("'rot' is not a number. Error in template data for image entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsVec2(entry.scale) then
|
|
TEN.Util.PrintLog("'scale' is not a Vec2. Error in template data for image entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.alignMode) or entry.alignMode < 0 or entry.alignMode > 8 then
|
|
TEN.Util.PrintLog("'alignMode' is not a valid View.AlignMode type for image entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.blendMode) or entry.blendMode < 0 or entry.blendMode > 11 then
|
|
TEN.Util.PrintLog("'blendMode' is not a valid Effects.BlendID type for image entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(entry.scaleMode) and entry.scaleMode < 0 or entry.scaleMode > 2 then
|
|
TEN.Util.PrintLog("'scaleMode' is not a valid View.ScaleMode type for image entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
importDiary:AddImageEntry(
|
|
entry.pageIndex,
|
|
entry.objectId,
|
|
entry.spriteId,
|
|
entry.color,
|
|
entry.pos,
|
|
entry.rot,
|
|
entry.scale,
|
|
entry.alignMode,
|
|
entry.scaleMode,
|
|
entry.blendMode
|
|
)
|
|
elseif entry.type == "text" then
|
|
|
|
if not Type.IsNumber(entry.pageIndex) or entry.pageIndex <=0 then
|
|
TEN.Util.PrintLog("'pageIndex' is not a valid page number. Error in template data for text entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsString(entry.text) then
|
|
TEN.Util.PrintLog("'text' is not a string. Error in template data for text entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsVec2(entry.textPos) then
|
|
TEN.Util.PrintLog("'textPos' is not a a Vec2. Error in template data for text entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsTable(entry.textOptions) then
|
|
TEN.Util.PrintLog("'textOptions' is not a table. Error in template data for text entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
else
|
|
for _, data in pairs(entry.textOptions) do
|
|
if type(data) ~= "number" or data < 0 or data > 3 then
|
|
TEN.Util.PrintLog("Data in 'textOptions' table is not a valid Strings.DisplayStringOption type. Error in template data for text entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
end
|
|
end
|
|
|
|
if not Type.IsNumber(entry.textScale) then
|
|
TEN.Util.PrintLog("'textScale' is not a number. Error in template data for text entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsColor(entry.textColor) then
|
|
TEN.Util.PrintLog("'textColor' is not in a Color format. Error in template data for text entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
importDiary:AddTextEntry(
|
|
entry.pageIndex,
|
|
entry.text,
|
|
entry.textPos,
|
|
entry.textOptions,
|
|
entry.textScale,
|
|
entry.textColor
|
|
)
|
|
elseif entry.type == "narration" then
|
|
|
|
if not Type.IsNumber(entry.pageIndex) or entry.pageIndex <=0 then
|
|
TEN.Util.PrintLog("'pageIndex' is not a valid page number. Error in template data for narration entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsString(entry.trackName) then
|
|
TEN.Util.PrintLog("'trackName' is not a string. Error in template data for narration entry for page: "..tostring(entry.pageIndex)..". Import Stopped for file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
importDiary:AddNarration(
|
|
entry.pageIndex,
|
|
entry.trackName
|
|
)
|
|
elseif entry.type == "diary" then
|
|
-- Skip this entry as diary is already imported. This comment is needed to avouid the error of Unknown type for diary.
|
|
else
|
|
TEN.Util.PrintLog("Unknown entry type: " .. tostring(entry.type).." in file: "..tostring(fileName), Util.LogLevel.WARNING)
|
|
end
|
|
end
|
|
|
|
--Unlock the pages as per the template
|
|
importDiary:UnlockPages(unlockCount, false)
|
|
print("External diary from file: "..tostring(fileName).." imported")
|
|
end
|
|
|
|
--- Creates a diary with extensive configuration options.
|
|
-- Parameters:
|
|
-- @tparam Objects.ObjID object The pickup object that will be used to create the diary. The diary can be created using PICKUP_ITEMX (596-611) or DIARY_ITEM (986). Access the diary by selecting the item in the inventory.
|
|
-- @tparam Objects.ObjID objectIdBg Object ID for the diary's sprite.
|
|
-- @tparam int spriteIdBg SpriteID from the specified object for the diary's sprite.
|
|
-- @tparam Color colorBg Color of diary's sprite.
|
|
-- @tparam Vec2 pos X,Y position of the bar's background in screen percent (0-100).
|
|
-- @tparam float rot rotation of the diary's sprite (0-360).
|
|
-- @tparam Vec2 scale X,Y Scaling factor for the bar's background sprite.
|
|
-- @tparam View.AlignMode alignMode Alignment for the diary's sprite.
|
|
-- @tparam View.ScaleMode scaleMode Scaling for the diary's sprite.
|
|
-- @tparam Effects.BlendID blendMode Blending modes for the diary's sprite.
|
|
-- @tparam number alpha alpha value for the diary's sprite (0-255).
|
|
-- @tparam Sound pageSound Sound to play with page turn.
|
|
-- @tparam Sound exitSound Sound to play when existing the diary.
|
|
-- @treturn CustomDiary
|
|
CustomDiary.Create = function(object, objectIdBg, spriteIdBg, colorBg, pos, rot, scale, alignMode, scaleMode, blendMode, alpha, pageSound, exitSound)
|
|
|
|
if not Type.IsNumber(object) or ((object < 596 or object > 611) and object ~= 986) then
|
|
TEN.Util.PrintLog("Error: Invalid object slot for diary creation. Please use a pickup object slot PICKUP_ITEM1 (596) to PICKUP_ITEM 16 (611) or DIARY_ITEM (986).", Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
local dataName = object .. "_diarydata"
|
|
local self = {Name = dataName}
|
|
GameVars.Engine.LastUsedDiary = object
|
|
|
|
if GameVars.Engine.Diaries[dataName] then
|
|
return setmetatable(self, CustomDiary)
|
|
end
|
|
|
|
GameVars.Engine.Diaries[dataName] = {}
|
|
|
|
if not Type.IsNumber(objectIdBg) or objectIdBg < 1353 or objectIdBg > 1400 then
|
|
TEN.Util.PrintLog("Invalid objectIdBg slot. Please use a sprite slot. Expected a sprite slot in function 'CustomDiary.Create' for the diary system.", Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[dataName].ObjectIdBg = objectIdBg
|
|
|
|
if not Type.IsNumber(spriteIdBg) then
|
|
TEN.Util.PrintLog("'spriteIdBg' is in an incorrect format. Expected a number type in function 'CustomDiary.Create' for the diary system.", Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[dataName].SpriteIdBg = spriteIdBg
|
|
|
|
if not Type.IsColor(colorBg) then
|
|
TEN.Util.PrintLog("'colorBg' is in an incorrect format. Expected a Color type in function 'CustomDiary.Create' for the diary system.", Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[dataName].ColorBg = colorBg
|
|
|
|
if not Type.IsVec2(pos) then
|
|
TEN.Util.PrintLog("'posBg' is in an incorrect format. Expected a Vec2 type in function 'CustomDiary.Create' for the diary system.", Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[dataName].Pos = pos
|
|
|
|
if not Type.IsNumber(rot) then
|
|
TEN.Util.PrintLog("'rot' is in an incorrect format. Expected a number type in function 'CustomDiary.Create' for the diary system.", Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[dataName].Rot = rot
|
|
|
|
|
|
if not Type.IsVec2(scale) then
|
|
TEN.Util.PrintLog("'scale' is in an incorrect format. Expected a Vec2 type in function 'CustomDiary.Create' for the diary system.", Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[dataName].Scale = scale
|
|
|
|
if not Type.IsNumber(alignMode) or alignMode < 0 or alignMode > 8 then
|
|
TEN.Util.PrintLog("'alignMode' is not a valid View.AlignMode type in function 'CustomDiary.Create' for the diary system.", Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[dataName].AlignMode = alignMode
|
|
|
|
if not Type.IsNumber(blendMode) or blendMode < 0 or blendMode > 11 then
|
|
TEN.Util.PrintLog("'blendMode' is not a valid Effects.BlendID type in function 'CustomDiary.Create' for the diary system.", Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[dataName].BlendMode = blendMode
|
|
|
|
if not Type.IsNumber(scaleMode) and scaleMode < 0 or scaleMode > 2 then
|
|
TEN.Util.PrintLog("'scaleMode' is not a valid View.ScaleMode type in function 'CustomDiary.Create' for the diary system.", Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[dataName].ScaleMode = scaleMode
|
|
|
|
if not Type.IsNumber(alpha) or alpha < 0 or alpha > 255 then
|
|
TEN.Util.PrintLog("'alpha is in an incorrect format. Expected a number (0-255) type in function 'CustomDiary.Create' for the diary system.", Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[dataName].Alpha = alpha
|
|
|
|
if not Type.IsNumber(pageSound) or pageSound <=0 then
|
|
TEN.Util.PrintLog("'pageSound' is in an incorrect format. Expected a number type in function 'CustomDiary.Create' for the diary system.", Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[dataName].PageSound = pageSound
|
|
|
|
if not Type.IsNumber(exitSound) or exitSound <=0 then
|
|
TEN.Util.PrintLog("'exitSound' is in an incorrect format. Expected a number type in function 'CustomDiary.Create' for the diary system:.", Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[dataName].ExitSound = exitSound
|
|
|
|
GameVars.Engine.Diaries[dataName].Name = dataName
|
|
GameVars.Engine.Diaries[dataName].CurrentPageIndex = 1
|
|
GameVars.Engine.Diaries[dataName].UnlockedPages = 1
|
|
GameVars.Engine.Diaries[dataName].Pages = {NarrationTrack=nil,TextEntries={},ImageEntries={}}
|
|
GameVars.Engine.Diaries[dataName].Object = object
|
|
GameVars.Engine.Diaries[dataName].CurrentAlpha = 0
|
|
GameVars.Engine.Diaries[dataName].TargetAlpha = 255
|
|
GameVars.Engine.Diaries[dataName].EntryCurrentAlpha = 0
|
|
GameVars.Engine.Diaries[dataName].EntryTargetAlpha = 255
|
|
GameVars.Engine.Diaries[dataName].Visible = false
|
|
GameVars.Engine.Diaries[dataName].Notification = {}
|
|
GameVars.Engine.Diaries[dataName].PageNumbers = {}
|
|
GameVars.Engine.Diaries[dataName].Controls = {}
|
|
GameVars.Engine.Diaries[dataName].Background = {}
|
|
GameVars.Engine.Diaries[dataName].AlphaBlendSpeed = 100
|
|
GameVars.Engine.Diaries[dataName].EntryFadingIn = true
|
|
|
|
print("CustomDiary Constructed for CustomDiary: " .. dataName)
|
|
return setmetatable(self, CustomDiary)
|
|
end
|
|
|
|
--- The function retrieves a diary by its unique object. This function is useful when you need to access or manipulate a diary that has already been created .
|
|
-- @tparam Objects.ObjID object The pickup object that was used to create the diary (596-611,986).
|
|
-- @treturn CustomDiary The diary created using the object.
|
|
CustomDiary.Get = function(object)
|
|
local dataName = object .. "_diarydata"
|
|
if GameVars.Engine.Diaries[dataName] then
|
|
local self = {Name = dataName}
|
|
return setmetatable(self, CustomDiary)
|
|
else
|
|
TEN.Util.PrintLog("Diary does not exist for object: "..tostring(object), Util.LogLevel.WARNING)
|
|
end
|
|
end
|
|
|
|
--- The function removes a custom diary and its associated data from the system. It ensures that the diary is no longer tracked or accessible in the LevelVars.Engine.Diaries.
|
|
-- Please call this once a diary has served its purpose. It helps reduce the savegame size.
|
|
-- @tparam Objects.ObjID object The pickup object that was used to create the diary (596-611,986).
|
|
CustomDiary.Delete = function (object)
|
|
local dataName = object .. "_diarydata"
|
|
if GameVars.Engine.Diaries[dataName] then
|
|
GameVars.Engine.Diaries[dataName] = nil
|
|
end
|
|
end
|
|
|
|
--- The function adds the callback to enable diaries in levels. This needs to be added to every level preferably in the LevelFuncs.OnStart.
|
|
-- @bool value True enables the diaries to be activated. False would disable the diaries.
|
|
CustomDiary.Status = function(value)
|
|
|
|
if Type.IsBoolean(value) then
|
|
if GameVars.Engine.Diaries then
|
|
if value == true then
|
|
TEN.Logic.AddCallback(TEN.Logic.CallbackPoint.POSTUSEITEM, LevelFuncs.Engine.Diaries.ActivateDiary)
|
|
TEN.Util.PrintLog("Diary system started.", Util.LogLevel.INFO)
|
|
elseif value == false then
|
|
TEN.Logic.RemoveCallback(TEN.Logic.CallbackPoint.POSTUSEITEM, LevelFuncs.Engine.Diaries.ActivateDiary)
|
|
TEN.Util.PrintLog("Diary system stopped.", Util.LogLevel.INFO)
|
|
end
|
|
end
|
|
else
|
|
TEN.Util.PrintLog("'value' is in an incorrect format. Expected a bool type in function 'CustomDiary.Status' for the diary system", Util.LogLevel.WARNING)
|
|
end
|
|
end
|
|
|
|
--- The function checks whether the specified diary is currently visible.
|
|
-- @treturn bool true if the diary is visible and false if it is not.
|
|
function CustomDiary:IsVisible()
|
|
|
|
if GameVars.Engine.Diaries[self.Name] then
|
|
return GameVars.Engine.Diaries[self.Name].Visible
|
|
end
|
|
end
|
|
|
|
--- The function displays the specified diary. Can be used to call the diary directly using volume or classic triggers.
|
|
-- @tparam int pageIndex The page number at which diary should be opened.
|
|
function CustomDiary:ShowDiary(pageIndex)
|
|
|
|
if GameVars.Engine.Diaries[self.Name] then
|
|
|
|
local object = GameVars.Engine.Diaries[self.Name].Object
|
|
|
|
if not Type.IsNumber(pageIndex) or pageIndex > #GameVars.Engine.Diaries[self.Name].Pages or pageIndex <=0 then
|
|
TEN.Util.PrintLog("'pageIndex' is in an incorrect format or not a valid page number. Expected a number type in function 'showDiary' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
GameVars.Engine.Diaries[self.Name].CurrentPageIndex = pageIndex
|
|
GameVars.Engine.Diaries[self.Name].NextPageIndex = pageIndex
|
|
|
|
LevelFuncs.Engine.Diaries.ActivateDiary(object)
|
|
|
|
end
|
|
end
|
|
|
|
--- The function returns the number of unlocked pages in the diary.
|
|
-- @treturn int total number of unlocked pages in the diary.
|
|
function CustomDiary:GetUnlockedPageCount()
|
|
|
|
if GameVars.Engine.Diaries[self.Name] then
|
|
return GameVars.Engine.Diaries[self.Name].UnlockedPages
|
|
end
|
|
end
|
|
|
|
--- The function unlocks the specified diary up to the given page number.
|
|
-- This value can be overridden to lock or unlock pages as needed.
|
|
-- A lower number can be set to restrict access to previously unlocked pages.
|
|
-- @tparam int pageIndex The page number up to which the diary should be unlocked.
|
|
-- @tparam bool notification If true, and notification has been defined, a notification icon and sound will be played.
|
|
function CustomDiary:UnlockPages(pageIndex, notification)
|
|
if GameVars.Engine.Diaries[self.Name] then
|
|
|
|
if not Type.IsNumber(pageIndex) or pageIndex > #GameVars.Engine.Diaries[self.Name].Pages or pageIndex <= 0 then
|
|
TEN.Util.PrintLog("'pageIndex' is in an incorrect format or not a valid page number. Expected a number type in function 'unlockPages' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsBoolean(notification) then
|
|
TEN.Util.PrintLog("'notification' is in an incorrect format. Expected a bool type in function 'unlockPages' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
local diary = GameVars.Engine.Diaries[self.Name]
|
|
diary.UnlockedPages = pageIndex
|
|
diary.CurrentPageIndex = pageIndex
|
|
diary.NextPageIndex = pageIndex
|
|
print("UnlockPages: currentPageIndex = " .. tostring(diary.CurrentPageIndex))
|
|
|
|
if notification and diary.Notification and next(diary.Notification) then
|
|
PlaySound(diary.Notification.NotificationSound)
|
|
diary.Notification.ElapsedTime = 0
|
|
diary.TargetAlpha = 255
|
|
diary.CurrentAlpha = 1
|
|
TEN.Logic.AddCallback(TEN.Logic.CallbackPoint.PRELOOP, LevelFuncs.Engine.Diaries.ShowNotification)
|
|
end
|
|
end
|
|
end
|
|
|
|
--- The function clears the page for the diary.
|
|
-- @tparam int pageIndex The page number to be cleared.
|
|
function CustomDiary:ClearPage(pageIndex)
|
|
|
|
if not Type.IsNumber(pageIndex) or pageIndex > #GameVars.Engine.Diaries[self.Name].Pages or pageIndex <=0 then
|
|
TEN.Util.PrintLog("'pageIndex' is in an incorrect format or not a valid page number. Expected a number type in function 'clearPage' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if GameVars.Engine.Diaries[self.Name] then
|
|
GameVars.Engine.Diaries[self.Name].Pages[pageIndex]= {NarrationTrack=nil,TextEntries={},ImageEntries={}}
|
|
TEN.Util.PrintLog("Page Cleared: ".. tostring(pageIndex).." for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
end
|
|
end
|
|
|
|
--- Adds a text entry to the specified page for the diary.
|
|
-- @tparam int pageIndex page number to add the text entry to.
|
|
-- @tparam string text Text entry to be added to the page.
|
|
-- @tparam Vec2 textPos X,Y position of the text.
|
|
-- @tparam Strings.DisplayStringOption textOptions alignment and effects for the text. Default: None. Please note text is automatically aligned to the LEFT
|
|
-- @tparam number textScale Scale factor for the text.
|
|
-- @tparam Color textColor Color of the text.
|
|
function CustomDiary:AddTextEntry(pageIndex, text, textPos, textOptions, textScale, textColor)
|
|
local textEntry = {}
|
|
|
|
if not Type.IsString(text) then
|
|
TEN.Util.PrintLog("'text' is in an incorrect format. Expected a string type in function 'addTextEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
textEntry.text = text
|
|
|
|
if not Type.IsVec2(textPos) then
|
|
TEN.Util.PrintLog("'textPos' is in an incorrect format. Expected a Vec2 type in function 'addTextEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
textEntry.textPos = textPos
|
|
|
|
if not Type.IsTable(textOptions) then
|
|
TEN.Util.PrintLog("'textOptions' is in an incorrect format. Expected a table type in function 'addTextEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
for _, data in pairs(textOptions) do
|
|
if type(data) ~= "number" or data < 0 or data > 3 then
|
|
TEN.Util.PrintLog("Data in 'textOptions' table is not a valid Strings.DisplayStringOption type in function 'addTextEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
end
|
|
textEntry.textOptions = textOptions
|
|
|
|
if not Type.IsNumber(textScale) then
|
|
TEN.Util.PrintLog("'textScale' is in an incorrect format. Expected a number type in function 'addTextEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
textEntry.textScale = textScale
|
|
|
|
if not Type.IsColor(textColor) then
|
|
TEN.Util.PrintLog("'textColor' is in an incorrect format. Expected a Color type in function 'addTextEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
textEntry.textColor = textColor
|
|
|
|
if Type.IsNumber(pageIndex) and pageIndex > 0 then
|
|
if not GameVars.Engine.Diaries[self.Name].Pages[pageIndex] then
|
|
GameVars.Engine.Diaries[self.Name].Pages[pageIndex] = {NarrationTrack=nil, TextEntries = {}, ImageEntries = {}}
|
|
end
|
|
table.insert(GameVars.Engine.Diaries[self.Name].Pages[pageIndex].TextEntries, textEntry)
|
|
print("Text entry added to page: ".. tostring(pageIndex).." for the diary system: "..tostring(self.Name))
|
|
else
|
|
TEN.Util.PrintLog("'pageIndex' is in an incorrect format. Expected a number type in function 'addTextEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
end
|
|
end
|
|
|
|
--- Adds an image entry to the specified page for the diary.
|
|
-- @tparam int pageIndex page number to add the image entry to.
|
|
-- @tparam Objects.ObjID objectId Object ID for the image entry sprite.
|
|
-- @tparam number spriteId SpriteID from the specified object for the image entry.
|
|
-- @tparam Color color Color of image entry.
|
|
-- @tparam Vec2 pos X,Y position of the image entry in screen percent (0-100).
|
|
-- @tparam number rot rotation of the image entry (0-360).
|
|
-- @tparam Vec2 scale X,Y Scaling factor for the image entry.
|
|
-- @tparam View.AlignMode alignMode Alignment for the image entry.
|
|
-- @tparam View.ScaleMode scaleMode Scaling for the image entry.
|
|
-- @tparam Effects.BlendID blendMode Blending modes for the image entry.
|
|
function CustomDiary:AddImageEntry(pageIndex, objectId, spriteId, color, pos, rot, scale, alignMode, scaleMode, blendMode)
|
|
|
|
local imageEntry = {}
|
|
|
|
if not Type.IsNumber(objectId) or objectId < 1353 and objectId > 1400 then
|
|
TEN.Util.PrintLog("Invalid objectId slot. Please use a sprite slot. Expected a sprite slot in function 'addImageEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
imageEntry.objectId = objectId
|
|
|
|
if not Type.IsNumber(spriteId) then
|
|
TEN.Util.PrintLog("'spriteId' is in an incorrect format. Expected a number type in function 'addImageEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
imageEntry.spriteId = spriteId
|
|
|
|
if not Type.IsColor(color) then
|
|
TEN.Util.PrintLog("'color' is in an incorrect format. Expected a Color type in function 'addImageEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
imageEntry.color = color
|
|
|
|
if not Type.IsVec2(pos) then
|
|
TEN.Util.PrintLog("'pos' is in an incorrect format. Expected a Vec2 type in function 'addImageEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
imageEntry.pos = pos
|
|
|
|
if not Type.IsNumber(rot) then
|
|
TEN.Util.PrintLog("'rot' is in an incorrect format. Expected a number type in function 'addImageEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
imageEntry.rot = rot
|
|
|
|
if not Type.IsVec2(scale) then
|
|
TEN.Util.PrintLog("'scale' is in an incorrect format. Expected a Vec2 type in function 'addImageEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
imageEntry.scale = scale
|
|
|
|
if not Type.IsNumber(alignMode) or alignMode < 0 or alignMode > 8 then
|
|
TEN.Util.PrintLog("'alignMode' is not a valid View.AlignMode type in function 'addImageEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
imageEntry.alignMode = alignMode
|
|
|
|
if not Type.IsNumber(scaleMode) and scaleMode < 0 or scaleMode > 2 then
|
|
TEN.Util.PrintLog("'scaleMode' is not a valid View.ScaleMode type in function 'addImageEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
imageEntry.scaleMode = scaleMode
|
|
|
|
if not Type.IsNumber(blendMode) or blendMode < 0 or blendMode > 11 then
|
|
TEN.Util.PrintLog("'blendMode' is not a valid Effects.BlendID type in function 'addImageEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
imageEntry.blendMode = blendMode
|
|
|
|
if Type.IsNumber(pageIndex) and pageIndex > 0 then
|
|
if not GameVars.Engine.Diaries[self.Name].Pages[pageIndex] then
|
|
GameVars.Engine.Diaries[self.Name].Pages[pageIndex] = {NarrationTrack=nil, TextEntries = {}, ImageEntries = {}}
|
|
end
|
|
table.insert(GameVars.Engine.Diaries[self.Name].Pages[pageIndex].ImageEntries, imageEntry)
|
|
print("Image entry added to page: ".. tostring(pageIndex).." for the diary system: "..tostring(self.Name))
|
|
else
|
|
TEN.Util.PrintLog("'pageIndex' is in an incorrect format. Expected a number type in function 'addImageEntry' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
end
|
|
end
|
|
|
|
--- Add a narration track in the voice channel to the page. Track is played with the draw button.
|
|
-- @tparam int pageIndex page number to add the narration track to.
|
|
-- @tparam string trackName of track (without file extension) to play.
|
|
function CustomDiary:AddNarration(pageIndex, trackName)
|
|
|
|
if Type.IsNumber(pageIndex) and pageIndex > 0 then
|
|
if not GameVars.Engine.Diaries[self.Name].Pages[pageIndex] then
|
|
GameVars.Engine.Diaries[self.Name].Pages[pageIndex] = {NarrationTrack=nil, TextEntries = {}, ImageEntries = {}}
|
|
end
|
|
|
|
if Type.IsString(trackName) then
|
|
GameVars.Engine.Diaries[self.Name].Pages[pageIndex].NarrationTrack = trackName
|
|
print("Narration added to page: ".. tostring(pageIndex).." for the diary system: "..tostring(self.Name))
|
|
else
|
|
TEN.Util.PrintLog("'trackName' is in an incorrect format. Expected a string type in function 'addNarration' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
else
|
|
TEN.Util.PrintLog("'pageIndex' is in an incorrect format. Expected a number type in function 'addNarration' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
end
|
|
|
|
end
|
|
|
|
--- Remove the narration track from the page of the specified diary.
|
|
-- @tparam int pageIndex page number to remove the narration track from.
|
|
function CustomDiary:RemoveNarration(pageIndex)
|
|
|
|
if not Type.IsNumber(pageIndex) or pageIndex > #GameVars.Engine.Diaries[self.Name].Pages or pageIndex <=0 then
|
|
TEN.Util.PrintLog("'pageIndex' is in an incorrect format or not a valid page number. Expected a number type in function 'removeNarration' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if GameVars.Engine.Diaries[self.Name].Pages[pageIndex] then
|
|
GameVars.Engine.Diaries[self.Name].Pages[pageIndex].NarrationTrack = {}
|
|
end
|
|
print("Narration removed from the page: ".. tostring(pageIndex).." for the diary system: "..tostring(self.Name))
|
|
end
|
|
|
|
--- Add a background image for the diary.
|
|
-- @tparam Objects.ObjID objectId Object ID for the diary's background.
|
|
-- @tparam number spriteId SpriteID from the specified object for the diary's background.
|
|
-- @tparam Color color Color of diary's background.
|
|
-- @tparam Vec2 pos X,Y position of the diary's background in screen percent (0-100).
|
|
-- @tparam float rot rotation of the diary's background sprite (0-360).
|
|
-- @tparam Vec2 scale X,Y Scaling factor for the diary's background.
|
|
-- @tparam View.AlignMode alignMode Alignment for the diary's background.
|
|
-- @tparam View.ScaleMode scaleMode Scaling for the diary's background.
|
|
-- @tparam Effects.BlendID blendMode Blending modes for the diary's background.
|
|
-- @tparam number alpha alpha value for the diary's background (0-255).
|
|
function CustomDiary:AddBackground(objectId, spriteId, color, pos, rot, scale, alignMode, scaleMode, blendMode, alpha)
|
|
if GameVars.Engine.Diaries[self.Name] then
|
|
|
|
if not Type.IsNumber(objectId) or objectId < 1353 and objectId > 1400 then
|
|
TEN.Util.PrintLog("Invalid objectId slot. Please use a sprite slot. Expected a sprite slot in function 'AddBackground' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Background.ObjectIdBg = objectId
|
|
|
|
if not Type.IsNumber(spriteId) then
|
|
TEN.Util.PrintLog("'spriteId' is in an incorrect format. Expected a number type in function 'AddBackground' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Background.SpriteIdBg = spriteId
|
|
|
|
if not Type.IsColor(color) then
|
|
TEN.Util.PrintLog("'color' is in an incorrect format. Expected a Color type in function 'AddBackground' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Background.ColorBg = color
|
|
|
|
if not Type.IsVec2(pos) then
|
|
TEN.Util.PrintLog("'pos' is in an incorrect format. Expected a Vec2 type in function 'AddBackground' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Background.Pos = pos
|
|
|
|
if not Type.IsNumber(rot) then
|
|
TEN.Util.PrintLog("'rot' is in an incorrect format. Expected a number type in function 'AddBackground' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Background.Rot = rot
|
|
|
|
if not Type.IsVec2(scale) then
|
|
TEN.Util.PrintLog("'scale' is in an incorrect format. Expected a Vec2 type in function 'AddBackground' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Background.Scale = scale
|
|
|
|
if not Type.IsNumber(alignMode) or alignMode < 0 or alignMode > 8 then
|
|
TEN.Util.PrintLog("'alignMode' is not a valid View.AlignMode type in function 'AddBackground' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Background.AlignMode = alignMode
|
|
|
|
if not Type.IsNumber(scaleMode) and scaleMode < 0 or scaleMode > 2 then
|
|
TEN.Util.PrintLog("'scaleMode' is not a valid View.ScaleMode type in function 'AddBackground' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Background.ScaleMode = scaleMode
|
|
|
|
if not Type.IsNumber(blendMode) or blendMode < 0 or blendMode > 11 then
|
|
TEN.Util.PrintLog("'blendMode' is not a valid Effects.BlendID type in function 'addBackground' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Background.BlendMode = blendMode
|
|
|
|
if not Type.IsNumber(alpha) or alpha < 0 or alpha > 255 then
|
|
TEN.Util.PrintLog("'alpha is in an incorrect format. Expected a number (0-255) type in function 'addBackground' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Background.Alpha = alpha
|
|
|
|
print("Background added for the diary system: "..tostring(self.Name))
|
|
end
|
|
end
|
|
|
|
--- Clears settings for the background for the specified diary.
|
|
function CustomDiary:ClearBackground()
|
|
if GameVars.Engine.Diaries[self.Name] then
|
|
GameVars.Engine.Diaries[self.Name].Background = {}
|
|
|
|
print("Background cleared for the diary system: "..tostring(self.Name))
|
|
end
|
|
end
|
|
|
|
--- Customizes the notification icon and sound for the diary.
|
|
-- @tparam number notificationTime Time in seconds the notification icon will show on screen.
|
|
-- @tparam Objects.ObjID objectId Object ID for the notification icon.
|
|
-- @tparam number spriteId SpriteID from the specified object for the notification icon.
|
|
-- @tparam Color color Color of notification icon.
|
|
-- @tparam Vec2 pos X,Y position of the notification icon in screen percent (0-100).
|
|
-- @tparam number rot rotation of the notification icon (0-360).
|
|
-- @tparam Vec2 scale X,Y Scaling factor for the notification icon.
|
|
-- @tparam View.AlignMode alignMode Alignment for the notification icon.
|
|
-- @tparam View.ScaleMode scaleMode Scaling for the notification icon.
|
|
-- @tparam Effects.BlendID blendMode Blending modes for the notification icon.
|
|
-- @tparam Sound notificationSound Sound to play with notification icon.
|
|
function CustomDiary:CustomizeNotification(notificationTime, objectId, spriteId, color, pos, rot, scale, alignMode, scaleMode, blendMode, notificationSound)
|
|
if GameVars.Engine.Diaries[self.Name] then
|
|
|
|
if Type.IsNumber(notificationTime) and notificationTime > 0 then
|
|
GameVars.Engine.Diaries[self.Name].Notification.NotificationTime = notificationTime
|
|
else
|
|
TEN.Util.PrintLog("'notificationTime' is in an incorrect format. Expected a number type in function 'customizeNotification' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsNumber(objectId) or objectId < 1353 and objectId > 1400 then
|
|
TEN.Util.PrintLog("Invalid objectId slot. Please use a sprite slot. Expected a sprite slot in function 'customizeNotification' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Notification.ObjectID = objectId
|
|
|
|
if not Type.IsNumber(spriteId) then
|
|
TEN.Util.PrintLog("'spriteId' is in an incorrect format. Expected a number type in function 'customizeNotification' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Notification.SpriteID = spriteId
|
|
|
|
if not Type.IsColor(color) then
|
|
TEN.Util.PrintLog("'color' is in an incorrect format. Expected a Color type in function 'customizeNotification' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Notification.Color = color
|
|
|
|
if not Type.IsVec2(pos) then
|
|
TEN.Util.PrintLog("'pos' is in an incorrect format. Expected a Vec2 type in function 'customizeNotification' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Notification.Pos = pos
|
|
|
|
if not Type.IsNumber(rot) then
|
|
TEN.Util.PrintLog("'rot' is in an incorrect format. Expected a number type in function 'customizeNotification' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Notification.Rot = rot
|
|
|
|
if not Type.IsVec2(scale) then
|
|
TEN.Util.PrintLog("'scale' is in an incorrect format. Expected a Vec2 type in function 'customizeNotification' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Notification.Scale = scale
|
|
|
|
if not Type.IsNumber(alignMode) or alignMode < 0 or alignMode > 8 then
|
|
TEN.Util.PrintLog("'alignMode' is not a valid View.AlignMode type in function 'customizeNotification' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Notification.AlignMode = alignMode
|
|
|
|
if not Type.IsNumber(scaleMode) and scaleMode < 0 or scaleMode > 2 then
|
|
TEN.Util.PrintLog("'scaleMode' is not a valid View.ScaleMode type in function 'customizeNotification' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Notification.ScaleMode = scaleMode
|
|
|
|
if not Type.IsNumber(blendMode) or blendMode < 0 or blendMode > 11 then
|
|
TEN.Util.PrintLog("'blendMode' is not a valid Effects.BlendID type in function 'customizeNotification' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Notification.BlendMode = blendMode
|
|
|
|
if not Type.IsNumber(notificationSound) and notificationSound < 0 then
|
|
TEN.Util.PrintLog("'notificationSound' is in an incorrect format. Expected a number type in function 'customizeNotification' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Notification.NotificationSound = notificationSound
|
|
|
|
GameVars.Engine.Diaries[self.Name].Notification.ElapsedTime = 0
|
|
|
|
print("Notification updated for the diary system: "..tostring(self.Name))
|
|
end
|
|
end
|
|
|
|
--- Clears settings for the notification system for the specified diary.
|
|
function CustomDiary:ClearNotification()
|
|
if GameVars.Engine.Diaries[self.Name] then
|
|
GameVars.Engine.Diaries[self.Name].Notification = {}
|
|
|
|
print("Notifications cleared for the diary system: "..tostring(self.Name))
|
|
end
|
|
end
|
|
|
|
--- Customizes the page numbers for the diary.
|
|
-- @tparam int pageNoType Specifies the format for page numbers (1 or 2). 1: Displays only the current page number. 2: Formats the page number as: [Prefix][CurrentPage][Separator][UnlockedPages].
|
|
-- @tparam string prefix Prefix to be added for type 2 of page numbers.
|
|
-- @tparam string separator Separator to be added for type 2 of page numbers.
|
|
-- @tparam Vec2 textPos X,Y position of the page numbers.
|
|
-- @tparam Strings.DisplayStringOption textOptions alignment and effects for the text. Default: None. Please note text is automatically aligned to the LEFT
|
|
-- @tparam number textScale Scale factor for the page numbers.
|
|
-- @tparam Color textColor Color of the page numbers.
|
|
function CustomDiary:CustomizePageNumbers(pageNoType, prefix, separator, textPos, textOptions, textScale, textColor)
|
|
|
|
if Type.IsNumber(pageNoType) then
|
|
if GameVars.Engine.Diaries[self.Name] and pageNoType >0 and pageNoType <=2 then
|
|
|
|
GameVars.Engine.Diaries[self.Name].PageNumbers.pageNoType = pageNoType
|
|
|
|
if Type.IsString(prefix) then
|
|
GameVars.Engine.Diaries[self.Name].PageNumbers.prefix = prefix
|
|
else
|
|
TEN.Util.PrintLog("'prefix' is in an incorrect format. Expected a string type in function 'customizePageNumbers' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if Type.IsString(separator) then
|
|
GameVars.Engine.Diaries[self.Name].PageNumbers.separator = separator
|
|
else
|
|
TEN.Util.PrintLog("'separator' is in an incorrect format. Expected a string type in function 'customizePageNumbers' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if Type.IsVec2(textPos) then
|
|
GameVars.Engine.Diaries[self.Name].PageNumbers.textPos = textPos
|
|
else
|
|
TEN.Util.PrintLog("'textPos' is in an incorrect format. Expected a Vec2 type in function 'customizePageNumbers' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsTable(textOptions) then
|
|
TEN.Util.PrintLog("'textOptions' is in an incorrect format. Expected a table type in function 'customizePageNumbers' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
else
|
|
for _, data in pairs(textOptions) do
|
|
if type(data) ~= "number" or data < 0 or data > 3 then
|
|
TEN.Util.PrintLog("Data in 'textOptions' table is not a valid Strings.DisplayStringOption type in function 'customizePageNumbers' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].PageNumbers.textOptions = textOptions
|
|
end
|
|
|
|
if Type.IsNumber(textScale) then
|
|
GameVars.Engine.Diaries[self.Name].PageNumbers.textScale = textScale
|
|
else
|
|
TEN.Util.PrintLog("'textScale' is in an incorrect format. Expected a number type in function 'customizePageNumbers' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if Type.IsColor(textColor) then
|
|
GameVars.Engine.Diaries[self.Name].PageNumbers.textColor = textColor
|
|
else
|
|
TEN.Util.PrintLog("'textColor' is in an incorrect format. Expected a Color type in function 'customizePageNumbers' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
end
|
|
else
|
|
TEN.Util.PrintLog("'pageNoType' is in an incorrect format. Expected a number type (1 or 2) in function 'customizePageNumbers' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
print("Page Numbers updated for the diary system: "..tostring(self.Name))
|
|
end
|
|
|
|
|
|
--- Clears settings for the page numbers for the specified diary.
|
|
function CustomDiary:ClearPageNumbers()
|
|
if GameVars.Engine.Diaries[self.Name] then
|
|
GameVars.Engine.Diaries[self.Name].PageNumbers = nil
|
|
print("Page Numbers cleared for the diary system: "..tostring(self.Name))
|
|
end
|
|
end
|
|
|
|
--- Customizes the controls text for the diary.
|
|
-- @tparam Vec2 textPos X,Y position of the controls text.
|
|
-- @tparam Strings.DisplayStringOption textOptions alignment and effects for the text. Default: None. Please note text is automatically aligned to the LEFT.
|
|
-- @tparam number textScale Scale factor for the controls.
|
|
-- @tparam Color textColor Color of the page controls.
|
|
function CustomDiary:CustomizeControls(textPos, textOptions, textScale, textColor)
|
|
if GameVars.Engine.Diaries[self.Name] then
|
|
if Type.IsVec2(textPos) then
|
|
GameVars.Engine.Diaries[self.Name].Controls.textPos = textPos
|
|
else
|
|
TEN.Util.PrintLog("'textPos' is in an incorrect format. Expected a Vec2 type in function 'customizeControls' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if not Type.IsTable(textOptions) then
|
|
TEN.Util.PrintLog("'textOptions' is in an incorrect format. Expected a table type in function 'customizeControls' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
else
|
|
for _, data in pairs(textOptions) do
|
|
if type(data) ~= "number" or data < 0 or data > 3 then
|
|
TEN.Util.PrintLog("Data in 'textOptions' table is not a valid Strings.DisplayStringOption type in function 'customizeControls' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Controls.textOptions = textOptions
|
|
end
|
|
|
|
if Type.IsNumber(textScale) then
|
|
GameVars.Engine.Diaries[self.Name].Controls.textScale = textScale
|
|
else
|
|
TEN.Util.PrintLog("'textScale' is in an incorrect format. Expected a number type in function 'customizeControls' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
|
|
if Type.IsColor(textColor) then
|
|
GameVars.Engine.Diaries[self.Name].Controls.textColor = textColor
|
|
else
|
|
TEN.Util.PrintLog("'textColor' is in an incorrect format. Expected a Color type in function 'customizeControls' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Controls.text1 = "Space: Play Voice Note"
|
|
GameVars.Engine.Diaries[self.Name].Controls.text2 = "Left Key: Previous Page"
|
|
GameVars.Engine.Diaries[self.Name].Controls.text3 = "Right Key: Next Page"
|
|
GameVars.Engine.Diaries[self.Name].Controls.text4 = "Esc: Back"
|
|
GameVars.Engine.Diaries[self.Name].Controls.separator = "|"
|
|
print("Controls updated for the diary system: "..tostring(self.Name))
|
|
end
|
|
end
|
|
|
|
--- Customizes the display text for controls for specified diary.
|
|
-- @tparam string string1 Text for Space key controls text.
|
|
-- @tparam string string2 Text for Left key controls text.
|
|
-- @tparam string string3 Text for Right key controls text.
|
|
-- @tparam string string4 Text for Esc key controls text.
|
|
-- @tparam string separator Text for separator between controls text.
|
|
function CustomDiary:CustomizeControlsText(string1, string2, string3, string4, separator)
|
|
if GameVars.Engine.Diaries[self.Name] then
|
|
|
|
if not Type.IsString(string1) then
|
|
TEN.Util.PrintLog("'string1' is in an incorrect format. Expected a string type in function 'customizeControlsText' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Controls.text1 = string1
|
|
|
|
if not Type.IsString(string2) then
|
|
TEN.Util.PrintLog("'string2' is in an incorrect format. Expected a string type in function 'customizeControlsText' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Controls.text2 = string2
|
|
|
|
if not Type.IsString(string3) then
|
|
TEN.Util.PrintLog("'string3' is in an incorrect format. Expected a string type in function 'customizeControlsText' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Controls.text3 = string3
|
|
|
|
if not Type.IsString(string4) then
|
|
TEN.Util.PrintLog("'string4' is in an incorrect format. Expected a string type in function 'customizeControlsText' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Controls.text4 = string4
|
|
|
|
if not Type.IsString(separator) then
|
|
TEN.Util.PrintLog("'separator' is in an incorrect format. Expected a string type in function 'customizeControlsText' for the diary system: "..tostring(self.Name), Util.LogLevel.WARNING)
|
|
return
|
|
end
|
|
GameVars.Engine.Diaries[self.Name].Controls.separator = separator
|
|
print("Controls text updated for the diary system: "..tostring(self.Name))
|
|
end
|
|
end
|
|
|
|
|
|
--- Clears settings for the specified diary's controls text.
|
|
function CustomDiary:ClearControls()
|
|
if GameVars.Engine.Diaries[self.Name] then
|
|
GameVars.Engine.Diaries[self.Name].Controls ={}
|
|
|
|
print("Controls cleared for the diary system: "..tostring(self.Name))
|
|
end
|
|
end
|
|
|
|
-- !Ignore
|
|
LevelFuncs.Engine.Diaries.ShowDiary = function()
|
|
|
|
local objectNumber = GameVars.Engine.LastUsedDiary
|
|
local dataName = objectNumber .. "_diarydata"
|
|
|
|
if GameVars.Engine.Diaries[dataName] then
|
|
|
|
local diary = GameVars.Engine.Diaries[dataName]
|
|
local currentIndex = diary.CurrentPageIndex
|
|
local maxPages = diary.UnlockedPages
|
|
local narrationTrack = diary.Pages[currentIndex].NarrationTrack
|
|
local alphaDelta = diary.AlphaBlendSpeed
|
|
|
|
if diary.CurrentAlpha ~= diary.TargetAlpha then
|
|
|
|
if diary.CurrentAlpha < diary.TargetAlpha then
|
|
diary.CurrentAlpha = math.floor(math.min(diary.CurrentAlpha + alphaDelta, diary.TargetAlpha))
|
|
else
|
|
diary.CurrentAlpha = math.floor(math.max(diary.CurrentAlpha - alphaDelta, diary.TargetAlpha))
|
|
end
|
|
end
|
|
|
|
-- Switch pages when entries have fully faded out
|
|
if diary.EntryFadingOut then
|
|
-- Fade out current entries
|
|
if diary.EntryCurrentAlpha > 0 then
|
|
diary.EntryCurrentAlpha = math.max(0, diary.EntryCurrentAlpha - alphaDelta)
|
|
else
|
|
-- Fade-out completed, switch page and start fade-in
|
|
diary.EntryFadingOut = false
|
|
diary.EntryFadingIn = true
|
|
diary.EntryCurrentAlpha = 0
|
|
currentIndex = diary.NextPageIndex and diary.NextPageIndex or 1-- Update to the new page
|
|
end
|
|
elseif diary.EntryFadingIn then
|
|
-- Fade in new entries
|
|
if diary.EntryCurrentAlpha < diary.EntryTargetAlpha then
|
|
diary.EntryCurrentAlpha = math.min(diary.EntryTargetAlpha, diary.EntryCurrentAlpha + alphaDelta)
|
|
else
|
|
-- Fade-in completed
|
|
diary.EntryFadingIn = false
|
|
end
|
|
end
|
|
|
|
if KeyIsHit(ActionID.DRAW) then
|
|
if narrationTrack then
|
|
PlayAudioTrack(narrationTrack, Sound.SoundTrackType.VOICE)
|
|
end
|
|
elseif KeyIsHit(ActionID.LEFT) and not (diary.EntryFadingOut or diary.EntryFadingIn) then
|
|
-- Initiate fade-out to switch to the previous page
|
|
if currentIndex > 1 then
|
|
diary.EntryFadingOut = true
|
|
diary.NextPageIndex = math.max(1, currentIndex - 1)
|
|
StopAudioTrack(Sound.SoundTrackType.VOICE)
|
|
PlaySound(diary.PageSound)
|
|
end
|
|
elseif KeyIsHit(ActionID.RIGHT) and not (diary.EntryFadingOut or diary.EntryFadingIn) then
|
|
-- Initiate fade-out to switch to the next page
|
|
if currentIndex < maxPages then
|
|
diary.EntryFadingOut = true
|
|
diary.NextPageIndex = math.min(maxPages, currentIndex + 1)
|
|
StopAudioTrack(Sound.SoundTrackType.VOICE)
|
|
PlaySound(diary.PageSound)
|
|
end
|
|
elseif KeyIsHit(ActionID.INVENTORY) then
|
|
PlaySound(diary.ExitSound)
|
|
diary.TargetAlpha = 0
|
|
diary.EntryFadingOut = true
|
|
end
|
|
|
|
--Sets the currentindex so that the diary opens at the same page
|
|
diary.CurrentPageIndex = currentIndex
|
|
local textEntries = GameVars.Engine.Diaries[dataName].Pages[currentIndex].TextEntries
|
|
local imageEntries = GameVars.Engine.Diaries[dataName].Pages[currentIndex].ImageEntries
|
|
|
|
if diary.CurrentAlpha > 0 then
|
|
diary.Visible = true
|
|
elseif diary.CurrentAlpha == 0 and diary.EntryCurrentAlpha == 0 then
|
|
diary.Visible = false
|
|
StopAudioTrack(Sound.SoundTrackType.VOICE)
|
|
PlaySound(diary.ExitSound)
|
|
Flow.SetFreezeMode(Flow.FreezeMode.NONE)
|
|
TEN.Logic.RemoveCallback(TEN.Logic.CallbackPoint.PREFREEZE, LevelFuncs.Engine.Diaries.ShowDiary)
|
|
return
|
|
end
|
|
|
|
if textEntries or imageEntries then
|
|
-- Draw Diary sprite
|
|
local dAlpha = math.min(diary.CurrentAlpha, diary.Alpha)
|
|
local dColor = TEN.Color(diary.ColorBg.r, diary.ColorBg.g, diary.ColorBg.b, dAlpha)
|
|
local dSprite = TEN.DisplaySprite(diary.ObjectIdBg, diary.SpriteIdBg, diary.Pos, diary.Rot, diary.Scale, dColor)
|
|
dSprite:Draw(1, diary.AlignMode, diary.ScaleMode, diary.BlendMode)
|
|
|
|
-- Draw Background Image
|
|
if diary.Background and next(diary.Background) then
|
|
local bgAlpha = math.min(diary.CurrentAlpha, diary.Background.Alpha)
|
|
local bgColor = TEN.Color(diary.Background.ColorBg.r, diary.Background.ColorBg.g, diary.Background.ColorBg.b, bgAlpha)
|
|
local bgSprite = TEN.DisplaySprite(diary.Background.ObjectIdBg, diary.Background.SpriteIdBg, diary.Background.Pos, diary.Background.Rot, diary.Background.Scale, bgColor)
|
|
bgSprite:Draw(0, diary.Background.AlignMode, diary.Background.ScaleMode, diary.Background.BlendMode)
|
|
end
|
|
|
|
if diary.Controls.textPos then
|
|
|
|
local controlTexts = {}
|
|
|
|
if narrationTrack then
|
|
table.insert(controlTexts, diary.Controls.text1)
|
|
end
|
|
if currentIndex > 1 then
|
|
table.insert(controlTexts, diary.Controls.text2)
|
|
end
|
|
if currentIndex < maxPages then
|
|
table.insert(controlTexts, diary.Controls.text3)
|
|
end
|
|
|
|
-- Add the always-present back control
|
|
table.insert(controlTexts, diary.Controls.text4)
|
|
local alignedText = table.concat(controlTexts, diary.Controls.separator)
|
|
local controlPosInPixel = TEN.Vec2(TEN.Util.PercentToScreen(diary.Controls.textPos.x, diary.Controls.textPos.y))
|
|
local IsString = TEN.Flow.IsStringPresent(alignedText)
|
|
local textColor = TEN.Color(diary.Controls.textColor.r, diary.Controls.textColor.g, diary.Controls.textColor.b, diary.CurrentAlpha)
|
|
|
|
local controlsText = TEN.Strings.DisplayString(alignedText, controlPosInPixel, diary.Controls.textScale, textColor, IsString, diary.Controls.textOptions)
|
|
ShowString(controlsText, 1 / 30)
|
|
|
|
end
|
|
|
|
|
|
|
|
--Draw Page Numbers
|
|
if diary.PageNumbers and next(diary.PageNumbers) then
|
|
|
|
local pageNo = diary.PageNumbers
|
|
local pageNumbers = tostring(currentIndex)
|
|
if pageNo.pageNoType == 2 then
|
|
pageNumbers = pageNo.prefix .. currentIndex .. pageNo.separator .. diary.UnlockedPages
|
|
end
|
|
|
|
local pageNoPosInPixel = TEN.Vec2(TEN.Util.PercentToScreen(pageNo.textPos.x, pageNo.textPos.y))
|
|
local IsString = TEN.Flow.IsStringPresent(pageNumbers)
|
|
local textColor = TEN.Color(pageNo.textColor.r, pageNo.textColor.g, pageNo.textColor.b, diary.CurrentAlpha)
|
|
|
|
local pageNumberText = TEN.Strings.DisplayString(pageNumbers, pageNoPosInPixel, pageNo.textScale, textColor, IsString, pageNo.textOptions)
|
|
ShowString(pageNumberText, 1 / 30)
|
|
|
|
end
|
|
|
|
-- Draw entries based on type
|
|
if textEntries then
|
|
for _, entry in ipairs(textEntries) do
|
|
|
|
local entryPosInPixel = TEN.Vec2(TEN.Util.PercentToScreen(entry.textPos.x, entry.textPos.y))
|
|
local IsString = TEN.Flow.IsStringPresent(entry.text)
|
|
local textColor = TEN.Color(entry.textColor.r, entry.textColor.g, entry.textColor.b, diary.EntryCurrentAlpha)
|
|
|
|
local entryText = TEN.Strings.DisplayString(entry.text, entryPosInPixel, entry.textScale, textColor, IsString, entry.textOptions)
|
|
ShowString(entryText, 1 / 30)
|
|
|
|
end
|
|
end
|
|
|
|
if imageEntries then
|
|
for _, entry in ipairs(imageEntries) do
|
|
|
|
local entryColor = TEN.Color(entry.color.r,entry.color.g,entry.color.b,diary.EntryCurrentAlpha)
|
|
local entrySprite = TEN.DisplaySprite(entry.objectId, entry.spriteId, entry.pos, entry.rot, entry.scale, entryColor)
|
|
|
|
entrySprite:Draw(2, entry.alignMode, entry.scaleMode, entry.blendMode)
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-- !Ignore
|
|
LevelFuncs.Engine.Diaries.ActivateDiary = function(objectNumber)
|
|
|
|
local dataName = objectNumber .. "_diarydata"
|
|
|
|
if GameVars.Engine.Diaries[dataName] then
|
|
GameVars.Engine.LastUsedDiary = objectNumber
|
|
TEN.Inventory.ClearUsedItem()
|
|
GameVars.Engine.Diaries[dataName].TargetAlpha = 255
|
|
GameVars.Engine.Diaries[dataName].EntryTargetAlpha = 255
|
|
TEN.Logic.AddCallback(TEN.Logic.CallbackPoint.PREFREEZE, LevelFuncs.Engine.Diaries.ShowDiary)
|
|
Flow.SetFreezeMode(Flow.FreezeMode.FULL)
|
|
end
|
|
|
|
end
|
|
|
|
-- !Ignore
|
|
LevelFuncs.Engine.Diaries.ShowNotification = function(dt)
|
|
|
|
local dataName = GameVars.Engine.LastUsedDiary .. "_diarydata"
|
|
|
|
if GameVars.Engine.Diaries[dataName] then
|
|
local diary = GameVars.Engine.Diaries[dataName]
|
|
|
|
if diary.CurrentAlpha ~= diary.TargetAlpha then
|
|
|
|
if diary.CurrentAlpha < diary.TargetAlpha then
|
|
diary.CurrentAlpha = math.floor(math.min(diary.CurrentAlpha + diary.AlphaBlendSpeed, diary.TargetAlpha))
|
|
else
|
|
diary.CurrentAlpha = math.floor(math.max(diary.CurrentAlpha - diary.AlphaBlendSpeed, diary.TargetAlpha))
|
|
end
|
|
|
|
end
|
|
|
|
GameVars.Engine.Diaries[dataName].Notification.ElapsedTime = GameVars.Engine.Diaries[dataName].Notification.ElapsedTime + dt
|
|
|
|
if GameVars.Engine.Diaries[dataName].Notification.ElapsedTime <= GameVars.Engine.Diaries[dataName].Notification.NotificationTime then
|
|
diary.TargetAlpha = 255
|
|
else
|
|
diary.TargetAlpha = 0
|
|
end
|
|
|
|
if diary.CurrentAlpha > 0 then
|
|
LevelFuncs.Engine.Diaries.PrepareNotification()
|
|
elseif diary.CurrentAlpha == 0 then
|
|
diary.Notification.ElapsedTime = 0
|
|
TEN.Logic.RemoveCallback(TEN.Logic.CallbackPoint.PRELOOP, LevelFuncs.Engine.Diaries.ShowNotification)
|
|
--print("Notification Callback removed")
|
|
return
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
-- !Ignore
|
|
LevelFuncs.Engine.Diaries.PrepareNotification = function()
|
|
|
|
local dataName = GameVars.Engine.LastUsedDiary .. "_diarydata"
|
|
|
|
if GameVars.Engine.Diaries[dataName] then
|
|
|
|
local diary = GameVars.Engine.Diaries[dataName]
|
|
local notif = diary.Notification
|
|
local spriteColor = Color(notif.Color.r, notif.Color.g, notif.Color.b, diary.CurrentAlpha)
|
|
|
|
local sprite = TEN.DisplaySprite(notif.ObjectID, notif.SpriteID, notif.Pos, notif.Rot, notif.Scale, spriteColor)
|
|
sprite:Draw(0, notif.AlignMode, notif.ScaleMode, notif.BlendMode)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return CustomDiary |