modal

package
v0.0.0-...-79996cc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package modal provides UI pop-up modals for Doodle.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Draw

func Draw()

Draw the modal UI to the screen.

func Handled

func Handled(ev *event.State) bool

Handled runs the modal manager's logic. Returns true if a modal is presently active, to signal to Doodle not to run game logic.

This function also returns true if the pkg/modal/loadscreen is currently active.

func Initialize

func Initialize(e render.Engine)

Initialize the modal package.

func Reset

func Reset()

Reset the modal state (closing all modals).

Types

type ConfigEndLevel

type ConfigEndLevel struct {
	Engine  render.Engine
	Success bool // false = failure condition

	// Handler functions - what you don't define will not
	// show as buttons in the modal. Buttons display priority
	// is as follows these docs in the source code.
	OnNextLevel       func() // Next Level (victory window)
	OnRetryCheckpoint func() // Retry from Checkpoint (failed)
	OnPityNextLevel   func() // Pity "Next Level" (Azulian Tag)
	OnRestartLevel    func() // Restart Level
	OnEditLevel       func() // Edit Level (if came from editor)
	OnExitToMenu      func() // Exit to Menu

	// Set these values to show the "New Record!" part of the modal.
	NewRecord   bool
	IsPerfect   bool
	TimeElapsed time.Duration
}

ConfigEndLevel sets options for the EndLevel modal.

type Modal struct {
	// contains filtered or unexported fields
}

Modal is an instance of a modal, i.e. Alert or Confirm.

func Alert

func Alert(message string, args ...interface{}) *Modal

Alert pops up an alert box modal.

Example
package main

import (
	"fmt"

	modal "git.kirsle.net/SketchyMaze/doodle/pkg/modal"
)

func main() {
	alert := modal.Alert("Permission Denied").WithTitle("Error").Then(func() {
		fmt.Println("Alert button answered!")
	})

	_ = alert
}
Output:

func Confirm

func Confirm(message string, args ...interface{}) *Modal

Confirm pops up an Ok/Cancel modal.

func EndLevel

func EndLevel(cfg ConfigEndLevel, title, message string, args ...interface{}) *Modal

EndLevel shows the End Level modal.

func Wait

func Wait(message string, args ...interface{}) *Modal

Wait pops up a non-dismissable modal that the caller can close when they're ready.

func (*Modal) Dismiss

func (m *Modal) Dismiss(call bool)

Dismiss the modal and optionally call the callback function.

func (*Modal) Then

func (m *Modal) Then(f func()) *Modal

Then calls a function after the modal is answered.

func (*Modal) WithTitle

func (m *Modal) WithTitle(title string) *Modal

WithTitle sets the title of the modal.

Directories

Path Synopsis
Package loadscreen implements a modal "Loading" screen for the game, which can be shown or hidden by gameplay scenes as needed.
Package loadscreen implements a modal "Loading" screen for the game, which can be shown or hidden by gameplay scenes as needed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL