本文整理匯總了Golang中github.com/remogatto/gospeccy/src/spectrum.Application.RequestExit方法的典型用法代碼示例。如果您正苦於以下問題:Golang Application.RequestExit方法的具體用法?Golang Application.RequestExit怎麽用?Golang Application.RequestExit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/remogatto/gospeccy/src/spectrum.Application
的用法示例。
在下文中一共展示了Application.RequestExit方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newSDLSurface
func newSDLSurface(app *spectrum.Application, w, h int) *SDLSurface {
surface := sdl.CreateRGBSurface(sdl.SWSURFACE, w, h, 32, 0, 0, 0, 0)
if surface == nil {
app.PrintfMsg("%s", sdl.GetError())
app.RequestExit()
return nil
}
return &SDLSurface{surface}
}
示例2: Main
func Main() {
var init_waitGroup *sync.WaitGroup
init_waitGroup = env.WaitName("init WaitGroup").(*sync.WaitGroup)
init_waitGroup.Add(1)
var app *spectrum.Application
app = env.Wait(reflect.TypeOf(app)).(*spectrum.Application)
var speccy *spectrum.Spectrum48k
speccy = env.Wait(reflect.TypeOf(speccy)).(*spectrum.Spectrum48k)
if !*enableSDL {
return
}
uiSettings = &InitialSettings{
scale2x: Scale2x,
fullscreen: Fullscreen,
showPaintedRegions: ShowPaintedRegions,
audio: Audio,
audioFreq: AudioFreq,
hqAudio: HQAudio,
}
composer = NewSDLSurfaceComposer(app)
composer.ShowPaintedRegions(*ShowPaintedRegions)
// SDL subsystems init
if err := initSDLSubSystems(app); err != nil {
app.PrintfMsg("%s", err)
app.RequestExit()
return
}
// Setup the display
r = NewSDLRenderer(app, speccy, *Scale2x, *Fullscreen, *Audio, *HQAudio, *AudioFreq)
setUI(r)
initCLI()
// Setup the audio
if *Audio {
audio, err := NewSDLAudio(app, *AudioFreq, *HQAudio)
if err == nil {
speccy.CommandChannel <- spectrum.Cmd_AddAudioReceiver{audio}
} else {
app.PrintfMsg("%s", err)
}
}
// Start the SDL event loop
go sdlEventLoop(app, speccy, *verboseInput)
init_waitGroup.Done()
hint := "Hint: Press F10 to invoke the built-in console.\n"
hint += " Input an empty line in the console to display available commands.\n"
fmt.Print(hint)
// Wait for all event loops to terminate, and then call 'sdl.Quit()'
shutdown.Wait()
if r.app.Verbose {
r.app.PrintfMsg("SDL: sdl.Quit()")
}
sdl.Quit()
}
示例3: sdlEventLoop
// A Go routine for processing SDL events.
func sdlEventLoop(app *spectrum.Application, speccy *spectrum.Spectrum48k, verboseInput bool) {
evtLoop := app.NewEventLoop()
consoleIsVisible := false
shutdown.Add(1)
for {
select {
case <-evtLoop.Pause:
evtLoop.Pause <- 0
case <-evtLoop.Terminate:
// Terminate this Go routine
if app.Verbose {
app.PrintfMsg("SDL event loop: exit")
}
evtLoop.Terminate <- 0
shutdown.Done()
return
case event := <-sdl.Events:
switch e := event.(type) {
case sdl.QuitEvent:
if app.Verbose {
app.PrintfMsg("SDL quit -> request[exit the application]")
}
app.RequestExit()
case sdl.JoyAxisEvent:
if verboseInput {
app.PrintfMsg("[Joystick] Axis: %d, Value: %d", e.Axis, e.Value)
}
if e.Axis == 0 {
if e.Value > 0 {
speccy.Joystick.KempstonDown(spectrum.KEMPSTON_RIGHT)
} else if e.Value < 0 {
speccy.Joystick.KempstonDown(spectrum.KEMPSTON_LEFT)
} else {
speccy.Joystick.KempstonUp(spectrum.KEMPSTON_RIGHT)
speccy.Joystick.KempstonUp(spectrum.KEMPSTON_LEFT)
}
} else if e.Axis == 1 {
if e.Value > 0 {
speccy.Joystick.KempstonDown(spectrum.KEMPSTON_UP)
} else if e.Value < 0 {
speccy.Joystick.KempstonDown(spectrum.KEMPSTON_DOWN)
} else {
speccy.Joystick.KempstonUp(spectrum.KEMPSTON_UP)
speccy.Joystick.KempstonUp(spectrum.KEMPSTON_DOWN)
}
}
case sdl.JoyButtonEvent:
if verboseInput {
app.PrintfMsg("[Joystick] Button: %d, State: %d", e.Button, e.State)
}
if e.Button == 0 {
if e.State > 0 {
speccy.Joystick.KempstonDown(spectrum.KEMPSTON_FIRE)
} else {
speccy.Joystick.KempstonUp(spectrum.KEMPSTON_FIRE)
}
}
case sdl.KeyboardEvent:
keyName := sdl.GetKeyName(sdl.Key(e.Keysym.Sym))
if verboseInput {
app.PrintfMsg("\n")
app.PrintfMsg("%v: %v", e.Keysym.Sym, keyName)
app.PrintfMsg("Type: %02x Which: %02x State: %02x\n", e.Type, e.Which, e.State)
app.PrintfMsg("Scancode: %02x Sym: %08x Mod: %04x Unicode: %04x\n", e.Keysym.Scancode, e.Keysym.Sym, e.Keysym.Mod, e.Keysym.Unicode)
}
if (keyName == "escape") && (e.Type == sdl.KEYDOWN) {
if app.Verbose {
app.PrintfMsg("escape key -> request[exit the application]")
}
app.RequestExit()
} else if (keyName == "f10") && (e.Type == sdl.KEYDOWN) {
//if app.Verbose {
// app.PrintfMsg("f10 key -> toggle console")
//}
if !r.toggling {
r.toggling = true
if r.cliSurface_orNil == nil {
done := make(chan bool)
r.cliSurfaceCh <- cmd_newCliSurface{newCLISurface(r.scale2x, r.fullscreen), done}
<-done
}
anim := clingon.NewSliderAnimation(0.500, 1.0)
var targetState int
if consoleIsVisible {
targetState = HIDE
} else {
//.........這裏部分代碼省略.........