diff --git a/CHANGELOG.md b/CHANGELOG.md index b20ae0d6..211906fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Rojo Changelog ## Unreleased Changes +* Added the `gameId` and `placeId` optional properties to project files. + * When connecting from the Rojo Roblox Studio plugin, Rojo will set the game and place ID of the current place to these values, if set. + * This is equivalent to running `game:SetUniverseId(...)` and `game:SetPlaceId(...)` from the command bar in Studio. ## [7.0.0-alpha.3][7.0.0-alpha.3] (February 19, 2021) * Updated dependencies, fixing `OptionalCoordinateFrame`-related issues. diff --git a/plugin/src/ServeSession.lua b/plugin/src/ServeSession.lua index 9e06065f..e8ab1e45 100644 --- a/plugin/src/ServeSession.lua +++ b/plugin/src/ServeSession.lua @@ -111,6 +111,7 @@ function ServeSession:start() self.__apiContext:connect() :andThen(function(serverInfo) self:__setStatus(Status.Connected, serverInfo.projectName) + self:__applyGameAndPlaceId(serverInfo) local rootInstanceId = serverInfo.rootInstanceId @@ -128,6 +129,16 @@ function ServeSession:stop() self:__stopInternal() end +function ServeSession:__applyGameAndPlaceId(serverInfo) + if serverInfo.gameId ~= nil then + game:SetUniverseId(serverInfo.gameId) + end + + if serverInfo.placeId ~= nil then + game:SetPlaceId(serverInfo.placeId) + end +end + function ServeSession:__onActiveScriptChanged(activeScript) if not self.__openScriptsExternally then Log.trace("Not opening script {} because feature not enabled.", activeScript) diff --git a/src/project.rs b/src/project.rs index 438f3210..9cc0d5de 100644 --- a/src/project.rs +++ b/src/project.rs @@ -57,6 +57,14 @@ pub struct Project { #[serde(skip_serializing_if = "Option::is_none")] pub serve_place_ids: Option>, + /// If specified, sets the current place's place ID when connecting to the + /// Rojo server from Roblox Studio. + pub place_id: Option, + + /// If specified, sets the current place's game ID when connecting to the + /// Rojo server from Roblox Studio. + pub game_id: Option, + /// A list of globs, relative to the folder the project file is in, that /// match files that should be excluded if Rojo encounters them. #[serde(default, skip_serializing_if = "Vec::is_empty")] diff --git a/src/serve_session.rs b/src/serve_session.rs index aec152d0..575bc54b 100644 --- a/src/serve_session.rs +++ b/src/serve_session.rs @@ -195,6 +195,14 @@ impl ServeSession { self.root_project.serve_port } + pub fn place_id(&self) -> Option { + self.root_project.place_id + } + + pub fn game_id(&self) -> Option { + self.root_project.game_id + } + pub fn start_time(&self) -> Instant { self.start_time } diff --git a/src/web/api.rs b/src/web/api.rs index 6a41f2e5..4038943a 100644 --- a/src/web/api.rs +++ b/src/web/api.rs @@ -69,6 +69,8 @@ impl ApiService { session_id: self.serve_session.session_id(), project_name: self.serve_session.project_name().to_owned(), expected_place_ids: self.serve_session.serve_place_ids().cloned(), + place_id: self.serve_session.place_id(), + game_id: self.serve_session.game_id(), root_instance_id, }) } diff --git a/src/web/interface.rs b/src/web/interface.rs index df4ba9ae..403592ea 100644 --- a/src/web/interface.rs +++ b/src/web/interface.rs @@ -104,6 +104,8 @@ pub struct ServerInfoResponse { pub protocol_version: u64, pub project_name: String, pub expected_place_ids: Option>, + pub game_id: Option, + pub place_id: Option, pub root_instance_id: Ref, }