Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: Video capability for MCMP and Lua API #6439

Draft
wants to merge 38 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7c4bced
Improve: StickMUD default listing to secure port
mpconley Sep 11, 2022
cf5230b
Merge pull request #1 from mpconley/stickmud-secure
mpconley Sep 11, 2022
1b2a22e
Merge branch 'Mudlet:development' into development
mpconley Oct 9, 2022
8aa0cb9
Merge branch 'Mudlet:development' into development
mpconley Oct 23, 2022
5c5a37b
Fix: Update TMediaPlayer Lists
mpconley Oct 23, 2022
7d635aa
Merge branch 'Mudlet:development' into development
mpconley Oct 29, 2022
ec37367
Merge branch 'Mudlet:development' into development
mpconley Nov 5, 2022
5721a1f
Merge branch 'Mudlet:development' into development
mpconley Nov 12, 2022
0d692e9
Add video
mpconley Nov 23, 2022
f4d1f20
Update comment
mpconley Nov 23, 2022
a6472b5
Apply suggestions from code review
mpconley Nov 24, 2022
f6d583e
Implementing review feedback
mpconley Nov 24, 2022
5de86c3
Implementing review feedback
mpconley Nov 24, 2022
42268de
Implementing review feedback
mpconley Nov 24, 2022
f543ab4
Implementing review feedback
mpconley Nov 24, 2022
b59b749
Merge branch 'development' into video_player
vadi2 Nov 24, 2022
dc17605
Implementing review feedback
mpconley Nov 24, 2022
cf4d5b1
Merge branch 'video_player' of https://github.com/mpconley/Mudlet int…
mpconley Nov 24, 2022
0ad1741
MCMP video fix
mpconley Nov 24, 2022
8ed2980
Restore video to menu bar
mpconley Nov 24, 2022
9bb779c
Remove blank line from mudlet.pro
mpconley Nov 24, 2022
ab27222
Restore empty string ref
mpconley Nov 24, 2022
c6ca669
Stream media (not Youtube)
mpconley Nov 25, 2022
565883c
Reduced files
mpconley Nov 25, 2022
6fc091d
Event rename
mpconley Nov 26, 2022
5e1fb57
Latest updates
mpconley Nov 26, 2022
570eedd
Merge branch 'development' into video_player
vadi2 Nov 26, 2022
039f8e2
Merge branch 'development' into video_player
mpconley Nov 26, 2022
86e333e
Small additions
mpconley Nov 26, 2022
c4e6289
Small additions
mpconley Nov 26, 2022
13aca7e
Small additions
mpconley Nov 26, 2022
71a9745
Video button/shortcut control
mpconley Nov 27, 2022
3b5f687
Merge branch 'development' into video_player
SlySven Nov 27, 2022
044b751
Anti-pasta
mpconley Nov 27, 2022
c9cda17
Merge branch 'video_player' of https://github.com/mpconley/Mudlet int…
mpconley Nov 27, 2022
91b2d86
Anti-pasta
mpconley Nov 27, 2022
5d139ba
stream = [bool]
mpconley Nov 28, 2022
53b3318
Merge branch 'development' into video_player
mpconley Dec 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/CMakeLists.txt
Expand Up @@ -78,6 +78,7 @@ set(mudlet_SRCS
dlgTriggerPatternEdit.cpp
dlgTriggersMainArea.cpp
dlgVarsMainArea.cpp
dlgVideoPlayer.cpp
EAction.cpp
exitstreewidget.cpp
FontManager.cpp
Expand Down Expand Up @@ -154,6 +155,7 @@ set(mudlet_SRCS
TTreeWidget.cpp
TTrigger.cpp
TVar.cpp
TVideoPlayer.cpp
VarUnit.cpp
XMLexport.cpp
XMLimport.cpp)
Expand Down Expand Up @@ -196,7 +198,8 @@ set(mudlet_UIS
ui/triggers_main_area.ui
ui/trigger_editor.ui
ui/trigger_pattern_edit.ui
ui/vars_main_area.ui)
ui/vars_main_area.ui
ui/videoplayer.ui)
mpconley marked this conversation as resolved.
Show resolved Hide resolved

set(mudlet_HDRS
ActionUnit.h
Expand Down Expand Up @@ -233,6 +236,7 @@ set(mudlet_HDRS
dlgTriggerPatternEdit.h
dlgTriggersMainArea.h
dlgVarsMainArea.h
dlgVideoPlayer.h
EAction.h
exitstreewidget.h
FontManager.h
Expand Down Expand Up @@ -318,6 +322,7 @@ set(mudlet_HDRS
TTreeWidget.h
TTrigger.h
TVar.h
TVideoPlayer.h
VarUnit.h
utils.h
widechar_width.h
Expand Down Expand Up @@ -362,6 +367,7 @@ find_package(
Qt5 5.14 REQUIRED
COMPONENTS Core
Multimedia
MultimediaWidgets
Network
OpenGL
UiTools
Expand Down Expand Up @@ -476,6 +482,7 @@ target_link_libraries(
Qt5::Core
Qt5::Network
Qt5::Multimedia
Qt5::MultimediaWidgets
Qt5::OpenGL
Qt5::UiTools
Qt5::Widgets
Expand Down
161 changes: 157 additions & 4 deletions src/Host.cpp
Expand Up @@ -26,14 +26,13 @@


#include "LuaInterface.h"
#include "TConsole.h"
#include "TDebug.h"
#include "TMainConsole.h"
#include "TCommandLine.h"
#include "TConsole.h"
#include "TDebug.h"
#include "TDockWidget.h"
#include "TEvent.h"
#include "TLabel.h"
#include "TMainConsole.h"
#include "TMap.h"
#include "TMedia.h"
#include "TRoomDB.h"
Expand All @@ -42,12 +41,13 @@
#include "TToolBar.h"
#include "VarUnit.h"
#include "XMLimport.h"
#include "dlgIRC.h"
#include "dlgMapper.h"
#include "dlgModuleManager.h"
#include "dlgNotepad.h"
#include "dlgPackageManager.h"
#include "dlgProfilePreferences.h"
#include "dlgIRC.h"
#include "dlgVideoPlayer.h"
#include "mudlet.h"

#include "pre_guard.h"
Expand Down Expand Up @@ -314,6 +314,7 @@ Host::Host(int port, const QString& hostname, const QString& login, const QStrin
, mBubbleMode(false)
, mShowRoomID(false)
, mShowPanel(true)
, mShowVideoPlayerPanel(true)
mpconley marked this conversation as resolved.
Show resolved Hide resolved
, mServerGUI_Package_version(QLatin1String("-1"))
, mServerGUI_Package_name(QLatin1String("nothing"))
, mAcceptServerGUI(true)
Expand All @@ -325,6 +326,7 @@ Host::Host(int port, const QString& hostname, const QString& login, const QStrin
, mFORCE_MXP_NEGOTIATION_OFF(false)
, mFORCE_CHARSET_NEGOTIATION_OFF(false)
, mpDockableMapWidget()
, mpDockableVideoPlayerWidget()
mpconley marked this conversation as resolved.
Show resolved Hide resolved
, mEnableTextAnalyzer(false)
, mTimerDebugOutputSuppressionInterval(QTime())
, mSearchOptions(dlgTriggerEditor::SearchOption::SearchOptionNone)
Expand Down Expand Up @@ -467,6 +469,11 @@ Host::~Host()
if (mpDockableMapWidget) {
mpDockableMapWidget->deleteLater();
}

if (mpDockableVideoPlayerWidget) {
mpDockableVideoPlayerWidget->deleteLater();
}

mIsGoingDown = true;
mIsClosingDown = true;
mErrorLogStream.flush();
Expand Down Expand Up @@ -2794,6 +2801,21 @@ std::pair<bool, QString> Host::setMapperTitle(const QString& title)
return {true, QString()};
}

std::pair<bool, QString> Host::setVideoPlayerTitle(const QString& title)
{
if (!mpDockableVideoPlayerWidget) {
return {false, "no floating/dockable type video player window found"};
}

if (title.isEmpty()) {
mpDockableVideoPlayerWidget->setWindowTitle(tr("Video Player - %1").arg(mHostName));
} else {
mpDockableVideoPlayerWidget->setWindowTitle(title);
}

return {true, QString()};
}

void Host::setDebugShowAllProblemCodepoints(const bool state)
{
if (mDebugShowAllProblemCodepoints != state) {
Expand Down Expand Up @@ -3432,6 +3454,88 @@ std::pair<bool, QString> Host::closeMapWidget()
return {true, QString()};
}

std::pair<bool, QString> Host::openVideoPlayerWidget(const QString& area, int x, int y, int width, int height)
{
if (!mpConsole) {
return {false, QString()};
}

auto pM = mpDockableVideoPlayerWidget;
auto pVideoPlayer = mpMedia->mpVideoPlayer;

if (!pM && !pVideoPlayer) {
showHideOrCreateVideoPlayer();
pM = mpDockableVideoPlayerWidget;
}

if (!pM) {
return {false, qsl("cannot create video player widget. Do you already use an embedded video player?")};
}

pM->show();

if (area.isEmpty()) {
return {true, QString()};
}

if (area == QLatin1String("f") || area == QLatin1String("floating")) {
if (!pM->isFloating()) {
// Undock a docked window
// Change of position or size is only possible when floating
pM->setFloating(true);
}

if ((x != -1) && (y != -1)) {
pM->move(x, y);
}

if ((width != -1) && (height != -1)) {
pM->resize(width, height);
}
return {true, QString()};
} else {
mpconley marked this conversation as resolved.
Show resolved Hide resolved
if (area == QLatin1String("r") || area == QLatin1String("right")) {
pM->setFloating(false);
mudlet::self()->addDockWidget(Qt::RightDockWidgetArea, pM);
return {true, QString()};
} else if (area == QLatin1String("l") || area == QLatin1String("left")) {
pM->setFloating(false);
mudlet::self()->addDockWidget(Qt::LeftDockWidgetArea, pM);
return {true, QString()};
} else if (area == QLatin1String("t") || area == QLatin1String("top")) {
pM->setFloating(false);
mudlet::self()->addDockWidget(Qt::TopDockWidgetArea, pM);
return {true, QString()};
} else if (area == QLatin1String("b") || area == QLatin1String("bottom")) {
pM->setFloating(false);
mudlet::self()->addDockWidget(Qt::BottomDockWidgetArea, pM);
return {true, QString()};
} else {
return {false, qsl(R"("docking option "%1" not available. available docking options are "t" top, "b" bottom, "r" right, "l" left and "f" floating")").arg(area)};
}
}
}

std::pair<bool, QString> Host::closeVideoPlayerWidget()
{
if (!mpConsole) {
return {false, QString()};
}

auto pM = mpDockableVideoPlayerWidget;

if (!pM) {
return {false, qsl("no video player widget found to close")};
}

if (!pM->isVisible()) {
return {false, qsl("video player widget already closed")};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this counts as a warning - unlike the mapper I do not know whether it is possible to completely remove an extant "video player" whereas we only ever hide (but do not destroy) the mapper (which causes other issues if the user wishes to change from one embedded in a console to a floating/dockable one - as it cannot be done without closing the profile - which I would not like to see replicated in this new feature...!)

}

pM->hide();
return {true, QString()};
}

bool Host::closeWindow(const QString& name)
{
if (!mpConsole) {
Expand Down Expand Up @@ -3675,17 +3779,24 @@ bool Host::setProfileStyleSheet(const QString& styleSheet)
if (mpDlgProfilePreferences) {
mpDlgProfilePreferences->setStyleSheet(styleSheet);
}

if (mpNotePad) {
mpNotePad->setStyleSheet(styleSheet);
mpNotePad->notesEdit->setStyleSheet(styleSheet);
}

if (mpDockableMapWidget) {
mpDockableMapWidget->setStyleSheet(styleSheet);
}

if (mpDockableVideoPlayerWidget) {
mpDockableVideoPlayerWidget->setStyleSheet(styleSheet);
}

for (auto& dockWidget : mpConsole->mDockWidgetMap) {
dockWidget->setStyleSheet(styleSheet);
}

if (this == mudlet::self()->mpCurrentActiveHost) {
mudlet::self()->setGlobalStyleSheet(styleSheet);
}
Expand Down Expand Up @@ -3903,6 +4014,48 @@ void Host::createMapper(const bool loadDefaultMap)
raiseEvent(mapOpenEvent);
}

void Host::showHideOrCreateVideoPlayer()
{
if (mpMedia->mpVideoPlayer) {
toggleVideoPlayerVisibility();
return;
}

createVideoPlayer();
}

void Host::toggleVideoPlayerVisibility()
{
bool visStatus = mpMedia->mpVideoPlayer->isVisible();
mpconley marked this conversation as resolved.
Show resolved Hide resolved

if (mpMedia->mpVideoPlayer->isFloatAndDockable()) {
mpMedia->mpVideoPlayer->parentWidget()->setVisible(!visStatus);
} else {
mpMedia->mpVideoPlayer->setVisible(!visStatus);
}
}

void Host::createVideoPlayer()
{
auto pMedia = mpMedia.data();
auto hostName(getName());

mpDockableVideoPlayerWidget = new QDockWidget(tr("Video Player - %1").arg(hostName));
mpDockableVideoPlayerWidget->setObjectName(qsl("dockVideoPlayer_%1").arg(hostName));

pMedia->mpVideoPlayer = new dlgVideoPlayer(mpDockableVideoPlayerWidget, this, pMedia);
pMedia->mpVideoPlayer->setStyleSheet(mProfileStyleSheet);
mpDockableVideoPlayerWidget->setWidget(pMedia->mpVideoPlayer);

mudlet::self()->addDockWidget(Qt::RightDockWidgetArea, mpDockableVideoPlayerWidget);
mudlet::self()->loadWindowLayout();

TEvent videoPlayerOpenEvent{};
videoPlayerOpenEvent.mArgumentList.append(QLatin1String("videoPlayerOpenEvent"));
mpconley marked this conversation as resolved.
Show resolved Hide resolved
videoPlayerOpenEvent.mArgumentTypeList.append(ARGUMENT_TYPE_STRING);
raiseEvent(videoPlayerOpenEvent);
}

void Host::setDockLayoutUpdated(const QString& name)
{
if (!mpConsole) {
Expand Down
10 changes: 9 additions & 1 deletion src/Host.h
Expand Up @@ -341,6 +341,7 @@ class Host : public QObject
void setSearchOptions(const dlgTriggerEditor::SearchOptions);
void setBufferSearchOptions(const TConsole::SearchOptions);
std::pair<bool, QString> setMapperTitle(const QString&);
std::pair<bool, QString> setVideoPlayerTitle(const QString&);
void setDebugShowAllProblemCodepoints(const bool);
bool debugShowAllProblemCodepoints() const { return mDebugShowAllProblemCodepoints; }
void setCompactInputLine(const bool state);
Expand All @@ -365,6 +366,8 @@ class Host : public QObject
std::pair<bool, QString> setWindow(const QString& windowname, const QString& name, int x1, int y1, bool show);
std::pair<bool, QString> openMapWidget(const QString& area, int x, int y, int width, int height);
std::pair<bool, QString> closeMapWidget();
std::pair<bool, QString> openVideoPlayerWidget(const QString& area, int x, int y, int width, int height);
std::pair<bool, QString> closeVideoPlayerWidget();
bool closeWindow(const QString&);
bool echoWindow(const QString&, const QString&);
bool pasteWindow(const QString& name);
Expand All @@ -386,6 +389,7 @@ class Host : public QObject
bool setBackgroundImage(const QString& name, QString& path, int mode);
bool resetBackgroundImage(const QString& name);
void showHideOrCreateMapper(const bool loadDefaultMap);
void showHideOrCreateVideoPlayer();
bool setProfileStyleSheet(const QString& styleSheet);
void check_for_mappingscript();
void setupIreDriverBugfix();
Expand Down Expand Up @@ -619,7 +623,8 @@ class Host : public QObject
bool mBubbleMode;
bool mMapViewOnly = true;
bool mShowRoomID;
bool mShowPanel;
bool mShowPanel; // Mapper
bool mShowVideoPlayerPanel;
mpconley marked this conversation as resolved.
Show resolved Hide resolved
QString mServerGUI_Package_version;
QString mServerGUI_Package_name;
bool mAcceptServerGUI;
Expand All @@ -632,6 +637,7 @@ class Host : public QObject
bool mFORCE_CHARSET_NEGOTIATION_OFF;
QSet<QChar> mDoubleClickIgnore;
QPointer<QDockWidget> mpDockableMapWidget;
QPointer<QDockWidget> mpDockableVideoPlayerWidget;
bool mEnableTextAnalyzer;
bool mWritingHostAndModules = false;
// Set from profile preferences, if the timer interval is less
Expand Down Expand Up @@ -704,6 +710,8 @@ private slots:
void thankForUsingPTB();
void toggleMapperVisibility();
void createMapper(const bool);
void createVideoPlayer();
void toggleVideoPlayerVisibility();
void removePackageInfo(const QString &packageName, const bool);
static void createModuleBackup(const QString &filename, const QString& saveName);
void writeModule(const QString &moduleName, const QString &filename);
Expand Down
1 change: 1 addition & 0 deletions src/TConsole.cpp
Expand Up @@ -38,6 +38,7 @@
#include "TSplitter.h"
#include "TTextEdit.h"
#include "dlgMapper.h"
#include "dlgVideoPlayer.h"
#include "mudlet.h"

#include "pre_guard.h"
Expand Down
2 changes: 2 additions & 0 deletions src/TConsole.h
Expand Up @@ -64,6 +64,7 @@ class QScrollBar;
class QToolButton;

class dlgMapper;
class dlgVideoPlayer;
class Host;
class TTextEdit;
class TCommandLine;
Expand Down Expand Up @@ -266,6 +267,7 @@ class TConsole : public QWidget
QWidget* mpMainDisplay = nullptr;

dlgMapper* mpMapper = nullptr;
dlgVideoPlayer* mpVideoPlayer = nullptr;

QScrollBar* mpScrollBar = nullptr;
QScrollBar* mpHScrollBar = nullptr;
Expand Down