Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/base/StarConfiguration.cpp8
-rw-r--r--source/base/StarConfiguration.hpp4
-rw-r--r--source/frontend/StarCharSelection.cpp14
-rw-r--r--source/frontend/StarCharSelection.hpp2
-rw-r--r--source/frontend/StarMainInterface.cpp22
-rw-r--r--source/windowing/StarLargeCharPlateWidget.cpp2
6 files changed, 37 insertions, 15 deletions
diff --git a/source/base/StarConfiguration.cpp b/source/base/StarConfiguration.cpp
index 89ec7fa..1d888a0 100644
--- a/source/base/StarConfiguration.cpp
+++ b/source/base/StarConfiguration.cpp
@@ -21,14 +21,14 @@ String Configuration::printConfiguration() const {
return m_currentConfig.printJson(2, true);
}
-Json Configuration::get(String const& key) const {
+Json Configuration::get(String const& key, Json def) const {
MutexLocker locker(m_mutex);
- return m_currentConfig.get(key, {});
+ return m_currentConfig.get(key, def);
}
-Json Configuration::getPath(String const& path) const {
+Json Configuration::getPath(String const& path, Json def) const {
MutexLocker locker(m_mutex);
- return m_currentConfig.query(path, {});
+ return m_currentConfig.query(path, def);
}
Json Configuration::getDefault(String const& key) const {
diff --git a/source/base/StarConfiguration.hpp b/source/base/StarConfiguration.hpp
index ffa66c3..4f5d97c 100644
--- a/source/base/StarConfiguration.hpp
+++ b/source/base/StarConfiguration.hpp
@@ -18,8 +18,8 @@ public:
Json currentConfiguration() const;
String printConfiguration() const;
- Json get(String const& key) const;
- Json getPath(String const& path) const;
+ Json get(String const& key, Json def = {}) const;
+ Json getPath(String const& path, Json def = {}) const;
Json getDefault(String const& key) const;
Json getDefaultPath(String const& path) const;
diff --git a/source/frontend/StarCharSelection.cpp b/source/frontend/StarCharSelection.cpp
index 6cbfb9b..6a61dcf 100644
--- a/source/frontend/StarCharSelection.cpp
+++ b/source/frontend/StarCharSelection.cpp
@@ -37,8 +37,7 @@ CharSelectionPane::CharSelectionPane(PlayerStoragePtr playerStorage,
updateCharacterPlates();
});
guiReader.registerCallback("clearSearch", [=](Widget*) {
- auto searchCharacter = fetchChild<TextBoxWidget>("searchCharacter");
- searchCharacter->setText("");
+ fetchChild<TextBoxWidget>("searchCharacter")->setText("");
});
guiReader.construct(root.assets()->json("/interface/windowconfig/charselection.config"), this);
@@ -63,6 +62,7 @@ void CharSelectionPane::show() {
Pane::show();
m_downScroll = 0;
+ fetchChild<TextBoxWidget>("searchCharacter")->setText("");
updateCharacterPlates();
}
@@ -96,14 +96,18 @@ void CharSelectionPane::updateCharacterPlates() {
if (m_filteredList.size() > 0 && scrollPosition < m_filteredList.size()) {
auto playerUuid = m_filteredList.get(scrollPosition);
if (auto player = m_playerStorage->loadPlayer(playerUuid)) {
+ charSelector->show();
player->humanoid()->setFacingDirection(Direction::Right);
charSelector->setPlayer(player);
- charSelector->enableDelete([this, playerUuid](Widget*) { m_deleteCallback(playerUuid); });
+ if (!m_readOnly)
+ charSelector->enableDelete([this, playerUuid](Widget*) { m_deleteCallback(playerUuid); });
return;
}
}
charSelector->setPlayer(PlayerPtr());
charSelector->disableDelete();
+ if (m_readOnly)
+ charSelector->hide();
};
updatePlayerLine("charSelector1", m_downScroll + 0);
@@ -122,4 +126,8 @@ void CharSelectionPane::updateCharacterPlates() {
fetchChild("playerDownButton")->hide();
}
+void CharSelectionPane::setReadOnly(bool readOnly) {
+ findChild("createCharButton")->setVisibility(!(m_readOnly = readOnly));
+}
+
}
diff --git a/source/frontend/StarCharSelection.hpp b/source/frontend/StarCharSelection.hpp
index b4837ca..eb4d906 100644
--- a/source/frontend/StarCharSelection.hpp
+++ b/source/frontend/StarCharSelection.hpp
@@ -19,6 +19,7 @@ public:
bool sendEvent(InputEvent const& event) override;
void show() override;
void updateCharacterPlates();
+ void setReadOnly(bool readOnly);
private:
void shiftCharacters(int movement);
@@ -28,6 +29,7 @@ private:
unsigned m_downScroll;
String m_search;
List<Uuid> m_filteredList;
+ bool m_readOnly = false;
CreateCharCallback m_createCallback;
SelectCharacterCallback m_selectCallback;
diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp
index 320cd4f..2b2bb5f 100644
--- a/source/frontend/StarMainInterface.cpp
+++ b/source/frontend/StarMainInterface.cpp
@@ -169,11 +169,23 @@ MainInterface::MainInterface(UniverseClientPtr client, WorldPainterPtr painter,
planetName->addChild("planetText", m_planetText);
m_paneManager.registerPane(MainInterfacePanes::PlanetText, PaneLayer::Hud, planetName);
- auto charSelectionMenu = make_shared<CharSelectionPane>(m_client->playerStorage(), [=]() {}, [=](PlayerPtr mainPlayer) {
- m_client->playerStorage()->moveToFront(mainPlayer->uuid());
- m_client->switchPlayer(mainPlayer->uuid());
- m_paneManager.dismissRegisteredPane(MainInterfacePanes::CharacterSwap); }, [=](Uuid) {});
- charSelectionMenu->setAnchor(PaneAnchor::Center);
+ auto charSelectionMenu = make_shared<CharSelectionPane>(m_client->playerStorage(), [=]() {},
+ [=](PlayerPtr mainPlayer) {
+ auto configuration = Root::singleton().configuration();
+ if (configuration->get("characterSwapMovesToFront", false).toBool())
+ m_client->playerStorage()->moveToFront(mainPlayer->uuid());
+ if (configuration->get("characterSwapDismisses", false).toBool())
+ m_paneManager.dismissRegisteredPane(MainInterfacePanes::CharacterSwap);
+ m_client->switchPlayer(mainPlayer->uuid());
+ }, [=](Uuid) {});
+ {
+ charSelectionMenu->setReadOnly(true);
+ charSelectionMenu->setAnchor(PaneAnchor::Center);
+ charSelectionMenu->unlockPosition();
+ auto backgrounds = charSelectionMenu->getBG();
+ backgrounds.header = std::move(backgrounds.body);
+ charSelectionMenu->setBG(backgrounds);
+ }
m_paneManager.registerPane(MainInterfacePanes::CharacterSwap, PaneLayer::ModalWindow, charSelectionMenu);
diff --git a/source/windowing/StarLargeCharPlateWidget.cpp b/source/windowing/StarLargeCharPlateWidget.cpp
index 5088f73..eb6c438 100644
--- a/source/windowing/StarLargeCharPlateWidget.cpp
+++ b/source/windowing/StarLargeCharPlateWidget.cpp
@@ -171,7 +171,7 @@ void LargeCharPlateWidget::update(float dt) {
return;
auto humanoid = m_player->humanoid();
- if (m_delete->isHovered()) {
+ if (m_delete && m_delete->isHovered()) {
humanoid->setEmoteState(HumanoidEmote::Sad);
humanoid->setState(Humanoid::Run);
} else {