Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Template for new versions:
## Misc Improvements

- `gui/export-world-map`: export of bridge and road materials and more precise bridge coordinates
- `gui/gm-editor`: Added toggle to sort fields alphabetically when displayed

## Removed

Expand Down
30 changes: 28 additions & 2 deletions gui/gm-editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ local keybindings_raw = {
{name='delete', key="CUSTOM_ALT_D",desc="Delete selected entry"},
{name='reinterpret', key="CUSTOM_ALT_R",desc="Open selected entry as something else"},
{name='start_filter', key="CUSTOM_S",desc="Start typing filter, Enter to finish"},
{name='toggle_sort', key="CUSTOM_SHIFT_S",desc="Toggle between alphabetical sorting"},
{name='gotopos', key="CUSTOM_G",desc="Move map view to location of target"},
{name='help', key="STRING_A063",desc="Show this help"},
{name='displace', key="STRING_A093",desc="Open reference offseted by index"},
Expand Down Expand Up @@ -121,7 +122,7 @@ end
GmEditorUi = defclass(GmEditorUi, widgets.Window)
GmEditorUi.ATTRS{
frame=sanitize_frame(copyall(config.data.frame or {})),
frame_title="GameMaster's editor",
frame_title="GameMaster's Editor",
frame_inset=0,
resizable=true,
resize_min=RESIZE_MIN,
Expand Down Expand Up @@ -620,6 +621,11 @@ function GmEditorUi:onInput(keys)
elseif keys[keybindings.help.key] then
self.subviews.pages:setSelected(2)
return true
elseif keys[keybindings.toggle_sort.key] then
self.sorting = not self.sorting
self:updateTitles()
self:updateTarget(true, true)
return true
end
end

Expand Down Expand Up @@ -660,8 +666,17 @@ function GmEditorUi:updateTitles()
end
for view,_ in pairs(views) do
local window = view.subviews[1]
local window_title = title
if window.autoupdate then
window_title = window_title .. ' (Live updates)'
end

if window.sorting then
window_title = window_title .. ' (Sorted)'
end

window.read_only = self.read_only
window.frame_title = title .. (window.autoupdate and ' (Live updates)' or '')
window.frame_title = window_title
end
save_config({read_only = self.read_only})
end
Expand Down Expand Up @@ -690,6 +705,17 @@ function GmEditorUi:updateTarget(preserve_pos,reindex)
end
self.subviews.lbl_current_item:itemById('union').text = type(trg.target) == 'userdata' and trg.target._type._union and " [union structure]" or ""
self.subviews.lbl_current_item:itemById('name').text=tostring(trg.target)

if self.sorting then
table.sort(trg.keys, function(a, b)
if type(a) == type(b) then
return a < b
end

return not(type(a) == "number")
end)
end

local t={}
for k,v in pairs(trg.keys) do
table.insert(t,{text={{text=string.format("%-"..trg.kw.."s",tostring(v))},{gap=2,text=self:getStringValue(trg,v)}}})
Expand Down