Skip to content

Commit 66ed52e

Browse files
Add support for gui/journal in legends mode
1 parent 52133fc commit 66ed52e

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

gui/journal.lua

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,19 +313,17 @@ function JournalScreen:onDismiss()
313313
end
314314

315315
function main(options)
316-
local fortress_worldmap_mode = not dfhack.isMapLoaded() and dfhack.world.isFortressMode()
317-
local fortress_mode = dfhack.isMapLoaded() and dfhack.world.isFortressMode()
318-
local adventure_mode = dfhack.isMapLoaded() and dfhack.world.isAdventureMode()
316+
local journal_context_mode = journal_context.detect_journal_context_mode()
319317

320-
if not fortress_mode and not adventure_mode and not fortress_worldmap_mode then
321-
qerror('journal requires a fortress/adventure map to be loaded')
318+
if journal_context_mode == nil then
319+
qerror('journal requires a fortress/adventure/world/legends map to be loaded')
322320
end
323321

324322
local save_layout = options and options.save_layout
325323
local overrided_context_mode = options and options.context_mode
326324

327325
local context_mode = overrided_context_mode == nil and
328-
journal_context.detect_journal_context_mode() or overrided_context_mode
326+
journal_context_mode or overrided_context_mode
329327

330328
view = view and view:raise() or JournalScreen{
331329
save_prefix=options and options.save_prefix or '',

internal/journal/journal_context.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ local AdventurerJournalContext = reqscript('internal/journal/contexts/adventure'
1010
JOURNAL_CONTEXT_MODE = {
1111
FORTRESS='fortress',
1212
ADVENTURE='adventure',
13-
WORLDMAP='WORLDMAP',
13+
WORLDMAP='worldmap',
14+
LEGENDS='legends',
1415
DUMMY='dummy'
1516
}
1617

@@ -21,8 +22,10 @@ function detect_journal_context_mode()
2122
return JOURNAL_CONTEXT_MODE.FORTRESS
2223
elseif dfhack.isMapLoaded() and dfhack.world.isAdventureMode() then
2324
return JOURNAL_CONTEXT_MODE.ADVENTURE
25+
elseif dfhack.world.isLegends() then
26+
return JOURNAL_CONTEXT_MODE.LEGENDS
2427
else
25-
qerror('unsupported game mode')
28+
return nil
2629
end
2730
end
2831

@@ -44,6 +47,10 @@ function journal_context_factory(journal_context_mode, save_prefix)
4447
elseif journal_context_mode == JOURNAL_CONTEXT_MODE.WORLDMAP then
4548
local world_id = df.global.world.cur_savegame.world_header.id1
4649

50+
return WorldmapJournalContext{save_prefix=save_prefix, world_id=world_id}
51+
elseif journal_context_mode == JOURNAL_CONTEXT_MODE.LEGENDS then
52+
local world_id = df.global.world.cur_savegame.world_header.id1
53+
4754
return WorldmapJournalContext{save_prefix=save_prefix, world_id=world_id}
4855
elseif journal_context_mode == JOURNAL_CONTEXT_MODE.DUMMY then
4956
return DummyJournalContext{}

0 commit comments

Comments
 (0)