diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 33ba3a5..8434c80 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -232,4 +232,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: OpenStarbound-macOS-Silicon - path: dist/* \ No newline at end of file + path: dist/* diff --git a/assets/opensb/client.config.patch b/assets/opensb/client.config.patch index 619a767..7bd18d6 100644 --- a/assets/opensb/client.config.patch +++ b/assets/opensb/client.config.patch @@ -10,5 +10,6 @@ "scissor" : false, "letterbox" : false }, - "postProcessLayers": [] + "postProcessLayers": [], + "postProcessGroups": {} } diff --git a/assets/opensb/interface/opensb/shaders/body.png b/assets/opensb/interface/opensb/shaders/body.png new file mode 100644 index 0000000..272ed29 Binary files /dev/null and b/assets/opensb/interface/opensb/shaders/body.png differ diff --git a/assets/opensb/interface/opensb/shaders/categoryname.png b/assets/opensb/interface/opensb/shaders/categoryname.png new file mode 100644 index 0000000..3019556 Binary files /dev/null and b/assets/opensb/interface/opensb/shaders/categoryname.png differ diff --git a/assets/opensb/interface/opensb/shaders/footer.png b/assets/opensb/interface/opensb/shaders/footer.png new file mode 100644 index 0000000..426f8a6 Binary files /dev/null and b/assets/opensb/interface/opensb/shaders/footer.png differ diff --git a/assets/opensb/interface/opensb/shaders/group.png b/assets/opensb/interface/opensb/shaders/group.png new file mode 100644 index 0000000..66f5cdb Binary files /dev/null and b/assets/opensb/interface/opensb/shaders/group.png differ diff --git a/assets/opensb/interface/opensb/shaders/groupback.png b/assets/opensb/interface/opensb/shaders/groupback.png new file mode 100644 index 0000000..ed838f3 Binary files /dev/null and b/assets/opensb/interface/opensb/shaders/groupback.png differ diff --git a/assets/opensb/interface/opensb/shaders/header.png b/assets/opensb/interface/opensb/shaders/header.png new file mode 100644 index 0000000..d4425f0 Binary files /dev/null and b/assets/opensb/interface/opensb/shaders/header.png differ diff --git a/assets/opensb/interface/opensb/shaders/optionname.png b/assets/opensb/interface/opensb/shaders/optionname.png new file mode 100644 index 0000000..f7c4500 Binary files /dev/null and b/assets/opensb/interface/opensb/shaders/optionname.png differ diff --git a/assets/opensb/interface/opensb/shaders/shaders.config b/assets/opensb/interface/opensb/shaders/shaders.config new file mode 100644 index 0000000..5154831 --- /dev/null +++ b/assets/opensb/interface/opensb/shaders/shaders.config @@ -0,0 +1,147 @@ +{ + "scripts" : ["/interface/opensb/shaders/shaders.lua"], + "scriptDelta" : 0, + "scriptWidgetCallbacks" : [ + "selectGroup", + "toggleGroupEnabled" + ], + + "gui" : { + "panefeature" : { + "type" : "panefeature", + "positionLocked" : false + }, + "background" : { + "type" : "background", + "fileHeader" : "/interface/opensb/shaders/header.png", + "fileBody" : "/interface/opensb/shaders/body.png", + "fileFooter" : "/interface/opensb/shaders/footer.png" + }, + "banner" : { + "type" : "canvas", + "rect" : [146, 187, 398, 215] + }, + "groups" : { + "type" : "scrollArea", + "rect" : [4, 16, 145, 214], + "children" : { + "list" : { + "type" : "list", + "schema" : { + "selectedBG" : "/interface/opensb/shaders/groupback.png?multiply=0f0", + "unselectedBG" : "/interface/opensb/shaders/groupback.png?multiply=222", + "spacing" : [0, 1], + "memberSize" : [130, 16], + "listTemplate" : { + "background" : { + "type" : "image", + "file" : "/interface/opensb/shaders/groupback.png?multiply=222", + "position" : [0, 0], + "zlevel" : -1 + }, + "button" : { + "type" : "button", + "callback" : "selectGroup", + "caption" : "Unnamed", + "base" : "/interface/opensb/shaders/group.png?replace;fff=fff0;000=0007", + "hover" : "/interface/opensb/shaders/group.png?replace;fff=fff7;000=3337", + "press" : "/interface/opensb/shaders/group.png?replace;fff=000;000=7777", + "pressedOffset" : [0, 0], + "position" : [0, 0] + } + } + } + } + }, + "buttons" : { + "horizontal" : { + "forward" : { "base" : "", "hover" : "", "pressed" : "" }, + "backward" : { "base" : "", "hover": "", "pressed" : "" } + }, + "vertical" : { + "forward" : { + "base" : "/interface/scrollarea/varrow-forward.png?setcolor=fff", + "hover" : "/interface/scrollarea/varrow-forwardhover.png", + "pressed" : "" + }, + "backward" : { + "base" : "/interface/scrollarea/varrow-backward.png?setcolor=fff", + "hover" : "/interface/scrollarea/varrow-backwardhover.png", + "pressed" : "" + } + } + }, + "thumbs" : { + "horizontal" : { + "base" : { "begin" : "", "end" : "", "inner" : "" }, + "hover" : { "begin" : "", "end" : "", "inner" : "" }, + "pressed" : { "begin" : "", "end" : "", "inner" : "" } + }, + "vertical" : { + "base" : { + "begin" : "/interface/scrollarea/vthumb-begin.png", + "end" : "/interface/scrollarea/vthumb-end.png", + "inner" : "/interface/scrollarea/vthumb-inner.png" + }, + "hover" : { + "begin" : "/interface/scrollarea/vthumb-beginhover.png", + "end" : "/interface/scrollarea/vthumb-endhover.png", + "inner" : "/interface/scrollarea/vthumb-innerhover.png" + }, + "pressed" : { + "begin" : "/interface/scrollarea/vthumb-beginhover.png", + "end" : "/interface/scrollarea/vthumb-endhover.png", + "inner" : "/interface/scrollarea/vthumb-innerhover.png" + } + } + } + }, + "options" : { + "type" : "scrollArea", + "rect" : [147, 16, 398, 185], + "children" : {}, + "buttons" : { + "horizontal" : { + "forward" : { "base" : "", "hover" : "", "pressed" : "" }, + "backward" : { "base" : "", "hover": "", "pressed" : "" } + }, + "vertical" : { + "forward" : { + "base" : "/interface/scrollarea/varrow-forward.png?setcolor=fff", + "hover" : "/interface/scrollarea/varrow-forwardhover.png", + "pressed" : "" + }, + "backward" : { + "base" : "/interface/scrollarea/varrow-backward.png?setcolor=fff", + "hover" : "/interface/scrollarea/varrow-backwardhover.png", + "pressed" : "" + } + } + }, + "thumbs" : { + "horizontal" : { + "base" : { "begin" : "", "end" : "", "inner" : "" }, + "hover" : { "begin" : "", "end" : "", "inner" : "" }, + "pressed" : { "begin" : "", "end" : "", "inner" : "" } + }, + "vertical" : { + "base" : { + "begin" : "/interface/scrollarea/vthumb-begin.png", + "end" : "/interface/scrollarea/vthumb-end.png", + "inner" : "/interface/scrollarea/vthumb-inner.png" + }, + "hover" : { + "begin" : "/interface/scrollarea/vthumb-beginhover.png", + "end" : "/interface/scrollarea/vthumb-endhover.png", + "inner" : "/interface/scrollarea/vthumb-innerhover.png" + }, + "pressed" : { + "begin" : "/interface/scrollarea/vthumb-beginhover.png", + "end" : "/interface/scrollarea/vthumb-endhover.png", + "inner" : "/interface/scrollarea/vthumb-innerhover.png" + } + } + } + } + } +} diff --git a/assets/opensb/interface/opensb/shaders/shaders.lua b/assets/opensb/interface/opensb/shaders/shaders.lua new file mode 100644 index 0000000..0030b5c --- /dev/null +++ b/assets/opensb/interface/opensb/shaders/shaders.lua @@ -0,0 +1,219 @@ +--constants +local PATH = "/interface/opensb/shaders/" +local GROUP_LIST_WIDGET = "groups.list" +local OPTIONS_WIDGET = "options" + +local fmt = string.format +local log = function() end + +function update() +end + + +local function alphabeticalNameSortGreater(a, b) return a.name > b.name end +local function alphabeticalNameSortLesser(a, b) return a.name < b.name end +local sortedGroups = {} +local groups = {} + +local widgetsToGroups = {} +local allSettings = {} + +local function addGroupToList(data) + local name = widget.addListItem(GROUP_LIST_WIDGET) + widget.setText(fmt("%s.%s.button", GROUP_LIST_WIDGET, name), data.friendlyName) + log("Added group ^cyan;%s^reset; to list", data.friendlyName) + return name +end + +local function parseGroups() + for name, data in next, renderer.postProcessGroups() do + if not data.hidden then + if not data.friendlyName then data.friendlyName = name end + data.groupId = name + data.name = data.friendlyName + groups[data.groupId] = data + end + end + + for groupId, data in pairs(groups) do + sortedGroups[#sortedGroups + 1] = data + end + table.sort(sortedGroups, alphabeticalNameSortLesser) + for i = 1, #sortedGroups do + local data = sortedGroups[i] + data.index = i + local name = addGroupToList(data) + data.widget = name + widgetsToGroups[name] = data + end + if sortedGroups[1] then + local first = sortedGroups[1].widget + widget.setListSelected(GROUP_LIST_WIDGET, first) + selectGroup(first) + end +end + +local activeGroup + +local function addOptionGroup(data, i, added) + local y = (i - 1) * -14 + local bg = { + type = "image", + file = PATH .. "groupname.png", + position = {-12, y} + } + local name = "group_" .. i + widget.addChild(BINDS_WIDGET, bg, name) + added[#added + 1] = name + local label = { + type = "label", + value = data.name, + wrapWidth = 120, + fontSize = 8, + hAnchor = "mid", + vAnchor = "mid", + position = {120, 6} + } + widget.addChild(fmt("%s.%s", BINDS_WIDGET, name), label, "text") +end + +local function addOption(data, i, added) + local y = (i - 1) * -14 + local bg = { + type = "image", + file = PATH .. "optionname.png", + position = {-12, y} + } + local name = "label_" .. i + widget.addChild(OPTIONS_WIDGET, bg, name) + added[#added + 1] = name + local label = { + type = "label", + value = data.name, + wrapWidth = 120, + fontSize = 8, + hAnchor = "mid", + vAnchor = "mid", + position = {62, 6} + } + widget.addChild(fmt("%s.%s", OPTIONS_WIDGET, name), label, "text") + -- todo: finish this +end + +local function addEnabled(groupname, i, added) + local y = (i - 1) * -14 + local bg = { + type = "image", + file = PATH .. "optionname.png", + position = {-12, y} + } + local name = "label_" .. i + widget.addChild(OPTIONS_WIDGET, bg, name) + added[#added + 1] = name + local label = { + type = "label", + value = "Enabled", + wrapWidth = 120, + fontSize = 8, + hAnchor = "mid", + vAnchor = "mid", + position = {62, 6} + } + widget.addChild(fmt("%s.%s", OPTIONS_WIDGET, name), label, "text") + local checkbox = { + type = "button", + callback = "toggleGroupEnabled", + position = {165, y + 2}, + pressedOffset = {0, 0}, + base = "/interface/optionsmenu/checkboxnocheck.png", + hover = "/interface/optionsmenu/checkboxnocheckhover.png", + baseImageChecked = "/interface/optionsmenu/checkboxcheck.png", + hoverImageChecked = "/interface/optionsmenu/checkboxcheckhover.png", + checkable = true, + checked = renderer.postProcessGroupEnabled(groupname) + } + name = "check_"..groupname + added[#added + 1] = name + widget.addChild(OPTIONS_WIDGET, checkbox, name) +end + +function toggleGroupEnabled(checkbox, cdata) + renderer.setPostProcessGroupEnabled(activeGroup, widget.getChecked(fmt("%s.%s",OPTIONS_WIDGET,checkbox)), true) +end + +function selectGroup() + local selected = widget.getListSelected(GROUP_LIST_WIDGET) + local group = widgetsToGroups[selected] + local dataFromPrev = widget.getData(OPTIONS_WIDGET) + if dataFromPrev then + for i, v in pairs(dataFromPrev) do + widget.removeChild(OPTIONS_WIDGET, v) + end + end + widgetsToOptions = {} + + activeGroup = group.groupId + + local bannerOptions = widget.bindCanvas("banner") + bannerOptions:clear() + + local bannerName = tostring(group.bannerName or group.name or group.groupId) + bannerOptions:drawText(bannerName, {position = {127, 13}, horizontalAnchor = "mid", verticalAnchor = "mid"}, 16) + + local added = {} + local index = 0 + addEnabled(group.groupId,index,added) + + --[[ + local categories = group.categories or {} + if not categories.unsorted then + categories.unsorted = {name = "Unsorted"} + end + + local sortedCategories = {} + for categoryId, data in pairs(categories) do + data.name = tostring(data.name or categoryId) + data.sortedOptions = {} + sortedCategories[#sortedCategories + 1] = data + end + + table.sort(sortedCategories, alphabeticalNameSortLesser) + + for categoryId, data in pairs(categories) do + table.sort(data.sortedOptions, alphabeticalNameSortLesser) + end + + local onlyUnsorted = not sortedGroups[2] and sortedGroups[1] == categories.unsorted + + for iA = 1, #sortedCategories do + local category = sortedCategories[iA] + local optionsCount = #category.sortedOptions + if optionsCount > 0 then + if not onlyUnsorted then + index = index + 1 + addOptionCategory(category, index, added) + end + for iB = 1, optionsCount do + index = index + 1 + addOption(category.sortedOptions[iB], index, added) + end + end + end]] + + widget.setData(OPTIONS_WIDGET, added) +end + + +local function initCallbacks() + widget.registerMemberCallback(GROUP_LIST_WIDGET, "selectGroup", selectGroup) +end + +function init() + --log = chat and chat.addMessage or sb.logInfo + + widget.clearListItems(GROUP_LIST_WIDGET) + initCallbacks() + parseGroups() + + script.setUpdateDelta(1) +end diff --git a/assets/opensb/interface/windowconfig/graphicsmenu.config.patch.lua b/assets/opensb/interface/windowconfig/graphicsmenu.config.patch.lua index 7d7ab44..b17053a 100644 --- a/assets/opensb/interface/windowconfig/graphicsmenu.config.patch.lua +++ b/assets/opensb/interface/windowconfig/graphicsmenu.config.patch.lua @@ -13,6 +13,12 @@ local function shift(thing, x, y) return thing end +local function moveto(thing, otherthing) + thing.position[1] = otherthing.position[1] + thing.position[2] = otherthing.position[2] + return thing +end + -- patch function, called by the game function patch(config) local layout = config.paneLayout @@ -41,10 +47,14 @@ function patch(config) -- Create hardware cursor toggle shift(clone(layout, "multiTextureLabel", "hardwareCursorLabel"), 98, -11).value = "HARDWARE CURSOR" shift(clone(layout, "multiTextureCheckbox", "hardwareCursorCheckbox"), 99, -11) + + -- Create shader menu button + shift(moveto(clone(layout, "accept", "showShadersMenu"), layout.interfaceScaleSlider), 112, -2).caption = "Shaders" + shift(layout.title, 0, 24) shift(layout.resLabel, 0, 28) shift(layout.resSlider, 0, 28) shift(layout.resValueLabel, 0, 28) return config -end \ No newline at end of file +end 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 @@ -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 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(m_playerStorage, m_mainMixer->mixer()); + m_titleScreen = make_shared(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 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 effects; unsigned passes; + PostProcessGroup* group; }; void renderReload(); @@ -104,6 +114,7 @@ private: WorldRenderData m_renderData; MainInterfacePtr m_mainInterface; + StringMap m_postProcessGroups; List 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>("setPostProcessGroupEnabled", bind(mem_fn(&ClientApplication::setPostProcessGroupEnabled), app, _1, _2, _3)); + callbacks.registerCallbackWithSignature("postProcessGroupEnabled", bind(mem_fn(&ClientApplication::postProcessGroupEnabled), app, _1)); + + // not entirely necessary (root.assetJson can achieve the same purpose) but may as well + callbacks.registerCallbackWithSignature("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(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 m_resList; List m_interfaceScaleList; @@ -30,6 +35,9 @@ private: List 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(m_client->mainPlayer()); m_paneManager.registerPane(MainInterfacePanes::Codex, PaneLayer::Window, m_codexInterface); - m_optionsMenu = make_shared(&m_paneManager); + m_optionsMenu = make_shared(&m_paneManager,m_client); m_paneManager.registerPane(MainInterfacePanes::Options, PaneLayer::ModalWindow, m_optionsMenu); m_popupInterface = make_shared(); @@ -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(assets->json(config.getString("voiceSettingsPanePath", "/interface/opensb/voicechat/voicechat.config"))); m_modBindingsMenu = make_shared(assets->json(config.getString("bindingsPanePath", "/interface/opensb/bindings/bindings.config"))); m_keybindingsMenu = make_shared(); - m_graphicsMenu = make_shared(); + m_graphicsMenu = make_shared(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(&m_paneManager); +void TitleScreen::initOptionsMenu(UniverseClientPtr client) { + auto optionsMenu = make_shared(&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();