Compare commits
9 Commits
93493c2af7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 262f3d59ec | |||
| e6329500b5 | |||
| 219423f2b3 | |||
| 1d5a891a71 | |||
| 5ddc2aaf7f | |||
| f9f0345c82 | |||
| 4619fef9a3 | |||
| 37f9bc215f | |||
| 0aee2e904f |
@@ -2,4 +2,25 @@ module zomo.dev/bappackage
|
||||
|
||||
go 1.25.0
|
||||
|
||||
require gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
require (
|
||||
github.com/charmbracelet/lipgloss v1.1.0
|
||||
github.com/charmbracelet/log v1.0.0
|
||||
gopkg.in/ini.v1 v1.67.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
|
||||
github.com/charmbracelet/x/ansi v0.8.0 // indirect
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
|
||||
github.com/charmbracelet/x/term v0.2.1 // indirect
|
||||
github.com/go-logfmt/logfmt v0.6.1 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/muesli/termenv v0.16.0 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
)
|
||||
|
||||
@@ -1,2 +1,46 @@
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
|
||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
|
||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
|
||||
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
|
||||
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
|
||||
github.com/charmbracelet/log v1.0.0 h1:HVVVMmfOorfj3BA9i8X8UL69Hoz9lI0PYwXfJvOdRc4=
|
||||
github.com/charmbracelet/log v1.0.0/go.mod h1:uYgY3SmLpwJWxmlrPwXvzVYujxis1vAKRV/0VQB7yWA=
|
||||
github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE=
|
||||
github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q=
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8=
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
|
||||
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
|
||||
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-logfmt/logfmt v0.6.1 h1:4hvbpePJKnIzH1B+8OR/JPbTx37NktoI9LE2QZBBkvE=
|
||||
github.com/go-logfmt/logfmt v0.6.1/go.mod h1:EV2pOAQoZaT1ZXZbqDl5hrymndi4SY9ED9/z6CO0XAk=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
|
||||
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
@@ -2,8 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/ini.v1"
|
||||
)
|
||||
@@ -12,6 +12,10 @@ type RoomIni struct {
|
||||
night int
|
||||
room int
|
||||
|
||||
name string
|
||||
credits string
|
||||
links []string
|
||||
|
||||
size float64
|
||||
speed float64
|
||||
fov float64
|
||||
@@ -28,8 +32,7 @@ func (r *RoomIni) ToIni() string {
|
||||
return strconv.FormatFloat(n, 'f', -1, 64)
|
||||
}
|
||||
|
||||
return fmt.Sprintf(`
|
||||
[NIGHT_%d_ROOM_%d]
|
||||
return fmt.Sprintf(`[NIGHT_%d_ROOM_%d]
|
||||
size=%s
|
||||
speed=%s
|
||||
FOV=%s
|
||||
@@ -49,6 +52,29 @@ Mini_speed=%s
|
||||
)
|
||||
}
|
||||
|
||||
func (r *RoomIni) ToCredits() string {
|
||||
name := r.name
|
||||
if name == "" {
|
||||
name = "unnamed"
|
||||
}
|
||||
credits := r.credits
|
||||
if credits == "" {
|
||||
credits = "no name"
|
||||
}
|
||||
links := strings.Join(r.links, " | ")
|
||||
if links == "" {
|
||||
links = "no links"
|
||||
}
|
||||
|
||||
return fmt.Sprintf(`Night %d - Room %d: %s
|
||||
By: %s
|
||||
Links: %s
|
||||
`,
|
||||
r.night, r.room, name,
|
||||
credits, links,
|
||||
)
|
||||
}
|
||||
|
||||
func NewRoomIni() RoomIni {
|
||||
return RoomIni{
|
||||
night: -1,
|
||||
@@ -72,29 +98,7 @@ func ReadIni(path string) (RoomIni, error) {
|
||||
return RoomIni{}, err
|
||||
}
|
||||
|
||||
meta, err := cfg.GetSection("DEFAULT")
|
||||
if err != nil {
|
||||
return RoomIni{}, fmt.Errorf("unable to load DEFAULT section in %s: %+v", path, err)
|
||||
}
|
||||
|
||||
sections := cfg.Sections()
|
||||
var room *ini.Section = nil
|
||||
|
||||
for _, sec := range sections {
|
||||
if room != nil {
|
||||
log.Printf("WARN: extra section in %s, section: %s", path, sec.Name())
|
||||
continue
|
||||
}
|
||||
if sec.Name() != "default" {
|
||||
room = sec
|
||||
}
|
||||
}
|
||||
|
||||
if room == nil {
|
||||
room = meta
|
||||
}
|
||||
|
||||
roomIni, err := loadIni(meta, room)
|
||||
roomIni, err := loadIni(cfg)
|
||||
if err != nil {
|
||||
return RoomIni{}, fmt.Errorf("ERROR: error loading ini from %s: %+v", path, err)
|
||||
}
|
||||
@@ -102,103 +106,163 @@ func ReadIni(path string) (RoomIni, error) {
|
||||
return roomIni, nil
|
||||
}
|
||||
|
||||
func loadIni(meta *ini.Section, room *ini.Section) (RoomIni, error) {
|
||||
func loadIni(cfg *ini.File) (RoomIni, error) {
|
||||
roomini := RoomIni{}
|
||||
|
||||
if val, err := loadInt(meta, "night", -1); err != nil {
|
||||
if err := loadIniMeta(&roomini, cfg); err != nil {
|
||||
return RoomIni{}, err
|
||||
}
|
||||
|
||||
if err := loadIniCredits(&roomini, cfg); err != nil {
|
||||
return RoomIni{}, err
|
||||
}
|
||||
|
||||
if err := loadIniRoom(&roomini, cfg); err != nil {
|
||||
return RoomIni{}, err
|
||||
}
|
||||
|
||||
return roomini, nil
|
||||
}
|
||||
|
||||
func loadIniMeta(roomini *RoomIni, cfg *ini.File) error {
|
||||
if val, err := loadInt(cfg, "night", -1); err != nil {
|
||||
return err
|
||||
} else {
|
||||
roomini.night = val
|
||||
}
|
||||
|
||||
if val, err := loadInt(meta, "room", -1); err != nil {
|
||||
return RoomIni{}, err
|
||||
if val, err := loadInt(cfg, "room", -1); err != nil {
|
||||
return err
|
||||
} else {
|
||||
roomini.room = val
|
||||
}
|
||||
|
||||
if roomini.night > 0 && roomini.room < 1 {
|
||||
return RoomIni{}, fmt.Errorf("night is set but room is not set")
|
||||
return fmt.Errorf("night is set but room is not set")
|
||||
}
|
||||
|
||||
if val, err := loadFloat(room, "size", 1); err != nil {
|
||||
return RoomIni{}, err
|
||||
return nil
|
||||
}
|
||||
|
||||
func loadIniCredits(roomini *RoomIni, cfg *ini.File) error {
|
||||
roomini.name = loadString(cfg, "name", "")
|
||||
roomini.credits = loadString(cfg, "credits", "")
|
||||
|
||||
linksstring := loadString(cfg, "links", "")
|
||||
roomini.links = strings.Split(linksstring, " ")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func loadIniRoom(roomini *RoomIni, cfg *ini.File) error {
|
||||
if val, err := loadFloat(cfg, "size", 1); err != nil {
|
||||
return err
|
||||
} else {
|
||||
roomini.size = val
|
||||
}
|
||||
|
||||
if val, err := loadFloat(room, "speed", 1); err != nil {
|
||||
return RoomIni{}, err
|
||||
if val, err := loadFloat(cfg, "speed", 1); err != nil {
|
||||
return err
|
||||
} else {
|
||||
roomini.speed = val
|
||||
}
|
||||
|
||||
if val, err := loadFloat(room, "fov", 55); err != nil {
|
||||
return RoomIni{}, err
|
||||
if val, err := loadFloat(cfg, "fov", 55); err != nil {
|
||||
return err
|
||||
} else {
|
||||
roomini.fov = val
|
||||
}
|
||||
|
||||
if val, err := loadFloat(room, "texture_repeat", 3); err != nil {
|
||||
return RoomIni{}, err
|
||||
if val, err := loadFloat(cfg, "texture_repeat", 3); err != nil {
|
||||
return err
|
||||
} else {
|
||||
roomini.textureRepeat = val
|
||||
}
|
||||
|
||||
if val, err := loadFloat(room, "room_height", 350); err != nil {
|
||||
return RoomIni{}, err
|
||||
if val, err := loadFloat(cfg, "room_height", 350); err != nil {
|
||||
return err
|
||||
} else {
|
||||
roomini.roomHeight = val
|
||||
}
|
||||
|
||||
if val, err := loadInt(room, "layer_frames", 1); err != nil {
|
||||
return RoomIni{}, err
|
||||
if val, err := loadInt(cfg, "layer_frames", 1); err != nil {
|
||||
return err
|
||||
} else {
|
||||
roomini.layerFrames = val
|
||||
}
|
||||
|
||||
if val, err := loadInt(room, "fog_color", 0); err != nil {
|
||||
return RoomIni{}, err
|
||||
if val, err := loadInt(cfg, "fog_color", 0); err != nil {
|
||||
return err
|
||||
} else {
|
||||
roomini.fogColor = val
|
||||
}
|
||||
|
||||
if val, err := loadFloat(room, "fog_end", -1); err != nil {
|
||||
return RoomIni{}, err
|
||||
if val, err := loadFloat(cfg, "fog_end", -1); err != nil {
|
||||
return err
|
||||
} else {
|
||||
roomini.fogEnd = val
|
||||
}
|
||||
|
||||
if val, err := loadFloat(room, "mini_speed", 1); err != nil {
|
||||
return RoomIni{}, err
|
||||
if val, err := loadFloat(cfg, "mini_speed", 1); err != nil {
|
||||
return err
|
||||
} else {
|
||||
roomini.miniSpeed = val
|
||||
}
|
||||
|
||||
return roomini, nil
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func loadInt(sec *ini.Section, key string, def int) (int, error) {
|
||||
func loadInt(cfg *ini.File, key string, def int) (int, error) {
|
||||
sections := cfg.Sections()
|
||||
|
||||
for _, sec := range sections {
|
||||
val, err := sec.GetKey(key)
|
||||
if err != nil {
|
||||
return def, nil
|
||||
continue
|
||||
}
|
||||
|
||||
valint, err := val.Int()
|
||||
if err != nil {
|
||||
return def, err
|
||||
}
|
||||
|
||||
return valint, nil
|
||||
}
|
||||
|
||||
func loadFloat(sec *ini.Section, key string, def float64) (float64, error) {
|
||||
val, err := sec.GetKey(key)
|
||||
if err != nil {
|
||||
return def, nil
|
||||
}
|
||||
|
||||
func loadFloat(cfg *ini.File, key string, def float64) (float64, error) {
|
||||
sections := cfg.Sections()
|
||||
|
||||
for _, sec := range sections {
|
||||
val, err := sec.GetKey(key)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
valfloat, err := val.Float64()
|
||||
if err != nil {
|
||||
return def, err
|
||||
}
|
||||
|
||||
return valfloat, nil
|
||||
}
|
||||
|
||||
return def, nil
|
||||
}
|
||||
|
||||
func loadString(cfg *ini.File, key string, def string) string {
|
||||
sections := cfg.Sections()
|
||||
|
||||
for _, sec := range sections {
|
||||
val, err := sec.GetKey(key)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
return val.String()
|
||||
}
|
||||
|
||||
return def
|
||||
}
|
||||
|
||||
+3
-2
@@ -2,10 +2,11 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
|
||||
"github.com/charmbracelet/log"
|
||||
)
|
||||
|
||||
type RoomFolder struct {
|
||||
@@ -30,7 +31,7 @@ func LoadRoomFolders(roomspath string) ([]RoomFolder, error) {
|
||||
entrypath := filepath.Join(roomspath, entry.Name())
|
||||
roomfolder, err := loadRoom(entrypath)
|
||||
if err != nil {
|
||||
log.Printf("ERROR: unable to load directory: %s: %v", entrypath, err)
|
||||
log.Errorf("unable to load directory: %s: %v", entrypath, err)
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
|
||||
"github.com/charmbracelet/log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -28,7 +29,7 @@ func mainErr() error {
|
||||
|
||||
err = CheckDuplicateRooms(roomFolders)
|
||||
if err != nil {
|
||||
log.Printf("Error in room assigmnents: %v", err)
|
||||
log.Errorf("Error in room assigmnents: %v", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,14 @@ import (
|
||||
"image"
|
||||
"image/color"
|
||||
"image/png"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/charmbracelet/log"
|
||||
)
|
||||
|
||||
//go:embed silence.wav
|
||||
@@ -19,6 +21,18 @@ var SILENCE_WAV []byte
|
||||
|
||||
const FILEPERM = 0644
|
||||
|
||||
var styleRedtext = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("9"))
|
||||
|
||||
var styleYellowtext = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("11"))
|
||||
|
||||
var styleGreentext = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("10"))
|
||||
|
||||
var padd = lipgloss.NewStyle().
|
||||
PaddingLeft(4)
|
||||
|
||||
// only deletes DATA/NIGHT_* folders and the CF.ini file
|
||||
// will not touch TITLE or any game files
|
||||
// so this can be ran safely in your game's directory
|
||||
@@ -28,17 +42,12 @@ func EmptyOut(outpath string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
cfpath := path.Join(outpath, "CF.ini")
|
||||
exists, err := Exists(cfpath)
|
||||
err = emptyOutCredits(outpath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !exists {
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Printf("INFO: removing %s", cfpath)
|
||||
return os.Remove(cfpath)
|
||||
return emptyOutCF(outpath)
|
||||
}
|
||||
|
||||
func emptyOutData(outpath string) error {
|
||||
@@ -66,7 +75,9 @@ func emptyOutData(outpath string) error {
|
||||
|
||||
if len(name) >= len(nightprefix) && name[:len(nightprefix)] == nightprefix {
|
||||
nightpath := path.Join(datapath, entry.Name())
|
||||
log.Printf("INFO: removing %s", nightpath)
|
||||
|
||||
log.Info(Renderf(styleRedtext, "removing %s", nightpath))
|
||||
|
||||
err = os.RemoveAll(nightpath)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -77,28 +88,105 @@ func emptyOutData(outpath string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func emptyOutCredits(outpath string) error {
|
||||
cfpath := path.Join(outpath, "credits.txt")
|
||||
exists, err := Exists(cfpath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !exists {
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Info(Renderf(styleRedtext, "removing %s", cfpath))
|
||||
return os.Remove(cfpath)
|
||||
}
|
||||
|
||||
func emptyOutCF(outpath string) error {
|
||||
cfpath := path.Join(outpath, "CF.ini")
|
||||
exists, err := Exists(cfpath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !exists {
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Info(Renderf(styleRedtext, "removing %s", cfpath))
|
||||
return os.Remove(cfpath)
|
||||
}
|
||||
|
||||
func CopyOut(roomFolders []RoomFolder, outpath string, splash1len, splash2len int) error {
|
||||
inistr := fmt.Sprintf(`[SETTINGS]
|
||||
// base ini settings
|
||||
var inistr strings.Builder
|
||||
fmt.Fprintf(&inistr, `[SETTINGS]
|
||||
Sensitivity=6
|
||||
Splash1len=%d
|
||||
Splash2len=%d
|
||||
`, splash1len, splash2len)
|
||||
|
||||
// loop through folders
|
||||
log.Info("")
|
||||
roomcredits := []string{}
|
||||
for _, roomFolder := range roomFolders {
|
||||
err := copyFolder(roomFolder, outpath)
|
||||
err := copyFolder(&roomFolder, outpath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error copying folder %s: %+v", roomFolder.Path, err)
|
||||
}
|
||||
inistr += roomFolder.Cfg.ToIni()
|
||||
inistr.WriteString(roomFolder.Cfg.ToIni())
|
||||
|
||||
err = checkCredits(&roomFolder)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error checking credits in folder %s: %+v", roomFolder.Path, err)
|
||||
}
|
||||
|
||||
roomcredits = append(roomcredits, roomFolder.Cfg.ToCredits())
|
||||
log.Info("")
|
||||
}
|
||||
|
||||
// save ini file
|
||||
outini := filepath.Join(outpath, "CF.ini")
|
||||
log.Println("INFO:")
|
||||
log.Printf("INFO: Writing %s", outini)
|
||||
return os.WriteFile(outini, []byte(inistr), FILEPERM)
|
||||
log.Info(Renderf(styleGreentext, "Writing %s", outini))
|
||||
|
||||
if err := os.WriteFile(outini, []byte(inistr.String()), FILEPERM); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
func copyFolder(roomFolder RoomFolder, outpath string) error {
|
||||
// save credits file
|
||||
creditsstring := strings.Join(roomcredits, "\n")
|
||||
|
||||
outcredits := filepath.Join(outpath, "credits.txt")
|
||||
log.Info(Renderf(styleGreentext, "Writing %s", outcredits))
|
||||
|
||||
return os.WriteFile(outcredits, []byte(creditsstring), FILEPERM)
|
||||
}
|
||||
|
||||
// doesn't error currently
|
||||
func checkCredits(roomFolder *RoomFolder) error {
|
||||
if roomFolder.Cfg.name == "" {
|
||||
log.Warn(padd.Render(styleYellowtext.Render("room config has no name, defaulting to folder name")))
|
||||
foldername := filepath.Base(roomFolder.Path)
|
||||
roomFolder.Cfg.name = foldername
|
||||
}
|
||||
|
||||
if roomFolder.Cfg.credits == "" {
|
||||
log.Warn(padd.Render(styleYellowtext.Render("room config has no credits")))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var styleTextRoom = lipgloss.NewStyle().
|
||||
Bold(true).
|
||||
Padding(0, 1).
|
||||
Background(lipgloss.Color("10")).
|
||||
Foreground(lipgloss.Color("0"))
|
||||
|
||||
var styleTextCopy = lipgloss.NewStyle().
|
||||
Bold(true).
|
||||
Foreground(lipgloss.Color("10"))
|
||||
|
||||
func copyFolder(roomFolder *RoomFolder, outpath string) error {
|
||||
nightdir := fmt.Sprintf("NIGHT_%d", roomFolder.Cfg.night)
|
||||
roomdir := fmt.Sprintf("ROOM_%d", roomFolder.Cfg.room)
|
||||
|
||||
@@ -106,11 +194,25 @@ func copyFolder(roomFolder RoomFolder, outpath string) error {
|
||||
|
||||
os.MkdirAll(roomoutpath, FILEPERM)
|
||||
|
||||
log.Println("INFO:")
|
||||
log.Printf("INFO: Copying %s", roomFolder.Path)
|
||||
log.Printf("INFO: to %s", roomoutpath)
|
||||
// print room info
|
||||
name := roomFolder.Cfg.name
|
||||
if name == "" {
|
||||
name = "MISSING NAME"
|
||||
}
|
||||
textRoom := Renderf(styleTextRoom, "Room - %s", name)
|
||||
log.Info(textRoom)
|
||||
|
||||
textCopy1 := styleTextCopy.Render("Copying From")
|
||||
textCopy2 := styleTextCopy.Render(" To")
|
||||
|
||||
textCopy1Comb := fmt.Sprintf("%s %s", textCopy1, roomFolder.Path)
|
||||
textCopy2Comb := fmt.Sprintf("%s %s", textCopy2, roomoutpath)
|
||||
|
||||
log.Info(padd.Render(textCopy1Comb))
|
||||
log.Info(padd.Render(textCopy2Comb))
|
||||
|
||||
if roomFolder.IsDefaultCfg {
|
||||
log.Println("INFO: room.ini was not found, using default settings")
|
||||
log.Info(padd.Render(styleYellowtext.Render("room.ini was not found, using default settings")))
|
||||
}
|
||||
|
||||
entries, err := os.ReadDir(roomFolder.Path)
|
||||
@@ -149,7 +251,7 @@ func copyFolder(roomFolder RoomFolder, outpath string) error {
|
||||
}
|
||||
|
||||
if len(extraRequiredImages) > 0 {
|
||||
log.Printf("INFO: necessary optional images will use a transparent file: %v", extraRequiredImages)
|
||||
log.Info(Renderf(padd, "necessary optional images will use a transparent file: %v", extraRequiredImages))
|
||||
|
||||
transparent := image.NewRGBA(image.Rectangle{image.Point{0, 0}, image.Point{1, 1}})
|
||||
transparent.Set(0, 0, color.RGBA{0xff, 0xff, 0xff, 0x01})
|
||||
@@ -172,11 +274,17 @@ func copyFolder(roomFolder RoomFolder, outpath string) error {
|
||||
} else {
|
||||
png.Encode(f, transparent)
|
||||
}
|
||||
|
||||
// ensure layer_frames is 1 if it's not included
|
||||
if strings.ToUpper(imagename) == "LAYER" && roomFolder.Cfg.layerFrames != 1 {
|
||||
log.Warn(padd.Render(Renderf(styleYellowtext, "room was configured to have %d layer frames, but no LAYER image exists: setting layer_frames=1", roomFolder.Cfg.layerFrames)))
|
||||
roomFolder.Cfg.layerFrames = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(extraRequiredAudio) > 0 {
|
||||
log.Printf("INFO: necessary optional audios will use a silent file: %v", extraRequiredAudio)
|
||||
log.Info(Renderf(padd, "necessary optional audios will use a silent file: %v", extraRequiredAudio))
|
||||
|
||||
for _, audioname := range extraRequiredAudio {
|
||||
audiopath := path.Join(roomoutpath, audioname+".wav")
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# bap-room-packager
|
||||
|
||||
**This is the guide for people who plan on working with or working on this program. [Click here for a guide if you want to submit a room.](userguide.md)**
|
||||
|
||||
This program will take a collection of [Bapalon](https://akuma-kira.itch.io/bap) rooms and automatically package them into BAP's directory format.
|
||||
|
||||
For a well developed example, see [SOUP ROOMS](https://kiteline.itch.io/soup-rooms).
|
||||
@@ -25,6 +27,8 @@ If the following optional audios are not included, they will be automatically fi
|
||||
- FOOT
|
||||
- MUSIC
|
||||
|
||||
### File Formats
|
||||
|
||||
Per BAP's readme file, here's a list of accepted file formats. Read BAP's readme file for engine limitations.
|
||||
|
||||
- image
|
||||
@@ -39,14 +43,13 @@ Per BAP's readme file, here's a list of accepted file formats. Read BAP's readme
|
||||
|
||||
### Room Settings
|
||||
|
||||
Each room's settings should be placed in a `ROOM.ini` (or `ROOM.txt`) file. Read BAP's readme file for more details of each setting.
|
||||
Each room's settings should be placed in a `ROOM.ini` (or `ROOM.txt`) file. Read BAP's readme file for more details about each setting.
|
||||
|
||||
The settings from each `ROOM.ini` file will be used to generate the final `CF.ini` file.
|
||||
|
||||
The following is an example `ROOM.ini` file. This is also the file's default settings, so any room with no `ROOM.ini`, or with missing settings from their `ROOM.ini` file, will use these values. The section title does not matter, in this case it's `example`.
|
||||
The following is an example `ROOM.ini` file. This is also the file's default settings, so any room with no `ROOM.ini`, or with missing settings from their `ROOM.ini` file, will use these values. Section titles (`[example]`) do not matter, they can be included or ommitted, the program searches all sections for all values.
|
||||
|
||||
```ini
|
||||
[example]
|
||||
size=1
|
||||
speed=1
|
||||
FOV=55
|
||||
@@ -56,6 +59,10 @@ Layer_Frames=1
|
||||
Fog_Color=0
|
||||
Fog_End=-1
|
||||
Mini_speed=1
|
||||
|
||||
name=<empty string>
|
||||
credits=<empty string>
|
||||
links=<empty string>
|
||||
```
|
||||
|
||||
## Usage
|
||||
@@ -94,7 +101,7 @@ rooms
|
||||
└───ROOM.ini
|
||||
```
|
||||
|
||||
The folder given by `outPath` can safely be the folder with BAP. This program will only touch the `DATA/NIGHT_*` folders and the `CF.ini` file in this folder.
|
||||
The folder given by `outPath` can safely be the folder with BAP. This program will only touch the `DATA/NIGHT_*` folders, the `CF.ini` file, and a generated `credits.txt` in this folder.
|
||||
|
||||
`roomPerNight` is used for rooms that do not have an assigned night and room number.
|
||||
|
||||
@@ -108,7 +115,6 @@ Here is an example of the example `ROOM.ini` above but directly assigned to nigh
|
||||
night=1
|
||||
room=1
|
||||
|
||||
[example]
|
||||
size=1
|
||||
speed=1
|
||||
FOV=55
|
||||
@@ -118,4 +124,8 @@ Layer_Frames=1
|
||||
Fog_Color=0
|
||||
Fog_End=-1
|
||||
Mini_speed=1
|
||||
|
||||
name=example
|
||||
credits=zomo
|
||||
links=https://example.com
|
||||
```
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
# Bap Room Packager User Guide
|
||||
|
||||
**This is the guide for people who plan on submitting a room. Your organizer must be using this tool for this guide to be applicable.**
|
||||
|
||||
[Click here to skip to the `ROOM.ini` file setup.](#room-settings)
|
||||
|
||||
This program will take a collection of [Bapalon](https://akuma-kira.itch.io/bap) rooms and automatically package them into BAP's directory format.
|
||||
|
||||
For a well developed example, see [SOUP ROOMS](https://kiteline.itch.io/soup-rooms).
|
||||
|
||||
## Room Folder Setup
|
||||
|
||||
Each room folder needs at least the following images. Every other file is optional.
|
||||
|
||||
- ART
|
||||
- CREDIT
|
||||
- FLOOR
|
||||
- ROOF
|
||||
- WALL
|
||||
|
||||
If the following optional images aren't included, they'll be automatically filled in with a transparent PNG file.
|
||||
|
||||
- MINI
|
||||
- INTERACT
|
||||
- LAYER
|
||||
|
||||
If the following optional audios aren't included, they'll be automatically filled in with a silent WAV file.
|
||||
|
||||
- FOOT
|
||||
- MUSIC
|
||||
|
||||
You should also include the following file to configure your room. Information about this file is below.
|
||||
|
||||
- ROOM.INI
|
||||
|
||||
## File Formats
|
||||
|
||||
Per BAP's readme file, here's a list of accepted file formats. Read BAP's readme file for engine limitations.
|
||||
|
||||
- image
|
||||
- PNG
|
||||
- JPG
|
||||
- BMP
|
||||
- audio
|
||||
- WAV
|
||||
- MP3
|
||||
- OGG
|
||||
- MIDI
|
||||
|
||||
Important notes about file formats:
|
||||
|
||||
- audio
|
||||
- for consistent results, use a WAV file for MUSIC
|
||||
|
||||
## Room Settings
|
||||
|
||||
You need to move the settings from BAP's `CF.ini` file into a new file called `ROOM.ini` in your room's folder. Read BAP's readme file for more details about each setting.
|
||||
|
||||
**You should also include your credits.** 3 options have been added:
|
||||
|
||||
- `name` is the name of your room
|
||||
- `credits` is your name
|
||||
- `links` is a link to you somewhere
|
||||
|
||||
Here's an example `ROOM.ini` file.
|
||||
|
||||
```ini
|
||||
size=1
|
||||
speed=1
|
||||
fov=55
|
||||
texture_repeat=3
|
||||
room_height=350
|
||||
layer_frames=1
|
||||
fog_color=0
|
||||
fog_end=-1
|
||||
mini_speed=1
|
||||
|
||||
name=example
|
||||
credits=zomo
|
||||
links=https://example.com
|
||||
```
|
||||
@@ -2,10 +2,13 @@ package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
)
|
||||
|
||||
func Exists(p ...string) (bool, error) {
|
||||
@@ -27,3 +30,8 @@ func SplitExt(filename string) (string, string) {
|
||||
}
|
||||
return name, ext
|
||||
}
|
||||
|
||||
func Renderf(style lipgloss.Style, format string, v ...any) string {
|
||||
str := fmt.Sprintf(format, v...)
|
||||
return style.Render(str)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user