README.for.developers
1xmastermind by Florian Schintke <schintke@cs.tu-berlin.de>
2
3General:
4========
5
6We have a graphical application here. To provide portability to other
7widgetsets or operating systems, we introduced an abstraction from the
8Graphical User Interface (GUI) and the rest of the application.
9
10We have two interfaces (implemented by functions). One for the
11application to make output to the user, and another for the GUI to
12tell the application what the user has done. (mastermind.c calls
13functions from apptogui.h (for updating output) and guitoapp.c calls
14functions from mastermind.h (to tell the application what the user has
15done).
16
17Only a few source files use the functions from the used widgetset (yet
18xforms). At the time I wrote this, only two parts (guitoapp.c and
19apptogui.c) of the application call functions from the widgetset.
20apptogui.h provides functions to make graphical output for the other
21modules. So if you want to port the game to ncurses or something else
22you only have to reimplement the functions in the guitoapp.c and
23apptogui.c. Notice: You must not change the apptogui.h or guitoapp.h
24file for a port.
25
26The design of the GUI is made with fdesign. fdesign generates the
27sources mainwindowdesign.c, .h and .fd. Nobody changes this files by
28hand, because otherwise you can't change the design of the application
29with the tool fdesign later.
30
31It is not easy to seperate the GUI from the rest of the application.
32The sources mastermind.[ch] provides functions for the game like
33'user_entered_new_try', 'user_wants_new_game', or
34'user_wants_to_see_correct_solution'. The GUI (in mainwindowdesign.c)
35calls functions for user events implemented in guitoapp.[ch] and this
36functions call functions from mastermind.h. Then this service
37functions must calculate some things, update internal data structures
38and then call the right routines from the apptogui.h to provide the
39right output in the GUI.
40
41Try to do as few updates of the GUI as possible in GUI functions.
42(example: don't calculate the answer of a new input of the user in
43guitoapp and display it). Instead tell the mastermind.c what happened
44(by calling a function from mastermind.h) and wait for new
45instructions from there.
46
47All callback funtions (called if buttons pressed down etc.) must be
48defined in guitoapp.c. No sourcecode will include the headerfile
49guitoapp.h because nobody needs it. The only user of this functions is
50the automatically generated gui and this knows about this functions
51already.
52
53How does the application work?
54==============================
55
56The main program initializes some stuff and then gives the control to
57the GUI. If a user action occurs, the GUI calls a function from the
58game (a function from mastermind.h). When this function returns, the
59GUI is waiting for the next user action. When the user presses the
60Quit button the GUI returns to the main program and this causes the
61application to close.
62
63A function from the game (functions in mastermind.h), as described
64before, updates some data structures, makes some calculations and
65calls some functions from the GUI to update the display for the user
66and returns.
67
README.for.users
1xmastermind:
2============
3
4The computer calculates a combination of five characters (each between
5A and J) and you have to try to find out the combination the computer
6has calculated. Your questions to the computer are also combinations
7of five characters (each between A and J).
8
9You get sets of black and/or white blocks as answers to your
10questions.
11
12If you get a black block as answer it means that there is one
13character in your try at the correct position (but you don't know
14which one it is).
15
16If you get a white block as answer it means that there is a character
17in your guess that also occurs in the solution, but at another
18position (but you don't know which one it is and at which position it
19would be correct).
20
21Hint:
22=====
23
24If you want to change a character at a position you can do it in
25mainly two different ways.
26
27You can use the mouse. Therefore you have to click at the position and
28have to select a character from the choice you get.
29
30You can use the keyboard and the mouse. Therefore you move your mouse
31over the position you want to change and type the character you want
32to have with the keyboard. This type of input is case insensitive.
33
34