-
Notifications
You must be signed in to change notification settings - Fork 207
Feat/worldmap journal #1449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wiktor-obrebski
wants to merge
6
commits into
DFHack:master
Choose a base branch
from
wiktor-obrebski:feat/worldmap-journal
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/worldmap journal #1449
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1f50fea
Allow using journal in worldmap
wiktor-obrebski 04ec64b
Hide journal when embark finished
wiktor-obrebski 2e8dc40
Add tests for worldmap journal
wiktor-obrebski f44ed91
Add journal worldmap changelog entry
wiktor-obrebski 52133fc
Add guard for journal screen change cleanup
wiktor-obrebski 66ed52e
Add support for gui/journal in legends mode
wiktor-obrebski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--@ module = true | ||
|
||
local json = require 'json' | ||
|
||
local JOURNAL_WELCOME_COPY = [=[ | ||
Welcome to gui/journal, your planning scroll for the world of Dwarf Fortress! | ||
|
||
Here, you can outline your fortress ideas, compare embark sites, or record thoughts before founding your settlement. | ||
The text you write here is saved together with your world - even if you cancel the embark. | ||
|
||
For guidance on navigation and hotkeys, tap the ? button in the upper right corner. | ||
Strike the earth! | ||
]=] | ||
|
||
local TOC_WELCOME_COPY = [=[ | ||
Start a line with # symbols and a space to create a header. For example: | ||
|
||
# My section heading | ||
|
||
or | ||
|
||
## My section subheading | ||
|
||
Those headers will appear here, and you can click on them to jump to them in the text.]=] | ||
|
||
worldmap_config = worldmap_config or json.open('dfhack-config/journal-context.json') | ||
|
||
WorldmapJournalContext = defclass(WorldmapJournalContext) | ||
WorldmapJournalContext.ATTRS{ | ||
save_prefix='', | ||
world_id=DEFAULT_NIL | ||
} | ||
|
||
function get_worldmap_context_key(prefix, world_id) | ||
return prefix .. 'world:' .. world_id | ||
end | ||
|
||
function WorldmapJournalContext:save_content(text, cursor) | ||
if dfhack.isWorldLoaded() then | ||
local key = get_worldmap_context_key(self.save_prefix, self.world_id) | ||
worldmap_config.data[key] = {text={text}, cursor={cursor}} | ||
worldmap_config:write() | ||
end | ||
end | ||
|
||
function WorldmapJournalContext:load_content() | ||
if dfhack.isWorldLoaded() then | ||
local key = get_worldmap_context_key(self.save_prefix, self.world_id) | ||
local worldmap_data = copyall(worldmap_config.data[key] or {}) | ||
|
||
if not worldmap_data.text or #worldmap_data.text[1] == 0 then | ||
worldmap_data.text={''} | ||
worldmap_data.show_tutorial = true | ||
end | ||
worldmap_data.cursor = worldmap_data.cursor or {#worldmap_data.text[1] + 1} | ||
return worldmap_data | ||
end | ||
end | ||
|
||
function WorldmapJournalContext:delete_content() | ||
if dfhack.isWorldLoaded() then | ||
local key = get_worldmap_context_key(self.save_prefix, self.world_id) | ||
table.remove(worldmap_config.data, key) | ||
worldmap_config:write() | ||
end | ||
end | ||
|
||
function WorldmapJournalContext:welcomeCopy() | ||
return JOURNAL_WELCOME_COPY | ||
end | ||
|
||
function WorldmapJournalContext:tocWelcomeCopy() | ||
return TOC_WELCOME_COPY | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if u see a better way to detect that embark is finished
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
gui/embark-anywhere
andexportlegends
, I mask the vanilla action buttons and intercept clicks on them to dismiss the window when the vanilla viewscreen is about to change state. Would that be possible here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it would be possible, but I am afraid such solution is too volatile.
UX can easly change, which will break the behaviour. And we do not have a way to test such behaviour.
I think it's much more realistic risk that change in the focus string name.