From 1ef7b37424b0b7bc098fea908c89c4f2181424fe Mon Sep 17 00:00:00 2001 From: "jerome.lesaux" Date: Tue, 12 Nov 2024 10:04:00 +0100 Subject: [PATCH] fix: fix palette convertion in tile tab --- gfx/tilemap.go | 2 +- go.mod | 2 +- go.sum | 2 ++ ui/martine-ui/tilemap_tab.go | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gfx/tilemap.go b/gfx/tilemap.go index 44bd38e..7f26f85 100644 --- a/gfx/tilemap.go +++ b/gfx/tilemap.go @@ -267,7 +267,7 @@ func TilemapClassical(mode uint8, isCpcPlus bool, filename, picturePath string, mapSize := constants.Size{Width: in.Bounds().Max.X, Height: in.Bounds().Bounds().Max.Y, ColorsAvailable: 16} m := ci.Resize(in, mapSize, cfg.ScrCfg.Process.ResizingAlgo) var palette color.Palette - palette = ci.ExtractPalette(m, isCpcPlus, cfg.ScrCfg.Size.ColorsAvailable) + palette, _, _ = ci.DowngradingPalette(m, cfg.ScrCfg.Size, isCpcPlus) refPalette := constants.CpcOldPalette if cfg.ScrCfg.IsPlus { refPalette = constants.CpcPlusPalette diff --git a/go.mod b/go.mod index 04b62a9..7d6dc43 100644 --- a/go.mod +++ b/go.mod @@ -41,7 +41,7 @@ require ( github.com/go-text/typesetting v0.2.0 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/gopherjs/gopherjs v1.17.2 // indirect - github.com/jeromelesaux/fyne-io v0.0.0-20241110220536-1bfc4382e7f7 + github.com/jeromelesaux/fyne-io v0.0.0-20241112080444-354b23c6e4c0 github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/muesli/clusters v0.0.0-20200529215643-2700303c1762 // indirect diff --git a/go.sum b/go.sum index 96337ae..7cf72b1 100644 --- a/go.sum +++ b/go.sum @@ -235,6 +235,8 @@ github.com/jeromelesaux/fyne-io v0.0.0-20241110200135-c8baa8a7fc0c h1:e9QzGbC8u2 github.com/jeromelesaux/fyne-io v0.0.0-20241110200135-c8baa8a7fc0c/go.mod h1:CfylT5HbwoZiniHx+zg+9fpOM4P8cE6XQuyUOTJHVOo= github.com/jeromelesaux/fyne-io v0.0.0-20241110220536-1bfc4382e7f7 h1:pQqCMgELaD/+xm5XBiqgJUzgSsNes/hLNmDH3SsNkqo= github.com/jeromelesaux/fyne-io v0.0.0-20241110220536-1bfc4382e7f7/go.mod h1:CfylT5HbwoZiniHx+zg+9fpOM4P8cE6XQuyUOTJHVOo= +github.com/jeromelesaux/fyne-io v0.0.0-20241112080444-354b23c6e4c0 h1:Yo25HaXORWETcDIWQgjiCn9JT6VnJ913MA+hmZm/D2c= +github.com/jeromelesaux/fyne-io v0.0.0-20241112080444-354b23c6e4c0/go.mod h1:CfylT5HbwoZiniHx+zg+9fpOM4P8cE6XQuyUOTJHVOo= github.com/jeromelesaux/m4client v0.0.0-20200309212559-efb59c22369c/go.mod h1:JO0ijl8YXO6FxogJoC3yAFbBjSAnkwFquc8W6C7k94E= github.com/jeromelesaux/m4client v0.0.0-20230327092026-4e80fd2b1474 h1:CWtkpA4Q63pkhHWRrd/e98JD4YVZhk3SZu58bUkQsuI= github.com/jeromelesaux/m4client v0.0.0-20230327092026-4e80fd2b1474/go.mod h1:Xc0HzC2TZ7fbDWyB8LosvziBQ5QvvwVt3xxAIEavWRc= diff --git a/ui/martine-ui/tilemap_tab.go b/ui/martine-ui/tilemap_tab.go index 6baaff7..d8083a0 100644 --- a/ui/martine-ui/tilemap_tab.go +++ b/ui/martine-ui/tilemap_tab.go @@ -134,6 +134,7 @@ func (m *MartineUI) SetTileImage(newTile image.Image, p color.Palette) { // nolint: funlen, gocognit func (m *MartineUI) newTilemapTab(tm *menu.TilemapMenu) *fyne.Container { + tm.Cfg.ScrCfg.Size.ColorsAvailable = constants.Mode0.ColorsAvailable // default value tm.ImageMenu.SetWindow(m.window) tm.Cfg.ScrCfg.Type = config.SpriteFormat importOpen := newImportButton(m, tm.ImageMenu)