summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2022-02-02 23:49:05 +0100
committerRené 'Necoro' Neumann <necoro@necoro.eu>2022-02-02 23:49:05 +0100
commit14d5d88df1e380bb78340952aa55780bbcb620e5 (patch)
tree708a9d0753439283488b12144b12c186bc84defc
parent80faa52aaf2e48092f8d8e0b1d9da59e6b47b098 (diff)
downloadengarde-importer-master.tar.gz
engarde-importer-master.tar.bz2
engarde-importer-master.zip
Slight restructuring / some commentsHEADmaster
-rw-r--r--gui.go34
-rw-r--r--main.go12
-rw-r--r--template.go10
3 files changed, 39 insertions, 17 deletions
diff --git a/gui.go b/gui.go
index ea26fbc..2c19e03 100644
--- a/gui.go
+++ b/gui.go
@@ -18,6 +18,10 @@ import (
//go:generate goversioninfo -64 -o resource_amd64.syso res/versioninfo.json
+/*
+ * Embedded Resources
+ */
+
//go:embed res/monitor_48.png
var icon []byte
@@ -25,6 +29,10 @@ var icon []byte
var icomoon []byte
var icomoonFI *g.FontInfo
+/*
+ * Data / State
+ */
+
type entryCfg struct {
inputFile string
target string
@@ -59,6 +67,11 @@ var (
entries []entryCfg
)
+/*
+ * Grid Layout
+ */
+// GridLayout is used to calculate the maximum width for labels,
+// so that the following widgets all start at the same offset.
type GridLayout struct {
widgets []g.Widget
labels []*g.LabelWidget
@@ -103,6 +116,10 @@ func (grid *GridLayout) Build() {
}
}
+/*
+ * Further additions to Giu
+ */
+
func Layout(widgets ...g.Widget) g.Layout {
return widgets
}
@@ -115,8 +132,17 @@ func PopID() g.Widget {
return g.Custom(imgui.PopID)
}
-const comboSize = 120
-const chooseStr = "Wähle..."
+func shouldQuit() {
+ g.Context.GetPlatform().SetShouldStop(true)
+}
+
+/*
+ * Putting together the GUI
+ */
+const (
+ comboSize = 120
+ chooseStr = "Wähle..."
+)
func buildEntry(idx int) g.Widget {
entry := &entries[idx]
@@ -183,10 +209,6 @@ func entryBuilder() g.Widget {
})
}
-func shouldQuit() {
- g.Context.GetPlatform().SetShouldStop(true)
-}
-
func loop() {
g.SingleWindow().Layout(
g.Align(g.AlignCenter).To(g.Label("Engarde Importer")),
diff --git a/main.go b/main.go
index d684390..abfac93 100644
--- a/main.go
+++ b/main.go
@@ -9,8 +9,8 @@ import (
)
type EngardeConfig struct {
- inputFile string
- outputDir string
+ InputFile string
+ OutputDir string
Name string
Description string
Gender Gender
@@ -26,8 +26,8 @@ func usage() string {
}
func parseArgs() (config EngardeConfig, err error) {
- config.inputFile = os.Args[1]
- config.outputDir = os.Args[2]
+ config.InputFile = os.Args[1]
+ config.OutputDir = os.Args[2]
config.Name = os.Args[3]
if config.Gender, err = GenderFromString(os.Args[4]); err != nil {
@@ -57,12 +57,12 @@ func run() error {
return err
}
- cfg.Participants, cfg.Clubs, err = parseOphardtInput(cfg.inputFile)
+ cfg.Participants, cfg.Clubs, err = parseOphardtInput(cfg.InputFile)
if err != nil {
return err
}
- return write(cfg)
+ return Write(cfg)
}
func main() {
diff --git a/template.go b/template.go
index f31c845..2a765c5 100644
--- a/template.go
+++ b/template.go
@@ -52,16 +52,16 @@ func writeVerbatim(outputDir string) error {
return nil
}
-func write(config EngardeConfig) error {
- if err := os.MkdirAll(config.outputDir, 0755); err != nil {
- return fmt.Errorf("creating output directory '%s': %w", config.outputDir, err)
+func Write(config EngardeConfig) error {
+ if err := os.MkdirAll(config.OutputDir, 0755); err != nil {
+ return fmt.Errorf("creating output directory '%s': %w", config.OutputDir, err)
}
- if err := writeVerbatim(config.outputDir); err != nil {
+ if err := writeVerbatim(config.OutputDir); err != nil {
return fmt.Errorf("copying default files: %w", err)
}
- if err := writeTemplates(config.outputDir, config); err != nil {
+ if err := writeTemplates(config.OutputDir, config); err != nil {
return fmt.Errorf("writing template files: %w", err)
}