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