Skip to content

Commit a54a57d

Browse files
committed
Work on onboarding
1 parent ad4f512 commit a54a57d

File tree

14 files changed

+113
-73
lines changed

14 files changed

+113
-73
lines changed

GUI/Metal/Layers/Canvas.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ class Canvas: Layer {
359359
}
360360

361361
func render(_ encoder: MTLRenderCommandEncoder) {
362+
363+
if !shouldRender { return }
362364

363365
// Configure the vertex shader
364366
encoder.setVertexBytes(&vertexUniforms2D,

GUI/Metal/Layers/Layer.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class Layer: NSObject {
2222
// Alpha channel of this layer
2323
var alpha: AnimatedFloat = AnimatedFloat(0.0)
2424

25+
// Indicates if this layer should be rendered
26+
var shouldRender = true
27+
2528
//
2629
// Initializing
2730
//

GUI/Metal/Layers/Onboarding.swift

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -53,41 +53,14 @@ class OnboardingLayerView: NSView {
5353
@MainActor
5454
class OnboardingPageContainerView: NSView {
5555

56-
/*
57-
private var bgLayer: CALayer?
58-
59-
override func viewDidMoveToWindow() {
60-
61-
super.viewDidMoveToWindow()
62-
wantsLayer = true
63-
64-
if let layer = self.layer, bgLayer == nil {
65-
66-
let background = CALayer()
67-
background.contents = NSImage(named: "vAmigaBg")
68-
background.contentsGravity = .resizeAspectFill
69-
background.autoresizingMask = [.layerWidthSizable, .layerHeightSizable]
70-
layer.insertSublayer(background, at: 0)
71-
bgLayer = background
72-
}
73-
}
74-
75-
override func layout() {
76-
77-
super.layout()
78-
bgLayer?.frame = CGRect(x: 0, y: 0,
79-
width: bounds.width,
80-
height: bounds.height - 32)
81-
}
82-
*/
8356
}
8457

8558
class OnboardingLayerViewController: NSViewController {
8659

8760
@IBOutlet weak var pageContainerView: OnboardingPageContainerView!
8861
@IBOutlet weak var pageDotIndicator: PageDotsIndicator!
62+
var layer: Onboarding!
8963

90-
// var pageController: NSPageController!
9164
private var pages: [NSViewController] = []
9265
private var currentPageIndex: Int = 0 {
9366
didSet { pageDotIndicator.currentPage = currentPageIndex }
@@ -100,12 +73,20 @@ class OnboardingLayerViewController: NSViewController {
10073

10174
override func viewDidAppear() {
10275

76+
print("View did appear...")
77+
10378
func instantiate(_ id: String) -> NSViewController {
10479

10580
let storyboard = NSStoryboard(name: "Onboarding", bundle: nil)
10681
return storyboard.instantiateController(withIdentifier: id) as! NSViewController
10782
}
10883

84+
// Remove all child view controllers and their views
85+
for child in children {
86+
child.view.removeFromSuperview()
87+
child.removeFromParent()
88+
}
89+
10990
super.viewDidAppear()
11091
pages = [instantiate("Step1"), instantiate("Step2")]
11192
pageDotIndicator.numberOfPages = pages.count
@@ -175,6 +156,12 @@ class OnboardingLayerViewController: NSViewController {
175156
showPage(at: prevIndex)
176157
}
177158
}
159+
160+
@IBAction func skipAction(_ sender: Any?) {
161+
162+
print("skip")
163+
layer!.close(delay: 1.0)
164+
}
178165
}
179166

180167
@MainActor
@@ -193,6 +180,21 @@ class Onboarding: Layer {
193180
onboardingVC = storyboard.instantiateController(withIdentifier: "OnboardingLayerViewController") as? OnboardingLayerViewController
194181
onboardingVC.view.wantsLayer = true
195182
onboardingVC.view.layer?.backgroundColor = NSColor.windowBackgroundColor.cgColor
183+
onboardingVC.layer = self
184+
}
185+
186+
override func open(delay: Double) {
187+
188+
super.open(delay: delay)
189+
190+
print("open")
191+
}
192+
193+
override func layerDidOpen() {
194+
195+
print("layerDidOpen")
196+
renderer.canvas.shouldRender = true
197+
renderer.splashScreen.shouldRender = true
196198
}
197199

198200
override func alphaDidChange() {

GUI/Metal/Layers/SplashScreen.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ class SplashScreen: Layer {
5858
}
5959

6060
func render(_ encoder: MTLRenderCommandEncoder) {
61-
61+
62+
if !shouldRender { return }
63+
6264
// Configure vertex shader
6365
encoder.setVertexBytes(&vertexUniforms,
6466
length: MemoryLayout<VertexUniforms>.stride,

GUI/Metal/Renderer.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,9 @@ class Renderer: NSObject, MTKViewDelegate {
297297
// Render the scene
298298
if canvas.isTransparent { splashScreen.render(encoder) }
299299
if canvas.isVisible { canvas.render(encoder) }
300+
300301
encoder.endEncoding()
301-
302+
302303
// Commit the command buffer
303304
buffer.addCompletedHandler { @Sendable [weak self] buffer in
304305

GUI/Metal/RendererSetup.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,16 @@ extension Renderer {
5151
}
5252

5353
func buildDescriptors() {
54-
55-
// Render pass descriptor
54+
55+
// Get the default background color
56+
let bgColor = NSColor.windowBackgroundColor.usingColorSpace(.deviceRGB) ?? .black
57+
let r = Double(bgColor.redComponent)
58+
let g = Double(bgColor.greenComponent)
59+
let b = Double(bgColor.blueComponent)
60+
61+
// Create the render pass descriptor
5662
descriptor = MTLRenderPassDescriptor()
57-
descriptor.colorAttachments[0].clearColor = MTLClearColorMake(0, 0, 0, 1)
63+
descriptor.colorAttachments[0].clearColor = MTLClearColorMake(r, g, b, 1.0)
5864
descriptor.colorAttachments[0].loadAction = MTLLoadAction.clear
5965
descriptor.colorAttachments[0].storeAction = MTLStoreAction.store
6066
descriptor.depthAttachment.clearDepth = 1

GUI/MyController.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ extension MyController {
209209
do {
210210

211211
// Experimental
212-
renderer.onboarding.open(delay: 1)
212+
renderer.splashScreen.shouldRender = false
213+
renderer.canvas.shouldRender = false
214+
renderer.onboarding.open(delay: 1.0)
213215

214216
// Install Aros if no Kickstart is present
215217
if !emu.mem.info.hasRom { installAros() }

GUI/MyControllerMenu.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,13 @@ extension MyController: NSMenuItemValidation {
168168
pref.applyUserDefaults()
169169

170170
// Power on
171+
/*
171172
emu.powerOn()
172173
try? emu.run()
174+
*/
175+
176+
// Launch the onboarding agent
177+
renderer.onboarding.open(delay: 1.0)
173178
}
174179

175180
@IBAction func importScriptAction(_ sender: Any!) {

GUI/System/OnboardingButton.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class OnboardingButton: NSControl {
3636
setup()
3737
}
3838

39+
var myFont: NSFont?
40+
3941
private func setup() {
4042

4143
wantsLayer = true

0 commit comments

Comments
 (0)