dolphin/Source/Core/DolphinQt/GBAWidget.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

113 lines
2.6 KiB
C
Raw Normal View History

2021-07-04 11:23:30 +00:00
// Copyright 2021 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
2021-07-24 17:12:17 +00:00
#include <optional>
2021-07-04 11:23:30 +00:00
#include <string>
#include <string_view>
#include <vector>
2021-07-22 20:19:50 +00:00
#include <QImage>
#include <QPoint>
2021-07-04 11:23:30 +00:00
#include <QWidget>
#include "Common/CommonTypes.h"
2021-07-22 21:22:47 +00:00
#include "Core/HW/GBACore.h"
2021-07-04 11:23:30 +00:00
class QCloseEvent;
class QContextMenuEvent;
class QDragEnterEvent;
class QDropEvent;
2021-07-24 17:12:17 +00:00
class QMouseEvent;
2021-07-04 11:23:30 +00:00
class QPaintEvent;
2021-07-24 17:12:17 +00:00
namespace NetPlay
{
struct PadDetails;
} // namespace NetPlay
2021-07-04 11:23:30 +00:00
class GBAWidget : public QWidget
{
Q_OBJECT
public:
2021-07-22 21:22:47 +00:00
explicit GBAWidget(std::weak_ptr<HW::GBA::Core> core, const HW::GBA::CoreInfo& info,
2021-07-24 17:12:17 +00:00
const std::optional<NetPlay::PadDetails>& netplay_pad);
2021-07-04 11:23:30 +00:00
~GBAWidget();
2021-07-22 21:22:47 +00:00
void GameChanged(const HW::GBA::CoreInfo& info);
2021-07-04 11:23:30 +00:00
void SetVideoBuffer(std::vector<u32> video_buffer);
void SetVolume(int volume);
void VolumeDown();
void VolumeUp();
bool IsMuted();
void ToggleMute();
void ToggleDisconnect();
void LoadROM();
void UnloadROM();
void PromptForEReaderCards();
2021-07-04 11:23:30 +00:00
void ResetCore();
void DoState(bool export_state);
void Resize(int scale);
2021-07-24 17:12:17 +00:00
bool IsBorderless() const;
void SetBorderless(bool enable);
2021-07-22 16:19:27 +00:00
bool IsAlwaysOnTop() const;
void SetAlwaysOnTop(bool enable);
2021-07-04 11:23:30 +00:00
private:
void UpdateTitle();
void UpdateVolume();
2021-07-24 17:12:17 +00:00
static Qt::WindowFlags LoadWindowFlags(int device_number);
void LoadSettings();
void SaveSettings();
2021-07-04 11:23:30 +00:00
bool CanControlCore();
bool CanResetCore();
void closeEvent(QCloseEvent* event) override;
void contextMenuEvent(QContextMenuEvent* event) override;
2021-07-24 17:12:17 +00:00
void mouseDoubleClickEvent(QMouseEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
2021-07-04 11:23:30 +00:00
void paintEvent(QPaintEvent* event) override;
void dragEnterEvent(QDragEnterEvent* event) override;
void dropEvent(QDropEvent* event) override;
std::weak_ptr<HW::GBA::Core> m_core;
2021-07-22 21:22:47 +00:00
HW::GBA::CoreInfo m_core_info;
2021-07-22 20:19:50 +00:00
QImage m_last_frame;
QImage m_previous_frame;
2021-07-04 11:23:30 +00:00
int m_local_pad;
bool m_is_local_pad;
2021-07-22 21:22:47 +00:00
std::string m_netplayer_name;
2021-07-04 11:23:30 +00:00
int m_volume;
bool m_muted;
bool m_force_disconnect;
bool m_moving;
QPoint m_move_pos;
2021-07-22 20:19:50 +00:00
bool m_interframe_blending;
2021-07-04 11:23:30 +00:00
};
class GBAWidgetController : public QObject
{
Q_OBJECT
public:
explicit GBAWidgetController() = default;
~GBAWidgetController();
2021-07-22 21:22:47 +00:00
void Create(std::weak_ptr<HW::GBA::Core> core, const HW::GBA::CoreInfo& info);
void GameChanged(const HW::GBA::CoreInfo& info);
2021-07-04 11:23:30 +00:00
void FrameEnded(std::vector<u32> video_buffer);
private:
GBAWidget* m_widget{};
};