@@ -64,6 +64,7 @@ class OnboardingLayerViewController: NSViewController {
6464    @IBOutlet   weak var  skipButton :  NSButton ! 
6565
6666    var  layer :  Onboarding ! 
67+     var  emu :  EmulatorProxy !  {  layer. emu } 
6768
6869    private  var  pages :  [ NSViewController ]  =  [ ] 
6970    private  var  currentPageIndex :  Int  =  0  { 
@@ -77,10 +78,12 @@ class OnboardingLayerViewController: NSViewController {
7778
7879    override func  viewDidAppear( )  { 
7980
80-         func  instantiate( _ id:  String )  ->  NSViewController  { 
81+         func  instantiate( _ id:  String )  ->  OnboardingViewController  { 
8182
8283            let  storyboard  =  NSStoryboard ( name:  " Onboarding " ,  bundle:  nil ) 
83-             return  storyboard. instantiateController ( withIdentifier:  id)  as!  NSViewController 
84+             let  result  =  storyboard. instantiateController ( withIdentifier:  id)  as!  OnboardingViewController 
85+             result. layer =  layer
86+             return  result
8487        } 
8588
8689        // Start over by removing all child view controllers and their views
@@ -142,17 +145,26 @@ class OnboardingLayerViewController: NSViewController {
142145
143146        currentPageIndex =  index
144147        prevButton. isEnabled =  currentPageIndex >  0 
145-         nextButton. title =  currentPageIndex ==  pages. count -  1  ?  " Finish "  :  " Continue " 
148+         nextButton. title =  currentPageIndex ==  pages. count -  1  ?  " Launch "  :  " Continue " 
146149    } 
147150
148151    @IBAction   func  nextPage( _ sender:  Any ? )  { 
149152
150153        let  nextIndex  =  currentPageIndex +  1 
154+ 
151155        if  pages. indices. contains ( nextIndex)  { 
152156            showPage ( at:  nextIndex) 
157+         }  else  { 
158+             finish ( ) 
153159        } 
154160    } 
155161
162+     func  finish( )  { 
163+ 
164+         layer. close ( delay:  1.0 ) 
165+         try ? . run ( ) 
166+     } 
167+ 
156168    @IBAction   func  previousPage( _ sender:  Any ? )  { 
157169
158170        let  prevIndex  =  currentPageIndex -  1 
@@ -164,7 +176,7 @@ class OnboardingLayerViewController: NSViewController {
164176    @IBAction   func  skipAction( _ sender:  Any ? )  { 
165177
166178        print ( " skip " ) 
167-         layer! . close ( delay :   1.0 ) 
179+         finish ( ) 
168180    } 
169181} 
170182
@@ -226,10 +238,24 @@ class Onboarding: Layer {
226238} 
227239
228240@MainActor  
229- class  OnboardingViewController1 :  NSViewController  { 
241+ class  OnboardingViewController :  NSViewController  { 
242+ 
243+     var  layer :  Onboarding ! 
244+     var  config :  Configuration  {  layer. controller. config } 
245+ 
246+     override func  viewDidLoad( )  { 
247+ 
248+         print ( " View did load " ) 
249+         apply ( ) 
250+     } 
230251
231-     var  model =  0  {  didSet {  refresh ( )  }  } 
252+     func  apply( )  {  } 
253+ } 
232254
255+ @MainActor  
256+ class  OnboardingViewController1 :  OnboardingViewController  { 
257+ 
258+     var  model =  0  {  didSet {  apply ( )  }  } 
233259    var  a500 :  Bool  {  model ==  0  } 
234260    var  a1000 :  Bool  {  model ==  1  } 
235261    var  a2000 :  Bool  {  model ==  2  } 
@@ -240,12 +266,13 @@ class OnboardingViewController1: NSViewController {
240266
241267    @IBAction   func  modelAction( _ sender:  NSControl )  { 
242268
243-         print ( " modelAction  \( sender. tag) " ) 
244269        model =  sender. tag
270+ 
245271    } 
246272
247-     override func  viewDidLoad ( )  { 
273+     override func  apply ( )  { 
248274
275+         config. revertTo ( model:  model) 
249276        refresh ( ) 
250277    } 
251278
@@ -260,9 +287,9 @@ class OnboardingViewController1: NSViewController {
260287} 
261288
262289@MainActor  
263- class  OnboardingViewController2 :  NSViewController  { 
290+ class  OnboardingViewController2 :  OnboardingViewController  { 
264291
265-     var  rom =  0  {  didSet {  refresh ( )  }  } 
292+     var  rom =  0  {  didSet {  apply ( )  }  } 
266293
267294    var  aros :  Bool  {  rom ==  0  } 
268295    var  diag :  Bool  {  rom ==  1  } 
@@ -274,9 +301,16 @@ class OnboardingViewController2: NSViewController {
274301
275302        print ( " romAction  \( sender. tag) " ) 
276303        rom =  sender. tag
304+ 
277305    } 
278306
279-     override func  viewDidLoad( )  { 
307+     override func  apply( )  { 
308+ 
309+         switch  rom { 
310+         case  0 :  layer. controller. installAros ( ) 
311+         case  1 :  layer. controller. installDiagRom ( ) 
312+         default :  fatalError ( ) 
313+         } 
280314
281315        refresh ( ) 
282316    } 
0 commit comments