mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:35:08 +02:00
Add display plugin introspection to the window scripting interface
This commit is contained in:
parent
5db78ef2e1
commit
8c375db90f
2 changed files with 71 additions and 0 deletions
|
@ -19,6 +19,7 @@
|
|||
#include <shared/QtHelpers.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include <plugins/PluginManager.h>
|
||||
#include <display-plugins/CompositorHelper.h>
|
||||
#include <AddressManager.h>
|
||||
#include "AndroidHelper.h"
|
||||
|
@ -609,3 +610,35 @@ void WindowScriptingInterface::onMessageBoxSelected(int button) {
|
|||
float WindowScriptingInterface::domainLoadingProgress() {
|
||||
return qApp->getOctreePacketProcessor().domainLoadingProgress();
|
||||
}
|
||||
|
||||
const DisplayPluginList& getDisplayPlugins() {
|
||||
static const auto& list = PluginManager::getInstance()->getDisplayPlugins();
|
||||
return list;
|
||||
}
|
||||
|
||||
int WindowScriptingInterface::getDisplayPluginCount() {
|
||||
return getDisplayPlugins().size();
|
||||
}
|
||||
|
||||
QString WindowScriptingInterface::getDisplayPluginName(int index) {
|
||||
return getDisplayPlugins().at(index)->getName();
|
||||
}
|
||||
|
||||
bool WindowScriptingInterface::isDisplayPluginHmd(int index) {
|
||||
return getDisplayPlugins().at(index)->isHmd();
|
||||
}
|
||||
|
||||
int WindowScriptingInterface::getActiveDisplayPlugin() {
|
||||
auto active = qApp->getActiveDisplayPlugin();
|
||||
auto size = getDisplayPluginCount();
|
||||
for (int i = 0; i < size; ++i) {
|
||||
if (getDisplayPlugins().at(i) == active) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void WindowScriptingInterface::setActiveDisplayPlugin(int index) {
|
||||
qApp->setActiveDisplayPlugin(getDisplayPlugins().at(index)->getName());
|
||||
}
|
||||
|
|
|
@ -575,6 +575,44 @@ public slots:
|
|||
|
||||
float domainLoadingProgress();
|
||||
|
||||
/**jsdoc
|
||||
* Return the number of display plugins currently available
|
||||
* @function Window.getDisplayPluginCount
|
||||
* @returns {int} The number of currently available display plugins
|
||||
*/
|
||||
int getDisplayPluginCount();
|
||||
|
||||
/**jsdoc
|
||||
* Return the human readable name of a display plugin
|
||||
* @function Window.getDisplayPluginName
|
||||
* @param {int} index - The index of the display plugin. Must be less than the value returned by {@link Window.getDisplayPluginCount|getDisplayPluginCount}.
|
||||
* @returns {string} The name of the specified display plugin
|
||||
*/
|
||||
QString getDisplayPluginName(int index);
|
||||
|
||||
/**jsdoc
|
||||
* Return whether a given display plugin is an HMD
|
||||
* @function Window.isDisplayPluginHmd
|
||||
* @param {int} index - The index of the display plugin. Must be less than the value returned by {@link Window.getDisplayPluginCount|getDisplayPluginCount}.
|
||||
* @returns {bool} True if the specified display plugin is a HMD
|
||||
*/
|
||||
bool isDisplayPluginHmd(int index);
|
||||
|
||||
/**jsdoc
|
||||
* Return the currently active display plugin
|
||||
* @function Window.getActiveDisplayPlugin
|
||||
* @returns {int} The index of the currently active display plugin
|
||||
*/
|
||||
int getActiveDisplayPlugin();
|
||||
|
||||
/**jsdoc
|
||||
* Return the currently active display plugin
|
||||
* @function Window.setActiveDisplayPlugin
|
||||
* @param {int} index - The index of the display plugin. Must be less than the value returned by {@link Window.getDisplayPluginCount|getDisplayPluginCount}.
|
||||
*/
|
||||
void setActiveDisplayPlugin(int index);
|
||||
|
||||
|
||||
private slots:
|
||||
void onWindowGeometryChanged(const QRect& geometry);
|
||||
void onMessageBoxSelected(int button);
|
||||
|
|
Loading…
Reference in a new issue