forked from bdsword/MatlabGo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckhistory.m
104 lines (85 loc) · 3.16 KB
/
checkhistory.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
function varargout = checkhistory(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @checkhistory_OpeningFcn, ...
'gui_OutputFcn', @checkhistory_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function checkhistory_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
init
set(gcf,'CurrentAxes',handles.axes1);
imageData = imread('ChessBoard.jpg');
imageHandle = image(imageData);
hold on;
set(gca,'xtick',[],'ytick',[]);
axis square;
set(gcf,'CurrentAxes',handles.chessPaintBoard);
set(handles.chessPaintBoard,'xtick',[],'ytick',[]);
set(handles.chessPaintBoard,'color','none');
axis square;
set(handles.figure1,'name','Go!Go!Matlab! - Chess Log Reading Mode');
% bg image
pic_bg = imread('gamebg.png');
image(pic_bg,'parent',handles.axes_gmbg)
set(handles.axes_gmbg,'xtick',[],'ytick',[],'units','pixels','position',[0,0,950,690]);
%--- four image button and set button----
picBP = imread('back_page.png');
BPImhandles = image(picBP,'parent',handles.axesBackp);
set(handles.axesBackp,'xtick',[],'ytick',[]);
set(BPImhandles, 'ButtonDownFcn', @backPage_ClickFcn);
picBack = imread('back.png');
backImhandles = image(picBack,'parent',handles.axesBack);
set(handles.axesBack,'xtick',[],'ytick',[]);
set(backImhandles, 'ButtonDownFcn', @back_ClickFcn);
picNext = imread('next.png');
nextImhandles = image(picNext,'parent',handles.axesNext);
set(handles.axesNext,'xtick',[],'ytick',[]);
set(nextImhandles, 'ButtonDownFcn', @next_ClickFcn);
%------------------
handles.chessBoard = imageHandle;
guidata(hObject, handles);
if nargin<=3
warndlg('The sgf content is not correct.');
startpage
close(handles.figure1);
end
global history;
history = varargin{1};
logPointer %init the logPointer
function varargout = checkhistory_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function back_ClickFcn(hObject, eventdata)
global logPointer;
handles = guidata(hObject);
if logPointer>0
logPointer=logPointer-1;
updateToLogPointer(handles.chessPaintBoard);
end
function next_ClickFcn(hObject, eventdata)
global logPointer;
global history;
handles = guidata(hObject);
if logPointer<size(history,2)
logPointer=logPointer+1;
updateToLogPointer(handles.chessPaintBoard);
end
function backPage_ClickFcn(hObject, eventdata)
handles = guidata(hObject);
close(gcf)
startpage
%======================================
% --- Executes on mouse press over axes background.
function chessPaintBoard_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to chessPaintBoard (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)