Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Unified diff context lines include a required leading space on blank lines.
patches/wine11/*.patch -whitespace
10 changes: 7 additions & 3 deletions Fixtures/Windows/d3d11-clear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <dxgi.h>
#include <wrl/client.h>
#include <cmath>
#include <cwchar>

using Microsoft::WRL::ComPtr;

Expand All @@ -12,7 +13,9 @@ static LRESULT CALLBACK WindowProc(HWND window, UINT message, WPARAM wparam, LPA
return DefWindowProcW(window, message, wparam, lparam);
}

int WINAPI wWinMain(HINSTANCE instance, HINSTANCE, PWSTR, int show) {
int WINAPI wWinMain(HINSTANCE instance, HINSTANCE, PWSTR commandLine, int show) {
const bool smoke = std::wcscmp(commandLine, L"--smoke") == 0;
unsigned frames = 0;
WNDCLASSW klass{}; klass.lpfnWndProc = WindowProc; klass.hInstance = instance;
klass.lpszClassName = L"IndieD3D11Fixture"; klass.hCursor = LoadCursor(nullptr, IDC_ARROW);
if (!RegisterClassW(&klass)) return 10;
Expand All @@ -28,7 +31,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE, PWSTR, int show) {
D3D_FEATURE_LEVEL level{};
HRESULT result = D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, 0, nullptr, 0,
D3D11_SDK_VERSION, &swap, &chain, &device, &level, &context);
if (FAILED(result)) { MessageBoxW(window, L"D3D11CreateDeviceAndSwapChain failed", L"Indie", MB_ICONERROR); return 20; }
if (FAILED(result)) { if (!smoke) MessageBoxW(window, L"D3D11CreateDeviceAndSwapChain failed", L"Indie", MB_ICONERROR); return 20; }
ComPtr<ID3D11Texture2D> buffer; ComPtr<ID3D11RenderTargetView> target;
if (FAILED(chain->GetBuffer(0, IID_PPV_ARGS(&buffer))) || FAILED(device->CreateRenderTargetView(buffer.Get(), nullptr, &target))) return 21;
ShowWindow(window, show);
Expand All @@ -41,6 +44,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE, PWSTR, int show) {
context->OMSetRenderTargets(1, target.GetAddressOf(), nullptr);
context->ClearRenderTargetView(target.Get(), color);
if (FAILED(chain->Present(1, 0))) return 22;
if (smoke && ++frames == 120) DestroyWindow(window);
}
return 0;
return smoke && frames != 120 ? 23 : 0;
}
15 changes: 10 additions & 5 deletions Fixtures/Windows/d3d12-clear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <dxgi1_4.h>
#include <wrl/client.h>
#include <cmath>
#include <cwchar>

using Microsoft::WRL::ComPtr;
static constexpr UINT FrameCount = 2;
Expand All @@ -13,7 +14,9 @@ static LRESULT CALLBACK WindowProc(HWND window, UINT message, WPARAM wparam, LPA
return DefWindowProcW(window, message, wparam, lparam);
}

int WINAPI wWinMain(HINSTANCE instance, HINSTANCE, PWSTR, int show) {
int WINAPI wWinMain(HINSTANCE instance, HINSTANCE, PWSTR commandLine, int show) {
const bool smoke = std::wcscmp(commandLine, L"--smoke") == 0;
unsigned frames = 0;
WNDCLASSW klass{}; klass.lpfnWndProc = WindowProc; klass.hInstance = instance;
klass.lpszClassName = L"IndieD3D12Fixture"; klass.hCursor = LoadCursor(nullptr, IDC_ARROW);
if (!RegisterClassW(&klass)) return 10;
Expand All @@ -25,7 +28,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE, PWSTR, int show) {
ComPtr<ID3D12Device> device;
if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory)))) return 20;
if (FAILED(D3D12CreateDevice(nullptr, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&device)))) {
MessageBoxW(window, L"D3D12CreateDevice failed", L"Indie", MB_ICONERROR); return 21;
if (!smoke) MessageBoxW(window, L"D3D12CreateDevice failed", L"Indie", MB_ICONERROR); return 21;
}

D3D12_COMMAND_QUEUE_DESC queueDescription{};
Expand Down Expand Up @@ -98,13 +101,15 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE, PWSTR, int show) {
++fenceValue; queue->Signal(fence.Get(), fenceValue);
if (fence->GetCompletedValue() < fenceValue) {
fence->SetEventOnCompletion(fenceValue, fenceEvent);
WaitForSingleObject(fenceEvent, INFINITE);
if (WaitForSingleObject(fenceEvent, smoke ? 10000 : INFINITE) != WAIT_OBJECT_0) { CloseHandle(fenceEvent); return 32; }
}
if (smoke && ++frames == 120) DestroyWindow(window);
}
++fenceValue; queue->Signal(fence.Get(), fenceValue);
if (fence->GetCompletedValue() < fenceValue) {
fence->SetEventOnCompletion(fenceValue, fenceEvent); WaitForSingleObject(fenceEvent, INFINITE);
fence->SetEventOnCompletion(fenceValue, fenceEvent);
if (WaitForSingleObject(fenceEvent, smoke ? 10000 : INFINITE) != WAIT_OBJECT_0) { CloseHandle(fenceEvent); return 32; }
}
CloseHandle(fenceEvent);
return 0;
return smoke && frames != 120 ? 33 : 0;
}
5 changes: 4 additions & 1 deletion Fixtures/Windows/win32-smoke.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include <windows.h>
#include <cwchar>

static LRESULT CALLBACK WindowProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam) {
if (message == WM_KEYDOWN && wparam == VK_ESCAPE) { DestroyWindow(window); return 0; }
if (message == WM_DESTROY) { PostQuitMessage(0); return 0; }
if (message == WM_TIMER && wparam == 1) { DestroyWindow(window); return 0; }
if (message == WM_PAINT) {
PAINTSTRUCT paint{};
HDC dc = BeginPaint(window, &paint);
Expand All @@ -20,14 +22,15 @@ static LRESULT CALLBACK WindowProc(HWND window, UINT message, WPARAM wparam, LPA
return DefWindowProcW(window, message, wparam, lparam);
}

int WINAPI wWinMain(HINSTANCE instance, HINSTANCE, PWSTR, int show) {
int WINAPI wWinMain(HINSTANCE instance, HINSTANCE, PWSTR commandLine, int show) {
WNDCLASSW klass{}; klass.lpfnWndProc = WindowProc; klass.hInstance = instance;
klass.lpszClassName = L"IndieSmokeFixture"; klass.hCursor = LoadCursor(nullptr, IDC_ARROW);
if (!RegisterClassW(&klass)) return 10;
HWND window = CreateWindowExW(0, klass.lpszClassName, L"Indie 兼容性测试 — 中文字体", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 800, 450, nullptr, nullptr, instance, nullptr);
if (!window) return 11;
ShowWindow(window, show);
if (std::wcscmp(commandLine, L"--smoke") == 0 && !SetTimer(window, 1, 2000, nullptr)) return 12;
MSG message{};
while (GetMessageW(&message, nullptr, 0, 0) > 0) { TranslateMessage(&message); DispatchMessageW(&message); }
return static_cast<int>(message.wParam);
Expand Down
6 changes: 4 additions & 2 deletions Sources/IndieCatalog/SteamAccountLibrary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,10 @@ public enum SteamStoreMetadataService {
.init(name: "l", value: AppLanguage.steamLanguage),
.init(name: "cc", value: "cn"),
]
guard let url = components.url,
let (data, response) = try? await session.data(from: url),
guard let url = components.url else { return nil }
var request = URLRequest(url: url)
request.timeoutInterval = 15
guard let (data, response) = try? await session.data(for: request),
(response as? HTTPURLResponse)?.statusCode == 200,
let envelope = try? IndieJSON.decoder().decode([String: StoreEnvelope].self, from: data),
let result = envelope[String(appID)], result.success, let details = result.data,
Expand Down
62 changes: 62 additions & 0 deletions Sources/IndieCatalog/SteamLibraryReader.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import Foundation

/// Serializes filesystem work away from the UI actor. Download manifests can
/// refresh frequently while account information and activity use a slower cadence.
public actor SteamLibraryReader {
public struct Snapshot: Sendable {
public let records: [SteamGame]
public let readyAppIDs: Set<UInt64>
public let accountGames: [SteamAccountGame]
public let activities: [UInt64: SteamGameActivity]
public let libraries: [SteamLibraryLocation]
}
private var root: URL?
private var lastFullRead: Date?
private var lastRecordRead: Date?
private var records: [SteamGame] = []
private var accountGames: [SteamAccountGame] = []
private var activities: [UInt64: SteamGameActivity] = [:]
private var libraries: [SteamLibraryLocation] = []

public init() {}

public func read(steamRoot: URL, bottleRoot: URL, force: Bool = false, now: Date = Date()) throws -> Snapshot {
let steamApps = steamRoot.appendingPathComponent("steamapps")
if force || root != steamRoot || lastRecordRead.map({ now.timeIntervalSince($0) >= 1 }) != false {
records = FileManager.default.fileExists(atPath: steamApps.path)
? try SteamScanner.scan(steamApps: steamApps) : []
lastRecordRead = now
}
if force || root != steamRoot || lastFullRead.map({ now.timeIntervalSince($0) >= 5 }) != false {
accountGames = try SteamAccountLibraryScanner.scan(steamRoot: steamRoot, installed: records)
activities = SteamActivityScanner.scan(steamRoot: steamRoot)
libraries = SteamLibraryLocation.load(steamRoot: steamRoot, bottleRoot: bottleRoot)
root = steamRoot
lastFullRead = now
}
// Installation readiness changes faster than the account scan cadence.
let installedIDs = Set(records.filter(\.isReadyToPlay).map(\.appID))
let games = accountGames.map {
SteamAccountGame(appID: $0.appID, name: $0.name, playtimeMinutes: $0.playtimeMinutes,
lastPlayed: $0.lastPlayed, isInstalled: installedIDs.contains($0.appID),
localArtworkDirectory: $0.localArtworkDirectory, headerImageURL: $0.headerImageURL,
description: $0.description)
}
return Snapshot(records: records, readyAppIDs: installedIDs, accountGames: games, activities: activities, libraries: libraries)
}
}

public struct SteamMetadataRetryPolicy: Sendable {
private var failures: [UInt64: (attempts: Int, retryAt: Date)] = [:]
public init() {}
public func canAttempt(_ appID: UInt64, now: Date = Date()) -> Bool {
failures[appID].map { now >= $0.retryAt } ?? true
}
public mutating func failed(_ appID: UInt64, now: Date = Date()) {
let attempts = min((failures[appID]?.attempts ?? 0) + 1, 6)
let delay = min(300.0, 10.0 * pow(2, Double(attempts - 1)))
failures[appID] = (attempts, now.addingTimeInterval(delay))
}
public mutating func succeeded(_ appID: UInt64) { failures[appID] = nil }
public mutating func reset() { failures.removeAll() }
}
35 changes: 35 additions & 0 deletions Sources/IndieCatalog/SteamStoreSearchState.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import Foundation

/// A response may update the UI only if it belongs to the active search.
public struct SteamStoreSearchState: Sendable, Equatable {
public enum Phase: Sendable, Equatable { case idle, waiting, loading, results, empty, failed(String) }
public private(set) var query = ""
public private(set) var phase: Phase = .idle
public private(set) var results: [SteamStoreItem] = []
private var requestID = UUID()
public init() {}
public var isLoading: Bool { phase == .loading }
public var completed: Bool { phase == .results || phase == .empty }
public var error: String? { if case .failed(let message) = phase { message } else { nil } }

public mutating func reset(_ query: String) {
requestID = UUID()
self.query = query.trimmingCharacters(in: .whitespacesAndNewlines)
phase = self.query.count < 2 ? .idle : .waiting
results = []
}
public mutating func begin(_ query: String) -> UUID {
reset(query)
phase = .loading
return requestID
}
public mutating func complete(_ items: [SteamStoreItem], requestID: UUID) {
guard self.requestID == requestID, phase == .loading else { return }
results = items
phase = items.isEmpty ? .empty : .results
}
public mutating func fail(_ message: String, requestID: UUID) {
guard self.requestID == requestID, phase == .loading else { return }
phase = .failed(message)
}
}
6 changes: 5 additions & 1 deletion Sources/IndieCore/Models.swift
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ public struct GameConfiguration: Codable, Hashable, Sendable, Identifiable {
public var controllerMode: ControllerMode
public var controllerRumble: Bool
public var frameInterpolation: Bool?
public var spatialAudioDiagnostics: Bool?
public var arguments: [String]
public var updatedAt: Date

Expand All @@ -340,6 +341,7 @@ public struct GameConfiguration: Codable, Hashable, Sendable, Identifiable {
controllerMode: ControllerMode = .automatic,
controllerRumble: Bool = true,
frameInterpolation: Bool? = nil,
spatialAudioDiagnostics: Bool? = nil,
arguments: [String] = [],
updatedAt: Date = Date()
) {
Expand All @@ -353,6 +355,7 @@ public struct GameConfiguration: Codable, Hashable, Sendable, Identifiable {
self.controllerMode = controllerMode
self.controllerRumble = controllerRumble
self.frameInterpolation = frameInterpolation
self.spatialAudioDiagnostics = spatialAudioDiagnostics
self.arguments = arguments
self.updatedAt = updatedAt
}
Expand All @@ -363,7 +366,8 @@ public struct GameConfiguration: Codable, Hashable, Sendable, Identifiable {
public var isCustomized: Bool {
virtualDesktop != nil || preferredRenderer != nil || syncBackend != .automatic ||
metalHUD != .inherit || metalFX != .inherit || metal4 != .inherit ||
controllerMode != .automatic || !controllerRumble || frameInterpolation == true || !arguments.isEmpty
controllerMode != .automatic || !controllerRumble || frameInterpolation == true ||
spatialAudioDiagnostics == true || !arguments.isEmpty
}
}

Expand Down
78 changes: 78 additions & 0 deletions Sources/IndieCore/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -597,3 +597,81 @@
"重试安装" = "Retry Installation";
"Steam 尚未联机,请打开 Steam 客户端恢复连接后重试" = "Steam is not connected. Open Steam to restore the connection, then retry";
"Steam 未联机" = "Steam disconnected";

"正在运行" = "Running";

"当前使用" = "Current selection";

"使用此版本" = "Use this version";

"删除 Wine 版本?" = "Delete Wine version?";

"当前使用的版本用于下一次启动;切换前请先退出游戏和 Windows Steam。删除会移到废纸篓,保留游戏和容器。" = "The selected version is used on the next launch. Quit games and Windows Steam before switching. Deleted versions move to Trash; games and bottles are kept.";

"将 %@ 移到废纸篓。游戏和容器不会被删除。" = "Move %@ to Trash. Games and bottles will be kept.";

"正在切换 Wine…" = "Switching Wine…";

"请先退出游戏和 Windows Steam,再切换 Wine" = "Quit games and Windows Steam before switching Wine";

"游戏引擎只能选择 Mac Gaming Uncle Wine 版本" = "Select a Mac Gaming Uncle Wine version for the game engine";

"Wine 已切换为 %@" = "Wine switched to %@";

"正在删除 Wine…" = "Deleting Wine…";

"请先切换到其他 Wine,再删除当前使用的版本" = "Switch to another Wine before deleting the current selection";

"Wine 已移到废纸篓,游戏和容器已保留" = "Wine moved to Trash; games and bottles kept";

"只能删除应用管理的已安装 Wine 版本" = "Only installed Wine versions managed by this app can be deleted";

"这个 Wine 仍在运行,请先退出游戏和 Windows Steam" = "This Wine is still running. Quit games and Windows Steam first";

"正在搜索 Steam 商店…" = "Searching the Steam store…";

"搜索失败" = "Search failed";

"没有找到匹配的游戏" = "No matching games";

"请输入至少两个字符" = "Enter at least two characters";

"试试游戏的英文名或更短的关键词" = "Try the English title or a shorter search term";

"即将搜索…" = "Search starting…";

"返回精选" = "Back to featured";

"精选游戏" = "Featured games";

"没有匹配的游戏" = "No matching games";

"调整搜索关键词或筛选条件" = "Change your search or filters";

"显示全部游戏" = "Show all games";

"正在补全游戏名称与封面…" = "Loading game names and artwork…";

"兼容性需实测" = "Compatibility needs testing";

"Steam 已连接" = "Steam connected";

"在 Steam 中获取" = "Get it in Steam";

"上一组游戏" = "Previous games";

"下一组游戏" = "Next games";

"你的游戏" = "Your games";

"商店分类" = "Store category";

"清除搜索" = "Clear search";

"游戏库筛选" = "Library filter";

"最小化窗口" = "Minimize Window";

"最大化或恢复窗口" = "Zoom / Restore Window";

"进入或退出全屏" = "Enter / Exit Full Screen";
Loading