From af47510b051f4c73e2d56ce91b4a66d8bc5e6b9e Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Tue, 15 Apr 2014 00:30:01 +0200 Subject: [PATCH] Initial script editor widget / icons made by MaximillianMerlin ty --- interface/resources/icons/load-script.svg | 125 ++++ interface/resources/icons/new-script.svg | 129 +++++ interface/resources/icons/save-script.svg | 674 ++++++++++++++++++++++ interface/src/Application.h | 1 + interface/src/Menu.cpp | 8 + interface/src/Menu.h | 4 + interface/src/ScriptHighlighting.cpp | 18 + interface/src/ScriptHighlighting.h | 25 + interface/src/ui/ScriptEditorWidget.cpp | 39 ++ interface/src/ui/ScriptEditorWidget.h | 34 ++ interface/src/ui/ScriptEditorWindow.cpp | 62 ++ interface/src/ui/ScriptEditorWindow.h | 39 ++ interface/ui/ScriptEditorWidget.ui | 89 +++ interface/ui/ScriptEditorWindow.ui | 290 ++++++++++ 14 files changed, 1537 insertions(+) create mode 100644 interface/resources/icons/load-script.svg create mode 100644 interface/resources/icons/new-script.svg create mode 100644 interface/resources/icons/save-script.svg create mode 100644 interface/src/ScriptHighlighting.cpp create mode 100644 interface/src/ScriptHighlighting.h create mode 100644 interface/src/ui/ScriptEditorWidget.cpp create mode 100644 interface/src/ui/ScriptEditorWidget.h create mode 100644 interface/src/ui/ScriptEditorWindow.cpp create mode 100644 interface/src/ui/ScriptEditorWindow.h create mode 100644 interface/ui/ScriptEditorWidget.ui create mode 100644 interface/ui/ScriptEditorWindow.ui diff --git a/interface/resources/icons/load-script.svg b/interface/resources/icons/load-script.svg new file mode 100644 index 0000000000..21be61c321 --- /dev/null +++ b/interface/resources/icons/load-script.svg @@ -0,0 +1,125 @@ + + + + + + + + + + image/svg+xml + + + + + T.Hofmeister + + + + + + + + + + + + + + + + + + + + + + diff --git a/interface/resources/icons/new-script.svg b/interface/resources/icons/new-script.svg new file mode 100644 index 0000000000..f68fcfa967 --- /dev/null +++ b/interface/resources/icons/new-script.svg @@ -0,0 +1,129 @@ + + + + + + + + + + image/svg+xml + + + + + T.Hofmeister + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/interface/resources/icons/save-script.svg b/interface/resources/icons/save-script.svg new file mode 100644 index 0000000000..04d41b8302 --- /dev/null +++ b/interface/resources/icons/save-script.svg @@ -0,0 +1,674 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + T.Hofmeister + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/interface/src/Application.h b/interface/src/Application.h index 6a14788caa..761b24bb31 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -244,6 +244,7 @@ public: void skipVersion(QString latestVersion); QStringList getRunningScripts() { return _scriptEnginesHash.keys(); } + ScriptEngine* getScriptEngine(QString scriptHash) { return _scriptEnginesHash.contains(scriptHash) ? _scriptEnginesHash[scriptHash] : NULL; } signals: diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 8ad55dec5b..87ab75cf3f 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -192,6 +192,7 @@ Menu::Menu() : QMenu* toolsMenu = addMenu("Tools"); addActionToQMenuAndActionHash(toolsMenu, MenuOption::MetavoxelEditor, 0, this, SLOT(showMetavoxelEditor())); + addActionToQMenuAndActionHash(toolsMenu, MenuOption::ScriptEditor, 0, this, SLOT(showScriptEditor())); #ifdef HAVE_QXMPP _chatAction = addActionToQMenuAndActionHash(toolsMenu, @@ -1058,6 +1059,13 @@ void Menu::showMetavoxelEditor() { _MetavoxelEditor->raise(); } +void Menu::showScriptEditor() { + if(!_ScriptEditor) { + _ScriptEditor = new ScriptEditorWindow(); + } + _ScriptEditor->raise(); +} + void Menu::showChat() { QMainWindow* mainWindow = Application::getInstance()->getWindow(); if (!_chatWindow) { diff --git a/interface/src/Menu.h b/interface/src/Menu.h index e827e43014..14ebbf356d 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -24,6 +24,7 @@ #include "location/LocationManager.h" #include "ui/PreferencesDialog.h" #include "ui/ChatWindow.h" +#include "ui/ScriptEditorWindow.h" const float ADJUST_LOD_DOWN_FPS = 40.0; const float ADJUST_LOD_UP_FPS = 55.0; @@ -161,6 +162,7 @@ private slots: void cycleFrustumRenderMode(); void runTests(); void showMetavoxelEditor(); + void showScriptEditor(); void showChat(); void toggleChat(); void audioMuteToggled(); @@ -212,6 +214,7 @@ private: FrustumDrawMode _frustumDrawMode; ViewFrustumOffset _viewFrustumOffset; QPointer _MetavoxelEditor; + QPointer _ScriptEditor; QPointer _chatWindow; OctreeStatsDialog* _octreeStatsDialog; LodToolsDialog* _lodToolsDialog; @@ -308,6 +311,7 @@ namespace MenuOption { const QString ResetAvatarSize = "Reset Avatar Size"; const QString RunningScripts = "Running Scripts"; const QString RunTimingTests = "Run Timing Tests"; + const QString ScriptEditor = "Script Editor..."; const QString SettingsExport = "Export Settings"; const QString SettingsImport = "Import Settings"; const QString Shadows = "Shadows"; diff --git a/interface/src/ScriptHighlighting.cpp b/interface/src/ScriptHighlighting.cpp new file mode 100644 index 0000000000..15505ac49a --- /dev/null +++ b/interface/src/ScriptHighlighting.cpp @@ -0,0 +1,18 @@ +// +// ScriptHighlighting.cpp +// interface/src +// +// Created by Thijs Wenker on 4/15/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "ScriptHighlighting.h" + +ScriptHighlighting::ScriptHighlighting(QObject* parent) : + QSyntaxHighlighter(parent) +{ + +} \ No newline at end of file diff --git a/interface/src/ScriptHighlighting.h b/interface/src/ScriptHighlighting.h new file mode 100644 index 0000000000..f2bd97930e --- /dev/null +++ b/interface/src/ScriptHighlighting.h @@ -0,0 +1,25 @@ +// +// ScriptHighlighting.h +// interface/src +// +// Created by Thijs Wenker on 4/15/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_ScriptHighlighting_h +#define hifi_ScriptHighlighting_h + +#include + +class ScriptHighlighting : public QSyntaxHighlighter { + Q_OBJECT + +public: + ScriptHighlighting(QObject* parent = 0); + +}; + +#endif // hifi_ScriptHighlighting_h diff --git a/interface/src/ui/ScriptEditorWidget.cpp b/interface/src/ui/ScriptEditorWidget.cpp new file mode 100644 index 0000000000..4adf01a28a --- /dev/null +++ b/interface/src/ui/ScriptEditorWidget.cpp @@ -0,0 +1,39 @@ +// +// ScriptEditorWidget.cpp +// interface/src/ui +// +// Created by Thijs Wenker on 4/14/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Application.h" +#include "ui_scriptEditorWidget.h" + +#include "ScriptEditorWidget.h" + +ScriptEditorWidget::ScriptEditorWidget() : + ui(new Ui::ScriptEditorWidget) +{ + ui->setupUi(this); + + // remove the title bar (see the Qt docs on setTitleBarWidget) + setTitleBarWidget(new QWidget()); + //QSyntaxHighlighter* highlighter = new QSyntaxHighlighter(); +} + +ScriptEditorWidget::~ScriptEditorWidget() { + delete ui; +} \ No newline at end of file diff --git a/interface/src/ui/ScriptEditorWidget.h b/interface/src/ui/ScriptEditorWidget.h new file mode 100644 index 0000000000..931ec105c9 --- /dev/null +++ b/interface/src/ui/ScriptEditorWidget.h @@ -0,0 +1,34 @@ +// +// ScriptEditorWidget.h +// interface/src/ui +// +// Created by Thijs Wenker on 4/14/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_ScriptEditorWidget_h +#define hifi_ScriptEditorWidget_h + +#include + +#include + +namespace Ui { +class ScriptEditorWidget; +} + +class ScriptEditorWidget : public QDockWidget { + Q_OBJECT + +public: + ScriptEditorWidget(); + ~ScriptEditorWidget(); + +private: + Ui::ScriptEditorWidget* ui; +}; + +#endif // hifi_ScriptEditorWidget_h diff --git a/interface/src/ui/ScriptEditorWindow.cpp b/interface/src/ui/ScriptEditorWindow.cpp new file mode 100644 index 0000000000..38fa26622a --- /dev/null +++ b/interface/src/ui/ScriptEditorWindow.cpp @@ -0,0 +1,62 @@ +// +// ScriptEditorWindow.cpp +// interface/src/ui +// +// Created by Thijs Wenker on 4/14/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Application.h" +#include "FlowLayout.h" +#include "ui_scriptEditorWindow.h" +#include "ScriptEditorWidget.h" + +#include "ScriptEditorWindow.h" + +ScriptEditorWindow::ScriptEditorWindow() : + ui(new Ui::ScriptEditorWindow) +{ + ui->setupUi(this); + show(); +} + +ScriptEditorWindow::~ScriptEditorWindow() { + delete ui; +} + +void ScriptEditorWindow::loadScriptClicked(){ + +} + +void ScriptEditorWindow::newScriptClicked(){ + addScriptEditorWidget(QString("new Script")); +} + +void ScriptEditorWindow::toggleRunScriptClicked(){ + +} + +void ScriptEditorWindow::saveScriptClicked(){ + +} + +void ScriptEditorWindow::addScriptEditorWidget(QString title){ + ScriptEditorWidget* newScriptEditorWidget = new ScriptEditorWidget();//ScriptEditorWidget(); + ui->tabWidget->addTab(newScriptEditorWidget, title); + ui->tabWidget->setCurrentWidget(newScriptEditorWidget); + newScriptEditorWidget->setUpdatesEnabled(true); + newScriptEditorWidget->adjustSize(); +} \ No newline at end of file diff --git a/interface/src/ui/ScriptEditorWindow.h b/interface/src/ui/ScriptEditorWindow.h new file mode 100644 index 0000000000..718826cf9d --- /dev/null +++ b/interface/src/ui/ScriptEditorWindow.h @@ -0,0 +1,39 @@ +// +// ScriptEditorWindow.h +// interface/src/ui +// +// Created by Thijs Wenker on 4/14/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_ScriptEditorWindow_h +#define hifi_ScriptEditorWindow_h + +#include + +namespace Ui { +class ScriptEditorWindow; +} + +class ScriptEditorWindow : public QWidget { + Q_OBJECT + +public: + ScriptEditorWindow(); + ~ScriptEditorWindow(); + +private: + Ui::ScriptEditorWindow* ui; + void addScriptEditorWidget(QString title); + +private slots: + void loadScriptClicked(); + void newScriptClicked(); + void toggleRunScriptClicked(); + void saveScriptClicked(); +}; + +#endif // hifi_ScriptEditorWindow_h diff --git a/interface/ui/ScriptEditorWidget.ui b/interface/ui/ScriptEditorWidget.ui new file mode 100644 index 0000000000..82398d587c --- /dev/null +++ b/interface/ui/ScriptEditorWidget.ui @@ -0,0 +1,89 @@ + + + ScriptEditorWidget + + + + 0 + 0 + 702 + 543 + + + + + 0 + 0 + + + + + 400 + 238 + + + + font-family: Helvetica, Arial, sans-serif; + + + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable + + + Qt::NoDockWidgetArea + + + Edit Script + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + Courier + 9 + 50 + false + false + + + + font: 9pt "Courier"; + + + + + + + Debug Log: + + + + + + + font: 8pt "Courier"; + + + + + + + + + diff --git a/interface/ui/ScriptEditorWindow.ui b/interface/ui/ScriptEditorWindow.ui new file mode 100644 index 0000000000..a612b2b1c9 --- /dev/null +++ b/interface/ui/ScriptEditorWindow.ui @@ -0,0 +1,290 @@ + + + ScriptEditorWindow + + + Qt::WindowModal + + + + 0 + 0 + 474 + 638 + + + + + 400 + 250 + + + + Script editor [] + + + font-family: Helvetica, Arial, sans-serif; + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 3 + + + QLayout::SetNoConstraint + + + 0 + + + 0 + + + + + New Script + + + New + + + + ../resources/icons/new-script.svg + ../resources/images/pinned.svg../resources/icons/new-script.svg + + + + 32 + 32 + + + + + + + + + 30 + 0 + + + + + 25 + 0 + + + + Load Script + + + Load + + + + ../resources/icons/load-script.svg../resources/icons/load-script.svg + + + + 32 + 32 + + + + false + + + QToolButton::MenuButtonPopup + + + Qt::ToolButtonIconOnly + + + + + + + + 0 + 2 + + + + Qt::NoFocus + + + Qt::NoContextMenu + + + Save Script + + + Save + + + + ../resources/icons/save-script.svg../resources/icons/save-script.svg + + + + 32 + 32 + + + + 316 + + + + + + + Toggle Run Script + + + Run/Stop + + + + ../resources/images/plus.svg../resources/images/plus.svg + + + + 32 + 32 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + true + + + + 250 + 80 + + + + QTabWidget::West + + + QTabWidget::Triangular + + + -1 + + + Qt::ElideNone + + + true + + + true + + + + + + + + + saveButton + clicked() + ScriptEditorWindow + saveScriptClicked() + + + 236 + 10 + + + 199 + 264 + + + + + toggleRunButton + clicked() + ScriptEditorWindow + toggleRunScriptClicked() + + + 330 + 10 + + + 199 + 264 + + + + + newButton + clicked() + ScriptEditorWindow + newScriptClicked() + + + 58 + 10 + + + 199 + 264 + + + + + loadButton + clicked() + ScriptEditorWindow + loadScriptClicked() + + + 85 + 10 + + + 199 + 264 + + + + +