├── AmHttpSocket.cpp ├── AmHttpSocket.h ├── AutoBoardText.cpp ├── AutoBoardText.h ├── Bdt.cpp ├── Bdt.h ├── Board.cpp ├── Board.h ├── BoardBitmap ├── Brick1.bmp ├── Brick2.bmp ├── Brick3.bmp ├── Brick4.bmp ├── Cloth1.bmp ├── Cloth2.bmp ├── Cloth3.bmp ├── Cloth4.bmp ├── Marble1.bmp ├── Marble2.bmp ├── Marble3.bmp ├── Marble4.bmp ├── Wood1.bmp ├── Wood2.bmp ├── Wood3.bmp ├── Wood4.bmp └── Wood5.bmp ├── Buf.cpp ├── Buf.h ├── CISBitmap.cpp ├── CISBitmap.h ├── DIBSectionLite.cpp ├── DIBSectionLite.h ├── Debug └── bestmove.dll ├── EditBoardText.cpp ├── EditBoardText.h ├── External ├── Debug │ ├── ForbiddenPointFinder.lib │ └── bestmove.lib ├── ForbiddenPointFinder.h ├── Release │ ├── ForbiddenPointFinder.lib │ └── bestmove.lib └── bestmove.h ├── FileInfo.cpp ├── FileInfo.h ├── FolderDlg.cpp ├── FolderDlg.h ├── Font.cpp ├── Font.h ├── FontDialog.h ├── GCColorEdit.cpp ├── GCColorEdit.h ├── Game.cpp ├── Game.h ├── HyperLink.cpp ├── HyperLink.h ├── IntReg.cpp ├── IntReg.h ├── LibraryFile.cpp ├── LibraryFile.h ├── MainFrm.cpp ├── MainFrm.h ├── MergeComment.cpp ├── MergeComment.h ├── ModeInformationI.h ├── MoveList.cpp ├── MoveList.h ├── MoveNode.cpp ├── MoveNode.h ├── Pdb.cpp ├── Pdb.h ├── Pos.cpp ├── Pos.h ├── Position.cpp ├── Position.h ├── ProgressWnd.cpp ├── ProgressWnd.h ├── README.md ├── Rdf.cpp ├── Rdf.h ├── Registry.cpp ├── Registry.h ├── Release └── bestmove.dll ├── RenJS.cpp ├── RenJS.h ├── RenLib.cpp ├── RenLib.dsp ├── RenLib.dsw ├── RenLib.gif ├── RenLib.h ├── RenLib.rc ├── RenLibApplet.cpp ├── RenLibApplet.h ├── RenLibAppletDialog.cpp ├── RenLibAppletDialog.h ├── RenLibDoc.cpp ├── RenLibDoc.h ├── RenLibUsersGuide.htm ├── RenLibView.cpp ├── RenLibView.h ├── Renartist.cpp ├── Renartist.h ├── Renjuclass.cpp ├── Renjuclass.h ├── SearchComment.cpp ├── SearchComment.h ├── SearchItem.cpp ├── SearchItem.h ├── SearchList.cpp ├── SearchList.h ├── SearchMove.cpp ├── SearchMove.h ├── Sgf.cpp ├── Sgf.h ├── Stack.cpp ├── Stack.h ├── StdAfx.cpp ├── StdAfx.h ├── StringEx.cpp ├── StringEx.h ├── TextBoard.cpp ├── TextBoard.h ├── TextBoxDlg.cpp ├── TextBoxDlg.h ├── Tree.cpp ├── Tree.h ├── Utils.cpp ├── Utils.h ├── Wzq.cpp ├── Wzq.h ├── applet ├── BlackWin.gif ├── Board.class ├── Command.class ├── Defs.class ├── Draw.gif ├── Move.class ├── MultiLineComment.class ├── OneLineComment.class ├── Parser.class ├── RenLibApplet.class ├── Text.class ├── Variant.class ├── WhiteWin.gif ├── b.gif ├── black19.gif ├── black32.gif ├── board19.gif ├── board32.gif ├── index.htm ├── w.gif ├── white19.gif └── white32.gif ├── cgfiltyp.cpp ├── cgfiltyp.h ├── res ├── InvalidBitmap.bmp ├── RenLib.ico ├── RenLib.rc2 ├── RenLibDoc.ico ├── hand.cur ├── stoneBlackLarge.bmp ├── stoneBlackSmall.bmp ├── stoneBlackSmallMedium.bmp ├── stoneWhiteLarge.bmp ├── stoneWhiteMedium.bmp ├── stoneWhiteSmall.bmp ├── toolbaredit.bmp ├── toolbarfile.bmp ├── toolbarfind.bmp ├── toolbarmove.bmp ├── toolbarposition.bmp └── vssver.scc ├── resource.h ├── webbrowser2.cpp └── webbrowser2.h /AmHttpSocket.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "AmHttpSocket.h" 3 | #include 4 | #include 5 | 6 | #define AgentName _T("Nimo Software HTTP Retriever 1.0") 7 | 8 | //case insensitive search functions... 9 | #ifdef UNICODE 10 | #define _tcsustr wcsustr 11 | #else 12 | #define _tcsustr strustr 13 | #endif 14 | char* strustr(char *source, char *s); 15 | wchar_t* wcsustr(wchar_t *source, wchar_t *s); 16 | 17 | char* strustr(char *source, char *s) 18 | { 19 | //make an uppercase copy af source and s 20 | char *csource = strdup(source); 21 | char *cs = strdup(s); 22 | strupr(csource); 23 | strupr(cs); 24 | //find cs in csource... 25 | char *result = strstr(csource, cs); 26 | if (result != NULL) 27 | { 28 | //cs is somewhere in csource 29 | int pos = result - csource; 30 | result = source; 31 | result += pos; 32 | } 33 | //clean up 34 | free(csource); 35 | free(cs); 36 | return result; 37 | } 38 | 39 | wchar_t* wcsustr(wchar_t *source, wchar_t *s) 40 | { 41 | //make an uppercase copy af source and s 42 | wchar_t *csource = wcsdup(source); 43 | wchar_t *cs = wcsdup(s); 44 | wcsupr(csource); 45 | wcsupr(cs); 46 | //find cs in csource... 47 | wchar_t *result = wcsstr(csource, cs); 48 | if (result != NULL) 49 | { 50 | //cs is somewhere in csource 51 | int pos = result - csource; 52 | result = source; 53 | result += pos; 54 | } 55 | //clean up 56 | free(csource); 57 | free(cs); 58 | return result; 59 | } 60 | 61 | CAmHttpSocket::CAmHttpSocket() 62 | { 63 | LastError = 0; 64 | ReceivedData = NULL; 65 | Headers = NULL; 66 | hIO = NULL; 67 | hIS = NULL; 68 | hCO = NULL; 69 | hIO = InternetOpen(m_strAgentName, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); 70 | m_strAgentName = AgentName; 71 | } 72 | 73 | CAmHttpSocket::~CAmHttpSocket() 74 | { 75 | if (ReceivedData != NULL) free(ReceivedData); 76 | if (Headers != NULL) free(Headers); 77 | if (hIO != NULL) InternetCloseHandle(hIO); 78 | if (hIS != NULL) InternetCloseHandle(hIS); 79 | if (hCO != NULL) InternetCloseHandle(hCO); 80 | } 81 | 82 | bool CAmHttpSocket::OpenUrl(const TCHAR *url) 83 | { 84 | if (hIS != NULL) InternetCloseHandle(hIS); 85 | hIS = InternetOpenUrl(hIO, url, NULL, 0, HTTP_QUERY_DATE, 0); 86 | if (hIS != NULL) return true; 87 | else 88 | { 89 | LastError = GetLastError(); 90 | return false; 91 | } 92 | } 93 | 94 | bool CAmHttpSocket::PostUrl(const TCHAR *url, const char *PostData, int PostDataLength) 95 | { 96 | //check length of postdata 97 | if (PostDataLength == -1) 98 | PostDataLength = strlen(PostData); 99 | //some variable that we need... 100 | URL_COMPONENTS uc; 101 | //let's split the url... 102 | uc.dwStructSize = sizeof(uc); 103 | uc.lpszScheme = NULL; 104 | uc.dwSchemeLength = 0; 105 | uc.lpszHostName = NULL; 106 | uc.dwHostNameLength = 1; 107 | uc.nPort = 0; 108 | uc.lpszUserName = NULL; 109 | uc.dwUserNameLength = 0; 110 | uc.lpszPassword = NULL; 111 | uc.dwPasswordLength = 0; 112 | uc.lpszUrlPath = NULL; 113 | uc.dwUrlPathLength = 1; 114 | uc.lpszExtraInfo = NULL; 115 | uc.dwExtraInfoLength = 0; 116 | InternetCrackUrl(url, _tcslen(url), 0, &uc); 117 | //post the data... 118 | if (hCO != NULL) InternetCloseHandle(hCO); 119 | TCHAR *HostName = _tcsdup(uc.lpszHostName); 120 | HostName[uc.dwHostNameLength] = '\0'; 121 | TCHAR *FileName = _tcsdup(uc.lpszUrlPath); 122 | FileName[uc.dwUrlPathLength] = '\0'; 123 | if (hIS != NULL) InternetCloseHandle(hIS); //if open, close the handle to the connection 124 | DWORD flags; 125 | if (uc.nPort == 80) 126 | { 127 | //we are talking plain http 128 | flags = INTERNET_FLAG_NO_CACHE_WRITE; 129 | } 130 | else 131 | { 132 | //we are talking secure https 133 | flags = INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_SECURE | 134 | INTERNET_FLAG_IGNORE_CERT_CN_INVALID | INTERNET_FLAG_IGNORE_CERT_DATE_INVALID; 135 | } 136 | TCHAR headers[] = _T("Content-Type: application/x-www-form-urlencoded"); //content type for post... 137 | TCHAR szAccept[] = _T("*/*"); //we accept everything... 138 | LPTSTR AcceptTypes[2]={0}; 139 | AcceptTypes[0]=szAccept; 140 | hCO = InternetConnect(hIO, HostName, uc.nPort, _T(""), _T(""), INTERNET_SERVICE_HTTP, INTERNET_FLAG_NO_CACHE_WRITE, 0); 141 | hIS = HttpOpenRequest(hCO, _T("POST"), FileName, NULL, NULL, (LPCTSTR*)AcceptTypes, flags, 0); 142 | if (!HttpSendRequest(hIS, headers, _tcslen(headers), (TCHAR*)PostData, PostDataLength)) 143 | { 144 | LastError = GetLastError(); 145 | free(HostName); 146 | free(FileName); 147 | 148 | // View error message 149 | LPVOID lpMsgBuf; 150 | FormatMessage( 151 | FORMAT_MESSAGE_ALLOCATE_BUFFER | 152 | FORMAT_MESSAGE_FROM_SYSTEM | 153 | FORMAT_MESSAGE_IGNORE_INSERTS, 154 | NULL, 155 | GetLastError(), 156 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language 157 | (LPTSTR) &lpMsgBuf, 158 | 0, 159 | NULL); 160 | TRACE ("CAmHttpSocket error: %s\n", (LPCTSTR) lpMsgBuf); 161 | LocalFree (lpMsgBuf); 162 | // End: View error message 163 | 164 | return false; 165 | } 166 | free(HostName); 167 | free(FileName); 168 | return true; 169 | } 170 | 171 | TCHAR* CAmHttpSocket::GetHeaders(const TCHAR *url) 172 | { 173 | //did we get an url? 174 | if (url == NULL) 175 | { 176 | LastError = -1; 177 | return NULL; 178 | } 179 | //open the url... 180 | OpenUrl(url); 181 | //delete old headers... 182 | if (Headers != NULL) free(Headers); 183 | Headers = (TCHAR*)calloc(1, sizeof(TCHAR)); 184 | //get the size headers 185 | DWORD d = 1, d2 = 0; 186 | int i = HttpQueryInfo(hIS, HTTP_QUERY_RAW_HEADERS, Headers, &d, &d2); 187 | //alloc some space for the headers 188 | Headers = (TCHAR*)realloc(Headers, d * sizeof(TCHAR)); 189 | if (!HttpQueryInfo(hIS, HTTP_QUERY_RAW_HEADERS, Headers, &d, &d2)) return NULL; 190 | return Headers; 191 | } 192 | 193 | char* CAmHttpSocket::GetPage(const TCHAR *url, bool Post, const char *PostData, int PostDataLength) 194 | { 195 | //did we get an url? 196 | if (url == NULL) 197 | { 198 | LastError = -1; 199 | return NULL; 200 | } 201 | //get the page and store it in ReceivedData... 202 | if (Post) 203 | { 204 | //use http post... 205 | if (!PostUrl(url, PostData, PostDataLength)) return NULL; 206 | } 207 | else 208 | { 209 | //use http get 210 | if (!OpenUrl(url)) return NULL; 211 | } 212 | const int rdsize = 8192; 213 | char mr[rdsize]; 214 | DWORD rd; 215 | int curpos = 0; 216 | if (ReceivedData != NULL) free(ReceivedData); 217 | ReceivedData = (char*)calloc(rdsize + 1, sizeof(char)); 218 | while (InternetReadFile(hIS, mr, rdsize - 1, &rd)) 219 | { 220 | if (rd == 0) break; 221 | mr[rd] = '\0'; 222 | curpos += rd; 223 | ReceivedData[curpos] = '\0'; 224 | strcat(ReceivedData, mr); 225 | ReceivedData = (char*)realloc(ReceivedData, curpos + rdsize); 226 | } 227 | return ReceivedData; 228 | } 229 | 230 | TCHAR* CAmHttpSocket::GetHeaderLine(TCHAR *s) 231 | { 232 | //find a line in the headers that contains s, and return a pointer to the line... 233 | if (Headers == NULL) return NULL; 234 | TCHAR *ts = Headers; 235 | if (_tcsustr(ts, s) != NULL) return ts; 236 | while (1) 237 | { 238 | if (*ts == '\0' && ts[1] == '\0') break; 239 | if (*ts == '\0') 240 | { 241 | ts++; 242 | if (_tcsustr(ts, s) != NULL) return ts; 243 | } 244 | else ts++; 245 | } 246 | return NULL; 247 | } 248 | 249 | int CAmHttpSocket::GetPageStatusCode() 250 | { 251 | //get the correct header line 252 | TCHAR *s = GetHeaderLine(_T("http")); 253 | if (s == NULL) return 0; //no headers 254 | //find the 3 digit code... 255 | if (_tcslen(s) < 3) return 0; //some error, the string is too short... 256 | while (!(isdigit(s[0]) && isdigit(s[1]) && isdigit(s[2]))) 257 | { 258 | if (s[3] == '\0') return 0; //we have reached the end of the string, without finding the number... 259 | s++; 260 | } 261 | //make a copy of s, and return the code 262 | TCHAR *code = _tcsdup(s); 263 | code[3] = '\0'; //remove all text after the 3 digit response code 264 | int result = _ttoi(code); 265 | free(code); 266 | return result; 267 | } -------------------------------------------------------------------------------- /AmHttpSocket.h: -------------------------------------------------------------------------------- 1 | //link with wininet.lib 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | /* 10 | custom errorcodes: 11 | -1: bad url... 12 | */ 13 | 14 | class CAmHttpSocket 15 | { 16 | public: 17 | int GetPageStatusCode(); //get the HTTP statuscode for the last received page 18 | TCHAR* GetHeaders(const TCHAR *url); //return a pointer th the headers from an url 19 | CAmHttpSocket(); 20 | ~CAmHttpSocket(); 21 | char* GetPage(const TCHAR *url, bool Post = false, const char *PostData = NULL, int PostDataLength = -1); //get a page, if post is false, HTTP GET is used othervise HTTP POST is used. if PostDataLength is -1 the data must be NULL terminated... 22 | 23 | void setAgent (CString strAgentName) 24 | { m_strAgentName = strAgentName; } 25 | 26 | protected: 27 | bool PostUrl(const TCHAR *url, const char *PostData, int PostDataLength = -1); //open a page using http post 28 | TCHAR* GetHeaderLine(TCHAR *s); //get a specific line from the headers 29 | bool OpenUrl(const TCHAR *url); //open a page using http get 30 | HINTERNET hIO, hIS, hCO; 31 | char *ReceivedData; //the internal databuffer 32 | TCHAR *Headers; //the internal headerbuffer 33 | int LastError; //internal statuscode... 34 | 35 | CString m_strAgentName; // agent name 36 | }; -------------------------------------------------------------------------------- /AutoBoardText.cpp: -------------------------------------------------------------------------------- 1 | // AutoBoardText.cpp : implementation file 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "renlib.h" 6 | #include "AutoBoardText.h" 7 | 8 | #ifdef _DEBUG 9 | #define new DEBUG_NEW 10 | #undef THIS_FILE 11 | static char THIS_FILE[] = __FILE__; 12 | #endif 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | // AutoBoardText dialog 16 | 17 | 18 | AutoBoardText::AutoBoardText(CWnd* pParent /*=NULL*/) 19 | : CDialog(AutoBoardText::IDD, pParent) 20 | { 21 | //{{AFX_DATA_INIT(AutoBoardText) 22 | m_NextAutoBoardText = _T(""); 23 | //}}AFX_DATA_INIT 24 | } 25 | 26 | 27 | void AutoBoardText::DoDataExchange(CDataExchange* pDX) 28 | { 29 | CDialog::DoDataExchange(pDX); 30 | //{{AFX_DATA_MAP(AutoBoardText) 31 | DDX_Text(pDX, IDC_BOARD_TEXT, m_NextAutoBoardText); 32 | DDV_MaxChars(pDX, m_NextAutoBoardText, 2); 33 | //}}AFX_DATA_MAP 34 | } 35 | 36 | 37 | BEGIN_MESSAGE_MAP(AutoBoardText, CDialog) 38 | //{{AFX_MSG_MAP(AutoBoardText) 39 | // NOTE: the ClassWizard will add message map macros here 40 | //}}AFX_MSG_MAP 41 | END_MESSAGE_MAP() 42 | 43 | ///////////////////////////////////////////////////////////////////////////// 44 | // AutoBoardText message handlers 45 | 46 | int AutoBoardText::DoModal() 47 | { 48 | CDialogTemplate dlt; 49 | int nResult; 50 | 51 | // load dialog template 52 | if (!dlt.Load(MAKEINTRESOURCE(AutoBoardText::IDD))) return -1; 53 | 54 | // set your own font, for example "Arial", 10 pts. 55 | dlt.SetFont(m_strFaceName, 10); 56 | 57 | // get pointer to the modified dialog template 58 | LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate); 59 | 60 | // let MFC know that you are using your own template 61 | m_lpszTemplateName = NULL; 62 | m_hDialogTemplate = NULL; 63 | 64 | InitModalIndirect(pdata); 65 | 66 | // display dialog box 67 | nResult = CDialog::DoModal(); 68 | 69 | // unlock memory object 70 | GlobalUnlock(dlt.m_hTemplate); 71 | 72 | return nResult; 73 | } 74 | -------------------------------------------------------------------------------- /AutoBoardText.h: -------------------------------------------------------------------------------- 1 | #if !defined(AFX_AUTO_BOARD_TEXT_H__47FED263_ECD1_11D5_92A3_0000E89F396C__INCLUDED_) 2 | #define AFX_AUTO_BOARD_TEXT_H__47FED263_ECD1_11D5_92A3_0000E89F396C__INCLUDED_ 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif // _MSC_VER > 1000 7 | // AutoBoardText.h : header file 8 | // 9 | 10 | ///////////////////////////////////////////////////////////////////////////// 11 | // AutoBoardText dialog 12 | 13 | class AutoBoardText : public CDialog 14 | { 15 | // Construction 16 | public: 17 | AutoBoardText(CWnd* pParent = NULL); // standard constructor 18 | 19 | // Dialog Data 20 | //{{AFX_DATA(AutoBoardText) 21 | enum { IDD = IDD_AUTO_BOARD_TEXT }; 22 | CString m_NextAutoBoardText; 23 | //}}AFX_DATA 24 | CString m_strFaceName; 25 | 26 | // Overrides 27 | // ClassWizard generated virtual function overrides 28 | //{{AFX_VIRTUAL(AutoBoardText) 29 | public: 30 | virtual int DoModal(); 31 | protected: 32 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 33 | //}}AFX_VIRTUAL 34 | 35 | // Implementation 36 | protected: 37 | 38 | // Generated message map functions 39 | //{{AFX_MSG(AutoBoardText) 40 | // NOTE: the ClassWizard will add member functions here 41 | //}}AFX_MSG 42 | DECLARE_MESSAGE_MAP() 43 | }; 44 | 45 | //{{AFX_INSERT_LOCATION}} 46 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 47 | 48 | #endif // !defined(AFX_AUTO_BOARD_TEXT_H__47FED263_ECD1_11D5_92A3_0000E89F396C__INCLUDED_) 49 | -------------------------------------------------------------------------------- /Bdt.h: -------------------------------------------------------------------------------- 1 | // Bdt.h: interface for the Bdt class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_BDT_H__01A513A2_A1E7_11D4_92A3_444553540000__INCLUDED_) 6 | #define AFX_BDT_H__01A513A2_A1E7_11D4_92A3_444553540000__INCLUDED_ 7 | 8 | #include "Game.h" 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif // _MSC_VER > 1000 13 | 14 | class MoveList; 15 | 16 | class Bdt 17 | { 18 | public: 19 | Bdt(); 20 | 21 | bool OpenFile(const CString& strFile); 22 | bool Done(); 23 | void Next(); 24 | 25 | bool Create(const CString& fileName); 26 | void Save(const MoveList& aMoveList); 27 | void Close(); 28 | 29 | Game& getGame(); 30 | CString getFilePath(); 31 | 32 | private: 33 | bool GetLine (CString& strLine); 34 | 35 | bool GetPlayers(CString& strLine, CString& strBlackPlayer, CString& strWhitePlayer); 36 | 37 | bool GetReverse(CString& strLine, CString& strReverse); 38 | 39 | bool Get5a(CString& strLine, CString& str5a); 40 | 41 | bool GetResult( 42 | CString& strLine, CString strLeft, CString strRight); 43 | 44 | bool GetTournament(CString& strLine, CString& strTournament); 45 | 46 | void GetInformation( 47 | const MoveList& aMoveList, 48 | CString& strBlackPlayer, 49 | CString& strWhitePlayer, 50 | CString& strResult, 51 | CString& str5A, 52 | CString& strReverse, 53 | CString& strTournament, 54 | CString& strComment); 55 | 56 | private: 57 | CStdioFile mGameFile; 58 | Game mGame; 59 | CString mFilePath; 60 | bool mDone; 61 | }; 62 | 63 | #endif // !defined(AFX_BDT_H__01A513A2_A1E7_11D4_92A3_444553540000__INCLUDED_) 64 | -------------------------------------------------------------------------------- /Board.h: -------------------------------------------------------------------------------- 1 | // Board.h: interface for the Board class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_BOARD_H__5B4D9628_FD87_11D3_92A3_F35A49B42825__INCLUDED_) 6 | #define AFX_BOARD_H__5B4D9628_FD87_11D3_92A3_F35A49B42825__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | #include "External/ForbiddenPointFinder.h" 13 | #include "MoveList.h" 14 | 15 | class MoveNode; 16 | 17 | class Board 18 | { 19 | 20 | public: 21 | enum EvaluatorSelection 22 | { 23 | ORIGINAL, 24 | RENJU_CLASS_RENJU_SOLVER, 25 | NONE 26 | }; 27 | 28 | enum BoardMarker 29 | { 30 | NO_MOVE, // 31 | BLACK_MOVE, // charMarker[0,1,2] 32 | WHITE_MOVE, // 33 | BLACK_VARIANT, 34 | WHITE_VARIANT, 35 | BLACK_AUTOLINKVARIANT, 36 | WHITE_AUTOLINKVARIANT, 37 | BLACK_MOVEORDERVARIANT, 38 | WHITE_MOVEORDERVARIANT, 39 | PASS 40 | }; 41 | 42 | enum WinMarker 43 | { 44 | NUMBER, 45 | UPPER, 46 | LOWER 47 | }; 48 | 49 | enum FindStatus 50 | { 51 | FIND_IDLE, 52 | FIND_VCF_IN_PROGRESS, 53 | FOUND_VCF, 54 | FOUND_NO_VCF, 55 | FIND_VCT_IN_PROGRESS, 56 | FOUND_VCT, 57 | FOUND_NO_VCT 58 | }; 59 | 60 | public: 61 | Board(); 62 | virtual ~Board(); 63 | 64 | void Clear(); 65 | void ClearWin(); 66 | 67 | bool isEqual(Board& aBoard); 68 | 69 | BoardMarker Get(CPoint Pos); 70 | BYTE GetNumber (CPoint Pos); 71 | CString GetText (CPoint Pos); 72 | bool isForbidden(CPoint Pos); 73 | bool isBoardText(CPoint Pos); 74 | CString GetWin(CPoint Pos); 75 | 76 | MoveNode* GetMove(CPoint Pos); 77 | MoveNode* GetChangedOrder(CPoint Pos); 78 | 79 | void Set (CPoint Pos, BoardMarker marker, MoveNode* pMove = 0, bool findForbidden = false); 80 | 81 | void SetChangedOrder(CPoint Pos, MoveNode* pChangedOrder); 82 | 83 | void SetNumber (CPoint Pos, BYTE number); 84 | void SetText (CPoint Pos, const CString& Text); 85 | 86 | void SetLastMove (const CPoint& Point); 87 | CPoint GetLastMove(); 88 | 89 | void SetPreviousVariant (const CPoint& Point); 90 | CPoint GetPreviousVariant(); 91 | 92 | void setEvaluatorSelection(EvaluatorSelection evaluatorSelection); 93 | EvaluatorSelection getEvaluatorSelection(); 94 | 95 | void setForbiddenInfo(const MoveList& moveList); 96 | 97 | FindStatus findVcf(const MoveList& moveList); 98 | FindStatus findVct(const MoveList& moveList); 99 | 100 | int setWinTrace(WinMarker marker); 101 | void updateWinTrace(WinMarker marker); 102 | 103 | bool canShowForbiddenPoints(); 104 | bool canFindVcf(); 105 | bool canFindVct(); 106 | 107 | void doFindVcf(); 108 | void doFindVct(); 109 | void stopFind(); 110 | 111 | FindStatus checkFindStatus(CString& strInfo); 112 | void resetFindStatus(); 113 | bool isFindActive(); 114 | bool isFindVctActive(); 115 | bool isFindVcfActive(); 116 | 117 | private: 118 | 119 | class Position 120 | { 121 | public: 122 | BoardMarker Marker; 123 | BYTE Number; 124 | BYTE Win; 125 | bool Forbidden; 126 | CString Text; 127 | MoveNode* pMove; 128 | MoveNode* pChangedOrder; 129 | }; 130 | 131 | Position m_Board[16][16]; 132 | CPoint m_LastMove; 133 | CPoint m_PreviousVariant; 134 | 135 | unsigned char mData[260]; 136 | int mVc3; 137 | FindStatus mFindStatus; 138 | 139 | EvaluatorSelection m_EvaluatorSelection; 140 | 141 | CForbiddenPointFinder mEvaluator; 142 | 143 | CString m_strWinMarker[226]; 144 | 145 | }; 146 | 147 | #endif // !defined(AFX_BOARD_H__5B4D9628_FD87_11D3_92A3_F35A49B42825__INCLUDED_) 148 | -------------------------------------------------------------------------------- /BoardBitmap/Brick1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Brick1.bmp -------------------------------------------------------------------------------- /BoardBitmap/Brick2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Brick2.bmp -------------------------------------------------------------------------------- /BoardBitmap/Brick3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Brick3.bmp -------------------------------------------------------------------------------- /BoardBitmap/Brick4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Brick4.bmp -------------------------------------------------------------------------------- /BoardBitmap/Cloth1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Cloth1.bmp -------------------------------------------------------------------------------- /BoardBitmap/Cloth2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Cloth2.bmp -------------------------------------------------------------------------------- /BoardBitmap/Cloth3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Cloth3.bmp -------------------------------------------------------------------------------- /BoardBitmap/Cloth4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Cloth4.bmp -------------------------------------------------------------------------------- /BoardBitmap/Marble1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Marble1.bmp -------------------------------------------------------------------------------- /BoardBitmap/Marble2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Marble2.bmp -------------------------------------------------------------------------------- /BoardBitmap/Marble3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Marble3.bmp -------------------------------------------------------------------------------- /BoardBitmap/Marble4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Marble4.bmp -------------------------------------------------------------------------------- /BoardBitmap/Wood1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Wood1.bmp -------------------------------------------------------------------------------- /BoardBitmap/Wood2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Wood2.bmp -------------------------------------------------------------------------------- /BoardBitmap/Wood3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Wood3.bmp -------------------------------------------------------------------------------- /BoardBitmap/Wood4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Wood4.bmp -------------------------------------------------------------------------------- /BoardBitmap/Wood5.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/BoardBitmap/Wood5.bmp -------------------------------------------------------------------------------- /Buf.cpp: -------------------------------------------------------------------------------- 1 | // Buf.cpp: implementation of the Buf class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "RenLib.h" 7 | #include "Buf.h" 8 | #include "Utils.h" 9 | 10 | #ifdef _DEBUG 11 | #undef THIS_FILE 12 | static char THIS_FILE[]=__FILE__; 13 | #define new DEBUG_NEW 14 | #endif 15 | 16 | //-------------------------------------------------------------------- 17 | // const 18 | //-------------------------------------------------------------------- 19 | 20 | namespace 21 | { 22 | const RecordSize = 256; // Record Size 23 | const StartIndex = 30; // First move in record 24 | } 25 | 26 | ////////////////////////////////////////////////////////////////////// 27 | // Construction/Destruction 28 | ////////////////////////////////////////////////////////////////////// 29 | 30 | Buf::Buf() 31 | : m_dwRead(0), 32 | m_nRecord(0), 33 | m_nNoMoves(0) 34 | { 35 | } 36 | 37 | //------------------------------------------------------------------------ 38 | 39 | Game& Buf::getGame() 40 | { 41 | return m_Game; 42 | } 43 | 44 | //------------------------------------------------------------------------ 45 | 46 | CString Buf::getFilePath() 47 | { 48 | return m_strFilePath; 49 | } 50 | 51 | //------------------------------------------------------------------------ 52 | 53 | bool Buf::OpenFile(const CString& strFile) 54 | { 55 | CFileException e; 56 | 57 | if( !m_bufFile.Open( strFile, CFile::modeRead, &e ) ) 58 | { 59 | return false; 60 | } 61 | 62 | m_strFilePath = m_bufFile.GetFilePath(); 63 | 64 | Next(); 65 | 66 | return true; 67 | } 68 | 69 | //------------------------------------------------------------------------ 70 | 71 | bool Buf::Done() 72 | { 73 | return (m_dwRead < RecordSize); 74 | } 75 | 76 | //------------------------------------------------------------------------ 77 | 78 | void Buf::Next() 79 | { 80 | BYTE buffer[RecordSize]; 81 | 82 | m_Game.clear(); 83 | 84 | if ((m_dwRead = m_bufFile.Read(buffer, RecordSize)) && (buffer[0] != 0)) 85 | { 86 | bool isTime = false; 87 | bool isReverse = false; 88 | bool isDraw = false; 89 | bool isBlackWin = false; 90 | bool isWhiteWin = false; 91 | 92 | CString strBlackPlayer; 93 | CString strWhitePlayer; 94 | 95 | for (int i = 0; i < StartIndex; i++) 96 | { 97 | if (buffer[i] > 127) 98 | { 99 | buffer[i] -= 100; 100 | 101 | if (i == 24) 102 | { 103 | isTime = true; 104 | } 105 | else if (i == 25) 106 | { 107 | isDraw = true; 108 | } 109 | else if (i == 26) 110 | { 111 | isReverse = false; 112 | } 113 | else if (i == 27) 114 | { 115 | isWhiteWin = true; 116 | } 117 | else if (i == 28) 118 | { 119 | isBlackWin = true; 120 | } 121 | else if (i == 29) 122 | { 123 | isReverse = true; 124 | } 125 | } 126 | } 127 | 128 | for (i = 0; i < 15; i++) 129 | { 130 | strBlackPlayer += buffer[i]; 131 | } 132 | 133 | for (i = 15; i < 30; i++) 134 | { 135 | strWhitePlayer += buffer[i]; 136 | } 137 | 138 | Utils::trim(strBlackPlayer); 139 | Utils::trim(strWhitePlayer); 140 | 141 | CString strResult; 142 | 143 | if (isDraw) 144 | { 145 | strResult = "0.5 - 0.5"; 146 | } 147 | else if (isBlackWin) 148 | { 149 | strResult = "1 - 0"; 150 | } 151 | else //if (isWhiteWin) 152 | { 153 | strResult = "0 - 1"; 154 | } 155 | 156 | CString str5A("?"); 157 | 158 | for (i=StartIndex; i < RecordSize; i++) 159 | { 160 | if (buffer[i] == 0) 161 | { 162 | break; 163 | } 164 | 165 | int y = 16 - (buffer[i] + 14) / 15; 166 | int x = (buffer[i] + 14) % 15 + 1; 167 | 168 | if (i == StartIndex && (x != 8 || y != 8)) 169 | { 170 | str5A.Format( 171 | "%s%s", 172 | Utils::XCoordinateImage(x, true, false), 173 | Utils::YCoordinateImage(y, false)); 174 | 175 | x = 8; 176 | y = 8; 177 | } 178 | 179 | m_Game.addPos(BYTE((15-y) * 16 + x)); 180 | } 181 | 182 | const int lastMove = m_Game.numberOfMoves(); 183 | 184 | const CString strResultComment(strBlackPlayer + " - " + strWhitePlayer + " " + strResult); 185 | 186 | m_Game.addOneLineComment(lastMove, strResultComment); 187 | 188 | CString strFileAndNumber; 189 | strFileAndNumber.Format("File: %s, No: %d", m_bufFile.GetFileTitle(), m_nRecord); 190 | m_Game.addMultiLineComment(lastMove, strFileAndNumber); 191 | 192 | CString strReverse("Reverse: "); 193 | strReverse += (isReverse ? "R" : "-"); 194 | m_Game.addMultiLineComment(lastMove, strReverse); 195 | 196 | m_Game.addMultiLineComment(lastMove, "5A: " + str5A); 197 | 198 | if (isTime) 199 | { 200 | m_Game.addMultiLineComment(lastMove, "Time loss"); 201 | } 202 | 203 | m_nRecord++; 204 | } 205 | 206 | if (Done()) 207 | { 208 | m_bufFile.Close(); 209 | } 210 | } 211 | 212 | //------------------------------------------------------------------------ 213 | 214 | bool Buf::Create(const CString& fileName) 215 | { 216 | return false; 217 | } 218 | 219 | void Buf::Save(const MoveList& aMoveList) 220 | { 221 | // if (!m_pdbFile.Open(fileName, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary)) 222 | // { 223 | // CString strMessage(Utils::GetString(IDS_MSG_OPEN_FILE, fileName)); 224 | // Utils::ShowMessage(strMessage, Utils::GetString(IDS_CAP_CREATE_PDB), MB_ICONERROR); 225 | // return false; 226 | // } 227 | // 228 | // m_pdbFile.Close(); 229 | // 230 | } 231 | 232 | void Buf::Close() 233 | { 234 | } 235 | -------------------------------------------------------------------------------- /Buf.h: -------------------------------------------------------------------------------- 1 | // Buf.h: interface for the Buf class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_BUF_H__01A513A2_A1E7_11D4_92A3_444553540000__INCLUDED_) 6 | #define AFX_BUF_H__01A513A2_A1E7_11D4_92A3_444553540000__INCLUDED_ 7 | 8 | #include "Game.h" 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif // _MSC_VER > 1000 13 | 14 | class MoveList; 15 | 16 | class Buf 17 | { 18 | public: 19 | Buf(); 20 | 21 | bool OpenFile(const CString& strFile); 22 | bool Done(); 23 | void Next(); 24 | 25 | bool Create(const CString& fileName); 26 | void Save(const MoveList& aMoveList); 27 | void Close(); 28 | 29 | public: 30 | Game& getGame(); 31 | CString getFilePath(); 32 | 33 | private: 34 | CFile m_bufFile; 35 | DWORD m_dwRead; 36 | int m_nRecord; 37 | int m_nNoMoves; 38 | 39 | Game m_Game; 40 | CString m_strFilePath; 41 | }; 42 | 43 | #endif // !defined(AFX_BUF_H__01A513A2_A1E7_11D4_92A3_444553540000__INCLUDED_) 44 | 45 | -------------------------------------------------------------------------------- /CISBitmap.cpp: -------------------------------------------------------------------------------- 1 | // CISBitmap.cpp: implementation of the CCISBitmap class. 2 | // Author: Paul Reynolds 3 | // Date: 24/04/1998 4 | // Version: 1.0 5 | ////////////////////////////////////////////////////////////////////// 6 | 7 | #include 8 | #include "CISBitmap.h" 9 | 10 | #ifdef _DEBUG 11 | #undef THIS_FILE 12 | static char THIS_FILE[]=__FILE__; 13 | #define new DEBUG_NEW 14 | #endif 15 | 16 | ////////////////////////////////////////////////////////////////////// 17 | // Construction/Destruction 18 | ////////////////////////////////////////////////////////////////////// 19 | 20 | CCISBitmap::CCISBitmap() 21 | { 22 | m_crBlack = 0; 23 | m_crWhite = RGB(255,255,255); 24 | } 25 | 26 | CCISBitmap::~CCISBitmap() 27 | { 28 | 29 | } 30 | 31 | int CCISBitmap::Width() 32 | { 33 | BITMAP bm; 34 | GetBitmap(&bm); 35 | return bm.bmWidth; 36 | } 37 | 38 | int CCISBitmap::Height() 39 | { 40 | BITMAP bm; 41 | GetBitmap(&bm); 42 | return bm.bmHeight; 43 | } 44 | 45 | void CCISBitmap::DrawTransparent(CDC * pDC, int x, int y, COLORREF crColour) 46 | { 47 | COLORREF crOldBack = pDC->SetBkColor(m_crWhite); 48 | COLORREF crOldText = pDC->SetTextColor(m_crBlack); 49 | CDC dcImage, dcTrans; 50 | 51 | // Create two memory dcs for the image and the mask 52 | dcImage.CreateCompatibleDC(pDC); 53 | dcTrans.CreateCompatibleDC(pDC); 54 | 55 | // Select the image into the appropriate dc 56 | CBitmap* pOldBitmapImage = dcImage.SelectObject(this); 57 | 58 | // Create the mask bitmap 59 | CBitmap bitmapTrans; 60 | int nWidth = Width(); 61 | int nHeight = Height(); 62 | bitmapTrans.CreateBitmap(nWidth, nHeight, 1, 1, NULL); 63 | 64 | // Select the mask bitmap into the appropriate dc 65 | CBitmap* pOldBitmapTrans = dcTrans.SelectObject(&bitmapTrans); 66 | 67 | // Build mask based on transparent colour 68 | dcImage.SetBkColor(crColour); 69 | dcTrans.BitBlt(0, 0, 100, 100, /*nWidth, nHeight,*/ &dcImage, 0, 0, SRCCOPY); 70 | 71 | // Do the work - True Mask method - cool if not actual display 72 | pDC->BitBlt(x, y, nWidth, nHeight, &dcImage, 0, 0, SRCINVERT); 73 | pDC->BitBlt(x, y, nWidth, nHeight, &dcTrans, 0, 0, SRCAND); 74 | pDC->BitBlt(x, y, nWidth, nHeight, &dcImage, 0, 0, SRCINVERT); 75 | 76 | // Restore settings 77 | dcImage.SelectObject(pOldBitmapImage); 78 | dcTrans.SelectObject(pOldBitmapTrans); 79 | pDC->SetBkColor(crOldBack); 80 | pDC->SetTextColor(crOldText); 81 | } 82 | -------------------------------------------------------------------------------- /CISBitmap.h: -------------------------------------------------------------------------------- 1 | // CISBitmap.h: interface for the CCISBitmap class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_CISBITMAP_H__08BA6EB3_DB4C_11D1_8A89_0040052E2D91__INCLUDED_) 6 | #define AFX_CISBITMAP_H__08BA6EB3_DB4C_11D1_8A89_0040052E2D91__INCLUDED_ 7 | 8 | #if _MSC_VER >= 1000 9 | #pragma once 10 | #endif // _MSC_VER >= 1000 11 | 12 | class CCISBitmap : public CBitmap 13 | { 14 | public: 15 | CCISBitmap(); 16 | virtual ~CCISBitmap(); 17 | 18 | // Functions 19 | int Height(); 20 | int Width(); 21 | virtual void DrawTransparent(CDC* pDC, int x, int y, COLORREF crColour); 22 | 23 | private: 24 | COLORREF m_crBlack; 25 | COLORREF m_crWhite; 26 | }; 27 | 28 | #endif // !defined(AFX_CISBITMAP_H__08BA6EB3_DB4C_11D1_8A89_0040052E2D91__INCLUDED_) 29 | -------------------------------------------------------------------------------- /DIBSectionLite.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/DIBSectionLite.cpp -------------------------------------------------------------------------------- /DIBSectionLite.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/DIBSectionLite.h -------------------------------------------------------------------------------- /Debug/bestmove.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/Debug/bestmove.dll -------------------------------------------------------------------------------- /EditBoardText.cpp: -------------------------------------------------------------------------------- 1 | // EditBoardText.cpp : implementation file 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "renlib.h" 6 | #include "EditBoardText.h" 7 | 8 | #ifdef _DEBUG 9 | #define new DEBUG_NEW 10 | #undef THIS_FILE 11 | static char THIS_FILE[] = __FILE__; 12 | #endif 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | // EditBoardText dialog 16 | 17 | 18 | EditBoardText::EditBoardText(CWnd* pParent /*=NULL*/) 19 | : CDialog(EditBoardText::IDD, pParent) 20 | { 21 | //{{AFX_DATA_INIT(EditBoardText) 22 | m_BoardText = _T(""); 23 | //}}AFX_DATA_INIT 24 | } 25 | 26 | 27 | void EditBoardText::DoDataExchange(CDataExchange* pDX) 28 | { 29 | CDialog::DoDataExchange(pDX); 30 | //{{AFX_DATA_MAP(EditBoardText) 31 | DDX_Text(pDX, IDC_BOARD_TEXT, m_BoardText); 32 | DDV_MaxChars(pDX, m_BoardText, 5); 33 | //}}AFX_DATA_MAP 34 | } 35 | 36 | 37 | BEGIN_MESSAGE_MAP(EditBoardText, CDialog) 38 | //{{AFX_MSG_MAP(EditBoardText) 39 | // NOTE: the ClassWizard will add message map macros here 40 | //}}AFX_MSG_MAP 41 | END_MESSAGE_MAP() 42 | 43 | ///////////////////////////////////////////////////////////////////////////// 44 | // EditBoardText message handlers 45 | 46 | int EditBoardText::DoModal() 47 | { 48 | CDialogTemplate dlt; 49 | int nResult; 50 | 51 | // load dialog template 52 | if (!dlt.Load(MAKEINTRESOURCE(EditBoardText::IDD))) return -1; 53 | 54 | // set your own font, for example "Arial", 10 pts. 55 | dlt.SetFont(m_strFaceName, 10); 56 | 57 | // get pointer to the modified dialog template 58 | LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate); 59 | 60 | // let MFC know that you are using your own template 61 | m_lpszTemplateName = NULL; 62 | m_hDialogTemplate = NULL; 63 | 64 | InitModalIndirect(pdata); 65 | 66 | // display dialog box 67 | nResult = CDialog::DoModal(); 68 | 69 | // unlock memory object 70 | GlobalUnlock(dlt.m_hTemplate); 71 | 72 | return nResult; 73 | } 74 | -------------------------------------------------------------------------------- /EditBoardText.h: -------------------------------------------------------------------------------- 1 | #if !defined(AFX_EDIT_BOARD_TEXT_H__879CA622_E2A1_11D5_92A3_0000E89F396C__INCLUDED_) 2 | #define AFX_EDIT_BOARD_TEXT_H__879CA622_E2A1_11D5_92A3_0000E89F396C__INCLUDED_ 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif // _MSC_VER > 1000 7 | // EditBoardText.h : header file 8 | // 9 | 10 | ///////////////////////////////////////////////////////////////////////////// 11 | // EditBoardText dialog 12 | 13 | class EditBoardText : public CDialog 14 | { 15 | // Construction 16 | public: 17 | EditBoardText(CWnd* pParent = NULL); // standard constructor 18 | 19 | // Dialog Data 20 | //{{AFX_DATA(EditBoardText) 21 | enum { IDD = IDD_EDIT_BOARD_TEXT }; 22 | CString m_BoardText; 23 | //}}AFX_DATA 24 | CString m_strFaceName; 25 | 26 | // Overrides 27 | // ClassWizard generated virtual function overrides 28 | //{{AFX_VIRTUAL(EditBoardText) 29 | public: 30 | virtual int DoModal(); 31 | protected: 32 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 33 | //}}AFX_VIRTUAL 34 | 35 | // Implementation 36 | protected: 37 | 38 | // Generated message map functions 39 | //{{AFX_MSG(EditBoardText) 40 | // NOTE: the ClassWizard will add member functions here 41 | //}}AFX_MSG 42 | DECLARE_MESSAGE_MAP() 43 | }; 44 | 45 | //{{AFX_INSERT_LOCATION}} 46 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 47 | 48 | #endif // !defined(AFX_EDIT_BOARD_TEXT_H__879CA622_E2A1_11D5_92A3_0000E89F396C__INCLUDED_) 49 | -------------------------------------------------------------------------------- /External/Debug/ForbiddenPointFinder.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/External/Debug/ForbiddenPointFinder.lib -------------------------------------------------------------------------------- /External/Debug/bestmove.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/External/Debug/bestmove.lib -------------------------------------------------------------------------------- /External/ForbiddenPointFinder.h: -------------------------------------------------------------------------------- 1 | #if !defined(FORBIDDENPOINTFINDER_H_INCLUDED_) 2 | #define FORBIDDENPOINTFINDER_H_INCLUDED_ 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif // _MSC_VER > 1000 7 | // ForbiddenPointFinder.h : header file 8 | // 9 | 10 | #define BOARDSIZE 15 11 | #define BLACKSTONE 'X' 12 | #define WHITESTONE 'O' 13 | #define EMPTYSTONE '.' 14 | #define BLACKFIVE 0 15 | #define WHITEFIVE 1 16 | #define BLACKFORBIDDEN 2 17 | 18 | class CForbiddenPointFinder 19 | { 20 | public: 21 | int nForbiddenPoints; 22 | CPoint ptForbidden[BOARDSIZE * BOARDSIZE]; 23 | 24 | private: 25 | char cBoard[BOARDSIZE+2][BOARDSIZE+2]; 26 | 27 | public: 28 | CForbiddenPointFinder(); 29 | virtual ~CForbiddenPointFinder(); 30 | 31 | void Clear(); 32 | int AddStone(int x, int y, char cStone); 33 | 34 | private: 35 | void SetStone(int x, int y, char cStone); 36 | BOOL IsFive(int x, int y, int nColor); 37 | BOOL IsOverline(int x, int y); 38 | BOOL IsFive(int x, int y, int nColor, int nDir); 39 | BOOL IsFour(int x, int y, int nColor, int nDir); 40 | int IsOpenFour(int x, int y, int nColor, int nDir); 41 | BOOL IsOpenThree(int x, int y, int nColor, int nDir ); 42 | BOOL IsDoubleFour(int x, int y); 43 | BOOL IsDoubleThree(int x, int y); 44 | 45 | void FindForbiddenPoints(); 46 | }; 47 | 48 | #endif // !defined(FORBIDDENPOINTFINDER_H_INCLUDED_) -------------------------------------------------------------------------------- /External/Release/ForbiddenPointFinder.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/External/Release/ForbiddenPointFinder.lib -------------------------------------------------------------------------------- /External/Release/bestmove.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/External/Release/bestmove.lib -------------------------------------------------------------------------------- /External/bestmove.h: -------------------------------------------------------------------------------- 1 | int __stdcall CheckWin(unsigned char*); 2 | int __stdcall GetBestMove(unsigned char*); 3 | int __stdcall GetClassSize(); 4 | int __stdcall GetJinShou(unsigned char*); 5 | int __stdcall GetLevel(); 6 | int __stdcall GetNodeNum(); 7 | int __stdcall StopThinking(); 8 | int __stdcall Vc3Solver(unsigned char*); 9 | 10 | // ********************************************************************* 11 | // Input: 12 | // ********************************************************************* 13 | // The functions with input "unsigned char*" have the same format: 14 | // 15 | // char[0] : 16 | // char[1] : the maxmum time in seconds for the computation: char[0]*256 + char[1] 17 | // char[2] : BestMove level:1-9, actually this is the search depth; if it is 0 ,try to find VCF. 18 | // char[3] : 19 | // char[4] : 20 | // char[5] : 21 | // char[6] : 22 | // char[7] : 23 | // char[8] : the total number of stones in the board. 24 | // char[8+1] : the first stone on the board, // usually it is 7*15+7 25 | // char[8+2] : the second stone on the board: 26 | // ... 27 | // ... 28 | // char[8+totalnumberstone]: the last stone in the board. 29 | // 30 | // ********************************************************************* 31 | // Output: 32 | // ********************************************************************* 33 | // 34 | // 1 35 | // ************************************* 36 | // int GetBestMove(unsigned char*); 37 | // The move value is stored at char[0], 38 | // 39 | // 2 40 | // ************************************** 41 | // int Vc3Solver(unsigned char*); 42 | // The move value is stored at char[0], 43 | // 44 | // If there exists a VCF, returns 2000+; 45 | // samples for use for finding vcf: 46 | // 47 | // unsigned char temp[260]; 48 | // temp[1]=(unsigned char)120; 49 | // temp[2]=(unsigned char)5; 50 | // temp[3]=(unsigned char)0; 51 | // temp[4]=(unsigned char)0; 52 | // temp[5]=(unsigned char)0; 53 | // temp[6]=(unsigned char)2;//HashTableSize;0--8M, 1--16M,2--32M, 54 | // temp[7]=(unsigned char)0; 55 | // 56 | // int i; 57 | // for(i=0;i<=qipu[0];i++) 58 | // { 59 | // temp[i+8]=qipu[i]; 60 | // } 61 | // 62 | // 63 | // ////call the function in the dll. 64 | // int vc3=Vc3Solver(temp); 65 | // VC4Chain[0]=0; 66 | // if(vc3>=20000) //found VCF, 67 | // { 68 | // VC4Chain[0]=vc3-20000+1; 69 | // for(i=0;i<=vc3-20000;i++) 70 | // { 71 | // VC4Chain[i+1]=temp[i];//store VCF chain 72 | // } 73 | // }else // no VCF. 74 | // { 75 | // } 76 | // 77 | // 78 | // 3 79 | // ************************************** 80 | // int GetJinShou(unsigned char*); 81 | // char[0]: the total number of jinshou position in the board 82 | // char[1]: first jinshou pos; 83 | // char[2]: second jinshou pos 84 | // ... 85 | // char[totaljinshou]: the last jinshou position. 86 | // 87 | // 4 88 | // *************************************** 89 | // int GetNodeNum(); 90 | // returns the current number of nodes that has been searched. 91 | // It could be used in the middle of computation. 92 | // 93 | // 5 94 | // **************************************** 95 | // int StopThinking(); 96 | // the program stop searching and returns 0 97 | // 98 | // 6 99 | // **************************************** 100 | // int CheckWin(): 101 | // 0: no win no lose 102 | // 3: the last stone is black and is jinshou, black lose, 103 | // 4: win 104 | // **************************************** 105 | -------------------------------------------------------------------------------- /FileInfo.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/FileInfo.h -------------------------------------------------------------------------------- /FolderDlg.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | /* 3 | DESCRIPTION: 4 | CFolderDialog - Folder Selection Dialog Class 5 | http://www.codeproject.com/dialog/cfolderdialog.asp 6 | 7 | NOTES: 8 | Copyright(C) Armen Hakobyan, 2002 9 | mailto:armen.h@web.am 10 | 11 | VERSION HISTORY: 12 | 24 Mar 2002 - First release 13 | 30 Mar 2003 - Some minor changes 14 | - Added missing in old Platform SDK new flag definitions 15 | - Added support for both MFC 6.0 and 7.0 16 | - Added OnIUnknown handler for Windows XP folder filtration 17 | - Added SetExpanded and SetOKText and GetSelectedFolder functions 18 | 24 May 2003 - Added OnSelChanged implementation 19 | 14 Jul 2003 - Added custom filtration for Windows XP 20 | */ 21 | ///////////////////////////////////////////////////////////////////////////// 22 | 23 | #include "stdafx.h" 24 | #include "FolderDlg.h" 25 | 26 | ///////////////////////////////////////////////////////////////////////////// 27 | 28 | #ifndef BFFM_VALIDATEFAILED 29 | #ifndef UNICODE 30 | #define BFFM_VALIDATEFAILED 3 31 | #else 32 | #define BFFM_VALIDATEFAILED 4 33 | #endif 34 | #endif 35 | 36 | #ifndef BFFM_IUNKNOWN 37 | #define BFFM_IUNKNOWN 5 38 | #endif 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | // CFolderDialog 42 | 43 | IMPLEMENT_DYNAMIC( CFolderDialog, CDialog ) 44 | 45 | CFolderDialog::CFolderDialog( IN LPCTSTR lpszTitle /*NULL*/, 46 | IN LPCTSTR lpszSelPath /*NULL*/, 47 | IN CWnd* pParentWnd /*NULL*/, 48 | IN UINT uFlags /*BIF_RETURNONLYFSDIRS*/ ) 49 | : CCommonDialog( pParentWnd ) 50 | , m_hWnd( NULL ) 51 | { 52 | ::ZeroMemory( m_szFolPath, MAX_PATH ); 53 | ::ZeroMemory( m_szSelPath, MAX_PATH ); 54 | ::ZeroMemory( &m_bi, sizeof( BROWSEINFO ) ); 55 | 56 | if( lpszSelPath != NULL ) 57 | SetSelectedFolder( lpszSelPath ); 58 | 59 | // Fill data 60 | m_bi.hwndOwner = pParentWnd->GetSafeHwnd(); 61 | m_bi.pidlRoot = NULL; 62 | m_bi.lpszTitle = lpszTitle; 63 | m_bi.ulFlags = uFlags; 64 | m_bi.lpfn = (BFFCALLBACK)BrowseCallbackProc; 65 | m_bi.lParam = (LPARAM)this; 66 | 67 | // The size of this buffer is assumed to be MAX_PATH bytes 68 | m_bi.pszDisplayName = new TCHAR[ MAX_PATH ]; 69 | ::ZeroMemory( m_bi.pszDisplayName, ( MAX_PATH * sizeof( TCHAR ) ) ); 70 | } 71 | 72 | CFolderDialog::~CFolderDialog( void ) 73 | { 74 | _delete2( m_bi.pszDisplayName ); 75 | ::ZeroMemory( &m_bi, sizeof( BROWSEINFO ) ); 76 | } 77 | 78 | BEGIN_MESSAGE_MAP( CFolderDialog, CCommonDialog ) 79 | END_MESSAGE_MAP() 80 | 81 | ///////////////////////////////////////////////////////////////////////////// 82 | // CFolderDialog message handlers 83 | 84 | #if ( _MFC_VER < 0x0700 ) 85 | INT CFolderDialog::DoModal( void ) 86 | #else 87 | INT_PTR CFolderDialog::DoModal( void ) 88 | #endif 89 | { 90 | ASSERT_VALID( this ); 91 | ASSERT( m_bi.lpfn != NULL ); 92 | 93 | m_bi.hwndOwner = PreModal(); 94 | INT_PTR nRet = -1; 95 | LPITEMIDLIST lpItemIDList = ::SHBrowseForFolder( &m_bi ); 96 | 97 | if( lpItemIDList != NULL ) 98 | { 99 | if( ::SHGetPathFromIDList( lpItemIDList, m_szFolPath ) ) 100 | { 101 | IMalloc* lpMalloc = NULL; 102 | if( SUCCEEDED( ::SHGetMalloc( &lpMalloc ) ) ) 103 | { 104 | lpMalloc->Free( lpItemIDList ); 105 | _releaseInterface( lpMalloc ); 106 | } 107 | nRet = IDOK; 108 | } 109 | else 110 | nRet = IDCANCEL; 111 | 112 | lpItemIDList = NULL; 113 | } 114 | 115 | PostModal(); 116 | return nRet; 117 | } 118 | 119 | ///////////////////////////////////////////////////////////////////////////// 120 | // Overridables: 121 | 122 | void CFolderDialog::OnInitialized( void ) 123 | { 124 | if( ::lstrlen( m_szSelPath ) > 0 ) 125 | SetSelection( m_szSelPath ); 126 | } 127 | 128 | void CFolderDialog::OnSelChanged( IN LPITEMIDLIST lpItemIDList ) 129 | { 130 | if( m_bi.ulFlags & BIF_STATUSTEXT ) 131 | { 132 | TCHAR szSelFol[ MAX_PATH ] = { 0 }; 133 | if( ::SHGetPathFromIDList( lpItemIDList, szSelFol ) ) 134 | SetStatusText( szSelFol ); 135 | } 136 | } 137 | 138 | INT CFolderDialog::OnValidateFailed( IN LPCTSTR /*lpszFolderPath*/ ) 139 | { 140 | ::MessageBeep( MB_ICONHAND ); 141 | return 1; // Return 1 to leave dialog open, 0 - to end one 142 | } 143 | 144 | void CFolderDialog::OnIUnknown( IN IUnknown* /*lpIUnknown*/ ) 145 | { 146 | } 147 | 148 | ///////////////////////////////////////////////////////////////////////////// 149 | // Callback function used with the SHBrowseForFolder function. 150 | 151 | INT CALLBACK CFolderDialog::BrowseCallbackProc( HWND hWnd, 152 | UINT uMsg, LPARAM lParam, LPARAM lpData ) 153 | { 154 | CFolderDialog* pThis = (CFolderDialog*)lpData; 155 | pThis->m_hWnd = hWnd; 156 | INT nRet = 0; 157 | 158 | switch( uMsg ) 159 | { 160 | case BFFM_INITIALIZED: 161 | pThis->OnInitialized(); 162 | break; 163 | case BFFM_SELCHANGED: 164 | pThis->OnSelChanged( (LPITEMIDLIST)lParam ); 165 | break; 166 | case BFFM_VALIDATEFAILED: 167 | nRet = pThis->OnValidateFailed( (LPCTSTR)lParam ); 168 | break; 169 | case BFFM_IUNKNOWN: 170 | pThis->OnIUnknown( (IUnknown*)lParam ); 171 | break; 172 | default: 173 | ASSERT( FALSE ); 174 | break; 175 | } 176 | 177 | pThis->m_hWnd = NULL; 178 | return nRet; 179 | } 180 | 181 | ///////////////////////////////////////////////////////////////////////////// 182 | 183 | void CFolderDialog::SetExpanded( IN LPCTSTR lpszFolderPath ) 184 | { 185 | ASSERT( m_hWnd != NULL ); 186 | 187 | USES_CONVERSION; 188 | ::SendMessage( m_hWnd, BFFM_SETEXPANDED, (WPARAM)TRUE, 189 | (LPARAM)(LPCWSTR)T2W( const_cast( lpszFolderPath ) ) ); 190 | } 191 | 192 | void CFolderDialog::SetOKText( IN LPCTSTR lpszText ) 193 | { 194 | ASSERT( m_hWnd != NULL ); 195 | 196 | USES_CONVERSION; 197 | ::SendMessage( m_hWnd, BFFM_SETOKTEXT, (WPARAM)0, 198 | (LPARAM)(LPCWSTR)T2W( const_cast( lpszText ) ) ); 199 | } 200 | 201 | 202 | ///////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /FolderDlg.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | /* 3 | DESCRIPTION: 4 | CFolderDialog - Folder Selection Dialog Class 5 | http://www.codeproject.com/dialog/cfolderdialog.asp 6 | 7 | NOTES: 8 | Copyright(C) Armen Hakobyan, 2002 9 | mailto:armen.h@web.am 10 | 11 | VERSION HISTORY: 12 | 24 Mar 2002 - First release 13 | 30 Mar 2003 - Some minor changes 14 | - Added missing in old Platform SDK new flag definitions 15 | - Added support for both MFC 6.0 and 7.0 16 | - Added OnIUnknown handler for Windows XP folder filtration 17 | - Added SetExpanded and SetOKText and GetSelectedFolder functions 18 | 24 May 2003 - Added OnSelChanged implementation 19 | 14 Jul 2003 - Added custom filtration for Windows XP 20 | */ 21 | ///////////////////////////////////////////////////////////////////////////// 22 | 23 | #ifndef __FOLDERDLG_H__ 24 | #define __FOLDERDLG_H__ 25 | #if defined( _MSC_VER ) && ( _MSC_VER >= 1020 ) 26 | #pragma once 27 | #endif 28 | 29 | ///////////////////////////////////////////////////////////////////////////// 30 | 31 | #ifndef __AFXDLGS_H__ 32 | #include < AfxDlgs.h > 33 | #endif 34 | 35 | #ifndef __ATLCONV_H__ 36 | #include < AtlConv.h > // MBCS/Unicode Conversion Macros 37 | #endif 38 | 39 | ///////////////////////////////////////////////////////////////////////////// 40 | 41 | #ifndef BFFM_SETOKTEXT // Version 5.0 or later 42 | #define BFFM_SETOKTEXT ( WM_USER + 105 ) // Unicode only, req. BIF_USENEWUI 43 | #define BFFM_SETEXPANDED ( WM_USER + 106 ) // Unicode only, req. BIF_USENEWUI 44 | #endif 45 | 46 | #ifndef BIF_NEWDIALOGSTYLE // Version 5.0 or later 47 | #define BIF_NEWDIALOGSTYLE 0x0040 48 | #define BIF_BROWSEINCLUDEURLS 0x0080 49 | #define BIF_UAHINT 0x0100 // Req. BIF_NEWDIALOGSTYLE 50 | #define BIF_NONEWFOLDERBUTTON 0x0200 51 | #define BIF_NOTRANSLATETARGETS 0x0400 52 | #define BIF_SHAREABLE 0x8000 // Req. BIF_USENEWUI 53 | #define BIF_USENEWUI ( BIF_NEWDIALOGSTYLE | BIF_EDITBOX ) 54 | #endif 55 | 56 | ///////////////////////////////////////////////////////////////////////////// 57 | 58 | #ifndef _delete2 59 | #define _delete2( p ) { if( p != NULL ){ delete[] p; p = NULL; } } 60 | #endif 61 | 62 | #ifndef _releaseInterface 63 | #define _releaseInterface( p ) { if( p != NULL ){ p->Release(); p = NULL; } } 64 | #endif 65 | 66 | #ifndef _NOINLINE 67 | #if ( _MSC_VER < 1700 ) 68 | #define _NOINLINE 69 | #else 70 | #define _NOINLINE __declspec( noinline ) 71 | #endif 72 | #endif 73 | 74 | ///////////////////////////////////////////////////////////////////////////// 75 | 76 | class CFolderDialog : public CCommonDialog 77 | { 78 | DECLARE_DYNAMIC( CFolderDialog ) 79 | 80 | public: 81 | CFolderDialog( IN LPCTSTR lpszTitle = NULL, 82 | IN LPCTSTR lpszSelPath = NULL, 83 | IN CWnd* pParentWnd = NULL, 84 | IN UINT uFlags = BIF_RETURNONLYFSDIRS ); 85 | virtual ~CFolderDialog( void ); 86 | 87 | public: 88 | #if ( _MFC_VER < 0x0700 ) 89 | virtual INT DoModal( void ); 90 | #else 91 | virtual INT_PTR DoModal( void ); 92 | #endif 93 | 94 | public: 95 | AFX_INLINE BOOL SetSelectedFolder( IN LPCTSTR lpszPath ); 96 | AFX_INLINE LPCTSTR GetFolderPath( void ) const; 97 | AFX_INLINE LPCTSTR GetFolderName( void ) const; 98 | AFX_INLINE INT GetFolderImage( void ) const; 99 | AFX_INLINE LPCTSTR GetSelectedFolder( void ) const; 100 | AFX_INLINE BROWSEINFO& GetBI( void ); 101 | AFX_INLINE const BROWSEINFO& GetBI( void ) const; 102 | 103 | protected: 104 | BROWSEINFO m_bi; 105 | TCHAR m_szSelPath[ MAX_PATH ]; 106 | TCHAR m_szFolPath[ MAX_PATH ]; 107 | 108 | protected: 109 | DECLARE_MESSAGE_MAP() 110 | 111 | virtual void OnInitialized( void ); 112 | virtual void OnSelChanged( IN LPITEMIDLIST lpItemIDList ); 113 | virtual INT OnValidateFailed( IN LPCTSTR /*lpszFolderPath*/ ); 114 | 115 | protected: // Windows XP or later 116 | virtual void OnIUnknown( IN IUnknown* /*lpIUnknown*/ ); 117 | 118 | protected: // Shell version 5.0 or later: 119 | _NOINLINE void SetExpanded( IN LPCTSTR lpszFolderPath ); 120 | _NOINLINE void SetOKText( IN LPCTSTR lpszText ); 121 | 122 | protected: // Valid to call only from the above handlers 123 | AFX_INLINE void EnableOK( IN BOOL bEnable = TRUE ); 124 | AFX_INLINE void SetSelection( IN LPITEMIDLIST lpItemIDList ); 125 | AFX_INLINE void SetSelection( IN LPCTSTR lpszFolderPath ); 126 | AFX_INLINE void SetStatusText( IN LPCTSTR lpszText ); 127 | 128 | protected: // Shell version 5.0 or later: 129 | AFX_INLINE void SetExpanded( IN LPITEMIDLIST lpItemIDList ); 130 | 131 | private: 132 | HWND m_hWnd; // used only in the callback function 133 | static INT CALLBACK BrowseCallbackProc( 134 | HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData 135 | ); 136 | }; 137 | 138 | ///////////////////////////////////////////////////////////////////////////// 139 | 140 | AFX_INLINE BOOL CFolderDialog::SetSelectedFolder( IN LPCTSTR lpszPath ) 141 | { ASSERT ( lpszPath != NULL ); 142 | return( ::lstrcpy( m_szSelPath, lpszPath ) != NULL ); } 143 | 144 | AFX_INLINE LPCTSTR CFolderDialog::GetSelectedFolder( void ) const 145 | { return m_szSelPath; } 146 | 147 | AFX_INLINE BROWSEINFO& CFolderDialog::GetBI( void ) 148 | { return m_bi; } 149 | 150 | AFX_INLINE const BROWSEINFO& CFolderDialog::GetBI( void ) const 151 | { return m_bi; } 152 | 153 | ///////////////////////////////////////////////////////////////////////////// 154 | // Filled after a call to DoModal 155 | 156 | AFX_INLINE LPCTSTR CFolderDialog::GetFolderPath( void ) const 157 | { return m_szFolPath; } 158 | 159 | AFX_INLINE LPCTSTR CFolderDialog::GetFolderName( void ) const 160 | { return m_bi.pszDisplayName; } 161 | 162 | AFX_INLINE INT CFolderDialog::GetFolderImage( void ) const 163 | { return m_bi.iImage; } 164 | 165 | ///////////////////////////////////////////////////////////////////////////// 166 | // Commands, valid to call only from handlers 167 | 168 | AFX_INLINE void CFolderDialog::EnableOK( IN BOOL bEnable /*TRUE*/ ) 169 | { ASSERT( m_hWnd != NULL ); 170 | ::SendMessage( m_hWnd, BFFM_ENABLEOK, (WPARAM)bEnable, 0L );} 171 | 172 | AFX_INLINE void CFolderDialog::SetSelection( IN LPITEMIDLIST lpItemIDList ) 173 | { ASSERT( m_hWnd != NULL ); 174 | ::SendMessage( m_hWnd, BFFM_SETSELECTION, (WPARAM)FALSE, (LPARAM)lpItemIDList ); } 175 | 176 | AFX_INLINE void CFolderDialog::SetSelection( IN LPCTSTR lpszFolderPath ) 177 | { ASSERT( m_hWnd != NULL ); 178 | ::SendMessage( m_hWnd, BFFM_SETSELECTION, (WPARAM)TRUE, (LPARAM)lpszFolderPath ); } 179 | 180 | AFX_INLINE void CFolderDialog::SetStatusText( IN LPCTSTR lpszText ) 181 | { ASSERT( m_hWnd != NULL ); 182 | ::SendMessage( m_hWnd, BFFM_SETSTATUSTEXT, (WPARAM)0, (LPARAM)lpszText ); } 183 | 184 | // Shell version 5.0 or later: 185 | 186 | AFX_INLINE void CFolderDialog::SetExpanded( IN LPITEMIDLIST lpItemIDList ) 187 | { ASSERT( m_hWnd != NULL ); 188 | ::SendMessage( m_hWnd, BFFM_SETEXPANDED, (WPARAM)FALSE, (LPARAM)lpItemIDList ); } 189 | 190 | ///////////////////////////////////////////////////////////////////////////// 191 | #endif // __FOLDERDLG_H__ 192 | ///////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /Font.cpp: -------------------------------------------------------------------------------- 1 | // Font.cpp: implementation of the Font class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "renlib.h" 7 | #include "Font.h" 8 | 9 | #ifdef _DEBUG 10 | #undef THIS_FILE 11 | static char THIS_FILE[]=__FILE__; 12 | #define new DEBUG_NEW 13 | #endif 14 | 15 | ////////////////////////////////////////////////////////////////////// 16 | // Construction/Destruction 17 | ////////////////////////////////////////////////////////////////////// 18 | 19 | namespace 20 | { 21 | const int defaultPointSize[] = { 6, 10, 12 }; 22 | 23 | const bool defaultItalic = false; 24 | const bool defaultBold = false; 25 | const CString defaultFaceName = "System"; 26 | } 27 | 28 | Font::Font() 29 | { 30 | setDefault(0); 31 | } 32 | 33 | Font::~Font() 34 | { 35 | } 36 | 37 | void Font::setDefault(int boardSize) 38 | { 39 | mPointSize = defaultPointSize[boardSize]; 40 | mIsBold = defaultBold; 41 | mIsItalic = defaultItalic; 42 | mFaceName = defaultFaceName; 43 | } 44 | 45 | void Font::getLogFont(LOGFONT& lf) 46 | { 47 | memset(&lf, 0, sizeof(LOGFONT)); 48 | lf.lfHeight = mPointSize * 10; 49 | lf.lfWeight = mIsBold ? 700 : 400; 50 | lf.lfItalic = mIsItalic ? TRUE : FALSE; 51 | strcpy (lf.lfFaceName, mFaceName); 52 | } 53 | 54 | 55 | int Font::getPointSize() 56 | { 57 | return mPointSize; 58 | } 59 | 60 | void Font::setPointSize(int pointSize) 61 | { 62 | mPointSize = pointSize; 63 | } 64 | 65 | bool Font::isBold() 66 | { 67 | return mIsBold; 68 | } 69 | 70 | void Font::setBold(bool bold) 71 | { 72 | mIsBold = bold; 73 | } 74 | 75 | bool Font::isItalic() 76 | { 77 | return mIsItalic; 78 | } 79 | 80 | void Font::setItalic(bool italic) 81 | { 82 | mIsItalic = italic; 83 | } 84 | 85 | CString Font::getFaceName() 86 | { 87 | return mFaceName; 88 | } 89 | 90 | void Font::setFaceName(const CString& faceName) 91 | { 92 | mFaceName = faceName; 93 | } 94 | 95 | CString Font::toString() 96 | { 97 | CString fontString; 98 | fontString.Format("%d,%d,%d,%s", mPointSize,mIsBold,mIsItalic,mFaceName); 99 | return fontString; 100 | } 101 | 102 | void Font::parse(CString fontString, int boardSize) 103 | { 104 | setDefault(boardSize); 105 | 106 | char seps[] = ","; 107 | char *token; 108 | 109 | token = strtok( fontString.GetBufferSetLength(fontString.GetLength()), seps ); 110 | 111 | if (token != NULL) 112 | { 113 | mPointSize = atoi(token); 114 | token = strtok( NULL, seps ); 115 | } 116 | 117 | if (token != NULL) 118 | { 119 | mIsBold = (atoi(token) == 1); 120 | token = strtok( NULL, seps ); 121 | } 122 | 123 | if (token != NULL) 124 | { 125 | mIsItalic = (atoi(token) == 1); 126 | token = strtok( NULL, seps ); 127 | } 128 | 129 | if (token != NULL) 130 | { 131 | mFaceName = token; 132 | token = strtok( NULL, seps ); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /Font.h: -------------------------------------------------------------------------------- 1 | // Font.h: interface for the Font class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_FONT_H__FC3BD1E2_A7E0_11D6_92A3_0000E89F396C__INCLUDED_) 6 | #define AFX_FONT_H__FC3BD1E2_A7E0_11D6_92A3_0000E89F396C__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | class Font 13 | { 14 | public: 15 | Font(); 16 | virtual ~Font(); 17 | 18 | void setDefault(int boardSize); 19 | 20 | void getLogFont(LOGFONT& lf); 21 | 22 | int getPointSize(); 23 | void setPointSize(int pointSize); 24 | 25 | bool isBold(); 26 | void setBold(bool bold); 27 | 28 | bool isItalic(); 29 | void setItalic(bool italic); 30 | 31 | CString getFaceName(); 32 | void setFaceName(const CString& faceName); 33 | 34 | CString toString(); 35 | void parse(CString fontString, int boardSize); 36 | 37 | private: 38 | int mPointSize; 39 | bool mIsBold; 40 | bool mIsItalic; 41 | CString mFaceName; 42 | 43 | }; 44 | 45 | #endif // !defined(AFX_FONT_H__FC3BD1E2_A7E0_11D6_92A3_0000E89F396C__INCLUDED_) 46 | -------------------------------------------------------------------------------- /FontDialog.h: -------------------------------------------------------------------------------- 1 | // FontDialog.h: interface for the FontDialog class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_FONTDIALOG_H__69ACDFA2_A960_11D6_92A3_0000E89F396C__INCLUDED_) 6 | #define AFX_FONTDIALOG_H__69ACDFA2_A960_11D6_92A3_0000E89F396C__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | class FontDialog 13 | { 14 | public: 15 | FontDialog(); 16 | virtual ~FontDialog(); 17 | 18 | }; 19 | 20 | #endif // !defined(AFX_FONTDIALOG_H__69ACDFA2_A960_11D6_92A3_0000E89F396C__INCLUDED_) 21 | -------------------------------------------------------------------------------- /Game.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/Game.cpp -------------------------------------------------------------------------------- /Game.h: -------------------------------------------------------------------------------- 1 | // Game.h: interface for the Game class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_GAME_H__768479C2_8105_11D4_92A3_BABD602D7A25__INCLUDED_) 6 | #define AFX_GAME_H__768479C2_8105_11D4_92A3_BABD602D7A25__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | #include 13 | #include "StringEx.h" 14 | 15 | class Game 16 | { 17 | public: 18 | enum Kind 19 | { 20 | NONE, 21 | PBEM, 22 | PLAYSITE, 23 | TEXTBOARD, 24 | BLIP, 25 | KURNIK, 26 | RENJUCLASS 27 | }; 28 | 29 | enum Result 30 | { 31 | VALID, 32 | OPEN_FILE_ERROR, 33 | INVALID_KIND, 34 | LESS_THAN_5_MOVES, 35 | SAME_COORDINATE 36 | }; 37 | 38 | class Node 39 | { 40 | public: 41 | Node(); 42 | 43 | BYTE getPos(); 44 | void setPos(BYTE pos); 45 | 46 | CString getOneLineComment(); 47 | void setOneLineComment(const CString& comment); 48 | 49 | CString getMultiLineComment(); 50 | void setMultiLineComment(const CString& comment); 51 | 52 | bool hasMoreBoardTexts(); 53 | void nextBoardText(BYTE& coord, CString& boardText); 54 | void addBoardText(const BYTE& coord, const CString& boardText); 55 | 56 | private: 57 | BYTE mPos; 58 | CString mOneLineComment; 59 | CString mMultiLineComment; 60 | 61 | std::vector mCoord; 62 | std::vector mBoardText; 63 | int mIndex; 64 | }; 65 | 66 | public: 67 | Game(); 68 | 69 | bool open(const CString& strFile, bool multipleGames); 70 | Result addGame(); 71 | void close(); 72 | 73 | Result addWebGame(CStringEx& strPage); 74 | 75 | void clear(); 76 | 77 | void addPos(BYTE pos); 78 | 79 | void AddMove(CString strMove); 80 | 81 | void addOneLineComment(int moveNo, const CString& comment); 82 | void addMultiLineComment(int moveNo, const CString& comment); 83 | void addBoardText(int moveNo, const BYTE& coord, const CString& boardText); 84 | 85 | Result CheckMoves(); 86 | 87 | CString getFilePath(); 88 | 89 | int numberOfMoves(); 90 | 91 | bool hasMoreMoves(); 92 | Node* nextMove(); 93 | 94 | private: 95 | void setKind(Kind kind); 96 | 97 | bool GetLine (CString& strLine); 98 | void getToken(CString& strLine, CString& strToken); 99 | 100 | void ParsePBeM(); 101 | void ParsePlaySite(); 102 | void ParseTextBoard(); 103 | void ParseBlip(CString& strLine); 104 | void ParseKurnik(CString& strLine); 105 | void ParseRenjuclass(CString& strLine); 106 | 107 | Result parseGame(); 108 | Result parseWebGame(CStringEx& strPage); 109 | Result parseApplet(CStringEx& strPage); 110 | Result parseRenjuclassDiagram(CString& strPage); 111 | void removeHtml(CString& strText); 112 | CString replaceEvery(CString& strTarget, const CString& strOccurence, const CString& strWith); 113 | CString trim(CString& strTarget, const CString& strOccurence); 114 | CPoint MoveToPoint(CString strMove); 115 | 116 | private: 117 | std::vector mMoves; 118 | int mIndex; 119 | CStdioFile mGameFile; 120 | Kind mKind; 121 | CString mResult; 122 | CString mFilePath; 123 | bool mMultipleGames; 124 | }; 125 | 126 | #endif // !defined(AFX_GAME_H__768479C2_8105_11D4_92A3_BABD602D7A25__INCLUDED_) 127 | -------------------------------------------------------------------------------- /HyperLink.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/HyperLink.cpp -------------------------------------------------------------------------------- /HyperLink.h: -------------------------------------------------------------------------------- 1 | // HyperLink.h : header file 2 | // 3 | // 4 | // HyperLink static control. Will open the default browser with the given URL 5 | // when the user clicks on the link. 6 | // 7 | // Copyright Chris Maunder, 1997, 1998 8 | // Feel free to use and distribute. May not be sold for profit. 9 | 10 | #if !defined(AFX_HYPERLINK_H__D1625061_574B_11D1_ABBA_00A0243D1382__INCLUDED_) 11 | #define AFX_HYPERLINK_H__D1625061_574B_11D1_ABBA_00A0243D1382__INCLUDED_ 12 | 13 | #if _MSC_VER >= 1000 14 | #pragma once 15 | #endif // _MSC_VER >= 1000 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // CHyperLink window 19 | 20 | class CHyperLink : public CStatic 21 | { 22 | // Construction/destruction 23 | public: 24 | CHyperLink(); 25 | virtual ~CHyperLink(); 26 | 27 | // Attributes 28 | public: 29 | 30 | // Operations 31 | public: 32 | 33 | void SetURL(const CString& strURL); 34 | CString GetURL() const; 35 | 36 | void SetColours(COLORREF crLinkColour, COLORREF crVisitedColour, 37 | COLORREF crHoverColour = -1); 38 | COLORREF GetLinkColour() const; 39 | COLORREF GetVisitedColour() const; 40 | COLORREF GetHoverColour() const; 41 | 42 | void SetVisited(BOOL bVisited = TRUE); 43 | BOOL GetVisited() const; 44 | 45 | void SetLinkCursor(HCURSOR hCursor); 46 | HCURSOR GetLinkCursor() const; 47 | 48 | void SetUnderline(BOOL bUnderline = TRUE); 49 | BOOL GetUnderline() const; 50 | 51 | void SetAutoSize(BOOL bAutoSize = TRUE); 52 | BOOL GetAutoSize() const; 53 | 54 | static HINSTANCE GotoURL(LPCTSTR url, int showcmd = SW_SHOW); 55 | 56 | // Overrides 57 | // ClassWizard generated virtual function overrides 58 | //{{AFX_VIRTUAL(CHyperLink) 59 | public: 60 | virtual BOOL PreTranslateMessage(MSG* pMsg); 61 | protected: 62 | virtual void PreSubclassWindow(); 63 | //}}AFX_VIRTUAL 64 | 65 | // Implementation 66 | protected: 67 | void ReportError(int nError); 68 | static LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata); 69 | void PositionWindow(); 70 | void SetDefaultCursor(); 71 | 72 | // Protected attributes 73 | protected: 74 | COLORREF m_crLinkColour, m_crVisitedColour; // Hyperlink colours 75 | COLORREF m_crHoverColour; // Hover colour 76 | BOOL m_bOverControl; // cursor over control? 77 | BOOL m_bVisited; // Has it been visited? 78 | BOOL m_bUnderline; // underline hyperlink? 79 | BOOL m_bAdjustToFit; // Adjust window size to fit text? 80 | CString m_strURL; // hyperlink URL 81 | CFont m_Font; // Underline font if necessary 82 | HCURSOR m_hLinkCursor; // Cursor for hyperlink 83 | CToolTipCtrl m_ToolTip; // The tooltip 84 | 85 | // Generated message map functions 86 | protected: 87 | //{{AFX_MSG(CHyperLink) 88 | afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); 89 | afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); 90 | afx_msg void OnMouseMove(UINT nFlags, CPoint point); 91 | //}}AFX_MSG 92 | afx_msg void OnClicked(); 93 | DECLARE_MESSAGE_MAP() 94 | }; 95 | 96 | ///////////////////////////////////////////////////////////////////////////// 97 | 98 | //{{AFX_INSERT_LOCATION}} 99 | // Microsoft Developer Studio will insert additional declarations immediately before the previous line. 100 | 101 | #endif // !defined(AFX_HYPERLINK_H__D1625061_574B_11D1_ABBA_00A0243D1382__INCLUDED_) 102 | -------------------------------------------------------------------------------- /IntReg.cpp: -------------------------------------------------------------------------------- 1 | // IntReg.cpp: implementation of the CIntReg class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "renlib.h" 7 | #include "IntReg.h" 8 | 9 | #ifdef _DEBUG 10 | #undef THIS_FILE 11 | static char THIS_FILE[]=__FILE__; 12 | #define new DEBUG_NEW 13 | #endif 14 | 15 | ////////////////////////////////////////////////////////////////////// 16 | // Construction/Destruction 17 | ////////////////////////////////////////////////////////////////////// 18 | 19 | CIntReg::CIntReg(const CString& strSection, const CString& strEntry, int nDefault) 20 | : mSection(strSection), 21 | mEntry(strEntry) 22 | { 23 | mValue = AfxGetApp()->GetProfileInt(mSection, mEntry, nDefault); 24 | } 25 | 26 | CIntReg::~CIntReg() 27 | { 28 | AfxGetApp()->WriteProfileInt(mSection, mEntry, mValue); 29 | } 30 | -------------------------------------------------------------------------------- /IntReg.h: -------------------------------------------------------------------------------- 1 | // IntReg.h: interface for the CIntReg class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_INTREG_H__CC8271A5_92F5_4D5F_A015_89351D894845__INCLUDED_) 6 | #define AFX_INTREG_H__CC8271A5_92F5_4D5F_A015_89351D894845__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | class CIntReg 13 | { 14 | public: 15 | CIntReg(const CString& strSection, const CString& strEntry, int nDefault); 16 | ~CIntReg(); 17 | 18 | private: 19 | CIntReg(); 20 | 21 | private: 22 | CString mSection; 23 | CString mEntry; 24 | int mValue; 25 | }; 26 | 27 | #endif // !defined(AFX_INTREG_H__CC8271A5_92F5_4D5F_A015_89351D894845__INCLUDED_) 28 | -------------------------------------------------------------------------------- /LibraryFile.cpp: -------------------------------------------------------------------------------- 1 | // LibraryFile.cpp: implementation of the LibraryFile class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "renlib.h" 7 | #include "LibraryFile.h" 8 | #include "Utils.h" 9 | #include "RenLibDoc.h" 10 | 11 | #ifdef _DEBUG 12 | #undef THIS_FILE 13 | static char THIS_FILE[]=__FILE__; 14 | #define new DEBUG_NEW 15 | #endif 16 | 17 | namespace 18 | { 19 | const HEADER_SIZE = 20; 20 | 21 | const MAJOR_FILE_VERSION_INDEX = 8; 22 | const MINOR_FILE_VERSION_INDEX = 9; 23 | 24 | const MAJOR_FILE_VERSION = 3; 25 | const MINOR_FILE_VERSION = 4; 26 | 27 | const MAJOR_FILE_VERSION_H8 = 3; 28 | const MINOR_FILE_VERSION_OLD = 0; 29 | 30 | const CENTER = 0x78; 31 | } 32 | 33 | ////////////////////////////////////////////////////////////////////// 34 | // Construction/Destruction 35 | ////////////////////////////////////////////////////////////////////// 36 | 37 | LibraryFile::LibraryFile() : 38 | m_indexStart(0), 39 | m_indexEnd(0), 40 | m_mode(UINT_MAX), 41 | m_MajorFileVersion(0), 42 | m_MinorFileVersion(0) 43 | { 44 | } 45 | 46 | //------------------------------------------------------------------------ 47 | 48 | LibraryFile::~LibraryFile() 49 | { 50 | } 51 | 52 | //------------------------------------------------------------------------ 53 | 54 | bool LibraryFile::OpenRead(const CString& fileName) 55 | { 56 | return Open(fileName, CFile::modeRead); 57 | } 58 | 59 | //------------------------------------------------------------------------ 60 | 61 | bool LibraryFile::OpenWrite(const CString& fileName) 62 | { 63 | return Open(fileName, CFile::modeCreate | CFile::modeWrite); 64 | } 65 | 66 | //------------------------------------------------------------------------ 67 | 68 | bool LibraryFile::Open(const CString& fileName, UINT mode) 69 | { 70 | m_mode = mode; 71 | CFileException e; 72 | return (m_file.Open(fileName, m_mode, &e ) != 0); 73 | } 74 | 75 | //------------------------------------------------------------------------ 76 | 77 | bool LibraryFile::Get(MoveNode& node) 78 | { 79 | node.setPos(CPoint(0,0)); 80 | node.clearInformation(); 81 | 82 | BYTE data1; 83 | BYTE data2; 84 | 85 | bool success = Get(data1, data2); 86 | 87 | if (success) 88 | { 89 | node.setPosInfo(data1, data2); 90 | 91 | if (node.isExtension()) 92 | { 93 | success = Get(data1, data2); 94 | node.setExtendedInfo(data1, data2); 95 | } 96 | } 97 | 98 | return success; 99 | } 100 | 101 | //------------------------------------------------------------------------ 102 | 103 | bool LibraryFile::Get(BYTE& data1, BYTE& data2) 104 | { 105 | data1 = 0; 106 | data2 = 0; 107 | 108 | if (m_indexStart >= m_indexEnd) 109 | { 110 | UINT nBytesRead = m_file.Read(m_buffer, BUFFERSIZE); 111 | 112 | if (nBytesRead == 0) 113 | { 114 | return false; 115 | } 116 | 117 | m_indexEnd = nBytesRead - 1; 118 | m_indexStart = 0; 119 | } 120 | 121 | data1 = m_buffer[m_indexStart++]; 122 | data2 = m_buffer[m_indexStart++]; 123 | 124 | return true; 125 | } 126 | 127 | //------------------------------------------------------------------------ 128 | 129 | void LibraryFile::Write() 130 | { 131 | if (m_mode == (CFile::modeCreate | CFile::modeWrite)) 132 | { 133 | if (m_indexEnd) 134 | { 135 | m_file.Write(m_buffer, m_indexEnd); 136 | m_indexEnd = 0; 137 | } 138 | } 139 | } 140 | 141 | //------------------------------------------------------------------------ 142 | 143 | void LibraryFile::Put(BYTE data1, BYTE data2) 144 | { 145 | if (m_indexEnd >= BUFFERSIZE) 146 | { 147 | Write(); 148 | } 149 | 150 | m_buffer[m_indexEnd++] = data1; 151 | 152 | if (m_indexEnd >= BUFFERSIZE) 153 | { 154 | Write(); 155 | } 156 | 157 | m_buffer[m_indexEnd++] = data2; 158 | } 159 | 160 | //------------------------------------------------------------------------ 161 | 162 | void LibraryFile::Put(const MoveNode& node) 163 | { 164 | BYTE data1; 165 | BYTE data2; 166 | 167 | node.getPosInfo(data1, data2); 168 | Put(data1, data2); 169 | 170 | if (node.isExtension()) 171 | { 172 | node.getExtendedInfo(data1, data2); 173 | Put(data1, data2); 174 | } 175 | } 176 | 177 | //------------------------------------------------------------------------ 178 | 179 | void LibraryFile::Put(const CString& str) 180 | { 181 | for (int i=0; i < str.GetLength(); i++) 182 | { 183 | if (m_indexEnd >= BUFFERSIZE) 184 | { 185 | Write(); 186 | } 187 | 188 | m_buffer[m_indexEnd++] = str[i]; 189 | } 190 | } 191 | 192 | //------------------------------------------------------------------------ 193 | 194 | void LibraryFile::Close() 195 | { 196 | try 197 | { 198 | Write(); 199 | m_file.Close(); 200 | } 201 | catch (...) 202 | { 203 | } 204 | } 205 | 206 | //------------------------------------------------------------------------ 207 | 208 | CString LibraryFile::GetFilePath() const 209 | { 210 | return m_file.GetFilePath(); 211 | } 212 | 213 | //------------------------------------------------------------------------ 214 | 215 | bool LibraryFile::CheckVersion() 216 | { 217 | bool VersionOk = false; 218 | 219 | // 0 1 2 3 4 5 6 7 220 | BYTE header[HEADER_SIZE] = { 0xFF, 'R', 'e', 'n', 'L', 'i', 'b', 0xFF }; 221 | 222 | BYTE buf[HEADER_SIZE]; 223 | DWORD dwRead; 224 | 225 | dwRead = m_file.Read(buf, HEADER_SIZE); 226 | 227 | if (dwRead == HEADER_SIZE) 228 | { 229 | bool HeaderMatch = true; 230 | 231 | for (int i=0; i<=7; i++) 232 | { 233 | if (buf[i] != header[i]) 234 | { 235 | HeaderMatch = false; 236 | break; 237 | } 238 | } 239 | 240 | if (HeaderMatch) 241 | { 242 | m_MajorFileVersion = buf[MAJOR_FILE_VERSION_INDEX]; 243 | m_MinorFileVersion = buf[MINOR_FILE_VERSION_INDEX]; 244 | 245 | if (100 * m_MajorFileVersion + m_MinorFileVersion <= 246 | 100 * MAJOR_FILE_VERSION + MINOR_FILE_VERSION) 247 | { 248 | VersionOk = true; 249 | } 250 | else 251 | { 252 | CString strMessage(Utils::GetString(IDS_MSG_VERSION, m_MajorFileVersion, m_MinorFileVersion)); 253 | Utils::ShowMessage(strMessage, Utils::GetString(IDS_CAP_VERSION), MB_ICONINFORMATION); 254 | } 255 | } 256 | else if (buf[0] == CENTER) 257 | { 258 | m_file.SeekToBegin(); 259 | VersionOk = true; 260 | } 261 | } 262 | 263 | if (!VersionOk) 264 | { 265 | CString strMessage(Utils::GetString(IDS_INVALID_LIB, m_file.GetFileName())); 266 | Utils::ShowMessage(strMessage, Utils::GetString(IDS_CAP_VERSION), MB_ICONERROR); 267 | } 268 | 269 | return VersionOk; 270 | } 271 | 272 | //------------------------------------------------------------------------ 273 | 274 | void LibraryFile::WriteHeader(bool isOldFormat) 275 | { 276 | // 0 1 2 3 4 5 6 7 277 | BYTE header[HEADER_SIZE] = { 0xFF, 'R', 'e', 'n', 'L', 'i', 'b', 0xFF, 278 | // 8 9 10 11 12 13 14 15 279 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 280 | // 16 17 18 19 281 | 0xFF, 0xFF, 0xFF, 0xFF }; 282 | 283 | header[MAJOR_FILE_VERSION_INDEX] = MAJOR_FILE_VERSION; 284 | 285 | if (isOldFormat) 286 | { 287 | header[MINOR_FILE_VERSION_INDEX] = MINOR_FILE_VERSION_OLD; 288 | } 289 | else 290 | { 291 | header[MINOR_FILE_VERSION_INDEX] = MINOR_FILE_VERSION; 292 | } 293 | 294 | m_file.Write(header, HEADER_SIZE); 295 | } 296 | 297 | //------------------------------------------------------------------------ 298 | 299 | CString LibraryFile::GetVersion() const 300 | { 301 | return m_Version; 302 | } 303 | 304 | //------------------------------------------------------------------------ 305 | -------------------------------------------------------------------------------- /LibraryFile.h: -------------------------------------------------------------------------------- 1 | // LibraryFile.h: interface for the LibraryFile class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_LIBRARYFILE_H__D04656A2_2118_11D5_92A3_A76A2BB73024__INCLUDED_) 6 | #define AFX_LIBRARYFILE_H__D04656A2_2118_11D5_92A3_A76A2BB73024__INCLUDED_ 7 | 8 | #include "MoveNode.h" 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif // _MSC_VER > 1000 13 | 14 | class LibraryFile 15 | { 16 | public: 17 | LibraryFile(); 18 | virtual ~LibraryFile(); 19 | 20 | bool OpenRead(const CString& fileName); 21 | bool OpenWrite(const CString& fileName); 22 | 23 | bool Get(BYTE& data1, BYTE& data2); 24 | bool Get(MoveNode& node); 25 | 26 | void Put(BYTE data1, BYTE data2); 27 | void Put(const MoveNode& node); 28 | void Put(const CString& str); 29 | 30 | CString GetFilePath() const; 31 | 32 | bool CheckVersion(); 33 | void WriteHeader(bool isOldFormat); 34 | 35 | void Close(); 36 | 37 | CString GetVersion() const; 38 | 39 | private: 40 | bool Open(const CString& fileName, UINT mode); 41 | void Write(); 42 | 43 | private: 44 | enum { BUFFERSIZE = 1024 }; 45 | 46 | CFile m_file; 47 | BYTE m_buffer[BUFFERSIZE]; 48 | int m_indexStart; 49 | int m_indexEnd; 50 | UINT m_mode; 51 | CString m_Version; 52 | BYTE m_MajorFileVersion; 53 | BYTE m_MinorFileVersion; 54 | }; 55 | 56 | #endif // !defined(AFX_LIBRARYFILE_H__D04656A2_2118_11D5_92A3_A76A2BB73024__INCLUDED_) 57 | -------------------------------------------------------------------------------- /MainFrm.h: -------------------------------------------------------------------------------- 1 | // MainFrm.h : interface of the CMainFrame class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_MAINFRM_H__72EC9D49_F85E_11D3_92A3_947F7AC2F525__INCLUDED_) 6 | #define AFX_MAINFRM_H__72EC9D49_F85E_11D3_92A3_947F7AC2F525__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | class CMainFrame : public CFrameWnd 13 | { 14 | 15 | protected: // create from serialization only 16 | CMainFrame(); 17 | DECLARE_DYNCREATE(CMainFrame) 18 | 19 | // Attributes 20 | public: 21 | 22 | // Operations 23 | public: 24 | void SetPaneText(const CString& text); 25 | 26 | // Overrides 27 | // ClassWizard generated virtual function overrides 28 | //{{AFX_VIRTUAL(CMainFrame) 29 | public: 30 | virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 31 | virtual BOOL PreTranslateMessage(MSG* pMsg); 32 | //}}AFX_VIRTUAL 33 | 34 | // Implementation 35 | public: 36 | virtual ~CMainFrame(); 37 | #ifdef _DEBUG 38 | virtual void AssertValid() const; 39 | virtual void Dump(CDumpContext& dc) const; 40 | #endif 41 | 42 | protected: // control bar embedded members 43 | CToolBar m_wndFileBar; 44 | CToolBar m_wndMoveBar; 45 | CToolBar m_wndPositionBar; 46 | CToolBar m_wndEditBar; 47 | CToolBar m_wndFindBar; 48 | CStatusBar m_wndStatusBar; 49 | 50 | private: 51 | static bool sIsPaneTextAllowed; 52 | static CString sPaneText; 53 | 54 | // Generated message map functions 55 | protected: 56 | //{{AFX_MSG(CMainFrame) 57 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 58 | afx_msg void OnUpdateMode(CCmdUI* pCmdUI); 59 | afx_msg void OnUpdateMove(CCmdUI* pCmdUI); 60 | afx_msg void OnUpdateVar(CCmdUI* pCmdUI); 61 | afx_msg void OnUpdateMark(CCmdUI* pCmdUI); 62 | afx_msg void OnUpdateMouse(CCmdUI* pCmdUI); 63 | afx_msg void OnUpdateText(CCmdUI* pCmdUI); 64 | afx_msg void OnFileBar(); 65 | afx_msg void OnMoveBar(); 66 | afx_msg void OnUpdateFileBar(CCmdUI* pCmdUI); 67 | afx_msg void OnUpdateMoveBar(CCmdUI* pCmdUI); 68 | afx_msg void OnPositionBar(); 69 | afx_msg void OnUpdatePositionBar(CCmdUI* pCmdUI); 70 | afx_msg void OnEditBar(); 71 | afx_msg void OnUpdateEditBar(CCmdUI* pCmdUI); 72 | afx_msg void OnFindBar(); 73 | afx_msg void OnUpdateFindBar(CCmdUI* pCmdUI); 74 | afx_msg void OnClose(); 75 | //}}AFX_MSG 76 | DECLARE_MESSAGE_MAP() 77 | 78 | private: 79 | void DockControlBarLeftOf(CToolBar* Bar,CToolBar* LeftOf); 80 | BOOL isVisible(const CToolBar& Bar); 81 | 82 | }; 83 | 84 | ///////////////////////////////////////////////////////////////////////////// 85 | 86 | //{{AFX_INSERT_LOCATION}} 87 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 88 | 89 | #endif // !defined(AFX_MAINFRM_H__72EC9D49_F85E_11D3_92A3_947F7AC2F525__INCLUDED_) 90 | -------------------------------------------------------------------------------- /MergeComment.cpp: -------------------------------------------------------------------------------- 1 | // MergeComment.cpp : implementation file 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "renlib.h" 6 | #include "MergeComment.h" 7 | 8 | #ifdef _DEBUG 9 | #define new DEBUG_NEW 10 | #undef THIS_FILE 11 | static char THIS_FILE[] = __FILE__; 12 | #endif 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | // MergeComment dialog 16 | 17 | 18 | namespace 19 | { 20 | UINT getDialogId(MergeComment::Kind kind) 21 | { 22 | UINT id = 0; 23 | 24 | switch (kind) 25 | { 26 | case MergeComment::ONE_LINE_COMMENT: 27 | { 28 | id = IDD_MERGE_ONELINE_COMMENT; 29 | break; 30 | } 31 | case MergeComment::MULTI_LINE_COMMENT: 32 | { 33 | id = IDD_MERGE_MULTI_LINE_COMMENT; 34 | break; 35 | } 36 | case MergeComment::BOARD_TEXT: 37 | { 38 | id = IDD_MERGE_BOARD_TEXT; 39 | break; 40 | } 41 | } 42 | 43 | return id; 44 | } 45 | } 46 | 47 | MergeComment::MergeComment(const CString& currentComment, const CString& newComment, MergeComment::Kind kind) 48 | : CDialog(getDialogId(kind), NULL), 49 | mKind(kind), 50 | mCurrentComment(currentComment), 51 | mNewComment(newComment), 52 | mSelection(CURRENT), 53 | mApplySelectionToAll(false) 54 | { 55 | //{{AFX_DATA_INIT(MergeComment) 56 | // NOTE: the ClassWizard will add member initialization here 57 | //}}AFX_DATA_INIT 58 | } 59 | 60 | 61 | void MergeComment::DoDataExchange(CDataExchange* pDX) 62 | { 63 | CDialog::DoDataExchange(pDX); 64 | //{{AFX_DATA_MAP(MergeComment) 65 | DDX_Control(pDX, IDC_MERGE_ALL, mApplyToAll); 66 | DDX_Control(pDX, IDC_SELECT_CURRENT, mSelectCurrent); 67 | DDX_Control(pDX, IDC_SELECT_NEW, mSelectNew); 68 | DDX_Control(pDX, IDC_SELECT_COMBINED, mSelectCombined); 69 | DDX_Control(pDX, IDC_EDIT_NEW, mNew); 70 | DDX_Control(pDX, IDC_EDIT_CURRENT, mCurrent); 71 | DDX_Control(pDX, IDC_EDIT_COMBINED, mCombinedComment); 72 | //}}AFX_DATA_MAP 73 | } 74 | 75 | 76 | BEGIN_MESSAGE_MAP(MergeComment, CDialog) 77 | //{{AFX_MSG_MAP(MergeComment) 78 | ON_BN_CLICKED(IDC_SELECT_CURRENT, OnCurrent) 79 | ON_BN_CLICKED(IDC_SELECT_NEW, OnNew) 80 | ON_BN_CLICKED(IDC_SELECT_COMBINED, OnCombined) 81 | //}}AFX_MSG_MAP 82 | END_MESSAGE_MAP() 83 | 84 | ///////////////////////////////////////////////////////////////////////////// 85 | // MergeComment message handlers 86 | 87 | BOOL MergeComment::OnInitDialog() 88 | { 89 | CDialog::OnInitDialog(); 90 | 91 | mCurrent.SetWindowText(mCurrentComment); 92 | mNew.SetWindowText(mNewComment); 93 | 94 | CString strDelimiter(mKind == MULTI_LINE_COMMENT ? "\r\n" : " "); 95 | 96 | mCombinedComment.SetWindowText(mCurrentComment + strDelimiter + mNewComment); 97 | 98 | updateControls(); 99 | 100 | return TRUE; // return TRUE unless you set the focus to a control 101 | // EXCEPTION: OCX Property Pages should return FALSE 102 | } 103 | 104 | //---------------------------------------------------------------------------- 105 | 106 | void MergeComment::OnCurrent() 107 | { 108 | mSelection = CURRENT; 109 | updateControls(); 110 | } 111 | 112 | //---------------------------------------------------------------------------- 113 | 114 | void MergeComment::OnNew() 115 | { 116 | mSelection = NEW; 117 | updateControls(); 118 | } 119 | 120 | //---------------------------------------------------------------------------- 121 | 122 | void MergeComment::OnCombined() 123 | { 124 | mSelection = COMBINED; 125 | updateControls(); 126 | } 127 | 128 | //---------------------------------------------------------------------------- 129 | 130 | void MergeComment::updateControls() 131 | { 132 | mSelectCurrent.SetCheck(mSelection == CURRENT); 133 | mSelectNew.SetCheck(mSelection == NEW); 134 | mSelectCombined.SetCheck(mSelection == COMBINED); 135 | 136 | mCurrent.EnableWindow(mSelectCurrent.GetCheck()); 137 | mNew.EnableWindow(mSelectNew.GetCheck()); 138 | mCombinedComment.EnableWindow(mSelectCombined.GetCheck()); 139 | } 140 | 141 | //---------------------------------------------------------------------------- 142 | 143 | CString MergeComment::getMergedComment() 144 | { 145 | return mCurrentComment; 146 | } 147 | 148 | //---------------------------------------------------------------------------- 149 | 150 | MergeComment::Selection 151 | MergeComment::getSelection() 152 | { 153 | return mSelection; 154 | } 155 | 156 | //---------------------------------------------------------------------------- 157 | 158 | bool MergeComment::getApplySelectionToAll() 159 | { 160 | return mApplySelectionToAll; 161 | } 162 | 163 | //---------------------------------------------------------------------------- 164 | 165 | void MergeComment::OnOK() 166 | { 167 | CDialog::OnOK(); 168 | 169 | if (mCurrent.IsWindowEnabled()) 170 | { 171 | mCurrent.GetWindowText(mCurrentComment); 172 | } 173 | else if (mNew.IsWindowEnabled()) 174 | { 175 | mNew.GetWindowText(mCurrentComment); 176 | } 177 | else if (mCombinedComment.IsWindowEnabled()) 178 | { 179 | mCombinedComment.GetWindowText(mCurrentComment); 180 | } 181 | 182 | if (mApplyToAll.GetCheck() == 1) 183 | { 184 | mApplySelectionToAll = true; 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /MergeComment.h: -------------------------------------------------------------------------------- 1 | #if !defined(AFX_MERGE_COMMENT_H__F6B9D182_F304_11D6_92A3_0000E89F396C__INCLUDED_) 2 | #define AFX_MERGE_COMMENT_H__F6B9D182_F304_11D6_92A3_0000E89F396C__INCLUDED_ 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif // _MSC_VER > 1000 7 | // MergeComment.h : header file 8 | // 9 | 10 | ///////////////////////////////////////////////////////////////////////////// 11 | // MergeComment dialog 12 | 13 | class MergeComment : public CDialog 14 | { 15 | // Construction 16 | public: 17 | enum Kind 18 | { 19 | ONE_LINE_COMMENT, 20 | MULTI_LINE_COMMENT, 21 | BOARD_TEXT 22 | }; 23 | 24 | enum Selection 25 | { 26 | CURRENT, 27 | NEW, 28 | COMBINED 29 | }; 30 | 31 | public: 32 | MergeComment(const CString& currentComment, const CString& newComment, Kind kind); 33 | 34 | CString getMergedComment(); 35 | Selection getSelection(); 36 | bool getApplySelectionToAll(); 37 | 38 | // Dialog Data 39 | //{{AFX_DATA(MergeComment) 40 | enum { IDD = IDD_MERGE_ONELINE_COMMENT }; 41 | CButton mSelectCurrent; 42 | CButton mSelectNew; 43 | CButton mSelectCombined; 44 | CEdit mNew; 45 | CEdit mCurrent; 46 | CEdit mCombinedComment; 47 | CButton mApplyToAll; 48 | //}}AFX_DATA 49 | 50 | 51 | // Overrides 52 | // ClassWizard generated virtual function overrides 53 | //{{AFX_VIRTUAL(MergeComment) 54 | protected: 55 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 56 | //}}AFX_VIRTUAL 57 | 58 | // Implementation 59 | protected: 60 | 61 | // Generated message map functions 62 | //{{AFX_MSG(MergeComment) 63 | virtual BOOL OnInitDialog(); 64 | afx_msg void OnCurrent(); 65 | afx_msg void OnNew(); 66 | afx_msg void OnCombined(); 67 | virtual void OnOK(); 68 | //}}AFX_MSG 69 | DECLARE_MESSAGE_MAP() 70 | 71 | private: 72 | Kind mKind; 73 | CString mCurrentComment; 74 | CString mNewComment; 75 | Selection mSelection; 76 | bool mApplySelectionToAll; 77 | 78 | private: 79 | void updateControls(); 80 | }; 81 | 82 | //{{AFX_INSERT_LOCATION}} 83 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 84 | 85 | #endif // !defined(AFX_MERGE_COMMENT_H__F6B9D182_F304_11D6_92A3_0000E89F396C__INCLUDED_) 86 | -------------------------------------------------------------------------------- /ModeInformationI.h: -------------------------------------------------------------------------------- 1 | // ModeInformationI.h: interface for the ModeInformationI class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_MODEINFORMATIONI_H__8D040222_6243_11D7_92A3_0000E89F396C__INCLUDED_) 6 | #define AFX_MODEINFORMATIONI_H__8D040222_6243_11D7_92A3_0000E89F396C__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | class ModeInformationI 13 | { 14 | public: 15 | virtual bool isReadOnly() = 0; 16 | }; 17 | 18 | #endif // !defined(AFX_MODEINFORMATIONI_H__8D040222_6243_11D7_92A3_0000E89F396C__INCLUDED_) 19 | -------------------------------------------------------------------------------- /MoveList.cpp: -------------------------------------------------------------------------------- 1 | // MoveList.cpp: implementation of the MoveList class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "RenLib.h" 7 | #include "MoveList.h" 8 | 9 | #ifdef _DEBUG 10 | #undef THIS_FILE 11 | static char THIS_FILE[]=__FILE__; 12 | #define new DEBUG_NEW 13 | #endif 14 | 15 | ////////////////////////////////////////////////////////////////////// 16 | // Construction/Destruction 17 | ////////////////////////////////////////////////////////////////////// 18 | 19 | MoveList::MoveList() 20 | { 21 | ClearAll(); 22 | } 23 | 24 | MoveList::~MoveList() 25 | { 26 | } 27 | 28 | void MoveList::ClearAll() 29 | { 30 | for (int i=0; i <= MAXINDEX; i++) 31 | { 32 | m_List[i] = 0; 33 | } 34 | 35 | m_nIndex = -1; 36 | } 37 | 38 | void MoveList::ClearEnd() 39 | { 40 | for (int i = m_nIndex + 1; i <= MAXINDEX; i++) 41 | { 42 | m_List[i] = 0; 43 | } 44 | } 45 | 46 | bool MoveList::IsEmpty() const 47 | { 48 | return m_nIndex == -1; 49 | } 50 | 51 | bool MoveList::IsFull() const 52 | { 53 | return m_nIndex == MAXINDEX; 54 | } 55 | 56 | void MoveList::SetRoot(MoveNode* pMove) 57 | { 58 | VERIFY(IsEmpty()); 59 | Add(pMove); 60 | } 61 | 62 | void MoveList::Add(MoveNode* pMove) 63 | { 64 | VERIFY(m_nIndex < MAXINDEX); 65 | m_List[++m_nIndex] = pMove; 66 | } 67 | 68 | void MoveList::Swap(int nIndex1, int nIndex2) 69 | { 70 | VERIFY(nIndex1 >= 1 && nIndex1 <= m_nIndex); 71 | VERIFY(nIndex2 >= 1 && nIndex2 <= m_nIndex); 72 | 73 | MoveNode* temp = m_List[nIndex1]; 74 | m_List[nIndex1] = m_List[nIndex2]; 75 | m_List[nIndex2] = temp; 76 | } 77 | 78 | MoveNode* MoveList::GetRoot() const 79 | { 80 | VERIFY(!IsEmpty()); 81 | return m_List[0]; 82 | } 83 | 84 | MoveNode* MoveList::Get(int nIndex) const 85 | { 86 | VERIFY(!IsEmpty()); 87 | VERIFY(nIndex >= 0 && nIndex <= MAXINDEX); 88 | return m_List[nIndex]; 89 | } 90 | 91 | MoveNode* MoveList::Current() const 92 | { 93 | VERIFY(!IsEmpty()); 94 | return m_List[m_nIndex]; 95 | } 96 | 97 | MoveNode* MoveList::Next() 98 | { 99 | if (m_nIndex < MAXINDEX) 100 | { 101 | return m_List[m_nIndex + 1]; 102 | } 103 | else 104 | { 105 | return 0; 106 | } 107 | } 108 | 109 | MoveNode* MoveList::Previous() 110 | { 111 | if (m_nIndex > 0) 112 | { 113 | return m_List[m_nIndex - 1]; 114 | } 115 | else 116 | { 117 | return 0; 118 | } 119 | } 120 | 121 | void MoveList::SetIndex(int nIndex) 122 | { 123 | VERIFY(nIndex >= 0 && nIndex <= m_nIndex); 124 | m_nIndex = nIndex; 125 | } 126 | 127 | void MoveList::SetRootIndex() 128 | { 129 | SetIndex(0); 130 | } 131 | 132 | void MoveList::Decrement() 133 | { 134 | VERIFY(m_nIndex > 0); 135 | m_nIndex--; 136 | } 137 | 138 | int MoveList::Index() const 139 | { 140 | return m_nIndex; 141 | } 142 | -------------------------------------------------------------------------------- /MoveList.h: -------------------------------------------------------------------------------- 1 | // MoveList.h: interface for the MoveList class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_MOVELIST_H__3C2C7489_F3BA_11D4_92A3_FE4B13876025__INCLUDED_) 6 | #define AFX_MOVELIST_H__3C2C7489_F3BA_11D4_92A3_FE4B13876025__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | class MoveNode; 13 | 14 | class MoveList 15 | { 16 | public: 17 | MoveList(); 18 | virtual ~MoveList(); 19 | 20 | bool IsEmpty() const; 21 | bool IsFull() const; 22 | 23 | void SetRoot(MoveNode* pMove); 24 | void Add(MoveNode* pMove); 25 | void Swap(int nIndex1, int nIndex2); 26 | 27 | MoveNode* Get(int nIndex) const; 28 | MoveNode* GetRoot() const; 29 | MoveNode* Current() const; 30 | 31 | MoveNode* Next(); 32 | MoveNode* Previous(); 33 | 34 | void SetIndex(int nIndex); 35 | void SetRootIndex(); 36 | void Decrement(); 37 | int Index() const; 38 | 39 | void ClearAll(); 40 | void ClearEnd(); 41 | 42 | private: 43 | enum { MAXINDEX = 225 }; 44 | 45 | MoveNode* m_List [MAXINDEX + 1]; // 1 based 46 | int m_nIndex; 47 | }; 48 | 49 | #endif // !defined(AFX_MOVELIST_H__3C2C7489_F3BA_11D4_92A3_FE4B13876025__INCLUDED_) 50 | -------------------------------------------------------------------------------- /MoveNode.cpp: -------------------------------------------------------------------------------- 1 | // MoveNode.cpp: implementation of the MoveNode class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "RenLib.h" 7 | #include "MoveNode.h" 8 | #include "Utils.h" 9 | 10 | #ifdef _DEBUG 11 | #undef THIS_FILE 12 | static char THIS_FILE[]=__FILE__; 13 | #define new DEBUG_NEW 14 | #endif 15 | 16 | //-------------------------------------------------------------------- 17 | // const 18 | //-------------------------------------------------------------------- 19 | 20 | namespace 21 | { 22 | // 23 | // Extension bytes 24 | // 25 | const BOARD_TEXT = 0x000100; 26 | 27 | // 28 | // Low byte 29 | // 30 | const DOWN = 0x000080; 31 | const RIGHT = 0x000040; 32 | const OLD_COMMENT = 0x000020; 33 | const MARK = 0x000010; 34 | const COMMENT = 0x000008; 35 | const START = 0x000004; 36 | const NO_MOVE = 0x000002; 37 | const EXTENSION = 0x000001; 38 | 39 | const MASK = 0xFFFF3F; 40 | 41 | const CPoint NullPoint(0, 0); 42 | 43 | bool isValid(CPoint Pos) 44 | { 45 | return 46 | Pos == NullPoint || (Pos.x >= 1 && Pos.x <= 15 && Pos.y >= 1 && Pos.y <= 15); 47 | } 48 | } 49 | 50 | ////////////////////////////////////////////////////////////////////// 51 | // Construction/Destruction 52 | ////////////////////////////////////////////////////////////////////// 53 | 54 | MoveNode::MoveNode() : 55 | mPos(NullPoint), 56 | mInfo(0), 57 | mMatch(0), 58 | mDown(0), 59 | mRight(0) 60 | { 61 | } 62 | 63 | MoveNode::MoveNode(MoveNode& node) : 64 | mPos(node.mPos), 65 | mInfo(node.mInfo), 66 | mMatch(0), 67 | mDown(0), 68 | mRight(0) 69 | { 70 | if (!isValid(mPos)) 71 | { 72 | // 73 | // ERROR checking code 74 | // 75 | CString strMessage; 76 | strMessage += Utils::GetString(IDS_MSG_POSITION, mPos); 77 | strMessage += "\n\n"; 78 | strMessage += Utils::GetString(IDS_MSG_REPORT); 79 | strMessage += "\n\n"; 80 | strMessage += Utils::GetString(IDS_MSG_NOTE); 81 | Utils::ShowMessage(strMessage, Utils::GetString(IDS_CAP_MAKE), MB_ICONERROR); 82 | 83 | setPos(CPoint(1,1)); 84 | setIsMark(true); 85 | } 86 | } 87 | 88 | MoveNode::MoveNode(CPoint Pos) : 89 | mPos(Pos), 90 | mInfo(0), 91 | mMatch(0), 92 | mDown(0), 93 | mRight(0) 94 | { 95 | if (!isValid(mPos)) 96 | { 97 | // 98 | // ERROR checking code 99 | // 100 | CString strMessage; 101 | strMessage += Utils::GetString(IDS_MSG_POSITION, mPos); 102 | strMessage += "\n\n"; 103 | strMessage += Utils::GetString(IDS_MSG_REPORT); 104 | strMessage += "\n\n"; 105 | strMessage += Utils::GetString(IDS_MSG_NOTE); 106 | Utils::ShowMessage(strMessage, Utils::GetString(IDS_CAP_MAKE), MB_ICONERROR); 107 | 108 | setPos(CPoint(1,1)); 109 | setIsMark(true); 110 | } 111 | } 112 | 113 | MoveNode::~MoveNode() 114 | { 115 | } 116 | 117 | void MoveNode::checkExtension() 118 | { 119 | setIsExtension((mInfo & 0xFFFF00) != 0); 120 | } 121 | 122 | bool MoveNode::isValue(UINT bitValue) const 123 | { 124 | return Utils::bit_is_one(bitValue, mInfo); 125 | } 126 | 127 | void MoveNode::setIsValue(bool value, UINT bitValue) 128 | { 129 | if (value) 130 | { 131 | Utils::set_bit(bitValue, mInfo); 132 | } 133 | else 134 | { 135 | Utils::clear_bit(bitValue, mInfo); 136 | } 137 | } 138 | 139 | void MoveNode::setPos(CPoint pos) 140 | { 141 | mPos = pos; 142 | setIsMove(true); 143 | } 144 | 145 | CPoint MoveNode::getPos() const 146 | { 147 | return mPos; 148 | } 149 | 150 | void MoveNode::setPosInfo(BYTE pos, BYTE info) 151 | { 152 | mPos = Utils::PosToPoint(pos); 153 | mInfo = (mInfo & 0xFFFF00) | info; 154 | } 155 | 156 | void MoveNode::getPosInfo(BYTE& pos, BYTE& info) const 157 | { 158 | pos = Utils::PointToPos(mPos); 159 | info = BYTE(mInfo & 0xFF); 160 | } 161 | 162 | void MoveNode::setExtendedInfo(BYTE info2, BYTE info1) 163 | { 164 | mInfo &= 0xFF; 165 | mInfo |= ((info2 << 8) | info1) << 8; 166 | } 167 | 168 | void MoveNode::getExtendedInfo(BYTE& info2, BYTE& info1) const 169 | { 170 | UINT info = mInfo >> 8; 171 | info1 = BYTE(info & 0xFF); 172 | 173 | info >>= 8; 174 | info2 = BYTE(info & 0xFF); 175 | } 176 | 177 | void MoveNode::clearInformation() 178 | { 179 | mInfo = 0; 180 | } 181 | 182 | bool MoveNode::isInformation() const 183 | { 184 | return (mInfo & MASK) != 0; 185 | } 186 | 187 | bool MoveNode::isDown() const 188 | { 189 | return isValue(DOWN); 190 | } 191 | 192 | void MoveNode::setIsDown(bool value) 193 | { 194 | setIsValue(value, DOWN); 195 | } 196 | 197 | bool MoveNode::isRight() const 198 | { 199 | return isValue(RIGHT); 200 | } 201 | 202 | void MoveNode::setIsRight(bool value) 203 | { 204 | setIsValue(value, RIGHT); 205 | } 206 | 207 | bool MoveNode::isOldComment() const 208 | { 209 | return isValue(OLD_COMMENT); 210 | } 211 | 212 | bool MoveNode::isNewComment() const 213 | { 214 | return isValue(COMMENT); 215 | } 216 | 217 | void MoveNode::setIsNewComment(bool value) 218 | { 219 | setIsValue(value, COMMENT); 220 | setIsValue(false, OLD_COMMENT); 221 | } 222 | 223 | bool MoveNode::isMark() const 224 | { 225 | return isValue(MARK); 226 | } 227 | 228 | void MoveNode::setIsMark(bool value) 229 | { 230 | setIsValue(value, MARK); 231 | } 232 | 233 | bool MoveNode::isStart() const 234 | { 235 | return isValue(START); 236 | } 237 | 238 | void MoveNode::setIsStart(bool value) 239 | { 240 | setIsValue(value, START); 241 | } 242 | 243 | bool MoveNode::isMove() const 244 | { 245 | return !isValue(NO_MOVE); 246 | } 247 | 248 | bool MoveNode::isPassMove() const 249 | { 250 | bool result = false; 251 | 252 | if (isMove()) 253 | { 254 | result = (mPos.x == 0 && mPos.y == 0); 255 | } 256 | 257 | return result; 258 | } 259 | 260 | void MoveNode::setIsMove(bool value) 261 | { 262 | setIsValue(!value, NO_MOVE); 263 | } 264 | 265 | bool MoveNode::isExtension() const 266 | { 267 | return isValue(EXTENSION); 268 | } 269 | 270 | void MoveNode::setIsExtension(bool value) 271 | { 272 | setIsValue(value, EXTENSION); 273 | } 274 | 275 | void MoveNode::setMatch(BYTE match) 276 | { 277 | mMatch = match; 278 | } 279 | 280 | BYTE MoveNode::getMatch() const 281 | { 282 | return mMatch; 283 | } 284 | 285 | void MoveNode::setDown(MoveNode* node) 286 | { 287 | mDown = node; 288 | } 289 | 290 | MoveNode* MoveNode::getDown() const 291 | { 292 | return mDown; 293 | } 294 | 295 | void MoveNode::setRight(MoveNode* node) 296 | { 297 | mRight = node; 298 | } 299 | 300 | MoveNode* MoveNode::getRight() const 301 | { 302 | return mRight; 303 | } 304 | 305 | bool MoveNode::isOneLineComment() const 306 | { 307 | return !mOneLineComment.IsEmpty(); 308 | } 309 | 310 | void MoveNode::setOneLineComment(const CString& comment) 311 | { 312 | mOneLineComment = comment; 313 | setIsNewComment(isOneLineComment() || isMultiLineComment()); 314 | } 315 | 316 | CString MoveNode::getOneLineComment() const 317 | { 318 | return mOneLineComment; 319 | } 320 | 321 | bool MoveNode::isMultiLineComment() const 322 | { 323 | return !mMultiLineComment.IsEmpty(); 324 | 325 | } 326 | 327 | void MoveNode::setMultiLineComment(const CString& comment) 328 | { 329 | mMultiLineComment = comment; 330 | setIsNewComment(isOneLineComment() || isMultiLineComment()); 331 | } 332 | 333 | CString MoveNode::getMultiLineComment() const 334 | { 335 | return mMultiLineComment; 336 | } 337 | 338 | void MoveNode::setIsBoardText(bool value) 339 | { 340 | setIsValue(value, BOARD_TEXT); 341 | checkExtension(); 342 | } 343 | 344 | bool MoveNode::isBoardText() const 345 | { 346 | return isValue(BOARD_TEXT); 347 | } 348 | 349 | void MoveNode::setBoardText(const CString& text) 350 | { 351 | mBoardText = text; 352 | setIsBoardText(!mBoardText.IsEmpty()); 353 | } 354 | 355 | CString MoveNode::getBoardText() const 356 | { 357 | return mBoardText; 358 | } 359 | -------------------------------------------------------------------------------- /MoveNode.h: -------------------------------------------------------------------------------- 1 | // MoveNode.h: interface for the MoveNode class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_MOVE_NODE_H__990E8D64_0BDE_11D4_92A3_CEA74A1A6D25__INCLUDED_) 6 | #define AFX_MOVE_NODE_H__990E8D64_0BDE_11D4_92A3_CEA74A1A6D25__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | class MoveNode 13 | { 14 | public: 15 | MoveNode(); 16 | explicit MoveNode(MoveNode& node); 17 | explicit MoveNode(CPoint Pos); 18 | 19 | virtual ~MoveNode(); 20 | 21 | void setPosInfo(BYTE pos, BYTE info); 22 | void getPosInfo(BYTE& pos, BYTE& info) const; 23 | 24 | void setExtendedInfo(BYTE info2, BYTE info1); 25 | void getExtendedInfo(BYTE& info2, BYTE& info1) const; 26 | 27 | // 28 | // Position 29 | // 30 | void setPos(CPoint pos); 31 | CPoint getPos() const; 32 | 33 | // 34 | // Information 35 | // 36 | void clearInformation(); 37 | bool isInformation() const; 38 | 39 | bool isDown() const; 40 | void setIsDown(bool value); 41 | 42 | bool isRight() const; 43 | void setIsRight(bool value); 44 | 45 | bool isOldComment() const; 46 | bool isNewComment() const; 47 | 48 | bool isMark() const; 49 | void setIsMark(bool value); 50 | 51 | bool isStart() const; 52 | void setIsStart(bool value); 53 | 54 | bool isMove() const; 55 | bool isPassMove() const; 56 | void setIsMove(bool value); 57 | 58 | bool isExtension() const; 59 | void setIsExtension(bool value); 60 | 61 | void setMatch(BYTE match); 62 | BYTE getMatch() const; 63 | 64 | // 65 | // Instance data 66 | // 67 | void setDown(MoveNode* node); 68 | MoveNode* getDown() const; 69 | 70 | void setRight(MoveNode* node); 71 | MoveNode* getRight() const; 72 | 73 | bool isOneLineComment() const; 74 | void setOneLineComment(const CString& comment); 75 | CString getOneLineComment() const; 76 | 77 | bool isMultiLineComment() const; 78 | void setMultiLineComment(const CString& comment); 79 | CString getMultiLineComment() const; 80 | 81 | bool isBoardText() const; 82 | void setBoardText(const CString& text); 83 | CString getBoardText() const; 84 | 85 | private: 86 | void setIsNewComment(bool value); 87 | void setIsBoardText(bool value); 88 | void checkExtension(); 89 | bool isValue(UINT bitValue) const; 90 | void setIsValue(bool value, UINT bitValue); 91 | 92 | private: 93 | CPoint mPos; // position, (x,y) 94 | UINT mInfo; // information 95 | 96 | BYTE mMatch; // position search 97 | 98 | CString mOneLineComment; // one line comment 99 | CString mMultiLineComment; // multi line comment 100 | CString mBoardText; // board text 101 | 102 | MoveNode* mDown; // next level 103 | MoveNode* mRight; // same level 104 | }; 105 | 106 | #endif // !defined(AFX_MOVE_NODE_H__990E8D64_0BDE_11D4_92A3_CEA74A1A6D25__INCLUDED_) -------------------------------------------------------------------------------- /Pdb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/Pdb.h -------------------------------------------------------------------------------- /Pos.cpp: -------------------------------------------------------------------------------- 1 | // Pos.cpp: implementation of the Pdb class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include 6 | #include "stdafx.h" 7 | #include "RenLib.h" 8 | #include "Pos.h" 9 | #include "MoveList.h" 10 | #include "MoveNode.h" 11 | #include "Utils.h" 12 | 13 | #ifdef _DEBUG 14 | #undef THIS_FILE 15 | static char THIS_FILE[]=__FILE__; 16 | #define new DEBUG_NEW 17 | #endif 18 | 19 | //-------------------------------------------------------------------- 20 | // const 21 | //-------------------------------------------------------------------- 22 | 23 | ////////////////////////////////////////////////////////////////////// 24 | // Construction/Destruction 25 | ////////////////////////////////////////////////////////////////////// 26 | 27 | Pos::Pos() 28 | { 29 | } 30 | 31 | //------------------------------------------------------------------------ 32 | 33 | Pos::~Pos() 34 | { 35 | } 36 | 37 | //------------------------------------------------------------------------ 38 | 39 | Game& Pos::getGame() 40 | { 41 | return m_Game; 42 | } 43 | 44 | //------------------------------------------------------------------------ 45 | 46 | CString Pos::getFilePath() 47 | { 48 | return m_strFilePath; 49 | } 50 | 51 | //------------------------------------------------------------------------ 52 | 53 | bool Pos::Open(const CString& strFile) 54 | { 55 | CFileException e; 56 | 57 | if (m_file.Open( strFile, CFile::modeRead, &e) == 0) 58 | { 59 | return false; 60 | } 61 | 62 | m_strFilePath = m_file.GetFilePath(); 63 | 64 | return true; 65 | } 66 | 67 | //------------------------------------------------------------------------ 68 | 69 | bool Pos::Read() 70 | { 71 | m_Game.clear(); 72 | 73 | UINT nBytesRead = m_file.Read(m_buffer, BUFFERSIZE); 74 | 75 | if (nBytesRead == 0 || m_buffer[0] == 0 || m_buffer[0] > 225) 76 | { 77 | return false; 78 | } 79 | 80 | for (int i = 1; i <= m_buffer[0]; i++) 81 | { 82 | int index = (m_buffer[i] / 15) * 16 + m_buffer[i] % 15 + 1; 83 | m_Game.addPos(BYTE(index)); 84 | } 85 | 86 | addZjrenjuComments(); 87 | 88 | return true; 89 | } 90 | 91 | //------------------------------------------------------------------------ 92 | 93 | void Pos::addZjrenjuComments() 94 | { 95 | CString fileName(m_file.GetFileTitle()); 96 | 97 | int index[6]; 98 | int last = 0; 99 | 100 | int NoOfDelimiters = 0; 101 | 102 | for (int i=0; i<5; i++) 103 | { 104 | index[i] = fileName.Find('#', last); 105 | last = index[i] + 1; 106 | 107 | if (index[i] != -1) 108 | { 109 | NoOfDelimiters++; 110 | } 111 | else 112 | { 113 | break; 114 | } 115 | } 116 | 117 | int first = 0; 118 | 119 | if (NoOfDelimiters == 5) 120 | { 121 | index[5] = fileName.ReverseFind('.'); 122 | 123 | CString info[6]; 124 | 125 | for (i=0; i<6; i++) 126 | { 127 | last = index[i]; 128 | info[i] = fileName.Mid(first, last-first); 129 | first = last + 1; 130 | } 131 | 132 | CString strTableNumber("Table: " + info[0]); 133 | 134 | CString strRule("Rule: "); 135 | 136 | if (info[1] == "0") 137 | { 138 | strRule += "Sakata"; 139 | } 140 | else if (info[1] == "1") 141 | { 142 | strRule += "RIF"; 143 | } 144 | else if (info[1] == "2") 145 | { 146 | strRule += "Two swap"; 147 | } 148 | 149 | CString strBlack(info[2]); 150 | 151 | CString strWhite(info[3]); 152 | 153 | CString strSwap("Swap: "); 154 | 155 | if (info[1] == "0" || info[1] == "1") 156 | { 157 | if (info[4] == "0") 158 | { 159 | strSwap += "No swap"; 160 | } 161 | else if (info[4] == "1") 162 | { 163 | strSwap += "Swap"; 164 | } 165 | } 166 | else if (info[1] == "2") 167 | { 168 | if (info[4] == "0") 169 | { 170 | strSwap += "No swap | No swap"; 171 | } 172 | else if (info[4] == "1") 173 | { 174 | strSwap += "Swap | No swap"; 175 | } 176 | else if (info[4] == "2") 177 | { 178 | strSwap += "No swap | Swap"; 179 | } 180 | else if (info[4] == "3") 181 | { 182 | strSwap += "Swap | Swap"; 183 | } 184 | } 185 | 186 | CString strResult(strBlack + " - " + strWhite + " "); 187 | 188 | CString strState("State: "); 189 | 190 | if (info[5] == "0") 191 | { 192 | strState += "Active"; 193 | } 194 | else if (info[5] == "1") 195 | { 196 | strState += "Forbidden point"; 197 | strResult += "0-1"; 198 | } 199 | else if (info[5] == "2") 200 | { 201 | strState += "Draw"; 202 | strResult += "0.5-0.5"; 203 | } 204 | else if (info[5] == "3") 205 | { 206 | strState += "Black won"; 207 | strResult += "1-0"; 208 | } 209 | else if (info[5] == "4") 210 | { 211 | strState += "White won"; 212 | strResult += "0-1"; 213 | } 214 | else if (info[5] == "5") 215 | { 216 | strState += "White resign"; 217 | strResult += "1-0"; 218 | } 219 | else if (info[5] == "6") 220 | { 221 | strState += "Black resign"; 222 | strResult += "0-1"; 223 | } 224 | else if (info[5] == "7") 225 | { 226 | strState += "White untime"; 227 | } 228 | else if (info[5] == "8") 229 | { 230 | strState += "Black untime"; 231 | } 232 | 233 | m_Game.addOneLineComment(m_Game.numberOfMoves(), strResult); 234 | 235 | m_Game.addMultiLineComment(m_Game.numberOfMoves(), strTableNumber); 236 | m_Game.addMultiLineComment(m_Game.numberOfMoves(), strRule); 237 | m_Game.addMultiLineComment(m_Game.numberOfMoves(), strSwap); 238 | m_Game.addMultiLineComment(m_Game.numberOfMoves(), strState); 239 | } 240 | } 241 | 242 | //------------------------------------------------------------------------ 243 | 244 | bool Pos::Save(const CString& fileName, const MoveList& aMoveList) 245 | { 246 | if (!m_file.Open(fileName, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary)) 247 | { 248 | CString strMessage(Utils::GetString(IDS_MSG_OPEN_FILE, fileName)); 249 | Utils::ShowMessage(strMessage, Utils::GetString(IDS_CAP_CREATE_POS), MB_ICONERROR); 250 | return false; 251 | } 252 | 253 | m_buffer[0] = 0; 254 | 255 | for(int i= 1; i <= aMoveList.Index(); i++) 256 | { 257 | CPoint Coord(aMoveList.Get(i)->getPos()); 258 | m_buffer[++m_buffer[0]] = BYTE((Coord.y - 1) * 15 + Coord.x - 1); 259 | } 260 | 261 | m_file.Write(m_buffer, m_buffer[0] + 1); 262 | 263 | m_file.Close(); 264 | 265 | return(true); 266 | } 267 | 268 | //------------------------------------------------------------------------ 269 | -------------------------------------------------------------------------------- /Pos.h: -------------------------------------------------------------------------------- 1 | // Pos.h: interface for the Pos class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "Game.h" 6 | 7 | #if _MSC_VER > 1000 8 | #pragma once 9 | #endif // _MSC_VER > 1000 10 | 11 | class MoveList; 12 | 13 | class Pos 14 | { 15 | public: 16 | Pos(); 17 | virtual ~Pos(); 18 | 19 | bool Open(const CString& strFile); 20 | bool Read(); 21 | bool Save(const CString& fileName, const MoveList& aMoveList); 22 | 23 | Game& getGame(); 24 | CString getFilePath(); 25 | 26 | private: 27 | void addZjrenjuComments(); 28 | 29 | private: 30 | enum { BUFFERSIZE = 226 }; 31 | 32 | CFile m_file; 33 | BYTE m_buffer[BUFFERSIZE]; 34 | 35 | public: 36 | Game m_Game; 37 | CString m_strFilePath; 38 | }; 39 | -------------------------------------------------------------------------------- /Position.cpp: -------------------------------------------------------------------------------- 1 | // Position.cpp: implementation of the Position class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "RenLib.h" 7 | #include "Position.h" 8 | #include "Utils.h" 9 | 10 | #ifdef _DEBUG 11 | #undef THIS_FILE 12 | static char THIS_FILE[]=__FILE__; 13 | #define new DEBUG_NEW 14 | #endif 15 | 16 | namespace 17 | { 18 | const CPoint NullPoint(0, 0); 19 | } 20 | 21 | ////////////////////////////////////////////////////////////////////// 22 | // Construction/Destruction 23 | ////////////////////////////////////////////////////////////////////// 24 | 25 | Position::Position() 26 | { 27 | } 28 | 29 | Position::~Position() 30 | { 31 | } 32 | 33 | bool Position::IsEqual(Pos& positionA, Pos& positionB) 34 | { 35 | for (int x=0; x < SIZE; x++) 36 | { 37 | for (int y=0; y < SIZE; y++) 38 | { 39 | if (positionA[x][y] != positionB[x][y]) 40 | { 41 | return false; 42 | } 43 | } 44 | } 45 | 46 | return true; 47 | } 48 | 49 | void Position::Clear(Pos& thePosition) 50 | { 51 | for (int x=0; x < SIZE; x++) 52 | { 53 | for (int y=0; y < SIZE; y++) 54 | { 55 | thePosition[x][y] = 0; 56 | } 57 | } 58 | } 59 | 60 | void Position::Put(const MoveList& theMoves, Pos& thePosition, bool findSimilar) 61 | { 62 | const int cBlack = 1; 63 | const int cWhite = 2; 64 | 65 | MoveList myMoves = theMoves; 66 | 67 | if (findSimilar) 68 | { 69 | CPoint smallest(15, 15); 70 | 71 | for (int i=0; i < myMoves.nMoves; i++) 72 | { 73 | if (smallest.x > myMoves.Moves[i].x) 74 | { 75 | smallest.x = myMoves.Moves[i].x; 76 | } 77 | 78 | if (smallest.y > myMoves.Moves[i].y) 79 | { 80 | smallest.y = myMoves.Moves[i].y; 81 | } 82 | } 83 | 84 | smallest -= CPoint(1, 1); 85 | VERIFY(Utils::isValidPoint(smallest)); 86 | 87 | for (i=0; i < myMoves.nMoves; i++) 88 | { 89 | myMoves.Moves[i] -= smallest; 90 | } 91 | } 92 | 93 | for (int i=0; i < myMoves.nMoves; i++) 94 | { 95 | const CPoint myPoint(myMoves.Moves[i]); 96 | 97 | VERIFY(myPoint == NullPoint || Utils::isValidPoint(myPoint)); 98 | 99 | thePosition[myPoint.x][myPoint.y] = ((i & 1) == 0 ? cBlack : cWhite); 100 | } 101 | } 102 | 103 | void Position::Rotate(MoveList& theMoves) 104 | { 105 | for (int i=0; i < theMoves.nMoves; i++) 106 | { 107 | const CPoint myPoint(theMoves.Moves[i]); 108 | 109 | if (myPoint != NullPoint) 110 | { 111 | // Rotate +90 degrees 112 | CPoint coord(CPoint(8 - myPoint.y, myPoint.x - 8)); 113 | 114 | coord += CPoint(8,8); 115 | VERIFY(Utils::isValidPoint(coord)); 116 | theMoves.Moves[i] = coord; 117 | } 118 | } 119 | } 120 | 121 | void Position::Reflect(MoveList& theMoves) 122 | { 123 | for (int i=0; i < theMoves.nMoves; i++) 124 | { 125 | if (theMoves.Moves[i] != NullPoint) 126 | { 127 | // Reflect 8th row 128 | const CPoint myPoint(theMoves.Moves[i].x, 16 - theMoves.Moves[i].y); 129 | 130 | VERIFY(Utils::isValidPoint(myPoint)); 131 | 132 | theMoves.Moves[i] = myPoint; 133 | } 134 | } 135 | } 136 | 137 | void Position::Init(const MoveList& theMoves, bool findSimilar) 138 | { 139 | // Clear position tables 140 | for (int i=0; i < NOOFTABLES; i++) 141 | { 142 | Clear(m_Position[i]); 143 | } 144 | 145 | // Setup the tables 146 | MoveList myMoves = theMoves; 147 | 148 | // 0 degrees 149 | Put(myMoves, m_Position[0], findSimilar); 150 | 151 | // +90 degrees 152 | Rotate(myMoves); 153 | Put(myMoves, m_Position[1], findSimilar); 154 | 155 | // +180 degrees 156 | Rotate(myMoves); 157 | Put(myMoves, m_Position[2], findSimilar); 158 | 159 | // +270 degrees 160 | Rotate(myMoves); 161 | Put(myMoves, m_Position[3], findSimilar); 162 | 163 | myMoves = theMoves; 164 | Reflect(myMoves); 165 | 166 | // 0 degrees, Reflect 167 | Put(myMoves, m_Position[4], findSimilar); 168 | 169 | // +90 degrees, Reflect 170 | Rotate(myMoves); 171 | Put(myMoves, m_Position[5], findSimilar); 172 | 173 | // +180 degrees, Reflect 174 | Rotate(myMoves); 175 | Put(myMoves, m_Position[6], findSimilar); 176 | 177 | // +270 degrees, Reflect 178 | Rotate(myMoves); 179 | Put(myMoves, m_Position[7], findSimilar); 180 | } 181 | 182 | BYTE Position::Match(const MoveList& theMoves, bool findSimilar) 183 | { 184 | Pos myPosition; 185 | Clear(myPosition); 186 | 187 | Put(theMoves, myPosition, findSimilar); 188 | 189 | for (int i=0; i < NOOFTABLES; i++) 190 | { 191 | if (IsEqual(myPosition, m_Position[i])) 192 | { 193 | return i+1; 194 | } 195 | } 196 | 197 | return 0; 198 | } 199 | 200 | void Position::NormalizeCoord(CPoint& Coord, BYTE nMatch) 201 | { 202 | if (nMatch >= 1 && nMatch <= 8 && Coord != NullPoint) 203 | { 204 | switch (nMatch) 205 | { 206 | case 1: 207 | case 5: 208 | { 209 | Coord = CPoint(Coord.x - 8, Coord.y - 8); 210 | break; 211 | } 212 | 213 | case 2: 214 | case 6: 215 | { 216 | Coord = CPoint(Coord.y - 8, 8 - Coord.x); 217 | break; 218 | } 219 | 220 | case 3: 221 | case 7: 222 | { 223 | Coord = CPoint(8 - Coord.x, 8 - Coord.y); 224 | break; 225 | } 226 | 227 | case 4: 228 | case 8: 229 | { 230 | Coord = CPoint(8 - Coord.y, Coord.x - 8); 231 | break; 232 | } 233 | } 234 | 235 | Coord += CPoint(8,8); 236 | 237 | if (nMatch > 4) 238 | { 239 | // Reflect 8th row 240 | Coord.y = 16 - Coord.y; 241 | } 242 | 243 | VERIFY(Utils::isValidPoint(Coord)); 244 | } 245 | } 246 | 247 | void Position::TransposeCoord(CPoint& Coord, BYTE nMatch) 248 | { 249 | if (nMatch >= 1 && nMatch <= 8 && Coord != NullPoint) 250 | { 251 | if (nMatch > 4) 252 | { 253 | // Reflect 8th row 254 | Coord.y = 16 - Coord.y; 255 | } 256 | 257 | switch (nMatch) 258 | { 259 | case 1: 260 | case 5: 261 | { 262 | Coord = CPoint(Coord.x - 8, Coord.y - 8); 263 | break; 264 | } 265 | 266 | case 2: 267 | case 6: 268 | { 269 | Coord = CPoint(8 - Coord.y, Coord.x - 8); 270 | break; 271 | } 272 | 273 | case 3: 274 | case 7: 275 | { 276 | Coord = CPoint(8 - Coord.x, 8 - Coord.y); 277 | break; 278 | } 279 | 280 | case 4: 281 | case 8: 282 | { 283 | Coord = CPoint(Coord.y - 8, 8 - Coord.x); 284 | break; 285 | } 286 | } 287 | 288 | Coord += CPoint(8,8); 289 | 290 | VERIFY(Utils::isValidPoint(Coord)); 291 | } 292 | } -------------------------------------------------------------------------------- /Position.h: -------------------------------------------------------------------------------- 1 | // Position.h: interface for the Position class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_POSITION_H__B52D9462_EF12_11D4_92A3_E1F468F15D25__INCLUDED_) 6 | #define AFX_POSITION_H__B52D9462_EF12_11D4_92A3_E1F468F15D25__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | class Position 13 | { 14 | public: 15 | class MoveList 16 | { 17 | public: 18 | int nMoves; 19 | CPoint Moves[15*15]; 20 | }; 21 | 22 | Position(); 23 | virtual ~Position(); 24 | 25 | void Init(const MoveList& theMoves, bool findSimilar); 26 | BYTE Match(const MoveList& theMoves, bool findSimilar); 27 | 28 | static void NormalizeCoord(CPoint& Coord, BYTE nMatch); 29 | static void TransposeCoord(CPoint& Coord, BYTE nMatch); 30 | 31 | private: 32 | enum 33 | { 34 | NOOFTABLES = 8, 35 | SIZE = 16 36 | }; 37 | 38 | typedef BYTE Pos[SIZE][SIZE]; // 1 based 39 | 40 | void Rotate(MoveList& theMoves); 41 | void Reflect(MoveList& theMoves); 42 | 43 | bool IsEqual(Pos& positionA, Pos& positionB); 44 | void Clear(Pos& thePosition); 45 | void Put(const MoveList& theMoves, Pos& thePosition, bool findSimilar); 46 | 47 | Pos m_Position[NOOFTABLES]; 48 | }; 49 | 50 | #endif // !defined(AFX_POSITION_H__B52D9462_EF12_11D4_92A3_E1F468F15D25__INCLUDED_) 51 | -------------------------------------------------------------------------------- /ProgressWnd.h: -------------------------------------------------------------------------------- 1 | // ProgressWnd.h : header file 2 | // 3 | // Written by Chris Maunder (chrismaunder@codeguru.com) 4 | // Copyright 1998. 5 | // 6 | // CProgressWnd is a drop-in popup progress window for use in 7 | // programs that a time consuming. Check out the accompanying HTML 8 | // doc file for details. 9 | // 10 | // This code may be used in compiled form in any way you desire. This 11 | // file may be redistributed by any means PROVIDING it is not sold for 12 | // profit without the authors written consent, and providing that this 13 | // notice and the authors name is included. If the source code in 14 | // this file is used in any commercial application then an email to 15 | // me would be nice. 16 | // 17 | // This file is provided "as is" with no expressed or implied warranty. 18 | // The author accepts no liability if it causes any damage to your 19 | // computer, causes your pet cat to fall ill, increases baldness or 20 | // makes you car start emitting strange noises when you start it up. 21 | // 22 | // Expect bugs. 23 | // 24 | // Please use and enjoy. Please let me know of any bugs/mods/improvements 25 | // that you have found/implemented and I will fix/incorporate them into this 26 | // file. 27 | 28 | 29 | #ifndef _INCLUDE_PROGRESSWND_H 30 | #define _INCLUDE_PROGRESSWND_H 31 | 32 | ///////////////////////////////////////////////////////////////////////////// 33 | // CProgressWnd window 34 | 35 | class CProgressWnd : public CWnd 36 | { 37 | // Construction/Destruction 38 | public: 39 | CProgressWnd(); 40 | CProgressWnd(CWnd* pParent, LPCTSTR pszTitle, BOOL bSmooth = FALSE); 41 | virtual ~CProgressWnd(); 42 | 43 | BOOL Create(CWnd* pParent, LPCTSTR pszTitle, BOOL bSmooth = FALSE); 44 | BOOL GoModal(LPCTSTR pszTitle =_T("Progress"), BOOL bSmooth = FALSE); 45 | 46 | protected: 47 | void CommonConstruct(); 48 | 49 | // Operations 50 | public: 51 | void SetRange(int nLower, int nUpper, int nStep = 1); 52 | // Set range and step size 53 | int OffsetPos(int nPos); // Same as CProgressCtrl 54 | int StepIt(); // " 55 | int SetStep(int nStep); // " 56 | int SetPos(int nPos); // " 57 | 58 | void SetText(LPCTSTR fmt, ...); // Set text in text area 59 | 60 | void Clear(); // Clear text, reset bar 61 | void Hide(); // Hide window 62 | void Show(); // Show window 63 | 64 | BOOL Cancelled() { return m_bCancelled; } // Was "Cancel" hit? 65 | 66 | void SetWindowSize(int nNumTextLines, int nWindowWidth = 390); 67 | 68 | void PeekAndPump(BOOL bCancelOnESCkey = TRUE); // Message pumping for modal operation 69 | 70 | // Implementation 71 | protected: 72 | void GetPreviousSettings(); 73 | void SaveCurrentSettings(); 74 | 75 | protected: 76 | BOOL m_bCancelled; 77 | BOOL m_bModal; 78 | BOOL m_bPersistantPosition; 79 | int m_nPrevPos, m_nPrevPercent; 80 | int m_nStep; 81 | int m_nMaxValue, m_nMinValue; 82 | int m_nNumTextLines; 83 | 84 | CStatic m_Text; 85 | CProgressCtrl m_wndProgress; 86 | CButton m_CancelButton; 87 | CString m_strTitle, 88 | m_strCancelLabel; 89 | CFont m_font; 90 | 91 | 92 | // Overrides 93 | // ClassWizard generated virtual function overrides 94 | //{{AFX_VIRTUAL(CProgressWnd) 95 | public: 96 | virtual BOOL DestroyWindow(); 97 | //}}AFX_VIRTUAL 98 | 99 | // Generated message map functions 100 | protected: 101 | //{{AFX_MSG(CProgressWnd) 102 | afx_msg BOOL OnEraseBkgnd(CDC* pDC); 103 | //}}AFX_MSG 104 | afx_msg void OnCancel(); 105 | DECLARE_MESSAGE_MAP() 106 | }; 107 | 108 | 109 | #endif 110 | ///////////////////////////////////////////////////////////////////////////// 111 | 112 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | The most popular Renju software in the world. The function of Renlib is to store analyses 2 | and games in the special "lib" format. It also has the possibility to write comments on analyses. 3 | It has a good VCF (victory by continuous fours) search function. Almost every serious renju player 4 | is using renlib as part of their everyday renju study. Besides Renlib software, you can get some 5 | samples of lib files with opening theories and analyses. Lots of players exchange lib files and 6 | publish the games and analyses collections in lib format in their homepages. In addition to that, 7 | Renlib can help you to create the Java-based renju diagrams for your website, together with the 8 | space for comments. Windows XP users should know that their Internet Explorer does not have Java 9 | support and in that case if you want to create web pages with renju diagrams then you could just 10 | visit www.java.com and install Java support first. Renlib is programmed by Frank Arkbo, Sweden. 11 | 12 | Location: http://www.renju.se/renlib/ 13 | 14 | The project is made in Microsoft Visual Studio C++. 15 | 16 | Tags: Five in a Row, Tic Tac Toe, TicTacToe, 5 in a Row, Go-Moku, Connect, Connect5, Connect6, Caro, Noughts and Crosses, Gomoku, Renju, Pente, Piskvork, Amoba, Kółko i Krzyżyk, Gomocup, AI, Engine, Artificial Intelligence, Brain, Pbrain, Gra, Game, Source Code Files, Program, Programming, Github, Board, Coding. 17 | 18 | ![Tags: Five in a Row, Tic Tac Toe, TicTacToe, 5 in a Row, Go-Moku, Connect, Connect5, Connect6, Caro, Noughts and Crosses, Gomoku, Renju, Pente, Piskvork, Amoba, Kółko i Krzyżyk, Gomocup, AI, Engine, Artificial Intelligence, Brain, Pbrain, Gra, Game, Source Code Files, Program, Programming, Github, Board, Coding.](RenLib.gif "Tags: Five in a Row, Tic Tac Toe, TicTacToe, 5 in a Row, Go-Moku, Connect, Connect5, Connect6, Caro, Noughts and Crosses, Gomoku, Renju, Pente, Piskvork, Amoba, Kółko i Krzyżyk, Gomocup, AI, Engine, Artificial Intelligence, Brain, Pbrain, Gra, Game, Source Code Files, Program, Programming, Github, Board, Coding.") 19 | -------------------------------------------------------------------------------- /Rdf.cpp: -------------------------------------------------------------------------------- 1 | // Rdf.cpp: implementation of the Rdf class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "renlib.h" 7 | #include "Rdf.h" 8 | #include "Utils.h" 9 | 10 | #ifdef _DEBUG 11 | #undef THIS_FILE 12 | static char THIS_FILE[]=__FILE__; 13 | #define new DEBUG_NEW 14 | #endif 15 | 16 | namespace 17 | { 18 | CString cFile("File: "); 19 | } 20 | 21 | ////////////////////////////////////////////////////////////////////// 22 | // Construction/Destruction 23 | ////////////////////////////////////////////////////////////////////// 24 | 25 | Rdf::Rdf() 26 | { 27 | } 28 | 29 | //------------------------------------------------------------------------ 30 | 31 | Game& Rdf::getGame() 32 | { 33 | return mGame; 34 | } 35 | 36 | //------------------------------------------------------------------------ 37 | 38 | CString Rdf::getFilePath() 39 | { 40 | return mstrFilePath; 41 | } 42 | 43 | //------------------------------------------------------------------------ 44 | 45 | bool Rdf::OpenFile(const CString& strFile) 46 | { 47 | CFileException e; 48 | 49 | if (!mGameFile.Open(strFile, CFile::modeRead, &e)) 50 | { 51 | return false; 52 | } 53 | 54 | mstrFilePath = mGameFile.GetFilePath(); 55 | 56 | Parse(); 57 | 58 | mGameFile.Close(); 59 | 60 | return true; 61 | } 62 | 63 | //------------------------------------------------------------------------ 64 | 65 | void Rdf::Parse() 66 | { 67 | mGame.clear(); 68 | 69 | CString strLine; 70 | mGameFile.ReadString(strLine); 71 | 72 | //---------------------- 73 | 74 | int index1 = strLine.Find(":RDFA"); 75 | 76 | if (index1 == -1) return; 77 | 78 | int index2 = strLine.Find(":", index1 + 1); 79 | 80 | if (index2 == -1) return; 81 | 82 | int index3 = strLine.Find("!", index2 + 1); 83 | 84 | if (index3 == -1) return; 85 | 86 | index2++; 87 | 88 | CString str5A; 89 | CString strMoves(strLine.Mid(index2, index3 - index2)); 90 | 91 | CPoint Coord; 92 | 93 | while (strMoves.GetLength() >= 4) 94 | { 95 | CString strNumber(strMoves.Mid(0, 2)); 96 | CString strCoord(strMoves.Mid(2, 2)); 97 | 98 | if (str5A.IsEmpty() && strNumber == "A5" && 99 | strCoord[0] >= 'a' && strCoord[0] <= 'o' && 100 | strCoord[1] >= 'a' && strCoord[1] <= 'o') 101 | { 102 | Coord.x = strCoord[0] - 'a' + 1; 103 | Coord.y = strCoord[1] - 'a' + 1; 104 | 105 | str5A = 106 | Utils::XCoordinateImage(Coord.x, true, false) + 107 | Utils::YCoordinateImage(Coord.y, true); 108 | } 109 | else 110 | { 111 | Coord.x = strCoord[0] - 'A' + 1; 112 | Coord.y = strCoord[1] - 'A' + 1; 113 | 114 | mGame.addPos(Utils::PointToPos(Coord)); 115 | } 116 | 117 | strMoves.Delete(0, 4); 118 | } 119 | 120 | const int lastMove = mGame.numberOfMoves(); 121 | 122 | mGame.addMultiLineComment(lastMove, "File: " + mGameFile.GetFileTitle()); 123 | mGame.addMultiLineComment(lastMove, "5A: " + str5A); 124 | } 125 | -------------------------------------------------------------------------------- /Rdf.h: -------------------------------------------------------------------------------- 1 | // Rdf.h: interface for the Rdf class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_RDF_H__D9D1757E_2A78_4AC6_AF64_D3AB73E17A05__INCLUDED_) 6 | #define AFX_RDF_H__D9D1757E_2A78_4AC6_AF64_D3AB73E17A05__INCLUDED_ 7 | 8 | #include "Game.h" 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif // _MSC_VER > 1000 13 | 14 | class Rdf 15 | { 16 | public: 17 | Rdf(); 18 | 19 | bool OpenFile(const CString& strFile); 20 | 21 | Game& getGame(); 22 | CString getFilePath(); 23 | 24 | private: 25 | void Parse(); 26 | 27 | private: 28 | CStdioFile mGameFile; 29 | 30 | Game mGame; 31 | CString mstrFilePath; 32 | }; 33 | 34 | #endif // !defined(AFX_RDF_H__D9D1757E_2A78_4AC6_AF64_D3AB73E17A05__INCLUDED_) 35 | -------------------------------------------------------------------------------- /Registry.h: -------------------------------------------------------------------------------- 1 | // Registry.h: interface for the Registry class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_REGISTRY_H__F6128891_1475_43EC_A2FE_C768ABC5C820__INCLUDED_) 6 | #define AFX_REGISTRY_H__F6128891_1475_43EC_A2FE_C768ABC5C820__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | class Registry 13 | { 14 | public: 15 | 16 | enum RegistryKey 17 | { 18 | // Int 19 | BackgroundColor, 20 | BlackALVColor, 21 | BlackCMOColor, 22 | BlackNumberColor, 23 | BlackStoneColor, 24 | BlackVariantColor, 25 | BlackVcfColor, 26 | BlackVctColor, 27 | BoardColor, 28 | BoardSize, 29 | BoardTextColor, 30 | CommentBkColor, 31 | CommentTextColor, 32 | Coordinates, 33 | CoordTextColor, 34 | CustColors_0, 35 | CustColors_1, 36 | CustColors_2, 37 | CustColors_3, 38 | CustColors_4, 39 | CustColors_5, 40 | CustColors_6, 41 | CustColors_7, 42 | CustColors_8, 43 | CustColors_9, 44 | CustColors_10, 45 | CustColors_11, 46 | CustColors_12, 47 | CustColors_13, 48 | CustColors_14, 49 | CustColors_15, 50 | Evaluator, 51 | ForbiddenColor, 52 | LastMoveColor, 53 | WinMarker, 54 | WhiteALVColor, 55 | WhiteCMOColor, 56 | WhiteNumberColor, 57 | WhiteStoneColor, 58 | WhiteVariantColor, 59 | WhiteVcfColor, 60 | WhiteVctColor, 61 | RegisteredVersion, 62 | NewsDate, 63 | 64 | // Bool 65 | AutoFindSamePosition, 66 | AutoPointMouse, 67 | BoardTextExtraSpace, 68 | CoordinatesFollow, 69 | IsZoomed, 70 | ShowAutoLinkVariants, 71 | ShowBoardBitmap, 72 | ShowBoardText, 73 | ShowChangedOrderOfMovesVariants, 74 | ShowComments, 75 | ShowForbidden, 76 | ShowLastMove, 77 | ShowNumbers, 78 | ShowStoneBitmap, 79 | ShowVariants, 80 | SwapRowNumber, 81 | 82 | // String 83 | BoardBitmap, 84 | FontSmall, 85 | FontMedium, 86 | FontLarge, 87 | FontBoardTextSmall, 88 | FontBoardTextMedium, 89 | FontBoardTextLarge, 90 | FontCommentSmall, 91 | FontCommentMedium, 92 | FontCommentLarge, 93 | StartPage 94 | }; 95 | 96 | public: 97 | Registry(); 98 | ~Registry(); 99 | 100 | UINT getInt(RegistryKey key, int nDefault); 101 | void setInt(RegistryKey key, int nValue); 102 | 103 | bool getBool(RegistryKey key, int bDefault); 104 | void setBool(RegistryKey key, int bValue); 105 | 106 | CString getString(RegistryKey key, const CString& strDefault); 107 | void setString(RegistryKey key, const CString& strValue); 108 | 109 | private: 110 | CString getSection(RegistryKey key); 111 | CString getEntry(RegistryKey key); 112 | 113 | private: 114 | CWinApp* mApp; 115 | }; 116 | 117 | #endif // !defined(AFX_REGISTRY_H__F6128891_1475_43EC_A2FE_C768ABC5C820__INCLUDED_) 118 | -------------------------------------------------------------------------------- /Release/bestmove.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/Release/bestmove.dll -------------------------------------------------------------------------------- /RenJS.h: -------------------------------------------------------------------------------- 1 | // RenJS.h: interface for the RenJS class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_RENJS_H__17E181E4_21CE_4989_A988_DCCA7631C0E7__INCLUDED_) 6 | #define AFX_RENJS_H__17E181E4_21CE_4989_A988_DCCA7631C0E7__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | #include 13 | 14 | class RenJS 15 | { 16 | public: 17 | enum Result 18 | { 19 | VALID, 20 | EMPTY_ERROR, 21 | OPEN_FILE_ERROR, 22 | READ_FILE_ERROR, 23 | LESS_THAN_5_MOVES, 24 | ID_ERROR, 25 | COORDINATE_ERROR, 26 | NUMBER_ERROR, 27 | PARENT_ERROR, 28 | CHILD_ERROR 29 | }; 30 | 31 | class Node 32 | { 33 | public: 34 | Node(RenJS* renjs); 35 | 36 | int getId(); 37 | void setId(int id); 38 | 39 | BYTE getPos(); 40 | void setPos(BYTE pos); 41 | 42 | int getNumber(); 43 | void setNumber(int number); 44 | 45 | int getParent(); 46 | void setParent(int parent); 47 | 48 | bool hasMoreChildren(); 49 | Node* nextChild(); 50 | void addChild(int child); 51 | 52 | CString getOneLineComment(); 53 | void setOneLineComment(const CString& comment); 54 | 55 | CString getMultiLineComment(); 56 | void setMultiLineComment(const CString& comment); 57 | 58 | CString getBoardText(); 59 | void setBoardText(const CString& boardText); 60 | 61 | private: 62 | int mId; 63 | BYTE mPos; 64 | int mNumber; 65 | int mParent; 66 | std::vector mChildren; 67 | int mIndex; 68 | CString mOneLineComment; 69 | CString mMultiLineComment; 70 | CString mBoardText; 71 | RenJS* mRenjs; 72 | }; 73 | 74 | public: 75 | RenJS(); 76 | 77 | Result addGame(const CString& strFile); 78 | 79 | bool hasMoreGames(); 80 | Node* nextGame(); 81 | 82 | CString getFilePath(); 83 | 84 | Result CheckMoves(); 85 | 86 | Node* getNode(int id); 87 | 88 | private: 89 | void parseGame(); 90 | void parseMove(const CString& strMove); 91 | void parseParam(const CString& strParam, Node& node); 92 | void parseId(const CString& strData, Node& node); 93 | void parseCoordinate(const CString& strData, Node& node); 94 | void parseNumber(const CString& strData, Node& node); 95 | void parseParent(const CString& strData, Node& node); 96 | void parseChildren(const CString& strData, Node& node); 97 | void parseChild(const CString& strData, Node& node); 98 | void parseComment(const CString& strData, Node& node); 99 | void parseOneLineComment(const CString& strData, Node& node); 100 | void parseMultiLineComment(const CString& strData, Node& node); 101 | void parseBoardText(const CString& strData, Node& node); 102 | bool extractCoordinate(const CString& strData, CPoint& Move); 103 | 104 | private: 105 | CStdioFile mGameFile; 106 | std::vector mMoves; 107 | int mIndex; 108 | Result mResult; 109 | CString mFilePath; 110 | 111 | private: 112 | class Exception 113 | { 114 | public: 115 | Exception(Result errorCause); 116 | 117 | Result getErrorCause(); 118 | 119 | private: 120 | Result mErrorCause; 121 | }; 122 | }; 123 | 124 | #endif // !defined(AFX_RENJS_H__17E181E4_21CE_4989_A988_DCCA7631C0E7__INCLUDED_) 125 | -------------------------------------------------------------------------------- /RenLib.cpp: -------------------------------------------------------------------------------- 1 | // RenLib.cpp : Defines the class behaviors for the application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "RenLib.h" 6 | 7 | #include "MainFrm.h" 8 | #include "RenLibDoc.h" 9 | #include "RenLibView.h" 10 | #include "Utils.h" 11 | #include 12 | #include "HyperLink.h" 13 | #include "Registry.h" 14 | 15 | #ifdef _DEBUG 16 | #define new DEBUG_NEW 17 | #undef THIS_FILE 18 | static char THIS_FILE[] = __FILE__; 19 | #endif 20 | 21 | ///////////////////////////////////////////////////////////////////////////// 22 | // CRenLibApp 23 | 24 | BEGIN_MESSAGE_MAP(CRenLibApp, CWinApp) 25 | //{{AFX_MSG_MAP(CRenLibApp) 26 | ON_COMMAND(ID_APP_ABOUT, OnAppAbout) 27 | //}}AFX_MSG_MAP 28 | // Standard file based document commands 29 | END_MESSAGE_MAP() 30 | 31 | ///////////////////////////////////////////////////////////////////////////// 32 | // CRenLibApp construction 33 | 34 | CRenLibApp::CRenLibApp() 35 | { 36 | } 37 | 38 | ///////////////////////////////////////////////////////////////////////////// 39 | // The one and only CRenLibApp object 40 | 41 | CRenLibApp theApp; 42 | 43 | ///////////////////////////////////////////////////////////////////////////// 44 | // CRenLibApp initialization 45 | 46 | BOOL CRenLibApp::InitInstance() 47 | { 48 | AfxEnableControlContainer(); 49 | 50 | #ifdef _AFXDLL 51 | Enable3dControls(); // Call this when using MFC in a shared DLL 52 | #else 53 | Enable3dControlsStatic(); // Call this when linking to MFC statically 54 | #endif 55 | 56 | // Change the registry key under which our settings are stored. 57 | SetRegistryKey(_T("Renju")); 58 | 59 | LoadStdProfileSettings(10); // Load standard INI file options (including MRU) 60 | 61 | // Register the application's document templates. Document templates 62 | // serve as the connection between documents, frame windows and views. 63 | 64 | CSingleDocTemplate* pDocTemplate; 65 | pDocTemplate = new CSingleDocTemplate( 66 | IDR_MAINFRAME, 67 | RUNTIME_CLASS(CRenLibDoc), 68 | RUNTIME_CLASS(CMainFrame), // main SDI frame window 69 | RUNTIME_CLASS(CRenLibView)); 70 | AddDocTemplate(pDocTemplate); 71 | 72 | // Enable DDE Execute open 73 | EnableShellOpen(); 74 | // RegisterShellFileTypes(FALSE); 75 | 76 | // Parse command line for standard shell commands, DDE, file open 77 | CCommandLineInfo cmdInfo; 78 | ParseCommandLine(cmdInfo); 79 | 80 | // Dispatch commands specified on the command line 81 | if (!ProcessShellCommand(cmdInfo)) 82 | return FALSE; 83 | 84 | // The one and only window has been initialized, so show and update it. 85 | Registry reg; 86 | if (reg.getInt(Registry::IsZoomed, false)) 87 | { 88 | m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED); 89 | } 90 | 91 | m_pMainWnd->UpdateWindow(); 92 | 93 | // Enable drag/drop open 94 | m_pMainWnd->DragAcceptFiles(); 95 | 96 | return TRUE; 97 | } 98 | 99 | 100 | ///////////////////////////////////////////////////////////////////////////// 101 | // CAboutDlg dialog used for App About 102 | 103 | class CAboutDlg : public CDialog 104 | { 105 | public: 106 | CAboutDlg(); 107 | 108 | // Dialog Data 109 | //{{AFX_DATA(CAboutDlg) 110 | enum { IDD = IDD_ABOUTBOX }; 111 | CHyperLink mMail; 112 | CString mVersion; 113 | //}}AFX_DATA 114 | 115 | // ClassWizard generated virtual function overrides 116 | //{{AFX_VIRTUAL(CAboutDlg) 117 | protected: 118 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 119 | //}}AFX_VIRTUAL 120 | 121 | // Implementation 122 | protected: 123 | //{{AFX_MSG(CAboutDlg) 124 | virtual BOOL OnInitDialog(); 125 | //}}AFX_MSG 126 | DECLARE_MESSAGE_MAP() 127 | }; 128 | 129 | CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) 130 | { 131 | //{{AFX_DATA_INIT(CAboutDlg) 132 | //}}AFX_DATA_INIT 133 | } 134 | 135 | void CAboutDlg::DoDataExchange(CDataExchange* pDX) 136 | { 137 | CDialog::DoDataExchange(pDX); 138 | //{{AFX_DATA_MAP(CAboutDlg) 139 | DDX_Control(pDX, IDC_MAIL, mMail); 140 | DDX_Text (pDX, IDC_VERSION, mVersion); 141 | //}}AFX_DATA_MAP 142 | } 143 | 144 | BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 145 | //{{AFX_MSG_MAP(CAboutDlg) 146 | //}}AFX_MSG_MAP 147 | END_MESSAGE_MAP() 148 | 149 | // App command to run the dialog 150 | void CRenLibApp::OnAppAbout() 151 | { 152 | CAboutDlg aboutDlg; 153 | aboutDlg.DoModal(); 154 | } 155 | 156 | ///////////////////////////////////////////////////////////////////////////// 157 | // CRenLibApp message handlers 158 | 159 | BOOL CAboutDlg::OnInitDialog() 160 | { 161 | CDialog::OnInitDialog(); 162 | 163 | const CString strRenLibEmail(Utils::GetString(IDS_RENLIB_EMAIL)); 164 | 165 | mVersion = CRenLibDoc::getProgramVersion(); 166 | 167 | mMail.SetWindowText(strRenLibEmail); 168 | mMail.SetURL("mailto:" + strRenLibEmail); 169 | mMail.SetUnderline(FALSE); 170 | 171 | // Transfer data from variables to controls 172 | UpdateData(FALSE); 173 | 174 | return TRUE; // return TRUE unless you set the focus to a control 175 | // EXCEPTION: OCX Property Pages should return FALSE 176 | } 177 | -------------------------------------------------------------------------------- /RenLib.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "RenLib"=".\RenLib.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | begin source code control 11 | "$/RenLib", BAAAAAAA 12 | . 13 | end source code control 14 | }}} 15 | 16 | Package=<4> 17 | {{{ 18 | }}} 19 | 20 | ############################################################################### 21 | 22 | Global: 23 | 24 | Package=<5> 25 | {{{ 26 | }}} 27 | 28 | Package=<3> 29 | {{{ 30 | }}} 31 | 32 | ############################################################################### 33 | 34 | -------------------------------------------------------------------------------- /RenLib.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/RenLib.gif -------------------------------------------------------------------------------- /RenLib.h: -------------------------------------------------------------------------------- 1 | // RenLib.h : main header file for the RENLIB application 2 | // 3 | 4 | #if !defined(AFX_RENLIB_H__72EC9D45_F85E_11D3_92A3_947F7AC2F525__INCLUDED_) 5 | #define AFX_RENLIB_H__72EC9D45_F85E_11D3_92A3_947F7AC2F525__INCLUDED_ 6 | 7 | #if _MSC_VER > 1000 8 | #pragma once 9 | #endif // _MSC_VER > 1000 10 | 11 | #ifndef __AFXWIN_H__ 12 | #error include 'stdafx.h' before including this file for PCH 13 | #endif 14 | 15 | #include "resource.h" // main symbols 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // CRenLibApp: 19 | // See RenLib.cpp for the implementation of this class 20 | // 21 | 22 | class CRenLibApp : public CWinApp 23 | { 24 | public: 25 | CRenLibApp(); 26 | 27 | // Overrides 28 | // ClassWizard generated virtual function overrides 29 | //{{AFX_VIRTUAL(CRenLibApp) 30 | public: 31 | virtual BOOL InitInstance(); 32 | //}}AFX_VIRTUAL 33 | 34 | // Implementation 35 | //{{AFX_MSG(CRenLibApp) 36 | afx_msg void OnAppAbout(); 37 | //}}AFX_MSG 38 | DECLARE_MESSAGE_MAP() 39 | }; 40 | 41 | 42 | ///////////////////////////////////////////////////////////////////////////// 43 | 44 | //{{AFX_INSERT_LOCATION}} 45 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 46 | 47 | #endif // !defined(AFX_RENLIB_H__72EC9D45_F85E_11D3_92A3_947F7AC2F525__INCLUDED_) 48 | -------------------------------------------------------------------------------- /RenLibApplet.h: -------------------------------------------------------------------------------- 1 | // RenLibApplet.h: interface for the RenLibApplet class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_RENLIB_APPLET_H__BB1690C8_CF99_48C1_B318_9A98599582C2__INCLUDED_) 6 | #define AFX_RENLIB_APPLET_H__BB1690C8_CF99_48C1_B318_9A98599582C2__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | #include 13 | 14 | class MoveList; 15 | class MoveNode; 16 | 17 | class RenLibApplet 18 | { 19 | public: 20 | enum Size 21 | { 22 | BIG, 23 | SMALL 24 | }; 25 | 26 | enum Url 27 | { 28 | WEB, 29 | LOCAL 30 | }; 31 | 32 | static const CString cFirstComment; 33 | static const CString cLastComment; 34 | 35 | class Information 36 | { 37 | public: 38 | Information(); 39 | 40 | Information( 41 | Size size, 42 | CString titleAppletWebPage, 43 | CString titleGameWebPage, 44 | BOOL showOneLineComment, 45 | BOOL showMultiLineComment, 46 | BOOL showBoardText, 47 | BOOL showCoordinates, 48 | BOOL showNumbers, 49 | BOOL showCommands, 50 | BOOL showBoard, 51 | Url url, 52 | CString repeatOneLineComment, 53 | COLORREF backgroundColor); 54 | 55 | public: 56 | Size mSize; 57 | CString mTitleAppletWebPage; 58 | CString mTitleGameWebPage; 59 | BOOL mShowOneLineComment; 60 | BOOL mShowMultiLineComment; 61 | BOOL mShowBoardText; 62 | BOOL mShowCoordinates; 63 | BOOL mShowNumbers; 64 | BOOL mShowCommands; 65 | BOOL mShowBoard; 66 | Url mUrl; 67 | CString mRepeatOneLineComment; 68 | COLORREF mBackgroundColor; 69 | }; 70 | 71 | public: 72 | RenLibApplet(Information info); 73 | 74 | virtual ~RenLibApplet(); 75 | 76 | bool getAppletInformation( 77 | const CString& strDirectory, Information& info, COLORREF* custColors); 78 | 79 | bool Create( 80 | const CString& fileName, const MoveList& aMoveList, 81 | CString& strComment, const Information& info); 82 | 83 | bool CreateExportGameFile( 84 | const CString& strDirectory, CStringList& strList, const CString& titleGameWebPage, 85 | const CString& strCaption, CString& strFile); 86 | 87 | bool CreateTournamentGameFile( 88 | const CString& strDirectory, CStringList& strList, const CString& titleGameWebPage, 89 | const CString& strCaption, CString& strFile); 90 | 91 | bool CreateGameCollectionFile( 92 | const CString& titleGameWebPage, const CString& strCaption, CString& strFile); 93 | 94 | bool AddGameCollectionFile( 95 | const MoveList& aMoveList, CString& strOneLineComment, CString& strMultiLineComment, 96 | const Information& info); 97 | 98 | bool CloseGameCollectionFile(); 99 | 100 | private: 101 | RenLibApplet(); 102 | 103 | void generateAppletCode( 104 | CString& strAppletCode, const MoveList& aMoveList, CString& strComment, 105 | const Information& info); 106 | 107 | private: 108 | typedef struct GameData 109 | { 110 | CString applet; 111 | CString oneLineComment; 112 | CString multiLineComment; 113 | }; 114 | 115 | CStdioFile mFile; 116 | std::vector mSortedList; 117 | 118 | CString mAppletUrl; 119 | CString mBlackWinImage; 120 | CString mWhiteWinImage; 121 | CString mDrawImage; 122 | 123 | void WriteLine(const CString& line); 124 | }; 125 | 126 | #endif // !defined(AFX_RENLIB_APPLET_H__BB1690C8_CF99_48C1_B318_9A98599582C2__INCLUDED_) 127 | -------------------------------------------------------------------------------- /RenLibAppletDialog.h: -------------------------------------------------------------------------------- 1 | #if !defined(AFX_RENLIB_APPLETDIALOG_H__FE6B22CA_64EF_4EEC_81C7_3C8FDF8B656D__INCLUDED_) 2 | #define AFX_RENLIB_APPLETDIALOG_H__FE6B22CA_64EF_4EEC_81C7_3C8FDF8B656D__INCLUDED_ 3 | 4 | #include "RenLibApplet.h" 5 | 6 | #if _MSC_VER > 1000 7 | #pragma once 8 | #endif // _MSC_VER > 1000 9 | // RenLibAppletDialog.h : header file 10 | // 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | // RenLibAppletDialog dialog 14 | 15 | class RenLibAppletDialog : public CDialog 16 | { 17 | // Construction 18 | public: 19 | RenLibAppletDialog( 20 | bool editTitleAppletWebPage, bool editTitleGameWebPage, COLORREF* custColors); 21 | 22 | RenLibAppletDialog( 23 | bool editTitleAppletWebPage, 24 | bool editTitleGameWebPage, 25 | bool editSize, 26 | bool editShowOneLineComment, 27 | bool editShowMultiLineComment, 28 | bool editShowBoardText, 29 | bool editShowCoordinates, 30 | bool editShowNumbers, 31 | bool editShowCommands, 32 | bool editUrl, 33 | bool editShowBoard, 34 | bool editBackgroundColor, 35 | bool editRepeatOneLineComment, 36 | COLORREF* custColors); 37 | 38 | void setInfo(const RenLibApplet::Information& info); 39 | void getInfo(RenLibApplet::Information& info); 40 | 41 | void setOneLineComments(std::vector& comments); 42 | 43 | private: 44 | void initData(); 45 | 46 | // Dialog Data 47 | //{{AFX_DATA(RenLibAppletDialog) 48 | enum { IDD = IDD_RENLIB_APPLET }; 49 | CString mTitleAppletWebPage; 50 | CString mTitleGameWebPage; 51 | int mSize; 52 | BOOL mShowOneLineComment; 53 | BOOL mShowMultiLineComment; 54 | BOOL mShowBoardText; 55 | BOOL mShowCoordinates; 56 | BOOL mShowNumbers; 57 | BOOL mShowCommands; 58 | BOOL mShowBoard; 59 | int mUrl; 60 | CString mRepeatOneLineComment; 61 | //}}AFX_DATA 62 | COLORREF mBackgroundColor; 63 | 64 | // Overrides 65 | // ClassWizard generated virtual function overrides 66 | //{{AFX_VIRTUAL(RenLibAppletDialog) 67 | protected: 68 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 69 | //}}AFX_VIRTUAL 70 | 71 | // Implementation 72 | protected: 73 | 74 | // Generated message map functions 75 | //{{AFX_MSG(RenLibAppletDialog) 76 | virtual BOOL OnInitDialog(); 77 | afx_msg void OnPaint(); 78 | afx_msg void OnChooseBackgroundColor(); 79 | //}}AFX_MSG 80 | DECLARE_MESSAGE_MAP() 81 | 82 | private: 83 | bool mEditTitleAppletWebPage; 84 | bool mEditTitleGameWebPage; 85 | bool mEditSize; 86 | bool mEditShowOneLineComment; 87 | bool mEditShowMultiLineComment; 88 | bool mEditShowBoardText; 89 | bool mEditShowCoordinates; 90 | bool mEditShowNumbers; 91 | bool mEditShowCommands; 92 | bool mEditUrl; 93 | bool mEditShowBoard; 94 | bool mEditBackgroundColor; 95 | bool mEditRepeatOneLineComment; 96 | 97 | std::vector mOneLineComments; 98 | 99 | COLORREF* mCustColors; 100 | CRect mColorRect; 101 | }; 102 | 103 | //{{AFX_INSERT_LOCATION}} 104 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 105 | 106 | #endif // !defined(AFX_RENLIB_APPLETDIALOG_H__FE6B22CA_64EF_4EEC_81C7_3C8FDF8B656D__INCLUDED_) 107 | -------------------------------------------------------------------------------- /Renartist.cpp: -------------------------------------------------------------------------------- 1 | // Renartist.cpp: implementation of the Renartist class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "renlib.h" 7 | #include "Renartist.h" 8 | #include "MoveList.h" 9 | #include "MoveNode.h" 10 | #include "Utils.h" 11 | 12 | #ifdef _DEBUG 13 | #undef THIS_FILE 14 | static char THIS_FILE[]=__FILE__; 15 | #define new DEBUG_NEW 16 | #endif 17 | 18 | ////////////////////////////////////////////////////////////////////// 19 | // Construction/Destruction 20 | ////////////////////////////////////////////////////////////////////// 21 | 22 | namespace 23 | { 24 | void addByte(CString& strValue, BYTE value) 25 | { 26 | CString strHex; 27 | strHex.Format("%02x", value); 28 | strValue += strHex; 29 | } 30 | 31 | void addOneLineComment(CString& strValue, CString& strComment) 32 | { 33 | CString strNew(strComment); 34 | 35 | while (strNew.GetLength() < 79) 36 | { 37 | strNew += ' '; 38 | } 39 | 40 | strNew += TCHAR(0); 41 | 42 | if (strNew.GetLength() % 2) 43 | { 44 | strNew += TCHAR(0); 45 | } 46 | 47 | for (int i=0; i < strNew.GetLength(); i++) 48 | { 49 | addByte(strValue, strNew[i]); 50 | } 51 | } 52 | 53 | void addMultiLineComment(CString& strValue, CString& strMultiLineComment) 54 | { 55 | int nLeft = 0; 56 | int nRight; 57 | 58 | while (nLeft < strMultiLineComment.GetLength()) 59 | { 60 | nRight = strMultiLineComment.Find(TCHAR(13), nLeft); 61 | 62 | if (nRight == -1) 63 | { 64 | nRight = strMultiLineComment.GetLength(); 65 | } 66 | 67 | CString strLine(strMultiLineComment.Mid(nLeft, nRight - nLeft)); 68 | 69 | strValue += strLine + TCHAR(10); 70 | 71 | nLeft = nRight + 2; 72 | } 73 | } 74 | } 75 | 76 | Renartist::Renartist() 77 | { 78 | } 79 | 80 | Renartist::~Renartist() 81 | { 82 | } 83 | 84 | bool Renartist::Create (const CString& fileName, const MoveList& aMoveList) 85 | { 86 | if (!m_file.Open(fileName, CFile::modeCreate | CFile::modeWrite | CFile::typeText)) 87 | { 88 | CString strMessage(Utils::GetString(IDS_MSG_OPEN_FILE, fileName)); 89 | Utils::ShowMessage(strMessage, Utils::GetString(IDS_CAP_CREATE_RENARTIST_APPLET), MB_ICONERROR); 90 | return false; 91 | } 92 | 93 | CString strTitle("renartist applet"); 94 | 95 | CString strComment(aMoveList.Current()->getOneLineComment()); 96 | 97 | if (!strComment.IsEmpty()) 98 | { 99 | strTitle = strComment; 100 | } 101 | 102 | CString strValue; 103 | 104 | for (int i = 1; i <= aMoveList.Index(); i++) 105 | { 106 | addByte(strValue, Utils::PointToPos(aMoveList.Get(i)->getPos())); 107 | 108 | CString strInfo; 109 | 110 | if (i < aMoveList.Index()) 111 | { 112 | strInfo = "0"; 113 | } 114 | else 115 | { 116 | strInfo = "4"; // Last move 117 | } 118 | 119 | strValue += strInfo; 120 | 121 | CString strComment(aMoveList.Get(i)->getOneLineComment()); 122 | 123 | if (i == 1 && strComment.IsEmpty()) 124 | { 125 | strComment = "renartist applet"; 126 | } 127 | 128 | if (strComment.IsEmpty()) 129 | { 130 | strInfo = "0"; 131 | } 132 | else 133 | { 134 | strInfo = "8"; 135 | } 136 | 137 | strValue += strInfo; 138 | 139 | if (!strComment.IsEmpty()) 140 | { 141 | addOneLineComment(strValue, strComment); 142 | } 143 | } 144 | 145 | WriteLine(""); 146 | WriteLine(""); 147 | WriteLine(""); 148 | WriteLine("" + strTitle + ""); 149 | WriteLine(""); 150 | WriteLine(""); 151 | WriteLine("
"); 152 | WriteLine("
"); 153 | WriteLine(""); 154 | WriteLine(""); 155 | WriteLine(""); 157 | WriteLine(""); 158 | WriteLine(""); 159 | WriteLine(""); 166 | WriteLine(""); 167 | WriteLine(""); 189 | WriteLine(""); 190 | WriteLine(""); 191 | WriteLine(""); 194 | WriteLine(""); 195 | WriteLine("
"); 156 | WriteLine("

   " + strTitle + "

"); 160 | WriteLine("
"); 161 | WriteLine(""); 162 | WriteLine(""); 163 | 164 | WriteLine(""); 165 | WriteLine("
"); 168 | WriteLine("

"); 169 | 170 | WriteLine(""); 188 | WriteLine("
"); 192 | WriteLine("
renartist applet commands:
left click (forward) - right click (back)
"); 193 | WriteLine("
"); 196 | WriteLine("
"); 197 | WriteLine("
"); 198 | WriteLine(""); 199 | WriteLine(""); 200 | 201 | m_file.Close(); 202 | 203 | return true; 204 | } 205 | 206 | void Renartist::WriteLine(const CString& line) 207 | { 208 | m_file.WriteString(line + TCHAR(10)); 209 | } 210 | -------------------------------------------------------------------------------- /Renartist.h: -------------------------------------------------------------------------------- 1 | // Renartist.h: interface for the Renartist class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_RENARTIST_H__821389C7_F056_4DF0_90C7_B631D092435A__INCLUDED_) 6 | #define AFX_RENARTIST_H__821389C7_F056_4DF0_90C7_B631D092435A__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | class MoveList; 13 | 14 | class Renartist 15 | { 16 | public: 17 | Renartist(); 18 | virtual ~Renartist(); 19 | 20 | bool Create (const CString& fileName, const MoveList& aMoveList); 21 | 22 | private: 23 | CStdioFile m_file; 24 | 25 | void WriteLine(const CString& line); 26 | }; 27 | 28 | #endif // !defined(AFX_RENARTIST_H__821389C7_F056_4DF0_90C7_B631D092435A__INCLUDED_) 29 | -------------------------------------------------------------------------------- /Renjuclass.cpp: -------------------------------------------------------------------------------- 1 | // Renjuclass.cpp: implementation of the Renjuclass class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "renlib.h" 7 | #include "Renjuclass.h" 8 | #include "MoveList.h" 9 | #include "MoveNode.h" 10 | #include "Utils.h" 11 | 12 | #ifdef _DEBUG 13 | #undef THIS_FILE 14 | static char THIS_FILE[]=__FILE__; 15 | #define new DEBUG_NEW 16 | #endif 17 | 18 | namespace 19 | { 20 | const CString cPrefix(""); 22 | } 23 | 24 | ////////////////////////////////////////////////////////////////////// 25 | // Construction/Destruction 26 | ////////////////////////////////////////////////////////////////////// 27 | 28 | Renjuclass::Renjuclass() 29 | { 30 | } 31 | 32 | Renjuclass::~Renjuclass() 33 | { 34 | } 35 | 36 | void Renjuclass::Create(const MoveList& aMoveList) 37 | { 38 | for (int i = 1; i <= aMoveList.Index(); i++) 39 | { 40 | CPoint Coord(aMoveList.Get(i)->getPos()); 41 | CString strMove(Utils::XCoordinateImage(Coord.x, true, false) + Utils::YCoordinateImage(Coord.y, true)); 42 | strMove.MakeLower(); 43 | m_strMoves += strMove + "+"; 44 | } 45 | 46 | m_strMoves.Delete(m_strMoves.GetLength()-1); 47 | 48 | m_strOneLineComment = aMoveList.Get(aMoveList.Index())->getOneLineComment(); 49 | 50 | if (m_strOneLineComment.IsEmpty()) 51 | { 52 | m_strOneLineComment = "Renjuclass Diagram"; 53 | } 54 | } 55 | 56 | bool Renjuclass::Save(const CString& fileName) 57 | { 58 | if (!m_file.Open(fileName, CFile::modeCreate | CFile::modeWrite | CFile::typeText)) 59 | { 60 | CString strMessage(Utils::GetString(IDS_MSG_OPEN_FILE, fileName)); 61 | Utils::ShowMessage(strMessage, Utils::GetString(IDS_CAP_CREATE_RENJUCLASS_DIAGRAM), MB_ICONERROR); 62 | return false; 63 | } 64 | 65 | m_file.WriteString("\n"); 66 | m_file.WriteString(""); 67 | m_file.WriteString("Renjuclass Diagram\n"); 68 | m_file.WriteString("\n"); 69 | m_file.WriteString("\n"); 70 | m_file.WriteString(m_strOneLineComment + "
"); 71 | m_file.WriteString(cPrefix + m_strMoves + cSuffix + "\n"); 72 | m_file.WriteString("\n"); 73 | m_file.WriteString("\n"); 74 | 75 | m_file.Close(); 76 | 77 | return true; 78 | } 79 | -------------------------------------------------------------------------------- /Renjuclass.h: -------------------------------------------------------------------------------- 1 | // Renjuclass.h: interface for the Renjuclass class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_RENJUCLASS_H__DEFEADC1_1E5E_11D6_92A3_0000E89F396C__INCLUDED_) 6 | #define AFX_RENJUCLASS_H__DEFEADC1_1E5E_11D6_92A3_0000E89F396C__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | class MoveList; 13 | class Game; 14 | 15 | class Renjuclass 16 | { 17 | public: 18 | Renjuclass(); 19 | virtual ~Renjuclass(); 20 | 21 | void Create(const MoveList& aMoveList); 22 | bool Save(const CString& fileName); 23 | 24 | private: 25 | CStdioFile m_file; 26 | CString m_strMoves; 27 | CString m_strOneLineComment; 28 | }; 29 | 30 | #endif // !defined(AFX_RENJUCLASS_H__DEFEADC1_1E5E_11D6_92A3_0000E89F396C__INCLUDED_) 31 | -------------------------------------------------------------------------------- /SearchComment.cpp: -------------------------------------------------------------------------------- 1 | // SearchComment.cpp : implementation file 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "RenLib.h" 6 | #include "SearchComment.h" 7 | 8 | #ifdef _DEBUG 9 | #define new DEBUG_NEW 10 | #undef THIS_FILE 11 | static char THIS_FILE[] = __FILE__; 12 | #endif 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | // SearchComment dialog 16 | 17 | 18 | SearchComment::SearchComment(CWnd* pParent /*=NULL*/) 19 | : CDialog(SearchComment::IDD, pParent) 20 | { 21 | //{{AFX_DATA_INIT(SearchComment) 22 | m_strComment = _T(""); 23 | mFindOption = 0; 24 | //}}AFX_DATA_INIT 25 | } 26 | 27 | 28 | void SearchComment::DoDataExchange(CDataExchange* pDX) 29 | { 30 | CDialog::DoDataExchange(pDX); 31 | //{{AFX_DATA_MAP(SearchComment) 32 | DDX_Text (pDX, IDC_ONE_LINE_COMMENT, m_strComment); 33 | DDV_MaxChars(pDX, m_strComment, 55); 34 | DDX_Radio (pDX, IDC_RADIO_COMMENT, mFindOption); 35 | //}}AFX_DATA_MAP 36 | } 37 | 38 | 39 | BEGIN_MESSAGE_MAP(SearchComment, CDialog) 40 | //{{AFX_MSG_MAP(SearchComment) 41 | // NOTE: the ClassWizard will add message map macros here 42 | //}}AFX_MSG_MAP 43 | END_MESSAGE_MAP() 44 | 45 | ///////////////////////////////////////////////////////////////////////////// 46 | // SearchComment message handlers 47 | 48 | int SearchComment::DoModal() 49 | { 50 | CDialogTemplate dlt; 51 | int nResult; 52 | 53 | // load dialog template 54 | if (!dlt.Load(MAKEINTRESOURCE(SearchComment::IDD))) return -1; 55 | 56 | // set your own font, for example "Arial", 10 pts. 57 | dlt.SetFont(m_strFaceName, 10); 58 | 59 | // get pointer to the modified dialog template 60 | LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate); 61 | 62 | // let MFC know that you are using your own template 63 | m_lpszTemplateName = NULL; 64 | m_hDialogTemplate = NULL; 65 | 66 | InitModalIndirect(pdata); 67 | 68 | // display dialog box 69 | nResult = CDialog::DoModal(); 70 | 71 | // unlock memory object 72 | GlobalUnlock(dlt.m_hTemplate); 73 | 74 | return nResult; 75 | } 76 | -------------------------------------------------------------------------------- /SearchComment.h: -------------------------------------------------------------------------------- 1 | #if !defined(AFX_SEARCH_COMMENT_H__9FE3DCE5_179A_11D4_92A3_B960D61F6125__INCLUDED_) 2 | #define AFX_SEARCH_COMMENT_H__9FE3DCE5_179A_11D4_92A3_B960D61F6125__INCLUDED_ 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif // _MSC_VER > 1000 7 | // SearchComment.h : header file 8 | // 9 | 10 | ///////////////////////////////////////////////////////////////////////////// 11 | // SearchComment dialog 12 | 13 | class SearchComment : public CDialog 14 | { 15 | // Construction 16 | public: 17 | SearchComment(CWnd* pParent = NULL); // standard constructor 18 | 19 | // Dialog Data 20 | //{{AFX_DATA(SearchComment) 21 | enum { IDD = IDD_SEARCH_COMMENT }; 22 | CString m_strComment; 23 | int mFindOption; 24 | //}}AFX_DATA 25 | CString m_strFaceName; 26 | 27 | 28 | // Overrides 29 | // ClassWizard generated virtual function overrides 30 | //{{AFX_VIRTUAL(SearchComment) 31 | public: 32 | virtual int DoModal(); 33 | protected: 34 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 35 | //}}AFX_VIRTUAL 36 | 37 | // Implementation 38 | protected: 39 | 40 | // Generated message map functions 41 | //{{AFX_MSG(SearchComment) 42 | // NOTE: the ClassWizard will add member functions here 43 | //}}AFX_MSG 44 | DECLARE_MESSAGE_MAP() 45 | }; 46 | 47 | //{{AFX_INSERT_LOCATION}} 48 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 49 | 50 | #endif // !defined(AFX_SEARCH_COMMENT_H__9FE3DCE5_179A_11D4_92A3_B960D61F6125__INCLUDED_) 51 | -------------------------------------------------------------------------------- /SearchItem.cpp: -------------------------------------------------------------------------------- 1 | // SearchItem.cpp: implementation of the SearchItem class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "renlib.h" 7 | #include "SearchItem.h" 8 | 9 | #ifdef _DEBUG 10 | #undef THIS_FILE 11 | static char THIS_FILE[]=__FILE__; 12 | #define new DEBUG_NEW 13 | #endif 14 | 15 | ////////////////////////////////////////////////////////////////////// 16 | // Construction/Destruction 17 | ////////////////////////////////////////////////////////////////////// 18 | 19 | SearchItem::SearchItem(MoveNode* moveNode) 20 | : mMoveNode(moveNode), 21 | mMergeText(NONE), 22 | mKind(NONE), 23 | mMatch(0) 24 | { 25 | } 26 | 27 | SearchItem::SearchItem(MoveNode* moveNode, int nMatch) 28 | : mMoveNode(moveNode), 29 | mMergeText(NONE), 30 | mKind(NONE), 31 | mMatch(nMatch) 32 | { 33 | } 34 | 35 | SearchItem::SearchItem(MoveNode* moveNode, const CString& mergeText, SearchItem::MergeKind kind) 36 | : mMoveNode(moveNode), 37 | mMergeText(mergeText), 38 | mKind(kind), 39 | mMatch(0) 40 | { 41 | } 42 | 43 | MoveNode* SearchItem::getMoveNode() const 44 | { 45 | return mMoveNode; 46 | } 47 | 48 | void SearchItem::setMoveNode(MoveNode* ptr) 49 | { 50 | mMoveNode = ptr; 51 | } 52 | 53 | CString SearchItem::getMergeText() const 54 | { 55 | return mMergeText; 56 | } 57 | 58 | void SearchItem::emptyMergeText() 59 | { 60 | mMergeText.Empty(); 61 | } 62 | 63 | SearchItem::MergeKind SearchItem::getKind() const 64 | { 65 | return mKind; 66 | } 67 | 68 | int SearchItem::getMatch() const 69 | { 70 | return mMatch; 71 | } 72 | 73 | bool SearchItem::operator==(SearchItem& item) 74 | { 75 | return 76 | mMoveNode == item.mMoveNode && 77 | mMergeText == item.mMergeText && 78 | mKind == item.mKind && 79 | mMatch == item.mMatch; 80 | } 81 | -------------------------------------------------------------------------------- /SearchItem.h: -------------------------------------------------------------------------------- 1 | // SearchItem.h: interface for the SearchItem class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_SEARCHITEM_H__BFA4E822_E43A_11D6_92A3_0000E89F396C__INCLUDED_) 6 | #define AFX_SEARCHITEM_H__BFA4E822_E43A_11D6_92A3_0000E89F396C__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | class MoveNode; 13 | 14 | class SearchItem 15 | { 16 | public: 17 | enum MergeKind 18 | { 19 | ONE_LINE_COMMENT, 20 | MULTI_LINE_COMMENT, 21 | BOARD_TEXT, 22 | NONE 23 | }; 24 | 25 | explicit SearchItem(MoveNode* moveNode); 26 | SearchItem(MoveNode* moveNode, int nMatch); 27 | SearchItem(MoveNode* moveNode, const CString& mergeText, MergeKind kind); 28 | 29 | MoveNode* getMoveNode() const; 30 | void setMoveNode(MoveNode* ptr); 31 | 32 | CString getMergeText() const; 33 | 34 | void emptyMergeText(); 35 | 36 | MergeKind getKind() const; 37 | 38 | int getMatch() const; 39 | 40 | bool operator==(SearchItem& item); 41 | 42 | private: 43 | MoveNode* mMoveNode; 44 | CString mMergeText; 45 | MergeKind mKind; 46 | int mMatch; 47 | }; 48 | 49 | #endif // !defined(AFX_SEARCHITEM_H__BFA4E822_E43A_11D6_92A3_0000E89F396C__INCLUDED_) 50 | -------------------------------------------------------------------------------- /SearchList.cpp: -------------------------------------------------------------------------------- 1 | // SearchList.cpp: implementation of the SearchList class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "RenLib.h" 7 | #include "SearchList.h" 8 | 9 | #ifdef _DEBUG 10 | #undef THIS_FILE 11 | static char THIS_FILE[]=__FILE__; 12 | #define new DEBUG_NEW 13 | #endif 14 | 15 | ////////////////////////////////////////////////////////////////////// 16 | // Construction/Destruction 17 | ////////////////////////////////////////////////////////////////////// 18 | 19 | namespace 20 | { 21 | const SearchItem emptyItem(0, "", SearchItem::NONE); 22 | } 23 | 24 | SearchList::SearchList() 25 | : mCurrent(0), 26 | mSearchKind(NONE) 27 | { 28 | } 29 | 30 | SearchList::~SearchList() 31 | { 32 | mTable.clear(); 33 | } 34 | 35 | void SearchList::Empty() 36 | { 37 | mTable.clear(); 38 | mCurrent = 0; 39 | mstrInfo.Empty(); 40 | } 41 | 42 | void SearchList::purge() 43 | { 44 | std::vector::iterator iter = mTable.begin(); 45 | 46 | for (int i=mTable.size()-1; i>=1; i--) 47 | { 48 | if (mTable[i].getMoveNode() == 0) 49 | { 50 | mTable.erase(iter + i); 51 | } 52 | } 53 | 54 | mCurrent = 0; 55 | mstrInfo.Empty(); 56 | } 57 | 58 | void SearchList::SetStart(SearchItem item) 59 | { 60 | if (mTable.empty()) 61 | { 62 | mTable.push_back(item); 63 | } 64 | else 65 | { 66 | mTable[0] = item; 67 | } 68 | } 69 | 70 | bool SearchList::HasStart() 71 | { 72 | return !mTable.empty(); 73 | } 74 | 75 | SearchItem* SearchList::GetStart() 76 | { 77 | VERIFY(!mTable.empty()); 78 | 79 | return &mTable[0]; 80 | } 81 | 82 | void SearchList::Add(SearchItem item) 83 | { 84 | bool isFound = false; 85 | 86 | if (item.getMoveNode() != GetStart()->getMoveNode()) 87 | { 88 | for (int i=1; i < mTable.size(); i++) 89 | { 90 | if (mTable[i] == item) 91 | { 92 | isFound = true; 93 | break; 94 | } 95 | } 96 | 97 | if (!isFound) 98 | { 99 | mTable.push_back(item); 100 | } 101 | } 102 | } 103 | 104 | void SearchList::Add(SearchItem item1, SearchItem item2) 105 | { 106 | mTable.push_back(item1); 107 | mTable.push_back(item2); 108 | } 109 | 110 | void SearchList::Clear() 111 | { 112 | VERIFY(mCurrent < mTable.size()); 113 | 114 | mTable[mCurrent] = emptyItem; 115 | } 116 | 117 | void SearchList::Clear(MoveNode* ptr) 118 | { 119 | for (int i=1; i < mTable.size(); i++) 120 | { 121 | if (mTable[i].getMoveNode() == ptr) 122 | { 123 | mTable[i] = emptyItem; 124 | break; 125 | } 126 | } 127 | } 128 | 129 | void SearchList::replace(MoveNode* fromPtr, MoveNode* toPtr) 130 | { 131 | for (int i=1; i < mTable.size(); i++) 132 | { 133 | if (mTable[i].getMoveNode() == fromPtr) 134 | { 135 | mTable[i].setMoveNode(toPtr); 136 | break; 137 | } 138 | } 139 | } 140 | 141 | SearchItem* SearchList::Get(int nIndex) 142 | { 143 | int size = mTable.size(); 144 | VERIFY(nIndex >= 0 && nIndex < mTable.size()); 145 | 146 | return &mTable[nIndex]; 147 | } 148 | 149 | SearchItem* SearchList::Current() 150 | { 151 | VERIFY(!mTable.empty()); 152 | return &mTable[mCurrent]; 153 | } 154 | 155 | SearchItem* SearchList::Next() 156 | { 157 | VERIFY(!mTable.empty()); 158 | 159 | mCurrent++; 160 | 161 | if (mCurrent >= mTable.size()) 162 | { 163 | mCurrent = 0; 164 | } 165 | 166 | return &mTable[mCurrent]; 167 | } 168 | 169 | SearchItem* SearchList::Previous() 170 | { 171 | VERIFY(!mTable.empty()); 172 | 173 | mCurrent--; 174 | 175 | if (mCurrent < 0) 176 | { 177 | mCurrent = mTable.size()-1; 178 | } 179 | 180 | return &mTable[mCurrent]; 181 | } 182 | 183 | bool SearchList::IsEmpty() const 184 | { 185 | for (int i=1; i < mTable.size(); i++) 186 | { 187 | if (mTable[i].getMoveNode() != 0) 188 | { 189 | return false; 190 | } 191 | } 192 | 193 | return true; 194 | } 195 | 196 | int SearchList::LastItem() const 197 | { 198 | VERIFY(!mTable.empty()); 199 | 200 | return mTable.size()-1; 201 | } 202 | 203 | int SearchList::CurrentIndex() const 204 | { 205 | VERIFY(!mTable.empty()); 206 | 207 | return mCurrent; 208 | } 209 | 210 | void SearchList::SetInfo(const CString& info, Kind SearchKind) 211 | { 212 | mstrInfo = info; 213 | mSearchKind = SearchKind; 214 | } 215 | 216 | CString SearchList::GetInfo() 217 | { 218 | return mstrInfo; 219 | } 220 | 221 | SearchList::Kind SearchList::GetKind() 222 | { 223 | return mSearchKind; 224 | } 225 | 226 | -------------------------------------------------------------------------------- /SearchList.h: -------------------------------------------------------------------------------- 1 | // SearchList.h: interface for the SearchList class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_SEARCHLIST_H__42608CC2_ED74_11D4_92A3_940247F04F25__INCLUDED_) 6 | #define AFX_SEARCHLIST_H__42608CC2_ED74_11D4_92A3_940247F04F25__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | #include "SearchItem.h" 13 | #include 14 | 15 | class MoveNode; 16 | 17 | class SearchList 18 | { 19 | public: 20 | void Empty(); 21 | void purge(); 22 | 23 | void SetStart(SearchItem item); 24 | bool HasStart(); 25 | SearchItem* GetStart(); 26 | 27 | void Add(SearchItem item); 28 | void Add(SearchItem item1, SearchItem item2); 29 | void Clear(); 30 | void Clear(MoveNode* ptr); 31 | void replace(MoveNode* fromPtr, MoveNode* toPtr); 32 | 33 | SearchItem* Get(int nIndex); 34 | SearchItem* Current(); 35 | SearchItem* Next(); 36 | SearchItem* Previous(); 37 | 38 | bool IsEmpty() const; 39 | int LastItem() const; 40 | int CurrentIndex() const; 41 | 42 | enum Kind 43 | { 44 | NONE, 45 | MARK, 46 | MOVE, 47 | SIMILAR_POSITION, 48 | SAME_POSITION, 49 | COMMENT, 50 | BOARD_TEXT, 51 | MERGE_COMMENT 52 | }; 53 | 54 | void SetInfo(const CString& info, Kind SearchKind); 55 | CString GetInfo(); 56 | Kind GetKind(); 57 | 58 | public: 59 | SearchList(); 60 | virtual ~SearchList(); 61 | 62 | private: 63 | std::vector mTable; 64 | 65 | int mCurrent; 66 | CString mstrInfo; 67 | Kind mSearchKind; 68 | }; 69 | 70 | #endif // !defined(AFX_SEARCHLIST_H__42608CC2_ED74_11D4_92A3_940247F04F25__INCLUDED_) 71 | -------------------------------------------------------------------------------- /SearchMove.cpp: -------------------------------------------------------------------------------- 1 | // SearchMove.cpp : implementation file 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "RenLib.h" 6 | #include "SearchMove.h" 7 | 8 | #ifdef _DEBUG 9 | #define new DEBUG_NEW 10 | #undef THIS_FILE 11 | static char THIS_FILE[] = __FILE__; 12 | #endif 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | // SearchMove dialog 16 | 17 | 18 | SearchMove::SearchMove(CWnd* pParent /*=NULL*/) 19 | : CDialog(SearchMove::IDD, pParent) 20 | { 21 | //{{AFX_DATA_INIT(SearchMove) 22 | m_strMoveNo = _T(""); 23 | //}}AFX_DATA_INIT 24 | } 25 | 26 | 27 | void SearchMove::DoDataExchange(CDataExchange* pDX) 28 | { 29 | CDialog::DoDataExchange(pDX); 30 | //{{AFX_DATA_MAP(SearchMove) 31 | DDX_Text(pDX, IDC_MOVE_NO, m_strMoveNo); 32 | DDV_MaxChars(pDX, m_strMoveNo, 3); 33 | //}}AFX_DATA_MAP 34 | } 35 | 36 | 37 | BEGIN_MESSAGE_MAP(SearchMove, CDialog) 38 | //{{AFX_MSG_MAP(SearchMove) 39 | // NOTE: the ClassWizard will add message map macros here 40 | //}}AFX_MSG_MAP 41 | END_MESSAGE_MAP() 42 | 43 | ///////////////////////////////////////////////////////////////////////////// 44 | // SearchMove message handlers 45 | -------------------------------------------------------------------------------- /SearchMove.h: -------------------------------------------------------------------------------- 1 | #if !defined(AFX_SEARCH_MOVE_H__86B35E02_DF1B_11D4_92A3_D19AF614AD25__INCLUDED_) 2 | #define AFX_SEARCH_MOVE_H__86B35E02_DF1B_11D4_92A3_D19AF614AD25__INCLUDED_ 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif // _MSC_VER > 1000 7 | // SearchMove.h : header file 8 | // 9 | 10 | ///////////////////////////////////////////////////////////////////////////// 11 | // SearchMove dialog 12 | 13 | class SearchMove : public CDialog 14 | { 15 | // Construction 16 | public: 17 | SearchMove(CWnd* pParent = NULL); // standard constructor 18 | 19 | // Dialog Data 20 | //{{AFX_DATA(SearchMove) 21 | enum { IDD = IDD_SEARCH_MOVE }; 22 | CString m_strMoveNo; 23 | //}}AFX_DATA 24 | 25 | 26 | // Overrides 27 | // ClassWizard generated virtual function overrides 28 | //{{AFX_VIRTUAL(SearchMove) 29 | protected: 30 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 31 | //}}AFX_VIRTUAL 32 | 33 | // Implementation 34 | protected: 35 | 36 | // Generated message map functions 37 | //{{AFX_MSG(SearchMove) 38 | // NOTE: the ClassWizard will add member functions here 39 | //}}AFX_MSG 40 | DECLARE_MESSAGE_MAP() 41 | }; 42 | 43 | //{{AFX_INSERT_LOCATION}} 44 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 45 | 46 | #endif // !defined(AFX_SEARCH_MOVE_H__86B35E02_DF1B_11D4_92A3_D19AF614AD25__INCLUDED_) 47 | -------------------------------------------------------------------------------- /Sgf.h: -------------------------------------------------------------------------------- 1 | #if !defined(AFX_SGF_H__INCLUDED_) 2 | #define AFX_SGF_H__INCLUDED_ 3 | 4 | #include "Game.h" 5 | 6 | #if _MSC_VER > 1000 7 | #pragma once 8 | #endif // _MSC_VER > 1000 9 | 10 | class Sgf 11 | { 12 | public: 13 | Sgf(); 14 | 15 | bool OpenFile(const CString& strFile, bool multipleGames); 16 | 17 | Game& getGame(); 18 | CString getFilePath(); 19 | 20 | static bool equalComment(const CString& strComment1, const CString& strComment2); 21 | 22 | private: 23 | void Parse(); 24 | CString PreProcess(const CString& strContent); 25 | CString FindString(const CString& strContent, const CString& strBegin, const CString& strEnd); 26 | CString ParseCommand(const CString& strContent, const CString& strCmd); 27 | 28 | static void swapComment(CString& strComment); 29 | 30 | private: 31 | CStdioFile m_sgfFile; 32 | 33 | Game m_Game; 34 | CString m_strFilePath; 35 | bool mMultipleGames; 36 | }; 37 | 38 | #endif // !defined(AFX_SGF_H__INCLUDED_) 39 | -------------------------------------------------------------------------------- /Stack.cpp: -------------------------------------------------------------------------------- 1 | // Stack.cpp: implementation of the Stack class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "RenLib.h" 7 | #include "Stack.h" 8 | 9 | #ifdef _DEBUG 10 | #undef THIS_FILE 11 | static char THIS_FILE[]=__FILE__; 12 | #define new DEBUG_NEW 13 | #endif 14 | 15 | ////////////////////////////////////////////////////////////////////// 16 | // Construction/Destruction 17 | ////////////////////////////////////////////////////////////////////// 18 | 19 | Stack::Stack() : 20 | m_nIndex(0) 21 | { 22 | const Item NullItem = {0, NULL}; 23 | 24 | for (int i=0; i < SIZE; i++) 25 | { 26 | m_Stack[i] = NullItem; 27 | } 28 | } 29 | 30 | Stack::~Stack() 31 | { 32 | } 33 | 34 | bool Stack::IsEmpty() 35 | { 36 | return (m_nIndex == 0); 37 | } 38 | 39 | void Stack::Push(int nMove, MoveNode* pMove) 40 | { 41 | VERIFY(m_nIndex < SIZE); 42 | 43 | m_Stack[m_nIndex].nMove = nMove; 44 | m_Stack[m_nIndex].pMove = pMove; 45 | m_nIndex++; 46 | } 47 | 48 | void Stack::Pop(int& nMove, MoveNode*& pMove) 49 | { 50 | VERIFY(m_nIndex > 0); 51 | 52 | m_nIndex--; 53 | nMove = m_Stack[m_nIndex].nMove; 54 | pMove = m_Stack[m_nIndex].pMove; 55 | } 56 | 57 | void Stack::Push(MoveNode* pMove) 58 | { 59 | VERIFY(m_nIndex < SIZE); 60 | 61 | m_Stack[m_nIndex].nMove = 0; 62 | m_Stack[m_nIndex].pMove = pMove; 63 | m_nIndex++; 64 | } 65 | 66 | void Stack::Pop(MoveNode*& pMove) 67 | { 68 | VERIFY(m_nIndex > 0); 69 | 70 | m_nIndex--; 71 | pMove = m_Stack[m_nIndex].pMove; 72 | } 73 | 74 | void Stack::Push(int nMove) 75 | { 76 | VERIFY(m_nIndex < SIZE); 77 | 78 | m_Stack[m_nIndex].nMove = nMove; 79 | m_Stack[m_nIndex].pMove = NULL; 80 | 81 | m_nIndex++; 82 | } 83 | 84 | void Stack::Pop(int& nMove) 85 | { 86 | VERIFY(m_nIndex > 0); 87 | 88 | m_nIndex--; 89 | nMove = m_Stack[m_nIndex].nMove; 90 | } 91 | -------------------------------------------------------------------------------- /Stack.h: -------------------------------------------------------------------------------- 1 | // Stack.h: interface for the Stack class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_STACK_H__3C2C7482_F3BA_11D4_92A3_FE4B13876025__INCLUDED_) 6 | #define AFX_STACK_H__3C2C7482_F3BA_11D4_92A3_FE4B13876025__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | #include "MoveNode.h" 13 | 14 | class Stack 15 | { 16 | public: 17 | Stack(); 18 | virtual ~Stack(); 19 | 20 | bool IsEmpty(); 21 | 22 | void Push(int nMove, MoveNode* pMove); 23 | void Pop(int& nMove, MoveNode*& pMove); 24 | 25 | void Push(MoveNode* pMove); 26 | void Pop(MoveNode*& pMove); 27 | 28 | void Push(int nMove); 29 | void Pop(int& nMove); 30 | 31 | private: 32 | struct Item 33 | { 34 | int nMove; 35 | MoveNode* pMove; 36 | }; 37 | 38 | enum { SIZE = 225 }; 39 | Item m_Stack [SIZE]; 40 | int m_nIndex; 41 | }; 42 | 43 | #endif // !defined(AFX_STACK_H__3C2C7482_F3BA_11D4_92A3_FE4B13876025__INCLUDED_) 44 | -------------------------------------------------------------------------------- /StdAfx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // RenLib.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /StdAfx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #if !defined(AFX_STDAFX_H__72EC9D47_F85E_11D3_92A3_947F7AC2F525__INCLUDED_) 7 | #define AFX_STDAFX_H__72EC9D47_F85E_11D3_92A3_947F7AC2F525__INCLUDED_ 8 | 9 | #if _MSC_VER > 1000 10 | #pragma once 11 | #endif // _MSC_VER > 1000 12 | 13 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 14 | 15 | #include // MFC core and standard components 16 | #include // MFC extensions 17 | #include // MFC support for Internet Explorer 4 Common Controls 18 | #ifndef _AFX_NO_AFXCMN_SUPPORT 19 | #include // MFC support for Windows Common Controls 20 | #endif // _AFX_NO_AFXCMN_SUPPORT 21 | 22 | #include 23 | #include 24 | 25 | //{{AFX_INSERT_LOCATION}} 26 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 27 | 28 | #endif // !defined(AFX_STDAFX_H__72EC9D47_F85E_11D3_92A3_947F7AC2F525__INCLUDED_) 29 | -------------------------------------------------------------------------------- /StringEx.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // StringEx.h 3 | // 4 | 5 | #ifndef __STRINGEX_H_ 6 | #define __STRINGEX_H_ 7 | 8 | class CStringEx : public CString 9 | { 10 | public: 11 | CStringEx() : CString( ){}; 12 | CStringEx( const CString& stringSrc) : CString( stringSrc ){}; 13 | CStringEx( const CStringEx& stringSrc) : CString( stringSrc ){}; 14 | CStringEx( TCHAR ch, int nRepeat = 1 ) : CString( ch, nRepeat ){}; 15 | CStringEx( LPCTSTR lpch, int nLength ) : CString( lpch, nLength ){}; 16 | CStringEx( const unsigned char* psz ) : CString( psz ){}; 17 | CStringEx( LPCWSTR lpsz ) : CString( lpsz ){}; 18 | CStringEx( LPCSTR lpsz ) : CString( lpsz ){}; 19 | 20 | CStringEx& Insert(int pos, LPCTSTR s); 21 | CStringEx& Insert(int pos, TCHAR c); 22 | 23 | CStringEx& Delete(int pos, int len); 24 | CStringEx& Replace(int pos, int len, LPCTSTR s); 25 | 26 | int Find( TCHAR ch, int startpos = 0 ) const; 27 | int Find( LPCTSTR lpszSub, int startpos = 0 ) const; 28 | int FindNoCase( TCHAR ch, int startpos = 0 ) const; 29 | int FindNoCase( LPCTSTR lpszSub, int startpos = 0 ) const; 30 | 31 | int FindReplace( LPCTSTR lpszSub, LPCTSTR lpszReplaceWith, BOOL bGlobal = TRUE ); 32 | int FindReplaceNoCase( LPCTSTR lpszSub, LPCTSTR lpszReplaceWith, 33 | BOOL bGlobal = TRUE ); 34 | 35 | int ReverseFind( TCHAR ch ) const{ return CString::ReverseFind(ch);}; 36 | int ReverseFind( LPCTSTR lpszSub, int startpos = -1 ) const; 37 | int ReverseFindNoCase( TCHAR ch, int startpos = -1 ) const; 38 | int ReverseFindNoCase( LPCTSTR lpszSub, int startpos = -1 ) const; 39 | 40 | CStringEx GetField( LPCTSTR delim, int fieldnum); 41 | CStringEx GetField( TCHAR delim, int fieldnum); 42 | int GetFieldCount( LPCTSTR delim ); 43 | int GetFieldCount( TCHAR delim ); 44 | 45 | CStringEx GetDelimitedField( LPCTSTR delimStart, LPCTSTR delimEnd, 46 | int fieldnum = 0); 47 | }; 48 | 49 | 50 | #endif 51 | ///////////////////////////////////////////////////////////////////// 52 | -------------------------------------------------------------------------------- /TextBoard.cpp: -------------------------------------------------------------------------------- 1 | // TextBoard.cpp: implementation of the TextBoard class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "renlib.h" 7 | #include "TextBoard.h" 8 | #include "MoveList.h" 9 | #include "MoveNode.h" 10 | #include "Utils.h" 11 | 12 | #ifdef _DEBUG 13 | #undef THIS_FILE 14 | static char THIS_FILE[]=__FILE__; 15 | #define new DEBUG_NEW 16 | #endif 17 | 18 | const CString TextBoard::cHeader("----- Text Board -----"); 19 | 20 | namespace 21 | { 22 | const CString cPrefix(" "); 23 | } 24 | 25 | ////////////////////////////////////////////////////////////////////// 26 | // Construction/Destruction 27 | ////////////////////////////////////////////////////////////////////// 28 | 29 | TextBoard::TextBoard() 30 | { 31 | m_Board[ 0] = " X=Black O=White "; 32 | m_Board[ 1] = " "; 33 | m_Board[ 2] = " A B C D E F G H I J K L M N O "; 34 | m_Board[ 3] = " 15 . . . . . . . . . . . . . . . 15 "; 35 | m_Board[ 4] = " 14 . . . . . . . . . . . . . . . 14 "; 36 | m_Board[ 5] = " 13 . . . . . . . . . . . . . . . 13 "; 37 | m_Board[ 6] = " 12 . . . . . . . . . . . . . . . 12 "; 38 | m_Board[ 7] = " 11 . . . . . . . . . . . . . . . 11 "; 39 | m_Board[ 8] = " 10 . . . . . . . . . . . . . . . 10 "; 40 | m_Board[ 9] = " 9 . . . . . . . . . . . . . . . 9 "; 41 | m_Board[10] = " 8 . . . . . . . . . . . . . . . 8 "; 42 | m_Board[11] = " 7 . . . . . . . . . . . . . . . 7 "; 43 | m_Board[12] = " 6 . . . . . . . . . . . . . . . 6 "; 44 | m_Board[13] = " 5 . . . . . . . . . . . . . . . 5 "; 45 | m_Board[14] = " 4 . . . . . . . . . . . . . . . 4 "; 46 | m_Board[15] = " 3 . . . . . . . . . . . . . . . 3 "; 47 | m_Board[16] = " 2 . . . . . . . . . . . . . . . 2 "; 48 | m_Board[17] = " 1 . . . . . . . . . . . . . . . 1 "; 49 | m_Board[18] = " A B C D E F G H I J K L M N O "; 50 | 51 | m_strBoard.Empty(); 52 | } 53 | 54 | TextBoard::~TextBoard() 55 | { 56 | 57 | } 58 | 59 | void TextBoard::Create (const MoveList& aMoveList) 60 | { 61 | for (int i = 1; i <= aMoveList.Index(); i++) 62 | { 63 | CPoint Coord(aMoveList.Get(i)->getPos()); 64 | const int row = 2 + Coord.y; 65 | const int col = 2 + 2 * Coord.x; 66 | const TCHAR marker(i&1 ? 'X' : 'O'); 67 | m_Board[row].SetAt(col, marker); 68 | } 69 | 70 | for (i = 0; i < NOOFROWS; i++) 71 | { 72 | m_strBoard += m_Board[i] + TCHAR(10); 73 | } 74 | 75 | m_strBoard += cPrefix + cHeader; 76 | m_strBoard += TCHAR(10); 77 | m_strBoard += TCHAR(10); 78 | 79 | CString strFirst(aMoveList.Current()->getOneLineComment()); 80 | 81 | if (!strFirst.IsEmpty()) 82 | { 83 | m_strBoard += cPrefix + strFirst; 84 | m_strBoard += TCHAR(10); 85 | } 86 | 87 | for (i = 1; i <= aMoveList.Index(); i += 2) 88 | { 89 | CString strLine; 90 | 91 | CString strNum; 92 | strNum.Format("%3d ", i); 93 | strLine += strNum; 94 | 95 | CPoint Coord(aMoveList.Get(i)->getPos()); 96 | CString strMove(Utils::XCoordinateImage(Coord.x, true, false) + Utils::YCoordinateImage(Coord.y, true)); 97 | strMove.MakeUpper(); 98 | strLine += strMove + (strMove.GetLength() < 3 ? " " : ""); 99 | 100 | if (i+1 <= aMoveList.Index()) 101 | { 102 | CString strNum; 103 | strNum.Format("%5d ", i+1); 104 | strLine += strNum; 105 | 106 | CPoint Coord(aMoveList.Get(i+1)->getPos()); 107 | CString strMove(Utils::XCoordinateImage(Coord.x, true, false) + Utils::YCoordinateImage(Coord.y, true)); 108 | strMove.MakeUpper(); 109 | strLine += strMove; 110 | } 111 | 112 | m_strBoard += cPrefix + strLine + TCHAR(10); 113 | } 114 | 115 | m_strBoard += TCHAR(10); 116 | } 117 | 118 | bool TextBoard::Save(const CString& fileName) 119 | { 120 | if (!m_file.Open(fileName, CFile::modeCreate | CFile::modeWrite | CFile::typeText)) 121 | { 122 | CString strMessage(Utils::GetString(IDS_MSG_OPEN_FILE, fileName)); 123 | Utils::ShowMessage(strMessage, Utils::GetString(IDS_CAP_CREATE_TEXT_BOARD), MB_ICONERROR); 124 | return false; 125 | } 126 | 127 | m_file.WriteString(m_strBoard); 128 | m_file.Close(); 129 | 130 | return true; 131 | } 132 | -------------------------------------------------------------------------------- /TextBoard.h: -------------------------------------------------------------------------------- 1 | // TextBoard.h: interface for the TextBoard class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_TEXTBOARD_H__DEFEADC2_1E5E_11D6_92A3_0000E89F396C__INCLUDED_) 6 | #define AFX_TEXTBOARD_H__DEFEADC2_1E5E_11D6_92A3_0000E89F396C__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | class MoveList; 13 | 14 | class TextBoard 15 | { 16 | public: 17 | const static CString cHeader; 18 | 19 | TextBoard(); 20 | virtual ~TextBoard(); 21 | 22 | void Create(const MoveList& aMoveList); 23 | bool Save(const CString& fileName); 24 | 25 | private: 26 | enum { NOOFROWS = 20 }; 27 | 28 | CStdioFile m_file; 29 | CString m_Board[NOOFROWS]; 30 | CString m_strBoard; 31 | }; 32 | 33 | #endif // !defined(AFX_TEXTBOARD_H__DEFEADC2_1E5E_11D6_92A3_0000E89F396C__INCLUDED_) 34 | -------------------------------------------------------------------------------- /TextBoxDlg.cpp: -------------------------------------------------------------------------------- 1 | // TextBoxDlg.cpp : implementation file 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "renlib.h" 6 | #include "TextBoxDlg.h" 7 | #include "Utils.h" 8 | 9 | #ifdef _DEBUG 10 | #define new DEBUG_NEW 11 | #undef THIS_FILE 12 | static char THIS_FILE[] = __FILE__; 13 | #endif 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // TextBoxDlg dialog 17 | 18 | 19 | TextBoxDlg::TextBoxDlg(const CString& title, 20 | const CString& message, 21 | const CString& messageList) 22 | : CDialog(TextBoxDlg::IDD, NULL), 23 | mTitle(title), 24 | mMessage(message), 25 | mMessageList(messageList) 26 | { 27 | //{{AFX_DATA_INIT(TextBoxDlg) 28 | // NOTE: the ClassWizard will add member initialization here 29 | //}}AFX_DATA_INIT 30 | } 31 | 32 | 33 | void TextBoxDlg::DoDataExchange(CDataExchange* pDX) 34 | { 35 | CDialog::DoDataExchange(pDX); 36 | //{{AFX_DATA_MAP(TextBoxDlg) 37 | DDX_Control(pDX, IDC_TEXT_BOX_MSG, mMsg); 38 | DDX_Control(pDX, IDC_TEXT_BOX_ICON, mIcon); 39 | DDX_Control(pDX, IDC_TEXT_BOX_LIST_MSG, mListMsg); 40 | //}}AFX_DATA_MAP 41 | } 42 | 43 | 44 | BEGIN_MESSAGE_MAP(TextBoxDlg, CDialog) 45 | //{{AFX_MSG_MAP(TextBoxDlg) 46 | //}}AFX_MSG_MAP 47 | END_MESSAGE_MAP() 48 | 49 | ///////////////////////////////////////////////////////////////////////////// 50 | // TextBoxDlg message handlers 51 | 52 | BOOL TextBoxDlg::OnInitDialog() 53 | { 54 | CDialog::OnInitDialog(); 55 | 56 | SetWindowText(mTitle); 57 | mMsg.SetWindowText(mMessage); 58 | mListMsg.SetWindowText(mMessageList); 59 | 60 | mIcon.SetIcon(AfxGetApp()->LoadStandardIcon(IDI_EXCLAMATION)); 61 | 62 | // Transfer data from variables to controls 63 | UpdateData(FALSE); 64 | 65 | Utils::Beep(); 66 | 67 | return TRUE; // return TRUE unless you set the focus to a control 68 | // EXCEPTION: OCX Property Pages should return FALSE 69 | } 70 | -------------------------------------------------------------------------------- /TextBoxDlg.h: -------------------------------------------------------------------------------- 1 | #if !defined(AFX_TEXTBOXDLG_H__8EE17462_EE76_11D6_92A3_0000E89F396C__INCLUDED_) 2 | #define AFX_TEXTBOXDLG_H__8EE17462_EE76_11D6_92A3_0000E89F396C__INCLUDED_ 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif // _MSC_VER > 1000 7 | // TextBoxDlg.h : header file 8 | // 9 | 10 | ///////////////////////////////////////////////////////////////////////////// 11 | // TextBoxDlg dialog 12 | 13 | class TextBoxDlg : public CDialog 14 | { 15 | // Construction 16 | public: 17 | TextBoxDlg(const CString& title, 18 | const CString& message, 19 | const CString& messageList); 20 | 21 | // Dialog Data 22 | //{{AFX_DATA(TextBoxDlg) 23 | enum { IDD = IDD_TEXT_BOX_DIALOG }; 24 | CStatic mMsg; 25 | CStatic mIcon; 26 | CEdit mListMsg; 27 | //}}AFX_DATA 28 | 29 | // Overrides 30 | // ClassWizard generated virtual function overrides 31 | //{{AFX_VIRTUAL(TextBoxDlg) 32 | protected: 33 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 34 | //}}AFX_VIRTUAL 35 | 36 | // Implementation 37 | protected: 38 | 39 | // Generated message map functions 40 | //{{AFX_MSG(TextBoxDlg) 41 | virtual BOOL OnInitDialog(); 42 | //}}AFX_MSG 43 | DECLARE_MESSAGE_MAP() 44 | 45 | private: 46 | CString mTitle; 47 | CString mMessage; 48 | CString mMessageList; 49 | }; 50 | 51 | //{{AFX_INSERT_LOCATION}} 52 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 53 | 54 | #endif // !defined(AFX_TEXTBOXDLG_H__8EE17462_EE76_11D6_92A3_0000E89F396C__INCLUDED_) 55 | -------------------------------------------------------------------------------- /Tree.cpp: -------------------------------------------------------------------------------- 1 | // Tree.cpp: implementation of the Tree class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "Tree.h" 7 | 8 | #ifdef _DEBUG 9 | #undef THIS_FILE 10 | static char THIS_FILE[]=__FILE__; 11 | #define new DEBUG_NEW 12 | #endif 13 | 14 | ////////////////////////////////////////////////////////////////////// 15 | // Construction/Destruction 16 | ////////////////////////////////////////////////////////////////////// 17 | 18 | Tree::Tree() 19 | { 20 | } 21 | 22 | //--------------------------------------------------------------------------- 23 | 24 | Tree::~Tree() 25 | { 26 | } 27 | 28 | //------------------------------------------------------------------------ 29 | // End of File 30 | //------------------------------------------------------------------------ 31 | -------------------------------------------------------------------------------- /Tree.h: -------------------------------------------------------------------------------- 1 | // Tree.h: interface for the Tree class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_TREE_H__A1834CE2_EA10_11D4_92A3_B530E692AE25__INCLUDED_) 6 | #define AFX_TREE_H__A1834CE2_EA10_11D4_92A3_B530E692AE25__INCLUDED_ 7 | 8 | #include "Board.h" 9 | #include "Game.h" 10 | #include "Buf.h" 11 | #include "MoveNode.h" 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | class Tree 18 | { 19 | public: 20 | Tree(); 21 | virtual ~Tree(); 22 | }; 23 | 24 | #endif // !defined(AFX_TREE_H__A1834CE2_EA10_11D4_92A3_B530E692AE25__INCLUDED_) 25 | -------------------------------------------------------------------------------- /Utils.h: -------------------------------------------------------------------------------- 1 | // Utils.h: interface for the Utils class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_UTILS_H__7B941A41_0BA5_11D4_92A3_CEA74A1A6D25__INCLUDED_) 6 | #define AFX_UTILS_H__7B941A41_0BA5_11D4_92A3_CEA74A1A6D25__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | #include 13 | 14 | class Utils 15 | { 16 | public: 17 | enum FileType 18 | { 19 | NONE, 20 | RENLIB_LIBRARY, 21 | TEXT_GAME, 22 | POS, 23 | PDB, 24 | BDT, 25 | BUF, 26 | RENLIB_APPLET, 27 | RENARTIST_APPLET, 28 | RENJU_CLASS_DIAGRAM, 29 | BMP, 30 | GAME_COLLECTION 31 | }; 32 | 33 | public: 34 | Utils(); 35 | virtual ~Utils(); 36 | 37 | static int msb (BYTE ch); 38 | static bool bit_is_one (int bit_value, UINT value); 39 | static void clear_bit (int bit_value, UINT& value); 40 | static void set_bit (int bit_value, UINT& value); 41 | 42 | static bool exists (const CString& strFile); 43 | static void remove (const CString& strFile); 44 | static bool rename (const CString& strOldFileName, CString& strNewFileName); 45 | 46 | static void AsciiToWinChar (CString& strComment); 47 | static void WinCharToAscii (CString& strComment); 48 | 49 | static CString Center(CString strComment, int nChar); 50 | 51 | static bool IsSubstring(CString strString, CString strCheck); 52 | 53 | static bool OpenFileDialog(CString& strFile); 54 | static bool SavePositionDialog(CString& strFile, FileType& fileType); 55 | static bool SaveGameCollectionDialog(CString& strFile, FileType& fileType); 56 | static bool SaveLibraryDialog(CString& strFile, FileType& fileType); 57 | 58 | static CString GetExtension(const CString& strFile); 59 | static CString GetTitle(const CString& strFile); 60 | 61 | static bool IsExtensionLib(const CString& strFile); 62 | static bool IsExtensionTxt(const CString& strFile); 63 | static bool IsExtensionWzq(const CString& strFile); 64 | static bool IsExtensionBuf(const CString& strFile); 65 | static bool IsExtensionPdb(const CString& strFile); 66 | static bool IsExtensionPos(const CString& strFile); 67 | static bool IsExtensionRenjs(const CString& strFile); 68 | static bool IsExtensionHtml(const CString& strFile); 69 | static bool IsExtensionSgf(const CString& strFile); 70 | static bool IsExtensionBdt(const CString& strFile); 71 | static bool IsExtensionRdf(const CString& strFile); 72 | 73 | static bool IsExtensionAccepted(const CString& strFile); 74 | 75 | static void MakeExtensionLib(CString& strFile); 76 | static void MakeExtensionBak(CString& strFile); 77 | 78 | static bool OpenMultiFileDialog(CStringList& fileNameList); 79 | 80 | static bool OpenBmpDialog(CString& strFile, const CString& strDirectory); 81 | 82 | static bool StringToInteger(const CString& strInt, int& integer); 83 | 84 | static void Beep(); 85 | 86 | static CString GetString(UINT nIDPrompt); 87 | static CString GetString(UINT nIDPrompt, int nParam); 88 | static CString GetString(UINT nIDPrompt, int nParam1, int nParam2); 89 | static CString GetString(UINT nIDPrompt, const CString& strParam); 90 | static CString GetString(UINT nIDPrompt, int nParam, const CString& strParam); 91 | static CString GetString(UINT nIDPrompt, CPoint pntParam); 92 | static CString GetString(UINT nIDPrompt, const CString& strParam, int nParam1, int nParam2); 93 | static int ShowMessage(const CString& strMessage, const CString& strCaption, UINT nType); 94 | 95 | static CString XCoordinateImage(int x, bool AO, bool Falling); 96 | static CString YCoordinateImage(int y, bool Falling); 97 | 98 | static bool LessThan(CPoint Left, CPoint Right); 99 | 100 | static CPoint PosToPoint(int pos); 101 | static BYTE PointToPos(CPoint Point); 102 | static bool isValidPoint(CPoint Point); 103 | static bool isLessThan(CPoint Point1, CPoint Point2); 104 | 105 | static void Increment(CString& strText); 106 | 107 | static void CopyToClipboard(const CString& strText); 108 | static void PasteFromClipboard(CString& strText); 109 | 110 | static void trim(CString& strText); 111 | 112 | static void associateLib(); 113 | static void associateWzq(); 114 | static void associateBuf(); 115 | static void associatePdb(); 116 | static void associatePos(); 117 | static void associateRenjs(); 118 | static void associateSgf(); 119 | static void associateBdt(); 120 | static void associateRdf(); 121 | 122 | static CString getCurrentDirectory(); 123 | static CString getRenLibPath(); 124 | static CString getRenLibDirectory(); 125 | static CString getBitmapDirectory(); 126 | static CString getAppletDirectory(); 127 | 128 | static CString SelectDirectory(const CString& strCaption); 129 | 130 | static void SelectColor(COLORREF& color, COLORREF defaultColor, COLORREF* custColors); 131 | 132 | static CString ReadWebPage(const std::vector& webPages); 133 | static CString ReadWebPage(const CString& webPage); 134 | 135 | static bool StringToInt(const CString& strInt, long& intValue); 136 | static bool HexToInt(const TCHAR& hex, int& intValue); 137 | static bool IntToHex(const int intValue, TCHAR& hex); 138 | 139 | private: 140 | static bool OpenSaveDialog(CString& strFile, const std::vector& filter, const CString& strInitialDirectory); 141 | static bool IsExtension(const CString& strFile, const CString& strExt); 142 | static void MakeExtension(CString& strFile, const CString& strExt); 143 | static int isNumber(const CString& strNumber); 144 | static void Increment(TCHAR& ch0, TCHAR& ch1); 145 | static void associateFile(const CString& strExt); 146 | static std::vector getOpenFilter(); 147 | static void getSavePositionFilter(std::vector& filter, std::vector& fileTypes); 148 | static void getSaveGameCollectionFilter(std::vector& filter, std::vector& fileTypes); 149 | static void getSaveLibraryFilter(std::vector& filter, std::vector& fileTypes); 150 | static CString makeFilter(const std::vector& filter); 151 | static CString getFileName(const std::vector& filter, int& typeIndex, CString fileName); 152 | static void setExtension(CString& strFile, const CString& strExt); 153 | static int findExtension(const std::vector& filter, const CString& strExt); 154 | static bool SaveDialog(CString& strFile, FileType& fileType, std::vector& filter, std::vector& fileTypes); 155 | }; 156 | 157 | #endif // !defined(AFX_UTILS_H__7B941A41_0BA5_11D4_92A3_CEA74A1A6D25__INCLUDED_) 158 | -------------------------------------------------------------------------------- /Wzq.cpp: -------------------------------------------------------------------------------- 1 | // Wzq.cpp: implementation of the Wzq class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include "renlib.h" 7 | #include "Wzq.h" 8 | #include "Utils.h" 9 | 10 | #ifdef _DEBUG 11 | #undef THIS_FILE 12 | static char THIS_FILE[]=__FILE__; 13 | #define new DEBUG_NEW 14 | #endif 15 | 16 | ////////////////////////////////////////////////////////////////////// 17 | // Construction/Destruction 18 | ////////////////////////////////////////////////////////////////////// 19 | 20 | //-------------------------------------------------------------------- 21 | // const 22 | //-------------------------------------------------------------------- 23 | 24 | namespace 25 | { 26 | const Size = 1024; // Record Size 27 | } 28 | 29 | ////////////////////////////////////////////////////////////////////// 30 | // Construction/Destruction 31 | ////////////////////////////////////////////////////////////////////// 32 | 33 | Wzq::Wzq() 34 | : m_dwRead(0) 35 | { 36 | } 37 | 38 | //------------------------------------------------------------------------ 39 | 40 | Game& Wzq::getGame() 41 | { 42 | return m_Game; 43 | } 44 | 45 | //------------------------------------------------------------------------ 46 | 47 | CString Wzq::getComment() 48 | { 49 | return m_strComment; 50 | } 51 | 52 | //------------------------------------------------------------------------ 53 | 54 | CString Wzq::getFilePath() 55 | { 56 | return m_strFilePath; 57 | } 58 | 59 | //------------------------------------------------------------------------ 60 | 61 | bool Wzq::OpenFile(const CString& strFile) 62 | { 63 | CFileException e; 64 | 65 | if (!m_wzqFile.Open(strFile, CFile::modeRead, &e)) 66 | { 67 | return false; 68 | } 69 | 70 | m_strFilePath = m_wzqFile.GetFilePath(); 71 | 72 | Parse(); 73 | 74 | return true; 75 | } 76 | 77 | //------------------------------------------------------------------------ 78 | 79 | void Wzq::Parse() 80 | { 81 | const int nameIndex = 10; 82 | 83 | BYTE buffer[Size]; 84 | 85 | m_Game.clear(); 86 | 87 | m_strComment.Empty(); 88 | 89 | int index = 0; 90 | 91 | BYTE a5 = 0; 92 | BYTE b5 = 0; 93 | 94 | if (m_dwRead = m_wzqFile.Read(buffer, Size)) 95 | { 96 | // 97 | // Read player names 98 | // 99 | int nChar = buffer[nameIndex]; 100 | 101 | index = nameIndex + 1; 102 | 103 | for (int i=1; i <= nChar; i++) 104 | { 105 | m_strComment += buffer[index++]; 106 | } 107 | 108 | m_strComment += " - "; 109 | 110 | nChar = buffer[index++]; 111 | 112 | for (i=0; i < nChar; i++) 113 | { 114 | m_strComment += buffer[index++]; 115 | } 116 | 117 | for (i=index; i < (int)m_dwRead; i++) 118 | { 119 | if (buffer[i] == 0x70) 120 | { 121 | break; 122 | } 123 | } 124 | 125 | // 126 | // Read moves 127 | // 128 | for (; i < (int)m_dwRead; i++) 129 | { 130 | if (buffer[i] != 0) 131 | { 132 | BYTE data = buffer[i]; 133 | 134 | if (m_Game.numberOfMoves() == 4) 135 | { 136 | if (a5 == 0) 137 | { 138 | a5 = data; 139 | continue; 140 | } 141 | else if (b5 == 0) 142 | { 143 | b5 = data; 144 | continue; 145 | } 146 | else if (data == a5) 147 | { 148 | data = b5; 149 | } 150 | else 151 | { 152 | data = a5; 153 | } 154 | } 155 | 156 | int y = data % 15 + 1; 157 | int x = data / 15 + 1; 158 | 159 | m_Game.addPos((y-1) * 16 + x); 160 | } 161 | } 162 | } 163 | 164 | m_wzqFile.Close(); 165 | } 166 | 167 | //------------------------------------------------------------------------ 168 | -------------------------------------------------------------------------------- /Wzq.h: -------------------------------------------------------------------------------- 1 | // Wzq.h: interface for the Wzq class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_WZQ_H__8C09631B_E972_4EDA_8FDB_C8B62B8A58F7__INCLUDED_) 6 | #define AFX_WZQ_H__8C09631B_E972_4EDA_8FDB_C8B62B8A58F7__INCLUDED_ 7 | 8 | #include "Game.h" 9 | 10 | #if _MSC_VER > 1000 11 | #pragma once 12 | #endif // _MSC_VER > 1000 13 | 14 | class Wzq 15 | { 16 | public: 17 | Wzq(); 18 | 19 | bool OpenFile(const CString& strFile); 20 | 21 | Game& getGame(); 22 | CString getComment(); 23 | CString getFilePath(); 24 | 25 | private: 26 | void Parse(); 27 | 28 | private: 29 | CFile m_wzqFile; 30 | DWORD m_dwRead; 31 | 32 | Game m_Game; 33 | CString m_strComment; 34 | CString m_strFilePath; 35 | }; 36 | 37 | #endif // !defined(AFX_WZQ_H__8C09631B_E972_4EDA_8FDB_C8B62B8A58F7__INCLUDED_) 38 | -------------------------------------------------------------------------------- /applet/BlackWin.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/BlackWin.gif -------------------------------------------------------------------------------- /applet/Board.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/Board.class -------------------------------------------------------------------------------- /applet/Command.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/Command.class -------------------------------------------------------------------------------- /applet/Defs.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/Defs.class -------------------------------------------------------------------------------- /applet/Draw.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/Draw.gif -------------------------------------------------------------------------------- /applet/Move.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/Move.class -------------------------------------------------------------------------------- /applet/MultiLineComment.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/MultiLineComment.class -------------------------------------------------------------------------------- /applet/OneLineComment.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/OneLineComment.class -------------------------------------------------------------------------------- /applet/Parser.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/Parser.class -------------------------------------------------------------------------------- /applet/RenLibApplet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/RenLibApplet.class -------------------------------------------------------------------------------- /applet/Text.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/Text.class -------------------------------------------------------------------------------- /applet/Variant.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/Variant.class -------------------------------------------------------------------------------- /applet/WhiteWin.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/WhiteWin.gif -------------------------------------------------------------------------------- /applet/b.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/b.gif -------------------------------------------------------------------------------- /applet/black19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/black19.gif -------------------------------------------------------------------------------- /applet/black32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/black32.gif -------------------------------------------------------------------------------- /applet/board19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/board19.gif -------------------------------------------------------------------------------- /applet/board32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/board32.gif -------------------------------------------------------------------------------- /applet/index.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Example using RenLib applet. See applet parameters in html code. 5 | 6 | 7 | 8 |

Public Online Applet

9 | 10 | In view mode, the position is updated every 10 seconds from URL1 (see html source).
11 |
12 | 13 | 14 | alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason. Your browser is completely ignoring the <APPLET> tag!" 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |

Admin Online Applet

29 | 30 | In view mode, the position is updated every 15 seconds from URL1 (see html source).
31 | In Edit mode, the position can be updated and submitted to URL2 (see html source).
32 |
33 | 34 | 35 | alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason. Your browser is completely ignoring the <APPLET> tag!" 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /applet/w.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/w.gif -------------------------------------------------------------------------------- /applet/white19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/white19.gif -------------------------------------------------------------------------------- /applet/white32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/applet/white32.gif -------------------------------------------------------------------------------- /cgfiltyp.h: -------------------------------------------------------------------------------- 1 | //- ----------------------------------------------------------------- 2 | //- (C) Copyright 2000 Blake V. Miller 3 | //- All Rights Reserved. 4 | //- ----------------------------------------------------------------- 5 | //- File : CGFILTYP.H 6 | //- Author : Blake Miller 7 | //- Version : June 16, 2000 8 | //- Purpose : File Type Access 9 | //- ----------------------------------------------------------------- 10 | 11 | #if _MSC_VER > 1000 12 | #pragma once 13 | #endif 14 | 15 | #ifndef __CGFILTYP_H__ 16 | #define __CGFILTYP_H__ 17 | #ifdef __cplusplus 18 | 19 | class CGCFileTypeAccess : public CObject 20 | { 21 | DECLARE_DYNAMIC(CGCFileTypeAccess) 22 | 23 | public: 24 | 25 | CGCFileTypeAccess(); 26 | virtual ~CGCFileTypeAccess(); 27 | 28 | virtual void ClearAllData(void); 29 | 30 | //- ---------------------------------------- 31 | //- Effect Registry 32 | 33 | virtual BOOL RegSetAllInfo (void); 34 | 35 | virtual BOOL RegSetExtension (void); 36 | virtual BOOL RegSetDocumentType (void); 37 | virtual BOOL RegSetCLSID (void); 38 | virtual BOOL RegSetShellInfo (void); 39 | 40 | //- ---------------------------------------- 41 | //- Modify Member Variables 42 | 43 | void SetExtension (LPCTSTR); 44 | void GetExtension (CString&) const; 45 | 46 | void SetContentType (LPCTSTR); 47 | void GetContentType (CString&) const; 48 | 49 | void SetShellOpenCommand (LPCTSTR); 50 | void GetShellOpenCommand (CString&) const; 51 | 52 | void SetShellNewCommand (LPCTSTR); 53 | void GetShellNewCommand (CString&) const; 54 | 55 | void SetShellNewFileName (LPCTSTR); 56 | void GetShellNewFileName (CString&) const; 57 | 58 | void SetDocumentClassName (LPCTSTR); 59 | void GetDocumentClassName (CString&) const; 60 | 61 | void SetDocumentDescription (LPCTSTR); 62 | void GetDocumentDescription (CString&) const; 63 | 64 | void SetDocumentCLSID (LPCTSTR); 65 | void GetDocumentCLSID (CString&) const; 66 | 67 | void SetDocumentCurrentVersion (LPCTSTR); 68 | void GetDocumentCurrentVersion (CString&) const; 69 | 70 | void SetDocumentDefaultIcon (LPCTSTR); 71 | void GetDocumentDefaultIcon (CString&) const; 72 | 73 | void SetDocumentShellOpenCommand (LPCTSTR); 74 | void GetDocumentShellOpenCommand (CString&) const; 75 | 76 | protected: 77 | 78 | BOOL SetRegistryValue(HKEY, LPCTSTR, LPCTSTR, LPCTSTR); 79 | 80 | CString m_csExtension; 81 | CString m_csContentType; 82 | CString m_csShellOpenCommand; 83 | CString m_csShellNewCommand; 84 | CString m_csShellNewFileName; 85 | 86 | CString m_csDocumentClassName; 87 | CString m_csDocumentDescription; 88 | CString m_csDocumentCLSID; 89 | CString m_csDocumentCurrentVersion; 90 | CString m_csDocumentDefaultIcon; 91 | CString m_csDocumentShellOpenCommand; 92 | 93 | }; 94 | 95 | #endif // __cplusplus 96 | #endif // __CGFILTYP_H__ 97 | 98 | //- ----------------------------------------------------------------- 99 | //- END CGFILTYP.H Header File 100 | //- ----------------------------------------------------------------- 101 | -------------------------------------------------------------------------------- /res/InvalidBitmap.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/res/InvalidBitmap.bmp -------------------------------------------------------------------------------- /res/RenLib.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/res/RenLib.ico -------------------------------------------------------------------------------- /res/RenLib.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // RENLIB.RC2 - resources Microsoft Visual C++ does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by Microsoft Visual C++ 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | ///////////////////////////////////////////////////////////////////////////// 11 | // Add manually edited resources here... 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | -------------------------------------------------------------------------------- /res/RenLibDoc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/res/RenLibDoc.ico -------------------------------------------------------------------------------- /res/hand.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/res/hand.cur -------------------------------------------------------------------------------- /res/stoneBlackLarge.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/res/stoneBlackLarge.bmp -------------------------------------------------------------------------------- /res/stoneBlackSmall.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/res/stoneBlackSmall.bmp -------------------------------------------------------------------------------- /res/stoneBlackSmallMedium.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/res/stoneBlackSmallMedium.bmp -------------------------------------------------------------------------------- /res/stoneWhiteLarge.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/res/stoneWhiteLarge.bmp -------------------------------------------------------------------------------- /res/stoneWhiteMedium.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/res/stoneWhiteMedium.bmp -------------------------------------------------------------------------------- /res/stoneWhiteSmall.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/res/stoneWhiteSmall.bmp -------------------------------------------------------------------------------- /res/toolbaredit.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/res/toolbaredit.bmp -------------------------------------------------------------------------------- /res/toolbarfile.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/res/toolbarfile.bmp -------------------------------------------------------------------------------- /res/toolbarfind.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/res/toolbarfind.bmp -------------------------------------------------------------------------------- /res/toolbarmove.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/res/toolbarmove.bmp -------------------------------------------------------------------------------- /res/toolbarposition.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/res/toolbarposition.bmp -------------------------------------------------------------------------------- /res/vssver.scc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gomoku/RenLib/7a51509f6e73613f16c6df93c3db6c0b4800c85e/res/vssver.scc -------------------------------------------------------------------------------- /webbrowser2.h: -------------------------------------------------------------------------------- 1 | #if !defined(AFX_WEBBROWSER2_H__966109D9_F3D2_4FD0_8437_6F544E0AB9C9__INCLUDED_) 2 | #define AFX_WEBBROWSER2_H__966109D9_F3D2_4FD0_8437_6F544E0AB9C9__INCLUDED_ 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif // _MSC_VER > 1000 7 | // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++ 8 | 9 | // NOTE: Do not modify the contents of this file. If this class is regenerated by 10 | // Microsoft Visual C++, your modifications will be overwritten. 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | // CWebBrowser2 wrapper class 14 | 15 | class CWebBrowser2 : public CWnd 16 | { 17 | protected: 18 | DECLARE_DYNCREATE(CWebBrowser2) 19 | public: 20 | CLSID const& GetClsid() 21 | { 22 | static CLSID const clsid 23 | = { 0x8856f961, 0x340a, 0x11d0, { 0xa9, 0x6b, 0x0, 0xc0, 0x4f, 0xd7, 0x5, 0xa2 } }; 24 | return clsid; 25 | } 26 | virtual BOOL Create(LPCTSTR lpszClassName, 27 | LPCTSTR lpszWindowName, DWORD dwStyle, 28 | const RECT& rect, 29 | CWnd* pParentWnd, UINT nID, 30 | CCreateContext* pContext = NULL) 31 | { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID); } 32 | 33 | BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, 34 | const RECT& rect, CWnd* pParentWnd, UINT nID, 35 | CFile* pPersist = NULL, BOOL bStorage = FALSE, 36 | BSTR bstrLicKey = NULL) 37 | { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID, 38 | pPersist, bStorage, bstrLicKey); } 39 | 40 | // Attributes 41 | public: 42 | 43 | // Operations 44 | public: 45 | void GoBack(); 46 | void GoForward(); 47 | void GoHome(); 48 | void GoSearch(); 49 | void Navigate(LPCTSTR URL, VARIANT* Flags, VARIANT* TargetFrameName, VARIANT* PostData, VARIANT* Headers); 50 | void Refresh(); 51 | void Refresh2(VARIANT* Level); 52 | void Stop(); 53 | LPDISPATCH GetApplication(); 54 | LPDISPATCH GetParent(); 55 | LPDISPATCH GetContainer(); 56 | LPDISPATCH GetDocument(); 57 | BOOL GetTopLevelContainer(); 58 | CString GetType(); 59 | long GetLeft(); 60 | void SetLeft(long nNewValue); 61 | long GetTop(); 62 | void SetTop(long nNewValue); 63 | long GetWidth(); 64 | void SetWidth(long nNewValue); 65 | long GetHeight(); 66 | void SetHeight(long nNewValue); 67 | CString GetLocationName(); 68 | CString GetLocationURL(); 69 | BOOL GetBusy(); 70 | void Quit(); 71 | void ClientToWindow(long* pcx, long* pcy); 72 | void PutProperty(LPCTSTR Property_, const VARIANT& vtValue); 73 | VARIANT GetProperty_(LPCTSTR Property_); 74 | CString GetName(); 75 | long GetHwnd(); 76 | CString GetFullName(); 77 | CString GetPath(); 78 | BOOL GetVisible(); 79 | void SetVisible(BOOL bNewValue); 80 | BOOL GetStatusBar(); 81 | void SetStatusBar(BOOL bNewValue); 82 | CString GetStatusText(); 83 | void SetStatusText(LPCTSTR lpszNewValue); 84 | long GetToolBar(); 85 | void SetToolBar(long nNewValue); 86 | BOOL GetMenuBar(); 87 | void SetMenuBar(BOOL bNewValue); 88 | BOOL GetFullScreen(); 89 | void SetFullScreen(BOOL bNewValue); 90 | void Navigate2(VARIANT* URL, VARIANT* Flags, VARIANT* TargetFrameName, VARIANT* PostData, VARIANT* Headers); 91 | long QueryStatusWB(long cmdID); 92 | void ExecWB(long cmdID, long cmdexecopt, VARIANT* pvaIn, VARIANT* pvaOut); 93 | void ShowBrowserBar(VARIANT* pvaClsid, VARIANT* pvarShow, VARIANT* pvarSize); 94 | long GetReadyState(); 95 | BOOL GetOffline(); 96 | void SetOffline(BOOL bNewValue); 97 | BOOL GetSilent(); 98 | void SetSilent(BOOL bNewValue); 99 | BOOL GetRegisterAsBrowser(); 100 | void SetRegisterAsBrowser(BOOL bNewValue); 101 | BOOL GetRegisterAsDropTarget(); 102 | void SetRegisterAsDropTarget(BOOL bNewValue); 103 | BOOL GetTheaterMode(); 104 | void SetTheaterMode(BOOL bNewValue); 105 | BOOL GetAddressBar(); 106 | void SetAddressBar(BOOL bNewValue); 107 | BOOL GetResizable(); 108 | void SetResizable(BOOL bNewValue); 109 | }; 110 | 111 | //{{AFX_INSERT_LOCATION}} 112 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 113 | 114 | #endif // !defined(AFX_WEBBROWSER2_H__966109D9_F3D2_4FD0_8437_6F544E0AB9C9__INCLUDED_) 115 | --------------------------------------------------------------------------------