#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QProcess>
#include <QPushButton>
#include <QMainWindow>
#include "ChooseModsWindow.h"
#include "SettingsWindow.h"
#include <QCloseEvent>
#include <QNetworkReply>
#include <Downloader.h>

namespace Ui{
class MainWindow;
}

class MainWindow : public QMainWindow{

	Q_OBJECT

	public:
		explicit MainWindow(QWidget* parent = nullptr);
		~MainWindow();
		void init();
		void closeApp();
		bool getGTAExecutable();
		void getGtaVersionThrewInternet(bool shouldUpdate, bool warnUpToDate = false);
		void getLauncherVersion(bool warnUpToDate = false);
		bool checkGtaAlreadyStarted(bool showMessage = true);
		static QString m_gtaDirectoryStr;
		static QString m_disabledModsDirectoryStr;
		static bool m_launcherCracked;
	private:
		ChooseModsWindow *m_chooseModsWindow = nullptr;
		SettingsWindow *m_settingsWindow = nullptr;
		Downloader *m_checkGtaVersion = nullptr;
		Downloader *m_checkLauncherVersion = nullptr;
		bool m_updCheckLauncher = false;
		bool m_updCheckScriptHookV = false;
		Version m_lastOfficialGTAVersion;
		bool isSteamVersion() const;
		bool checkOS();
		void setBackground();
		void setFavicon();
		void setButtons();
		void connectAll();
		void closeEvent(QCloseEvent *event);
		bool removeScriptHookVDinput(bool permanent = false);
		void addScriptHookVDinput();
		bool checkNeedSteamAndOk();
		Ui::MainWindow* ui;
		QString findGamePath();
		void setRelativeDirs(const QString &base);
		void setGtaVersion();
		static Version getScriptHookVVersion();
		static void setGTAHighPriority();
		bool checkForUpdateCompatibility();
		void startGTANoUpdate();
		void showThanksMessage();
		Version getGtaVersion() const;
		void setTitle();
	public slots:
		void gotLauncherVersionSlot(QByteArray resp, bool warnUpToDate);
		void uninstallLauncherSlot(bool shouldCloseApp = true, bool confirmation = true);
		void closeAppSlot();
		void startGtaArgsSlot(QStringList args = QStringList());
		void startGtaOnlineSlot();
		void startGtaWithModsSlot(bool offlineMode = false, bool checkForCompatibility = true, bool addScriptHook = true);
		void showChooseModsWindowSlot();
		void downloadFinishedSlot(QByteArray resp, bool askForUpdate, bool warnUpToDate);
		void showSettingsWindowSlot();
		void showPlayContextualMenuSlot(const QPoint &pos);
	protected:
		void changeEvent(QEvent *event) override;
};

#endif // MAINWINDOW_H
