File tree Expand file tree Collapse file tree
experimental/fasthtml/gpu_puzzles Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ const State = {
1111 wgslStatus : "" ,
1212} ;
1313
14+ codeState = [ ] ;
15+
1416const PuzzleSpec = [
1517 {
1618 name : "Map" ,
@@ -234,8 +236,15 @@ async function updateEditor() {
234236 }
235237}
236238
237- function update ( event ) {
239+ async function update ( event ) {
240+
241+ if ( ! AppState . isDispatchReady ) {
242+ await waitForDispatchReady ( ) ;
243+ }
238244 console . log ( "Updating" ) ;
245+ if ( event . type == "selectPuzzle" ) {
246+ codeState [ AppState . puzzleIndex ] = AppState . editor . getValue ( ) ;
247+ }
239248 if ( ( event . type === "selectPuzzle" ) & ( event . value === "prev" ) ) {
240249 AppState . puzzleIndex = AppState . puzzleIndex - 1 ;
241250 if ( AppState . puzzleIndex < 0 ) {
@@ -257,7 +266,11 @@ function update(event) {
257266 if ( event . type === "init" || event . type === "selectPuzzle" ) {
258267 // Reset editor template code if we are either starting the app for the
259268 // first time or picking a new puzzle
260- AppState . editor . setValue ( AppState . module . getTemplate ( AppState . puzzleIndex ) ) ;
269+ if ( codeState [ AppState . puzzleIndex ] ) {
270+ AppState . editor . setValue ( codeState [ AppState . puzzleIndex ] ) ;
271+ } else {
272+ AppState . editor . setValue ( AppState . module . getTemplate ( AppState . puzzleIndex ) ) ;
273+ }
261274 }
262275
263276 updateEditor ( ) ;
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ def controls():
3333 Div (
3434 "Puzzle 1: Map" ,
3535 id = "puzzle_name" ,
36- style = "font-size: 1.5rem; width: 15vw ; font-weight: bold;"
36+ style = "font-size: 1.5rem; width: 25vw ; font-weight: bold;"
3737 ),
3838 Button (
3939 ">>" ,
You can’t perform that action at this time.
0 commit comments