feat(multiplayer)#1579
Draft
icgnos wants to merge 14 commits into
Draft
Conversation
modified: src-tauri/src/multiplayer/helpers/terracotta.rs new file: src-tauri/target-codex-checkkzyTw1/CACHEDIR.TAG new file: src/components/modals/multiplayer-modal.tsx modified: src/components/special/shared-modals-provider.tsx modified: src/global.d.ts modified: src/locales/en.json modified: src/locales/zh-Hans.json modified: src/pages/launch.tsx new file: src/services/multiplayer.ts modified: src/styles/launch.module.css new file: target-codex-checkC3WPzf/CACHEDIR.TAG
modified: src-tauri/src/multiplayer/helpers/terracotta.rs modified: src/components/modals/multiplayer-modal.tsx modified: src/locales/en.json modified: src/locales/zh-Hans.json modified: src/services/multiplayer.ts
…nd decompression improvements
…player functionality
Contributor
Reviewer's GuideIntroduce a Terracotta-based multiplayer feature, including frontend UI to host/join rooms, a new multiplayer modal and service, and backend Tauri commands and resource plumbing to download, unpack, and launch the Terracotta binary with task monitoring. Sequence diagram for hosting a Terracotta multiplayer roomsequenceDiagram
actor User
participant LaunchPage
participant MultiplayerModal
participant MultiplayerService
participant TauriBackend
participant TaskMonitor
participant TerracottaBinary
User->>LaunchPage: Click multiplayer button
LaunchPage->>MultiplayerService: checkPlatformSupport()
MultiplayerService-->>LaunchPage: InvokeResponse<boolean>
LaunchPage->>MultiplayerModal: openSharedModal(multiplayer)
Note over MultiplayerModal,TauriBackend: Core not installed path
MultiplayerModal->>MultiplayerService: downloadTerracotta()
MultiplayerService->>TauriBackend: invoke download_terracotta
TauriBackend->>TauriBackend: build_download_param()
TauriBackend->>TaskMonitor: schedule_progressive_task_group("terracotta")
TaskMonitor-->>TauriBackend: task_group_id
TauriBackend->>TaskMonitor: wait_for_task_group(task_group_id)
TaskMonitor-->>TauriBackend: Completed or error
TauriBackend->>TauriBackend: decompress() terracotta archive
TauriBackend-->>MultiplayerService: success
MultiplayerService-->>MultiplayerModal: success
Note over MultiplayerModal,TerracottaBinary: Host creates room
User->>MultiplayerModal: Click create room
MultiplayerModal->>MultiplayerService: launchTerracotta()
MultiplayerService->>TauriBackend: invoke launch_terracotta
TauriBackend->>TerracottaBinary: spawn --hmcl <temp_path>
TauriBackend-->>MultiplayerService: success
MultiplayerService-->>MultiplayerModal: success
TerracottaBinary->>TauriBackend: write port file sjmcl-terracotta
MultiplayerModal->>MultiplayerService: fetchPort()
MultiplayerService->>TauriBackend: invoke fetch_port
TauriBackend-->>MultiplayerService: port
MultiplayerService-->>MultiplayerModal: port
loop Poll Terracotta state
MultiplayerModal->>TerracottaBinary: HTTP GET /state
TerracottaBinary-->>MultiplayerModal: JSON { room, profiles, state }
end
MultiplayerModal-->>User: Show invite code and joined profiles
Class diagram for multiplayer-related frontend and backend typesclassDiagram
class MultiplayerService {
<<TypeScript_class>>
+static checkPlatformSupport() InvokeResponse~boolean~
+static checkTerracotta() InvokeResponse~boolean~
+static launchTerracotta() InvokeResponse~void~
+static downloadTerracotta() InvokeResponse~void~
+static fetchPort() InvokeResponse~number~
}
class MultiplayerModal {
<<React_Component>>
-Phase phase
-number port
-string generatedInviteCode
-boolean isDownloading
-number errorType
-string difficulty
-Profile[] profiles
-boolean isJoinDialogOpen
-string joinCode
-boolean isJoining
+handleCreateRoom()
+handleDownloadTerracotta()
+handleJoinRoomConfirm()
+handleReconnect()
+handleReturnToLobby()
+handleCopyInviteCode()
}
class MultiplayerActionButton {
<<React_Component>>
+icon IconType
+imageSrc string
+title string
}
class Phase {
<<TypeScript_union>>
checking
notDownloaded
ready
scanning
roomStarted
guestStarting
guestOk
error
disconnected
}
class MultiplayerError {
<<Rust_enum>>
+ExecutableNotFound
+PortFileNotFound
+CompressedFileNotFound
}
class ResourceType {
<<Rust_enum>>
+Terracotta
..existing_variants..
}
class TerracottaHelpers {
<<Rust_module>>
+build_download_param(app AppHandle) SJMCLResult~Vec~PTaskParam~~
+decompress(app AppHandle) SJMCLResult~()~
}
class MultiplayerCommands {
<<Rust_module>>
+check_terracotta(app AppHandle) SJMCLResult~bool~
+launch_terracotta(app AppHandle) SJMCLResult~()~
+download_terracotta(app AppHandle) SJMCLResult~()~
+fetch_port(app AppHandle) SJMCLResult~u16~
}
class TaskMonitor {
<<Rust_struct>>
+wait_for_task_group(task_group &str) SJMCLResult~()~
..existing_methods..
}
class DownloadParam {
<<Rust_struct>>
+src Url
+dest PathBuf
+filename Option~String~
+sha1 Option~String~
}
class PTaskParam {
<<Rust_enum>>
+Download(DownloadParam)
..other_variants..
}
MultiplayerModal --> MultiplayerService : uses
MultiplayerModal --> Phase : state
MultiplayerModal --> MultiplayerActionButton : composes
MultiplayerService --> MultiplayerCommands : invokes_via_Tauri
MultiplayerCommands --> TerracottaHelpers : calls
TerracottaHelpers --> ResourceType : uses
MultiplayerCommands --> TaskMonitor : schedules_and_waits
PTaskParam --> DownloadParam : contains
TerracottaHelpers --> PTaskParam : returns
MultiplayerCommands --> MultiplayerError : returns_error
TerracottaHelpers --> MultiplayerError : returns_error
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
This PR is a ..
Related Issues
Description
Additional Context
Summary by Sourcery
Add Terracotta-based multiplayer support with a new launcher UI entry point and Tauri backend integration for downloading, launching, and managing the external multiplayer core.
New Features:
Enhancements:
Build: