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

summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/client/CMakeLists.txt4
-rw-r--r--source/client/StarClientApplication.cpp55
-rw-r--r--source/client/StarClientApplication.hpp11
-rw-r--r--source/client/StarRenderingLuaBindings.cpp21
-rw-r--r--source/client/StarRenderingLuaBindings.hpp13
-rw-r--r--source/frontend/CMakeLists.txt4
-rw-r--r--source/frontend/StarGraphicsMenu.cpp18
-rw-r--r--source/frontend/StarGraphicsMenu.hpp10
-rw-r--r--source/frontend/StarMainInterface.cpp4
-rw-r--r--source/frontend/StarOptionsMenu.cpp4
-rw-r--r--source/frontend/StarOptionsMenu.hpp3
-rw-r--r--source/frontend/StarShadersMenu.cpp22
-rw-r--r--source/frontend/StarShadersMenu.hpp22
-rw-r--r--source/frontend/StarTitleScreen.cpp8
-rw-r--r--source/frontend/StarTitleScreen.hpp5
15 files changed, 181 insertions, 23 deletions
diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt
index 57b8231..a6773d3 100644
--- a/source/client/CMakeLists.txt
+++ b/source/client/CMakeLists.txt
@@ -12,10 +12,12 @@ INCLUDE_DIRECTORIES (
SET (star_client_HEADERS
StarClientApplication.hpp
+ StarRenderingLuaBindings.hpp
)
SET (star_client_SOURCES
StarClientApplication.cpp
+ StarRenderingLuaBindings.cpp
)
IF (STAR_SYSTEM_WINDOWS)
@@ -37,4 +39,4 @@ IF(UNIX)
set_target_properties (starbound PROPERTIES LINK_FLAGS "-Wl,-rpath,'$ORIGIN'")
ENDIF()
-TARGET_LINK_LIBRARIES (starbound ${STAR_EXT_LIBS} ${STAR_EXT_GUI_LIBS}) \ No newline at end of file
+TARGET_LINK_LIBRARIES (starbound ${STAR_EXT_LIBS} ${STAR_EXT_GUI_LIBS})
diff --git a/source/client/StarClientApplication.cpp b/source/client/StarClientApplication.cpp
index 71bec5d..09ebf0c 100644
--- a/source/client/StarClientApplication.cpp
+++ b/source/client/StarClientApplication.cpp
@@ -24,6 +24,7 @@
#include "StarVoiceLuaBindings.hpp"
#include "StarCameraLuaBindings.hpp"
#include "StarClipboardLuaBindings.hpp"
+#include "StarRenderingLuaBindings.hpp"
#if defined STAR_SYSTEM_WINDOWS
#include <windows.h>
@@ -405,10 +406,12 @@ void ClientApplication::render() {
auto size = Vec2F(renderer->screenSize());
auto quad = renderFlatRect(RectF::withSize(size / -2, size), Vec4B::filled(0), 0.0f);
for (auto& layer : m_postProcessLayers) {
- for (unsigned i = 0; i < layer.passes; i++) {
- for (auto& effect : layer.effects) {
- renderer->switchEffectConfig(effect);
- renderer->render(quad);
+ if (layer.group ? layer.group->enabled : true) {
+ for (unsigned i = 0; i < layer.passes; i++) {
+ for (auto& effect : layer.effects) {
+ renderer->switchEffectConfig(effect);
+ renderer->render(quad);
+ }
}
}
}
@@ -434,6 +437,8 @@ void ClientApplication::getAudioData(int16_t* sampleData, size_t frameCount) {
}
}
+auto postProcessGroupsRoot = "postProcessGroups";
+
void ClientApplication::renderReload() {
auto assets = m_root->assets();
auto renderer = Application::renderer();
@@ -464,18 +469,55 @@ void ClientApplication::renderReload() {
loadEffectConfig("world");
+ // define post process groups and set them to be enabled/disabled based on config
+
+ auto config = m_root->configuration();
+ if (!config->get(postProcessGroupsRoot).isType(Json::Type::Object))
+ config->set(postProcessGroupsRoot, JsonObject());
+ auto groupsConfig = config->get(postProcessGroupsRoot);
+
+ m_postProcessGroups.clear();
+ auto postProcessGroups = assets->json("/client.config:postProcessGroups").toObject();
+ for (auto& pair : postProcessGroups) {
+ auto name = pair.first;
+ auto groupConfig = groupsConfig.opt(name);
+ auto def = pair.second.getBool("enabledDefault",true);
+ if (!groupConfig)
+ config->setPath(strf("{}.{}", postProcessGroupsRoot, name),JsonObject());
+ m_postProcessGroups.add(name,PostProcessGroup{ groupConfig ? groupConfig.value().getBool("enabled", def) : def });
+ }
+
+ // define post process layers and optionally assign them to groups
m_postProcessLayers.clear();
auto postProcessLayers = assets->json("/client.config:postProcessLayers").toArray();
for (auto& layer : postProcessLayers) {
auto effects = jsonToStringList(layer.getArray("effects"));
for (auto& effect : effects)
loadEffectConfig(effect);
- m_postProcessLayers.append(PostProcessLayer{ std::move(effects), (unsigned)layer.getUInt("passes", 1) });
+ PostProcessGroup* group = nullptr;
+ auto gname = layer.optString("group");
+ if (gname) {
+ group = &m_postProcessGroups.get(gname.value());
+ }
+ m_postProcessLayers.append(PostProcessLayer{ std::move(effects), (unsigned)layer.getUInt("passes", 1), group });
}
loadEffectConfig("interface");
}
+void ClientApplication::setPostProcessGroupEnabled(String group, bool enabled, Maybe<bool> save) {
+ m_postProcessGroups.get(group).enabled = enabled;
+ if (save && save.value())
+ m_root->configuration()->setPath(strf("{}.{}.enabled", postProcessGroupsRoot, group),enabled);
+}
+bool ClientApplication::postProcessGroupEnabled(String group) {
+ return m_postProcessGroups.get(group).enabled;
+}
+
+Json ClientApplication::postProcessGroups() {
+ return m_root->assets()->json("/client.config:postProcessGroups");
+}
+
void ClientApplication::changeState(MainAppState newState) {
MainAppState oldState = m_state;
m_state = newState;
@@ -543,6 +585,7 @@ void ClientApplication::changeState(MainAppState newState) {
m_universeClient->setLuaCallbacks("input", LuaBindings::makeInputCallbacks());
m_universeClient->setLuaCallbacks("voice", LuaBindings::makeVoiceCallbacks());
m_universeClient->setLuaCallbacks("camera", LuaBindings::makeCameraCallbacks(&m_worldPainter->camera()));
+ m_universeClient->setLuaCallbacks("renderer", LuaBindings::makeRenderingCallbacks(this));
Json alwaysAllow = m_root->configuration()->getPath("safe.alwaysAllowClipboard");
m_universeClient->setLuaCallbacks("clipboard", LuaBindings::makeClipboardCallbacks(appController(), alwaysAllow && alwaysAllow.toBool()));
@@ -568,7 +611,7 @@ void ClientApplication::changeState(MainAppState newState) {
};
m_mainMixer->setUniverseClient(m_universeClient);
- m_titleScreen = make_shared<TitleScreen>(m_playerStorage, m_mainMixer->mixer());
+ m_titleScreen = make_shared<TitleScreen>(m_playerStorage, m_mainMixer->mixer(), m_universeClient);
if (auto renderer = Application::renderer())
m_titleScreen->renderInit(renderer);
}
diff --git a/source/client/StarClientApplication.hpp b/source/client/StarClientApplication.hpp
index 840dc9a..323f2b7 100644
--- a/source/client/StarClientApplication.hpp
+++ b/source/client/StarClientApplication.hpp
@@ -18,6 +18,11 @@ STAR_CLASS(Input);
STAR_CLASS(Voice);
class ClientApplication : public Application {
+public:
+ void setPostProcessGroupEnabled(String group, bool enabled, Maybe<bool> save);
+ bool postProcessGroupEnabled(String group);
+ Json postProcessGroups();
+
protected:
virtual void startup(StringList const& cmdLineArgs) override;
virtual void shutdown() override;
@@ -53,9 +58,14 @@ private:
String password;
};
+ struct PostProcessGroup {
+ bool enabled;
+ };
+
struct PostProcessLayer {
List<String> effects;
unsigned passes;
+ PostProcessGroup* group;
};
void renderReload();
@@ -104,6 +114,7 @@ private:
WorldRenderData m_renderData;
MainInterfacePtr m_mainInterface;
+ StringMap<PostProcessGroup> m_postProcessGroups;
List<PostProcessLayer> m_postProcessLayers;
// Valid if main app state == SinglePlayer
diff --git a/source/client/StarRenderingLuaBindings.cpp b/source/client/StarRenderingLuaBindings.cpp
new file mode 100644
index 0000000..4c9e7a2
--- /dev/null
+++ b/source/client/StarRenderingLuaBindings.cpp
@@ -0,0 +1,21 @@
+#include "StarRenderingLuaBindings.hpp"
+#include "StarLuaConverters.hpp"
+#include "StarClientApplication.hpp"
+
+namespace Star {
+
+LuaCallbacks LuaBindings::makeRenderingCallbacks(ClientApplication* app) {
+ LuaCallbacks callbacks;
+
+ // if the last argument is defined and true, this change will also be saved to starbound.config and read on next game start, use for things such as an interface that does this
+ callbacks.registerCallbackWithSignature<void, String, bool, Maybe<bool>>("setPostProcessGroupEnabled", bind(mem_fn(&ClientApplication::setPostProcessGroupEnabled), app, _1, _2, _3));
+ callbacks.registerCallbackWithSignature<bool, String>("postProcessGroupEnabled", bind(mem_fn(&ClientApplication::postProcessGroupEnabled), app, _1));
+
+ // not entirely necessary (root.assetJson can achieve the same purpose) but may as well
+ callbacks.registerCallbackWithSignature<Json>("postProcessGroups", bind(mem_fn(&ClientApplication::postProcessGroups), app));
+
+ return callbacks;
+}
+
+
+}
diff --git a/source/client/StarRenderingLuaBindings.hpp b/source/client/StarRenderingLuaBindings.hpp
new file mode 100644
index 0000000..68e709f
--- /dev/null
+++ b/source/client/StarRenderingLuaBindings.hpp
@@ -0,0 +1,13 @@
+#pragma once
+
+#include "StarLua.hpp"
+
+namespace Star {
+
+STAR_CLASS(ClientApplication);
+
+namespace LuaBindings {
+ LuaCallbacks makeRenderingCallbacks(ClientApplication* app);
+}
+
+}
diff --git a/source/frontend/CMakeLists.txt b/source/frontend/CMakeLists.txt
index 0934308..b619e90 100644
--- a/source/frontend/CMakeLists.txt
+++ b/source/frontend/CMakeLists.txt
@@ -55,6 +55,7 @@ SET (star_frontend_HEADERS
StarSimpleTooltip.hpp
StarSongbookInterface.hpp
StarStatusPane.hpp
+ StarShadersMenu.hpp
StarTeleportDialog.hpp
StarVoice.hpp
StarVoiceLuaBindings.hpp
@@ -107,6 +108,7 @@ SET (star_frontend_SOURCES
StarSimpleTooltip.cpp
StarSongbookInterface.cpp
StarStatusPane.cpp
+ StarShadersMenu.cpp
StarTeleportDialog.cpp
StarVoice.cpp
StarVoiceLuaBindings.cpp
@@ -118,4 +120,4 @@ ADD_LIBRARY (star_frontend OBJECT ${star_frontend_SOURCES} ${star_frontend_HEADE
IF(STAR_PRECOMPILED_HEADERS)
TARGET_PRECOMPILE_HEADERS (star_frontend REUSE_FROM star_core)
-ENDIF() \ No newline at end of file
+ENDIF()
diff --git a/source/frontend/StarGraphicsMenu.cpp b/source/frontend/StarGraphicsMenu.cpp
index efce444..3974453 100644
--- a/source/frontend/StarGraphicsMenu.cpp
+++ b/source/frontend/StarGraphicsMenu.cpp
@@ -9,10 +9,12 @@
#include "StarButtonWidget.hpp"
#include "StarOrderedSet.hpp"
#include "StarJsonExtra.hpp"
+#include "StarShadersMenu.hpp"
namespace Star {
-GraphicsMenu::GraphicsMenu() {
+GraphicsMenu::GraphicsMenu(PaneManager* manager,UniverseClientPtr client)
+ : m_paneManager(manager) {
GuiReader reader;
reader.registerCallback("cancel",
[&](Widget*) {
@@ -103,10 +105,14 @@ GraphicsMenu::GraphicsMenu() {
Root::singleton().configuration()->set("newLighting", checked);
syncGui();
});
+ reader.registerCallback("showShadersMenu", [=](Widget*) {
+ displayShaders();
+ });
auto assets = Root::singleton().assets();
- Json paneLayout = assets->json("/interface/windowconfig/graphicsmenu.config:paneLayout");
+ auto config = assets->json("/interface/windowconfig/graphicsmenu.config");
+ Json paneLayout = config.get("paneLayout");
m_interfaceScaleList = jsonToIntList(assets->json("/interface/windowconfig/graphicsmenu.config:interfaceScaleList"));
m_resList = jsonToVec2UList(assets->json("/interface/windowconfig/graphicsmenu.config:resolutionList"));
@@ -122,6 +128,8 @@ GraphicsMenu::GraphicsMenu() {
initConfig();
syncGui();
+
+ m_shadersMenu = make_shared<ShadersMenu>(assets->json(config.getString("shadersPanePath", "/interface/opensb/shaders/shaders.config")), client);
}
void GraphicsMenu::show() {
@@ -240,6 +248,10 @@ void GraphicsMenu::apply() {
}
}
+void GraphicsMenu::displayShaders() {
+ m_paneManager->displayPane(PaneLayer::ModalWindow, m_shadersMenu);
+}
+
void GraphicsMenu::applyWindowSettings() {
auto configuration = Root::singleton().configuration();
auto appController = GuiContext::singleton().applicationController();
@@ -253,4 +265,4 @@ void GraphicsMenu::applyWindowSettings() {
appController->setNormalWindow(jsonToVec2U(configuration->get("windowedResolution")));
}
-} \ No newline at end of file
+}
diff --git a/source/frontend/StarGraphicsMenu.hpp b/source/frontend/StarGraphicsMenu.hpp
index 6d03652..c212f71 100644
--- a/source/frontend/StarGraphicsMenu.hpp
+++ b/source/frontend/StarGraphicsMenu.hpp
@@ -1,14 +1,17 @@
#pragma once
#include "StarPane.hpp"
+#include "StarMainInterfaceTypes.hpp"
+#include "StarUniverseClient.hpp"
namespace Star {
STAR_CLASS(GraphicsMenu);
+STAR_CLASS(ShadersMenu);
class GraphicsMenu : public Pane {
public:
- GraphicsMenu();
+ GraphicsMenu(PaneManager* manager,UniverseClientPtr client);
void show() override;
void dismissed() override;
@@ -23,6 +26,8 @@ private:
void apply();
void applyWindowSettings();
+
+ void displayShaders();
List<Vec2U> m_resList;
List<int> m_interfaceScaleList;
@@ -30,6 +35,9 @@ private:
List<float> m_cameraSpeedList;
JsonObject m_localChanges;
+
+ ShadersMenuPtr m_shadersMenu;
+ PaneManager* m_paneManager;
};
}
diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp
index 41eceb7..8468f7f 100644
--- a/source/frontend/StarMainInterface.cpp
+++ b/source/frontend/StarMainInterface.cpp
@@ -117,7 +117,7 @@ MainInterface::MainInterface(UniverseClientPtr client, WorldPainterPtr painter,
m_codexInterface = make_shared<CodexInterface>(m_client->mainPlayer());
m_paneManager.registerPane(MainInterfacePanes::Codex, PaneLayer::Window, m_codexInterface);
- m_optionsMenu = make_shared<OptionsMenu>(&m_paneManager);
+ m_optionsMenu = make_shared<OptionsMenu>(&m_paneManager,m_client);
m_paneManager.registerPane(MainInterfacePanes::Options, PaneLayer::ModalWindow, m_optionsMenu);
m_popupInterface = make_shared<PopupInterface>();
@@ -1604,4 +1604,4 @@ void MainInterface::displayScriptPane(ScriptPanePtr& scriptPane, EntityId source
}
}
-} \ No newline at end of file
+}
diff --git a/source/frontend/StarOptionsMenu.cpp b/source/frontend/StarOptionsMenu.cpp
index 0ea1fa1..8253f1f 100644
--- a/source/frontend/StarOptionsMenu.cpp
+++ b/source/frontend/StarOptionsMenu.cpp
@@ -13,7 +13,7 @@
namespace Star {
-OptionsMenu::OptionsMenu(PaneManager* manager)
+OptionsMenu::OptionsMenu(PaneManager* manager, UniverseClientPtr client)
: m_sfxRange(0, 100), m_musicRange(0, 100), m_paneManager(manager) {
auto root = Root::singletonPtr();
auto assets = root->assets();
@@ -90,7 +90,7 @@ OptionsMenu::OptionsMenu(PaneManager* manager)
m_voiceSettingsMenu = make_shared<VoiceSettingsMenu>(assets->json(config.getString("voiceSettingsPanePath", "/interface/opensb/voicechat/voicechat.config")));
m_modBindingsMenu = make_shared<BindingsMenu>(assets->json(config.getString("bindingsPanePath", "/interface/opensb/bindings/bindings.config")));
m_keybindingsMenu = make_shared<KeybindingsMenu>();
- m_graphicsMenu = make_shared<GraphicsMenu>();
+ m_graphicsMenu = make_shared<GraphicsMenu>(manager,client);
initConfig();
}
diff --git a/source/frontend/StarOptionsMenu.hpp b/source/frontend/StarOptionsMenu.hpp
index 4bc36ad..9fde1ac 100644
--- a/source/frontend/StarOptionsMenu.hpp
+++ b/source/frontend/StarOptionsMenu.hpp
@@ -3,6 +3,7 @@
#include "StarPane.hpp"
#include "StarConfiguration.hpp"
#include "StarMainInterfaceTypes.hpp"
+#include "StarUniverseClient.hpp"
namespace Star {
@@ -17,7 +18,7 @@ STAR_CLASS(OptionsMenu);
class OptionsMenu : public Pane {
public:
- OptionsMenu(PaneManager* manager);
+ OptionsMenu(PaneManager* manager, UniverseClientPtr client);
virtual void show() override;
diff --git a/source/frontend/StarShadersMenu.cpp b/source/frontend/StarShadersMenu.cpp
new file mode 100644
index 0000000..4e15b66
--- /dev/null
+++ b/source/frontend/StarShadersMenu.cpp
@@ -0,0 +1,22 @@
+#include "StarShadersMenu.hpp"
+
+namespace Star {
+
+ShadersMenu::ShadersMenu(Json const& config, UniverseClientPtr client) : BaseScriptPane(config) {
+ m_client = std::move(client);
+}
+
+void ShadersMenu::show() {
+ BaseScriptPane::show();
+}
+
+void ShadersMenu::displayed() {
+ m_script.setLuaRoot(m_client->luaRoot());
+ BaseScriptPane::displayed();
+}
+
+void ShadersMenu::dismissed() {
+ BaseScriptPane::dismissed();
+}
+
+}
diff --git a/source/frontend/StarShadersMenu.hpp b/source/frontend/StarShadersMenu.hpp
new file mode 100644
index 0000000..9b24b0d
--- /dev/null
+++ b/source/frontend/StarShadersMenu.hpp
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "StarBaseScriptPane.hpp"
+#include "StarUniverseClient.hpp"
+
+namespace Star {
+
+STAR_CLASS(ShadersMenu);
+
+class ShadersMenu : public BaseScriptPane {
+public:
+ ShadersMenu(Json const& config, UniverseClientPtr client);
+
+ virtual void show() override;
+ void displayed() override;
+ void dismissed() override;
+
+private:
+ UniverseClientPtr m_client;
+};
+
+}
diff --git a/source/frontend/StarTitleScreen.cpp b/source/frontend/StarTitleScreen.cpp
index 895e88a..b48ac13 100644
--- a/source/frontend/StarTitleScreen.cpp
+++ b/source/frontend/StarTitleScreen.cpp
@@ -18,7 +18,7 @@
namespace Star {
-TitleScreen::TitleScreen(PlayerStoragePtr playerStorage, MixerPtr mixer)
+TitleScreen::TitleScreen(PlayerStoragePtr playerStorage, MixerPtr mixer, UniverseClientPtr client)
: m_playerStorage(playerStorage), m_skipMultiPlayerConnection(false), m_mixer(mixer) {
m_titleState = TitleState::Quit;
@@ -43,7 +43,7 @@ TitleScreen::TitleScreen(PlayerStoragePtr playerStorage, MixerPtr mixer)
initCharSelectionMenu();
initCharCreationMenu();
initMultiPlayerMenu();
- initOptionsMenu();
+ initOptionsMenu(client);
initModsMenu();
resetState();
@@ -345,8 +345,8 @@ void TitleScreen::initMultiPlayerMenu() {
m_paneManager.registerPane("multiplayerMenu", PaneLayer::Hud, m_multiPlayerMenu);
}
-void TitleScreen::initOptionsMenu() {
- auto optionsMenu = make_shared<OptionsMenu>(&m_paneManager);
+void TitleScreen::initOptionsMenu(UniverseClientPtr client) {
+ auto optionsMenu = make_shared<OptionsMenu>(&m_paneManager,client);
optionsMenu->setAnchor(PaneAnchor::Center);
optionsMenu->lockPosition();
diff --git a/source/frontend/StarTitleScreen.hpp b/source/frontend/StarTitleScreen.hpp
index 65ebb57..9aaac96 100644
--- a/source/frontend/StarTitleScreen.hpp
+++ b/source/frontend/StarTitleScreen.hpp
@@ -4,6 +4,7 @@
#include "StarAmbient.hpp"
#include "StarRegisteredPaneManager.hpp"
#include "StarInterfaceCursor.hpp"
+#include "StarUniverseClient.hpp"
namespace Star {
@@ -39,7 +40,7 @@ enum class TitleState {
class TitleScreen {
public:
- TitleScreen(PlayerStoragePtr playerStorage, MixerPtr mixer);
+ TitleScreen(PlayerStoragePtr playerStorage, MixerPtr mixer, UniverseClientPtr client);
void renderInit(RendererPtr renderer);
@@ -80,7 +81,7 @@ private:
void initCharSelectionMenu();
void initCharCreationMenu();
void initMultiPlayerMenu();
- void initOptionsMenu();
+ void initOptionsMenu(UniverseClientPtr client);
void initModsMenu();
void renderCursor();