Add CONTRIBUTORS file content to credits screen (#159)

This commit is contained in:
Averrin 2019-11-13 17:56:45 +01:00 committed by Tim Sarbin
parent 738a203325
commit f83ab90d96
2 changed files with 45 additions and 0 deletions

23
CONTRIBUTORS Normal file
View File

@ -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

View File

@ -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...)
},
}
}