mirror of
https://github.com/InoriRus/Kyty.git
synced 2026-08-28 05:06:40 +00:00
add launcher
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#ifndef LAUNCHER_INCLUDE_COMMON_H_
|
||||
#define LAUNCHER_INCLUDE_COMMON_H_
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <QArgument>
|
||||
#include <QObject>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
// IWYU pragma: end_exports
|
||||
|
||||
#define KYTY_QT_CLASS_NO_COPY(name) \
|
||||
public: \
|
||||
name(const name&) = delete; /* NOLINT(bugprone-macro-parentheses) */ \
|
||||
name& operator=(const name&) = delete; /* NOLINT(bugprone-macro-parentheses) */ \
|
||||
name(name&&) noexcept = delete; /* NOLINT(bugprone-macro-parentheses) */ \
|
||||
name& operator=(name&&) noexcept = delete; /* NOLINT(bugprone-macro-parentheses) */
|
||||
|
||||
#define KYTY_QT_CLASS_DEFAULT_COPY(name) \
|
||||
public: \
|
||||
name(const name&) = default; /* NOLINT(bugprone-macro-parentheses) */ \
|
||||
name& operator=(const name&) = default; /* NOLINT(bugprone-macro-parentheses) */ \
|
||||
name(name&&) noexcept = default; /* NOLINT(bugprone-macro-parentheses) */ \
|
||||
name& operator=(name&&) noexcept = default; /* NOLINT(bugprone-macro-parentheses) */
|
||||
|
||||
#endif /* LAUNCHER_INCLUDE_COMMON_H_ */
|
||||
@@ -0,0 +1,180 @@
|
||||
#ifndef LAUNCHER_INCLUDE_CONFIGURATION_H_
|
||||
#define LAUNCHER_INCLUDE_CONFIGURATION_H_
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QChar>
|
||||
#include <QMetaEnum>
|
||||
#include <QMetaType>
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QVariant>
|
||||
|
||||
#define KYTY_CFG_SETL(n) s->setValue(#n, n);
|
||||
#define KYTY_CFG_SET(n) s->setValue(#n, QVariant::fromValue(n).toString());
|
||||
#define KYTY_CFG_GET(n) n = s->value(#n).value<decltype(n)>();
|
||||
#define KYTY_CFG_GETL(n) n = s->value(#n).toStringList();
|
||||
|
||||
#define KYTY_LIBS \
|
||||
{ \
|
||||
"libc_internal_1", "libkernel_1", "libVideoOut_1", "libSysmodule_1", "libDiscMap_1", "libDebug_1", "libGraphicsDriver_1", \
|
||||
"libUserService_1", "libPad_1" \
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline QStringList EnumToList()
|
||||
{
|
||||
QStringList ret;
|
||||
auto me = QMetaEnum::fromType<T>();
|
||||
int count = me.keyCount();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
auto key = QString(me.key(i));
|
||||
ret << (key.startsWith('R') && key.size() > 2 && key.at(1).isDigit() ? key.remove('R').toLower() : key);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T TextToEnum(const QString& text)
|
||||
{
|
||||
auto me = QMetaEnum::fromType<T>();
|
||||
return static_cast<T>(me.keyToValue(((text.size() > 1 && text.at(0).isDigit()) ? 'R' + text.toUpper() : text).toUtf8().data()));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
QString EnumToText(T value)
|
||||
{
|
||||
auto me = QMetaEnum::fromType<T>();
|
||||
auto key = QString(me.valueToKey(static_cast<int>(value)));
|
||||
return (key.startsWith('R') && key.size() > 2 && key.at(1).isDigit() ? key.remove('R').toLower() : key);
|
||||
}
|
||||
|
||||
namespace Kyty {
|
||||
|
||||
class Configuration: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum class Resolution
|
||||
{
|
||||
R1280X720,
|
||||
R1920X1080,
|
||||
};
|
||||
Q_ENUM(Resolution)
|
||||
|
||||
enum class ShaderOptimizationType
|
||||
{
|
||||
None,
|
||||
Size,
|
||||
Performance
|
||||
};
|
||||
Q_ENUM(ShaderOptimizationType)
|
||||
|
||||
enum class ShaderLogDirection
|
||||
{
|
||||
Silent,
|
||||
Console,
|
||||
File
|
||||
};
|
||||
Q_ENUM(ShaderLogDirection)
|
||||
|
||||
enum class ProfilerDirection
|
||||
{
|
||||
None,
|
||||
File,
|
||||
Network,
|
||||
FileAndNetwork
|
||||
};
|
||||
Q_ENUM(ProfilerDirection)
|
||||
|
||||
enum class LogDirection
|
||||
{
|
||||
Silent,
|
||||
Console,
|
||||
File
|
||||
};
|
||||
Q_ENUM(LogDirection)
|
||||
|
||||
Configuration() = default;
|
||||
|
||||
QString Name;
|
||||
QString BaseDir; /* Game base directory */
|
||||
|
||||
Resolution screen_resolution = Resolution::R1280X720;
|
||||
bool neo = true;
|
||||
bool vulkan_validation_enabled = true;
|
||||
bool shader_validation_enabled = true;
|
||||
ShaderOptimizationType shader_optimization_type = ShaderOptimizationType::Performance;
|
||||
ShaderLogDirection shader_log_direction = ShaderLogDirection::Silent;
|
||||
QString shader_log_folder = "_Shaders";
|
||||
bool command_buffer_dump_enabled = false;
|
||||
QString command_buffer_dump_folder = "_Buffers";
|
||||
LogDirection printf_direction = LogDirection::Silent;
|
||||
QString printf_output_file = "_kyty.txt";
|
||||
ProfilerDirection profiler_direction = ProfilerDirection::None;
|
||||
QString profiler_output_file = "_profile.prof";
|
||||
bool spirv_debug_printf_enabled = false;
|
||||
|
||||
QStringList elfs;
|
||||
QStringList elfs_selected;
|
||||
QStringList libs = KYTY_LIBS;
|
||||
QStringList libs_selected = KYTY_LIBS;
|
||||
|
||||
void WriteSettings(QSettings* s) const
|
||||
{
|
||||
KYTY_CFG_SET(Name);
|
||||
KYTY_CFG_SET(BaseDir);
|
||||
KYTY_CFG_SET(screen_resolution);
|
||||
KYTY_CFG_SET(neo);
|
||||
KYTY_CFG_SET(vulkan_validation_enabled);
|
||||
KYTY_CFG_SET(shader_validation_enabled);
|
||||
KYTY_CFG_SET(shader_optimization_type);
|
||||
KYTY_CFG_SET(shader_log_direction);
|
||||
KYTY_CFG_SET(shader_log_folder);
|
||||
KYTY_CFG_SET(command_buffer_dump_enabled);
|
||||
KYTY_CFG_SET(command_buffer_dump_folder);
|
||||
KYTY_CFG_SET(printf_direction);
|
||||
KYTY_CFG_SET(printf_output_file);
|
||||
KYTY_CFG_SET(profiler_direction);
|
||||
KYTY_CFG_SET(profiler_output_file);
|
||||
KYTY_CFG_SET(spirv_debug_printf_enabled);
|
||||
KYTY_CFG_SETL(elfs);
|
||||
KYTY_CFG_SETL(elfs_selected);
|
||||
KYTY_CFG_SETL(libs);
|
||||
KYTY_CFG_SETL(libs_selected);
|
||||
}
|
||||
|
||||
void ReadSettings(QSettings* s)
|
||||
{
|
||||
KYTY_CFG_GET(Name);
|
||||
KYTY_CFG_GET(BaseDir);
|
||||
KYTY_CFG_GET(screen_resolution);
|
||||
KYTY_CFG_GET(neo);
|
||||
KYTY_CFG_GET(vulkan_validation_enabled);
|
||||
KYTY_CFG_GET(shader_validation_enabled);
|
||||
KYTY_CFG_GET(shader_optimization_type);
|
||||
KYTY_CFG_GET(shader_log_direction);
|
||||
KYTY_CFG_GET(shader_log_folder);
|
||||
KYTY_CFG_GET(command_buffer_dump_enabled);
|
||||
KYTY_CFG_GET(command_buffer_dump_folder);
|
||||
KYTY_CFG_GET(printf_direction);
|
||||
KYTY_CFG_GET(printf_output_file);
|
||||
KYTY_CFG_GET(profiler_direction);
|
||||
KYTY_CFG_GET(profiler_output_file);
|
||||
KYTY_CFG_GET(spirv_debug_printf_enabled);
|
||||
KYTY_CFG_GETL(elfs);
|
||||
KYTY_CFG_GETL(elfs_selected);
|
||||
KYTY_CFG_GETL(libs);
|
||||
KYTY_CFG_GETL(libs_selected);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Kyty
|
||||
|
||||
Q_DECLARE_METATYPE(Kyty::Configuration*)
|
||||
|
||||
#endif /* LAUNCHER_INCLUDE_CONFIGURATION_H_ */
|
||||
@@ -0,0 +1,62 @@
|
||||
#ifndef CONFIGURATION_EDIT_DIALOG_H
|
||||
#define CONFIGURATION_EDIT_DIALOG_H
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QProcess>
|
||||
#include <QString>
|
||||
class QByteArray;
|
||||
class QMoveEvent;
|
||||
class QSettings;
|
||||
class ConfigurationListWidget;
|
||||
|
||||
namespace Kyty {
|
||||
class Configuration;
|
||||
} // namespace Kyty
|
||||
|
||||
namespace Ui {
|
||||
class ConfigurationEditDialog;
|
||||
} // namespace Ui
|
||||
|
||||
class ConfigurationEditDialog: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
KYTY_QT_CLASS_NO_COPY(ConfigurationEditDialog);
|
||||
|
||||
public:
|
||||
explicit ConfigurationEditDialog(Kyty::Configuration* info, ConfigurationListWidget* parent = nullptr);
|
||||
~ConfigurationEditDialog() override;
|
||||
|
||||
static void WriteSettings(QSettings* s);
|
||||
static void ReadSettings(QSettings* s);
|
||||
|
||||
void SetTitle(const QString& str);
|
||||
|
||||
private:
|
||||
Ui::ConfigurationEditDialog* m_ui = nullptr;
|
||||
Kyty::Configuration* m_info = nullptr;
|
||||
QProcess m_process;
|
||||
ConfigurationListWidget* m_parent = nullptr;
|
||||
|
||||
protected:
|
||||
void Init();
|
||||
|
||||
void moveEvent(QMoveEvent* event) override;
|
||||
|
||||
static QString g_last_base_dir;
|
||||
static QByteArray g_last_geometry;
|
||||
|
||||
/*slots:*/
|
||||
|
||||
void update_info();
|
||||
void adjust_size();
|
||||
void save();
|
||||
void browse_base_path();
|
||||
void scan_elfs();
|
||||
void scan_libs();
|
||||
void clear();
|
||||
void test();
|
||||
};
|
||||
|
||||
#endif // CONFIGURATION_EDIT_DIALOG_H
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef CONFIGURATION_ITEM_H
|
||||
#define CONFIGURATION_ITEM_H
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
#include <QListWidgetItem>
|
||||
|
||||
namespace Kyty {
|
||||
class Configuration;
|
||||
} // namespace Kyty
|
||||
|
||||
class ConfigurationItem: public QListWidgetItem
|
||||
{
|
||||
public:
|
||||
explicit ConfigurationItem(Kyty::Configuration* info, QListWidget* parent);
|
||||
~ConfigurationItem() override;
|
||||
|
||||
void Update();
|
||||
|
||||
KYTY_QT_CLASS_NO_COPY(ConfigurationItem);
|
||||
|
||||
Kyty::Configuration* GetInfo() { return m_info; }
|
||||
[[nodiscard]] const Kyty::Configuration* GetInfo() const { return m_info; }
|
||||
// void SetInfo(Kyty::Configuration* info);
|
||||
void SetRunning(bool state);
|
||||
[[nodiscard]] bool IsRunning() const { return m_running; }
|
||||
|
||||
private:
|
||||
Kyty::Configuration* m_info = nullptr;
|
||||
bool m_running = false;
|
||||
};
|
||||
|
||||
#endif // CONFIGURATION_ITEM_H
|
||||
@@ -0,0 +1,64 @@
|
||||
#ifndef CONFIGURATION_LIST_WIDGET_H
|
||||
#define CONFIGURATION_LIST_WIDGET_H
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
||||
class ConfigurationItem;
|
||||
class QListWidgetItem;
|
||||
class QPoint;
|
||||
class MainDialog;
|
||||
|
||||
namespace Ui {
|
||||
class ConfigurationListWidget;
|
||||
} // namespace Ui
|
||||
|
||||
class ConfigurationListWidget: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
KYTY_QT_CLASS_NO_COPY(ConfigurationListWidget);
|
||||
|
||||
public:
|
||||
explicit ConfigurationListWidget(QWidget* parent = nullptr);
|
||||
~ConfigurationListWidget() override;
|
||||
|
||||
void SetRunEnabled(bool flag) { m_run_enabled = flag; }
|
||||
[[nodiscard]] bool IsRunEnabled() const { return m_run_enabled; }
|
||||
|
||||
[[nodiscard]] const ConfigurationItem* GetSelectedItem() const { return m_selected_item; }
|
||||
ConfigurationItem* GetSelectedItem() { return m_selected_item; }
|
||||
|
||||
void SetMainDialog(MainDialog* main_dialog) { m_main_dialog = main_dialog; }
|
||||
MainDialog* GetMainDialog() { return m_main_dialog; }
|
||||
|
||||
[[nodiscard]] const QString& GetSettingsFile() const { return m_settings_file; }
|
||||
|
||||
signals:
|
||||
|
||||
void Run();
|
||||
void Select();
|
||||
|
||||
public slots:
|
||||
void WriteSettings();
|
||||
void ReadSettings();
|
||||
|
||||
protected slots:
|
||||
|
||||
void add_configuration();
|
||||
void edit_configuration();
|
||||
void delete_configuartion();
|
||||
void run_configuration();
|
||||
void list_itemClicked(QListWidgetItem* witem);
|
||||
void show_context_menu(const QPoint& pos);
|
||||
|
||||
private:
|
||||
ConfigurationItem* m_selected_item = nullptr;
|
||||
bool m_run_enabled = true;
|
||||
Ui::ConfigurationListWidget* m_ui = nullptr;
|
||||
MainDialog* m_main_dialog = nullptr;
|
||||
QString m_settings_file;
|
||||
};
|
||||
|
||||
#endif // CONFIGURATION_LIST_WIDGET_H
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef MAIN_DIALOG_H
|
||||
#define MAIN_DIALOG_H
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
|
||||
class QWidget;
|
||||
class QProcess;
|
||||
class MainDialogPrivate;
|
||||
class QSettings;
|
||||
class QResizeEvent;
|
||||
|
||||
namespace Kyty {
|
||||
class Configuration;
|
||||
} // namespace Kyty
|
||||
|
||||
class MainDialog: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
KYTY_QT_CLASS_NO_COPY(MainDialog);
|
||||
|
||||
signals:
|
||||
void Start();
|
||||
void Quit();
|
||||
void Resize();
|
||||
|
||||
public:
|
||||
explicit MainDialog(QWidget* parent = nullptr);
|
||||
~MainDialog() override = default;
|
||||
|
||||
void RunInterpreter(QProcess* process, Kyty::Configuration* info, bool con_emu);
|
||||
|
||||
static void WriteSettings(QSettings* s);
|
||||
static void ReadSettings(QSettings* s);
|
||||
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
|
||||
private:
|
||||
MainDialogPrivate* m_p = nullptr;
|
||||
};
|
||||
|
||||
#endif // MAIN_DIALOG_H
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef MANDATORY_LINEEDIT_H
|
||||
#define MANDATORY_LINEEDIT_H
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QString>
|
||||
|
||||
class QPaintEvent;
|
||||
class QWidget;
|
||||
|
||||
constexpr char MANDATORY_AND_EMPTY[] = "mandatory_and_empty";
|
||||
|
||||
class MandatoryLineEdit: public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MandatoryLineEdit(QWidget* parent = nullptr);
|
||||
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
|
||||
static bool FindEmpty(QObject* p);
|
||||
|
||||
protected slots:
|
||||
|
||||
void changed(const QString& text);
|
||||
};
|
||||
|
||||
#endif // MANDATORY_LINEEDIT_H
|
||||
Reference in New Issue
Block a user