Spit and polish
* On the failure (but still success) dialog on Survival Mode levels (e.g. Azulian Tag): make the default be to retry the level but show a "pity" Next Level button below, as the level is marked as completed (silver score) and the next one is unlocked.
This commit is contained in:
parent
ffc2c6f69b
commit
450c6b3bb2
|
@ -43,6 +43,7 @@ type Chunker struct {
|
||||||
requestsN1 map[render.Point]interface{} // chunks accessed last tick
|
requestsN1 map[render.Point]interface{} // chunks accessed last tick
|
||||||
requestsN2 map[render.Point]interface{} // 2 ticks ago (to free soon)
|
requestsN2 map[render.Point]interface{} // 2 ticks ago (to free soon)
|
||||||
chunksToFree map[render.Point]uint64 // chopping block (free after X ticks)
|
chunksToFree map[render.Point]uint64 // chopping block (free after X ticks)
|
||||||
|
ctfMu sync.Mutex // lock for chunksToFree
|
||||||
requestMu sync.Mutex
|
requestMu sync.Mutex
|
||||||
|
|
||||||
// The palette reference from first call to Inflate()
|
// The palette reference from first call to Inflate()
|
||||||
|
@ -299,6 +300,11 @@ func (c *Chunker) GetChunk(p render.Point) (*Chunk, bool) {
|
||||||
chunk, ok := c.Chunks[p]
|
chunk, ok := c.Chunks[p]
|
||||||
c.chunkMu.RUnlock()
|
c.chunkMu.RUnlock()
|
||||||
|
|
||||||
|
// Was it on the chopping block for garbage collection?
|
||||||
|
c.ctfMu.Lock()
|
||||||
|
delete(c.chunksToFree, p)
|
||||||
|
c.ctfMu.Unlock()
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
// An empty chunk? We hang onto these until save time to commit
|
// An empty chunk? We hang onto these until save time to commit
|
||||||
// the empty chunk to ZIP.
|
// the empty chunk to ZIP.
|
||||||
|
@ -392,6 +398,7 @@ func (c *Chunker) FreeCaches() int {
|
||||||
|
|
||||||
// Chunks requested 2 ticks ago but not this tick, put on the chopping
|
// Chunks requested 2 ticks ago but not this tick, put on the chopping
|
||||||
// block to free them later.
|
// block to free them later.
|
||||||
|
c.ctfMu.Lock()
|
||||||
for coord := range requestsN2 {
|
for coord := range requestsN2 {
|
||||||
// Old point not requested recently?
|
// Old point not requested recently?
|
||||||
if _, ok := requestsThisTick[coord]; !ok {
|
if _, ok := requestsThisTick[coord]; !ok {
|
||||||
|
@ -411,6 +418,7 @@ func (c *Chunker) FreeCaches() int {
|
||||||
delete(c.chunksToFree, coord)
|
delete(c.chunksToFree, coord)
|
||||||
c.FreeChunk(coord)
|
c.FreeChunk(coord)
|
||||||
}
|
}
|
||||||
|
c.ctfMu.Unlock()
|
||||||
|
|
||||||
// Rotate the cached ticks and clean the slate.
|
// Rotate the cached ticks and clean the slate.
|
||||||
c.requestsN2 = c.requestsN1
|
c.requestsN2 = c.requestsN1
|
||||||
|
|
|
@ -18,11 +18,13 @@ type ConfigEndLevel struct {
|
||||||
Success bool // false = failure condition
|
Success bool // false = failure condition
|
||||||
|
|
||||||
// Handler functions - what you don't define will not
|
// Handler functions - what you don't define will not
|
||||||
// show as buttons in the modal.
|
// 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
|
OnRestartLevel func() // Restart Level
|
||||||
OnRetryCheckpoint func() // Continue from checkpoint
|
OnEditLevel func() // Edit Level (if came from editor)
|
||||||
OnEditLevel func()
|
|
||||||
OnNextLevel func() // Next Level
|
|
||||||
OnExitToMenu func() // Exit to Menu
|
OnExitToMenu func() // Exit to Menu
|
||||||
|
|
||||||
// Set these values to show the "New Record!" part of the modal.
|
// Set these values to show the "New Record!" part of the modal.
|
||||||
|
@ -152,6 +154,10 @@ func makeEndLevel(m *Modal, cfg ConfigEndLevel) *ui.Window {
|
||||||
Label: "Restart Level",
|
Label: "Restart Level",
|
||||||
F: cfg.OnRestartLevel,
|
F: cfg.OnRestartLevel,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Label: "Next Level",
|
||||||
|
F: cfg.OnPityNextLevel,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Label: "Edit Level",
|
Label: "Edit Level",
|
||||||
F: cfg.OnEditLevel,
|
F: cfg.OnEditLevel,
|
||||||
|
|
|
@ -561,8 +561,8 @@ func (s *PlayScene) FailLevel(message string) {
|
||||||
|
|
||||||
if s.Level.GameRule.Survival {
|
if s.Level.GameRule.Survival {
|
||||||
s.ShowEndLevelModal(
|
s.ShowEndLevelModal(
|
||||||
true,
|
false,
|
||||||
"Level Completed",
|
"You've died!",
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"%s\nCongrats on surviving for %s!",
|
"%s\nCongrats on surviving for %s!",
|
||||||
message,
|
message,
|
||||||
|
@ -639,6 +639,15 @@ func (s *PlayScene) ShowEndLevelModal(success bool, title, message string) {
|
||||||
config.OnEditLevel = s.EditLevel
|
config.OnEditLevel = s.EditLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Survival Mode failure? The level is considered completed even if you
|
||||||
|
// die (silver high score) but the default button should be Retry rather
|
||||||
|
// than Next Level.
|
||||||
|
var survivalFailure bool
|
||||||
|
if !success && s.Level.GameRule.Survival {
|
||||||
|
survivalFailure = true
|
||||||
|
success = true // level is completed
|
||||||
|
}
|
||||||
|
|
||||||
// Beaten the level?
|
// Beaten the level?
|
||||||
if success {
|
if success {
|
||||||
config.OnRetryCheckpoint = nil
|
config.OnRetryCheckpoint = nil
|
||||||
|
@ -688,6 +697,14 @@ func (s *PlayScene) ShowEndLevelModal(success bool, title, message string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Survival Mode failures: the Retry buttons should be higher
|
||||||
|
// priority than Next Level but they still get the (pity)
|
||||||
|
// Next Level button.
|
||||||
|
if survivalFailure {
|
||||||
|
config.OnPityNextLevel = config.OnNextLevel
|
||||||
|
config.OnNextLevel = nil
|
||||||
|
}
|
||||||
|
|
||||||
// Show the modal.
|
// Show the modal.
|
||||||
modal.EndLevel(config, title, message)
|
modal.EndLevel(config, title, message)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user