Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Fyne GUI option that adds a GameBoy feel
It also recolours pixels to match the original palette perhaps that should be part of the internal graphics? Fixes #12
- Loading branch information
1 parent
d6ef6e9
commit 1c46810
Showing
6 changed files
with
254 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package fyne | ||
|
||
import "fyne.io/fyne" | ||
|
||
var resourceFrameSvg = &fyne.StaticResource{ | ||
StaticName: "frame.svg", | ||
StaticContent: []byte{ | ||
60, 63, 120, 109, 108, 32, 118, 101, 114, 115, 105, 111, 110, 61, 34, 49, 46, 48, 34, 32, 101, 110, 99, 111, 100, 105, 110, 103, 61, 34, 85, 84, 70, 45, 56, 34, 32, 115, 116, 97, 110, 100, 97, 108, 111, 110, 101, 61, 34, 110, 111, 34, 63, 62, 10, 60, 33, 45, 45, 32, 67, 114, 101, 97, 116, 101, 100, 32, 119, 105, 116, 104, 32, 73, 110, 107, 115, 99, 97, 112, 101, 32, 40, 104, 116, 116, 112, 58, 47, 47, 119, 119, 119, 46, 105, 110, 107, 115, 99, 97, 112, 101, 46, 111, 114, 103, 47, 41, 32, 45, 45, 62, 10, 10, 60, 115, 118, 103, 10, 32, 32, 32, 120, 109, 108, 110, 115, 61, 34, 104, 116, 116, 112, 58, 47, 47, 119, 119, 119, 46, 119, 51, 46, 111, 114, 103, 47, 50, 48, 48, 48, 47, 115, 118, 103, 34, 10, 32, 32, 32, 119, 105, 100, 116, 104, 61, 34, 49, 51, 48, 109, 109, 34, 10, 32, 32, 32, 104, 101, 105, 103, 104, 116, 61, 34, 49, 48, 48, 109, 109, 34, 10, 32, 32, 32, 118, 105, 101, 119, 66, 111, 120, 61, 34, 48, 32, 48, 32, 49, 51, 48, 32, 49, 48, 48, 34, 10, 32, 32, 32, 118, 101, 114, 115, 105, 111, 110, 61, 34, 49, 46, 49, 34, 10, 32, 32, 32, 105, 100, 61, 34, 115, 118, 103, 56, 34, 62, 10, 32, 32, 60, 100, 101, 102, 115, 10, 32, 32, 32, 32, 32, 105, 100, 61, 34, 100, 101, 102, 115, 50, 34, 32, 47, 62, 10, 32, 32, 60, 103, 10, 32, 32, 32, 32, 32, 105, 100, 61, 34, 108, 97, 121, 101, 114, 49, 34, 10, 32, 32, 32, 32, 32, 116, 114, 97, 110, 115, 102, 111, 114, 109, 61, 34, 116, 114, 97, 110, 115, 108, 97, 116, 101, 40, 48, 44, 45, 49, 57, 55, 41, 34, 62, 10, 32, 32, 32, 32, 60, 114, 101, 99, 116, 10, 32, 32, 32, 32, 32, 32, 32, 115, 116, 121, 108, 101, 61, 34, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 102, 105, 108, 108, 58, 35, 98, 100, 98, 100, 98, 100, 59, 102, 105, 108, 108, 45, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 115, 116, 114, 111, 107, 101, 58, 35, 98, 100, 98, 100, 98, 100, 59, 115, 116, 114, 111, 107, 101, 45, 119, 105, 100, 116, 104, 58, 48, 59, 115, 116, 114, 111, 107, 101, 45, 108, 105, 110, 101, 99, 97, 112, 58, 114, 111, 117, 110, 100, 59, 115, 116, 114, 111, 107, 101, 45, 108, 105, 110, 101, 106, 111, 105, 110, 58, 114, 111, 117, 110, 100, 59, 115, 116, 114, 111, 107, 101, 45, 109, 105, 116, 101, 114, 108, 105, 109, 105, 116, 58, 52, 59, 115, 116, 114, 111, 107, 101, 45, 100, 97, 115, 104, 97, 114, 114, 97, 121, 58, 110, 111, 110, 101, 59, 115, 116, 114, 111, 107, 101, 45, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 112, 97, 105, 110, 116, 45, 111, 114, 100, 101, 114, 58, 115, 116, 114, 111, 107, 101, 32, 102, 105, 108, 108, 32, 109, 97, 114, 107, 101, 114, 115, 34, 10, 32, 32, 32, 32, 32, 32, 32, 105, 100, 61, 34, 114, 101, 99, 116, 57, 48, 53, 34, 10, 32, 32, 32, 32, 32, 32, 32, 119, 105, 100, 116, 104, 61, 34, 50, 48, 34, 10, 32, 32, 32, 32, 32, 32, 32, 104, 101, 105, 103, 104, 116, 61, 34, 49, 48, 48, 34, 10, 32, 32, 32, 32, 32, 32, 32, 120, 61, 34, 48, 34, 10, 32, 32, 32, 32, 32, 32, 32, 121, 61, 34, 49, 57, 55, 34, 32, 47, 62, 10, 32, 32, 32, 32, 60, 114, 101, 99, 116, 10, 32, 32, 32, 32, 32, 32, 32, 115, 116, 121, 108, 101, 61, 34, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 102, 105, 108, 108, 58, 35, 98, 100, 98, 100, 98, 100, 59, 102, 105, 108, 108, 45, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 115, 116, 114, 111, 107, 101, 58, 35, 98, 100, 98, 100, 98, 100, 59, 115, 116, 114, 111, 107, 101, 45, 119, 105, 100, 116, 104, 58, 48, 59, 115, 116, 114, 111, 107, 101, 45, 108, 105, 110, 101, 99, 97, 112, 58, 114, 111, 117, 110, 100, 59, 115, 116, 114, 111, 107, 101, 45, 108, 105, 110, 101, 106, 111, 105, 110, 58, 114, 111, 117, 110, 100, 59, 115, 116, 114, 111, 107, 101, 45, 109, 105, 116, 101, 114, 108, 105, 109, 105, 116, 58, 52, 59, 115, 116, 114, 111, 107, 101, 45, 100, 97, 115, 104, 97, 114, 114, 97, 121, 58, 110, 111, 110, 101, 59, 115, 116, 114, 111, 107, 101, 45, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 112, 97, 105, 110, 116, 45, 111, 114, 100, 101, 114, 58, 115, 116, 114, 111, 107, 101, 32, 102, 105, 108, 108, 32, 109, 97, 114, 107, 101, 114, 115, 34, 10, 32, 32, 32, 32, 32, 32, 32, 105, 100, 61, 34, 114, 101, 99, 116, 57, 48, 53, 45, 51, 34, 10, 32, 32, 32, 32, 32, 32, 32, 119, 105, 100, 116, 104, 61, 34, 50, 48, 34, 10, 32, 32, 32, 32, 32, 32, 32, 104, 101, 105, 103, 104, 116, 61, 34, 49, 48, 48, 34, 10, 32, 32, 32, 32, 32, 32, 32, 120, 61, 34, 49, 49, 48, 34, 10, 32, 32, 32, 32, 32, 32, 32, 121, 61, 34, 49, 57, 55, 34, 32, 47, 62, 10, 32, 32, 32, 32, 60, 114, 101, 99, 116, 10, 32, 32, 32, 32, 32, 32, 32, 115, 116, 121, 108, 101, 61, 34, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 102, 105, 108, 108, 58, 35, 98, 100, 98, 100, 98, 100, 59, 102, 105, 108, 108, 45, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 115, 116, 114, 111, 107, 101, 58, 35, 98, 100, 98, 100, 98, 100, 59, 115, 116, 114, 111, 107, 101, 45, 119, 105, 100, 116, 104, 58, 48, 59, 115, 116, 114, 111, 107, 101, 45, 108, 105, 110, 101, 99, 97, 112, 58, 114, 111, 117, 110, 100, 59, 115, 116, 114, 111, 107, 101, 45, 108, 105, 110, 101, 106, 111, 105, 110, 58, 114, 111, 117, 110, 100, 59, 115, 116, 114, 111, 107, 101, 45, 109, 105, 116, 101, 114, 108, 105, 109, 105, 116, 58, 52, 59, 115, 116, 114, 111, 107, 101, 45, 100, 97, 115, 104, 97, 114, 114, 97, 121, 58, 110, 111, 110, 101, 59, 115, 116, 114, 111, 107, 101, 45, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 112, 97, 105, 110, 116, 45, 111, 114, 100, 101, 114, 58, 115, 116, 114, 111, 107, 101, 32, 102, 105, 108, 108, 32, 109, 97, 114, 107, 101, 114, 115, 34, 10, 32, 32, 32, 32, 32, 32, 32, 105, 100, 61, 34, 114, 101, 99, 116, 57, 48, 53, 45, 54, 34, 10, 32, 32, 32, 32, 32, 32, 32, 119, 105, 100, 116, 104, 61, 34, 57, 48, 34, 10, 32, 32, 32, 32, 32, 32, 32, 104, 101, 105, 103, 104, 116, 61, 34, 49, 48, 34, 10, 32, 32, 32, 32, 32, 32, 32, 120, 61, 34, 50, 48, 34, 10, 32, 32, 32, 32, 32, 32, 32, 121, 61, 34, 49, 57, 55, 34, 32, 47, 62, 10, 32, 32, 32, 32, 60, 114, 101, 99, 116, 10, 32, 32, 32, 32, 32, 32, 32, 115, 116, 121, 108, 101, 61, 34, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 102, 105, 108, 108, 58, 35, 98, 100, 98, 100, 98, 100, 59, 102, 105, 108, 108, 45, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 115, 116, 114, 111, 107, 101, 58, 35, 98, 100, 98, 100, 98, 100, 59, 115, 116, 114, 111, 107, 101, 45, 119, 105, 100, 116, 104, 58, 48, 59, 115, 116, 114, 111, 107, 101, 45, 108, 105, 110, 101, 99, 97, 112, 58, 114, 111, 117, 110, 100, 59, 115, 116, 114, 111, 107, 101, 45, 108, 105, 110, 101, 106, 111, 105, 110, 58, 114, 111, 117, 110, 100, 59, 115, 116, 114, 111, 107, 101, 45, 109, 105, 116, 101, 114, 108, 105, 109, 105, 116, 58, 52, 59, 115, 116, 114, 111, 107, 101, 45, 100, 97, 115, 104, 97, 114, 114, 97, 121, 58, 110, 111, 110, 101, 59, 115, 116, 114, 111, 107, 101, 45, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 112, 97, 105, 110, 116, 45, 111, 114, 100, 101, 114, 58, 115, 116, 114, 111, 107, 101, 32, 102, 105, 108, 108, 32, 109, 97, 114, 107, 101, 114, 115, 34, 10, 32, 32, 32, 32, 32, 32, 32, 105, 100, 61, 34, 114, 101, 99, 116, 57, 48, 53, 45, 54, 45, 55, 34, 10, 32, 32, 32, 32, 32, 32, 32, 119, 105, 100, 116, 104, 61, 34, 57, 48, 34, 10, 32, 32, 32, 32, 32, 32, 32, 104, 101, 105, 103, 104, 116, 61, 34, 49, 48, 34, 10, 32, 32, 32, 32, 32, 32, 32, 120, 61, 34, 50, 48, 34, 10, 32, 32, 32, 32, 32, 32, 32, 121, 61, 34, 50, 56, 55, 34, 32, 47, 62, 10, 32, 32, 32, 32, 60, 112, 97, 116, 104, 10, 32, 32, 32, 32, 32, 32, 32, 115, 116, 121, 108, 101, 61, 34, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 102, 105, 108, 108, 58, 35, 54, 52, 54, 54, 55, 54, 59, 102, 105, 108, 108, 45, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 115, 116, 114, 111, 107, 101, 58, 35, 54, 52, 54, 54, 55, 54, 59, 115, 116, 114, 111, 107, 101, 45, 119, 105, 100, 116, 104, 58, 48, 59, 115, 116, 114, 111, 107, 101, 45, 108, 105, 110, 101, 99, 97, 112, 58, 114, 111, 117, 110, 100, 59, 115, 116, 114, 111, 107, 101, 45, 108, 105, 110, 101, 106, 111, 105, 110, 58, 114, 111, 117, 110, 100, 59, 115, 116, 114, 111, 107, 101, 45, 109, 105, 116, 101, 114, 108, 105, 109, 105, 116, 58, 52, 59, 115, 116, 114, 111, 107, 101, 45, 100, 97, 115, 104, 97, 114, 114, 97, 121, 58, 110, 111, 110, 101, 59, 115, 116, 114, 111, 107, 101, 45, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 112, 97, 105, 110, 116, 45, 111, 114, 100, 101, 114, 58, 115, 116, 114, 111, 107, 101, 32, 102, 105, 108, 108, 32, 109, 97, 114, 107, 101, 114, 115, 34, 10, 32, 32, 32, 32, 32, 32, 32, 100, 61, 34, 109, 32, 50, 54, 46, 52, 53, 55, 48, 51, 49, 44, 55, 46, 53, 53, 56, 53, 57, 51, 56, 32, 99, 32, 45, 57, 46, 52, 52, 56, 56, 49, 57, 44, 48, 32, 45, 49, 56, 46, 56, 57, 56, 52, 51, 55, 50, 44, 57, 46, 52, 52, 57, 54, 49, 56, 50, 32, 45, 49, 56, 46, 56, 57, 56, 52, 51, 55, 50, 44, 49, 56, 46, 56, 57, 56, 52, 51, 55, 50, 32, 86, 32, 51, 53, 49, 46, 52, 57, 54, 48, 57, 32, 99, 32, 45, 49, 48, 101, 45, 56, 44, 57, 46, 52, 52, 56, 56, 50, 32, 56, 46, 53, 48, 52, 55, 51, 54, 50, 44, 49, 56, 46, 56, 57, 56, 52, 52, 32, 49, 56, 46, 56, 57, 56, 52, 51, 55, 50, 44, 49, 56, 46, 56, 57, 56, 52, 52, 32, 72, 32, 51, 57, 56, 46, 55, 52, 48, 50, 51, 32, 99, 32, 53, 54, 46, 54, 57, 50, 57, 50, 44, 48, 32, 56, 53, 46, 48, 51, 57, 48, 55, 44, 45, 50, 56, 46, 51, 52, 56, 49, 32, 56, 53, 46, 48, 51, 57, 48, 55, 44, 45, 56, 53, 46, 48, 52, 49, 48, 49, 32, 86, 32, 50, 54, 46, 52, 53, 55, 48, 51, 49, 32, 99, 32, 48, 44, 45, 57, 46, 52, 52, 56, 56, 49, 57, 32, 45, 57, 46, 52, 52, 55, 54, 55, 44, 45, 49, 56, 46, 56, 57, 56, 52, 51, 55, 50, 32, 45, 49, 56, 46, 56, 57, 54, 52, 57, 44, 45, 49, 56, 46, 56, 57, 56, 52, 51, 55, 50, 32, 122, 32, 77, 32, 57, 52, 46, 50, 56, 53, 49, 53, 54, 44, 53, 49, 32, 72, 32, 51, 57, 54, 46, 54, 52, 56, 52, 52, 32, 86, 32, 51, 50, 56, 32, 72, 32, 57, 52, 46, 50, 56, 53, 49, 53, 54, 32, 90, 34, 10, 32, 32, 32, 32, 32, 32, 32, 116, 114, 97, 110, 115, 102, 111, 114, 109, 61, 34, 109, 97, 116, 114, 105, 120, 40, 48, 46, 50, 54, 52, 53, 56, 51, 51, 51, 44, 48, 44, 48, 44, 48, 46, 50, 54, 52, 53, 56, 51, 51, 51, 44, 48, 44, 49, 57, 55, 41, 34, 10, 32, 32, 32, 32, 32, 32, 32, 105, 100, 61, 34, 114, 101, 99, 116, 56, 56, 48, 34, 32, 47, 62, 10, 32, 32, 32, 32, 60, 99, 105, 114, 99, 108, 101, 10, 32, 32, 32, 32, 32, 32, 32, 115, 116, 121, 108, 101, 61, 34, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 102, 105, 108, 108, 58, 35, 100, 57, 49, 48, 49, 48, 59, 102, 105, 108, 108, 45, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 115, 116, 114, 111, 107, 101, 58, 35, 100, 57, 49, 48, 49, 48, 59, 115, 116, 114, 111, 107, 101, 45, 119, 105, 100, 116, 104, 58, 48, 59, 115, 116, 114, 111, 107, 101, 45, 108, 105, 110, 101, 99, 97, 112, 58, 114, 111, 117, 110, 100, 59, 115, 116, 114, 111, 107, 101, 45, 108, 105, 110, 101, 106, 111, 105, 110, 58, 114, 111, 117, 110, 100, 59, 115, 116, 114, 111, 107, 101, 45, 109, 105, 116, 101, 114, 108, 105, 109, 105, 116, 58, 52, 59, 115, 116, 114, 111, 107, 101, 45, 100, 97, 115, 104, 97, 114, 114, 97, 121, 58, 110, 111, 110, 101, 59, 115, 116, 114, 111, 107, 101, 45, 111, 112, 97, 99, 105, 116, 121, 58, 49, 59, 112, 97, 105, 110, 116, 45, 111, 114, 100, 101, 114, 58, 115, 116, 114, 111, 107, 101, 32, 102, 105, 108, 108, 32, 109, 97, 114, 107, 101, 114, 115, 34, 10, 32, 32, 32, 32, 32, 32, 32, 105, 100, 61, 34, 112, 97, 116, 104, 57, 52, 55, 34, 10, 32, 32, 32, 32, 32, 32, 32, 99, 120, 61, 34, 49, 49, 46, 50, 53, 34, 10, 32, 32, 32, 32, 32, 32, 32, 99, 121, 61, 34, 50, 51, 53, 46, 53, 34, 10, 32, 32, 32, 32, 32, 32, 32, 114, 61, 34, 50, 34, 32, 47, 62, 10, 32, 32, 60, 47, 103, 62, 10, 60, 47, 115, 118, 103, 62, 10}} |
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,168 @@ | ||
package fyne | ||
|
||
import ( | ||
"fmt" | ||
"image" | ||
"log" | ||
"os" | ||
|
||
"fyne.io/fyne" | ||
"fyne.io/fyne/app" | ||
"fyne.io/fyne/canvas" | ||
"fyne.io/fyne/driver/desktop" | ||
|
||
"github.com/HFO4/gbc-in-cloud/util" | ||
) | ||
|
||
type LCD struct { | ||
pixels *[160][144][3]uint8 | ||
screen *image.RGBA | ||
|
||
frame, output fyne.CanvasObject | ||
|
||
inputStatus *byte | ||
interrupt bool | ||
title string | ||
} | ||
|
||
func (lcd *LCD) Init(pixels *[160][144][3]uint8, title string) { | ||
lcd.pixels = pixels | ||
lcd.title = title | ||
log.Println("[Display] Initialize Fyne GUI display") | ||
} | ||
|
||
func (lcd *LCD) InitStatus(statusPointer *byte) { | ||
lcd.inputStatus = statusPointer | ||
} | ||
|
||
func (lcd *LCD) UpdateInput() bool { | ||
if lcd.interrupt { | ||
lcd.interrupt = false | ||
|
||
return true | ||
} | ||
|
||
return false | ||
} | ||
|
||
func (lcd *LCD) NewInput(b []byte) { | ||
} | ||
|
||
func (lcd *LCD) draw(w, h int) image.Image { | ||
i := 0 | ||
for y := 0; y < 144; y++ { | ||
for x := 0; x < 160; x++ { | ||
r, g, b := lcd.pixels[x][y][0], lcd.pixels[x][y][1], lcd.pixels[x][y][2] | ||
|
||
if r == 0xFF && g == 0xFF && b == 0xFF { | ||
lcd.screen.Pix[i] = 0x9b | ||
lcd.screen.Pix[i+1] = 0xbc | ||
lcd.screen.Pix[i+2] = 0x0f | ||
} else if r == 0xCC && g == 0xCC && b == 0xCC { | ||
lcd.screen.Pix[i] = 0x8b | ||
lcd.screen.Pix[i+1] = 0xac | ||
lcd.screen.Pix[i+2] = 0x0f | ||
} else if r == 0x77 && g == 0x77 && b == 0x77 { | ||
lcd.screen.Pix[i] = 0x30 | ||
lcd.screen.Pix[i+1] = 0x62 | ||
lcd.screen.Pix[i+2] = 0x30 | ||
} else { | ||
lcd.screen.Pix[i] = 0x0f | ||
lcd.screen.Pix[i+1] = 0x38 | ||
lcd.screen.Pix[i+2] = 0x0f | ||
} | ||
lcd.screen.Pix[i+3] = 0xff | ||
|
||
i += 4 | ||
} | ||
} | ||
|
||
return lcd.screen | ||
} | ||
|
||
// Mapping from keys to GB index. | ||
// Reference :https://github.com/Humpheh/goboy/blob/master/pkg/gbio/iopixel/pixels.go | ||
var keyMap = map[fyne.KeyName]byte{ | ||
// A button | ||
fyne.KeyZ: 5, | ||
// B button | ||
fyne.KeyX: 4, | ||
// SELECT button | ||
fyne.KeyBackspace: 6, | ||
// START button | ||
fyne.KeyReturn: 7, | ||
// RIGHT button | ||
fyne.KeyRight: 0, | ||
// LEFT button | ||
fyne.KeyLeft: 1, | ||
// UP button | ||
fyne.KeyUp: 2, | ||
// DOWN button | ||
fyne.KeyDown: 3, | ||
} | ||
|
||
func (lcd *LCD) buttonDown(ev *fyne.KeyEvent) { | ||
|
||
var statusCopy byte | ||
statusCopy = *lcd.inputStatus | ||
if offset, ok := keyMap[ev.Name]; ok { | ||
statusCopy = util.ClearBit(statusCopy, uint(offset)) | ||
lcd.interrupt = true | ||
} | ||
|
||
*lcd.inputStatus = statusCopy | ||
} | ||
|
||
func (lcd *LCD) buttonUp(ev *fyne.KeyEvent) { | ||
|
||
var statusCopy byte | ||
statusCopy = *lcd.inputStatus | ||
if offset, ok := keyMap[ev.Name]; ok { | ||
statusCopy = util.SetBit(statusCopy, uint(offset)) | ||
lcd.interrupt = true | ||
} | ||
|
||
*lcd.inputStatus = statusCopy | ||
} | ||
|
||
func (lcd *LCD) MinSize([]fyne.CanvasObject) fyne.Size { | ||
return fyne.NewSize(520, 400) | ||
} | ||
|
||
func (lcd *LCD) Layout(_ []fyne.CanvasObject, size fyne.Size) { | ||
lcd.frame.Resize(size) | ||
|
||
xScale := float32(size.Width) / 520.0 | ||
yScale := float32(size.Height) / 400.0 | ||
|
||
lcd.output.Resize(fyne.NewSize(int(320*xScale), int(296*yScale))) | ||
lcd.output.Move(fyne.NewPos(int(100*xScale), int(54*yScale))) | ||
} | ||
|
||
func (lcd *LCD) Run(drawSignal chan bool) { | ||
a := app.New() | ||
win := a.NewWindow(fmt.Sprintf("GameBoy - %s", lcd.title)) | ||
|
||
lcd.screen = image.NewRGBA(image.Rect(0, 0, 160, 144)) | ||
lcd.output = canvas.NewRaster(lcd.draw) | ||
go func() { | ||
for { | ||
// drawSignal was sent by the emulator | ||
<-drawSignal | ||
|
||
canvas.Refresh(lcd.output) | ||
} | ||
}() | ||
|
||
lcd.frame = canvas.NewImageFromResource(resourceFrameSvg) | ||
content := fyne.NewContainerWithLayout(lcd, lcd.output, lcd.frame) | ||
|
||
win.SetPadded(false) | ||
win.SetContent(content) | ||
win.Canvas().(desktop.Canvas).SetOnKeyDown(lcd.buttonDown) | ||
win.Canvas().(desktop.Canvas).SetOnKeyUp(lcd.buttonUp) | ||
win.SetOnClosed(func() { | ||
os.Exit(0) | ||
}) | ||
win.ShowAndRun() | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,5 @@ | ||
#!/bin/sh | ||
|
||
cd `dirname $0` | ||
fyne bundle -package fyne frame.svg > bunded.go | ||
|
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