From 0cc1d17f4f442c4d715d1ab4bdbb5e71e32e0071 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sun, 15 Aug 2021 20:26:47 -0700 Subject: [PATCH] Sort levels and doodads in the Open menu --- pkg/doodads/json.go | 2 -- pkg/play_scene.go | 1 + pkg/windows/open_level_editor.go | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pkg/doodads/json.go b/pkg/doodads/json.go index e64dd2f..6a50e98 100644 --- a/pkg/doodads/json.go +++ b/pkg/doodads/json.go @@ -8,7 +8,6 @@ import ( "path/filepath" "git.kirsle.net/apps/doodle/pkg/balance" - "git.kirsle.net/apps/doodle/pkg/log" "git.kirsle.net/apps/doodle/pkg/usercfg" ) @@ -44,7 +43,6 @@ func FromJSON(filename string, data []byte) (*Doodad, error) { } } else if len(data) > 1 && data[0] == 0x1f && data[1] == 0x8b { // Gzip compressed. `1F8B` is gzip magic number. - log.Debug("Decompress doodad %s", filename) if gzd, err := FromGzip(data); err != nil { return nil, err } else { diff --git a/pkg/play_scene.go b/pkg/play_scene.go index 52ddccb..f1341df 100644 --- a/pkg/play_scene.go +++ b/pkg/play_scene.go @@ -234,6 +234,7 @@ func (s *PlayScene) setupPlayer() { // from right here. log.Info("Found start-flag.doodad at %s (ID %s)", actor.Point, actorID) flag = actor + flagCount++ break } } diff --git a/pkg/windows/open_level_editor.go b/pkg/windows/open_level_editor.go index f2753ec..8347886 100644 --- a/pkg/windows/open_level_editor.go +++ b/pkg/windows/open_level_editor.go @@ -2,6 +2,8 @@ package windows import ( "fmt" + "sort" + "strings" "git.kirsle.net/apps/doodle/pkg/balance" "git.kirsle.net/apps/doodle/pkg/level" @@ -67,6 +69,13 @@ func NewOpenLevelEditor(config OpenLevelEditor) *ui.Window { sysLevels, _ := level.ListSystemLevels() levels = append(levels, sysLevels...) + // Sort them! + sort.Slice( + levels, func(i, j int) bool { + return strings.ToLower(levels[i]) < strings.ToLower(levels[j]) + }, + ) + lvlRow := ui.NewFrame("Level Row 0") frame.Pack(lvlRow, ui.Pack{ Side: ui.N, @@ -156,6 +165,14 @@ func NewOpenLevelEditor(config OpenLevelEditor) *ui.Window { }) files, _ := userdir.ListDoodads() + + // Sort them! + sort.Slice( + files, func(i, j int) bool { + return strings.ToLower(files[i]) < strings.ToLower(files[j]) + }, + ) + ddRow := ui.NewFrame("Doodad Row 0") frame.Pack(ddRow, ui.Pack{ Side: ui.N,