clone

fifteen puzzle games for the terminal, with daily puzzles, weekly ladders and xp, built on bubble tea

chore/regenerate-vhs-gifs
puzzletea / app / screen_core.go
screen_core.go 4.0K
1package app23import tea "charm.land/bubbletea/v2"45type screenAction interface{ isScreenAction() }67type openPlayMenuAction struct{}89func (openPlayMenuAction) isScreenAction() {}1011type openStatsAction struct{}1213func (openStatsAction) isScreenAction() {}1415type openOptionsMenuAction struct{}1617func (openOptionsMenuAction) isScreenAction() {}1819type quitAction struct{}2021func (quitAction) isScreenAction() {}2223type openGameSelectAction struct{}2425func (openGameSelectAction) isScreenAction() {}2627type openContinueAction struct{}2829func (openContinueAction) isScreenAction() {}3031type openDailyAction struct{}3233func (openDailyAction) isScreenAction() {}3435type openWeeklyAction struct{}3637func (openWeeklyAction) isScreenAction() {}3839type openSeedInputAction struct{}4041func (openSeedInputAction) isScreenAction() {}4243type openExportAction struct{}4445func (openExportAction) isScreenAction() {}4647type backAction struct {48 target viewState49}5051func (backAction) isScreenAction() {}5253type gameSelectEnterAction struct{}5455func (gameSelectEnterAction) isScreenAction() {}5657type modeSelectEnterAction struct{}5859func (modeSelectEnterAction) isScreenAction() {}6061type continueEnterAction struct{}6263func (continueEnterAction) isScreenAction() {}6465type weeklyShiftAction struct {66 delta int67}6869func (weeklyShiftAction) isScreenAction() {}7071type weeklyEnterAction struct{}7273func (weeklyEnterAction) isScreenAction() {}7475type helpSelectEnterAction struct{}7677func (helpSelectEnterAction) isScreenAction() {}7879type openThemeSelectAction struct{}8081func (openThemeSelectAction) isScreenAction() {}8283type openHelpSelectAction struct{}8485func (openHelpSelectAction) isScreenAction() {}8687type previewThemeAction struct {88 name string89}9091func (previewThemeAction) isScreenAction() {}9293type confirmThemeAction struct{}9495func (confirmThemeAction) isScreenAction() {}9697type seedConfirmAction struct{}9899func (seedConfirmAction) isScreenAction() {}100101type exportSubmitAction struct{}102103func (exportSubmitAction) isScreenAction() {}104105type screenModel interface {106 State() viewState107 Resize(width, height int) screenModel108 Update(msg tea.Msg) (screenModel, tea.Cmd, screenAction)109 View(notice noticeState) string110 Apply(m model) model111}112113func (m model) activeScreen() screenModel {114 switch m.state {115 case mainMenuView:116 return mainMenuScreen{117 width: m.width,118 height: m.height,119 menu: m.nav.mainMenu,120 }121 case playMenuView:122 return playMenuScreen{123 width: m.width,124 height: m.height,125 menu: m.nav.playMenu,126 }127 case optionsMenuView:128 return optionsMenuScreen{129 width: m.width,130 height: m.height,131 menu: m.nav.optionsMenu,132 }133 case seedInputView:134 return seedInputScreen{135 width: m.width,136 height: m.height,137 seed: m.seed,138 }139 case gameSelectView:140 return gameSelectScreen{141 width: m.width,142 height: m.height,143 list: m.nav.gameSelectList,144 detail: m.nav.categoryDetail,145 }146 case modeSelectView:147 return modeSelectScreen{148 width: m.width,149 height: m.height,150 entry: m.nav.selectedCategory,151 list: m.nav.modeSelectList,152 }153 case exportView:154 return exportScreen{155 width: m.width,156 height: m.height,157 export: m.export,158 }159 case continueView:160 return continueScreen{161 width: m.width,162 height: m.height,163 cont: m.cont,164 }165 case weeklyView:166 return weeklyScreen{167 width: m.width,168 height: m.height,169 weekly: m.weekly,170 }171 case helpSelectView:172 return helpSelectScreen{173 width: m.width,174 height: m.height,175 help: m.help,176 }177 case helpDetailView:178 return helpDetailScreen{179 width: m.width,180 height: m.height,181 help: m.help,182 }183 case statsView:184 return statsScreen{185 width: m.width,186 height: m.height,187 stats: m.stats,188 }189 case themeSelectView:190 return themeSelectScreen{191 width: m.width,192 height: m.height,193 theme: m.theme,194 }195 case generatingView:196 return generatingScreen{197 width: m.width,198 height: m.height,199 spinner: m.spinner,200 }201 case exportRunningView:202 return exportRunningScreen{203 width: m.width,204 height: m.height,205 spinner: m.spinner,206 }207 default:208 return nil209 }210}