mirror of
https://github.com/Fluffy-Bean/ColouringApp.git
synced 2025-02-17 23:50:05 +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 {
|
func NewCanvas(name string, size, offset raylib.Vector2, background raylib.Texture2D) *Canvas {
|
||||||
return &Canvas{
|
return &Canvas{
|
||||||
Name: name,
|
Name: name,
|
||||||
Size: size,
|
Size: size,
|
||||||
Offset: offset,
|
Offset: offset,
|
||||||
Target: raylib.LoadRenderTexture(int32(size.X), int32(size.Y)),
|
Target: raylib.LoadRenderTexture(int32(size.X), int32(size.Y)),
|
||||||
Background: background,
|
Background: background,
|
||||||
Strokes: []raylib.Texture2D{},
|
Strokes: []raylib.Texture2D{},
|
||||||
UndoneStrokes: []raylib.Texture2D{},
|
UndoneStrokes: []raylib.Texture2D{},
|
||||||
Refresh: true,
|
UnsavedChanges: false,
|
||||||
|
Refresh: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
main.go
17
main.go
|
@ -43,11 +43,7 @@ func main() {
|
||||||
for !applicationShouldQuit {
|
for !applicationShouldQuit {
|
||||||
// Update default loop values
|
// Update default loop values
|
||||||
if raylib.WindowShouldClose() {
|
if raylib.WindowShouldClose() {
|
||||||
if canvas.UnsavedChanges {
|
applicationState = StateWindowWantsToDie
|
||||||
applicationState = StateWindowWantsToDie
|
|
||||||
} else {
|
|
||||||
applicationShouldQuit = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if raylib.IsWindowResized() {
|
if raylib.IsWindowResized() {
|
||||||
applicationWindowWidth = int32(raylib.GetScreenWidth())
|
applicationWindowWidth = int32(raylib.GetScreenWidth())
|
||||||
|
@ -287,7 +283,6 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
raylib.EndScissorMode()
|
raylib.EndScissorMode()
|
||||||
case StateNewCanvas:
|
case StateNewCanvas:
|
||||||
if !canvas.UnsavedChanges {
|
if !canvas.UnsavedChanges {
|
||||||
|
@ -311,6 +306,16 @@ func main() {
|
||||||
AddToast("Created New Canvas: " + canvas.Name)
|
AddToast("Created New Canvas: " + canvas.Name)
|
||||||
}
|
}
|
||||||
case StateWindowWantsToDie:
|
case StateWindowWantsToDie:
|
||||||
|
if !canvas.UnsavedChanges {
|
||||||
|
applicationShouldQuit = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if !canvas.UnsavedChanges {
|
||||||
|
applicationState = StateNormal
|
||||||
|
shouldCreateNewCanvas = true
|
||||||
|
AddToast("Created New Canvas: " + canvas.Name)
|
||||||
|
break
|
||||||
|
}
|
||||||
gui.Unlock()
|
gui.Unlock()
|
||||||
raylib.DrawRectangle(0, 0, applicationWindowWidth, applicationWindowHeight, raylib.Fade(raylib.Black, 0.5))
|
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)
|
windowPos := raylib.NewRectangle(float32((applicationWindowWidth/2)-200), float32((applicationWindowHeight/2)-75), 400, 150)
|
||||||
|
|
Loading…
Reference in a new issue