-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Server status, selector on assets, etc.
- Loading branch information
Showing
8 changed files
with
179 additions
and
70 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2020-2023 CesiumGS, Inc. and Contributors | ||
|
||
#include "CesiumServerSelector.h" | ||
#include "CesiumEditor.h" | ||
#include "CesiumIonServer.h" | ||
|
||
void CesiumServerSelector::Construct(const FArguments& InArgs) { | ||
ChildSlot | ||
[SNew(SComboBox<TObjectPtr<UCesiumIonServer>>) | ||
.OptionsSource(&FCesiumEditorModule::serverManager().GetServerList()) | ||
.OnGenerateWidget(this, &CesiumServerSelector::OnGenerateServerEntry) | ||
.OnSelectionChanged( | ||
this, | ||
&CesiumServerSelector::OnServerSelectionChanged) | ||
.Content() | ||
[SNew(STextBlock) | ||
.Text(this, &CesiumServerSelector::GetServerValueAsText)]]; | ||
} | ||
|
||
namespace { | ||
|
||
FText GetNameFromCesiumIonServerAsset( | ||
const TObjectPtr<UCesiumIonServer>& pServer) { | ||
if (!pServer) | ||
return FText::FromString("Error: No Cesium ion server configured."); | ||
|
||
std::shared_ptr<CesiumIonSession> pSession = | ||
FCesiumEditorModule::serverManager().GetSession(pServer); | ||
|
||
FString prefix; | ||
FString suffix; | ||
|
||
if (pSession->isConnecting() || pSession->isResuming()) { | ||
suffix = " (connecting...)"; | ||
} else if (pSession->isLoadingProfile()) { | ||
suffix = " (loading profile...)"; | ||
} else if (pSession->isConnected() && pSession->isProfileLoaded()) { | ||
prefix = FString(UTF8_TO_TCHAR(pSession->getProfile().username.c_str())); | ||
prefix += " @ "; | ||
} else { | ||
suffix = " (not connected)"; | ||
} | ||
|
||
return FText::FromString( | ||
prefix + | ||
(pServer->DisplayName.IsEmpty() ? pServer->GetPackage()->GetName() | ||
: pServer->DisplayName) + | ||
suffix); | ||
} | ||
|
||
} // namespace | ||
|
||
FText CesiumServerSelector::GetServerValueAsText() const { | ||
UCesiumIonServer* pServer = FCesiumEditorModule::serverManager().GetCurrent(); | ||
return GetNameFromCesiumIonServerAsset(pServer); | ||
} | ||
|
||
TSharedRef<SWidget> CesiumServerSelector::OnGenerateServerEntry( | ||
TObjectPtr<UCesiumIonServer> pServerAsset) { | ||
return SNew(STextBlock).Text_Lambda([pServerAsset]() { | ||
return GetNameFromCesiumIonServerAsset(pServerAsset); | ||
}); | ||
} | ||
|
||
void CesiumServerSelector::OnServerSelectionChanged( | ||
TObjectPtr<UCesiumIonServer> InItem, | ||
ESelectInfo::Type InSeletionInfo) { | ||
FCesiumEditorModule::serverManager().SetCurrent(InItem); | ||
FCesiumEditorModule::serverManager().GetCurrentSession()->resume(); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2020-2023 CesiumGS, Inc. and Contributors | ||
|
||
#pragma once | ||
|
||
#include "Widgets/SCompoundWidget.h" | ||
|
||
class FArguments; | ||
class UCesiumIonServer; | ||
|
||
class CesiumServerSelector : public SCompoundWidget { | ||
SLATE_BEGIN_ARGS(CesiumServerSelector) {} | ||
SLATE_END_ARGS() | ||
|
||
void Construct(const FArguments& InArgs); | ||
|
||
private: | ||
TSharedRef<SWidget> | ||
OnGenerateServerEntry(TObjectPtr<UCesiumIonServer> pServer); | ||
|
||
FText GetServerValueAsText() const; | ||
|
||
void OnServerSelectionChanged( | ||
TObjectPtr<UCesiumIonServer> InItem, | ||
ESelectInfo::Type InSeletionInfo); | ||
}; |