Skip to content

Commit fa1bb00

Browse files
committed
Merge Adventure Arena reader improvements
2 parents 38dec8d + c84afeb commit fa1bb00

227 files changed

Lines changed: 1654 additions & 2329 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Makefile‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ test: $(LUA_OBJC_BIN) $(FRAMEWORK_MODULES) $(NATIVE_PLUGINS) $(PARITY_IMAGE_DIFF
189189
DEVELOPER_DIR ?= /Applications/Xcode.app/Contents/Developer
190190
export DEVELOPER_DIR
191191
IOS_MIN := 26.5
192-
DEVICE ?= iPhone 17
192+
SIMULATOR_DEVICE = $(or $(DEVICE),iPhone 17)
193193
IOS_SDK := $(shell xcrun --sdk iphonesimulator --show-sdk-path 2>/dev/null)
194194
IOS_CC := $(shell xcrun --sdk iphonesimulator --find clang)
195195
LUA_SRC_DIR := vendor/lua-5.4.8/src
@@ -259,12 +259,12 @@ ios-packager-stop:
259259

260260
ios-run: ios-host ios-packager
261261
chmod +x scripts/ios-run.sh
262-
DEVELOPER_DIR=$(DEVELOPER_DIR) DEVICE="$(DEVICE)" PROJECT="$(or $(PROJECT),demo/hello)" \
262+
DEVELOPER_DIR=$(DEVELOPER_DIR) DEVICE="$(SIMULATOR_DEVICE)" PROJECT="$(or $(PROJECT),demo/hello)" \
263263
scripts/ios-run.sh
264264

265265
ios-internal-screenshot: ios-host ios-packager
266266
DEVELOPER_DIR=$(DEVELOPER_DIR) OUT="$(or $(OUT),/tmp/ios-internal-screenshot.png)" \
267-
PROJECT="$(or $(PROJECT),demo/hello)" DEVICE="$(DEVICE)" \
267+
PROJECT="$(or $(PROJECT),demo/hello)" DEVICE="$(SIMULATOR_DEVICE)" \
268268
scripts/ios-internal-screenshot.sh
269269

270270
ios-screenshot:
@@ -330,10 +330,11 @@ parity-report: parity-check
330330

331331
# Standalone iPad development app (no Mac packager required).
332332
.PHONY: ipad ipad-simulator ipad-run ipad-deploy list-devices
333-
.PHONY: iphone-deploy
334-
iphone-deploy:
335-
$(MAKE) ipad-deploy DEVICE_TYPE=iPhone APP="$(or $(APP),adventure-arena)" \
336-
DEVICE_FAMILY=1 FILE_SHARING=0
333+
.PHONY: iphone iphone-deploy
334+
iphone iphone-deploy:
335+
$(MAKE) -f scripts/ipad/build.mk SDK=iphoneos deploy DEVICE_TYPE=iPhone \
336+
APP="$(or $(APP),adventure-arena)" DEVICE_FAMILY=1 FILE_SHARING=0 \
337+
DEVICE="$(or $(DEVICE),$(IPHONE_DEVICE))"
337338

338339
ipad:
339340
$(MAKE) -f scripts/ipad/build.mk SDK=iphoneos app

‎README.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,10 @@ UIKit preview, an OpenRouter coding agent, system keyboard dictation, source
481481
editing, and undo. Projects run and save locally without the Mac packager.
482482
See [Lua Studio](apps/studio/README.md) for setup and current boundaries.
483483

484-
Deploy an app from `apps/<name>/` to an iPhone with
485-
`make iphone-deploy APP=adventure-arena`. It uses the same build, signing, and
486-
install flow and automatically selects the only available physical iPhone.
484+
Use `make iphone APP=adventure-arena` to build, sign, install, and launch the app
485+
on a physical iPhone. The target uses `IPHONE_DEVICE` when set and otherwise
486+
selects the only available physical iPhone. Pass `DEVICE=<name-or-identifier>`
487+
to select a different phone for one run. Use `make list-devices` to see devices.
487488

488489
### Adventure Arena in Xcode
489490

‎apps/adventure-arena/Controller.lua‎

Lines changed: 21 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
local SavedGames = require("apps.adventure-arena.models.SavedGames")
21
local Session = require("apps.adventure-arena.zilscript.zilscript.reader.Session")
32
local JsonDocument = require("apps.adventure-arena.services.JsonDocument")
43
local Store = require("apps.adventure-arena.Store")
@@ -17,10 +16,6 @@ local DOCUMENTS = {
1716
onboarding = "adventure-arena/onboarding.json",
1817
}
1918

20-
-- Tabs in template order; each owns a navigation stack so a page opens in
21-
-- the tab the tap came from.
22-
local TABS = { "library", "bookshelf", "create", "settings", "search" }
23-
2419
local Controller = {}
2520
Controller.__index = Controller
2621

@@ -61,15 +56,8 @@ function Controller.new(options)
6156
self.pages = PageHost.new(ns, {
6257
push = function(id, state) return self:pushPage(id, state) end,
6358
back = function() return self:back() end,
64-
focus = function(origin) self:focus(origin) end,
65-
selectTab = function(name) return self:selectTab(name) end,
66-
tabChanged = function(index)
67-
self.selectedTab = index
68-
self:focus(TABS[index + 1])
69-
end,
59+
openCatalogPage = function(id) return self:openCatalogPage(id) end,
7060
openSession = function(id, fresh) return self.sessionController:show(id, fresh) end,
71-
resume = function() return self:resumeLatest() end,
72-
showAccessory = function(resumable) self:showAccessory(resumable) end,
7361
openGuide = function() self.onboarding:openGuide(self.window) end,
7462
mountReadingOptions = function(host) self:mountReadingOptions(host) end,
7563
})
@@ -141,90 +129,55 @@ function Controller:back()
141129
self.navigation:pop()
142130
end
143131

144-
function Controller:focus(origin)
145-
local navigation = self.navigations and self.navigations[origin]
146-
if navigation then self.navigation = navigation end
147-
end
132+
function Controller:openCatalogPage(id)
133+
if id == "create" then return self:push("pages/Create", {}) end
148134

149-
-- Discover / Library / Create / Settings / Search, matching Tabs.etlua.
150-
function Controller:selectTab(name)
151-
local index
152-
for i, key in ipairs(TABS) do
153-
if key == name then index = i - 1 break end
135+
local template, data
136+
if id == "search" then
137+
template, data = "pages/Search", self.pages:data("search")
138+
else
139+
assert(id == "settings", "unknown catalog page")
140+
template, data = "layouts/CatalogPage", { title = "Settings", actions = {} }
154141
end
155-
if not index then return false end
156-
self.selectedTab = index
157-
self:focus(name)
158-
if self.tabs then self.tabs:selectTab(index) end
159-
return true
160-
end
161-
162-
-- The accessory resumes the latest story in whichever tab is showing.
163-
function Controller:resumeLatest()
164-
local latest = SavedGames:latest()
165-
if not latest then return false end
166-
self:focus(TABS[(self.selectedTab or 0) + 1])
167-
return self.sessionController:show(latest.gameId)
142+
data.actions.closeCatalogPage = function()
143+
if id == "settings" then
144+
self.readingOptions:unmount(self.catalogReadingOptions)
145+
self.catalogReadingOptions, self.readingHost = nil, nil
146+
end
147+
self.pages:unmount(id)
148+
end
149+
local _, refs = self:push(template, data)
150+
self.pages:mount(id, refs.catalogContent)
168151
end
169152

170-
-- Discover's data and the actions of every page the window layout names:
171-
-- Discover's own, and the search field's.
172153
function Controller:libraryData()
173154
local library = self.pages:data("discover")
174-
local actions = {}
175-
for name, action in pairs(library.actions) do actions[name] = action end
176-
actions.search = self.pages:data("search").actions.search
177-
return { library = library, actions = actions }
155+
return { library = library, actions = library.actions }
178156
end
179157

180-
-- Everything that shows reading progress: the Discover shelf, the Library
181-
-- tab and the tab bar accessory, each asked again.
182158
function Controller:refreshProgress()
183159
self.pages:refresh()
184160
end
185161

186-
-- An open book hides the accessory with the tab bar, as does having
187-
-- nothing to resume.
188-
function Controller:showAccessory(resumable)
189-
if self.tabs then self.tabs.accessoryHidden = not resumable or self.sessionController:isOpen() end
190-
end
191-
192162
-- The reading options are shared with the in-book sheet: mounted once per
193163
-- host the Settings page draws.
194164
function Controller:mountReadingOptions(host)
195165
if not host or self.readingHost == host then return end
166+
self.readingOptions:unmount(self.catalogReadingOptions)
196167
self.readingHost = host
197-
self.readingOptions:mount(host, true)
198-
end
199-
200-
function Controller:attach(refs)
201-
local pages = self.pages
202-
-- An empty catalog shows its empty state and has no shelf to fill.
203-
if refs.continueShelf then pages:mount("continueShelf", refs.continueShelf) end
204-
if refs.bookshelf then pages:mount("bookshelf", refs.bookshelf) end
205-
if refs.nowReading then pages:mount("nowReading", refs.nowReading) end
206-
if refs.searchResults then pages:mount("search", refs.searchResults) end
207-
if refs.settings then pages:mount("settings", refs.settings) end
168+
self.catalogReadingOptions = self.readingOptions:mount(host, true)
208169
end
209170

210171
function Controller:home()
211172
local _, refs = xml.renderFile(VIEWS .. "layouts/Home.etlua", self:libraryData(), self.ns)
212173
self.navigation = refs.navigation
213-
self.navigations = { library = refs.navigation }
214-
self:attach(refs)
215174
return self.navigation
216175
end
217176

218177
function Controller:createWindow()
219178
local config, refs = xml.renderFile(VIEWS .. "layouts/Window.etlua", self:libraryData(), self.ns)
220179
self.navigation = refs.navigation
221-
self.navigations = {
222-
library = refs.navigation, bookshelf = refs.bookshelfNavigation, create = refs.createNavigation,
223-
settings = refs.settingsNavigation, search = refs.searchNavigation,
224-
}
225-
self.tabs = refs.tabs
226180
self.window = self.ns.Window(config)
227-
self:attach(refs)
228181
-- Headless runs drive the tour themselves; a live launch shows it once.
229182
if not rawget(_G, "__headless") and self.onboarding:needed() then
230183
self.onboarding:open(self.window)

‎apps/adventure-arena/Info.plist‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plist version="1.0">
44
<dict>
55
<key>CFBundleDevelopmentRegion</key><string>en</string>
6-
<key>CFBundleDisplayName</key><string>Adventure Arena</string>
6+
<key>CFBundleDisplayName</key><string>Elsewhere</string>
77
<key>CFBundleExecutable</key><string>$(EXECUTABLE_NAME)</string>
88
<key>CFBundleIdentifier</key><string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
99
<key>CFBundleInfoDictionaryVersion</key><string>6.0</string>

‎apps/adventure-arena/Store.lua‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
local Model = require("data.model")
2-
local Adventures = require("apps.adventure-arena.models.Adventures")
32
local ReadingSettings = require("apps.adventure-arena.models.ReadingSettings")
43
local SavedGames = require("apps.adventure-arena.models.SavedGames")
54

@@ -21,7 +20,7 @@ function Store.new(options)
2120
local function load(document) return document and document.load and document.load() end
2221
local games = {}
2322
for _, game in ipairs(options.games or require("apps.adventure-arena.catalog.Adventures")) do
24-
table.insert(games, Adventures.prepare(game))
23+
table.insert(games, game)
2524
end
2625
return Model.bind({
2726
adventures = games,

‎apps/adventure-arena/app.xml‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
<App name="Adventure Arena" startup="discover" controller="Controller">
2-
<!-- A phone app has no sidebar: the tabs and navigation stacks are
3-
layouts/Tabs.etlua, and every page is unlisted. `origin` names the
4-
navigation stack a page opens its stories in. -->
5-
<Page id="discover" title="Discover" origin="library" listed="false" />
6-
<Page id="continueShelf" title="Continue Reading" origin="library" listed="false" />
7-
<Page id="bookshelf" title="Library" origin="bookshelf" listed="false" />
8-
<Page id="nowReading" title="Now Reading" listed="false" />
9-
<Page id="search" title="Search" origin="search" listed="false" />
2+
<Page id="discover" title="Discover" listed="false" />
3+
<Page id="search" title="Search" listed="false" />
104
<Page id="settings" title="Settings" listed="false" />
115
<Page id="detail" title="Adventure" listed="false" />
126
<Page id="collection" title="Collection" listed="false" />
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)