forked from UNDERdecoded/Gen2Recomped-DramaticShapes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
1913 lines (1832 loc) · 88.6 KB
/
Copy pathmain.lua
File metadata and controls
1913 lines (1832 loc) · 88.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- Dramatic Shape Voxel Mod: a full 3D diorama overworld, shipped as a
-- rendering pipeline mod.
--
-- The engine's render_pipelines registry (src/mods/Schemas.lua) lets a mod
-- own part of the frame. This mod registers two:
--
-- voxel a drawWorld pipeline. Instead of the flat tile blit, the
-- overworld's terrain is extruded into real geometry, walked
-- by a depth-buffered 3D camera, with characters as leaning
-- sprite slabs and a shadow map throwing real cast shadows
-- across whatever they land on. Occlusion is the depth
-- buffer, not a y-sort: walk behind a building and the
-- building is simply in front.
--
-- tiltshift a worldPresent pipeline -- the stage that post-processes
-- the finished world BEFORE the UI composites over it. A
-- tilt-shift blur that sells the miniature-model look, on the
-- diorama only, leaving text boxes and menus crisp.
--
-- Everything a display mode needs beyond the two draw functions -- the
-- OFF/15/35/50 ladder, the options rows, the hotkeys, persistence in
-- save.options.pipelines, the free-roam gate, the mutual exclusion with
-- the engine's TILT mode -- is engine plumbing driven by the records
-- below. This file declares; lib/ draws.
--
-- Voxel mode is presentational: it changes what the world LOOKS like and
-- nothing about what it IS. TWO rungs are the deliberate exception. 1ST
-- (the camera in the player's own eyes) and 3RD (the same rig, boomed back
-- behind their shoulder) replace the grid WALK with a free,
-- camera-relative one while either is selected (lib/FreeMove.lua), because
-- a camera you can steer with a mouse demands feet that go where it looks.
-- Even there the game is untouched: the walk asks the engine's own
-- collision the same questions a grid step asks, keeps the player's
-- logical cell synced, and fires the engine's own landing pipeline per
-- cell crossed -- warps, encounters, ledges, gates and scripts all run
-- exactly as themselves. Step off the rung and the grid walk is back.
local mod = ...
-- ------- the mod namespace
--
-- lib/ modules require each other through V rather than package.path: a
-- mod directory is not on it, and may live inside a mounted .love archive
-- that plain require cannot reach. Each module is loaded once, with V
-- passed in as its vararg (`local V = ...`).
local V = { mod = mod, path = mod.path }
function V.game()
return mod.game or require("src.core.Game")
end
function V.generation()
local ok, GameVersion = pcall(require, "src.core.GameVersion")
if ok and GameVersion and type(GameVersion.generation) == "function" then
return tonumber(GameVersion.generation()) or 1
end
return 1
end
-- Crash capture for the render pipelines: the engine's guardRender swallows
-- any throw in drawWorld and silently falls back to the flat 2D path, which
-- reads on screen as "voxel broke" with no trace. Capture the error, persist
-- it through mod.storage (playthrough-scoped), and surface it once through
-- the LOVE error handler so it lands in lua-error.log.
local crashReported = nil
local worldProbe = { updates = 0, draws = 0, wrote = {} } -- plus voxelStuck below
local voxelStuck = 0
-- Fresh-install Gen2 default for the VOXEL pipeline. Levels follow
-- Voxel.ANGLE_LABELS = { OFF, FULL, 15, 35, 50, 75, 1ST(EXP), 3RD(EXP) },
-- so 1 = FULL (the diorama preset). 1ST/3RD are OFF by default: a free-cam
-- rung is a deliberate player choice, not something a fresh save should
-- boot into. (Literal 1: VoxelState loads below, so Voxel.FULL_LEVEL is not
-- in scope yet here.)
local GEN2_DEFAULT_VOXEL = 1
-- Gold/Silver loads display settings from options.lua's nested `gold` block.
-- Older Battle Art builds wrote the ladder at the file root, which Gen2
-- intentionally ignores. Seed only a MISSING Gen2 value; an explicit 0 is a
-- player's OFF choice and must remain off.
local function gen2PipelineOptions(game)
local opts = game and (game.options
or (game.save and game.save.options)) or nil
if type(opts) ~= "table" then return nil end
if type(opts.pipelines) ~= "table" then opts.pipelines = {} end
if V.generation() == 2 and opts.pipelines.voxel == nil then
opts.pipelines.voxel = GEN2_DEFAULT_VOXEL
if game and type(game.persistOptions) == "function" then
pcall(game.persistOptions, game)
elseif game and type(game.writeOptions) == "function" then
pcall(game.writeOptions, game)
end
end
return opts
end
local function writeWorldProbe(key, text)
if worldProbe.wrote[key] then return end
worldProbe.wrote[key] = true
local okCache, cache = pcall(function() return mod.cache end)
if okCache and cache and type(cache.write) == "function" then
pcall(cache.write, cache, "world_probe_" .. key .. ".txt", text)
end
end
local function captureRenderCrash(body)
local ok, result = xpcall(body, function(err)
err = tostring(err)
if err:find("crashcapture", 1, true) then return err end
local trace = debug and debug.traceback and debug.traceback("", 2) or ""
local okDate, at = pcall(os.date, "!%Y-%m-%d %H:%M:%S UTC")
crashReported = { message = err, traceback = trace,
at = okDate and at or "unknown" }
local okCache, cache = pcall(function() return mod.cache end)
if okCache and cache and type(cache.write) == "function" then
pcall(cache.write, cache, "render_crash.txt",
crashReported.at .. "\n" .. err .. "\n" .. trace)
end
local okStorage, storage = pcall(function() return mod.storage end)
if okStorage and storage then
for _, game in ipairs({ V.game(), nil }) do
local okW = pcall(storage.write, storage, game,
"render_crash", { crashReported })
if okW then break end
end
end
return "crashcapture: " .. err .. "\n" .. trace
end)
if not ok then
-- one loud surfacing: the LOVE error handler writes lua-error.log
error(result, 0)
end
return result
end
local function chunkFor(rel)
local source = mod:read(rel)
if not source then
error(("BATTLE_ART_VOXEL_GEN2: %s is missing -- reinstall the mod"):format(rel), 0)
end
local chunk, err = load(source, "@" .. mod.path .. "/" .. rel)
if not chunk then
error(("BATTLE_ART_VOXEL_GEN2: %s did not compile: %s"):format(rel, tostring(err)), 0)
end
return chunk
end
local modules = {}
function V.require(name)
local hit = modules[name]
if hit ~= nil then return hit end
local value = chunkFor("lib/" .. name .. ".lua")(V)
modules[name] = value
return value
end
local dataFiles = {}
function V.data(name)
local hit = dataFiles[name]
if hit ~= nil then return hit end
local value = chunkFor("data/" .. name .. ".lua")(V)
dataFiles[name] = value
return value
end
-- ------- pipelines
local Voxel = V.require("VoxelState")
local Voxel3D = V.require("Voxel3D")
local VoxelScene = V.require("VoxelScene")
local RenderDistance = V.require("RenderDistance")
local TiltShift = V.require("TiltShift")
local ChunkMesher = V.require("ChunkMesher")
local VoxelPrecache = V.require("VoxelPrecache")
local VoxelPrecacheScreen = V.require("VoxelPrecacheScreen")
local VoxelCacheRamScreen = V.require("VoxelCacheRamScreen")
local VoxelMeshDisk = V.require("VoxelMeshDisk")
local Shadows = V.require("Shadows")
local StaticGeometry = V.require("StaticGeometry")
local ModSetting = V.require("ModSetting")
local RamPrecacheSetting = ModSetting.new(
"ramPrecacheMb", "RAM PRECACHE MB",
{ 3072, false, 0 },
{ "3072", "OFF", "FULL" },
1)
local PipelineCanvas = V.require("PipelineCanvas")
local WorldCanvasOrientation = V.require("WorldCanvasOrientation")
local VoxelGrid = V.require("VoxelGrid")
local WorldCurve = V.require("WorldCurve")
local OverworldBattle = V.require("OverworldBattle")
local StadiumBackground = V.require("StadiumBackground")
local BattleExit = V.require("BattleExit")
local BattleArt = V.require("BattleArt")
local AnimatedBattleArt = V.require("AnimatedBattleArt")
local InterfaceSprites = V.require("InterfaceSprites")
local WorldUnderlay = V.require("WorldUnderlay")
local UiBackplates = V.require("UiBackplates")
local BattleStage = V.require("BattleStage")
local BattlePresentation = V.require("BattlePresentation")
local DayNight = V.require("DayNight")
local DayTint = V.require("DayTint")
local Water = V.require("Water")
local AntiAlias = V.require("AntiAlias")
local FirstPerson = V.require("FirstPerson")
local FreeMove = V.require("FreeMove")
local CamControl = V.require("CamControl")
local VR = V.require("VR")
-- HORDE MODE: the konami code's minigame. Horde owns the state machine and
-- every hook; the other four are the gun, the crowd, the readout and the
-- chip-synthesized sounds it fires. See lib/Horde.lua for the whole design.
local Horde = V.require("Horde")
local HordeGun = V.require("HordeGun")
local HordeHud = V.require("HordeHud")
local HordeSfx = V.require("HordeSfx")
-- Freeze the final modded registries before saves begin mutating live maps.
-- Persistent geometry is always fingerprinted from this immutable source.
mod.events:on("mods.loaded", function(payload)
StaticGeometry.capture(payload and payload.data)
end)
-- Forward declaration: the voxel pipeline's update hook (registered below)
-- calls this, and it is defined further down with the settings it drives.
-- Declared rather than left global -- a mod writing to _G would leak into
-- every other mod's namespace.
local applyFull
-- The last VOID FILL the terrain was meshed under; see the update hook.
-- The scene canvas size required by the active host compositor.
--
-- `ctx.width/height` are the window measured in LOVE UNITS
-- (love.graphics.getDimensions), but the engine composites a pipeline's
-- returned canvas with `draw(canvas, 0, 0, 0, 1/dpiX, 1/dpiY)` -- a scale
-- that only covers the window when the canvas is at PIXEL resolution.
-- Sizing it in units costs the DPI scale TWICE: the canvas is that much
-- smaller, then it is drawn that much smaller again, so the diorama lands
-- in the top-left corner at 1/dpi of the screen. Desktop never sees it --
-- units and pixels are the same thing there -- but on Android the DPI scale
-- is the display density (2.625 on a 420dpi panel), and the world came out
-- a third of the size in each direction.
--
-- That contract applies to Gen 1. Gold/Silver/Crystal's Gen 2 World instead
-- draws the returned canvas directly at scale 1, so framebuffer dimensions
-- there create a DPI-factor crop. PipelineCanvas keeps the two contracts
-- explicit instead of guessing from the dimensions themselves.
local function sceneSize(ctx)
return PipelineCanvas.sceneSize(ctx, V.generation())
end
local voidFill = { last = nil }
function voidFill.check()
local TileRenderer = require("src.render.TileRenderer")
local now = TileRenderer.voidFill
if voidFill.last ~= nil and now ~= voidFill.last then
ChunkMesher.invalidate() -- no map id: every ring on every map is stale
end
voidFill.last = now
end
mod.content.render_pipelines:register("voxel", {
label = "VOXEL",
levels = Voxel.ANGLE_LABELS,
-- 3 is the engine's TILT key, which this mode supersedes -- see the
-- hotkey block near the bottom of this file for how it is claimed
hotkey = "3",
-- above tiltshift, so the two sort together in the options list with the
-- mode first and its post-process under it
priority = 20,
-- Headless runs and drivers without a depth canvas or shader support
-- answer false here, and the engine keeps the vanilla 2D path -- which
-- is why no caller ever has to guard for a missing 3D pass.
available = function()
return Voxel3D.available()
end,
-- the engine hands over the live level; we ease the camera toward it.
-- pump() advances queued mesh builds inside a few-millisecond budget,
-- so entering voxel mode (and streaming neighbours while walking)
-- costs frames nothing visible -- the old synchronous build froze the
-- first frame for seconds. prefetch() runs here as well as in the
-- draw, because update ticks even while a warp's Transition covers
-- the screen: the destination's meshes start building the moment the
-- map swaps behind the fade, and the fade-covered frames get a wider
-- pump slice -- so stepping out of a door lands on terrain that is
-- already there instead of a flat flash.
update = function(dt, level)
worldProbe.updates = worldProbe.updates + 1
-- FULL is a preset, so it is applied ON THE PRESS rather than held every
-- frame: it SETS the other rows and then leaves them alone. Holding them
-- would make the zoom keys and the wheel dead while the mode was on, and
-- would fight anyone who changed one deliberately.
applyFull(level)
Voxel.update(dt, level)
-- the first-person head, on the same tick: its blend in and out of the
-- orbit, the mouse capture lifecycle, and the frame's stick-rate look.
-- Unconditional like Voxel.update, because the blend has to keep easing
-- OUT after the rung is left
FirstPerson.update(dt)
-- the day/night clock, on the same always-running tick: Pipelines.update
-- runs whatever the level, so time passes with the mode off, through
-- battles and menus, and a CYCLE evening falls mid-fight exactly as it
-- would mid-walk
DayNight.update(dt)
-- The overworld battle rides this hook rather than owning a pipeline of
-- its own, because it owns no pass of the FRAME: it draws under a battle
-- screen the engine composites, which is not a stage the registry has.
-- What it needs is a tick that keeps running once the overworld stops
-- being the top state, and this is one -- Game:update calls
-- Pipelines.update unconditionally, so it survives the transition wipe
-- and the whole battle. Ahead of the active() gate below, because a 3D
-- battle does not require the free-roam mode to be switched on.
OverworldBattle.update(dt)
-- The horde, on the same always-running tick and for the same reason:
-- it owns no pass of the frame, it is a MODE over the overworld, and
-- it has to keep thinking while a warp's wipe covers the screen (the
-- crowd follows the player through the door) and under the GAME OVER
-- card, which is a pushed state that stops everything below it.
Horde.update(dt)
-- VOID FILL picks the block the border ring is made of, and in this
-- mode that ring is BAKED INTO THE MESH rather than drawn each frame.
-- So the option has to reach the cache or nothing happens on screen
-- until the meshes are dropped for some other reason -- which reads
-- exactly like the option doing nothing at all. Polled rather than
-- hooked because the engine changes it from three places (the options
-- row, applyOptions on load, TileRenderer.setVoidFill) and none of
-- them announces it. Ahead of the active() gate, so switching it
-- while voxel mode is OFF still invalidates what is cached.
voidFill.check()
-- The whole VR frame -- session lifecycle, xrWaitFrame's pacing, both
-- eye renders, the layer submit -- rides this hook, because it is the
-- one tick that runs through menus, dialogs and battles, which is
-- what a headset needs the world (or at least the UI panel) to do.
-- Ahead of the active() gate: with the mode off, the headset still
-- shows the flat screen on the floating panel.
VR.update(dt)
local Game = V.game()
local ow = Game and (Game.overworld or Game.world)
local Pipelines = require("src.render.Pipelines")
local opts = gen2PipelineOptions(Game) or { pipelines = {} }
-- Sample every ~10s and OVERWRITE: the first samples land on the title
-- screen before Game2 builds its world, so a one-shot probe only ever
-- recorded world=false. The latest sample is the interesting one.
-- Belt-and-braces restore: the game.ready listener can miss its window
-- (options may load after our chunk registers), so watch for the stuck
-- state directly -- stored level > 0 while the runtime sits at 0. Two
-- consecutive samples past boot before acting, so a deliberate OFF by
-- the player is respected once they have had a chance to choose it.
if Pipelines.level("voxel") <= 0 and (opts.pipelines.voxel or 0) > 0 then
voxelStuck = voxelStuck + 1
if voxelStuck == 2 then
Pipelines.setLevel("voxel", math.min(opts.pipelines.voxel,
Pipelines.maxLevel("voxel")))
Voxel.setLevel(Pipelines.level("voxel"))
writeWorldProbe("restore",
"restored at update " .. tostring(worldProbe.updates)
.. " -> level " .. tostring(Pipelines.level("voxel")))
end
else
voxelStuck = 0
end
if worldProbe.updates % 600 == 0 then
local top = Game and Game.stack and Game.stack.top
and Game.stack:top() or nil
writeWorldProbe("update", table.concat({
"at_update=" .. tostring(worldProbe.updates),
"top=" .. tostring(top and top.name or top),
"level=" .. tostring(level),
"voxelLevel=" .. tostring(Voxel.level),
"angle=" .. tostring(Voxel.angle),
"ready=" .. tostring(Voxel.ready),
"active=" .. tostring(Voxel.active()),
"world=" .. tostring(ow ~= nil),
"map=" .. tostring(ow and ow.map and ow.map.id),
"camera=" .. tostring(ow and ow.camera ~= nil),
"pending=" .. tostring(ChunkMesher.pending()),
}, "\n"))
end
if not Voxel.active() then return end
if ow and ow.map and ow.camera then
pcall(VoxelScene.prefetch, ow)
-- Complement nearby cache misses in RAM. Persistence remains explicit
-- through CACHE / SAVE so ordinary play never performs surprise I/O.
pcall(VoxelPrecache.update, Game)
end
ChunkMesher.pump(Game and Game.stack
and Game.stack:top() ~= ow)
end,
drawWorld = function(ctx)
worldProbe.draws = worldProbe.draws + 1
-- the palette closure, stashed for the VR frame: it renders from the
-- update hook, where no ctx exists to carry one
VR.paletteFor = ctx.paletteFor
return captureRenderCrash(function()
-- With a headset running, the window's world pass becomes the MIRROR
-- -- the left eye, fitted to the window -- rather than a third full
-- render of the scene. Everything else about the frame (the UI the
-- engine composites over this) is unchanged, which is exactly what
-- the headset's floating panel photographs.
if VR.active() then
local sw, sh = sceneSize(ctx)
local m = VR.mirror(sw, sh)
if m then return m end
end
-- Terrain and characters are geometry; the field FX stay ordinary 2D
-- draws composited on top, anchored through the same camera the 3D
-- pass used (ctx.drawFx below). The scene renders at the window's
-- PIXEL resolution (see sceneSize) so the 3D pass is crisp rather than
-- a magnified low-res image, while the FX closures keep drawing in
-- world-pixel units.
local sw, sh = sceneSize(ctx)
-- With AA on, the whole pass runs into a canvas BIGGER than the window
-- and is folded back down at the end (see AntiAlias). Nothing between
-- these two lines knows: every pass in the frame measures itself in the
-- canvas it was handed, so the sky's dither, the water's march and the
-- camera itself all come out the same picture at a higher sample rate.
local rw, rh = AntiAlias.expand(sw, sh)
local canvas = VoxelScene.render(ctx.state, rw, rh,
ctx.vw, ctx.vh, ctx.paletteFor)
if not canvas then
if worldProbe.draws == 1 or worldProbe.draws % 120 == 0 then
local map = ctx.state and ctx.state.map
writeWorldProbe("decline_" .. tostring(worldProbe.draws),
table.concat({
"draws=" .. tostring(worldProbe.draws),
"map=" .. tostring(map and map.id),
"renderer=" .. tostring(map and map.renderer ~= nil),
"atlas=" .. tostring(map and map.renderer
and map.renderer.image ~= nil),
"tileset=" .. tostring(map and map.tileset ~= nil),
"terrain=" .. tostring(map and ChunkMesher.pair(map, false)
~= nil),
"body=" .. tostring(map and ChunkMesher.pair(map, true)
~= nil),
"pending=" .. tostring(ChunkMesher.pending()),
"voxelLevel=" .. tostring(Voxel.level),
"angle=" .. tostring(Voxel.angle),
"ready=" .. tostring(Voxel.ready),
}, "\n"))
end
-- Battle teardown can reveal the world before its streamed terrain is
-- ready. Keep the clean arena backdrop for that short handoff instead
-- of exposing Silver's flat world between the two composites.
return WorldCanvasOrientation.present(
OverworldBattle.handoff(), "overworld-handoff", V.generation())
end
writeWorldProbe("success", "draws=" .. tostring(worldProbe.draws)
.. "\nmap=" .. tostring(ctx.state and ctx.state.map
and ctx.state.map.id))
if Voxel3D.beginOverlay() then
-- the FX closures are ordinary 2D draws sized in DISPLAY pixels, and
-- they are drawing into the supersampled canvas alongside everything
-- else -- so the scale goes up with it, or the "!" bubble lands the
-- right place at half the size. project() already answers in canvas
-- pixels, so only the scale needs saying.
ctx.drawFx(function(wx, wy) return Voxel3D.project(wx, 0, wy) end,
ctx.scale * AntiAlias.factor())
-- the horde's readout rides the same overlay, over the FX: health,
-- ammunition, the crosshair and the banners, sized in the same
-- supersampled canvas pixels everything else here is drawn in. A
-- headset never reaches this line (drawWorld returns the mirror
-- above) -- lib/VR draws the same HUD onto each eye instead.
HordeHud.drawFlat(rw, rh, ctx.scale * AntiAlias.factor())
Voxel3D.endOverlay()
end
-- and back to the window's own size, which is what the engine composites
-- one canvas pixel to one display pixel. A pass-through when AA is off.
local resolved = AntiAlias.resolve(canvas, sw, sh, "world")
if resolved then OverworldBattle.worldReady() end
return WorldCanvasOrientation.present(
resolved, "overworld", V.generation())
end)
end,
invalidate = function()
Voxel3D.invalidate()
OverworldBattle.invalidate()
AntiAlias.invalidate()
WorldCanvasOrientation.invalidate()
ChunkMesher.invalidate() -- no map id = every cached mesh
VR.invalidate() -- the mirror, and FBO ids of dead canvases
end,
})
mod.content.render_pipelines:register("tiltshift", {
label = "T-SHIFT",
levels = TiltShift.LABELS,
-- 6 is free: no engine branch claims it, so this one alone reaches the
-- registry by the documented route
hotkey = "6",
priority = 10,
update = function(dt, level)
TiltShift.update(dt, level)
end,
-- worldPresent, not present: the blur belongs on the diorama, not on the
-- dialog box in front of it. A pass-through when the level is 0 or the
-- shader is unavailable, so the frame is untouched in every other case.
worldPresent = function(canvas)
return TiltShift.apply(canvas)
end,
invalidate = function()
TiltShift.invalidate()
end,
})
-- ------- this mod's own settings
--
-- Neither of these is a pipeline: they own no pass of the frame, they
-- PARAMETERISE the voxel one, so they have nothing to put in drawWorld or
-- present and the registry would rightly reject them. Plain mod settings
-- instead -- see ModSetting for where they persist and how the two rows
-- each ends up on stay in step.
-- ------- the FULL preset
--
-- Everything the mode wants switched to at once. Applied when the VOXEL row
-- ARRIVES at FULL and not again, so the player can still move the camera or
-- the zoom afterwards -- it is a starting point, not a lock.
--
-- Leaving FULL deliberately does NOT undo any of it. A preset that reverted
-- would throw away whatever the player had changed since, and "put it back
-- how it was" is not a thing this can know.
local fullWas = nil
applyFull = function(level)
local isFull = Voxel.isFull(level)
local was = fullWas
fullWas = isFull
if not isFull or was == true or was == nil then return end
local Game = require("src.core.Game")
local Pipelines = require("src.render.Pipelines")
local Zoom = require("src.render.Zoom")
local opts = Game.save and Game.save.options
if not opts then return end
-- the miniature blur at its strongest: FULL is the diorama look, and the
-- tilt-shift is most of what makes it read as a model. A fresh Gen2 install
-- arrives at FULL through GEN2_DEFAULT_VOXEL (which wants the diorama with
-- T-SHIFT off), so only a player who steps onto FULL by hand gets the blur;
-- the default boot keeps the preset's other rows but not the tilt-shift.
local freshDefault = level == GEN2_DEFAULT_VOXEL
if not freshDefault then
-- Tilt-shift is opt-in: FULL must not force the blur on (and persist it),
-- which previously snapped every manual FULL arrival to max and stuck.
-- Leave it OFF / at its stored value; the player turns T-SHIFT on from
-- the OPTIONS row if they want the diorama blur.
end
Pipelines.syncOptions(opts)
-- the horizon flat. The curve bends the world away from a walking player,
-- which fights a fixed diorama framing
WorldCurve.setting:setIndex(1, Game)
-- and the water reflecting everything it can: FULL is the diorama at its
-- most photographed, and a lake with the sky and the shoreline in it is
-- most of what makes the model read as being outdoors
Water.setting:setIndex(1, Game)
-- and the view fitted to the window
opts.zoom = 0
Zoom.applyOptions(opts)
-- battles on the map too: FULL means the whole mode, and a fight is where
-- half of it is spent. Set and then LET GO of -- unlike the rows above, both
-- battle rows stay on the menu under FULL (see the rows hook), so this is
-- where the preset puts them and not where they are held.
OverworldBattle.setting:setIndex(1, Game)
-- with both mons out there on it: BACK SPRITES keeps the player's own on the
-- menu, which is the one part of the old screen FULL is least about. Set the
-- same way, and changed back on the same row a keypress later.
OverworldBattle.backSetting:setIndex(1, Game)
-- and the battle screen the staged fight is composed for. WIDE re-lays that
-- screen out on a 304x144 surface, which moves every anchor the arena camera
-- is solved against (OverworldBattle.forceOG); FULL has just switched staged
-- fights on, so the layout follows them.
OverworldBattle.forceOG(Game)
-- and the sky on the clock on the wall: FULL sets DAYTIME to SYNC. Set and
-- then LET GO of, like the battle rows above -- the row stays on the menu
-- under FULL, because holding it there left a player who booted after dark
-- with no way to ask for daylight.
DayNight.forceSync(Game)
if Game.writeOptions then pcall(Game.writeOptions, Game) end
end
-- Whether a fight can be staged on the map, as far as the OPTIONS menu is
-- concerned: the 3D-BTL row, and nothing else.
--
-- It used to answer yes under FULL as well, on the grounds that FULL owned
-- that row and switched it on. FULL no longer owns it -- the row stays on the
-- menu under FULL and can be switched off there (see the rows hook) -- so that
-- clause would now claim staged battles for a preset the player had just
-- turned them off inside, pinning BATTLE LAYOUT to OG for a fight that is
-- never staged. The row is the only thing that decides, which is what every
-- other reader of this setting already believed: OverworldBattle.begin and
-- wantsFront both gate on enabled() alone.
--
-- Deliberately NOT gated on Voxel3D.available(): the engine offers a
-- pipeline's row whether or not the hardware can run it (Pipelines.rows), so
-- this mode's rows say ON on a machine without a depth buffer too, and a menu
-- that claims 3D battles are on must not also offer the layout they cannot be
-- drawn in.
local function stagedBattles()
return OverworldBattle.enabled()
end
local function applyRamPrecacheBudget()
local value = RamPrecacheSetting:get()
if value == false then
-- OFF: disable precache entirely, no preload, no RAM limit
VoxelMeshDisk.setRamPrecacheEnabled(false)
return false
end
VoxelMeshDisk.setRamPrecacheEnabled(true)
if value == 0 then
-- FULL: no RAM budget cap, eager whole-world load
VoxelMeshDisk.setRamBudget(0)
else
VoxelMeshDisk.setRamBudget(tonumber(value) * 1024 * 1024)
end
return true
end
-- Gen 2 does not build render-pipeline rows for either of its options
-- screens. Keep one small bridge for those surfaces: the in-game row still
-- edits Pipelines directly, while the mod manager stores this mirror key and
-- the options-changed event below applies it to the same live level.
local VOXEL_OPTION_KEY = "voxelLevel"
local VOXEL_HELP = "Choose the voxel camera: OFF, the FULL diorama preset, "
.. "or an orbit/free-camera rung. This is the touch-accessible equivalent "
.. "of the keyboard's 3 display-mode key."
local function mirrorVoxelOption(game, level)
game = game or V.game()
level = math.max(0, math.min(Voxel.MAX_LEVEL,
math.floor(tonumber(level) or 0)))
local changed = false
local opts = game and game.save and game.save.options
if opts then
opts.modOptions = opts.modOptions or {}
opts.modOptions[mod.id] = opts.modOptions[mod.id] or {}
changed = opts.modOptions[mod.id][VOXEL_OPTION_KEY] ~= level
opts.modOptions[mod.id][VOXEL_OPTION_KEY] = level
end
local loader = game and game.mods
if loader then
loader.modOptions = loader.modOptions or {}
loader.modOptions[mod.id] = loader.modOptions[mod.id] or {}
loader.modOptions[mod.id][VOXEL_OPTION_KEY] = level
end
return changed
end
local function setVoxelOption(game, level)
game = game or V.game()
local Pipelines = require("src.render.Pipelines")
level = Pipelines.setLevel("voxel", level)
Voxel.setLevel(level)
local opts = gen2PipelineOptions(game)
if opts then
Pipelines.syncOptions(opts)
opts.tilt, opts.gbcfx = 0, 0
end
mirrorVoxelOption(game, level)
applyFull(level)
local okTilt, Tilt = pcall(require, "src.render.Tilt")
if okTilt and Tilt and Tilt.setLevel then pcall(Tilt.setLevel, 0) end
local okGbc, GBCFX = pcall(require, "src.render.GBCFX")
if okGbc and GBCFX and GBCFX.setLevel then pcall(GBCFX.setLevel, 0) end
if game and game.writeOptions then pcall(game.writeOptions, game)
elseif game and game.persistOptions then pcall(game.persistOptions, game) end
return level
end
local SETTINGS = {
{ RenderDistance.setting,
"Limit connected-map terrain, water, figures and distant characters. "
.. "SHORT/MEDIUM/FAR cover 16/32/64 movement cells. MEDIUM is the default; "
.. "FULL restores uncapped rendering. The current map always stays visible.",
full = true },
{ RamPrecacheSetting,
"Compressed voxel cache retained for CONTINUE and nearby-area loading. "
.. "Choose FULL to retain every precached record; larger values use more "
.. "system RAM but reduce first-entry disk reads on mobile.",
full = true },
{ VoxelGrid.setting, "One-pixel wireframe along every voxel edge." },
{ VoxelScene.silhouetteSetting,
"Draw silhouettes for characters hidden behind voxel geometry. "
.. "OFF disables the silhouette pass completely." },
{ WorldCurve.setting,
"Bend the world down over the horizon, Animal Crossing style." },
{ Water.setting,
"Reflections on water. FULL adds screen-space reflections of the "
.. "shoreline, the trees and the buildings behind it; SKY is the sky, "
.. "the sun and the moon alone, which is most of the look for a "
.. "fraction of the cost." },
{ Shadows.setting,
"Enable shadows. OFF removes both the real cast-shadow map and its flat "
.. "fallback from free roam and staged battles; UNLIT battle cards also "
.. "decline shadows even while this global switch is ON.",
full = true },
-- `full` marks a row FULL does not take away. FULL owns the diorama's own
-- knobs; what a battle is drawn over, and how it is framed, are not that.
-- Off the OPTIONS menu while VR is on: the headset REQUIRES staged
-- battles (OverworldBattle.enabled answers true regardless of this row)
-- and forbids back sprites (backPinned answers false), so both rows
-- decide nothing there and a dead switch on the menu reads as broken.
{ OverworldBattle.setting,
"Fight on the map: the battle draws over the nearest clear ground, "
.. "shot over the shoulder with a slow parallax drift.",
when = function() return not VR.enabled() end, full = true },
-- Advanced compatibility control, kept off the in-game menu because it
-- pins the player pic to the UI camera and applies the world's night tint,
-- overriding the staged camera and SPRITE LIGHT presentation controls.
{ OverworldBattle.backSetting,
"Keep your own Pokemon on the battle menu, seen from behind in its "
.. "original slot, instead of standing it on the map facing the foe. "
.. "The foe is still out there on its own tile.",
when = function() return stagedBattles() and not VR.enabled() end,
full = true, managerOnly = true },
-- Battle Art rows (ported from the Gen1 fork). Only offered while a fight
-- can actually be staged on the map.
{ BattleArt.setting,
"Use optional PNGs from assets/battle in fights. Missing art falls "
.. "back to the ROM. ANIMATED is the tested fresh-install default.",
when = function() return stagedBattles() end, full = true },
{ BattleArt.trainerSetting,
"Use the ROM opponent trainers, or choose an optional static collection. "
.. "A class missing from that collection falls back to its ROM portrait.",
when = function()
return stagedBattles() and BattleArt.setting:get() ~= "rom"
end, full = true, managerOnly = true },
{ BattleArt.playerArtSetting,
"Choose the player trainer's static battle-intro portrait. A missing "
.. "named choice tries player.png, then ROM. PNG uses player.png "
.. "directly. BATTLE ART: ROM pins this row to ROM.",
when = function()
return stagedBattles() and BattleArt.setting:get() == "static"
end, full = true },
{ BattleArt.playerAnimationSetting,
"Choose the player trainer's battle-intro art under ANIMATED. PNG uses "
.. "player.png as a static portrait; named sets play their authored "
.. "slide poses once. Missing art and ROM retain the engine portrait.",
when = function()
return stagedBattles() and BattleArt.setting:get() == "animated"
end, full = true },
{ BattleArt.frontAnimationSetting,
"Choose the front generation used by BATTLE ART: ANIMATED. GEN 1 reads "
.. "single-frame PNGs; GEN 2-5 read atlases. STATIC ignores this row. "
.. "Missing art falls directly back to ROM.",
when = function()
return stagedBattles() and BattleArt.setting:get() == "animated"
end, full = true },
{ BattleArt.backAnimationSetting,
"Choose the player back-art generation. STATIC reads only a PNG from "
.. "back-static/GEN for every choice. ANIMATED reads static GEN 1, 2, "
.. "and 4 PNGs, or animated GEN 3 and 5 atlases. Missing art falls "
.. "back to the ROM.",
when = function() return stagedBattles() and BattleArt.setting:get() ~= "rom"
end, full = true },
{ BattleArt.duplicateSetting,
"Choose who owns Pokemon pictures when another sprite mod is installed. "
.. "BATTLE ART keeps this mod's selected front and back collections on "
.. "top, including its DV-routed shiny collections. MODDED installs no "
.. "Pokemon art and captures the pictures chosen by another sprite mod "
.. "or the ROM on both sides.",
when = function() return stagedBattles() end, full = true },
{ BattleArt.viewSetting,
"Show the player's Pokemon from the front or back. Supplied art stays "
.. "world-placed; a missing selected back falls back to the ROM UI pic.",
when = function() return stagedBattles() end, full = true },
{ BattleArt.frontFlipSetting,
"Orient the player-side FRONT SPRITES card. BATTLE ART mirrors ordinary "
.. "front art so it faces the opponent. DEFAULT preserves the image's "
.. "authored direction, for sprite mods that already supply a flipped "
.. "player picture such as Crystal Animated Sprites.",
when = function()
return stagedBattles() and BattleArt.playerSide() == "front"
end, full = true },
{ UiBackplates.spriteLight,
"SHADED lets the mons receive the world's day tint and cast shadows; "
.. "UNLIT draws them flat and full bright. UNLIT is what the OG "
.. "battle's sprites look like.",
when = function() return stagedBattles() end, full = true },
{ UiBackplates.hudColor,
"INVERTED uses bright white HUD ink over the arena; COLOR keeps the "
.. "engine's black ink. HP and EXP bars retain their native colors.",
when = function() return stagedBattles() end, full = true },
{ UiBackplates.arenaFill,
"Choose the staged battle background: the voxel world, a flat white "
.. "field, assets/battle/front-static/bosses/arena.png, or Stadium 2's "
.. "live field and models when its importer is ready. STADIUM2 falls "
.. "back to OFF's voxel battlefield when unavailable.",
when = function() return stagedBattles() end, full = true },
{ UiBackplates.stadiumCircle,
"Control Stadium's ground circles independently of ARENA FILL. ON uses "
.. "the full circle, HALF uses a smaller circle, and OFF hides it while "
.. "an invisible plane still receives model shadows.",
when = function() return StadiumBackground.installed() end, full = true },
{ UiBackplates.backdropOffset,
"Crop the selected PNG arena downward in source-image pixels.",
when = function()
return stagedBattles() and UiBackplates.arenaPng()
end, full = true },
{ UiBackplates.bossBg,
"Allow encounter-specific boss artwork to override an illustrated arena.",
full = true, managerOnly = true },
{ UiBackplates.textboxFill,
"Choose opaque white, translucent dark, opaque black, or paperless "
.. "battle text boxes.",
when = function() return stagedBattles() end, full = true },
{ InterfaceSprites.setting,
"INTERFACE SPRITES: show BATTLE ART's regular-form FRONT outside battle. "
.. "Title and status support timed atlas animation; other hook-aware "
.. "screens use single-image sets or retain ROM art, independent of "
.. "DUPLICATE FIX (which owns only battle pictures). "
.. "MODDED leaves the interfaces to another sprite mod or the ROM.",
full = true },
{ InterfaceSprites.scalingSetting,
"FIT keeps Summary and Dex artwork within 56x56. FULL keeps native pixels "
.. "and can overlap the UI. Summary aligns the first pose at the bottom; "
.. "Dex centers it. Animation timing and movement are preserved.",
full = true },
{ WorldUnderlay.setting,
"Choose the solid outdoor world beneath terrain holes and beyond map edges: "
.. "CYAN or BLACK. OFF/KFP leaves the underlay to Kanto First Person. "
.. "NATURE uses a black underlay and continues each biome beyond loaded "
.. "ROM cells with stable random-sized tree or rock billboards. "
.. "Indoor horizons automatically match "
.. "the room's own border/void material so the finite map ring cannot reveal "
.. "a differently coloured infinite fill behind it.",
full = true, managerOnly = true },
-- Marked `full` on the battle rows' reasoning, and then some. FULL SETS this
-- to SYNC on arrival (applyFull) because the diorama's sky should follow the
-- clock on the wall; it used to HOLD it there and take the row away, which
-- meant a player who started the game after dark had the whole world
-- multiplied by DayNight.TINTS.night with no row anywhere to say otherwise.
-- A preset that hides the one row deciding whether you can see is a lock,
-- not a preset.
{ DayNight.setting,
"What time it is outdoors: pin the sky to DAY, NIGHT, DUSK or DAWN, "
.. "let CYCLE run it -- ten minutes of sun, ten of moon, with the "
.. "shadows, the sky and the light following -- or SYNC it to the "
.. "clock on the wall, so Kanto's evening falls when yours does.",
full = true },
-- Marked `full` for the opposite reason the battle rows are: this is not a
-- knob on the look at all, it is what the look COSTS. FULL is a preset for
-- the diorama, not a licence to spend four times the fill rate on the
-- machine it happens to be running on, so it neither sets this nor takes
-- the row away -- the player decides what their hardware can carry, from
-- inside FULL like anywhere else.
{ AntiAlias.setting,
"Smooth the stair-stepped edges of the 3D world -- roof ridges, ledge "
.. "lips, a tree against the sky -- by rendering the diorama larger than "
.. "the window and folding it back down. Every edge in the picture "
.. "softens with them, the tileset's own texels included, so the diorama "
.. "reads smoother rather than sharper. 2X costs half again as many "
.. "pixels in each direction and 4X twice, which makes this the most "
.. "expensive row in the mod.",
full = true },
-- `full` for the same reason as AA: not a knob on the look, a question
-- about the hardware on the desk.
{ VR.setting,
"PCVR through OpenXR (SteamVR, Oculus, WMR). The diorama becomes a "
.. "tabletop model your head moves around; the 1ST rung stands you "
.. "inside the world at life size, looking where the headset looks. "
.. "Menus and dialogs float on a panel. Needs a Windows OpenXR runtime "
.. "and the mod running from a real folder; without them the row stays "
.. "and the game stays flat, with the reason on the console.",
-- on Windows the row stays even when a runtime is missing (the console
-- says why); off Windows -- mobile above all -- there is no VR to have
-- and the row does not exist
when = function() return VR.supported() end, full = true },
-- Under the VR row and only while it is ON: a comfort setting for a
-- device that is not plugged in decides nothing, and this one is read
-- exclusively by the headset's right stick.
{ VR.smoothTurn,
"Turn smoothly with the right stick instead of snapping 45 degrees a "
.. "flick. OFF by default, and deliberately: a software turn moves the "
.. "world past a head that did not move, which is the most reliable way "
.. "to make somebody ill in a headset. Turn it on if you have your sea "
.. "legs and want the continuity.",
when = function() return VR.enabled() end, full = true },
}
local voxelChoices = {}
for level, label in ipairs(Voxel.ANGLE_LABELS) do
voxelChoices[#voxelChoices + 1] = { label, level - 1 }
end
local schema = {
{ key = VOXEL_OPTION_KEY, type = "choice", label = "VOXEL",
choices = voxelChoices, default = GEN2_DEFAULT_VOXEL, help = VOXEL_HELP },
}
for _, entry in ipairs(SETTINGS) do
-- the VR rows are absent from the mod manager's page too where the
-- platform cannot do VR at all -- the OPTIONS menu's `when` gates are
-- situational (a row hidden for now), this one is existential
local vrOnly = entry[1] == VR.setting or entry[1] == VR.smoothTurn
if not vrOnly or VR.supported() then
schema[#schema + 1] = entry[1]:schema(entry[2])
end
end
mod.options:define(schema)
-- ------- this mod's hotkeys
--
-- 3 VOXEL cycle the camera ladder (was 6; skips FULL)
-- 5 V-GRID toggle the wireframe (new)
-- 6 T-SHIFT cycle the blur ladder (was 9)
-- 7 V-CURVE cycle the horizon bend (new)
-- 8 3D-BTL toggle overworld battles (new)
-- 9 WATER cycle the water reflections (new; 9 was T-SHIFT's old key)
--
-- Only 6 arrives by the documented route. Game:keypressed answers the
-- engine's own display keys FIRST and returns -- 2 COLORS, 3 TILT, 4 ZOOM,
-- 5 GBC FX -- and only then offers the key to Pipelines.hotkey, expressly
-- so "a pipeline can never shadow one" (Schemas, render_pipelines.hotkey).
-- 3 and 5 are two of those, and 7 and 8 belong to plain mod settings that
-- own no pass and so have no registry to claim a key from at all.
--
-- So this wraps Game:keypressed. It is the invasive option and it is the
-- only one: polling the keyboard in update() would fire alongside the
-- engine's handler rather than instead of it, so 3 would cycle this mode
-- AND the engine's TILT on the same press.
--
-- Consequences worth being explicit about: while this mod is enabled, TILT
-- (3) and GBC FX (5) are unreachable by key -- and unreachable on the OPTIONS
-- menu too, where both rows are taken away and both values held at zero (see
-- pinEngineFx). Nothing is being hidden that still does something: TILT is the
-- flat fake of what this mode does for real, the registry already forces it
-- off whenever a world pipeline takes the pass, and GBC FX is a full-screen
-- present pass over the top of the diorama. Uninstalling puts both back.
--
-- Everything the engine does around a pipeline hotkey has to happen here
-- too, so the work is DELEGATED rather than reimplemented: Pipelines.hotkey
-- applies its own gate and ladder, and the three lines after it are the
-- engine's own (syncOptions, the tilt exclusion, writeOptions).
local HOTKEYS = {
["3"] = "pipeline", -- voxel, by its declared hotkey
["6"] = "pipeline", -- tiltshift, likewise
["5"] = VoxelGrid.setting,
["7"] = WorldCurve.setting,
["8"] = OverworldBattle.setting,
["9"] = Water.setting,
}
-- One step of the VOXEL angle ladder: everything a "3" press does, named
-- so the pad's SELECT button (below) can make exactly the same step. The
-- gate is the registry's own; the tilt/GBC FX clearing is the engine work
-- the key has always delegated (see the wrap below for why).
local function cycleVoxel(game)
local Pipelines = require("src.render.Pipelines")
-- HORDE MODE holds the rung at 1ST for as long as it runs. Refused HERE
-- rather than at each caller because this one function IS every way a
-- player can step the ladder: the "3" key, the pad's SELECT, and the VR
-- left-stick click all come through it.
if Horde.viewLocked() then return false end
local top, world
if type(game.pipelineGate) == "function" then
top, world = game:pipelineGate()
else
top = game.stack and game.stack:top()
world = game.overworld or game.world
end
if not Pipelines.canToggle("voxel", top, world) then return false end
setVoxelOption(game, Voxel.nextHotkeyLevel(Pipelines.level("voxel")))
local options = game.options or (game.save and game.save.options) or {}
-- 3 is the key that used to turn TILT on and sits next to the one that
-- used to turn GBC FX on, and this mod has taken both away. A player who
-- left either running before enabling the mod would otherwise have no
-- way back to off, and both fight the diorama -- so the VOXEL step
-- clears them on EVERY press, not just the press that switches on.
options.tilt = 0
options.gbcfx = 0
-- Silver has the option keys and native display hotkeys, but does not ship
-- Gen1's standalone GBCFX module. Clear whichever optional renderer modules
-- this engine lineage actually exposes without making the voxel key depend
-- on either one existing.
local okGbc, GBCFX = pcall(require, "src.render.GBCFX")
if okGbc and GBCFX and GBCFX.setLevel then pcall(GBCFX.setLevel, 0) end
local okTilt, Tilt = pcall(require, "src.render.Tilt")
if okTilt and Tilt and Tilt.setLevel then
pcall(Tilt.setLevel, options.tilt or 0)
end
return true
end
-- The VR stick click makes this same step (VR.stepView): the function is
-- a local of this file, so the handoff is explicit rather than a
-- reimplementation drifting out of date in lib/VR.lua.
VR.cycleVoxel = cycleVoxel
if V.generation() ~= 2 then
local Game = require("src.core.Game")
local Pipelines = require("src.render.Pipelines")
local inner = Game.keypressed
function Game:keypressed(key)
-- HORDE MODE owns the keyboard's spare keys while it runs: R reloads,