From f83ab90d968c6c1d5679ecb3bcfe5e739130fb40 Mon Sep 17 00:00:00 2001 From: Averrin Date: Wed, 13 Nov 2019 17:56:45 +0100 Subject: [PATCH] Add CONTRIBUTORS file content to credits screen (#159) --- CONTRIBUTORS | 23 +++++++++++++++++++++++ d2core/d2scene/credits.go | 22 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 CONTRIBUTORS diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 00000000..bac2b46d --- /dev/null +++ b/CONTRIBUTORS @@ -0,0 +1,23 @@ +* OPEN DIABLO 2 +Tim "essial" Sarbin +ndechiara +mewmew +grazz +Erexo +Ziemas +liberodark +cardoso +Mirey +Lectem +wtfblub +q3cpma +averrin + +* DIABLO2 LOGO +Jose Pardilla (th3-prophetman) + +* DT1 File Specifications +Paul SIRAMY + +* Other Specifications and general info +Various users on Phrozen Keep diff --git a/d2core/d2scene/credits.go b/d2core/d2scene/credits.go index 3e81cbf4..20971837 100644 --- a/d2core/d2scene/credits.go +++ b/d2core/d2scene/credits.go @@ -1,7 +1,11 @@ package d2scene import ( + "bufio" "image/color" + "log" + "os" + "path" "strings" "github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource" @@ -57,6 +61,23 @@ func CreateCredits(fileProvider d2interface.FileProvider, sceneProvider d2interf return result } +// Load is called to load the contributors data from file +// TODO: use markdown for file and convert it to the suitable format +func (v *Credits) LoadContributors() []string { + contributors := []string{} + file, err := os.Open(path.Join("./", "CONTRIBUTORS")) + if err != nil { + log.Fatal("CONTRIBUTORS file is missing") + } + defer file.Close() + + scanner := bufio.NewScanner(file) + for scanner.Scan() { + contributors = append(contributors, strings.Trim(scanner.Text(), " ")) + } + return contributors +} + // Load is called to load the resources for the credits scene func (v *Credits) Load() []func() { return []func(){ @@ -76,6 +97,7 @@ func (v *Credits) Load() []func() { for i := range v.creditsText { v.creditsText[i] = strings.Trim(v.creditsText[i], " ") } + v.creditsText = append(v.LoadContributors(), v.creditsText...) }, } }