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>
|
2023-12-13 15:04:44 +00:00
|
|
|
#include <span>
|
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>
|
2021-07-22 16:02:34 +00:00
|
|
|
#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);
|
2023-12-13 15:07:17 +00:00
|
|
|
~GBAWidget() override;
|
2021-07-04 11:23:30 +00:00
|
|
|
|
2021-07-22 21:22:47 +00:00
|
|
|
void GameChanged(const HW::GBA::CoreInfo& info);
|
2023-12-13 15:04:44 +00:00
|
|
|
void SetVideoBuffer(std::span<const u32> video_buffer);
|
2021-07-04 11:23:30 +00:00
|
|
|
|
|
|
|
void SetVolume(int volume);
|
|
|
|
void VolumeDown();
|
|
|
|
void VolumeUp();
|
|
|
|
bool IsMuted();
|
|
|
|
void ToggleMute();
|
|
|
|
void ToggleDisconnect();
|
|
|
|
|
|
|
|
void LoadROM();
|
|
|
|
void UnloadROM();
|
2021-07-22 07:15:49 +00:00
|
|
|
void PromptForEReaderCards();
|
2021-07-04 11:23:30 +00:00
|
|
|
void ResetCore();
|
|
|
|
void DoState(bool export_state);
|
2021-11-21 17:04:33 +00:00
|
|
|
void ImportExportSave(bool export_save);
|
2021-07-04 11:23:30 +00:00
|
|
|
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;
|
2021-07-22 16:02:34 +00:00
|
|
|
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;
|
2021-07-22 16:02:34 +00:00
|
|
|
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;
|
2023-12-13 15:07:17 +00:00
|
|
|
~GBAWidgetController() override;
|
2021-07-04 11:23:30 +00:00
|
|
|
|
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);
|
2023-12-13 15:04:44 +00:00
|
|
|
void FrameEnded(std::span<const u32> video_buffer);
|
2021-07-04 11:23:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
GBAWidget* m_widget{};
|
|
|
|
};
|