utils

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Waiting = iota
	Crafting
	Pausing
	Paused
	Stopping
	Stopped
	Finished
)

Indices for status color codes

View Source
const (
	Primary   = lipgloss.Color("12")
	Secondary = lipgloss.Color("14")
	Tertiary  = lipgloss.Color("13")

	Gray   = lipgloss.Color("8")
	Red    = lipgloss.Color("9")
	Green  = lipgloss.Color("10")
	Yellow = lipgloss.Color("11")
)

Variables

View Source
var (
	TitleStyle      = lipgloss.NewStyle().Padding(0, 1).Background(Primary)
	TitleView       = TitleStyle.Render("XIVCrafter")
	ListStyle       = lipgloss.NewStyle().Margin(1, 1)
	MainStyle       = lipgloss.NewStyle().Margin(1, 3)
	StatusStyle     = lipgloss.NewStyle().PaddingLeft(6)
	ListStatusStyle = lipgloss.NewStyle().PaddingLeft(4)
)
View Source
var (
	// XIVCrafter config file path
	ConfigPath string
)
View Source
var Logger *log.Logger

For debug mode

View Source
var (
	// Status color codes
	Status = []string{
		lipgloss.NewStyle().Foreground(Gray).Render("Waiting"),
		lipgloss.NewStyle().Foreground(Green).Render("Crafting"),
		lipgloss.NewStyle().Foreground(Yellow).Render("Pausing"),
		lipgloss.NewStyle().Foreground(Yellow).Render("Paused"),
		lipgloss.NewStyle().Foreground(Red).Render("Stopping"),
		lipgloss.NewStyle().Foreground(Red).Render("Stopped"),
		lipgloss.NewStyle().Foreground(Green).Render("Finished"),
	}
)

Functions

func CheckUniqueKeys

func CheckUniqueKeys(keys ...string) bool

CheckUniqueKeys checks to see if all hotkeys are unique

func CheckUniqueNames

func CheckUniqueNames(recipes []Recipe) bool

CheckUniqueNames checks to see if the Name field are unique per Recipe

func CheckValidKey

func CheckValidKey(key string) bool

CheckValidKey checks to see if the given string is a valid hotkey for XIVCrafter

func Validate

func Validate(startPause string, stop string, confirm string, cancel string, recipes []Recipe) (string, error)

Validate checks and validates the entire config for XIVCrafter

func ValidateRecipe

func ValidateRecipe(startPause string, stop string, confirm string, cancel string, recipe Recipe) error

ValidateSettings checks and validates the XIVCrafter settings and a recipe

func ValidateSettings

func ValidateSettings(startPause string, stop string, confirm string, cancel string) error

ValidateSettings checks and validates just the XIVCrafter settings

func WriteToConfig

func WriteToConfig(StartPause string, Stop string, Confirm string, Cancel string, Recipes []Recipe) error

WriteToConfig attempts to save the hotkeys and recipes into the config file

Types

type Config

type Config struct {
	StartPause string `json:"start_pause"`
	Stop       string `json:"stop"`

	Confirm string `json:"confirm"`
	Cancel  string `json:"cancel"`

	// Slice of Recipe structs
	Recipes []Recipe `json:"recipes"`
}

func NewConfig

func NewConfig() *Config

NewConfig returns the default settings for a Config struct

type Recipe

type Recipe struct {
	// XIVCrafter Settings
	Name string `json:"name"`

	// Consumables
	Food         string `json:"food"`
	FoodDuration int    `json:"food_duration"`
	Potion       string `json:"potion"`

	// In-Game Hotkeys
	Macro1         string `json:"macro1"`
	Macro1Duration int    `json:"macro1_duration"`
	Macro2         string `json:"macro2"`
	Macro2Duration int    `json:"macro2_duration"`
	Macro3         string `json:"macro3"`
	Macro3Duration int    `json:"macro3_duration"`
}

func NewRecipe

func NewRecipe() *Recipe

NewRecipe returns the default settings for a Recipe struct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL