aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/MainWindow.cpp30
-rw-r--r--src/base_tab/BasePanelBF.cpp31
-rw-r--r--src/base_tab/BasePanelBF.h12
-rw-r--r--src/base_tab/BaseTab.cpp15
-rw-r--r--src/base_tab/BaseTab.hpp3
5 files changed, 46 insertions, 45 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 5c1a87f..afca91e 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -51,12 +51,6 @@ MainWindow::MainWindow()
notebook = new wxAuiNotebook(this, wxID_ANY);
NewGame(new Game());
- // Test base tab
- BaseTab *bt = new BaseTab((wxFrame *)notebook);
- bt->SetLabel("New Base");
- notebook->AddPage(bt, bt->GetLabel());
- notebook->SetSelection(notebook->GetPageIndex(bt));
-
Bind(wxEVT_AUINOTEBOOK_PAGE_CHANGED, &MainWindow::OnPageChange, this,
wxID_ANY);
Bind(REFRESH_TAB_TITLE, &MainWindow::OnRefreshTabTitle, this, wxID_ANY);
@@ -112,26 +106,10 @@ void MainWindow::OnOpen(wxCommandEvent &event) {
wxFD_OPEN | wxFD_FILE_MUST_EXIST);
if (openFileDialog.ShowModal() != wxID_CANCEL) {
std::string path = openFileDialog.GetPath().ToStdString();
- pgnp::PGN pgn;
- try {
- pgn.FromFile(path);
- pgn.ParseNextGame();
- pgnp::HalfMove *pgnp_moves = new pgnp::HalfMove();
- pgn.GetMoves(pgnp_moves);
- std::string fen =
- "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
- if (pgn.HasTag("FEN")) {
- fen = pgn.GetTagValue("FEN");
- }
- HalfMove *m = new HalfMove(pgnp_moves, fen);
- Game *g = new Game(m, fen);
- for (std::string &s : pgn.GetTagList()) {
- g->SetTag(s, pgn.GetTagValue(s));
- }
- NewGame(g);
- } catch (std::exception &e) {
- SHOW_DIALOG_ERROR("Invalid PGN file: " + std::string(e.what()));
- }
+ // Test base tab
+ BaseTab *bt = new BaseTab((wxFrame *)notebook, path);
+ notebook->AddPage(bt, bt->GetLabel());
+ notebook->SetSelection(notebook->GetPageIndex(bt));
}
}
diff --git a/src/base_tab/BasePanelBF.cpp b/src/base_tab/BasePanelBF.cpp
index c6b8381..e179ec0 100644
--- a/src/base_tab/BasePanelBF.cpp
+++ b/src/base_tab/BasePanelBF.cpp
@@ -17,13 +17,8 @@ BasePanelBF::BasePanelBF( wxWindow* parent, wxWindowID id, const wxPoint& pos, c
wxBoxSizer* top_sizer;
top_sizer = new wxBoxSizer( wxHORIZONTAL );
- current_base_label = new wxStaticText( this, wxID_ANY, wxT("Current base:"), wxDefaultPosition, wxDefaultSize, 0 );
- current_base_label->Wrap( -1 );
- top_sizer->Add( current_base_label, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
-
- current_base = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
- current_base->Enable( false );
-
+ current_base = new wxStaticText( this, wxID_ANY, wxT("unknown"), wxDefaultPosition, wxDefaultSize, 0 );
+ current_base->Wrap( -1 );
top_sizer->Add( current_base, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
save_button = new wxButton( this, wxID_ANY, wxT("Save"), wxDefaultPosition, wxDefaultSize, 0 );
@@ -35,18 +30,36 @@ BasePanelBF::BasePanelBF( wxWindow* parent, wxWindowID id, const wxPoint& pos, c
main_sizer->Add( top_sizer, 0, wxEXPAND, 5 );
- game_list = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxLC_REPORT );
- main_sizer->Add( game_list, 1, wxALL|wxEXPAND, 5 );
+ separator_1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
+ main_sizer->Add( separator_1, 0, wxEXPAND | wxALL, 5 );
wxBoxSizer* bottom_sizer;
bottom_sizer = new wxBoxSizer( wxHORIZONTAL );
+ append_choice_label = new wxStaticText( this, wxID_ANY, wxT("Import games from:"), wxDefaultPosition, wxDefaultSize, 0 );
+ append_choice_label->Wrap( -1 );
+ bottom_sizer->Add( append_choice_label, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+
+ wxArrayString append_choiceChoices;
+ append_choice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, append_choiceChoices, 0 );
+ append_choice->SetSelection( 0 );
+ bottom_sizer->Add( append_choice, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+
+ append_button = new wxButton( this, wxID_ANY, wxT("Append"), wxDefaultPosition, wxDefaultSize, 0 );
+ bottom_sizer->Add( append_button, 0, wxALL, 5 );
+
+
+ bottom_sizer->Add( 0, 0, 1, wxEXPAND, 5 );
+
delete_button = new wxButton( this, wxID_ANY, wxT("Delete selection"), wxDefaultPosition, wxDefaultSize, 0 );
bottom_sizer->Add( delete_button, 0, wxALL, 5 );
main_sizer->Add( bottom_sizer, 0, wxEXPAND, 5 );
+ game_list = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxLC_REPORT );
+ main_sizer->Add( game_list, 1, wxALL|wxEXPAND, 5 );
+
this->SetSizer( main_sizer );
this->Layout();
diff --git a/src/base_tab/BasePanelBF.h b/src/base_tab/BasePanelBF.h
index 63c4939..1bbbea1 100644
--- a/src/base_tab/BasePanelBF.h
+++ b/src/base_tab/BasePanelBF.h
@@ -15,12 +15,13 @@
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
-#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/sizer.h>
+#include <wx/statline.h>
+#include <wx/choice.h>
#include <wx/listctrl.h>
#include <wx/panel.h>
@@ -35,12 +36,15 @@ class BasePanelBF : public wxPanel
private:
protected:
- wxStaticText* current_base_label;
- wxTextCtrl* current_base;
+ wxStaticText* current_base;
wxButton* save_button;
wxButton* export_button;
- wxListCtrl* game_list;
+ wxStaticLine* separator_1;
+ wxStaticText* append_choice_label;
+ wxChoice* append_choice;
+ wxButton* append_button;
wxButton* delete_button;
+ wxListCtrl* game_list;
public:
diff --git a/src/base_tab/BaseTab.cpp b/src/base_tab/BaseTab.cpp
index 95a1a8d..82a0db0 100644
--- a/src/base_tab/BaseTab.cpp
+++ b/src/base_tab/BaseTab.cpp
@@ -1,7 +1,7 @@
#include "BaseTab.hpp"
#include <wx/filename.h>
-BaseTab::BaseTab(wxFrame *parent)
+BaseTab::BaseTab(wxFrame *parent, std::string base_file)
: BasePanelBF(parent), TabInfos(TabInfos::BASE), base(NULL) {
game_list->InsertColumn(0, L"id", wxLIST_FORMAT_LEFT, 50);
@@ -14,11 +14,11 @@ BaseTab::BaseTab(wxFrame *parent)
this->Bind(wxEVT_BUTTON, &BaseTab::OnBim, this, wxID_ANY);
this->Bind(wxEVT_LIST_ITEM_ACTIVATED, &BaseTab::OnOpenGame, this, wxID_ANY);
+ current_base->SetLabel(base_file);
+ LoadFile(base_file);
}
-void BaseTab::OnBim(wxCommandEvent &event) {
- LoadFile("/home/loic/hartwig.pgn");
-}
+void BaseTab::OnBim(wxCommandEvent &event) {}
void BaseTab::OnOpenGame(wxListEvent &event) {
wxLogDebug("Open!");
@@ -39,6 +39,7 @@ void BaseTab::LoadFile(std::string path) {
wxString ext = file.GetExt().Lower();
if (ext == "pgn") {
base = new PGNGameBase(path);
+ SetLabel(file.GetName()+ "(PGN)");
}
if (base != NULL) {
@@ -51,8 +52,12 @@ void BaseTab::LoadFile(std::string path) {
game_list->SetItem(index, 3, base->GetTag("Event"));
game_list->SetItem(index, 4, base->GetTag("Round"));
game_list->SetItem(index, 5, base->GetTag("Result"));
- game_list->SetItem(index, 5, base->GetTag("ECO"));
+ game_list->SetItem(index, 6, base->GetTag("ECO"));
id++;
}
}
+
+ wxCommandEvent event(REFRESH_TAB_TITLE, GetId());
+ event.SetEventObject(this);
+ ProcessEvent(event);
} \ No newline at end of file
diff --git a/src/base_tab/BaseTab.hpp b/src/base_tab/BaseTab.hpp
index 26ee8c1..3283102 100644
--- a/src/base_tab/BaseTab.hpp
+++ b/src/base_tab/BaseTab.hpp
@@ -6,12 +6,13 @@
// Foreign events
wxDECLARE_EVENT(NEW_GAME_EVENT, wxCommandEvent);
+wxDECLARE_EVENT(REFRESH_TAB_TITLE, wxCommandEvent);
class BaseTab : public BasePanelBF, public TabInfos {
GameBase *base;
public:
- BaseTab(wxFrame *parent);
+ BaseTab(wxFrame *parent, std::string base_file);
void ApplyPreferences();
void LoadFile(std::string path);
void OnBim(wxCommandEvent &event);