Skip to content

Commit 311b1a5

Browse files
Allow specifying pin dimensions
Some pins might only be applicable to certain dimensions such as the Nether. In these cases, players can set the pin's dimension to have it only appear in that dimension. The coordinates then are relative to the dimension they're assigned to, and the appropriate label views will automatically convert when necessary. By default, pins in v1 will be assumed as the Overworld.
1 parent c3564b0 commit 311b1a5

File tree

12 files changed

+184
-44
lines changed

12 files changed

+184
-44
lines changed

Alidade.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MCMaps/Legacy/Views/Pins/CartographyMapPinDetailView.swift

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,28 +63,19 @@ struct CartographyMapPinDetailView: View {
6363
}
6464
}
6565

66-
HStack {
67-
Label(viewModel.pinLocationLabel, semanticIcon: .overworld)
68-
.font(.subheadline)
69-
.monospaced()
70-
.foregroundStyle(.secondary)
71-
.help("Location in Overworld: \(viewModel.pinLocationLabel)")
72-
.accessibilityLabel("Location in Overworld")
73-
.accessibilityValue(viewModel.pinLocationLabel)
74-
Label(viewModel.netherTranslatedCoordinate, semanticIcon: .nether)
75-
.font(.subheadline)
76-
.monospaced()
77-
.foregroundStyle(.secondary)
78-
.help("Location in Nether: \(viewModel.netherTranslatedCoordinate)")
79-
.accessibilityLabel("Location in Nether")
80-
.accessibilityValue(viewModel.netherTranslatedCoordinate)
81-
}
82-
.padding(.vertical, 2)
66+
PinCoordinateStack(pin: viewModel.pin.wrappedValue)
67+
.font(.subheadline)
68+
.foregroundStyle(.secondary)
69+
.padding(.vertical, 2)
8370
}
8471

8572
.listRowBackground(Color.clear)
8673
.listRowSeparator(.hidden)
8774

75+
Group {
76+
WorldCodedDimensionPicker(selection: viewModel.pin.dimension)
77+
}
78+
8879
Group {
8980
if !viewModel.images().isEmpty {
9081
Section("Photos") {

MCMaps/Red Window/Views/Detail/Cells/RedWindowPinHeader.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,9 @@ struct RedWindowPinHeader: RedWindowDetailCell {
8989
.foregroundStyle(.primary)
9090
.font(.largeTitle)
9191
.bold()
92-
Text("(\(Int(pin.position.x)), \(Int(pin.position.y)))")
92+
PinCoordinateStack(pin: pin)
9393
.font(.headline)
9494
.foregroundStyle(.secondary)
95-
.fontDesign(.monospaced)
9695
}
9796
Spacer()
9897
}
@@ -111,7 +110,7 @@ struct RedWindowPinHeader: RedWindowDetailCell {
111110
Rectangle()
112111
.fill(
113112
Color(pin.color?.swiftUIColor ?? .accent)
114-
.opacity(0.85)
113+
.opacity(0.75)
115114
.gradient
116115
)
117116
}

MCMaps/Red Window/Views/Detail/RedWindowPinDetailView.swift

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,24 @@ struct RedWindowPinDetailView: View {
131131
}
132132
#endif
133133

134-
ToolbarItem {
135-
PhotosPicker(selection: $photosPickerItem, matching: .images) {
136-
Label("Add From Photos", systemImage: "photo.badge.plus")
137-
}
138-
}
139-
ToolbarItem {
140-
Button("Add From Files", systemImage: "folder") {
141-
uploadFromFiles.toggle()
142-
}
143-
}
134+
photoUploadToolbar
144135

145136
#if RED_WINDOW
146137
if #available(macOS 16, iOS 19, *) {
147138
ToolbarSpacer(.fixed)
148139
}
149140
#endif
150141

142+
ToolbarItem {
143+
Menu("Pin Dimension", systemImage: "globe") {
144+
#if os(iOS)
145+
Label("Pin Dimension", systemImage: "globe")
146+
.foregroundStyle(.secondary)
147+
#endif
148+
WorldCodedDimensionPicker(selection: $pin.dimension)
149+
}
150+
}
151+
151152
ToolbarItem {
152153
Menu("Pin Color", systemImage: "paintpalette") {
153154
#if os(iOS)
@@ -194,6 +195,21 @@ struct RedWindowPinDetailView: View {
194195
}
195196
}
196197

198+
private var photoUploadToolbar: some ToolbarContent {
199+
Group {
200+
ToolbarItem {
201+
PhotosPicker(selection: $photosPickerItem, matching: .images) {
202+
Label("Add From Photos", systemImage: "photo.badge.plus")
203+
}
204+
}
205+
ToolbarItem {
206+
Button("Add From Files", systemImage: "folder") {
207+
uploadFromFiles.toggle()
208+
}
209+
}
210+
}
211+
}
212+
197213
private func loadPickerSelection(_ item: PhotosPickerItem) async {
198214
do {
199215
if let data = try await item.loadTransferable(type: Data.self) {

MCMaps/Red Window/Views/Library/RedWindowLibraryGridCell.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ struct RedWindowLibraryGridCell: View {
5757
Text("(\(pin.position.accessibilityReadout))")
5858
.font(.subheadline)
5959
.foregroundStyle(.secondary)
60+
Text(pin.dimension.rawValue.localizedCapitalized)
61+
.font(.subheadline)
62+
.foregroundStyle(.tertiary)
6063
}
6164
.animation(.default, value: horizontalSizeClass)
6265
}

MCMaps/Red Window/Views/Library/RedWindowPinLibraryListView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ struct RedWindowPinLibraryListView: View {
4242
if horizontalSizeClass == .compact {
4343
Text(val.content.position.accessibilityReadout)
4444
.foregroundStyle(.secondary)
45+
Text(val.content.dimension.rawValue.localizedCapitalized)
46+
.foregroundStyle(.tertiary)
4547
}
4648
}
4749
} icon: {
@@ -51,6 +53,7 @@ struct RedWindowPinLibraryListView: View {
5153
}
5254
}
5355
TableColumn("Location", value: \.content.position.accessibilityReadout)
56+
TableColumn("Dimension", value: \.content.dimension.rawValue.localizedCapitalized)
5457
TableColumn("Tags") { val in
5558
Group {
5659
if let tags = val.content.tags, !tags.isEmpty {

MCMaps/Resources/Localizable.xcstrings

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -306,17 +306,15 @@
306306
"Location" : {
307307

308308
},
309-
"Location in Nether" : {
310-
311-
},
312-
"Location in Nether: %@" : {
313-
314-
},
315-
"Location in Overworld" : {
316-
317-
},
318-
"Location in Overworld: %@" : {
319-
309+
"Location in %@: %@" : {
310+
"localizations" : {
311+
"en" : {
312+
"stringUnit" : {
313+
"state" : "new",
314+
"value" : "Location in %1$@: %2$@"
315+
}
316+
}
317+
}
320318
},
321319
"Locations You've Visited" : {
322320

@@ -407,6 +405,9 @@
407405
},
408406
"Pin Color" : {
409407

408+
},
409+
"Pin Dimension" : {
410+
410411
},
411412
"Pin Here..." : {
412413

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// MinecraftWorldDimension+Pin.swift
3+
// MCMaps
4+
//
5+
// Created by Marquis Kurt on 13-08-2025.
6+
//
7+
8+
import CubiomesKit
9+
import MCMap
10+
11+
extension MinecraftWorld.Dimension {
12+
init(fromPinDimension pinDimension: CartographyMapPin.Dimension) {
13+
switch pinDimension {
14+
case .overworld:
15+
self = .overworld
16+
case .nether:
17+
self = .nether
18+
case .end:
19+
self = .end
20+
}
21+
}
22+
}

MCMaps/Shared/Views/Forms/PinCreatorForm.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ struct PinCreatorForm: View {
2626
@State private var name: String = "Pin"
2727
@State private var color: CartographyMapPin.Color = .blue
2828
@State private var updatedLocation = CGPoint.zero
29+
@State private var dimension: CartographyMapPin.Dimension = .overworld
2930

3031
@State private var locationX = 0.0
3132
@State private var locationY = 0.0
@@ -62,6 +63,7 @@ struct PinCreatorForm: View {
6263
TextField("Z Coordinate", value: $locationY, format: .number)
6364
#endif
6465
}
66+
WorldCodedDimensionPicker(selection: $dimension)
6567
} header: {
6668
Text("World Location")
6769
}
@@ -100,7 +102,14 @@ struct PinCreatorForm: View {
100102
ToolbarItem(placement: .confirmationAction) {
101103
Button("Create", systemImage: "checkmark") {
102104
dismiss()
103-
completion(CartographyMapPin(named: name, at: updatedLocation, color: color))
105+
completion(
106+
CartographyMapPin(
107+
named: name,
108+
at: updatedLocation,
109+
dimension: dimension,
110+
color: color
111+
)
112+
)
104113
}
105114
}
106115
#if os(macOS)

MCMaps/Shared/ManagedAnnotatedMap.swift renamed to MCMaps/Shared/Views/ManagedAnnotatedMap.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ struct ManagedAnnotatedMap<MapContent: View>: View {
7474
var usedIDs = Set<String>()
7575

7676
for pin in file.pins {
77+
let dim = MinecraftWorld.Dimension(fromPinDimension: pin.dimension)
78+
if dim != dimension { continue }
79+
7780
let marker = Marker(
7881
location: pin.position,
7982
title: pin.name,

0 commit comments

Comments
 (0)