-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will fix errors that occur when running the app outside the project directory.
- Loading branch information
Showing
8 changed files
with
134 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package assets | ||
|
||
import ( | ||
"bytes" | ||
"embed" | ||
"image" | ||
"strings" | ||
) | ||
|
||
//go:embed * | ||
var content embed.FS | ||
|
||
var DecredIcons map[string]image.Image | ||
|
||
func init() { | ||
decredIcons, err := Icons() | ||
if err != nil { | ||
panic("Error loading icons") | ||
} | ||
|
||
DecredIcons = decredIcons | ||
} | ||
|
||
func Icons() (map[string]image.Image, error) { | ||
entries, err := content.ReadDir("decredicons") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
decredIcons := make(map[string]image.Image) | ||
for _, entry := range entries { | ||
|
||
if entry.IsDir() || !strings.HasSuffix(entry.Name(), ".png") { | ||
continue | ||
} | ||
|
||
imgBytes, err := content.ReadFile("decredicons/" + entry.Name()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
img, _, err := image.Decode(bytes.NewBuffer(imgBytes)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
split := strings.Split(entry.Name(), ".") | ||
decredIcons[split[0]] = img | ||
} | ||
|
||
return decredIcons, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.