Interface
IpuzClues
Description [src]
interface Ipuz.Clues : Ipuz.Grid
An interface to access and modify the clues of a crossword-like
puzzle. It is intended to be used with IpuzClue
clues
only, and will not work with other clue types.
Clue Sets
The IpuzClues
interface is organized around the concept of
clue sets. Clue sets have an ordered list of clues, and are
identified by an IpuzClueDirection
. In general, it’s
expected to have one clue set in a given physical direction. It is
possible to have multiple clue sets with the same direction, but
they must have different labels.
Here is an examples of adding clues to a standard crossword from scratch:
IpuzPuzzle *puzzle;
puzzle = ipuz_crossword_new ();
...
// Add across and down clue sets to a grid
ipuz_clues_clue_add_clue_set (IPUZ_CLUES (puzzle), IPUZ_CLUE_DIRECTION_ACROSS, NULL);
ipuz_clues_clue_add_clue_set (IPUZ_CLUES (puzzle), IPUZ_CLUE_DIRECTION_DOWN, NULL);
// Add a clue in the across direction
ipuz_clues_append_clue (IPUZ_CLUES (puzzle), IPUZ_CLUE_DIRECTION_ACROSS, clue);
Referring to clue sets
Clue sets are referred to by their direction. Here’s an example of creating a puzzle with two custom clue sets:
// This puzzle has two sets of clues, both spiraling in different directions
cw_direction = ipuz_clues_clue_add_clue_set (clues, IPUZ_CLUE_DIRECTION_CLUES, "Clockwise");
ccw_direction = ipuz_clues_clue_add_clue_set (clues, IPUZ_CLUE_DIRECTION_CLUES, "Counter Clockwise");
// Add a clue who's cells of spiral in the clockwise direction
ipuz_clues_append_clue (clues, cw_direction, clue);
In this example, the direction returned by
ipuz_clues_add_clue_set()
can be used to work with the clue
set later on. They will have different values. In addition,
ccw_direction
will have a value equal to or greater than
IpuzClueDirection
.
Itemizing clue sets
It is also possible to iterate through all the clue sets in a
puzzle. That can be done through a combination of
ipuz_clues_get_n_clue_sets()
and ipuz_clues_clue_set_get_dir()
.
g_print ("Puzzle has the following clue directions:\n")
for (guint i = 0; i < ipuz_clues_get_n_clue_sets (clues))
{
IpuzClueDirection direction;
const gchar *label;
direction = ipuz_clues_clue_set_get_dir (clues, i);
label = ipuz_clue_sets_get_direction (direction);
g_print ("\t%s\n", label);
}
Note
The index
of a clue set is not guaranteed to be stable and
should only be used to iterate through all clue sets. It
shouldn’t be used to refer to a clue set anywhere else.
Hiden Clue Sets
Most clue sets are displayed to the user. However, there are times
that it’s convenient to indicate the cells of clues without
revealing them to the users — such as with an alphabetical
crossword. In that instance, it’s useful to have a mirror of user
visible clues with a direction of IpuzClueDirection
.
By convention, these clues are never shown to the user.
Prerequisite
In order to implement Clues, your type must inherit fromIpuzGrid
.
Instance methods
ipuz_clues_add_clue_set
Adds a new clue set to clues
. This clue set will be in the
direction of direction
, and will be empty. If label
is set, then
it will set the label of the newly created clue set.
ipuz_clues_clue_guessed
Returns TRUE
if clue
has a user guess for every cell. If all the
user guesses are correct, then correct
is set to TRUE
as well.
ipuz_clues_get_clue_string_by_id
Returns a string containing the solution of the puzzle for a given clue. This string will have ‘?’ characters embedded within it if there are cells without solutions set yet.
ipuz_clues_get_guess_string_by_id
Returns a string containing the guess in the puzzle for a given clue. This string will have ‘?’ characters embedded within it if there are cells not completely filled out.
ipuz_clues_remove_clue_set
Removes the clue set in the direction of direction
. All the clues
associated with that clue set will be unreffed.
Interface structure
struct IpuzCluesInterface {
GTypeInterface g_iface;
IpuzClueDirection (* add_clue_set) (
IpuzClues* clues,
IpuzClueDirection direction,
const gchar* label
);
void (* remove_clue_set) (
IpuzClues* clues,
IpuzClueDirection direction
);
void (* clear_clue_sets) (
IpuzClues* clues
);
guint (* get_n_clue_sets) (
IpuzClues* clues
);
IpuzClueDirection (* clue_set_get_dir) (
IpuzClues* clues,
guint index
);
const gchar* (* clue_set_get_label) (
IpuzClues* clues,
IpuzClueDirection direction
);
GArray* (* get_clues) (
IpuzClues* clues,
IpuzClueDirection direction
);
void (* foreach_clue) (
IpuzClues* clues,
IpuzCluesForeachClueFunc func,
gpointer user_data
);
guint (* get_n_clues) (
IpuzClues* clues,
IpuzClueDirection direction
);
IpuzClue* (* get_clue_by_id) (
IpuzClues* clues,
IpuzClueId* clue_id
);
void (* remove_clue) (
IpuzClues* clues,
IpuzClue* clue
);
gboolean (* get_id_by_clue) (
IpuzClues* clues,
const IpuzClue* clue,
IpuzClueId* clue_id
);
gchar* (* get_clue_string_by_id) (
IpuzClues* clues,
IpuzClueId* clue_id
);
gchar* (* get_guess_string_by_id) (
IpuzClues* clues,
IpuzClueId* clue_id
);
gboolean (* clue_guessed) (
IpuzClues* clues,
IpuzClue* clue,
gboolean* correct
);
IpuzClue* (* find_clue_by_number) (
IpuzClues* clues,
IpuzClueDirection direction,
gint number
);
IpuzClue* (* find_clue_by_label) (
IpuzClues* clues,
IpuzClueDirection direction,
const char* label
);
IpuzClue* (* find_clue_by_coord) (
IpuzClues* clues,
IpuzClueDirection direction,
const IpuzCellCoord* coord
);
}
Interface members
g_iface |
|
No description available. | |
add_clue_set |
|
No description available. | |
remove_clue_set |
|
No description available. | |
clear_clue_sets |
|
No description available. | |
get_n_clue_sets |
|
No description available. | |
clue_set_get_dir |
|
No description available. | |
clue_set_get_label |
|
No description available. | |
get_clues |
|
No description available. | |
foreach_clue |
|
No description available. | |
get_n_clues |
|
No description available. | |
get_clue_by_id |
|
No description available. | |
remove_clue |
|
No description available. | |
get_id_by_clue |
|
No description available. | |
get_clue_string_by_id |
|
No description available. | |
get_guess_string_by_id |
|
No description available. | |
clue_guessed |
|
No description available. | |
find_clue_by_number |
|
No description available. | |
find_clue_by_label |
|
No description available. | |
find_clue_by_coord |
|
No description available. |
Virtual methods
Ipuz.Clues.add_clue_set
Adds a new clue set to clues
. This clue set will be in the
direction of direction
, and will be empty. If label
is set, then
it will set the label of the newly created clue set.
Ipuz.Clues.clue_guessed
Returns TRUE
if clue
has a user guess for every cell. If all the
user guesses are correct, then correct
is set to TRUE
as well.
Ipuz.Clues.get_clue_string_by_id
Returns a string containing the solution of the puzzle for a given clue. This string will have ‘?’ characters embedded within it if there are cells without solutions set yet.
Ipuz.Clues.get_guess_string_by_id
Returns a string containing the guess in the puzzle for a given clue. This string will have ‘?’ characters embedded within it if there are cells not completely filled out.
Ipuz.Clues.remove_clue_set
Removes the clue set in the direction of direction
. All the clues
associated with that clue set will be unreffed.