all features implemented

This commit is contained in:
Rory Hinnen
2026-09-07 15:27:33 -05:00
parent ac4d4a670a
commit 2a6130ba8e
64 changed files with 691 additions and 340 deletions
+49
View File
@@ -0,0 +1,49 @@
//
// Die.swift
// Bunch O' Dice
//
// Created by Rory Hinnen on 22/6/18.
//
import SwiftUI
struct Die: View {
@EnvironmentObject var current: Roll
@State var whichDie: Dice.DiceType
var body: some View {
/* let size = 25.0
let displayColorHit = (whichDie.rawValue >= current.cutoff.rawValue) ? Color.red : Color.primary
let displayColorArmor = (whichDie.rawValue <= current.cutoff.rawValue) ? Color.red : Color.primary
let displayColorArmorText = (whichDie.rawValue < current.cutoff.rawValue) ? Color.red : Color.primary
HStack{
Text(String(current.dice.value(which: whichDie)))
.foregroundColor(current.state == .armour ?
displayColorArmorText : displayColorHit)
Image(systemName: "die.face." + String(whichDie.rawValue) + ".fill")
.foregroundColor(current.state == .armour ?
displayColorArmor : displayColorHit)
}
.font(.system(size: size))
.padding(2)
.gesture(TapGesture().onEnded {
if current.state == .hit {
if whichDie.rawValue != 1 {
current.hitCutoff = whichDie }
} else if current.state == .armour {
current.armourSave = Int(whichDie.rawValue)
}
})
} */
Text("")
}
struct Die_Previews: PreviewProvider {
static var previews: some View {
Die(whichDie: Dice.DiceType.one)
.environmentObject(Roll())
}
}
@@ -0,0 +1,50 @@
//
// Die.swift
// Bunch O' Dice
//
// Created by Rory Hinnen on 22/2/20.
//
import SwiftUI
struct SingleDie: View {
@EnvironmentObject var current: Roll
@State var whichDie: Dice.DiceType
var body: some View {
VStack {
Text(String(current.dice.value(which: whichDie)))
Group {
if (current.state != .armour) && (whichDie.rawValue >= current.cutoff.rawValue) {
Text(whichDie.print())
.foregroundColor(Color.red)
} else if (current.state == .armour) && (whichDie.rawValue < current.cutoff.rawValue) {
Text(whichDie.print())
.foregroundColor(Color.red)
} else {
Text(whichDie.print())
.foregroundColor(Color.black)
.background(Color.white)
}
}
.font(.system(size: 45))
}
.font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/)
.padding(.horizontal, 5.0)
.gesture(TapGesture().onEnded {
if current.state == .hit {
current.hitCutoff = whichDie
}
else if current.state == .armour {
current.armourSave = Int(whichDie.rawValue)
}
})
}
}
struct Die_Previews: PreviewProvider {
static var previews: some View {
Die(whichDie: .one)
.environmentObject(Roll())
}
}
@@ -0,0 +1,29 @@
//
// SwiftUIView.swift
// Bunch O' Dice
//
// Created by Rory Martin Hinnen on 6/7/22.
//
import SwiftUI
struct ShowPoolLandscape: View {
@EnvironmentObject var current: Roll
var body: some View {
HStack {
Spacer()
ForEach(Dice.DiceType.allCases, id: \.rawValue) { i in
SingleDie(whichDie: i)
}
Spacer()
}
}
}
struct ShowPool_Previews: PreviewProvider {
static var previews: some View {
ShowPoolLandscape()
.environmentObject(Roll())
}
}
+50
View File
@@ -0,0 +1,50 @@
//
// IncrementDie.swift
// Bunch O' Dice
//
// Created by Rory Martin Hinnen on 6/7/22.
//
import SwiftUI
struct AddToPool: View {
@EnvironmentObject var current: Roll
var body: some View {
VStack {
Spacer()
Text(String(current.total) + " 🎲")
.font(.system(size: 40))
.padding(15)
HStack {
ForEach(Array(stride(from: 2, through: 0, by: -1)), id: \.self) { place in
VStack{
Text("▲")
.gesture(TapGesture().onEnded({
current.incrementDigits(place: place)
}))
Text(String(current.totalDigits[place]))
.padding(4)
.border(.black, width: 1.0)
Text("▼")
.gesture(TapGesture().onEnded({
current.decrementDigits(place: place)
}))
}
}
}
.font(.system(size: 45))
.padding(10)
Button("Clear", action: {current.total = 0})
Spacer()
}
}
}
struct IncrementDie_Previews: PreviewProvider {
static var previews: some View {
AddToPool()
.environmentObject(Roll())
}
}
+30
View File
@@ -0,0 +1,30 @@
//
// HistoryView.swift
// Bunch O' Dice
//
// Created by Rory Hinnen on 22/6/11.
//
import SwiftUI
struct HistoryView: View {
@EnvironmentObject var current: Roll
@Binding var isShowing: Bool
var body: some View {
VStack{
List(current.history) {event in
Text("\(event.poolTotal) Dice Rolled, \(event.total) \(event.state.print())")
}
Spacer()
Button("Dismiss", action: {isShowing.toggle()})
}
}
}
struct HistoryView_Previews: PreviewProvider {
static var previews: some View {
HistoryView(isShowing: .constant(false))
.environmentObject(Roll())
}
}
+41
View File
@@ -0,0 +1,41 @@
//
// SettingsView.swift
// Bunch O' Dice
//
// Created by Rory Hinnen on 22/7/2.
//
import SwiftUI
struct SettingsView: View {
@EnvironmentObject var current: Roll
@Binding var isShowing: Bool
var body: some View {
VStack{
VStack{
Text("DieHammer")
.font(.title)
Text("A roll management tool for Warhammer & Warhammer:40,000")
.font(.subheadline)
}.padding()
Group{
VStack{
Text("Theme")
Button(String(current.appearance.name)) {current.appearance.next()}
}
Button("Tutorial") {current.currentPage = "OnboardingView"}
.padding()
}
Spacer()
Button("Dismiss", action: {isShowing = false})
}
}
}
struct SettingsView_Previews: PreviewProvider {
static var previews: some View {
SettingsView(isShowing: .constant(true))
.environmentObject(Roll())
}
}
@@ -0,0 +1,54 @@
//
// DieHorizontal.swift
// Bunch O' Dice
//
// Created by Rory Hinnen on 22/6/12.
//
import SwiftUI
struct DieHorizontal: View {
@EnvironmentObject var current: Roll
@State var whichDie: Dice.DiceType
var body: some View {
HStack {
Text(String(current.dice.value(which: whichDie)))
.offset(x: 0.0, y: 2.0)
Group {
if (current.state != .armour) && (whichDie.rawValue >= current.cutoff.rawValue) {
Text(whichDie.print())
.foregroundColor(Color.red)
} else if (current.state == .armour) && (whichDie.rawValue < current.cutoff.rawValue) {
Text(whichDie.print())
.foregroundColor(Color.red)
} else {
Text(whichDie.print())
.foregroundColor(Color.black)
}
}
.font(.system(size: 40))
}
.font(.system(size: 25))
.padding(.horizontal, 5.0)
.gesture(TapGesture().onEnded {
if current.state == .hit {
current.hitCutoff = whichDie
}
else if current.state == .armour {
current.armourSave = Int(whichDie.rawValue)
}
})
}
}
struct DieHorizontal_Previews: PreviewProvider {
static var previews: some View {
VStack {
DieHorizontal(whichDie: .four).environmentObject(Roll())
DieHorizontal(whichDie: .three).environmentObject(Roll())
}
}
//.environmentObject(Roll())
}
@@ -0,0 +1,26 @@
//
// ShowPoolHorizontal.swift
// Bunch O' Dice
//
// Created by Rory Hinnen on 22/6/12.
//
import SwiftUI
struct ShowPoolHorizontal: View {
@EnvironmentObject var current: Roll
var body: some View {
VStack(alignment: .trailing) {
ForEach(Dice.DiceType.allCases.reversed(), id: \.rawValue) { i in
DieHorizontal(whichDie: i)
}
}
}
}
struct ShowPoolHorizontal_Previews: PreviewProvider {
static var previews: some View {
ShowPoolHorizontal().environmentObject(Roll())
}
}
+20
View File
@@ -0,0 +1,20 @@
//
// dice.swift
// Bunch O' Dice
//
// Created by Rory Hinnen on 6/10/23.
//
import SwiftUI
struct dice: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
struct dice_Previews: PreviewProvider {
static var previews: some View {
dice()
}
}
@@ -0,0 +1,47 @@
//
// PortraitScreen.swift
// Bunch O' Dice
//
// Created by Rory Hinnen on 22/6/11.
//
import SwiftUI
struct PortraitScreen: View {
@EnvironmentObject var current: Roll
var frameSize: CGFloat // = CGFloat(120)
let fontSize: Double // = 35.0
let blurSize: Double // = 11.0
var body: some View {
Group{
VStack {
HStack {
Spacer()
Pool(frameSize: frameSize, fontSize: fontSize, blurSize: blurSize)
Spacer()
Total(frameSize: frameSize, fontSize: fontSize, blurSize: blurSize)
Spacer()
}
ShowPoolLandscape()
Group {
switch current.state {
case .wound:
WoundCalculator()
case .armour:
ArmourCalculator()
default:
HitCalculator()
}
}
}.padding()
}
}
}
struct PortraitScreen_Previews: PreviewProvider {
static var previews: some View {
PortraitScreen(frameSize: 120, fontSize: 35, blurSize: 11)
.environmentObject(Roll())
}
}