-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
56 changed files
with
24,126 additions
and
4,156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/**************************************************************************** | ||
* Custom dialog - Clipboard browser | ||
* Author: Bill Forster | ||
* License: MIT license. Full text of license is in associated file LICENSE | ||
* Copyright 2010-2014, Bill Forster <billforsternz at gmail dot com> | ||
****************************************************************************/ | ||
#define _CRT_SECURE_NO_DEPRECATE | ||
#include "GameLogic.h" | ||
#include "ClipboardDialog.h" | ||
|
||
// ClipboardDialog constructors | ||
ClipboardDialog::ClipboardDialog | ||
( | ||
wxWindow *parent, | ||
GamesCache *gc, | ||
GamesCache *gc_clipboard, | ||
wxWindowID id, | ||
const wxPoint& pos, | ||
const wxSize& size, | ||
long style | ||
) : PgnDialog( parent, gc, gc_clipboard, id, pos, size, style ) | ||
{ | ||
} | ||
|
||
wxSizer *ClipboardDialog::GdvAddExtraControls() | ||
{ | ||
wxSizer *vsiz_panel_button1 = PgnDialog::GdvAddExtraControls(); | ||
filter_ctrl = new wxCheckBox( this, ID_DB_CHECKBOX, | ||
wxT("&Clipboard as temp database"), wxDefaultPosition, wxDefaultSize, 0 ); | ||
vsiz_panel_button1->Add(filter_ctrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); | ||
filter_ctrl->SetValue( objs.gl->db_clipboard ); | ||
return vsiz_panel_button1; | ||
} | ||
|
||
void ClipboardDialog::OnCheckBox( bool checked ) | ||
{ | ||
objs.gl->db_clipboard = checked; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/**************************************************************************** | ||
* Custom dialog - Clipboard browser | ||
* Author: Bill Forster | ||
* License: MIT license. Full text of license is in associated file LICENSE | ||
* Copyright 2010-2014, Bill Forster <billforsternz at gmail dot com> | ||
****************************************************************************/ | ||
#ifndef CLIPBOARD_DIALOG_H | ||
#define CLIPBOARD_DIALOG_H | ||
#include "wx/wx.h" | ||
#include "GameDocument.h" | ||
#include "PgnDialog.h" | ||
|
||
// ClipboardDialog class declaration | ||
class ClipboardDialog: public PgnDialog | ||
{ | ||
public: | ||
|
||
// Constructors | ||
ClipboardDialog | ||
( | ||
wxWindow *parent, | ||
GamesCache *gc, | ||
GamesCache *gc_clipboard, | ||
wxWindowID id, | ||
const wxPoint& pos = wxDefaultPosition, | ||
const wxSize& size = wxDefaultSize, | ||
long style = wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX | ||
); | ||
|
||
// Overrides | ||
virtual wxSizer *GdvAddExtraControls(); | ||
virtual void OnCheckBox( bool checked ); | ||
|
||
}; | ||
|
||
|
||
#endif // CLIPBOARD_DIALOG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/**************************************************************************** | ||
* Compact game representation | ||
* Author: Bill Forster | ||
* License: MIT license. Full text of license is in associated file LICENSE | ||
* Copyright 2010-2015, Bill Forster <billforsternz at gmail dot com> | ||
****************************************************************************/ | ||
|
||
#ifndef COMPACT_GAME_H | ||
#define COMPACT_GAME_H | ||
#include <string> | ||
#include <vector> | ||
#include <memory> | ||
#include "thc.h" | ||
|
||
class Roster | ||
{ | ||
public: | ||
std::string white; | ||
std::string black; | ||
std::string event; | ||
std::string site; | ||
std::string result; | ||
std::string round; | ||
std::string date; | ||
std::string eco; | ||
std::string white_elo; | ||
std::string black_elo; | ||
std::string fen; | ||
}; | ||
|
||
class GameDocument; | ||
|
||
class CompactGame | ||
{ | ||
public: | ||
CompactGame() { game_id=0; transpo_nbr=0; } | ||
Roster r; | ||
thc::ChessPosition start_position; | ||
std::vector< thc::Move > moves; | ||
|
||
// temp stuff hopefully | ||
int game_id; | ||
int transpo_nbr; | ||
|
||
std::string Description(); | ||
void Upscale( GameDocument &gd ); // to GameDocument | ||
void Downscale( GameDocument &gd ); // from GameDocument | ||
bool HaveStartPosition() { return (r.fen.length() > 0 ); } | ||
thc::ChessPosition &GetStartPosition() { if( r.fen.length()>0 ) start_position.Forsyth(r.fen.c_str()); return start_position; } | ||
|
||
// Return index into vector where start position found | ||
bool FindPositionInGame( uint64_t hash_to_match, int &idx ) | ||
{ | ||
thc::ChessRules cr = GetStartPosition(); | ||
size_t len = moves.size(); | ||
uint64_t hash = cr.Hash64Calculate(); | ||
bool found = (hash==hash_to_match); | ||
idx = 0; | ||
for( size_t i=0; !found && i<len; i++ ) | ||
{ | ||
thc::Move mv = moves[i]; | ||
hash = cr.Hash64Update( hash, mv ); | ||
if( hash == hash_to_match ) | ||
{ | ||
found = true; | ||
idx = static_cast<int>(i+1); | ||
break; | ||
} | ||
cr.PlayMove(mv); | ||
} | ||
return found; | ||
} | ||
|
||
}; | ||
|
||
#endif // COMPACT_GAME_H |
Oops, something went wrong.