summaryrefslogtreecommitdiff
path: root/gameView
diff options
context:
space:
mode:
authorAotrix <[email protected]>2026-10-10 16:09:48 +0200
committerAotrix <[email protected]>2026-10-10 16:09:48 +0200
commitc777502a1c22b240f66069831e6f0cb1e7e41b64 (patch)
tree6201b076b88ba6c50c4654b6da7abf8b5cda8267 /gameView
parent326f6cb61773c82182d91142749072aa3ca4c450 (diff)
Use string_view and delete gameViewHEADmaster
Diffstat (limited to 'gameView')
-rw-r--r--gameView/.clangd3
-rw-r--r--gameView/CMakeLists.txt8
-rw-r--r--gameView/main.cpp212
3 files changed, 0 insertions, 223 deletions
diff --git a/gameView/.clangd b/gameView/.clangd
deleted file mode 100644
index dddeaef..0000000
--- a/gameView/.clangd
+++ /dev/null
@@ -1,3 +0,0 @@
-CompileFlags:
- Remove:
- - -mno-direct-extern-access
diff --git a/gameView/CMakeLists.txt b/gameView/CMakeLists.txt
deleted file mode 100644
index 1e923f1..0000000
--- a/gameView/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-cmake_minimum_required(VERSION 3.20)
-
-project(GameView LANGUAGES CXX)
-
-set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
-add_executable(gameView main.cpp)
-find_package(Qt6 COMPONENTS Widgets REQUIRED)
-target_link_libraries(gameView PRIVATE Qt6::Widgets)
diff --git a/gameView/main.cpp b/gameView/main.cpp
deleted file mode 100644
index 2478735..0000000
--- a/gameView/main.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-#include <QVBoxLayout>
-#include <QtWidgets>
-#include <format>
-#include <fstream>
-#include <memory>
-#include <nlohmann/json.hpp>
-#include <qapplication.h>
-#include <qboxlayout.h>
-#include <qgridlayout.h>
-#include <qlistwidget.h>
-#include <qmenubar.h>
-#include <qnamespace.h>
-#include <qobject.h>
-#include <qpushbutton.h>
-#include <qtmetamacros.h>
-#include <qtoolbar.h>
-#include <qwidget.h>
-
-class ControlInterface : public QObject
-{
- public:
- ControlInterface& registerListOfCardsWidget(std::shared_ptr<QListWidget>& iListOfCards)
- {
- _listOfCardsWidget = iListOfCards;
- return *this;
- }
-
- ControlInterface& registerMainWindow(std::shared_ptr<QWidget>& iMainWindow)
- {
- _mainWindow = iMainWindow;
- return *this;
- }
-
- ControlInterface& registerMainMenuBar(std::shared_ptr<QMenuBar>& iMenuBar)
- {
- _mainMenuBar = iMenuBar;
- return *this;
- }
-
- ControlInterface& registerRightView(std::shared_ptr<QGraphicsView>& iRightView)
- {
- _rightView = iRightView;
- return *this;
- }
-
- std::shared_ptr<QWidget> listOfCardsWidget()
- {
- return _listOfCardsWidget;
- }
-
- std::shared_ptr<QWidget> mainWindow()
- {
- return _mainWindow;
- }
-
- std::shared_ptr<QMenuBar> mainMenuBar()
- {
- return _mainMenuBar;
- }
-
- std::shared_ptr<QGraphicsView> rightView()
- {
- return _rightView;
- }
-
- ControlInterface& configure()
- {
- configureListOfCardsWidget().configureMainMenuBar().configureRightGraphicsView();
- return *this;
- }
-
- public slots:
-
- void display_card(QListWidgetItem* iItem)
- {
- _popUpWindowSelectCard = std::make_shared<QWidget>(_mainWindow.get());
- _popUpWindowSelectCard->resize(400, 500);
- _popUpWindowSelectCard->setWindowFlag(Qt::WindowType::Dialog);
- _popUpWindowSelectCard->show();
- }
-
- private:
- std::shared_ptr<QListWidget> _listOfCardsWidget;
- std::shared_ptr<QWidget> _mainWindow;
- std::shared_ptr<QMenuBar> _mainMenuBar;
- std::shared_ptr<QGraphicsView> _rightView;
- std::shared_ptr<QGraphicsScene> _rightScene;
-
- std::vector<nlohmann::basic_json<>> _cards;
- std::shared_ptr<QWidget> _popUpWindowSelectCard;
-
- ControlInterface& fillListOfCards(const std::string& iCardsJsonPath)
- {
- std::ifstream aCardsJsonFile{iCardsJsonPath};
- uint64_t aCardIndex{0};
- _cards.clear();
- _listOfCardsWidget->clear();
- for (auto& aCard : nlohmann::json::parse(aCardsJsonFile))
- {
- _cards.push_back(aCard);
- _listOfCardsWidget->insertItem(aCardIndex++,
- std::format("{} ({})", aCard["name"].get<std::string>(),
- aCard["id"].get<uint64_t>())
- .c_str());
- }
- QObject::connect(_listOfCardsWidget.get(), &QListWidget::itemDoubleClicked, this,
- &ControlInterface::display_card);
- _listOfCardsWidget->setVisible(true);
- _listOfCardsWidget->setFixedWidth(_listOfCardsWidget->sizeHintForColumn(0) +
- 2 * _listOfCardsWidget->frameWidth() + 20);
- _mainWindow->resize(1500, 1000);
- return *this;
- }
-
- ControlInterface& configureListOfCardsWidget()
- {
- _listOfCardsWidget->hide();
- return *this;
- }
-
- ControlInterface& configureMainMenuBar()
- {
- QMenu* aOpenMenu = _mainMenuBar->addMenu("File");
- aOpenMenu->addAction("Open JSON file",
- [this]
- {
- QFileDialog aFileDialog;
- aFileDialog.setWindowTitle("Choose JSON file");
- QDir aCurrentDir{QDir::currentPath()};
- aFileDialog.setDirectory(aCurrentDir);
- aFileDialog.setFileMode(QFileDialog::ExistingFile);
- aFileDialog.setOption(QFileDialog::ShowDirsOnly, false);
- aFileDialog.setNameFilter("*.json");
- aFileDialog.exec();
- const QStringList kFilePaths{aFileDialog.selectedFiles()};
- if (kFilePaths.size() > 0)
- {
- fillListOfCards(kFilePaths[0].toStdString());
- _rightView->setVisible(true);
- }
- });
- aOpenMenu->addAction("Quit", [this] { _mainWindow->close(); });
- return *this;
- }
-
- ControlInterface& configureRightGraphicsView()
- {
- _rightScene = std::make_shared<QGraphicsScene>();
- QGraphicsRectItem* rect = _rightScene->addRect(QRectF(0, 0, 100, 100));
- QGraphicsItem* item = _rightScene->itemAt(50, 50, QTransform());
- _rightView->setScene(_rightScene.get());
- _rightView->hide();
- return *this;
- }
-};
-
-// int main(int argc,
-// char* argv[])
-//{
-// QApplication aApplication(argc, argv);
-// auto aWindow = std::make_shared<QWidget>();
-// aWindow->resize(400, 50);
-// // Set Dialog flag for i3 users
-// aWindow->setWindowFlag(Qt::WindowType::Dialog);
-//
-// QGridLayout aLayout(aWindow.get());
-// QHBoxLayout aHLayout(aLayout.widget());
-// auto aMenuBar = std::make_shared<QMenuBar>();
-// aLayout.addWidget(aMenuBar.get(), 0, 0);
-// auto aListOfCards = std::make_shared<QListWidget>();
-// aLayout.addLayout(&aHLayout, 1, 0);
-// aHLayout.addWidget(aListOfCards.get());
-// auto aRightView = std::make_shared<QGraphicsView>();
-// aHLayout.addWidget(aRightView.get());
-//
-// ControlInterface aControlInterface;
-// aControlInterface.registerListOfCardsWidget(aListOfCards)
-// .registerMainWindow(aWindow)
-// .registerMainMenuBar(aMenuBar)
-// .registerRightView(aRightView)
-// .configure();
-// aWindow->show();
-// aWindow->setWindowTitle("Hearthstone simulator");
-// return aApplication.exec();
-// }
-
-class ControlCentre : public QObject
-{
- Q_OBJECT
- public:
- /* view */
- public slots:
- void setView(/* View */);
-
- signals:
- void viewSelected(/* selected view */);
-
- private:
-};
-
-auto main(int argc,
- char* argv[]) -> int
-{
- QApplication aApplication(argc, argv);
- auto aWindow = std::make_shared<QWidget>();
- aWindow->resize(1400, 800);
- // Set Dialog flag for i3 users
- aWindow->setWindowFlag(Qt::WindowType::Dialog);
- aWindow->show();
- aWindow->setWindowTitle("Hearthstone simulator");
- return aApplication.exec();
-}