Commit 7554a929 authored by Loic Guegan's avatar Loic Guegan
Browse files

Update

parent 02773ce8
Pipeline #213331407 passed with stage
in 6 minutes and 56 seconds
#ifndef VIEW_HPP
#define VIEW_HPP
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include <memory>
namespace ochess {
namespace gui {
class Controller;
class View {
public:
virtual wxMenu* GetMenu() {
return (nullptr);
}
};
} // namespace gui
} // namespace ochess
#endif
......@@ -9,7 +9,7 @@ EVT_KEY_DOWN(BoardPanel::HandleKey)
END_EVENT_TABLE()
BoardPanel::BoardPanel(wxFrame *parent) :
wxPanel(parent), Configurable("BoardView"), C(this) {
wxPanel(parent), Configurable("BoardView") {
UA = std::make_shared<UserActions>();
CNF.AddModule(this);
UA->IsDraggingPiece = false;
......
#ifndef BOARDPANEL_HPP
#define BOARDPANEL_HPP
#ifndef GUI_BOARD_BOARDPANEL_HPP
#define GUI_BOARD_BOARDPANEL_HPP
#include "gui/View.hpp"
#include "controller/BoardController.hpp"
#include "controller/DrawingToolBox.hpp"
#include "controller/Skin.hpp"
......@@ -27,7 +26,7 @@ typedef struct UserActions {
bool WasDragging;
} UserActions;
class BoardPanel: public wxPanel, public Configurable, public View {
class BoardPanel: public wxPanel, public Configurable {
private:
BoardController C;
std::shared_ptr<UserActions> UA;
......
#include "BoardView.hpp"
#include <wx/artprov.h>
namespace ochess {
namespace gui {
......@@ -17,7 +18,6 @@ BoardView::BoardView(wxFrame *parent) :
BP = new BoardPanel((wxFrame*) this);
vbox->Add(toolbar, 0, wxEXPAND, 0);
vbox->Add(BP, 1, wxEXPAND, 20);
this->SetSizer(vbox);
}
......
#ifndef BOARDVIEW_HPP
#define BOARDVIEW_HPP
#ifndef GUI_BOARD_BOARDVIEW_HPP
#define GUI_BOARD_BOARDVIEW_HPP
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include "gui/View.hpp"
#include "BoardPanel.hpp"
namespace ochess {
namespace gui {
class BoardView: public wxPanel, public View {
class BoardView: public wxPanel {
private:
public:
BoardPanel *BP;
......
......@@ -3,9 +3,8 @@
namespace ochess {
namespace gui {
BoardController::BoardController(View *v) :
BoardController::BoardController() :
G(FEN_INITIAL) {
V = v;
bfs::path enginePath = "./engine";
if (bfs::exists(enginePath)) {
BlackEngine = new Engine(enginePath);
......
#ifndef BOARDCONTROLLER_HPP
#define BOARDCONTROLLER_HPP
#ifndef GUI_BOARD_CONTROLLER_BOARDCONTROLLER_HPP_
#define GUI_BOARD_CONTROLLER_BOARDCONTROLLER_HPP_
#include "gui/View.hpp"
#include "DrawingToolBox.hpp"
#include "Skin.hpp"
#include "model/Game.hpp"
......@@ -21,14 +20,13 @@ namespace gui {
class BoardController: public DrawingToolBox {
private:
View *V;
Engine *BlackEngine;
public:
Game G;
std::vector<Coord> HLS;
std::vector<std::pair<Coord, Coord>> Arrows;
BoardController(View *v);
BoardController();
void Move(Coord src, Coord dst);
......
#ifndef DRAWINGTOOLBOX_HPP
#define DRAWINGTOOLBOX_HPP
#ifndef GUI_BOARD_CONTROLLER_DRAWINGTOOLBOX_HPP_
#define GUI_BOARD_CONTROLLER_DRAWINGTOOLBOX_HPP_
#include "model/Board.hpp"
#include "Skin.hpp"
......
#ifndef SKIN_HPP
#define SKIN_HPP
#ifndef GUI_BOARD_CONTROLLER_SKIN_HPP_
#define GUI_BOARD_CONTROLLER_SKIN_HPP_
#include "ochess.hpp"
#include <wx/wxprec.h>
......
......@@ -5,8 +5,7 @@ namespace gui {
EngineView::EngineView() :
wxDialog(NULL, -1, "Engine Configuration", wxDefaultPosition,
wxSize(250, 230)),C(this) {
// panel = new wxPanel(this, -1);
wxSize(250, 230)) {
this->Bind(wxEVT_CLOSE_WINDOW, &EngineView::OnClose, this);
menu = new wxMenu;
menu->Append(599, "Add Engine", "llll");
......
#ifndef ENGINEPANEL_HPP
#define ENGINEPANEL_HPP
#ifndef GUI_ENGINE_ENGINEVIEW_HPP
#define GUI_ENGINE_ENGINEVIEW_HPP
#include "gui/View.hpp"
#include "controller/EngineController.hpp"
#include "ochess.hpp"
#include "wx/sizer.h"
#include "wx/wx.h"
......@@ -11,15 +9,13 @@
namespace ochess {
namespace gui {
class EngineView: public wxDialog, public View {
class EngineView: public wxDialog {
private:
EngineController C;
//wxPanel *panel;
wxMenu *menu;
public:
EngineView();
wxMenu* GetMenu() override;
wxMenu* GetMenu();
void OnClose(wxCloseEvent &event);
void AddEngine(wxCommandEvent &event);
......
#include "EngineController.hpp"
namespace ochess {
namespace gui {
EngineController::EngineController(View *v) {
V = v;
}
} // namespace gui
} // namespace ochess
#ifndef ENGINECONTROLLER_HPP
#define ENGINECONTROLLER_HPP
#include "../../../log.hpp"
#include "engine/Engine.hpp"
#include "gui/View.hpp"
namespace ochess {
namespace gui {
class EngineController {
private:
View *V;
public:
EngineController(View *v);
};
} // namespace gui
} // namespace ochess
#endif
......@@ -48,6 +48,11 @@ void MainFrame::Create(WIN name) {
}
}
}
wxWindow* MainFrame::operator[](WIN name){
if(Windows.find(name)==Windows.end())
Create(name);
return(Windows[name]);
}
MainFrame::MainFrame(const wxString &title, const wxPoint &pos,
const wxSize &size) :
......@@ -65,9 +70,10 @@ wxFrame(NULL, wxID_ANY, title, pos, size) {
menuBar->Append(getPiecesMenu(), "Pieces");
Create(BOARD);
//Create(ENGINE);
//menuBar->Append(e->GetMenu(), "Engines");
wxWindow* w=(*this)[ENGINE];
EngineView* v=(EngineView*)w;
menuBar->Append(v->GetMenu(), "Engines");
this->Bind(wxEVT_CLOSE_WINDOW, &MainFrame::OnClose, this);
menuBar->Append(getSquaresMenu(), "Board");
SetMenuBar(menuBar);
......
......@@ -5,11 +5,14 @@
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include "gui/board/BoardView.hpp"
#include "gui/engine/EngineView.hpp"
#include "ochess.hpp"
#include <unordered_map>
#define GET_VIEW(mainFrame, entry, viewType) ((viewType*)(*((MainFrame*)(mainFrame)))[(entry)])
namespace ochess {
namespace gui {
......@@ -34,6 +37,7 @@ public:
* @param size The size.
*/
MainFrame(const wxString &title, const wxPoint &pos, const wxSize &size);
wxWindow* operator[](WIN name);
private:
/**
* Main window components
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment