Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions Sources/GameWidget/Commons/Entity.swift

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//
// File.swift
//
//
// Created by rrbox on 2023/04/22.
//

import Foundation
8 changes: 8 additions & 0 deletions Sources/GameWidget/Commons/Spacer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//
// File.swift
//
//
// Created by rrbox on 2023/04/23.
//

import Foundation
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//
// File.swift
//
//
// Created by rrbox on 2023/04/22.
//

import Foundation
29 changes: 29 additions & 0 deletions Sources/GameWidget/Commons/StructuringTools/Stack/HStack.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// HStack.swift
//
//
// Created by rrbox on 2023/04/21.
//

import SpriteKit

public struct HStack<T: WidgetTupleProtocol>: WidgetListElementType, SplittingFrameElementType {
let widgetTuple: T

public init(@WidgetTupleBuilder _ builder: () -> T) {
self.widgetTuple = builder()
}

public func addTo(buffer: inout [SKNode], frame: WidgetFrame, center: WidgetNotificationSystem) {
let size = CGSize(width: frame.size.width/CGFloat(self.widgetTuple.countOfNodes), height: frame.size.height)
var position = CGPoint(x: frame.position.x + (-frame.size.width/2) + (size.width/2), y: frame.position.y)// 左端四角形の中心の座標

let frames = (0...self.widgetTuple.countOfNodes-1).reduce(into: [WidgetFrame]()) { partialResult, i in
partialResult.append(WidgetFrame(position: position, padding: frame.padding, size: size))
position.x += size.width
}

self.widgetTuple.addTo(buffer: &buffer, frames: frames, center: center)
}

}
32 changes: 32 additions & 0 deletions Sources/GameWidget/Commons/StructuringTools/Stack/VStack.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// VStack.swift
//
//
// Created by rrbox on 2023/04/21.
//

import SpriteKit

public struct VStack<T: WidgetTupleProtocol>: WidgetListElementType, SplittingFrameElementType {
let widgetTuple: T

public init(@WidgetTupleBuilder _ builder: () -> T) {
self.widgetTuple = builder()
}

public func addTo(buffer: inout [SKNode], frame: WidgetFrame, center: WidgetNotificationSystem) {
// 等分されたサイズ
let size = CGSize(width: frame.size.width, height: frame.size.height/CGFloat(self.widgetTuple.countOfNodes))

// 四角形の左端頂点の座標
var position = CGPoint(x: frame.position.x, y: frame.position.y + (frame.size.height/2) - (size.height/2))

let frames = (0...self.widgetTuple.countOfNodes-1).reduce(into: [WidgetFrame]()) { partialResult, i in
partialResult.append(WidgetFrame(position: position, padding: frame.padding, size: size))
position.y -= size.height
}

self.widgetTuple.addTo(buffer: &buffer, frames: frames, center: center)
}

}
182 changes: 0 additions & 182 deletions Sources/GameWidget/Commons/WidgetList.swift

This file was deleted.

Loading