mirror of
https://github.com/Fluffy-Bean/ColouringApp.git
synced 2025-01-29 15:48:27 +00:00
Check if user wants to quit app 2
This commit is contained in:
parent
3740187ee2
commit
51a6bf959c
17
canvas.go
17
canvas.go
|
@ -121,14 +121,15 @@ func (c *Canvas) Save() {
|
|||
|
||||
func NewCanvas(name string, size, offset raylib.Vector2, background raylib.Texture2D) *Canvas {
|
||||
return &Canvas{
|
||||
Name: name,
|
||||
Size: size,
|
||||
Offset: offset,
|
||||
Target: raylib.LoadRenderTexture(int32(size.X), int32(size.Y)),
|
||||
Background: background,
|
||||
Strokes: []raylib.Texture2D{},
|
||||
UndoneStrokes: []raylib.Texture2D{},
|
||||
Refresh: true,
|
||||
Name: name,
|
||||
Size: size,
|
||||
Offset: offset,
|
||||
Target: raylib.LoadRenderTexture(int32(size.X), int32(size.Y)),
|
||||
Background: background,
|
||||
Strokes: []raylib.Texture2D{},
|
||||
UndoneStrokes: []raylib.Texture2D{},
|
||||
UnsavedChanges: false,
|
||||
Refresh: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
17
main.go
17
main.go
|
@ -43,11 +43,7 @@ func main() {
|
|||
for !applicationShouldQuit {
|
||||
// Update default loop values
|
||||
if raylib.WindowShouldClose() {
|
||||
if canvas.UnsavedChanges {
|
||||
applicationState = StateWindowWantsToDie
|
||||
} else {
|
||||
applicationShouldQuit = true
|
||||
}
|
||||
applicationState = StateWindowWantsToDie
|
||||
}
|
||||
if raylib.IsWindowResized() {
|
||||
applicationWindowWidth = int32(raylib.GetScreenWidth())
|
||||
|
@ -287,7 +283,6 @@ func main() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
raylib.EndScissorMode()
|
||||
case StateNewCanvas:
|
||||
if !canvas.UnsavedChanges {
|
||||
|
@ -311,6 +306,16 @@ func main() {
|
|||
AddToast("Created New Canvas: " + canvas.Name)
|
||||
}
|
||||
case StateWindowWantsToDie:
|
||||
if !canvas.UnsavedChanges {
|
||||
applicationShouldQuit = true
|
||||
break
|
||||
}
|
||||
if !canvas.UnsavedChanges {
|
||||
applicationState = StateNormal
|
||||
shouldCreateNewCanvas = true
|
||||
AddToast("Created New Canvas: " + canvas.Name)
|
||||
break
|
||||
}
|
||||
gui.Unlock()
|
||||
raylib.DrawRectangle(0, 0, applicationWindowWidth, applicationWindowHeight, raylib.Fade(raylib.Black, 0.5))
|
||||
windowPos := raylib.NewRectangle(float32((applicationWindowWidth/2)-200), float32((applicationWindowHeight/2)-75), 400, 150)
|
||||
|
|
Loading…
Reference in a new issue