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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/opensb/scripts/opensb/assets/postload.lua22
-rw-r--r--assets/opensb/scripts/opensb/player/commands.lua11
-rw-r--r--assets/opensb/scripts/opensb/player/copy_paste.lua18
-rw-r--r--source/application/StarMainApplication_sdl.cpp2
-rw-r--r--source/base/StarAssets.cpp12
-rw-r--r--source/base/StarAssets.hpp2
-rw-r--r--source/core/scripting/StarUtilityLuaBindings.cpp1
-rw-r--r--source/frontend/StarClientCommandProcessor.cpp6
-rw-r--r--source/frontend/StarClientCommandProcessor.hpp1
-rw-r--r--source/frontend/StarInventory.cpp7
-rw-r--r--source/game/StarPlayer.cpp2
-rw-r--r--source/game/StarRoot.cpp5
-rw-r--r--source/game/StarRoot.hpp2
-rw-r--r--source/game/StarStatusController.cpp5
14 files changed, 86 insertions, 10 deletions
diff --git a/assets/opensb/scripts/opensb/assets/postload.lua b/assets/opensb/scripts/opensb/assets/postload.lua
index 256e199..0110bc1 100644
--- a/assets/opensb/scripts/opensb/assets/postload.lua
+++ b/assets/opensb/scripts/opensb/assets/postload.lua
@@ -29,4 +29,24 @@ end
assets.patch(
"/interface/windowconfig/songbook.config",
"/interface/windowconfig/songbook_search_patch.lua"
-) \ No newline at end of file
+)
+
+
+-- Relocate songs to the /songs/ folder
+
+local songs = assets.byExtension("abc")
+local count = 0
+
+for i = 1, #songs do
+ local song = songs[i]
+ if song:sub(1, 7) ~= "/songs/" then
+ local data = assets.bytes(song)
+ assets.erase(song)
+ assets.add("/songs" .. song, data)
+ count = count + 1
+ end
+end
+
+if count > 0 then
+ sb.logInfo("Moved %s misplaced songs to /songs/", count)
+end \ No newline at end of file
diff --git a/assets/opensb/scripts/opensb/player/commands.lua b/assets/opensb/scripts/opensb/player/commands.lua
index 9696e0d..2d83106 100644
--- a/assets/opensb/scripts/opensb/player/commands.lua
+++ b/assets/opensb/scripts/opensb/player/commands.lua
@@ -36,4 +36,15 @@ register("run", function(src)
end
end)
+register("headrotation", function(arg)
+ local key = "disableHeadRotation"
+ if status.statusProperty(key) == true then
+ status.setStatusProperty(key, nil)
+ return "Head rotation is now enabled for this character"
+ else
+ status.setStatusProperty(key, true)
+ return "Head rotation is now disabled for this character"
+ end
+end)
+
module.register = register \ No newline at end of file
diff --git a/assets/opensb/scripts/opensb/player/copy_paste.lua b/assets/opensb/scripts/opensb/player/copy_paste.lua
index 2a15af4..f301427 100644
--- a/assets/opensb/scripts/opensb/player/copy_paste.lua
+++ b/assets/opensb/scripts/opensb/player/copy_paste.lua
@@ -24,13 +24,18 @@ local function copyItem()
local item = player.swapSlotItem() or player.primaryHandItem() or player.altHandItem()
if not item then return end
- clipboard.setText(sb.printJson(item, 2))
- local message = string.format("Copied ^cyan;%s^reset; to clipboard", getItemName(item))
+ local message = "^#f00;Failed to write to clipboard^reset;"
+ if clipboard.setText(sb.printJson(item, 2)) then
+ message = string.format("Copied ^cyan;%s^reset; to clipboard", getItemName(item))
+ end
interface.queueMessage(message, 4, 0.5)
end
local function pasteItem()
- if player.swapSlotItem() then return end
+ if not clipboard.available() then
+ return interface.queueMessage("^#f00;Clipboard unavailable^reset;", 4, 0.5)
+ end
+ local swap = player.swapSlotItem()
local data = getClipboardText()
if not data then return end
@@ -38,6 +43,13 @@ local function pasteItem()
if not success then
popupError("Error parsing clipboard item", result)
else
+ if swap then
+ if swap.name == result.name and sb.jsonEqual(swap.parameters, result.parameters) then
+ result.count = (tonumber(result.count) or 1) + (tonumber(swap.count) or 1)
+ else
+ return interface.queueMessage("^#f00;Cursor is occupied^reset;", 4, 0.5)
+ end
+ end
local success, err = pcall(player.setSwapSlotItem, result)
if not success then popupError("Error loading clipboard item", err)
else
diff --git a/source/application/StarMainApplication_sdl.cpp b/source/application/StarMainApplication_sdl.cpp
index e0dfd37..c3ffbf0 100644
--- a/source/application/StarMainApplication_sdl.cpp
+++ b/source/application/StarMainApplication_sdl.cpp
@@ -522,7 +522,7 @@ private:
}
bool isFocused() const override {
- return (SDL_GetWindowFlags(parent->m_sdlWindow) & (SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS)) != 0;
+ return (SDL_GetWindowFlags(parent->m_sdlWindow) & SDL_WINDOW_INPUT_FOCUS) != 0;
}
void setTargetUpdateRate(float targetUpdateRate) override {
diff --git a/source/base/StarAssets.cpp b/source/base/StarAssets.cpp
index ecd2068..7db8efe 100644
--- a/source/base/StarAssets.cpp
+++ b/source/base/StarAssets.cpp
@@ -348,6 +348,13 @@ Assets::~Assets() {
m_workerThreads.clear();
}
+void Assets::hotReload() const {
+ MutexLocker assetsLocker(m_assetsMutex);
+ m_assetsCache.clear();
+ m_queue.clear();
+ m_framesSpecifications.clear();
+}
+
StringList Assets::assetSources() const {
MutexLocker assetsLocker(m_assetsMutex);
return m_assetSources;
@@ -779,6 +786,11 @@ void Assets::workerMain() {
if (m_stopThreads)
break;
+ {
+ RecursiveMutexLocker luaLocker(m_luaMutex);
+ as<LuaEngine>(m_luaEngine.get())->collectGarbage();
+ }
+
MutexLocker assetsLocker(m_assetsMutex);
AssetId assetId;
diff --git a/source/base/StarAssets.hpp b/source/base/StarAssets.hpp
index e7b8611..6ffcb05 100644
--- a/source/base/StarAssets.hpp
+++ b/source/base/StarAssets.hpp
@@ -161,6 +161,8 @@ public:
Assets(Settings settings, StringList assetSources);
~Assets();
+ void hotReload() const;
+
// Returns a list of all the asset source paths used by Assets in load order.
StringList assetSources() const;
diff --git a/source/core/scripting/StarUtilityLuaBindings.cpp b/source/core/scripting/StarUtilityLuaBindings.cpp
index 98ad239..8fb65cc 100644
--- a/source/core/scripting/StarUtilityLuaBindings.cpp
+++ b/source/core/scripting/StarUtilityLuaBindings.cpp
@@ -120,6 +120,7 @@ LuaCallbacks LuaBindings::makeUtilityCallbacks() {
callbacks.registerCallback("replaceTags", UtilityCallbacks::replaceTags);
callbacks.registerCallback("parseJsonSequence", [](String const& json) { return Json::parseSequence(json); });
callbacks.registerCallback("jsonMerge", [](Json const& a, Json const& b) { return jsonMerge(a, b); });
+ callbacks.registerCallback("jsonEqual", [](Json const& a, Json const& b) { return a == b; });
callbacks.registerCallback("jsonQuery", [](Json const& json, String const& path, Json const& def) { return json.query(path, def); });
callbacks.registerCallback("makeRandomSource", [](Maybe<uint64_t> seed) { return seed ? RandomSource(*seed) : RandomSource(); });
callbacks.registerCallback("makePerlinSource", [](Json const& config) { return PerlinF(config); });
diff --git a/source/frontend/StarClientCommandProcessor.cpp b/source/frontend/StarClientCommandProcessor.cpp
index 7671a00..c19c68f 100644
--- a/source/frontend/StarClientCommandProcessor.cpp
+++ b/source/frontend/StarClientCommandProcessor.cpp
@@ -20,6 +20,7 @@ ClientCommandProcessor::ClientCommandProcessor(UniverseClientPtr universeClient,
m_paneManager(paneManager), m_macroCommands(std::move(macroCommands)) {
m_builtinCommands = {
{"reload", bind(&ClientCommandProcessor::reload, this)},
+ {"hotReload", bind(&ClientCommandProcessor::hotReload, this)},
{"whoami", bind(&ClientCommandProcessor::whoami, this)},
{"gravity", bind(&ClientCommandProcessor::gravity, this)},
{"debug", bind(&ClientCommandProcessor::debug, this, _1)},
@@ -128,6 +129,11 @@ String ClientCommandProcessor::reload() {
return "Client Star::Root reloaded";
}
+String ClientCommandProcessor::hotReload() {
+ Root::singleton().hotReload();
+ return "Hot-reloaded assets";
+}
+
String ClientCommandProcessor::whoami() {
return strf("Client: You are {}. You are {}an Admin.",
m_universeClient->mainPlayer()->name(), m_universeClient->mainPlayer()->isAdmin() ? "" : "not ");
diff --git a/source/frontend/StarClientCommandProcessor.hpp b/source/frontend/StarClientCommandProcessor.hpp
index c3978a4..df60b96 100644
--- a/source/frontend/StarClientCommandProcessor.hpp
+++ b/source/frontend/StarClientCommandProcessor.hpp
@@ -26,6 +26,7 @@ private:
String previewQuestPane(StringList const& arguments, function<PanePtr(QuestPtr)> createPane);
String reload();
+ String hotReload();
String whoami();
String gravity();
String debug(String const& argumentsString);
diff --git a/source/frontend/StarInventory.cpp b/source/frontend/StarInventory.cpp
index 3730c9b..1c42a0d 100644
--- a/source/frontend/StarInventory.cpp
+++ b/source/frontend/StarInventory.cpp
@@ -450,12 +450,13 @@ void InventoryPane::update(float dt) {
}
if (auto item = inventory->swapSlotItem()) {
+ float pitch = 1.f - ((float)item->count() / (float)item->maxStack()) * .2f;
if (!m_currentSwapSlotItem || !item->matches(*m_currentSwapSlotItem, true))
- context->playAudio(RandomSource().randFrom(m_pickUpSounds));
+ context->playAudio(RandomSource().randFrom(m_pickUpSounds), 0, 1.f, pitch);
else if (item->count() > m_currentSwapSlotItem->count())
- context->playAudio(RandomSource().randFrom(m_someUpSounds));
+ context->playAudio(RandomSource().randFrom(m_someUpSounds), 0, 1.f, pitch);
else if (item->count() < m_currentSwapSlotItem->count())
- context->playAudio(RandomSource().randFrom(m_someDownSounds));
+ context->playAudio(RandomSource().randFrom(m_someDownSounds), 0, 1.f, pitch);
m_currentSwapSlotItem = item->descriptor();
} else {
diff --git a/source/game/StarPlayer.cpp b/source/game/StarPlayer.cpp
index c094bbb..af85cce 100644
--- a/source/game/StarPlayer.cpp
+++ b/source/game/StarPlayer.cpp
@@ -1086,7 +1086,7 @@ void Player::update(float dt, uint64_t) {
}
if (calculateHeadRotation) { // master or not an OpenStarbound player
float headRotation = 0.f;
- if (m_humanoid->primaryHandHoldingItem() || m_humanoid->altHandHoldingItem() || m_humanoid->dance()) {
+ if (Humanoid::globalHeadRotation() && (m_humanoid->primaryHandHoldingItem() || m_humanoid->altHandHoldingItem() || m_humanoid->dance())) {
auto primary = m_tools->primaryHandItem();
auto alt = m_tools->altHandItem();
String const disableFlag = "disableHeadRotation";
diff --git a/source/game/StarRoot.cpp b/source/game/StarRoot.cpp
index fbf818f..e429646 100644
--- a/source/game/StarRoot.cpp
+++ b/source/game/StarRoot.cpp
@@ -371,6 +371,11 @@ void Root::registerReloadListener(ListenerWeakPtr reloadListener) {
m_reloadListeners.addListener(std::move(reloadListener));
}
+void Root::hotReload() {
+ assets()->hotReload();
+ m_reloadListeners.trigger();
+}
+
String Root::toStoragePath(String const& path) const {
return File::relativeTo(m_settings.storageDirectory, File::convertDirSeparators(path));
}
diff --git a/source/game/StarRoot.hpp b/source/game/StarRoot.hpp
index 2079a5e..4659488 100644
--- a/source/game/StarRoot.hpp
+++ b/source/game/StarRoot.hpp
@@ -131,6 +131,8 @@ public:
// the internal listener list.
void registerReloadListener(ListenerWeakPtr reloadListener);
+ void hotReload();
+
// Translates the given path to be relative to the configured storage
// location.
String toStoragePath(String const& path) const;
diff --git a/source/game/StarStatusController.cpp b/source/game/StarStatusController.cpp
index 26c83d0..d6635b6 100644
--- a/source/game/StarStatusController.cpp
+++ b/source/game/StarStatusController.cpp
@@ -132,7 +132,10 @@ Json StatusController::statusProperty(String const& name, Json const& def) const
}
void StatusController::setStatusProperty(String const& name, Json value) {
- m_statusProperties.set(name, value);
+ if (value.isNull())
+ m_statusProperties.remove(name);
+ else
+ m_statusProperties.set(name, value);
}
StringList StatusController::statNames() const {