Merge pull request #157 from Bottinator22/main
Allow post process shaders to be grouped up and enabled/disabled via Lua or a shaders menu
@ -10,5 +10,6 @@
|
||||
"scissor" : false,
|
||||
"letterbox" : false
|
||||
},
|
||||
"postProcessLayers": []
|
||||
"postProcessLayers": [],
|
||||
"postProcessGroups": {}
|
||||
}
|
||||
|
BIN
assets/opensb/interface/opensb/shaders/body.png
Normal file
After Width: | Height: | Size: 743 B |
BIN
assets/opensb/interface/opensb/shaders/categoryname.png
Normal file
After Width: | Height: | Size: 391 B |
BIN
assets/opensb/interface/opensb/shaders/footer.png
Normal file
After Width: | Height: | Size: 163 B |
BIN
assets/opensb/interface/opensb/shaders/group.png
Normal file
After Width: | Height: | Size: 80 B |
BIN
assets/opensb/interface/opensb/shaders/groupback.png
Normal file
After Width: | Height: | Size: 162 B |
BIN
assets/opensb/interface/opensb/shaders/header.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
assets/opensb/interface/opensb/shaders/optionname.png
Normal file
After Width: | Height: | Size: 197 B |
147
assets/opensb/interface/opensb/shaders/shaders.config
Normal file
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
219
assets/opensb/interface/opensb/shaders/shaders.lua
Normal file
@ -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
|
@ -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
|
||||
@ -42,6 +48,10 @@ function patch(config)
|
||||
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)
|
||||
|
@ -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)
|
||||
|
@ -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,6 +406,7 @@ 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) {
|
||||
if (layer.group ? layer.group->enabled : true) {
|
||||
for (unsigned i = 0; i < layer.passes; i++) {
|
||||
for (auto& effect : layer.effects) {
|
||||
renderer->switchEffectConfig(effect);
|
||||
@ -413,6 +415,7 @@ void ClientApplication::render() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
renderer->switchEffectConfig("interface");
|
||||
auto start = Time::monotonicMicroseconds();
|
||||
m_mainInterface->renderInWorldElements();
|
||||
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
21
source/client/StarRenderingLuaBindings.cpp
Normal file
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
13
source/client/StarRenderingLuaBindings.hpp
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "StarLua.hpp"
|
||||
|
||||
namespace Star {
|
||||
|
||||
STAR_CLASS(ClientApplication);
|
||||
|
||||
namespace LuaBindings {
|
||||
LuaCallbacks makeRenderingCallbacks(ClientApplication* app);
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
@ -24,12 +27,17 @@ private:
|
||||
void apply();
|
||||
void applyWindowSettings();
|
||||
|
||||
void displayShaders();
|
||||
|
||||
List<Vec2U> m_resList;
|
||||
List<int> m_interfaceScaleList;
|
||||
List<float> m_zoomList;
|
||||
List<float> m_cameraSpeedList;
|
||||
|
||||
JsonObject m_localChanges;
|
||||
|
||||
ShadersMenuPtr m_shadersMenu;
|
||||
PaneManager* m_paneManager;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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>();
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
22
source/frontend/StarShadersMenu.cpp
Normal file
@ -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();
|
||||
}
|
||||
|
||||
}
|
22
source/frontend/StarShadersMenu.hpp
Normal file
@ -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;
|
||||
};
|
||||
|
||||
}
|
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
|