-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewHowTo.m
More file actions
81 lines (64 loc) · 3.02 KB
/
ViewHowTo.m
File metadata and controls
81 lines (64 loc) · 3.02 KB
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
classdef ViewHowTo < Component
% VIEWHOWTO Visualizes how to play and responds to relevant model events.
%
% Copyright 2023 The MathWorks, Inc.
properties ( Access = private )
Title (1,1) matlab.ui.control.Label
Rules (1,1) matlab.ui.control.Label
end
methods
function obj = ViewHowTo( model, namedArgs )
% VIEWHOWTO ViewHowTo constructor.
arguments
model (1,1) ModelMathWords
namedArgs.?ViewHowTo
end
% Call the superclass constructor
obj@Component( model )
% Set any user-specified properties
set( obj, namedArgs )
end
end
methods ( Access = protected )
function setup( obj )
% SETUP Initialize the how to play view.
g = uigridlayout( Parent=obj, ...
RowHeight=["1x" "9x"], ColumnWidth="1x" );
obj.Title = uilabel( Parent=g, Text="How to Play", ...
HorizontalAlignment="center", ...
FontName="Bookman Old Style", FontSize=24 );
[m,n] = size( obj.Model.Guesses );
list = ["<b>Goal:</b> guess the MathWord in "+m+" tries or less."; ""; "<ul>" + ...
"<li>Each guess must be a valid "+n+"-letter word or function.</li>" + ...
"<li>Each solution will be a core MATLAB function or method.</li>" + ...
"<li>Letter tiles will change color to show how " + ...
"close your guess was to the solution:</li></ul>"];
% see COMPAREWORDS for color order
colors = join( string( flip( 255*obj.Model.Colors ) ), "," );
key = "<p style='color:White;background-color:rgb(" + colors + ...
");border:1px solid Black;text-align:center;'>" + ...
["The letter is in the word and in the correct location."; ...
"The letter is in the word but in the wrong location."; ...
"The letter is not in the word in any location."] + "</p>";
obj.Rules = uilabel( Parent=g, Text=[list;key], WordWrap="on", ...
Interpreter = "html", VerticalAlignment="top", ...
FontName="Bookman Old Style", FontSize=16 );
end
function update( ~ )
% UPDATE Update the view. This method is empty
% because there are no public properties of the view.
end
function refresh( ~, ~, ~ )
% REFRESH Listener callback inherited from Component, but not used.
end
function letter( ~, ~, ~ )
% LETTER Listener callback inherited from Component, but not used.
end
function backspace( ~, ~, ~ )
% BACKSPACE Listener callback inherited from Component, but not used.
end
function enter( ~, ~, ~ )
% ENTER Listener callback inherited from Component, but not used.
end
end
end