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
8 changes: 4 additions & 4 deletions MCColorFix.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
ENABLE_APP_SANDBOX = NO;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -273,7 +273,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 0.2.0;
PRODUCT_BUNDLE_IDENTIFIER = "Coder-Stevie.MCColorFix";
PRODUCT_NAME = "$(TARGET_NAME)";
REGISTER_APP_GROUPS = YES;
Expand All @@ -293,7 +293,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
ENABLE_APP_SANDBOX = NO;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -303,7 +303,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 0.2.0;
PRODUCT_BUNDLE_IDENTIFIER = "Coder-Stevie.MCColorFix";
PRODUCT_NAME = "$(TARGET_NAME)";
REGISTER_APP_GROUPS = YES;
Expand Down
100 changes: 84 additions & 16 deletions MCColorFix/ControlPanelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,102 @@ import ScreenCaptureKit

struct ControlPanelView: View {
@EnvironmentObject var overlay: OverlayController
@State private var selected: TargetWindow?
@State private var showAllWindows = false

/// Show the full list when the user asked for it, or automatically when
/// the heuristics found nothing — otherwise there would be no way to
/// select a window the scoring missed.
private var windowsToShow: [TargetWindow] {
let likely = overlay.likelyWindows
if showAllWindows || likely.isEmpty { return overlay.allWindows }
return likely
}

private static let rowHeight: CGFloat = 44
private static let maxListHeight: CGFloat = 264

/// A ScrollView reports an ideal height of 0, and MenuBarExtra sizes its
/// window to the content's ideal height — so a maxHeight-only constraint
/// collapses the list to nothing. Give it a definite height instead.
private var listHeight: CGFloat {
min(CGFloat(windowsToShow.count) * Self.rowHeight, Self.maxListHeight)
}

var body: some View {
VStack(alignment: .leading, spacing: 12) {
Text("Minecraft Color Fix")
.font(.headline)
HStack(alignment: .firstTextBaseline) {
Text("Minecraft Color Fix")
.font(.headline)
Spacer()
// Makes it unambiguous which build is running — several copies
// of this app tend to accumulate in Downloads.
Text(OverlayController.versionString)
.font(.caption2)
.foregroundStyle(.secondary)
}

Text(overlay.statusText)
.font(.caption)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)

if overlay.needsScreenRecordingPermission {
Button("Open Screen Recording Settings") {
overlay.openScreenRecordingSettings()
}
}
if overlay.isTranslocated {
Button("Reveal app in Finder") {
overlay.revealAppInFinder()
}
}

Divider()

if overlay.availableWindows.isEmpty {
Button("Find Minecraft Window") {
overlay.refreshWindowList()
}
} else {
ForEach(overlay.availableWindows, id: \.scWindow.windowID) { window in
Button(window.title) {
overlay.start(target: window)
if !overlay.needsScreenRecordingPermission {
if windowsToShow.isEmpty {
Button("Find Minecraft Window") {
overlay.refreshWindowList()
}
} else {
ScrollView {
VStack(alignment: .leading, spacing: 2) {
ForEach(windowsToShow, id: \.scWindow.windowID) { window in
Button {
overlay.start(target: window)
} label: {
VStack(alignment: .leading, spacing: 1) {
Text(window.displayName)
Text(window.subtitle)
.font(.caption2)
.foregroundStyle(.secondary)
}
.frame(maxWidth: .infinity, alignment: .leading)
}
.buttonStyle(.plain)
.padding(.vertical, 4)
.padding(.horizontal, 6)
.frame(height: Self.rowHeight)
.contentShape(Rectangle())
}
}
}
.frame(height: listHeight)

HStack {
Button("Refresh") {
overlay.refreshWindowList()
}
Spacer()
// Hidden when the list is already showing everything.
if !overlay.likelyWindows.isEmpty {
Button(showAllWindows ? "Show likely only" : "Show all windows") {
showAllWindows.toggle()
}
}
}
.font(.caption)
}
Button("Refresh") {
overlay.refreshWindowList()
}
.font(.caption)
}

if overlay.isRunning {
Expand All @@ -46,7 +114,7 @@ struct ControlPanelView: View {
}
}
.padding()
.frame(width: 280)
.frame(width: 300)
.onAppear {
overlay.refreshWindowList()
}
Expand Down
Loading