From b6938f8187dfb1d796355deb3cd7b33c523b9026 Mon Sep 17 00:00:00 2001 From: Hugo Pezziardi Date: Wed, 18 Dec 2024 17:42:42 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A=20(NewGEK):=20Rename=20positionnin?= =?UTF-8?q?g=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/DnD/Grid/BaseScene/DnDGridBaseScene.swift | 10 +++++----- .../DnD/Grid/BaseScene/DnDGridFiveChoicesScene.swift | 4 ++-- .../DnD/Grid/BaseScene/DnDGridFourChoicesScene.swift | 4 ++-- .../DnD/Grid/BaseScene/DnDGridSixChoicesScene.swift | 4 ++-- .../DnD/Grid/BaseScene/DnDGridThreeChoicesScene.swift | 4 ++-- .../DnD/Grid/BaseScene/DnDGridTwoChoicesScene.swift | 4 ++-- .../BaseScene/DnDGridWithZonesBaseScene.swift | 10 ++++------ .../DnD/OneToOne/BaseScene/DnDOneToOneBaseScene.swift | 8 ++++---- 8 files changed, 23 insertions(+), 25 deletions(-) diff --git a/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridBaseScene.swift b/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridBaseScene.swift index 719097e03..c55004ef6 100644 --- a/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridBaseScene.swift +++ b/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridBaseScene.swift @@ -30,7 +30,7 @@ class DnDGridBaseScene: SKScene { backgroundColor = .clear removeAllChildren() removeAllActions() - self.setFirstAnswerPosition() + self.setPositionVariables() self.layoutChoices() } @@ -75,7 +75,7 @@ class DnDGridBaseScene: SKScene { func layoutChoices() { for (index, choice) in self.viewModel.choices.enumerated() { - choice.initialPosition = self.setInitialPosition(index) + choice.initialPosition = self.setChoicePosition(index) choice.position = choice.initialPosition! self.bindNodesToSafeArea([choice]) self.dropDestinations.append(choice) @@ -94,11 +94,11 @@ class DnDGridBaseScene: SKScene { // MARK: - Answer Positioning - func setFirstAnswerPosition() { - fatalError("setFirstAnswerPosition() must be implemented in the sub-scene") + func setPositionVariables() { + fatalError("setPositionVariables() must be implemented in the sub-scene") } - func setInitialPosition(_: Int) -> CGPoint { + func setChoicePosition(_: Int) -> CGPoint { fatalError("setNextAnswerPosition(_ index:) must be implemented in the sub-scene") } diff --git a/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridFiveChoicesScene.swift b/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridFiveChoicesScene.swift index 54c64e902..1713494d8 100644 --- a/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridFiveChoicesScene.swift +++ b/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridFiveChoicesScene.swift @@ -5,13 +5,13 @@ import SwiftUI class DnDGridFiveChoicesScene: DnDGridBaseScene { - override func setFirstAnswerPosition() { + override func setPositionVariables() { self.horizontalSpacer = size.width / 3 self.verticalSpacer = size.height / 3 self.initialNodeX = (size.width / 2) - self.horizontalSpacer } - override func setInitialPosition(_ index: Int) -> CGPoint { + override func setChoicePosition(_ index: Int) -> CGPoint { if index / 3 < 1 { let positionX = self.initialNodeX + (self.horizontalSpacer * CGFloat(index % 3)) let positionY = 2 * self.verticalSpacer + 30 diff --git a/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridFourChoicesScene.swift b/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridFourChoicesScene.swift index 486a8d466..0a45d7997 100644 --- a/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridFourChoicesScene.swift +++ b/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridFourChoicesScene.swift @@ -5,13 +5,13 @@ import SwiftUI class DnDGridFourChoicesScene: DnDGridBaseScene { - override func setFirstAnswerPosition() { + override func setPositionVariables() { self.horizontalSpacer = size.width / 2 self.verticalSpacer = size.height / 3 self.initialNodeX = (size.width - self.horizontalSpacer) / 2 } - override func setInitialPosition(_ index: Int) -> CGPoint { + override func setChoicePosition(_ index: Int) -> CGPoint { let positionX = self.initialNodeX + (self.horizontalSpacer * CGFloat(index % 2)) if index / 2 < 1 { let positionY = 2 * self.verticalSpacer + 30 diff --git a/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridSixChoicesScene.swift b/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridSixChoicesScene.swift index 4df1aaf0d..51f3c726c 100644 --- a/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridSixChoicesScene.swift +++ b/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridSixChoicesScene.swift @@ -5,13 +5,13 @@ import SwiftUI class DnDGridSixChoicesScene: DnDGridBaseScene { - override func setFirstAnswerPosition() { + override func setPositionVariables() { self.horizontalSpacer = size.width / 3 self.verticalSpacer = size.height / 3 self.initialNodeX = (size.width / 2) - self.horizontalSpacer } - override func setInitialPosition(_ index: Int) -> CGPoint { + override func setChoicePosition(_ index: Int) -> CGPoint { let positionX = self.initialNodeX + (self.horizontalSpacer * CGFloat(index % 3)) if index / 3 < 1 { let positionY = 2 * self.verticalSpacer + 30 diff --git a/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridThreeChoicesScene.swift b/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridThreeChoicesScene.swift index 4116a49eb..c1413ab2e 100644 --- a/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridThreeChoicesScene.swift +++ b/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridThreeChoicesScene.swift @@ -5,13 +5,13 @@ import SwiftUI class DnDGridThreeChoicesScene: DnDGridBaseScene { - override func setFirstAnswerPosition() { + override func setPositionVariables() { self.horizontalSpacer = size.width / 2 self.verticalSpacer = size.height / 3 self.initialNodeX = (size.width - self.horizontalSpacer) / 2 } - override func setInitialPosition(_ index: Int) -> CGPoint { + override func setChoicePosition(_ index: Int) -> CGPoint { if index / 2 < 1 { let positionX = self.initialNodeX + (self.horizontalSpacer * CGFloat(index % 2)) let positionY = 2 * self.verticalSpacer + 30 diff --git a/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridTwoChoicesScene.swift b/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridTwoChoicesScene.swift index 0787b9783..7982ff35e 100644 --- a/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridTwoChoicesScene.swift +++ b/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/Grid/BaseScene/DnDGridTwoChoicesScene.swift @@ -5,13 +5,13 @@ import SwiftUI class DnDGridTwoChoicesScene: DnDGridBaseScene { - override func setFirstAnswerPosition() { + override func setPositionVariables() { self.horizontalSpacer = size.width / 2 self.verticalSpacer = size.height / 2 self.initialNodeX = (size.width - self.horizontalSpacer) / 2 } - override func setInitialPosition(_ index: Int) -> CGPoint { + override func setChoicePosition(_ index: Int) -> CGPoint { let positionX = self.initialNodeX + (self.horizontalSpacer * CGFloat(index % 2)) return CGPoint(x: positionX, y: self.verticalSpacer) } diff --git a/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/GridWithZones/BaseScene/DnDGridWithZonesBaseScene.swift b/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/GridWithZones/BaseScene/DnDGridWithZonesBaseScene.swift index b49248443..f1eb60893 100644 --- a/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/GridWithZones/BaseScene/DnDGridWithZonesBaseScene.swift +++ b/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/GridWithZones/BaseScene/DnDGridWithZonesBaseScene.swift @@ -67,7 +67,7 @@ class DnDGridWithZonesBaseScene: SKScene { removeAllChildren() removeAllActions() - self.setFirstAnswerPosition() + self.setPositionVariables() self.layoutDropZones() self.layoutAnswers() } @@ -80,7 +80,7 @@ class DnDGridWithZonesBaseScene: SKScene { func layoutAnswers() { for (index, choice) in self.viewModel.choices.enumerated() { - choice.initialPosition = self.setInitialPosition(index) + choice.initialPosition = self.setChoicePosition(index) choice.position = choice.initialPosition! let shadowChoice = DnDShadowNode(node: choice) @@ -99,12 +99,11 @@ class DnDGridWithZonesBaseScene: SKScene { } } - func setFirstAnswerPosition() { + func setPositionVariables() { self.spacer = size.width / CGFloat(self.viewModel.choices.count + 1) - self.defaultPosition = CGPoint(x: self.spacer, y: 3 * size.height / 4) } - func setInitialPosition(_ index: Int) -> CGPoint { + func setChoicePosition(_ index: Int) -> CGPoint { CGPoint(x: self.spacer * CGFloat(index + 1), y: 3 * size.height / 4) } @@ -128,5 +127,4 @@ class DnDGridWithZonesBaseScene: SKScene { private var answerNodes: [DnDAnswerNode] = [] private var playedNode: DnDAnswerNode? private var spacer: CGFloat = .zero - private var defaultPosition = CGPoint.zero } diff --git a/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/OneToOne/BaseScene/DnDOneToOneBaseScene.swift b/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/OneToOne/BaseScene/DnDOneToOneBaseScene.swift index 29b866735..71fa3a31b 100644 --- a/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/OneToOne/BaseScene/DnDOneToOneBaseScene.swift +++ b/Modules/GameEngineKit/Sources/_NewSystem/Views/DnD/OneToOne/BaseScene/DnDOneToOneBaseScene.swift @@ -82,7 +82,7 @@ class DnDOneToOneBaseScene: SKScene { func layoutChoices() { for (index, choice) in self.viewModel.choices.enumerated() { - choice.initialPosition = self.setInitialPosition(index) + choice.initialPosition = self.setChoicePosition(index) choice.position = choice.initialPosition! self.answerNodes.append(choice) @@ -94,17 +94,17 @@ class DnDOneToOneBaseScene: SKScene { func layoutDropzones() { for (index, dropzone) in self.viewModel.dropzones.enumerated() { - dropzone.position = self.setInitialDropZonePosition(index) + dropzone.position = self.setDropZonePosition(index) self.dropZonesNodes.append(dropzone) addChild(dropzone) } } - func setInitialPosition(_ index: Int) -> CGPoint { + func setChoicePosition(_ index: Int) -> CGPoint { CGPoint(x: self.spacer * CGFloat(index + 1), y: size.height - self.viewModel.choices[0].size.height * 0.8) } - func setInitialDropZonePosition(_ index: Int) -> CGPoint { + func setDropZonePosition(_ index: Int) -> CGPoint { CGPoint(x: self.spacer * CGFloat(index + 1), y: self.viewModel.choices[0].size.height * 0.8) }