{"action":"created","issue":{"url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/2668","repository_url":"https://api.github.com/repos/MovingBlocks/Terasology","labels_url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/2668/labels{/name}","comments_url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/2668/comments","events_url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/2668/events","html_url":"https://github.com/MovingBlocks/Terasology/issues/2668","id":195842762,"number":2668,"title":"FlexibleConfig","user":{"login":"emanuele3d","id":6934584,"avatar_url":"https://avatars.githubusercontent.com/u/6934584?v=3","gravatar_id":"","url":"https://api.github.com/users/emanuele3d","html_url":"https://github.com/emanuele3d","followers_url":"https://api.github.com/users/emanuele3d/followers","following_url":"https://api.github.com/users/emanuele3d/following{/other_user}","gists_url":"https://api.github.com/users/emanuele3d/gists{/gist_id}","starred_url":"https://api.github.com/users/emanuele3d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emanuele3d/subscriptions","organizations_url":"https://api.github.com/users/emanuele3d/orgs","repos_url":"https://api.github.com/users/emanuele3d/repos","events_url":"https://api.github.com/users/emanuele3d/events{/privacy}","received_events_url":"https://api.github.com/users/emanuele3d/received_events","type":"User","site_admin":false},"labels":[{"id":180651220,"url":"https://api.github.com/repos/MovingBlocks/Terasology/labels/API","name":"API","color":"eb6420","default":false},{"id":223291,"url":"https://api.github.com/repos/MovingBlocks/Terasology/labels/Architecture","name":"Architecture","color":"A13027","default":false},{"id":56016179,"url":"https://api.github.com/repos/MovingBlocks/Terasology/labels/Rendering","name":"Rendering","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":47,"created_at":"2016-12-15T15:59:12Z","updated_at":"2017-01-15T14:04:31Z","closed_at":null,"body":"***Introduction***\r\nThe current rendering config is a relatively straightforward (if long) Java class with hardcoded video settings and their handling. This includes accessors (get*(), set*(), is*()), but also functionality to subscribe to the config to be notified of changes - to specific values or to the whole config. \r\n\r\nThis works, but is inflexible. Ideally engine and modules should be able to publish their configuration settings, as needed. Here is a couple of simple scenarios to ponder about.\r\n\r\n****Scenario 1 - ShadowMapNode****\r\nThe ShadowMapNode is responsible for generating a ShadowMap used to cast shadows from the main light (sun/moon). This node wishes to publish two settings to the rendering config: a) a boolean defining its enabled/disabled state b) an integer defining the size of the (square) shadow map, in pixels. \r\n\r\n****Sceneario 2 - RealCameras module****\r\nThe RealCameras module (so far a fictional one) introduces a number of realistic effects for the camera. Among them are lens flares. These are generated by a specialized node injected into the render graph on module startup. The node renders up to 20 lens flare elements, each having a set of parameters to play with, such as the texture asset used, the distance along the flare axis and the maximum opacity of the element. All these settings need to be published at runtime on the rendering config, for the user to play with. \r\n\r\n***FlexibleConfig and Setting classes***\r\nEnter the FlexibleConfig class, barely more than a <ResourceURN, Setting> map:\r\n* `void add(Setting)` - doesn't allow overwriting a stored setting object with a new one using the same ResourceUrn\r\n* `boolean remove(ResourceUrn)` - return true if the setting has been removed from the config. This happens only if the setting no longer has subscribers.\r\n* `Setting get(ResourceUrn)`\r\n* `boolean has(ResourceUrn)`\r\n\r\nIndividual Setting instances would contain:\r\n* an id - of type ResourceURN: the prefix is engine-set and is either \"engine\" or the fully qualified name of the module publishing the setting.\r\n* a stored value\r\n* a type - i.e. boolean, integer, float, double, one-selection/multiple-selection lists\r\n* a default value\r\n* a range - where applicable, i.e. integers, float, double \r\n* a list of choices - where applicable, i.e. list-type settings\r\n* a comma-separated list of ui-path\r\n* a human-readable name - translation friendly, to be displayed in the UI\r\n* a description - translation-friendly, potentially verbose, describing in plain language what a setting does.\r\n\r\n`Setting` is largely immutable and contains the information from the FlexibleConfigs Features section. But it would have a setter methods for the stored value. It also provides subscribe()/unsubscribe() methods and a `boolean hasSubscribers()` method. \r\n\r\nA few clarifications about the ui-path feature. A ui path would provide a hint to the ui on how to group settings together. I.e. all settings having a path /engine/shadows/shadowmap *could* be displayed together when the \"shadows\" list item is selected in the \"engine\" tab of the rendering config. It could be meaningful however for the same setting to be also be displayed in a separate tab/menu, hence the possibility for multiple ui paths. Ultimately however, it is up to the UI code to decide how to take advantage of them. I.e. a simpler UI might not provide \"tabs\" and might group settings between horizontal separators instead, potentially ignoring the deeper sections of a path.\r\n\r\nHow does this all sound? And notice that this issue specifically avoids dealing with the UI needed to display the content of a FlexibleConfig instance. That will be for a separate issue.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/comments/272697167","html_url":"https://github.com/MovingBlocks/Terasology/issues/2668#issuecomment-272697167","issue_url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/2668","id":272697167,"user":{"login":"eviltak","id":8018181,"avatar_url":"https://avatars.githubusercontent.com/u/8018181?v=3","gravatar_id":"","url":"https://api.github.com/users/eviltak","html_url":"https://github.com/eviltak","followers_url":"https://api.github.com/users/eviltak/followers","following_url":"https://api.github.com/users/eviltak/following{/other_user}","gists_url":"https://api.github.com/users/eviltak/gists{/gist_id}","starred_url":"https://api.github.com/users/eviltak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eviltak/subscriptions","organizations_url":"https://api.github.com/users/eviltak/orgs","repos_url":"https://api.github.com/users/eviltak/repos","events_url":"https://api.github.com/users/eviltak/events{/privacy}","received_events_url":"https://api.github.com/users/eviltak/received_events","type":"User","site_admin":false},"created_at":"2017-01-15T14:04:31Z","updated_at":"2017-01-15T14:04:31Z","body":"PR #2757 has been created for this issue."}}
{"actor":{"display_login":"eviltak"}}