Skip to content

Commit

Permalink
fix: WASM build not using TrueColor
Browse files Browse the repository at this point in the history
  • Loading branch information
BigJk committed Aug 25, 2024
1 parent 312c3db commit 475190c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
41 changes: 21 additions & 20 deletions system/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ package image
import (
"bytes"
"errors"
"github.com/BigJk/end_of_eden/internal/fs"
"github.com/BigJk/imeji"
"github.com/BigJk/imeji/charmaps"
"github.com/charmbracelet/log"
"github.com/muesli/termenv"
"image"
"image/draw"
"image/gif"
Expand All @@ -19,6 +14,12 @@ import (
"path/filepath"
"runtime"
"strings"

"github.com/BigJk/end_of_eden/internal/fs"
"github.com/BigJk/imeji"
"github.com/BigJk/imeji/charmaps"
"github.com/charmbracelet/log"
"github.com/muesli/termenv"
)

// TODO: Better decoupling in relation to session
Expand Down Expand Up @@ -52,21 +53,21 @@ func buildOption(options ...Option) (Options, []imeji.Option) {
if runtime.GOOS == "js" {
imejiOptions = append(imejiOptions, imeji.WithTrueColor())
data.tag += "truecolor"
}

switch termenv.DefaultOutput().Profile {
case termenv.TrueColor:
imejiOptions = append(imejiOptions, imeji.WithTrueColor())
data.tag += "truecolor"
case termenv.ANSI:
imejiOptions = append(imejiOptions, imeji.WithANSI())
data.tag += "ansi"
case termenv.ANSI256:
imejiOptions = append(imejiOptions, imeji.WithANSI256())
data.tag += "ansi256"
default:
// TODO: should this be the default fallback?
imejiOptions = append(imejiOptions, imeji.WithTrueColor())
} else {
switch termenv.DefaultOutput().Profile {
case termenv.TrueColor:
imejiOptions = append(imejiOptions, imeji.WithTrueColor())
data.tag += "truecolor"
case termenv.ANSI:
imejiOptions = append(imejiOptions, imeji.WithANSI())
data.tag += "ansi"
case termenv.ANSI256:
imejiOptions = append(imejiOptions, imeji.WithANSI256())
data.tag += "ansi256"
default:
// TODO: should this be the default fallback?
imejiOptions = append(imejiOptions, imeji.WithTrueColor())
}
}

// Build image options
Expand Down
9 changes: 9 additions & 0 deletions ui/menus/mainmenu/choices.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package mainmenu

import (
"runtime"

"github.com/BigJk/end_of_eden/system/audio"
"github.com/BigJk/end_of_eden/ui/style"
"github.com/charmbracelet/bubbles/list"
Expand Down Expand Up @@ -49,6 +51,13 @@ func NewChoicesModel(zones *zone.Manager, hideSettings bool) ChoicesModel {
choiceItem{zones, "Exit", "Got enough already?", ChoiceExit},
}

// Hide exit on web
if runtime.GOOS == "js" {
choices = lo.Filter(choices, func(value list.Item, i int) bool {
return value.(choiceItem).title != "Exit" || value.(choiceItem).title == "Mods"
})
}

if hideSettings {
choices = lo.Filter(choices, func(value list.Item, i int) bool {
return value.(choiceItem).key != ChoiceSettings
Expand Down

0 comments on commit 475190c

Please sign in to comment.